diff options
author | Roland Dreier <rolandd@cisco.com> | 2008-01-25 17:15:24 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-01-25 17:15:24 -0500 |
commit | 1efb61444ca3a598dfafb7a6c573c5d5d42d3432 (patch) | |
tree | bcc6fde51f22f89f9dc86f7555956ef245996896 /drivers/infiniband/ulp/ipoib/ipoib_cm.c | |
parent | 2337f80941ac22f747ce6fd2c7a79e91d911a3ce (diff) |
IPoIB/cm: Factor out ipoib_cm_free_rx_ring()
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>
Diffstat (limited to 'drivers/infiniband/ulp/ipoib/ipoib_cm.c')
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_cm.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 5d2da1676928..388f0413fcb7 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
@@ -155,6 +155,22 @@ partial_error: | |||
155 | return NULL; | 155 | return NULL; |
156 | } | 156 | } |
157 | 157 | ||
158 | static void ipoib_cm_free_rx_ring(struct net_device *dev, | ||
159 | struct ipoib_cm_rx_buf *rx_ring) | ||
160 | { | ||
161 | struct ipoib_dev_priv *priv = netdev_priv(dev); | ||
162 | int i; | ||
163 | |||
164 | for (i = 0; i < ipoib_recvq_size; ++i) | ||
165 | if (rx_ring[i].skb) { | ||
166 | ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1, | ||
167 | rx_ring[i].mapping); | ||
168 | dev_kfree_skb_any(rx_ring[i].skb); | ||
169 | } | ||
170 | |||
171 | kfree(rx_ring); | ||
172 | } | ||
173 | |||
158 | static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv *priv) | 174 | static void ipoib_cm_start_rx_drain(struct ipoib_dev_priv *priv) |
159 | { | 175 | { |
160 | struct ib_send_wr *bad_wr; | 176 | struct ib_send_wr *bad_wr; |
@@ -1328,7 +1344,7 @@ int ipoib_cm_dev_init(struct net_device *dev) | |||
1328 | void ipoib_cm_dev_cleanup(struct net_device *dev) | 1344 | void ipoib_cm_dev_cleanup(struct net_device *dev) |
1329 | { | 1345 | { |
1330 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 1346 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
1331 | int i, ret; | 1347 | int ret; |
1332 | 1348 | ||
1333 | if (!priv->cm.srq) | 1349 | if (!priv->cm.srq) |
1334 | return; | 1350 | return; |
@@ -1342,13 +1358,7 @@ void ipoib_cm_dev_cleanup(struct net_device *dev) | |||
1342 | priv->cm.srq = NULL; | 1358 | priv->cm.srq = NULL; |
1343 | if (!priv->cm.srq_ring) | 1359 | if (!priv->cm.srq_ring) |
1344 | return; | 1360 | return; |
1345 | for (i = 0; i < ipoib_recvq_size; ++i) | 1361 | |
1346 | if (priv->cm.srq_ring[i].skb) { | 1362 | ipoib_cm_free_rx_ring(dev, priv->cm.srq_ring); |
1347 | ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1, | ||
1348 | priv->cm.srq_ring[i].mapping); | ||
1349 | dev_kfree_skb_any(priv->cm.srq_ring[i].skb); | ||
1350 | priv->cm.srq_ring[i].skb = NULL; | ||
1351 | } | ||
1352 | kfree(priv->cm.srq_ring); | ||
1353 | priv->cm.srq_ring = NULL; | 1363 | priv->cm.srq_ring = NULL; |
1354 | } | 1364 | } |