netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND net-next PATCH 1/3] net: dsa: qca8k: reduce mgmt ethernet timeout
@ 2022-06-18  7:26 Christian Marangi
  2022-06-18  7:26 ` [RESEND net-next PATCH 2/3] net: dsa: qca8k: change only max_frame_size of mac_frame_size_reg Christian Marangi
  2022-06-18  7:26 ` [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change Christian Marangi
  0 siblings, 2 replies; 6+ messages in thread
From: Christian Marangi @ 2022-06-18  7:26 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan McDowell, netdev, linux-kernel
  Cc: Christian Marangi

The current mgmt ethernet timeout is set to 100ms. This value is too
big and would slow down any mdio command in case the mgmt ethernet
packet have some problems on the receiving part.
Reduce it to just 5ms to handle case when some operation are done on the
master port that would cause the mgmt ethernet to not work temporarily.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/dsa/qca8k.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h
index 04408e11402a..ec58d0e80a70 100644
--- a/drivers/net/dsa/qca8k.h
+++ b/drivers/net/dsa/qca8k.h
@@ -15,7 +15,7 @@
 
 #define QCA8K_ETHERNET_MDIO_PRIORITY			7
 #define QCA8K_ETHERNET_PHY_PRIORITY			6
-#define QCA8K_ETHERNET_TIMEOUT				100
+#define QCA8K_ETHERNET_TIMEOUT				5
 
 #define QCA8K_NUM_PORTS					7
 #define QCA8K_NUM_CPU_PORTS				2
-- 
2.36.1


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

* [RESEND net-next PATCH 2/3] net: dsa: qca8k: change only max_frame_size of mac_frame_size_reg
  2022-06-18  7:26 [RESEND net-next PATCH 1/3] net: dsa: qca8k: reduce mgmt ethernet timeout Christian Marangi
@ 2022-06-18  7:26 ` Christian Marangi
  2022-06-18  7:26 ` [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change Christian Marangi
  1 sibling, 0 replies; 6+ messages in thread
From: Christian Marangi @ 2022-06-18  7:26 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan McDowell, netdev, linux-kernel
  Cc: Christian Marangi

Currently we overwrite the entire MAX_FRAME_SIZE reg instead of tweaking
just the MAX_FRAME_SIZE value. Change this and update only the relevant
bits.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/dsa/qca8k.c | 8 ++++++--
 drivers/net/dsa/qca8k.h | 3 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
index 2727d3169c25..eaaf80f96fa9 100644
--- a/drivers/net/dsa/qca8k.c
+++ b/drivers/net/dsa/qca8k.c
@@ -2345,7 +2345,9 @@ qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
 		return 0;
 
 	/* Include L2 header / FCS length */
-	return qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, new_mtu + ETH_HLEN + ETH_FCS_LEN);
+	return regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
+				  QCA8K_MAX_FRAME_SIZE_MASK,
+				  new_mtu + ETH_HLEN + ETH_FCS_LEN);
 }
 
 static int
@@ -3015,7 +3017,9 @@ qca8k_setup(struct dsa_switch *ds)
 	}
 
 	/* Setup our port MTUs to match power on defaults */
-	ret = qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, ETH_FRAME_LEN + ETH_FCS_LEN);
+	ret = regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
+				 QCA8K_MAX_FRAME_SIZE_MASK,
+				 ETH_FRAME_LEN + ETH_FCS_LEN);
 	if (ret)
 		dev_warn(priv->dev, "failed setting MTU settings");
 
diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h
index ec58d0e80a70..1d0c383a95e7 100644
--- a/drivers/net/dsa/qca8k.h
+++ b/drivers/net/dsa/qca8k.h
@@ -87,7 +87,8 @@
 #define   QCA8K_MDIO_MASTER_MAX_REG			32
 #define QCA8K_GOL_MAC_ADDR0				0x60
 #define QCA8K_GOL_MAC_ADDR1				0x64
-#define QCA8K_MAX_FRAME_SIZE				0x78
+#define QCA8K_MAX_FRAME_SIZE_REG			0x78
+#define   QCA8K_MAX_FRAME_SIZE_MASK			GENMASK(13, 0)
 #define QCA8K_REG_PORT_STATUS(_i)			(0x07c + (_i) * 4)
 #define   QCA8K_PORT_STATUS_SPEED			GENMASK(1, 0)
 #define   QCA8K_PORT_STATUS_SPEED_10			0
-- 
2.36.1


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

