[ofa-general] [PATCH] libibmad: make accessors function for retry values used in libibmad
Ira Weiny
weiny2 at llnl.gov
Thu Aug 6 16:01:07 PDT 2009
From: Ira Weiny <weiny2 at llnl.gov>
Date: Thu, 6 Aug 2009 15:27:30 -0700
Subject: [PATCH] libibmad: make accessors function for retry values used in libibmad
In addition use this function to determine the retries used throughout the library.
Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
libibmad/include/infiniband/mad.h | 1 +
libibmad/src/libibmad.map | 1 +
libibmad/src/mad.c | 5 +++++
libibmad/src/mad_internal.h | 1 +
libibmad/src/rpc.c | 12 +++---------
5 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h
index c5d73d5..0d0dcf1 100644
--- a/libibmad/include/infiniband/mad.h
+++ b/libibmad/include/infiniband/mad.h
@@ -804,6 +804,7 @@ 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);
MAD_EXPORT int mad_get_timeout(struct ibmad_port *srcport, int override_ms);
+MAD_EXPORT int mad_get_retries(struct ibmad_port *srcport);
/* register.c */
diff --git a/libibmad/src/libibmad.map b/libibmad/src/libibmad.map
index a8605b5..b9a890c 100644
--- a/libibmad/src/libibmad.map
+++ b/libibmad/src/libibmad.map
@@ -71,6 +71,7 @@ IBMAD_1.3 {
mad_rpc_set_retries;
mad_rpc_set_timeout;
mad_get_timeout;
+ mad_get_retries;
madrpc;
madrpc_def_timeout;
madrpc_init;
diff --git a/libibmad/src/mad.c b/libibmad/src/mad.c
index bc64a0f..7192dd6 100644
--- a/libibmad/src/mad.c
+++ b/libibmad/src/mad.c
@@ -70,6 +70,11 @@ int mad_get_timeout(struct ibmad_port *srcport, int override_ms)
srcport->timeout ? srcport->timeout : madrpc_timeout);
}
+int mad_get_retries(struct ibmad_port *srcport)
+{
+ return (srcport->retries ? srcport->retries : madrpc_retries);
+}
+
void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath, void *data)
{
int is_resp = rpc->method & IB_MAD_RESPONSE;
diff --git a/libibmad/src/mad_internal.h b/libibmad/src/mad_internal.h
index 7a16a46..475adfc 100644
--- a/libibmad/src/mad_internal.h
+++ b/libibmad/src/mad_internal.h
@@ -44,5 +44,6 @@ struct ibmad_port {
extern struct ibmad_port *ibmp;
extern int madrpc_timeout;
+extern int madrpc_retries;
#endif /* _MAD_INTERNAL_H_ */
diff --git a/libibmad/src/rpc.c b/libibmad/src/rpc.c
index bb83114..b5e4441 100644
--- a/libibmad/src/rpc.c
+++ b/libibmad/src/rpc.c
@@ -53,9 +53,9 @@ struct ibmad_port *ibmp = &mad_port;
static int iberrs;
+int madrpc_retries = MAD_DEF_RETRIES;
int madrpc_timeout = MAD_DEF_TIMEOUT_MS;
-static int madrpc_retries = MAD_DEF_RETRIES;
static void *save_mad;
static int save_mad_len = 256;
@@ -211,7 +211,6 @@ void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc,
{
int status, len;
uint8_t sndbuf[1024], rcvbuf[1024], *mad;
- int retries;
int redirect = 1;
while (redirect) {
@@ -221,12 +220,10 @@ void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc,
if ((len = mad_build_pkt(sndbuf, rpc, dport, 0, payload)) < 0)
return NULL;
- retries = port->retries ? port->retries : madrpc_retries;
-
if ((len = _do_madrpc(port->port_id, sndbuf, rcvbuf,
port->class_agents[rpc->mgtclass],
len, mad_get_timeout(port, rpc->timeout),
- retries)) < 0) {
+ mad_get_retries(port))) < 0) {
IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport));
return NULL;
}
@@ -267,7 +264,6 @@ void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc,
{
int status, len;
uint8_t sndbuf[1024], rcvbuf[1024], *mad;
- int retries;
memset(sndbuf, 0, umad_size() + IB_MAD_SIZE);
@@ -276,12 +272,10 @@ void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc,
if ((len = mad_build_pkt(sndbuf, rpc, dport, rmpp, data)) < 0)
return NULL;
- retries = port->retries ? port->retries : madrpc_retries;
-
if ((len = _do_madrpc(port->port_id, sndbuf, rcvbuf,
port->class_agents[rpc->mgtclass],
len, mad_get_timeout(port, rpc->timeout),
- retries)) < 0) {
+ mad_get_retries(port))) < 0) {
IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport));
return NULL;
}
--
1.5.4.5
More information about the general
mailing list