[ofa-general] Re: [PATCH] IB/ipoib: drain cq in dev_stop

Michael S. Tsirkin mst at dev.mellanox.co.il
Thu May 24 08:50:08 PDT 2007


> I'm still uncomfortable with the fact that ipoib_ib_dev_stop could cause
> packets to be passed up without poll being called. Is this OK?
> 
> It is possible we never saw problems in practice because the race window is
> small, but it seems that we should pass a flag to handle_rx_wc routines to have
> it drop all packets.  Roland, what do you think?

Maybe the following is needed on top of this patch?
Roland, what do you think?

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

---

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 8404f05..92a2655 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -165,7 +165,7 @@ static int ipoib_ib_post_receives(struct net_device *dev)
 	return 0;
 }
 
-static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
+static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc, int flush)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 	unsigned int wr_id = wc->wr_id & ~IPOIB_OP_RECV;
@@ -184,7 +184,7 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
 	skb  = priv->rx_ring[wr_id].skb;
 	addr = priv->rx_ring[wr_id].mapping;
 
-	if (unlikely(wc->status != IB_WC_SUCCESS)) {
+	if (unlikely(wc->status != IB_WC_SUCCESS || flush)) {
 		if (wc->status != IB_WC_WR_FLUSH_ERR)
 			ipoib_warn(priv, "failed recv event "
 				   "(status=%d, wrid=%d vend_err %x)\n",
@@ -302,11 +302,11 @@ int ipoib_poll(struct net_device *dev, int *budget)
 			if (wc->wr_id & IPOIB_CM_OP_SRQ) {
 				++done;
 				--max;
-				ipoib_cm_handle_rx_wc(dev, wc);
+				ipoib_cm_handle_rx_wc(dev, wc, 0);
 			} else if (wc->wr_id & IPOIB_OP_RECV) {
 				++done;
 				--max;
-				ipoib_ib_handle_rx_wc(dev, wc);
+				ipoib_ib_handle_rx_wc(dev, wc, 0);
 			} else
 				ipoib_ib_handle_tx_wc(dev, wc);
 		}
@@ -558,9 +558,9 @@ void ipoib_drain_cq(struct net_device *dev)
 		n = ib_poll_cq(priv->cq, IPOIB_NUM_WC, priv->ibwc);
 		for (i = 0; i < n; ++i) {
 			if (priv->ibwc[i].wr_id & IPOIB_CM_OP_SRQ)
-				ipoib_cm_handle_rx_wc(dev, priv->ibwc + i);
+				ipoib_cm_handle_rx_wc(dev, priv->ibwc + i, 1);
 			else if (priv->ibwc[i].wr_id & IPOIB_OP_RECV)
-				ipoib_ib_handle_rx_wc(dev, priv->ibwc + i);
+				ipoib_ib_handle_rx_wc(dev, priv->ibwc + i, 1);
 			else
 				ipoib_ib_handle_tx_wc(dev, priv->ibwc + i);
 		}
 


-- 
MST



More information about the general mailing list