net: dsa: qca8k: reduce mgmt ethernet timeout
Subsystems (3)
PATCH 1/3 net: dsa: qca8k: reduce mgmt ethernet timeout
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.
--- drivers/net/dsa/qca8k.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/qca8k.h +1 -1
@@ -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
Signature · 1 line
2.36.1
PATCH 2/3 net: dsa: qca8k: change only max_frame_size of mac_frame_size_reg
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.
--- drivers/net/dsa/qca8k.c | 8 ++++++-- drivers/net/dsa/qca8k.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/net/dsa/qca8k.c +6 -2
@@ -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" );
drivers/net/dsa/qca8k.h +2 -1
@@ -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
Signature · 1 line
2.36.1
PATCH 3/3 net: dsa: qca8k: reset cpu port on MTU change
In reply to Christian MarangiIt 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.
--- drivers/net/dsa/qca8k.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
drivers/net/dsa/qca8k.c +23 -3
@@ -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
Signature · 1 line
2.36.1
Vladimir Oltean
maintainerRe: [PATCH 2/3] net: dsa: qca8k: change only max_frame_size of mac_frame_size_reg
In reply to Christian MarangiQuoted 41 lines · Christian Marangi
Currently we overwrite the entire
MAX_FRAME_SIZEreg instead of tweaking just theMAX_FRAME_SIZEvalue. Change this and update only the relevant bits.Signed-off-by Christian Marangi <[email protected]>--- drivers/net/dsa/qca8k.c | 8 ++++++-- drivers/net/dsa/qca8k.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-)drivers/net/dsa/qca8k.c +6
-2@@ -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" );drivers/net/dsa/qca8k.h +0
-0
drivers/net/dsa/qca8k.h line 91
Quoted 6 lines
drivers/net/dsa/qca8k.h +2
-1@@ -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)
What's at bits 14 and beyond? Trying to understand the impact of this change.
Quoted 6 lines
drivers/net/dsa/qca8k.h +0
-0#define QCA8K_REG_PORT_STATUS (_i) (0x07c + (_i) * 4)#define QCA8K_PORT_STATUS_SPEED GENMASK(1, 0)#define QCA8K_PORT_STATUS_SPEED_10 0Signature · 1 line
2.36.1
Vladimir Oltean
maintainerQuoted 8 lines · 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 <[email protected]>---
I think this could very well qualify as a regression and have a tag of:
if it was presented along with a situation where users could hit some real life conditions where the Ethernet management interface isn't functional.
Quoted 19 lines
drivers/net/dsa/qca8k.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/dsa/qca8k.h +1
-1@@ -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 2Signature · 1 line
2.36.1
Re: [PATCH 2/3] net: dsa: qca8k: change only max_frame_size of mac_frame_size_reg
In reply to Vladimir OlteanQuoted 37 lines · Vladimir Oltean
Quoted 36 lines · Christian Marangi
Currently we overwrite the entire
MAX_FRAME_SIZEreg instead of tweaking just theMAX_FRAME_SIZEvalue. Change this and update only the relevant bits.Signed-off-by Christian Marangi <[email protected]>--- drivers/net/dsa/qca8k.c | 8 ++++++-- drivers/net/dsa/qca8k.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-)drivers/net/dsa/qca8k.c +6
-2@@ -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" );
Quoted 14 lines
drivers/net/dsa/qca8k.h line 91
Quoted 11 lines
drivers/net/dsa/qca8k.h +2
-1@@ -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)What's at bits 14 and beyond? Trying to understand the impact of this change.
Most of them are reserved bits (from Documentation).
The few we have Documentation of are debug bits about CRC handling, IPG and special mode where the MAC send pause frames based on the signal.
It's a cleanup and seems a nice change now that we are touching this part.
Quoted 6 lines
Quoted 6 lines
drivers/net/dsa/qca8k.h +0
-0#define QCA8K_REG_PORT_STATUS (_i) (0x07c + (_i) * 4)#define QCA8K_PORT_STATUS_SPEED GENMASK(1, 0)#define QCA8K_PORT_STATUS_SPEED_10 0Signature · 1 line
2.36.1
Signature · 1 line
Ansuel
Quoted 10 lines · Vladimir Oltean
Quoted 8 lines · 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 <[email protected]>---
Quoted 8 lines
I think this could very well qualify as a regression and have a tag of:
Fixes 5950c7c0a68c ("net: dsa: qca8k: add support for mgmt read/write in Ethernet packet")if it was presented along with a situation where users could hit some real life conditions where the Ethernet management interface isn't functional.
It's really to handle corner case... In testing the MTU change (and noticing the mgmt ethernet going "macheroni") I notice the timeout was absurdly high. In a situation where something goes wrong at least you can have access to it after some time.
Ok I will add the fixes tag.
Quoted 19 lines
Quoted 19 lines
drivers/net/dsa/qca8k.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/dsa/qca8k.h +1
-1@@ -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 2Signature · 1 line
2.36.1
Signature · 1 line
Ansuel