Skip to content

Commit ae824f4

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 ec7f9b5 commit ae824f4

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

debian/libibnetdisc5.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ libibnetdisc.so.5 libibnetdisc5 #MINVER#
2929
ibnd_dump_agg_linkspeedextsup@IBNETDISC_1.1 1.6.1
3030
ibnd_ext_umad_get_cas@IBNETDISC_1.2 1.6.1
3131
ibnd_ext_umad_get_ca_by_name@IBNETDISC_1.2 1.6.1
32+
ibnd_convert_portid_to_dr@IBNETDISC_1.2 1.6.1

libibnetdisc/ibnetdisc.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,41 @@ ibnd_port_t *ibnd_find_port_dr(ibnd_fabric_t * fabric, char *dr_str)
996996
return rc;
997997
}
998998

999+
int ibnd_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+
1004+
if (dest_type == IB_DEST_DRPATH || dest_type == IB_DEST_DRSLID)
1005+
return 0;
1006+
// copy portid, reset all destination fields
1007+
memcpy(&new_portid, portid, sizeof(ib_portid_t));
1008+
new_portid.lid = 0;
1009+
memset(&new_portid.drpath, 0, sizeof(ib_dr_path_t));
1010+
if (!fabric)
1011+
return -1;
1012+
1013+
switch (dest_type) {
1014+
case IB_DEST_LID:
1015+
case IB_DEST_GID:
1016+
case IB_DEST_GUID:
1017+
found_port = ibnd_find_port_lid(fabric, portid->lid);
1018+
if (!found_port || !found_port->node)
1019+
return -1;
1020+
memcpy(&new_portid.drpath, &found_port->node->path_portid.drpath,
1021+
sizeof(ib_dr_path_t));
1022+
break;
1023+
case IB_DEST_DRPATH:
1024+
case IB_DEST_DRSLID:
1025+
return 0;
1026+
default:
1027+
return -1;
1028+
}
1029+
1030+
memcpy(portid, &new_portid, sizeof(ib_portid_t));
1031+
return 0;
1032+
}
1033+
9991034
void ibnd_iter_ports(ibnd_fabric_t * fabric, ibnd_iter_port_func_t func,
10001035
void *user_data)
10011036
{

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 ibnd_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: [input] 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
@@ -38,4 +38,5 @@ IBNETDISC_1.2 {
3838
global:
3939
ibnd_ext_umad_get_cas;
4040
ibnd_ext_umad_get_ca_by_name;
41+
ibnd_convert_portid_to_dr;
4142
} IBNETDISC_1.1;

0 commit comments

Comments
 (0)