[PATCH 3/3] ramips: ethernet: ralink: mtu change while interface is down

Luiz Angelo Daros de Luca luizluca at gmail.com
Thu Jan 6 21:37:23 PST 2022


fe_change_mtu didn't update the registers if the interface was down.

DSA increases the CPU port MTU to accommodate the CPU tag. As this
happens while the CPU port was still down, the chip regs didn't get
updated and larger frames were dropped.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca at gmail.com>
---
 .../files/drivers/net/ethernet/ralink/mtk_eth_soc.c    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c
index be2ee6ba7f..0ae520183b 100644
--- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c
+++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c
@@ -1484,10 +1484,9 @@ static int fe_change_mtu(struct net_device *dev, int new_mtu)
 		priv->rx_ring.frag_size = PAGE_SIZE;
 	priv->rx_ring.rx_buf_size = fe_max_buf_size(priv->rx_ring.frag_size);
 
-	if (!netif_running(dev))
-		return 0;
+	if (netif_running(dev))
+		fe_stop(dev);
 
-	fe_stop(dev);
 	if (!IS_ENABLED(CONFIG_SOC_MT7621)) {
 		fwd_cfg = fe_r32(fwd_reg);
 		if (new_mtu <= ETH_DATA_LEN) {
@@ -1501,7 +1500,10 @@ static int fe_change_mtu(struct net_device *dev, int new_mtu)
 		fe_w32(fwd_cfg, fwd_reg);
 	}
 
-	return fe_open(dev);
+	if (netif_running(dev))
+		return fe_open(dev);
+
+	return 0;
 }
 
 static const struct net_device_ops fe_netdev_ops = {
-- 
2.34.0




More information about the openwrt-devel mailing list