1 From 3470079687448abac42deb62774253be1d6bdef3 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Sat, 23 Jul 2022 16:29:33 +0200
4 Subject: [PATCH 5/5] net: ethernet: stmicro: stmmac: permit MTU change with
7 Remove the limitation where the interface needs to be down to change
8 MTU by releasing and opening the stmmac driver to set the new MTU.
9 Also call the set_filter function to correctly init the port.
10 This permits to remove the EBUSY error while the ethernet port is
11 running permitting a correct MTU change if for example a DSA request
12 a MTU change for a switch CPU port.
14 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
15 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
17 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 30 +++++++++++++++----
18 1 file changed, 24 insertions(+), 6 deletions(-)
20 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
21 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
22 @@ -5626,18 +5626,15 @@ static int stmmac_change_mtu(struct net_
24 struct stmmac_priv *priv = netdev_priv(dev);
25 int txfifosz = priv->plat->tx_fifo_size;
26 + struct stmmac_dma_conf *dma_conf;
27 const int mtu = new_mtu;
31 txfifosz = priv->dma_cap.tx_fifo_size;
33 txfifosz /= priv->plat->tx_queues_to_use;
35 - if (netif_running(dev)) {
36 - netdev_err(priv->dev, "must be stopped to change its MTU\n");
40 if (stmmac_xdp_is_enabled(priv) && new_mtu > ETH_DATA_LEN) {
41 netdev_dbg(priv->dev, "Jumbo frames not supported for XDP\n");
43 @@ -5649,8 +5646,29 @@ static int stmmac_change_mtu(struct net_
44 if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB))
48 + if (netif_running(dev)) {
49 + netdev_dbg(priv->dev, "restarting interface to change its MTU\n");
50 + /* Try to allocate the new DMA conf with the new mtu */
51 + dma_conf = stmmac_setup_dma_desc(priv, mtu);
52 + if (IS_ERR(dma_conf)) {
53 + netdev_err(priv->dev, "failed allocating new dma conf for new MTU %d\n",
55 + return PTR_ERR(dma_conf);
58 + stmmac_release(dev);
60 + ret = __stmmac_open(dev, dma_conf);
63 + netdev_err(priv->dev, "failed reopening the interface after MTU change\n");
67 + stmmac_set_rx_mode(dev);
71 netdev_update_features(dev);