From: Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Vladimir Koushnir
<vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
"linux-rdma
(linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH infiniband-diags] Remove redundant umad file descriptor from libibnetdisc
Date: Mon, 13 Apr 2015 11:34:37 -0400 [thread overview]
Message-ID: <552BE20D.6080906@dev.mellanox.co.il> (raw)
From: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Date: Wed, 8 Apr 2015 12:29:44 +0300
Today, two umad SMP file descriptors are used in libibnetdisc.
One of them is needed only for retrieving LID of the local port
for combined routing.
The patch removes the need for 2 files descriptors by retrieving
LID of the local port in advance.
Signed-off-by: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
libibnetdisc/src/ibnetdisc.c | 34 +++++++++++++++++-----------------
libibnetdisc/src/internal.h | 1 -
2 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/libibnetdisc/src/ibnetdisc.c b/libibnetdisc/src/ibnetdisc.c
index e346905..e0f2d78 100644
--- a/libibnetdisc/src/ibnetdisc.c
+++ b/libibnetdisc/src/ibnetdisc.c
@@ -127,12 +127,6 @@ static int extend_dpath(smp_engine_t * engine, ib_portid_t * portid,
if (portid->lid) {
/* If we were LID routed we need to set up the drslid */
- if (!scan->selfportid.lid)
- if (ib_resolve_self_via(&scan->selfportid, NULL, NULL,
- scan->ibmad_port) < 0) {
- IBND_ERROR("Failed to resolve self\n");
- return -1;
- }
portid->drpath.drslid = (uint16_t) scan->selfportid.lid;
portid->drpath.drdlid = 0xFFFF;
}
@@ -712,6 +706,7 @@ ibnd_fabric_t *ibnd_discover_fabric(char * ca_name, int ca_port,
ib_portid_t my_portid = { 0 };
smp_engine_t engine;
ibnd_scan_t scan;
+ struct ibmad_port *ibmad_port;
int nc = 2;
int mc[2] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS };
@@ -735,20 +730,27 @@ ibnd_fabric_t *ibnd_discover_fabric(char * ca_name, int ca_port,
scan.cfg = &config;
scan.initial_hops = from->drpath.cnt;
- if (smp_engine_init(&engine, ca_name, ca_port, &scan, &config)) {
- free(f_int);
+ ibmad_port = mad_rpc_open_port(ca_name, ca_port, mc, nc);
+ if (!ibmad_port) {
+ IBND_ERROR("can't open MAD port (%s:%d)\n", ca_name, ca_port);
return (NULL);
}
+ mad_rpc_set_timeout(ibmad_port, cfg->timeout_ms);
+ mad_rpc_set_retries(ibmad_port, cfg->retries);
+ smp_mkey_set(ibmad_port, cfg->mkey);
- scan.ibmad_port = mad_rpc_open_port(ca_name, ca_port, mc, nc);
- if (!scan.ibmad_port) {
- IBND_ERROR("can't open MAD port (%s:%d)\n", ca_name, ca_port);
- smp_engine_destroy(&engine);
+ if (ib_resolve_self_via(&scan.selfportid,
+ NULL, NULL, ibmad_port) < 0) {
+ IBND_ERROR("Failed to resolve self\n");
+ mad_rpc_close_port(ibmad_port);
+ return NULL;
+ }
+ mad_rpc_close_port(ibmad_port);
+
+ if (smp_engine_init(&engine, ca_name, ca_port, &scan, &config)) {
+ free(f_int);
return (NULL);
}
- mad_rpc_set_timeout(scan.ibmad_port, cfg->timeout_ms);
- mad_rpc_set_retries(scan.ibmad_port, cfg->retries);
- smp_mkey_set(scan.ibmad_port, cfg->mkey);
IBND_DEBUG("from %s\n", portid2str(from));
@@ -763,11 +765,9 @@ ibnd_fabric_t *ibnd_discover_fabric(char * ca_name, int ca_port,
goto error;
smp_engine_destroy(&engine);
- mad_rpc_close_port(scan.ibmad_port);
return (ibnd_fabric_t *)f_int;
error:
smp_engine_destroy(&engine);
- mad_rpc_close_port(scan.ibmad_port);
ibnd_destroy_fabric(&f_int->fabric);
return NULL;
}
diff --git a/libibnetdisc/src/internal.h b/libibnetdisc/src/internal.h
index 1ccd29c..a50d2d7 100644
--- a/libibnetdisc/src/internal.h
+++ b/libibnetdisc/src/internal.h
@@ -71,7 +71,6 @@ typedef struct ibnd_scan {
ib_portid_t selfportid;
f_internal_t *f_int;
struct ibnd_config *cfg;
- struct ibmad_port *ibmad_port;
unsigned initial_hops;
} ibnd_scan_t;
--
1.7.8.2
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2015-04-13 15:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-13 15:34 Hal Rosenstock [this message]
[not found] ` <552BE20D.6080906-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-07-03 15:20 ` [PATCH infiniband-diags] Remove redundant umad file descriptor from libibnetdisc ira.weiny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=552BE20D.6080906@dev.mellanox.co.il \
--to=hal-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
--cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=vladimirk-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox