[ofa-general] [PATCH] libibmad: add mad_rpc_class_agent() call

Sasha Khapyorsky sashak at voltaire.com
Wed Mar 11 03:54:42 PDT 2009


Add new thread safe mad_rpc_class_agent() class which gets port as
parameter. Deprecate old mad_class_agent() and convert its usage in
ibsysstat.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 infiniband-diags/src/ibsysstat.c  |    7 ++++---
 libibmad/include/infiniband/mad.h |    3 ++-
 libibmad/src/libibmad.map         |    1 +
 libibmad/src/rpc.c                |    9 ++++++++-
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/infiniband-diags/src/ibsysstat.c b/infiniband-diags/src/ibsysstat.c
index 8f879ae..03c0515 100644
--- a/infiniband-diags/src/ibsysstat.c
+++ b/infiniband-diags/src/ibsysstat.c
@@ -103,8 +103,9 @@ static int server_respond(void *umad, int size)
 	if (ibdebug > 1)
 		xdump(stderr, "mad respond pkt\n", mad, IB_MAD_SIZE);
 
-	if (umad_send(mad_rpc_portid(srcport), mad_class_agent(rpc.mgtclass), umad,
-		      size, rpc.timeout, 0) < 0) {
+	if (umad_send(mad_rpc_portid(srcport),
+		      mad_rpc_class_agent(srcport, rpc.mgtclass), umad, size,
+		      rpc.timeout, 0) < 0) {
 		DEBUG("send failed; %m");
 		return -1;
 	}
@@ -233,7 +234,7 @@ static char *ibsystat(ib_portid_t *portid, int attr)
 		IBPANIC("cannot build packet.");
 
 	fd = mad_rpc_portid(srcport);
-	agent = mad_class_agent(rpc.mgtclass);
+	agent = mad_rpc_class_agent(srcport, rpc.mgtclass);
 	timeout = ibd_timeout ? ibd_timeout : MAD_DEF_TIMEOUT_MS;
 
 	if (umad_send(fd, agent, buf, len, timeout, 0) < 0)
diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h
index 9b398fa..6611d9e 100644
--- a/libibmad/include/infiniband/mad.h
+++ b/libibmad/include/infiniband/mad.h
@@ -744,6 +744,7 @@ MAD_EXPORT void *mad_rpc_rmpp(const struct ibmad_port *srcport, ib_rpc_t * rpc,
 MAD_EXPORT int mad_rpc_portid(struct ibmad_port *srcport);
 MAD_EXPORT void mad_rpc_set_retries(struct ibmad_port *port, int retries);
 MAD_EXPORT void mad_rpc_set_timeout(struct ibmad_port *port, int timeout);
+MAD_EXPORT int mad_rpc_class_agent(struct ibmad_port *srcport, int cls);
 
 /* register.c */
 MAD_EXPORT int mad_register_port_client(int port_id, int mgmt,
@@ -760,7 +761,7 @@ MAD_EXPORT int mad_register_server_via(int mgmt, uint8_t rmpp_version,
 				long method_mask[16 / sizeof(long)],
 				uint32_t class_oui,
 				struct ibmad_port *srcport);
-MAD_EXPORT int mad_class_agent(int mgmt);
+MAD_EXPORT int mad_class_agent(int mgmt) DEPRECATED;
 
 /* serv.c */
 MAD_EXPORT int mad_send(ib_rpc_t * rpc, ib_portid_t * dport,
diff --git a/libibmad/src/libibmad.map b/libibmad/src/libibmad.map
index 10c7cd0..b7c2031 100644
--- a/libibmad/src/libibmad.map
+++ b/libibmad/src/libibmad.map
@@ -68,6 +68,7 @@ IBMAD_1.3 {
 		mad_rpc;
 		mad_rpc_rmpp;
 		mad_rpc_portid;
+		mad_rpc_class_agent;
 		mad_rpc_set_retries;
 		mad_rpc_set_timeout;
 		madrpc;
diff --git a/libibmad/src/rpc.c b/libibmad/src/rpc.c
index 3f3b7a2..233874b 100644
--- a/libibmad/src/rpc.c
+++ b/libibmad/src/rpc.c
@@ -109,7 +109,14 @@ int madrpc_portid(void)
 
 int mad_rpc_portid(struct ibmad_port *srcport)
 {
-	return (srcport->port_id);
+	return srcport->port_id;
+}
+
+int mad_rpc_class_agent(struct ibmad_port *port, int class)
+{
+	if (class < 1 || class > MAX_CLASS)
+		return -1;
+	return port->class_agents[class];
 }
 
 static int
-- 
1.6.1.2.319.gbd9e




More information about the general mailing list