aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/ulp
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2008-01-25 17:15:24 -0500
committerRoland Dreier <rolandd@cisco.com>2008-01-25 17:15:24 -0500
commitefcd99717f76c6d19dd81203c60fe198480de522 (patch)
tree684815ced67fd8443fe9e039cba4b4909c1f73ce /drivers/infiniband/ulp
parent7b3687df66cab4ecd6efb42cfa0c7de60cc4e3b9 (diff)
IPoIB/cm: Factor out ipoib_cm_free_rx_reap_list()
Factor out the code for going through the rx_reap list of struct ipoib_cm_rx and freeing each one. This consolidates the code duplicated between ipoib_cm_dev_stop() and ipoib_cm_rx_reap() and reduces the risk of error when adding additional accounting. Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 9edc9fc96210..75717a9cbcdc 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -673,10 +673,27 @@ err_cm:
673 return ret; 673 return ret;
674} 674}
675 675
676static void ipoib_cm_free_rx_reap_list(struct net_device *dev)
677{
678 struct ipoib_dev_priv *priv = netdev_priv(dev);
679 struct ipoib_cm_rx *rx, *n;
680 LIST_HEAD(list);
681
682 spin_lock_irq(&priv->lock);
683 list_splice_init(&priv->cm.rx_reap_list, &list);
684 spin_unlock_irq(&priv->lock);
685
686 list_for_each_entry_safe(rx, n, &list, list) {
687 ib_destroy_cm_id(rx->id);
688 ib_destroy_qp(rx->qp);
689 kfree(rx);
690 }
691}
692
676void ipoib_cm_dev_stop(struct net_device *dev) 693void ipoib_cm_dev_stop(struct net_device *dev)
677{ 694{
678 struct ipoib_dev_priv *priv = netdev_priv(dev); 695 struct ipoib_dev_priv *priv = netdev_priv(dev);
679 struct ipoib_cm_rx *p, *n; 696 struct ipoib_cm_rx *p;
680 unsigned long begin; 697 unsigned long begin;
681 LIST_HEAD(list); 698 LIST_HEAD(list);
682 int ret; 699 int ret;
@@ -722,15 +739,9 @@ void ipoib_cm_dev_stop(struct net_device *dev)
722 spin_lock_irq(&priv->lock); 739 spin_lock_irq(&priv->lock);
723 } 740 }
724 741
725 list_splice_init(&priv->cm.rx_reap_list, &list);
726
727 spin_unlock_irq(&priv->lock); 742 spin_unlock_irq(&priv->lock);
728 743
729 list_for_each_entry_safe(p, n, &list, list) { 744 ipoib_cm_free_rx_reap_list(dev);
730 ib_destroy_cm_id(p->id);
731 ib_destroy_qp(p->qp);
732 kfree(p);
733 }
734 745
735 cancel_delayed_work(&priv->cm.stale_task); 746 cancel_delayed_work(&priv->cm.stale_task);
736} 747}
@@ -1182,20 +1193,8 @@ void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb,
1182 1193
1183static void ipoib_cm_rx_reap(struct work_struct *work) 1194static void ipoib_cm_rx_reap(struct work_struct *work)
1184{ 1195{
1185 struct ipoib_dev_priv *priv = container_of(work, struct ipoib_dev_priv, 1196 ipoib_cm_free_rx_reap_list(container_of(work, struct ipoib_dev_priv,
1186 cm.rx_reap_task); 1197 cm.rx_reap_task)->dev);
1187 struct ipoib_cm_rx *p, *n;
1188 LIST_HEAD(list);
1189
1190 spin_lock_irq(&priv->lock);
1191 list_splice_init(&priv->cm.rx_reap_list, &list);
1192 spin_unlock_irq(&priv->lock);
1193
1194 list_for_each_entry_safe(p, n, &list, list) {
1195 ib_destroy_cm_id(p->id);
1196 ib_destroy_qp(p->qp);
1197 kfree(p);
1198 }
1199} 1198}
1200 1199
1201static void ipoib_cm_stale_task(struct work_struct *work) 1200static void ipoib_cm_stale_task(struct work_struct *work)