Skip to content

Commit 386228c

Browse files
Ansuelkuba-moo
authored andcommitted
net: dsa: qca8k: reset cpu port on MTU change
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: f58d259 ("net: dsa: qca8k: implement the port MTU callbacks") Cc: [email protected] Signed-off-by: Christian Marangi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 13f28c2 commit 386228c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

drivers/net/dsa/qca8k.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,7 @@ static int
23342334
qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
23352335
{
23362336
struct qca8k_priv *priv = ds->priv;
2337+
int ret;
23372338

23382339
/* We have only have a general MTU setting.
23392340
* DSA always set the CPU port's MTU to the largest MTU of the slave
@@ -2344,8 +2345,27 @@ qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
23442345
if (!dsa_is_cpu_port(ds, port))
23452346
return 0;
23462347

2348+
/* To change the MAX_FRAME_SIZE the cpu ports must be off or
2349+
* the switch panics.
2350+
* Turn off both cpu ports before applying the new value to prevent
2351+
* this.
2352+
*/
2353+
if (priv->port_enabled_map & BIT(0))
2354+
qca8k_port_set_status(priv, 0, 0);
2355+
2356+
if (priv->port_enabled_map & BIT(6))
2357+
qca8k_port_set_status(priv, 6, 0);
2358+
23472359
/* Include L2 header / FCS length */
2348-
return qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, new_mtu + ETH_HLEN + ETH_FCS_LEN);
2360+
ret = qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, new_mtu + ETH_HLEN + ETH_FCS_LEN);
2361+
2362+
if (priv->port_enabled_map & BIT(0))
2363+
qca8k_port_set_status(priv, 0, 1);
2364+
2365+
if (priv->port_enabled_map & BIT(6))
2366+
qca8k_port_set_status(priv, 6, 1);
2367+
2368+
return ret;
23492369
}
23502370

23512371
static int

0 commit comments

Comments
 (0)