Skip to content

Commit c307ee5

Browse files
authored
Merge pull request #1641 from mazorasaf/sa_get_handle_fix
infiniband-diags: Fix sa_get_handle to use smi/gsi API
2 parents 5df6832 + 26480ca commit c307ee5

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

infiniband-diags/ibdiag_sa.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
* the saquery tool and provides it to other utilities.
4949
*/
5050

51+
static struct ibmad_ports_pair *srcports;
52+
5153
struct sa_handle *sa_get_handle(char *ca_name)
5254
{
5355
struct sa_handle *handle;
@@ -57,7 +59,13 @@ struct sa_handle *sa_get_handle(char *ca_name)
5759

5860
char *name = ca_name ? ca_name : ibd_ca;
5961

60-
resolve_sm_portid(name, ibd_ca_port, &handle->dport);
62+
int mgmt_classes[1] = { IB_SA_CLASS };
63+
64+
srcports = mad_rpc_open_port2(name, ibd_ca_port, mgmt_classes, 1, 0);
65+
if (!srcports)
66+
IBEXIT("Failed to open '%s' port '%d'", name, ibd_ca_port);
67+
68+
resolve_sm_portid(srcports->gsi.ca_name, ibd_ca_port, &handle->dport);
6169
if (!handle->dport.lid) {
6270
IBWARN("No SM/SA found on port %s:%d",
6371
name ? "" : name,
@@ -69,20 +77,8 @@ struct sa_handle *sa_get_handle(char *ca_name)
6977
if (!handle->dport.qkey)
7078
handle->dport.qkey = IB_DEFAULT_QP1_QKEY;
7179

72-
handle->fd = umad_open_port(name, ibd_ca_port);
73-
if (handle->fd < 0) {
74-
IBWARN("umad_open_port on port %s:%d failed",
75-
name ? "" : name,
76-
ibd_ca_port);
77-
goto err;
78-
}
79-
if ((handle->agent = umad_register(handle->fd, IB_SA_CLASS, 2, 1, NULL)) < 0) {
80-
umad_close_port(handle->fd);
81-
IBWARN("umad_register for SA class failed on port %s:%d",
82-
name ? "" : name,
83-
ibd_ca_port);
84-
goto err;
85-
}
80+
handle->fd = mad_rpc_portid(srcports->gsi.port);
81+
handle->agent = mad_rpc_class_agent(srcports->gsi.port, IB_SA_CLASS);
8682

8783
return handle;
8884

@@ -94,7 +90,7 @@ struct sa_handle *sa_get_handle(char *ca_name)
9490
void sa_free_handle(struct sa_handle * h)
9591
{
9692
umad_unregister(h->fd, h->agent);
97-
umad_close_port(h->fd);
93+
mad_rpc_close_port2(srcports);
9894
free(h);
9995
}
10096

infiniband-diags/ibqueryerrors.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,10 +1124,12 @@ int main(int argc, char **argv)
11241124
ibd_ca, ibd_ca_port);
11251125
}
11261126

1127-
smp_mkey_set(ibmad_port, ibd_mkey);
1127+
smp_mkey_set(ibmad_ports->smi.port, ibd_mkey);
11281128

1129-
if (ibd_timeout)
1130-
mad_rpc_set_timeout(ibmad_port, ibd_timeout);
1129+
if (ibd_timeout) {
1130+
mad_rpc_set_timeout(ibmad_ports->smi.port, ibd_timeout);
1131+
mad_rpc_set_timeout(ibmad_ports->gsi.port, ibd_timeout);
1132+
}
11311133

11321134
if (port_guid_str) {
11331135
ibnd_port_t *ndport = ibnd_find_port_guid(fabric, port_guid);
@@ -1141,7 +1143,7 @@ int main(int argc, char **argv)
11411143

11421144
uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
11431145
if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0,
1144-
ibd_timeout, ibmad_port)) {
1146+
ibd_timeout, ibmad_ports->smi.port)) {
11451147
fprintf(stderr, "Failed to query local Node Info\n");
11461148
goto close_port;
11471149
}

0 commit comments

Comments
 (0)