Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added UMAD utilities for planarized fabrics, modified ibportstate to be compatible with planarized fabrics #1398

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions debian/libibnetdisc5.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ libibnetdisc.so.5 libibnetdisc5 #MINVER#
ibnd_dump_agg_linkspeedext@IBNETDISC_1.1 1.6.1
ibnd_dump_agg_linkspeedexten@IBNETDISC_1.1 1.6.1
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
1 change: 1 addition & 0 deletions infiniband-diags/ibdiag_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <infiniband/mad.h>
#include <util/iba_types.h>
#include <infiniband/ibnetdisc.h>
#include <infiniband/ibnetdisc_ext_umad.h>
#include <linux/types.h>

extern int ibverbose;
Expand Down
40 changes: 36 additions & 4 deletions infiniband-diags/ibportstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
Expand Down Expand Up @@ -436,6 +437,8 @@ int main(int argc, char **argv)
uint32_t vendorid, rem_vendorid;
uint16_t devid, rem_devid;
uint64_t val;
ext_umad_ca_t ext_ca = {};
bool is_planarized_fabric = false;
char *endp;
char usage_args[] = "<dest dr_path|lid|guid> <portnum> [<op>]\n"
"\nSupported ops: enable, disable, on, off, reset, speed, espeed, fdr10,\n"
Expand All @@ -455,22 +458,51 @@ int main(int argc, char **argv)
ibdiag_process_opts(argc, argv, NULL, NULL, NULL, NULL,
usage_args, usage_examples);

if (ibnd_ext_umad_get_ca_by_name(ibd_ca, ibd_ca_port, &ext_ca) < 0)
IBEXIT("Couldn't find the umad CA\n");
if (!ext_ca.gsi.name[0] || !ext_ca.smi.name[0])
IBEXIT("Invalid CA name found\n");

if (strncmp(ext_ca.gsi.name, ext_ca.smi.name, UMAD_CA_NAME_LEN))
is_planarized_fabric = true;

argc -= optind;
argv += optind;

if (argc < 2)
ibdiag_show_usage();

srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
// srcport should be an SMI port
srcport = mad_rpc_open_port(ext_ca.smi.name, ext_ca.smi.ports[0], mgmt_classes, 3);
if (!srcport)
IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
IBEXIT("Failed to open '%s' port '%d'", ext_ca.smi.name, ext_ca.smi.ports[0]);

smp_mkey_set(srcport, ibd_mkey);

if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
ibd_dest_type, ibd_sm_id, srcport) < 0)
if (resolve_portid_str(ext_ca.smi.name, ext_ca.smi.ports[0], &portid, argv[0],
ibd_dest_type, ibd_sm_id, srcport) < 0)
IBEXIT("can't resolve destination port %s", argv[0]);

if (is_planarized_fabric && (ibd_dest_type != IB_DEST_DRPATH)) {
int rc = 0;
struct ibnd_config config = {};

config.mkey = ibd_mkey;
config.timeout_ms = ibd_timeout;

ibnd_fabric_t *fabric = ibnd_discover_fabric(ext_ca.smi.name,
ext_ca.smi.ports[0], NULL, &config);

if (!fabric)
IBEXIT("Discovery failed");

rc = ibnd_convert_portid_to_dr(fabric, &portid, ibd_dest_type);
ibnd_destroy_fabric(fabric);

if (rc < 0)
IBEXIT("Couldn't convert destination port %s to direct route", argv[0]);
}

if (argc > 1)
portnum = strtol(argv[1], NULL, 0);

Expand Down
4 changes: 3 additions & 1 deletion libibnetdisc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
publish_headers(infiniband
ibnetdisc_ext_umad.h
ibnetdisc.h
ibnetdisc_osd.h
)

rdma_library(ibnetdisc libibnetdisc.map
# See Documentation/versioning.md
5 5.1.${PACKAGE_VERSION}
5 5.2.${PACKAGE_VERSION}
ibnetdisc_ext_umad.c
chassis.c
ibnetdisc.c
ibnetdisc_cache.c
Expand Down
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
Loading