[ofa-general] [PATCH] opensm/vendor: use umad_get_issm_path() in osm_vendor_set_sm()

Sasha Khapyorsky sashak at voltaire.com
Thu Oct 18 07:03:41 PDT 2007


Instead of assuming undocumented feature that umad_open_port() will
return umad device number (which is not so anymore) use newly introduced
umad_get_issm_path() for real issm device name resolving.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/vendor/osm_vendor_ibumad.h |    1 +
 opensm/libvendor/osm_vendor_ibumad.c      |   34 +++++++++++++++++-----------
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/opensm/include/vendor/osm_vendor_ibumad.h b/opensm/include/vendor/osm_vendor_ibumad.h
index f86aeef..743b393 100644
--- a/opensm/include/vendor/osm_vendor_ibumad.h
+++ b/opensm/include/vendor/osm_vendor_ibumad.h
@@ -165,6 +165,7 @@ typedef struct _osm_vendor {
 	int umad_port_id;
 	void *receiver;
 	int issmfd;
+	char issm_path[256];
 } osm_vendor_t;
 
 #define OSM_BIND_INVALID_HANDLE 0
diff --git a/opensm/libvendor/osm_vendor_ibumad.c b/opensm/libvendor/osm_vendor_ibumad.c
index ca2e2c9..6d78573 100644
--- a/opensm/libvendor/osm_vendor_ibumad.c
+++ b/opensm/libvendor/osm_vendor_ibumad.c
@@ -828,6 +828,17 @@ osm_vendor_bind(IN osm_vendor_t * const p_vend,
 		goto Exit;
 	}
 
+	if (umad_get_issm_path(p_vend->umad_port.ca_name,
+			       p_vend->umad_port.portnum,
+			       p_vend->issm_path,
+			       sizeof(p_vend->issm_path)) < 0) {
+		osm_log(p_vend->p_log, OSM_LOG_ERROR,
+			"osm_vendor_bind: ERR 5424: "
+			"Cannot resolve issm path for port %s:%u\n",
+			p_vend->umad_port.ca_name, p_vend->umad_port.portnum);
+		goto Exit;
+	}
+
 	if (!(p_bind = malloc(sizeof(*p_bind)))) {
 		osm_log(p_vend->p_log, OSM_LOG_ERROR,
 			"osm_vendor_bind: ERR 5425: "
@@ -1164,27 +1175,24 @@ void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
 {
 	osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
 	osm_vendor_t *p_vend = p_bind->p_vend;
-	char issmstring[24];
 
 	OSM_LOG_ENTER(p_vend->p_log, osm_vendor_set_sm);
-	sprintf(issmstring, "/dev/infiniband/issm%d", p_vend->umad_port_id);
 	if (TRUE == is_sm_val) {
-		p_vend->issmfd = open(issmstring, O_NONBLOCK);
+		p_vend->issmfd = open(p_vend->issm_path, O_NONBLOCK);
 		if (p_vend->issmfd < 0) {
 			osm_log(p_vend->p_log, OSM_LOG_ERROR,
 				"osm_vendor_set_sm: ERR 5431: "
-				"setting IS_SM capability"
-				" mask failed; errno %d\n", errno);
+				"setting IS_SM capmask: cannot open file "
+				"\'%s\': %s\n",
+				p_vend->issm_path, strerror(errno));
 			p_vend->issmfd = -1;
 		}
-	} else {
-		if (p_vend->issmfd != -1) {
-			if (0 != close(p_vend->issmfd))
-				osm_log(p_vend->p_log, OSM_LOG_ERROR,
-					"osm_vendor_set_sm: ERR 5432: "
-					"clearing IS_SM capability"
-					" mask failed: errno %d\n", errno);
-		}
+	} else if (p_vend->issmfd != -1) {
+		if (0 != close(p_vend->issmfd))
+			osm_log(p_vend->p_log, OSM_LOG_ERROR,
+				"osm_vendor_set_sm: ERR 5432: "
+				"clearing IS_SM capmask: cannot close: %s\n",
+				strerror(errno));
 		p_vend->issmfd = -1;
 	}
 	OSM_LOG_EXIT(p_vend->p_log);
-- 
1.5.3.4.206.g58ba4




More information about the general mailing list