Skip to content

Commit f26fc5a

Browse files
committed
Add a utility function that converts LID routed portid to direct route
In planarized fabrics, all SMPs must be sent by direct route. convert_portid_to_dr converts a portid object to direct route. Signed-off-by: Amir Nir <anir@nvidia.com>
1 parent af2c8b9 commit f26fc5a

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

libibnetdisc/ibnetdisc.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,39 @@ ibnd_port_t *ibnd_find_port_dr(ibnd_fabric_t * fabric, char *dr_str)
10031003
return rc;
10041004
}
10051005

1006+
int convert_portid_to_dr(ibnd_fabric_t *fabric, ib_portid_t *portid, enum MAD_DEST dest_type)
1007+
{
1008+
ibnd_port_t *found_port = NULL;
1009+
ib_portid_t new_portid;
1010+
if (dest_type == IB_DEST_DRPATH || dest_type == IB_DEST_DRSLID)
1011+
return 0;
1012+
// copy portid, reset all destination fields
1013+
memcpy(&new_portid, portid, sizeof(ib_portid_t));
1014+
new_portid.lid = 0;
1015+
memset(&new_portid.drpath, 0, sizeof(ib_dr_path_t));
1016+
if (!fabric)
1017+
return -1;
1018+
1019+
switch (dest_type) {
1020+
case IB_DEST_LID:
1021+
case IB_DEST_GID:
1022+
case IB_DEST_GUID:
1023+
found_port = ibnd_find_port_lid(fabric, portid->lid);
1024+
if (!found_port || !found_port->node)
1025+
return -1;
1026+
memcpy(&new_portid.drpath, &found_port->node->path_portid.drpath, sizeof(ib_dr_path_t));
1027+
break;
1028+
case IB_DEST_DRPATH:
1029+
case IB_DEST_DRSLID:
1030+
return 0;
1031+
default:
1032+
return -1;
1033+
}
1034+
1035+
memcpy(portid, &new_portid, sizeof(ib_portid_t));
1036+
return 0;
1037+
}
1038+
10061039
void ibnd_iter_ports(ibnd_fabric_t * fabric, ibnd_iter_port_func_t func,
10071040
void *user_data)
10081041
{

libibnetdisc/ibnetdisc.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ typedef void (*ibnd_iter_port_func_t) (ibnd_port_t * port, void *user_data);
228228
void ibnd_iter_ports(ibnd_fabric_t *fabric, ibnd_iter_port_func_t func,
229229
void *user_data);
230230

231+
/** =========================================================================
232+
* Port operations
233+
*/
234+
int convert_portid_to_dr(ibnd_fabric_t *fabric, ib_portid_t *portid, enum MAD_DEST dest_type);
235+
/**
236+
* Convert a portid's destination type to direct route.
237+
*
238+
* fabric: discovered fabric
239+
* portid: input/output portid object, to be converted to direct route
240+
* dest_type: current destination type
241+
*/
242+
231243
/** =========================================================================
232244
* Chassis queries
233245
*/

libibnetdisc/libibnetdisc.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ IBNETDISC_1.0 {
1818
ibnd_find_port_dr;
1919
ibnd_find_port_lid;
2020
ibnd_iter_ports;
21+
convert_portid_to_dr;
2122
ext_umad_get_cas;
2223
ext_umad_get_ca_by_name;
2324
local: *;

0 commit comments

Comments
 (0)