Remove redundant umad file descriptor from libibnetdisc
PATCH 1/1 Remove redundant umad file descriptor from libibnetdisc
From: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/[email protected]>
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.
--- libibnetdisc/src/ibnetdisc.c | 34 +++++++++++++++++----------------- libibnetdisc/src/internal.h | 1 - 2 files changed, 17 insertions(+), 18 deletions(-)
libibnetdisc/src/ibnetdisc.c +17 -17
@@ -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 ; }
libibnetdisc/src/internal.h +0 -1
@@ -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;
Signature · 6 lines
1.7.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 552BE20D.6080906-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
ira.weiny
AppliedQuoted 7 lines · Hal Rosenstock
From: Vladimir Koushnir <vladimirk-VPRAkNaXOzVWk0Htik3J/[email protected]>
Date: Wed, 8 Apr 2015 12:29:44 +0300Today, 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.
Quoted 5 lines
The patch removes the need for 2 files descriptors by retrieving LID of the local port in advance.
Thanks applied,
Ira
Quoted 94 lines
--- libibnetdisc/src/ibnetdisc.c | 34 +++++++++++++++++----------------- libibnetdisc/src/internal.h | 1 - 2 files changed, 17 insertions(+), 18 deletions(-)libibnetdisc/src/ibnetdisc.c +17
-17@@ -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 ; }libibnetdisc/src/internal.h +0
-1@@ -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;Signature · 1 line
1.7.8.2
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html