[openib-general] Re: [PATCH] ib_mad: prevent duplicate outstanding MADtransactions with same TID.

Michael S. Tsirkin mst at mellanox.co.il
Thu Jan 19 07:51:02 PST 2006


Quoting r. Jack Morgenstein <jackm at mellanox.co.il>:
> Subject: [PATCH] ib_mad: prevent duplicate outstanding MADtransactions with same TID.
> 
> Prevent multiple outstanding MAD transactions with the same TID.
> Could happen if duplicate requests are posted.
> 
> Signed-off-by: Jack Morgenstein <jackm at mellanox.co.il>

This patch was detecting an ack or nack as a duplicate of an rmpp request.
We only need to do checks for rmpp data packets. Here's a fixed patch:

---

Prevent issuing multiple MAD transactions with the same TID.
Could happen if duplicate requests are posted.

Signed-off-by: Jack Morgenstein <jackm at mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: latest/drivers/infiniband/core/mad.c
===================================================================
--- latest.orig/drivers/infiniband/core/mad.c	2006-01-16 18:19:55.000000000 +0200
+++ latest/drivers/infiniband/core/mad.c	2006-01-19 11:41:42.000000000 +0200
@@ -907,6 +907,20 @@
 	return ret;
 }
 
+static inline int is_rmpp_data(struct ib_mad *mad)
+{
+	/* check if has rmpp header */
+	if (mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_ADM &&
+	    (mad->mad_hdr.mgmt_class < IB_MGMT_CLASS_VENDOR_RANGE2_START ||
+	     mad->mad_hdr.mgmt_class > IB_MGMT_CLASS_VENDOR_RANGE2_END))
+		return 0;
+
+	return ((ib_get_rmpp_flags(&((struct ib_rmpp_mad *)mad)->rmpp_hdr) &
+		 IB_MGMT_RMPP_FLAG_ACTIVE) &&
+		((struct ib_rmpp_mad *)mad)->rmpp_hdr.rmpp_type ==
+		IB_MGMT_RMPP_TYPE_DATA);
+}
+
 /*
  * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated
  *  with the registered client
@@ -964,6 +979,13 @@
 		/* Reference MAD agent until send completes */
 		atomic_inc(&mad_agent_priv->refcount);
 		spin_lock_irqsave(&mad_agent_priv->lock, flags);
+		if (is_rmpp_data(send_buf->mad) &&
+		    ib_find_send_mad(mad_agent_priv, mad_send_wr->tid)) {
+			/* Duplicate send request */
+			spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+			atomic_dec(&mad_agent_priv->refcount);
+			return -EBUSY;
+		}
 		list_add_tail(&mad_send_wr->agent_list,
 			      &mad_agent_priv->send_list);
 		spin_unlock_irqrestore(&mad_agent_priv->lock, flags);


-- 
MST



More information about the general mailing list