[openib-general] [PATCH] [CM] synchronize canceling a MAD with completion processing
Sean Hefty
mshefty at ichips.intel.com
Thu Feb 24 14:45:44 PST 2005
This patch synchronizes the canceling of a MAD by the CM with the
processing of completions. The changes have not been committed as
they depend on the MAD layer patch.
Signed-off-by: Sean Hefty <sean.hefty at intel.com>
Index: infiniband/core/cm.c
===================================================================
--- infiniband/core/cm.c (revision 1905)
+++ infiniband/core/cm.c (working copy)
@@ -628,7 +628,6 @@ int ib_destroy_cm_id(struct ib_cm_id *cm
struct cm_id_private *cm_id_priv;
struct cm_work *work;
unsigned long flags;
- u64 wr_id;
cm_id_priv = container_of(cm_id, struct cm_id_private, id);
retest:
@@ -643,9 +642,9 @@ retest:
break;
case IB_CM_SIDR_REQ_SENT:
cm_id->state = IB_CM_IDLE;
- wr_id = (unsigned long) cm_id_priv->msg;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent,
+ (unsigned long) cm_id_priv->msg);
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, wr_id);
break;
case IB_CM_SIDR_REQ_RCVD:
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
@@ -1327,7 +1326,6 @@ static int cm_rep_handler(struct cm_work
struct cm_timewait_info *timewait_info;
struct cm_rep_msg *rep_msg;
unsigned long flags;
- u64 wr_id;
int ret;
rep_msg = (struct cm_rep_msg *)work->mad_recv_wc->recv_buf.mad;
@@ -1384,13 +1382,13 @@ static int cm_rep_handler(struct cm_work
/* todo: handle peer_to_peer */
- wr_id = (unsigned long) cm_id_priv->msg;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent,
+ (unsigned long) cm_id_priv->msg);
ret = atomic_inc_and_test(&cm_id_priv->work_count);
if (!ret)
list_add_tail(&work->list, &cm_id_priv->work_list);
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, wr_id);
if (ret)
cm_process_work(cm_id_priv, work);
else
@@ -1408,7 +1406,6 @@ static int cm_establish_handler(struct c
{
struct cm_id_private *cm_id_priv;
unsigned long flags;
- u64 wr_id;
int ret;
/* See comment in ib_cm_establish about lookup. */
@@ -1422,13 +1419,13 @@ static int cm_establish_handler(struct c
goto out;
}
- wr_id = (unsigned long) cm_id_priv->msg;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent,
+ (unsigned long) cm_id_priv->msg);
ret = atomic_inc_and_test(&cm_id_priv->work_count);
if (!ret)
list_add_tail(&work->list, &cm_id_priv->work_list);
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, wr_id);
if (ret)
cm_process_work(cm_id_priv, work);
else
@@ -1444,7 +1441,6 @@ static int cm_rtu_handler(struct cm_work
struct cm_id_private *cm_id_priv;
struct cm_rtu_msg *rtu_msg;
unsigned long flags;
- u64 wr_id;
int ret;
rtu_msg = (struct cm_rtu_msg *)work->mad_recv_wc->recv_buf.mad;
@@ -1463,13 +1459,13 @@ static int cm_rtu_handler(struct cm_work
}
cm_id_priv->id.state = IB_CM_ESTABLISHED;
- wr_id = (unsigned long) cm_id_priv->msg;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent,
+ (unsigned long) cm_id_priv->msg);
ret = atomic_inc_and_test(&cm_id_priv->work_count);
if (!ret)
list_add_tail(&work->list, &cm_id_priv->work_list);
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, wr_id);
if (ret)
cm_process_work(cm_id_priv, work);
else
@@ -1664,7 +1660,6 @@ static int cm_drep_handler(struct cm_wor
struct cm_id_private *cm_id_priv;
struct cm_drep_msg *drep_msg;
unsigned long flags;
- u64 wr_id;
int ret;
drep_msg = (struct cm_drep_msg *)work->mad_recv_wc->recv_buf.mad;
@@ -1683,14 +1678,13 @@ static int cm_drep_handler(struct cm_wor
}
cm_enter_timewait(cm_id_priv);
- wr_id = (unsigned long) cm_id_priv->msg;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent,
+ (unsigned long) cm_id_priv->msg);
ret = atomic_inc_and_test(&cm_id_priv->work_count);
if (!ret)
list_add_tail(&work->list, &cm_id_priv->work_list);
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, wr_id);
-
if (ret)
cm_process_work(cm_id_priv, work);
else
@@ -1842,7 +1836,6 @@ static int cm_rej_handler(struct cm_work
struct cm_id_private *cm_id_priv;
struct cm_rej_msg *rej_msg;
unsigned long flags;
- u64 wr_id = 0;
int ret;
rej_msg = (struct cm_rej_msg *)work->mad_recv_wc->recv_buf.mad;
@@ -1856,7 +1849,8 @@ static int cm_rej_handler(struct cm_work
switch (cm_id_priv->id.state) {
case IB_CM_REQ_SENT:
case IB_CM_REP_SENT:
- wr_id = (unsigned long) cm_id_priv->msg;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent,
+ (unsigned long) cm_id_priv->msg);
/* fall through */
case IB_CM_REQ_RCVD:
case IB_CM_MRA_REQ_SENT:
@@ -1868,7 +1862,8 @@ static int cm_rej_handler(struct cm_work
cm_reset_to_idle(cm_id_priv);
break;
case IB_CM_DREQ_SENT:
- wr_id = (unsigned long) cm_id_priv->msg;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent,
+ (unsigned long) cm_id_priv->msg);
/* fall through */
case IB_CM_REP_RCVD:
case IB_CM_MRA_REP_SENT:
@@ -1886,8 +1881,6 @@ static int cm_rej_handler(struct cm_work
list_add_tail(&work->list, &cm_id_priv->work_list);
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- if (wr_id)
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, wr_id);
if (ret)
cm_process_work(cm_id_priv, work);
else
@@ -2222,7 +2215,6 @@ static int cm_apr_handler(struct cm_work
struct cm_id_private *cm_id_priv;
struct cm_apr_msg *apr_msg;
unsigned long flags;
- u64 wr_id;
int ret;
apr_msg = (struct cm_apr_msg *)work->mad_recv_wc->recv_buf.mad;
@@ -2244,7 +2236,8 @@ static int cm_apr_handler(struct cm_work
goto out;
}
cm_id_priv->id.lap_state = IB_CM_LAP_IDLE;
- wr_id = (unsigned long) cm_id_priv->msg;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent,
+ (unsigned long) cm_id_priv->msg);
cm_id_priv->msg = NULL;
ret = atomic_inc_and_test(&cm_id_priv->work_count);
@@ -2252,8 +2245,6 @@ static int cm_apr_handler(struct cm_work
list_add_tail(&work->list, &cm_id_priv->work_list);
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, wr_id);
-
if (ret)
cm_process_work(cm_id_priv, work);
else
@@ -2546,10 +2537,10 @@ static int cm_sidr_rep_handler(struct cm
goto out;
}
cm_id_priv->id.state = IB_CM_IDLE;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
ib_cancel_mad(cm_id_priv->av.port->mad_agent,
(unsigned long) cm_id_priv->msg);
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
cm_format_sidr_rep_event(work);
cm_process_work(cm_id_priv, work);
return 0;
More information about the general
mailing list