Skip to content

Commit f6b1ed0

Browse files
committed
Changed ibportstate to always send direct route SMPs on planarized fabrics.
ibportstate now checks if source CA is a planarized CA, and if so, uses direct route only. if the destination's direct route isn't given as argument, ibportstate will perform a fabric discovery to determine the direct route to the destination. Signed-off-by: Amir Nir <anir@nvidia.com>
1 parent ae824f4 commit f6b1ed0

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

infiniband-diags/ibportstate.c

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <stdio.h>
3737
#include <stdlib.h>
38+
#include <stdbool.h>
3839
#include <unistd.h>
3940
#include <string.h>
4041
#include <errno.h>
@@ -436,6 +437,8 @@ int main(int argc, char **argv)
436437
uint32_t vendorid, rem_vendorid;
437438
uint16_t devid, rem_devid;
438439
uint64_t val;
440+
ext_umad_ca_t ext_ca = {};
441+
bool is_planarized_fabric = false;
439442
char *endp;
440443
char usage_args[] = "<dest dr_path|lid|guid> <portnum> [<op>]\n"
441444
"\nSupported ops: enable, disable, on, off, reset, speed, espeed, fdr10,\n"
@@ -455,22 +458,51 @@ int main(int argc, char **argv)
455458
ibdiag_process_opts(argc, argv, NULL, NULL, NULL, NULL,
456459
usage_args, usage_examples);
457460

461+
if (ibnd_ext_umad_get_ca_by_name(ibd_ca, ibd_ca_port, &ext_ca) < 0)
462+
IBEXIT("Couldn't find the umad CA\n");
463+
if (!ext_ca.gsi.name[0] || !ext_ca.smi.name[0])
464+
IBEXIT("Invalid CA name found\n");
465+
466+
if (strncmp(ext_ca.gsi.name, ext_ca.smi.name, UMAD_CA_NAME_LEN))
467+
is_planarized_fabric = true;
468+
458469
argc -= optind;
459470
argv += optind;
460471

461472
if (argc < 2)
462473
ibdiag_show_usage();
463474

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

468480
smp_mkey_set(srcport, ibd_mkey);
469481

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

486+
if (is_planarized_fabric && (ibd_dest_type != IB_DEST_DRPATH)) {
487+
int rc = 0;
488+
struct ibnd_config config = {};
489+
490+
config.mkey = ibd_mkey;
491+
config.timeout_ms = ibd_timeout;
492+
493+
ibnd_fabric_t *fabric = ibnd_discover_fabric(ext_ca.smi.name,
494+
ext_ca.smi.ports[0], NULL, &config);
495+
496+
if (!fabric)
497+
IBEXIT("Discovery failed");
498+
499+
rc = ibnd_convert_portid_to_dr(fabric, &portid, ibd_dest_type);
500+
ibnd_destroy_fabric(fabric);
501+
502+
if (rc < 0)
503+
IBEXIT("Couldn't convert destination port %s to direct route", argv[0]);
504+
}
505+
474506
if (argc > 1)
475507
portnum = strtol(argv[1], NULL, 0);
476508

0 commit comments

Comments
 (0)