diff mbox

[1/2] ipoib mcast sendonly join: Isolate common list remove code

Message ID 20151211181724.185428150@linux.com (mailing list archive)
State Superseded
Headers show

Commit Message

Christoph Lameter (Ampere) Dec. 11, 2015, 6:16 p.m. UTC
Code cleanup to remove multicast specific code from ipoib_main.c

The removal of a list of multicast groups occurs in three places.
Create a new function ipoib_mcast_remove_list(). Use this new
function in ipoib_main.c too.
That in turn allows the dropping of two functions that were
exported from ipoib_multicast.c for expiration of mc groups.

Signed-off-by: Christoph Lameter <cl@linux.com>
---
 drivers/infiniband/ulp/ipoib/ipoib.h           |  3 +--
 drivers/infiniband/ulp/ipoib/ipoib_main.c      |  7 ++-----
 drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 24 ++++++++++++++----------
 3 files changed, 17 insertions(+), 17 deletions(-)

Comments

Ira Weiny Dec. 11, 2015, 11:10 p.m. UTC | #1
On Fri, Dec 11, 2015 at 12:16:53PM -0600, Christoph Lameter wrote:
> Code cleanup to remove multicast specific code from ipoib_main.c
> 
> The removal of a list of multicast groups occurs in three places.
> Create a new function ipoib_mcast_remove_list(). Use this new
> function in ipoib_main.c too.
> That in turn allows the dropping of two functions that were
> exported from ipoib_multicast.c for expiration of mc groups.
> 
> Signed-off-by: Christoph Lameter <cl@linux.com>

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> ---
>  drivers/infiniband/ulp/ipoib/ipoib.h           |  3 +--
>  drivers/infiniband/ulp/ipoib/ipoib_main.c      |  7 ++-----
>  drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 24 ++++++++++++++----------
>  3 files changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
> index 3ede103..989c409 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib.h
> +++ b/drivers/infiniband/ulp/ipoib/ipoib.h
> @@ -495,7 +495,6 @@ void ipoib_dev_cleanup(struct net_device *dev);
>  void ipoib_mcast_join_task(struct work_struct *work);
>  void ipoib_mcast_carrier_on_task(struct work_struct *work);
>  void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb);
> -void ipoib_mcast_free(struct ipoib_mcast *mc);
>  
>  void ipoib_mcast_restart_task(struct work_struct *work);
>  int ipoib_mcast_start_thread(struct net_device *dev);
> @@ -549,7 +548,7 @@ void ipoib_path_iter_read(struct ipoib_path_iter *iter,
>  
>  int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
>  		       union ib_gid *mgid, int set_qkey);
> -int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast);
> +void ipoib_mcast_remove_list(struct net_device *dev, struct list_head *remove_list);
>  struct ipoib_mcast *__ipoib_mcast_find(struct net_device *dev, void *mgid);
>  
>  int ipoib_init_qp(struct net_device *dev);
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 7d32818..483ff20 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> @@ -1150,7 +1150,7 @@ static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv)
>  	unsigned long flags;
>  	int i;
>  	LIST_HEAD(remove_list);
> -	struct ipoib_mcast *mcast, *tmcast;
> +	struct ipoib_mcast *mcast;
>  	struct net_device *dev = priv->dev;
>  
>  	if (test_bit(IPOIB_STOP_NEIGH_GC, &priv->flags))
> @@ -1207,10 +1207,7 @@ static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv)
>  
>  out_unlock:
>  	spin_unlock_irqrestore(&priv->lock, flags);
> -	list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
> -		ipoib_mcast_leave(dev, mcast);
> -		ipoib_mcast_free(mcast);
> -	}
> +	ipoib_mcast_remove_list(dev, &remove_list);
>  }
>  
>  static void ipoib_reap_neigh(struct work_struct *work)
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
> index f357ca6..8acb420a 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
> @@ -106,7 +106,7 @@ static void __ipoib_mcast_schedule_join_thread(struct ipoib_dev_priv *priv,
>  		queue_delayed_work(priv->wq, &priv->mcast_task, 0);
>  }
>  
> -void ipoib_mcast_free(struct ipoib_mcast *mcast)
> +static void ipoib_mcast_free(struct ipoib_mcast *mcast)
>  {
>  	struct net_device *dev = mcast->dev;
>  	int tx_dropped = 0;
> @@ -677,7 +677,7 @@ int ipoib_mcast_stop_thread(struct net_device *dev)
>  	return 0;
>  }
>  
> -int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
> +static int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
>  {
>  	struct ipoib_dev_priv *priv = netdev_priv(dev);
>  	int ret = 0;
> @@ -704,6 +704,16 @@ int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
>  	return 0;
>  }
>  
> +void ipoib_mcast_remove_list(struct net_device *dev, struct list_head *remove_list)
> +{
> +	struct ipoib_mcast *mcast, *tmcast;
> +
> +	list_for_each_entry_safe(mcast, tmcast, remove_list, list) {
> +		ipoib_mcast_leave(dev, mcast);
> +		ipoib_mcast_free(mcast);
> +	}
> +}
> +
>  void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb)
>  {
>  	struct ipoib_dev_priv *priv = netdev_priv(dev);
> @@ -810,10 +820,7 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
>  		if (test_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags))
>  			wait_for_completion(&mcast->done);
>  
> -	list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
> -		ipoib_mcast_leave(dev, mcast);
> -		ipoib_mcast_free(mcast);
> -	}
> +	ipoib_mcast_remove_list(dev, &remove_list);
>  }
>  
>  static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
> @@ -939,10 +946,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)
>  		if (test_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags))
>  			wait_for_completion(&mcast->done);
>  
> -	list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
> -		ipoib_mcast_leave(mcast->dev, mcast);
> -		ipoib_mcast_free(mcast);
> -	}
> +	ipoib_mcast_remove_list(mcast->dev, &remove_list);
>  
>  	/*
>  	 * Double check that we are still up
> -- 
> 2.5.0
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 3ede103..989c409 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -495,7 +495,6 @@  void ipoib_dev_cleanup(struct net_device *dev);
 void ipoib_mcast_join_task(struct work_struct *work);
 void ipoib_mcast_carrier_on_task(struct work_struct *work);
 void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb);
-void ipoib_mcast_free(struct ipoib_mcast *mc);
 
 void ipoib_mcast_restart_task(struct work_struct *work);
 int ipoib_mcast_start_thread(struct net_device *dev);
@@ -549,7 +548,7 @@  void ipoib_path_iter_read(struct ipoib_path_iter *iter,
 
 int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
 		       union ib_gid *mgid, int set_qkey);
-int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast);
+void ipoib_mcast_remove_list(struct net_device *dev, struct list_head *remove_list);
 struct ipoib_mcast *__ipoib_mcast_find(struct net_device *dev, void *mgid);
 
 int ipoib_init_qp(struct net_device *dev);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 7d32818..483ff20 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1150,7 +1150,7 @@  static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv)
 	unsigned long flags;
 	int i;
 	LIST_HEAD(remove_list);
-	struct ipoib_mcast *mcast, *tmcast;
+	struct ipoib_mcast *mcast;
 	struct net_device *dev = priv->dev;
 
 	if (test_bit(IPOIB_STOP_NEIGH_GC, &priv->flags))
@@ -1207,10 +1207,7 @@  static void __ipoib_reap_neigh(struct ipoib_dev_priv *priv)
 
 out_unlock:
 	spin_unlock_irqrestore(&priv->lock, flags);
-	list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
-		ipoib_mcast_leave(dev, mcast);
-		ipoib_mcast_free(mcast);
-	}
+	ipoib_mcast_remove_list(dev, &remove_list);
 }
 
 static void ipoib_reap_neigh(struct work_struct *work)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index f357ca6..8acb420a 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -106,7 +106,7 @@  static void __ipoib_mcast_schedule_join_thread(struct ipoib_dev_priv *priv,
 		queue_delayed_work(priv->wq, &priv->mcast_task, 0);
 }
 
-void ipoib_mcast_free(struct ipoib_mcast *mcast)
+static void ipoib_mcast_free(struct ipoib_mcast *mcast)
 {
 	struct net_device *dev = mcast->dev;
 	int tx_dropped = 0;
@@ -677,7 +677,7 @@  int ipoib_mcast_stop_thread(struct net_device *dev)
 	return 0;
 }
 
-int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
+static int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 	int ret = 0;
@@ -704,6 +704,16 @@  int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
 	return 0;
 }
 
+void ipoib_mcast_remove_list(struct net_device *dev, struct list_head *remove_list)
+{
+	struct ipoib_mcast *mcast, *tmcast;
+
+	list_for_each_entry_safe(mcast, tmcast, remove_list, list) {
+		ipoib_mcast_leave(dev, mcast);
+		ipoib_mcast_free(mcast);
+	}
+}
+
 void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -810,10 +820,7 @@  void ipoib_mcast_dev_flush(struct net_device *dev)
 		if (test_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags))
 			wait_for_completion(&mcast->done);
 
-	list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
-		ipoib_mcast_leave(dev, mcast);
-		ipoib_mcast_free(mcast);
-	}
+	ipoib_mcast_remove_list(dev, &remove_list);
 }
 
 static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
@@ -939,10 +946,7 @@  void ipoib_mcast_restart_task(struct work_struct *work)
 		if (test_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags))
 			wait_for_completion(&mcast->done);
 
-	list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
-		ipoib_mcast_leave(mcast->dev, mcast);
-		ipoib_mcast_free(mcast);
-	}
+	ipoib_mcast_remove_list(mcast->dev, &remove_list);
 
 	/*
 	 * Double check that we are still up