[openib-general] [PATCH] stored MAD timeout usage changes
Sean Hefty
mshefty at ichips.intel.com
Thu Oct 7 14:33:21 PDT 2004
This patch converts stored MAD timeouts from ms to jiffies and changes from keying off a non-zero timeout to using the MAD status value when handling errors and canceling MADs.
- Sean
Index: access/ib_mad_priv.h
===================================================================
--- access/ib_mad_priv.h (revision 956)
+++ access/ib_mad_priv.h (working copy)
@@ -120,7 +120,7 @@
struct ib_mad_agent *agent;
u64 wr_id; /* client WR ID */
u64 tid;
- int timeout;
+ unsigned long timeout;
int refcount;
enum ib_wc_status status;
};
Index: access/ib_mad.c
===================================================================
--- access/ib_mad.c (revision 956)
+++ access/ib_mad.c (working copy)
@@ -352,11 +352,10 @@
mad_send_wr->tid = send_wr->wr.ud.mad_hdr->tid;
mad_send_wr->agent = mad_agent;
+ /* Timeout will be updated after send completes. */
mad_send_wr->timeout = cur_send_wr->wr.ud.timeout_ms;
- if (mad_send_wr->timeout)
- mad_send_wr->refcount = 2;
- else
- mad_send_wr->refcount = 1;
+ /* One reference for each work request to QP + response. */
+ mad_send_wr->refcount = 1 + (mad_send_wr->timeout > 0);
mad_send_wr->status = IB_WC_SUCCESS;
/* Reference MAD agent until send completes */
@@ -787,14 +786,10 @@
list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list,
agent_list) {
-
- if (mad_send_wr->tid == tid) {
- /* Verify request is still valid */
- if (mad_send_wr->status == IB_WC_SUCCESS &&
- mad_send_wr->timeout)
- return mad_send_wr;
- else
- return NULL;
+ if (mad_send_wr->tid == tid && mad_send_wr->timeout) {
+ /* Verify request has not been canceled. */
+ return (mad_send_wr->status == IB_WC_SUCCESS) ?
+ mad_send_wr : NULL;
}
}
return NULL;
@@ -823,6 +818,7 @@
ib_free_recv_mad(&recv->header.recv_wc);
return;
}
+ /* Timeout = 0 means that we won't wait for a response. */
mad_send_wr->timeout = 0;
spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
@@ -951,12 +947,8 @@
spin_lock_irqsave(&mad_agent_priv->lock, flags);
if (mad_send_wc->status != IB_WC_SUCCESS &&
mad_send_wr->status == IB_WC_SUCCESS) {
-
mad_send_wr->status = mad_send_wc->status;
- if (mad_send_wr->timeout) {
- mad_send_wr->timeout = 0;
- mad_send_wr->refcount--;
- }
+ mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
}
/*
@@ -1077,17 +1069,14 @@
&mad_agent_priv->send_list, agent_list) {
if (mad_send_wr->status == IB_WC_SUCCESS)
- mad_send_wr->status = IB_WC_WR_FLUSH_ERR;
-
- if (mad_send_wr->timeout) {
- mad_send_wr->timeout = 0;
- mad_send_wr->refcount--;
- }
+ mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
if (mad_send_wr->refcount == 0) {
list_del(&mad_send_wr->agent_list);
list_add_tail(&mad_send_wr->agent_list,
&cancel_list);
+ } else {
+ mad_send_wr->status = IB_WC_WR_FLUSH_ERR;
}
}
spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
@@ -1142,14 +1131,10 @@
}
if (mad_send_wr->status == IB_WC_SUCCESS)
- mad_send_wr->status = IB_WC_WR_FLUSH_ERR;
-
- if (mad_send_wr->timeout) {
- mad_send_wr->timeout = 0;
- mad_send_wr->refcount--;
- }
+ mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
if (mad_send_wr->refcount != 0) {
+ mad_send_wr->status = IB_WC_WR_FLUSH_ERR;
spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
goto ret;
}
More information about the general
mailing list