* [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change
  2022-06-18  7:26 [RESEND net-next PATCH 1/3] net: dsa: qca8k: reduce mgmt ethernet timeout Christian Marangi
  2022-06-18  7:26 ` [RESEND net-next PATCH 2/3] net: dsa: qca8k: change only max_frame_size of mac_frame_size_reg Christian Marangi
@ 2022-06-18  7:26 ` Christian Marangi
  2022-06-21  4:56   ` Jakub Kicinski
  1 sibling, 1 reply; 6+ messages in thread
From: Christian Marangi @ 2022-06-18  7:26 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan McDowell, netdev, linux-kernel
  Cc: Christian Marangi

It was discovered that the Documentation lacks of a fundamental detail
on how to correctly change the MAX_FRAME_SIZE of the switch.

In fact if the MAX_FRAME_SIZE is changed while the cpu port is on, the
switch panics and cease to send any packet. This cause the mgmt ethernet
system to not receive any packet (the slow fallback still works) and
makes the device not reachable. To recover from this a switch reset is
required.

To correctly handle this, turn off the cpu ports before changing the
MAX_FRAME_SIZE and turn on again after the value is applied.

Fixes: f58d2598cf70 ("net: dsa: qca8k: implement the port MTU callbacks")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/dsa/qca8k.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
index eaaf80f96fa9..0b92b9d5954a 100644
--- a/drivers/net/dsa/qca8k.c
+++ b/drivers/net/dsa/qca8k.c
@@ -2334,6 +2334,7 @@ static int
 qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
 {
 	struct qca8k_priv *priv = ds->priv;
+	int ret;
 
 	/* We have only have a general MTU setting.
 	 * DSA always set the CPU port's MTU to the largest MTU of the slave
@@ -2344,10 +2345,29 @@ qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
 	if (!dsa_is_cpu_port(ds, port))
 		return 0;
 
+	/* To change the MAX_FRAME_SIZE the cpu ports must be off or
+	 * the switch panics.
+	 * Turn off both cpu ports before applying the new value to prevent
+	 * this.
+	 */
+	if (priv->port_enabled_map & BIT(0))
+		qca8k_port_set_status(priv, 0, 0);
+
+	if (priv->port_enabled_map & BIT(6))
+		qca8k_port_set_status(priv, 6, 0);
+
 	/* Include L2 header / FCS length */
-	return regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
-				  QCA8K_MAX_FRAME_SIZE_MASK,
-				  new_mtu + ETH_HLEN + ETH_FCS_LEN);
+	ret = regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
+				 QCA8K_MAX_FRAME_SIZE_MASK,
+				 new_mtu + ETH_HLEN + ETH_FCS_LEN);
+
+	if (priv->port_enabled_map & BIT(0))
+		qca8k_port_set_status(priv, 0, 1);
+
+	if (priv->port_enabled_map & BIT(6))
+		qca8k_port_set_status(priv, 6, 1);
+
+	return ret;
 }
 
 static int
-- 
2.36.1


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

* Re: [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change
  2022-06-18  7:26 ` [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change Christian Marangi
@ 2022-06-21  4:56   ` Jakub Kicinski
  2022-06-21 14:51     ` Christian Marangi
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2022-06-21  4:56 UTC (permalink / raw)
  To: Christian Marangi
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Paolo Abeni, Jonathan McDowell,
	netdev, linux-kernel

On Sat, 18 Jun 2022 09:26:50 +0200 Christian Marangi wrote:
> It was discovered that the Documentation lacks of a fundamental detail
> on how to correctly change the MAX_FRAME_SIZE of the switch.
> 
> In fact if the MAX_FRAME_SIZE is changed while the cpu port is on, the
> switch panics and cease to send any packet. This cause the mgmt ethernet
> system to not receive any packet (the slow fallback still works) and
> makes the device not reachable. To recover from this a switch reset is
> required.
> 
> To correctly handle this, turn off the cpu ports before changing the
> MAX_FRAME_SIZE and turn on again after the value is applied.
> 
> Fixes: f58d2598cf70 ("net: dsa: qca8k: implement the port MTU callbacks")
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 
It reads like this patch should be backported to 5.10 and 5.15 stable
branches. While patches 1 and 2 are cleanups. In which case you should
reports just patch 3 against net/master first, we'll send it to Linus at
the end of the week and then you can send the cleanups on top for -next.

One extra question below.

> diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> index eaaf80f96fa9..0b92b9d5954a 100644
> --- a/drivers/net/dsa/qca8k.c
> +++ b/drivers/net/dsa/qca8k.c
> @@ -2334,6 +2334,7 @@ static int
>  qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
>  {
>  	struct qca8k_priv *priv = ds->priv;
> +	int ret;
>  
>  	/* We have only have a general MTU setting.
>  	 * DSA always set the CPU port's MTU to the largest MTU of the slave
> @@ -2344,10 +2345,29 @@ qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
>  	if (!dsa_is_cpu_port(ds, port))
>  		return 0;
>  
> +	/* To change the MAX_FRAME_SIZE the cpu ports must be off or
> +	 * the switch panics.
> +	 * Turn off both cpu ports before applying the new value to prevent
> +	 * this.
> +	 */
> +	if (priv->port_enabled_map & BIT(0))
> +		qca8k_port_set_status(priv, 0, 0);
> +
> +	if (priv->port_enabled_map & BIT(6))
> +		qca8k_port_set_status(priv, 6, 0);
> +
>  	/* Include L2 header / FCS length */
> -	return regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
> -				  QCA8K_MAX_FRAME_SIZE_MASK,
> -				  new_mtu + ETH_HLEN + ETH_FCS_LEN);
> +	ret = regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,

Why care about the return code of this regmap access but not the ones
inside the *port_set_status() calls?

> +				 QCA8K_MAX_FRAME_SIZE_MASK,
> +				 new_mtu + ETH_HLEN + ETH_FCS_LEN);
> +
> +	if (priv->port_enabled_map & BIT(0))
> +		qca8k_port_set_status(priv, 0, 1);
> +
> +	if (priv->port_enabled_map & BIT(6))
> +		qca8k_port_set_status(priv, 6, 1);
> +
> +	return ret;
>  }
>  
>  static int

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

