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 19, 2023
1 parent 8eae150 commit 55a01bb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
33 changes: 33 additions & 0 deletions libibnetdisc/ibnetdisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,39 @@ ibnd_port_t *ibnd_find_port_dr(ibnd_fabric_t * fabric, char *dr_str)
return rc;
}

int 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 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: 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 @@ -18,6 +18,7 @@ IBNETDISC_1.0 {
ibnd_find_port_dr;
ibnd_find_port_lid;
ibnd_iter_ports;
convert_portid_to_dr;
ext_umad_get_cas;
ext_umad_get_ca_by_name;
local: *;
Expand Down

0 comments on commit 55a01bb

Please sign in to comment.