Skip to content

Commit

Permalink
Add a utility function that converts LID routed portid to direct route
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
anir-nvidia committed Oct 22, 2023
1 parent ec7f9b5 commit ae824f4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions debian/libibnetdisc5.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ libibnetdisc.so.5 libibnetdisc5 #MINVER#
ibnd_dump_agg_linkspeedextsup@IBNETDISC_1.1 1.6.1
ibnd_ext_umad_get_cas@IBNETDISC_1.2 1.6.1
ibnd_ext_umad_get_ca_by_name@IBNETDISC_1.2 1.6.1
ibnd_convert_portid_to_dr@IBNETDISC_1.2 1.6.1
35 changes: 35 additions & 0 deletions libibnetdisc/ibnetdisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,41 @@ ibnd_port_t *ibnd_find_port_dr(ibnd_fabric_t * fabric, char *dr_str)
return rc;
}

int ibnd_convert_portid_to_dr(ibnd_fabric_t *fabric, ib_portid_t *portid, enum MAD_DEST dest_type)
{
ibnd_port_t *found_port = NULL;
ib_portid_t new_portid;

if (dest_type == IB_DEST_DRPATH || dest_type == IB_DEST_DRSLID)
return 0;
// copy portid, reset all destination fields
memcpy(&new_portid, portid, sizeof(ib_portid_t));
new_portid.lid = 0;
memset(&new_portid.drpath, 0, sizeof(ib_dr_path_t));
if (!fabric)
return -1;

switch (dest_type) {
case IB_DEST_LID:
case IB_DEST_GID:
case IB_DEST_GUID:
found_port = ibnd_find_port_lid(fabric, portid->lid);
if (!found_port || !found_port->node)
return -1;
memcpy(&new_portid.drpath, &found_port->node->path_portid.drpath,
sizeof(ib_dr_path_t));
break;
case IB_DEST_DRPATH:
case IB_DEST_DRSLID:
return 0;
default:
return -1;
}

memcpy(portid, &new_portid, sizeof(ib_portid_t));
return 0;
}

void ibnd_iter_ports(ibnd_fabric_t * fabric, ibnd_iter_port_func_t func,
void *user_data)
{
Expand Down
12 changes: 12 additions & 0 deletions libibnetdisc/ibnetdisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ typedef void (*ibnd_iter_port_func_t) (ibnd_port_t * port, void *user_data);
void ibnd_iter_ports(ibnd_fabric_t *fabric, ibnd_iter_port_func_t func,
void *user_data);

/** =========================================================================
* Port operations
*/
int ibnd_convert_portid_to_dr(ibnd_fabric_t *fabric, ib_portid_t *portid, enum MAD_DEST dest_type);
/**
* Convert a portid's destination type to direct route.
*
* fabric: [input] discovered fabric
* portid: [input/output] portid object, to be converted to direct route
* dest_type: current destination type
*/

/** =========================================================================
* Chassis queries
*/
Expand Down
1 change: 1 addition & 0 deletions libibnetdisc/libibnetdisc.map
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ IBNETDISC_1.2 {
global:
ibnd_ext_umad_get_cas;
ibnd_ext_umad_get_ca_by_name;
ibnd_convert_portid_to_dr;
} IBNETDISC_1.1;

0 comments on commit ae824f4

Please sign in to comment.