Skip to content

Commit

Permalink
Demonstration for how to use new API in smpquery:
Browse files Browse the repository at this point in the history
We're getting SMI/GSI details and need to pass the relevant ibmad_port/CA name to the required methods depending if it is using SMI/GSI calls.
For example:
resolve_portid_str is using inside a GMP calls
(in case  dest_type is not IB_DEST_DRSLID) so we're passing it the gsi name and gsi port
smp_query_via is using SMP calls so we're passing it the smi port

Signed-off-by: Asaf Mazor <[email protected]>
  • Loading branch information
root authored and mazorasaf committed Dec 11, 2024
1 parent ed84a2e commit 29a5532
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions infiniband-diags/smpquery.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "ibdiag_common.h"

static struct ibmad_port *srcport;
static struct ibmad_ports_pair *srcports;

static op_fn_t node_desc, node_info, port_info, switch_info, pkey_table,
sl2vl_table, vlarb_table, guid_info, mlnx_ext_port_info, port_info_extended;
Expand Down Expand Up @@ -475,17 +476,19 @@ int main(int argc, char **argv)
if (!(fn = match_op(match_tbl, argv[0])))
IBEXIT("operation '%s' not supported", argv[0]);

srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
if (!srcport)
srcports = mad_rpc_open_port2(ibd_ca, ibd_ca_port, mgmt_classes, 3);
if (!srcports)
IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);

Check failure on line 482 in infiniband-diags/smpquery.c

View check run for this annotation

Azure Pipelines / linux-rdma.rdma-core (Build Compile Tests)

infiniband-diags/smpquery.c#L482

infiniband-diags/smpquery.c(482,): error TRAILING_WHITESPACE: trailing whitespace
srcport = srcports->smi.port;

smp_mkey_set(srcport, ibd_mkey);

node_name_map = open_node_name_map(node_name_map_file);

if (ibd_dest_type != IB_DEST_DRSLID) {
if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
ibd_dest_type, ibd_sm_id, srcport) < 0)
if (resolve_portid_str(srcports->gsi.ca_name, ibd_ca_port, &portid, argv[1],
ibd_dest_type, ibd_sm_id, srcports->gsi.port) < 0)
IBEXIT("can't resolve destination port %s", argv[1]);
if ((err = fn(&portid, argv + 2, argc - 2)))
IBEXIT("operation %s: %s", argv[0], err);
Expand All @@ -494,13 +497,13 @@ int main(int argc, char **argv)

memset(concat, 0, 64);
snprintf(concat, sizeof(concat), "%s %s", argv[1], argv[2]);
if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, concat,
if (resolve_portid_str(srcports->smi.ca_name, ibd_ca_port, &portid, concat,
ibd_dest_type, ibd_sm_id, srcport) < 0)
IBEXIT("can't resolve destination port %s", concat);
if ((err = fn(&portid, argv + 3, argc - 3)))
IBEXIT("operation %s: %s", argv[0], err);
}
close_node_name_map(node_name_map);
mad_rpc_close_port(srcport);
mad_rpc_close_port2(srcports);
exit(0);
}

0 comments on commit 29a5532

Please sign in to comment.