netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: systemport: Unmap queues upon DSA unregister event
@ 2018-11-06 23:15 Florian Fainelli
  2018-11-06 23:15 ` [PATCH net-next 1/3] net: dsa: bcm_sf2: Turn on PHY to allow successful registration Florian Fainelli
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-11-06 23:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

Hi all,

This patch series fixes the unbinding/binding of the bcm_sf2 switch
driver along with bcmsysport which monitors the switch port queues.
Because the driver was not processing the DSA_PORT_UNREGISTER event, we
would not be unmapping switch port/queues, which could cause incorrect
decisions to be made by the HW (e.g: queue always back-pressured).

Florian Fainelli (3):
  net: dsa: bcm_sf2: Turn on PHY to allow successful registration
  net: systemport: Simplify queue mapping logic
  net: systemport: Unmap queues upon DSA unregister event

 drivers/net/dsa/bcm_sf2.c                  |  4 ++
 drivers/net/ethernet/broadcom/bcmsysport.c | 71 ++++++++++++++++++----
 drivers/net/ethernet/broadcom/bcmsysport.h |  1 -
 3 files changed, 62 insertions(+), 14 deletions(-)

-- 
2.17.1

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

* [PATCH net-next 1/3] net: dsa: bcm_sf2: Turn on PHY to allow successful registration
  2018-11-06 23:15 [PATCH net-next 0/3] net: systemport: Unmap queues upon DSA unregister event Florian Fainelli
@ 2018-11-06 23:15 ` Florian Fainelli
  2018-11-06 23:15 ` [PATCH net-next 2/3] net: systemport: Simplify queue mapping logic Florian Fainelli
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-11-06 23:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

We are binding to the PHY using the SF2 slave MDIO bus that we create,
binding involves reading the PHY's MII_PHYSID1/2 which won't be possible
if the PHY is turned off. Temporarily turn it on/off for the bus probing
to succeeed. This fixes unbind/bind problems where the port connecting
to that PHY would be in error since it could not connect to it.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/bcm_sf2.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 2eb68769562c..2c664aac1e7b 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1090,12 +1090,16 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	bcm_sf2_gphy_enable_set(priv->dev->ds, true);
+
 	ret = bcm_sf2_mdio_register(ds);
 	if (ret) {
 		pr_err("failed to register MDIO bus\n");
 		return ret;
 	}
 
+	bcm_sf2_gphy_enable_set(priv->dev->ds, false);
+
 	ret = bcm_sf2_cfp_rst(priv);
 	if (ret) {
 		pr_err("failed to reset CFP\n");
-- 
2.17.1

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

* [PATCH net-next 2/3] net: systemport: Simplify queue mapping logic
  2018-11-06 23:15 [PATCH net-next 0/3] net: systemport: Unmap queues upon DSA unregister event Florian Fainelli
  2018-11-06 23:15 ` [PATCH net-next 1/3] net: dsa: bcm_sf2: Turn on PHY to allow successful registration Florian Fainelli
