IPoIB/cm: Factor out ipoib_cm_free_rx_ring()
authorRoland Dreier <rolandd@cisco.com>
Fri, 25 Jan 2008 22:15:24 +0000 (14:15 -0800)
committerRoland Dreier <rolandd@cisco.com>
Fri, 25 Jan 2008 22:15:24 +0000 (14:15 -0800)
Factor out the code to unmap/free skbs and free the receive ring in
ipoib_cm_dev_cleanup() into a new function ipoib_cm_free_rx_ring().
This function will be called from a couple of other places when
support for devices that don't implement SRQs is added.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/ulp/ipoib/ipoib_cm.c

index 5d2da16769287a8b29b25940bd7369f4d4ce3c39..388f0413fcb70da48f5f06af92e3a5f552db003b 100644 (file)
@@ -155,6 +155,22 @@ partial_error:
        return NULL;
 }
 
+static void ipoib_cm_free_rx_ring(struct net_device *dev,
+                                 struct ipoib_cm_rx_buf *rx_ring)
+{
+       struct ipoib_dev_priv *priv = netdev_priv(dev);
+       int i;
+
+       for (i = 0; i < ipoib_recvq_size; ++i)
+               if (rx_ring[i].skb) {
+                       ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1,
+                                             rx_ring[i].mapping);
+                       dev_kfree_skb_any(rx_ring[i].skb);
+               }
+
+       kfree(rx_ring);
+}
+
 static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv *priv)
 {
        struct ib_send_wr *bad_wr;
@@ -1328,7 +1344,7 @@ int ipoib_cm_dev_init(struct net_device *dev)
 void ipoib_cm_dev_cleanup(struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = netdev_priv(dev);
-       int i, ret;
+       int ret;
 
        if (!priv->cm.srq)
                return;
@@ -1342,13 +1358,7 @@ void ipoib_cm_dev_cleanup(struct net_device *dev)
        priv->cm.srq = NULL;
        if (!priv->cm.srq_ring)
                return;
-       for (i = 0; i < ipoib_recvq_size; ++i)
-               if (priv->cm.srq_ring[i].skb) {
-                       ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1,
-                                             priv->cm.srq_ring[i].mapping);
-                       dev_kfree_skb_any(priv->cm.srq_ring[i].skb);
-                       priv->cm.srq_ring[i].skb = NULL;
-               }
-       kfree(priv->cm.srq_ring);
+
+       ipoib_cm_free_rx_ring(dev, priv->cm.srq_ring);
        priv->cm.srq_ring = NULL;
 }