All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: systemport: Correclty disambiguate driver instances
@ 2018-04-25 23:21 Florian Fainelli
  2018-04-26 15:06 ` Vivien Didelot
  2018-04-27 17:15 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Florian Fainelli @ 2018-04-25 23:21 UTC (permalink / raw)
  To: netdev; +Cc: davem, vivien.didelot, Florian Fainelli

While adding the DSA notifier, we will be sending DSA notifications with
info->master that is going to point to a particular net_device instance.

Our logic in bcm_sysport_map_queues() correctly disambiguates net_device
instances that are not covered by our own driver, but it will not make
sure that info->master points to a particular driver instance that we
are interested in. In a system where e.g: two or more SYSTEMPORT
instances are registered, this would lead in programming two or more
times the queue mapping, completely messing with the logic which does
the queue/port allocation and tracking.

Fix this by looking at the notifier_block pointer which is unique per
instance and allows us to go back to our driver private structure, and
in turn to the backing net_device instance.

Fixes: d156576362c0 ("net: systemport: Establish lower/upper queue mapping")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index f9a3c1a76d5d..0c2b0fab81cf 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2144,14 +2144,21 @@ static const struct net_device_ops bcm_sysport_netdev_ops = {
 	.ndo_select_queue	= bcm_sysport_select_queue,
 };
 
-static int bcm_sysport_map_queues(struct net_device *dev,
+static int bcm_sysport_map_queues(struct notifier_block *nb,
 				  struct dsa_notifier_register_info *info)
 {
-	struct bcm_sysport_priv *priv = netdev_priv(dev);
 	struct bcm_sysport_tx_ring *ring;
+	struct bcm_sysport_priv *priv;
 	struct net_device *slave_dev;
 	unsigned int num_tx_queues;
 	unsigned int q, start, port;
+	struct net_device *dev;
+
+	priv = container_of(nb, struct bcm_sysport_priv, dsa_notifier);
+	if (priv->netdev != info->master)
+		return 0;
+
+	dev = info->master;
 
 	/* We can't be setting up queue inspection for non directly attached
 	 * switches
@@ -2174,6 +2181,7 @@ static int bcm_sysport_map_queues(struct net_device *dev,
 	if (priv->is_lite)
 		netif_set_real_num_tx_queues(slave_dev,
 					     slave_dev->num_tx_queues / 2);
+
 	num_tx_queues = slave_dev->real_num_tx_queues;
 
 	if (priv->per_port_num_tx_queues &&
@@ -2201,7 +2209,7 @@ static int bcm_sysport_map_queues(struct net_device *dev,
 	return 0;
 }
 
-static int bcm_sysport_dsa_notifier(struct notifier_block *unused,
+static int bcm_sysport_dsa_notifier(struct notifier_block *nb,
 				    unsigned long event, void *ptr)
 {
 	struct dsa_notifier_register_info *info;
@@ -2211,7 +2219,7 @@ static int bcm_sysport_dsa_notifier(struct notifier_block *unused,
 
 	info = ptr;
 
-	return notifier_from_errno(bcm_sysport_map_queues(info->master, info));
+	return notifier_from_errno(bcm_sysport_map_queues(nb, info));
 }
 
 #define REV_FMT	"v%2x.%02x"
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: systemport: Correclty disambiguate driver instances
  2018-04-25 23:21 [PATCH net] net: systemport: Correclty disambiguate driver instances Florian Fainelli
@ 2018-04-26 15:06 ` Vivien Didelot
  2018-04-27 17:15 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Vivien Didelot @ 2018-04-26 15:06 UTC (permalink / raw)
  To: Florian Fainelli, netdev; +Cc: davem, Florian Fainelli

Florian Fainelli <f.fainelli@gmail.com> writes:

> While adding the DSA notifier, we will be sending DSA notifications with
> info->master that is going to point to a particular net_device instance.
>
> Our logic in bcm_sysport_map_queues() correctly disambiguates net_device
> instances that are not covered by our own driver, but it will not make
> sure that info->master points to a particular driver instance that we
> are interested in. In a system where e.g: two or more SYSTEMPORT
> instances are registered, this would lead in programming two or more
> times the queue mapping, completely messing with the logic which does
> the queue/port allocation and tracking.
>
> Fix this by looking at the notifier_block pointer which is unique per
> instance and allows us to go back to our driver private structure, and
> in turn to the backing net_device instance.
>
> Fixes: d156576362c0 ("net: systemport: Establish lower/upper queue mapping")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: systemport: Correclty disambiguate driver instances
  2018-04-25 23:21 [PATCH net] net: systemport: Correclty disambiguate driver instances Florian Fainelli
  2018-04-26 15:06 ` Vivien Didelot
@ 2018-04-27 17:15 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-04-27 17:15 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, vivien.didelot

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Wed, 25 Apr 2018 16:21:51 -0700

> While adding the DSA notifier, we will be sending DSA notifications with
> info->master that is going to point to a particular net_device instance.
> 
> Our logic in bcm_sysport_map_queues() correctly disambiguates net_device
> instances that are not covered by our own driver, but it will not make
> sure that info->master points to a particular driver instance that we
> are interested in. In a system where e.g: two or more SYSTEMPORT
> instances are registered, this would lead in programming two or more
> times the queue mapping, completely messing with the logic which does
> the queue/port allocation and tracking.
> 
> Fix this by looking at the notifier_block pointer which is unique per
> instance and allows us to go back to our driver private structure, and
> in turn to the backing net_device instance.
> 
> Fixes: d156576362c0 ("net: systemport: Establish lower/upper queue mapping")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-27 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-25 23:21 [PATCH net] net: systemport: Correclty disambiguate driver instances Florian Fainelli
2018-04-26 15:06 ` Vivien Didelot
2018-04-27 17:15 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.