* Re: [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change
  2022-06-21  4:56   ` Jakub Kicinski
@ 2022-06-21 14:51     ` Christian Marangi
  2022-06-21 15:04       ` Christian Marangi
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Marangi @ 2022-06-21 14:51 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Paolo Abeni, Jonathan McDowell,
	netdev, linux-kernel

On Mon, Jun 20, 2022 at 09:56:19PM -0700, Jakub Kicinski wrote:
> On Sat, 18 Jun 2022 09:26:50 +0200 Christian Marangi wrote:
> > It was discovered that the Documentation lacks of a fundamental detail
> > on how to correctly change the MAX_FRAME_SIZE of the switch.
> > 
> > In fact if the MAX_FRAME_SIZE is changed while the cpu port is on, the
> > switch panics and cease to send any packet. This cause the mgmt ethernet
> > system to not receive any packet (the slow fallback still works) and
> > makes the device not reachable. To recover from this a switch reset is
> > required.
> > 
> > To correctly handle this, turn off the cpu ports before changing the
> > MAX_FRAME_SIZE and turn on again after the value is applied.
> > 
> > Fixes: f58d2598cf70 ("net: dsa: qca8k: implement the port MTU callbacks")
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
>  
> It reads like this patch should be backported to 5.10 and 5.15 stable
> branches. While patches 1 and 2 are cleanups. In which case you should
> reports just patch 3 against net/master first, we'll send it to Linus at
> the end of the week and then you can send the cleanups on top for -next.
>

Ok will split this series.

> One extra question below.
> 
> > diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> > index eaaf80f96fa9..0b92b9d5954a 100644
> > --- a/drivers/net/dsa/qca8k.c
> > +++ b/drivers/net/dsa/qca8k.c
> > @@ -2334,6 +2334,7 @@ static int
> >  qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
> >  {
> >  	struct qca8k_priv *priv = ds->priv;
> > +	int ret;
> >  
> >  	/* We have only have a general MTU setting.
> >  	 * DSA always set the CPU port's MTU to the largest MTU of the slave
> > @@ -2344,10 +2345,29 @@ qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
> >  	if (!dsa_is_cpu_port(ds, port))
> >  		return 0;
> >  
> > +	/* To change the MAX_FRAME_SIZE the cpu ports must be off or
> > +	 * the switch panics.
> > +	 * Turn off both cpu ports before applying the new value to prevent
> > +	 * this.
> > +	 */
> > +	if (priv->port_enabled_map & BIT(0))
> > +		qca8k_port_set_status(priv, 0, 0);
> > +
> > +	if (priv->port_enabled_map & BIT(6))
> > +		qca8k_port_set_status(priv, 6, 0);
> > +
> >  	/* Include L2 header / FCS length */
> > -	return regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
> > -				  QCA8K_MAX_FRAME_SIZE_MASK,
> > -				  new_mtu + ETH_HLEN + ETH_FCS_LEN);
> > +	ret = regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
> 
> Why care about the return code of this regmap access but not the ones
> inside the *port_set_status() calls?
> 

No reason just following old bad behaviour done in other function where
qca8k_port_set_status is used. Will send v2 with the error handled.

> > +				 QCA8K_MAX_FRAME_SIZE_MASK,
> > +				 new_mtu + ETH_HLEN + ETH_FCS_LEN);
> > +
> > +	if (priv->port_enabled_map & BIT(0))
> > +		qca8k_port_set_status(priv, 0, 1);
> > +
> > +	if (priv->port_enabled_map & BIT(6))
> > +		qca8k_port_set_status(priv, 6, 1);
> > +
> > +	return ret;
> >  }
> >  
> >  static int

-- 
	Ansuel

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

* Re: [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change
  2022-06-21 14:51     ` Christian Marangi
@ 2022-06-21 15:04       ` Christian Marangi
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Marangi @ 2022-06-21 15:04 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Paolo Abeni, Jonathan McDowell,
	netdev, linux-kernel

On Tue, Jun 21, 2022 at 04:51:46PM +0200, Christian Marangi wrote:
> On Mon, Jun 20, 2022 at 09:56:19PM -0700, Jakub Kicinski wrote:
> > On Sat, 18 Jun 2022 09:26:50 +0200 Christian Marangi wrote:
> > > It was discovered that the Documentation lacks of a fundamental detail
> > > on how to correctly change the MAX_FRAME_SIZE of the switch.
> > > 
> > > In fact if the MAX_FRAME_SIZE is changed while the cpu port is on, the
> > > switch panics and cease to send any packet. This cause the mgmt ethernet
> > > system to not receive any packet (the slow fallback still works) and
> > > makes the device not reachable. To recover from this a switch reset is
> > > required.
> > > 
> > > To correctly handle this, turn off the cpu ports before changing the
> > > MAX_FRAME_SIZE and turn on again after the value is applied.
> > > 
> > > Fixes: f58d2598cf70 ("net: dsa: qca8k: implement the port MTU callbacks")
> > > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> >  
> > It reads like this patch should be backported to 5.10 and 5.15 stable
> > branches. While patches 1 and 2 are cleanups. In which case you should
> > reports just patch 3 against net/master first, we'll send it to Linus at
> > the end of the week and then you can send the cleanups on top for -next.
> >
> 
> Ok will split this series.
> 
> > One extra question below.
> > 
> > > diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> > > index eaaf80f96fa9..0b92b9d5954a 100644
> > > --- a/drivers/net/dsa/qca8k.c
> > > +++ b/drivers/net/dsa/qca8k.c
> > > @@ -2334,6 +2334,7 @@ static int
> > >  qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
> > >  {
> > >  	struct qca8k_priv *priv = ds->priv;
> > > +	int ret;
> > >  
> > >  	/* We have only have a general MTU setting.
> > >  	 * DSA always set the CPU port's MTU to the largest MTU of the slave
> > > @@ -2344,10 +2345,29 @@ qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
> > >  	if (!dsa_is_cpu_port(ds, port))
> > >  		return 0;
> > >  
> > > +	/* To change the MAX_FRAME_SIZE the cpu ports must be off or
> > > +	 * the switch panics.
> > > +	 * Turn off both cpu ports before applying the new value to prevent
> > > +	 * this.
> > > +	 */
> > > +	if (priv->port_enabled_map & BIT(0))
> > > +		qca8k_port_set_status(priv, 0, 0);
> > > +
> > > +	if (priv->port_enabled_map & BIT(6))
> > > +		qca8k_port_set_status(priv, 6, 0);
> > > +
> > >  	/* Include L2 header / FCS length */
> > > -	return regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
> > > -				  QCA8K_MAX_FRAME_SIZE_MASK,
> > > -				  new_mtu + ETH_HLEN + ETH_FCS_LEN);
> > > +	ret = regmap_update_bits(priv->regmap, QCA8K_MAX_FRAME_SIZE_REG,
> > 
> > Why care about the return code of this regmap access but not the ones
> > inside the *port_set_status() calls?
> > 
> 
> No reason just following old bad behaviour done in other function where
> qca8k_port_set_status is used. Will send v2 with the error handled.
>

Actually now that i checked, the qca8k_port_set_status is void... So it
would require an additional change to that function. Will make it part
of the net-next series...

> > > +				 QCA8K_MAX_FRAME_SIZE_MASK,
> > > +				 new_mtu + ETH_HLEN + ETH_FCS_LEN);
> > > +
> > > +	if (priv->port_enabled_map & BIT(0))
> > > +		qca8k_port_set_status(priv, 0, 1);
> > > +
> > > +	if (priv->port_enabled_map & BIT(6))
> > > +		qca8k_port_set_status(priv, 6, 1);
> > > +
> > > +	return ret;
> > >  }
> > >  
> > >  static int
> 
> -- 
> 	Ansuel

-- 
	Ansuel

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

end of thread, other threads:[~2022-06-21 15:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-18  7:26 [RESEND net-next PATCH 1/3] net: dsa: qca8k: reduce mgmt ethernet timeout Christian Marangi
2022-06-18  7:26 ` [RESEND net-next PATCH 2/3] net: dsa: qca8k: change only max_frame_size of mac_frame_size_reg Christian Marangi
2022-06-18  7:26 ` [RESEND net-next PATCH 3/3] net: dsa: qca8k: reset cpu port on MTU change Christian Marangi
2022-06-21  4:56   ` Jakub Kicinski
2022-06-21 14:51     ` Christian Marangi
2022-06-21 15:04       ` Christian Marangi

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).