@ 2018-11-06 23:15 ` Florian Fainelli
  2018-11-06 23:15 ` [PATCH net-next 3/3] net: systemport: Unmap queues upon DSA unregister event Florian Fainelli
  2018-11-06 23:40 ` [PATCH net-next 0/3] " David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-11-06 23:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

The use of a bitmap speeds up the finding of the first available queue
to which we could start establishing the mapping for, but we still have
to loop over all slave network devices to set them up. Simplify the
logic to have a single loop, and use the fact that a correctly
configured ring has inspect set to true. This will make things simpler
to unwind during device unregistration.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 17 +++++++++--------
 drivers/net/ethernet/broadcom/bcmsysport.h |  1 -
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 0e2d99c737e3..f620c647bb86 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2312,7 +2312,7 @@ static int bcm_sysport_map_queues(struct notifier_block *nb,
 	struct bcm_sysport_priv *priv;
 	struct net_device *slave_dev;
 	unsigned int num_tx_queues;
-	unsigned int q, start, port;
+	unsigned int q, qp, port;
 	struct net_device *dev;
 
 	priv = container_of(nb, struct bcm_sysport_priv, dsa_notifier);
@@ -2351,20 +2351,21 @@ static int bcm_sysport_map_queues(struct notifier_block *nb,
 
 	priv->per_port_num_tx_queues = num_tx_queues;
 
-	start = find_first_zero_bit(&priv->queue_bitmap, dev->num_tx_queues);
-	for (q = 0; q < num_tx_queues; q++) {
-		ring = &priv->tx_rings[q + start];
+	for (q = 0, qp = 0; q < dev->num_tx_queues && qp < num_tx_queues;
+	     q++) {
+		ring = &priv->tx_rings[q];
+
+		if (ring->inspect)
+			continue;
 
 		/* Just remember the mapping actual programming done
 		 * during bcm_sysport_init_tx_ring
 		 */
-		ring->switch_queue = q;
+		ring->switch_queue = qp;
 		ring->switch_port = port;
 		ring->inspect = true;
 		priv->ring_map[q + port * num_tx_queues] = ring;
-
-		/* Set all queues as being used now */
-		set_bit(q + start, &priv->queue_bitmap);
+		qp++;
 	}
 
 	return 0;
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h
index a7a230884a87..94d64b203098 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.h
+++ b/drivers/net/ethernet/broadcom/bcmsysport.h
@@ -795,7 +795,6 @@ struct bcm_sysport_priv {
 	/* map information between switch port queues and local queues */
 	struct notifier_block	dsa_notifier;
 	unsigned int		per_port_num_tx_queues;
-	unsigned long		queue_bitmap;
 	struct bcm_sysport_tx_ring *ring_map[DSA_MAX_PORTS * 8];
 
 };
-- 
2.17.1

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

* [PATCH net-next 3/3] net: systemport: Unmap queues upon DSA unregister event
  2018-11-06 23:15 [PATCH net-next 0/3] net: systemport: Unmap queues upon DSA unregister event Florian Fainelli
  2018-11-06 23:15 ` [PATCH net-next 1/3] net: dsa: bcm_sf2: Turn on PHY to allow successful registration Florian Fainelli
  2018-11-06 23:15 ` [PATCH net-next 2/3] net: systemport: Simplify queue mapping logic Florian Fainelli
@ 2018-11-06 23:15 ` Florian Fainelli
  2018-11-06 23:40 ` [PATCH net-next 0/3] " David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2018-11-06 23:15 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, vivien.didelot, Florian Fainelli

Binding and unbinding the switch driver which creates the DSA slave
network devices for which we set-up inspection would lead to
undesireable effects since we were not clearing the port/queue mapping
to the SYSTEMPORT TX queue.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 56 +++++++++++++++++++---
 1 file changed, 50 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index f620c647bb86..f8f0a027b3ae 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2371,17 +2371,61 @@ static int bcm_sysport_map_queues(struct notifier_block *nb,
 	return 0;
 }
 
+static int bcm_sysport_unmap_queues(struct notifier_block *nb,
+				    struct dsa_notifier_register_info *info)
+{
+	struct bcm_sysport_tx_ring *ring;
+	struct bcm_sysport_priv *priv;
+	struct net_device *slave_dev;
+	unsigned int num_tx_queues;
+	struct net_device *dev;
+	unsigned int q, port;
+
+	priv = container_of(nb, struct bcm_sysport_priv, dsa_notifier);
+	if (priv->netdev != info->master)
+		return 0;
+
+	dev = info->master;
+
+	if (dev->netdev_ops != &bcm_sysport_netdev_ops)
+		return 0;
+
+	port = info->port_number;
+	slave_dev = info->info.dev;
+
+	num_tx_queues = slave_dev->real_num_tx_queues;
+
+	for (q = 0; q < dev->num_tx_queues; q++) {
+		ring = &priv->tx_rings[q];
+
+		if (ring->switch_port != port)
+			continue;
+
+		if (!ring->inspect)
+			continue;
+
+		ring->inspect = false;
+		priv->ring_map[q + port * num_tx_queues] = NULL;
+	}
+
+	return 0;
+}
+
 static int bcm_sysport_dsa_notifier(struct notifier_block *nb,
 				    unsigned long event, void *ptr)
 {
-	struct dsa_notifier_register_info *info;
+	int ret = NOTIFY_DONE;
 
-	if (event != DSA_PORT_REGISTER)
-		return NOTIFY_DONE;
-
-	info = ptr;
+	switch (event) {
+	case DSA_PORT_REGISTER:
+		ret = bcm_sysport_map_queues(nb, ptr);
+		break;
+	case DSA_PORT_UNREGISTER:
+		ret = bcm_sysport_unmap_queues(nb, ptr);
+		break;
+	}
 
-	return notifier_from_errno(bcm_sysport_map_queues(nb, info));
+	return notifier_from_errno(ret);
 }
 
 #define REV_FMT	"v%2x.%02x"
-- 
2.17.1

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

* Re: [PATCH net-next 0/3] net: systemport: Unmap queues upon DSA unregister event
  2018-11-06 23:15 [PATCH net-next 0/3] net: systemport: Unmap queues upon DSA unregister event Florian Fainelli
                   ` (2 preceding siblings ...)
  2018-11-06 23:15 ` [PATCH net-next 3/3] net: systemport: Unmap queues upon DSA unregister event Florian Fainelli
@ 2018-11-06 23:40 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-11-06 23:40 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, andrew, vivien.didelot

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue,  6 Nov 2018 15:15:15 -0800

> This patch series fixes the unbinding/binding of the bcm_sf2 switch
> driver along with bcmsysport which monitors the switch port queues.
> Because the driver was not processing the DSA_PORT_UNREGISTER event, we
> would not be unmapping switch port/queues, which could cause incorrect
> decisions to be made by the HW (e.g: queue always back-pressured).

Series applied, thanks Florian.

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

end of thread, other threads:[~2018-11-07  9:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06 23:15 [PATCH net-next 0/3] net: systemport: Unmap queues upon DSA unregister event Florian Fainelli
2018-11-06 23:15 ` [PATCH net-next 1/3] net: dsa: bcm_sf2: Turn on PHY to allow successful registration Florian Fainelli
2018-11-06 23:15 ` [PATCH net-next 2/3] net: systemport: Simplify queue mapping logic Florian Fainelli
2018-11-06 23:15 ` [PATCH net-next 3/3] net: systemport: Unmap queues upon DSA unregister event Florian Fainelli
2018-11-06 23:40 ` [PATCH net-next 0/3] " David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).