[ofa-general] [PATCH] Add ib_resolve_gid_via and make portid an out only parameter of ib_resolve_portid_str_via

Ira Weiny weiny2 at llnl.gov
Tue Jul 21 13:56:03 PDT 2009


From: Ira Weiny <weiny2 at llnl.gov>
Date: Wed, 22 Apr 2009 17:12:58 -0700
Subject: [PATCH] Add ib_resolve_gid_via and make portid an out only parameter of ib_resolve_portid_str_via


Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 libibmad/include/infiniband/mad.h |    4 ++++
 libibmad/src/libibmad.map         |    1 +
 libibmad/src/resolve.c            |   27 +++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h
index bdf5158..ee004a9 100644
--- a/libibmad/include/infiniband/mad.h
+++ b/libibmad/include/infiniband/mad.h
@@ -724,6 +724,7 @@ enum MAD_DEST {
 	IB_DEST_DRPATH,
 	IB_DEST_GUID,
 	IB_DEST_DRSLID,
+	IB_DEST_GID
 };
 
 enum MAD_NODE_TYPE {
@@ -912,6 +913,9 @@ MAD_EXPORT int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
 MAD_EXPORT int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
 				   ib_portid_t * sm_id, int timeout,
 				   const struct ibmad_port *srcport);
+MAD_EXPORT int ib_resolve_gid_via(ib_portid_t * portid, ibmad_gid_t gid,
+				   ib_portid_t * sm_id, int timeout,
+				   const struct ibmad_port *srcport);
 MAD_EXPORT int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
 					 enum MAD_DEST dest, ib_portid_t * sm_id,
 					 const struct ibmad_port *srcport);
diff --git a/libibmad/src/libibmad.map b/libibmad/src/libibmad.map
index 7b49a4d..1462064 100644
--- a/libibmad/src/libibmad.map
+++ b/libibmad/src/libibmad.map
@@ -99,6 +99,7 @@ IBMAD_1.3 {
 		ib_path_query_via;
 		ib_resolve_smlid_via;
 		ib_resolve_guid_via;
+		ib_resolve_gid_via;
 		ib_resolve_portid_str_via;
 		ib_resolve_self_via;
 		mad_field_name;
diff --git a/libibmad/src/resolve.c b/libibmad/src/resolve.c
index 643c187..05b5602 100644
--- a/libibmad/src/resolve.c
+++ b/libibmad/src/resolve.c
@@ -70,6 +70,26 @@ int ib_resolve_smlid(ib_portid_t * sm_id, int timeout)
 	return ib_resolve_smlid_via(sm_id, timeout, ibmp);
 }
 
+int ib_resolve_gid_via(ib_portid_t * portid, ibmad_gid_t gid,
+			ib_portid_t * sm_id, int timeout,
+			const struct ibmad_port *srcport)
+{
+	ib_portid_t sm_portid;
+	char buf[IB_SA_DATA_SIZE] = { 0 };
+
+	if (!sm_id) {
+		sm_id = &sm_portid;
+		if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
+			return -1;
+	}
+
+	if ((portid->lid =
+	     ib_path_query_via(srcport, gid, gid, sm_id, buf)) < 0)
+		return -1;
+
+	return 0;
+}
+
 int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
 			ib_portid_t * sm_id, int timeout,
 			const struct ibmad_port *srcport)
@@ -112,12 +132,15 @@ int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
 			      enum MAD_DEST dest_type, ib_portid_t * sm_id,
 			      const struct ibmad_port *srcport)
 {
+	ibmad_gid_t gid;
 	uint64_t guid;
 	int lid;
 	char *routepath;
 	ib_portid_t selfportid = { 0 };
 	int selfport = 0;
 
+	memset(portid, 0, sizeof *portid);
+
 	switch (dest_type) {
 	case IB_DEST_LID:
 		lid = strtol(addr_str, 0, 0);
@@ -152,6 +175,10 @@ int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
 			return -1;
 		return 0;
 
+	case IB_DEST_GID:
+		if (inet_pton(AF_INET6, addr_str, &gid) <= 0)
+			return -1;
+		return ib_resolve_gid_via(portid, gid, sm_id, 0, srcport);
 	default:
 		IBWARN("bad dest_type %d", dest_type);
 	}
-- 
1.5.4.5




More information about the general mailing list