Skip to content

Commit 55a01bb

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 8eae150 commit 55a01bb

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
@@ -996,6 +996,39 @@ ibnd_port_t *ibnd_find_port_dr(ibnd_fabric_t * fabric, char *dr_str)
996996
return rc;
997997
}
998998

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

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)