From patchwork Sat Jul 16 23:08:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 12920326 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B56CC43334 for ; Sat, 16 Jul 2022 23:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=24eP6Wrl8OCLUtPb84o+3S1MH2bCgTBQTh0QkpiIhms=; b=Rw6H+uv7/HMogs H6iqfT3u+Z8ETDFWbCNxXvwir9DiAXcPHObR9tRXnwpbKbCeK4y06nHY89x5Bx/KPuRY5KETYGYp6 yH86MLsrSUVCdkBpJUQ294rMsH04N7sMNHQbLxgNrtvDuAPPXVwu2PVPEO7FE2wcPr1N+VcTTeFBt zOJpltipmob8EWBFoDZ8e44Mj3zmya/EvRNaDgZvXv8hYFZ2Wqjmao4BXTG2hBzaZ3POpEgNZQwPM A4YI8Hojsdwtskhha/ghFZUMxukYZr4QB3R5nzRLKNl2leRIlCWYotef4o9QFJUa+DsNklAZj7Px/ s186l/geaIxJC9QDyS6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCquA-001BPq-BM; Sat, 16 Jul 2022 23:08:58 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCqtU-001BAB-IS for linux-arm-kernel@lists.infradead.org; Sat, 16 Jul 2022 23:08:20 +0000 Received: by mail-wr1-x42c.google.com with SMTP id d16so11809542wrv.10 for ; Sat, 16 Jul 2022 16:08:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HbvtEGsMnEuUqxalVZhu5nqYG6ItmLh575xNRmd1EY8=; b=cEphPFT8NMAhz2OTlbsbTFKS7ThG5Zx3zSRzc3b/JDptIOxxNpJH8Tezp89SGRMQVt 9meyrRM5jS/nGsmw/1efAc7PRJjkekzvEUz5wZdfbDJyPECoN2+AEXcvHUpdViNaIFuS qgatX0Ak3wDZoVz12pAOMZgnNBFthZct0MRiYsQe9b6u+MkyEs7WLnUkrBugk16wWUAe bQnOL14h+kVZrLREBzv7CvRd68C1SFvp4mxdKKK6QygLkk2lho2p5F1aRH8C3Io+TLJv kD0I8aofEsNzlmbqKmd4pWf3S+Un4bo15dxDjMa4VTDluFcTYfztgKu8Yg5L4RXc1MaZ PqJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HbvtEGsMnEuUqxalVZhu5nqYG6ItmLh575xNRmd1EY8=; b=pfw4mFts1lF9xWFM7Hq7kqPkp3971CWf3XPkH5o0XaTiFAWbd6RbupR2TDLr8+PoSX +aTec5I3MH54O/MHY/0JQj8GZ7FisrMMFnGJH0e+FSErO8vC8lNzgJ3pma/uDaDGpoFz WViL/0MlTsoAxW2huVB30YGntvuyM3p8sSOIy8X4WYL18AkTp7AofMI1Zd3hhYTeUj8S MGBKfUAz+G8dKPYAtXTRt1xJx1XSyyNCfM8gzkOgeS6JoamA9UE62TbiNd89A6G+Zvv5 5oPK4uUDGM/mOdpJGwlIJoK+7HwhIxHvJI8JEBxw48wAEfBTW9m2ASKi9pKSI7EnjV1c 6eJQ== X-Gm-Message-State: AJIora+b8nCjN2kawnb74uoS3u+oOZXDlHiwRUFbxnk4iuDYfuTjpVwe Ino8cBT+gKVEpq91JmeyG8w= X-Google-Smtp-Source: AGRyM1vHXqLPb9/lz3m4XQ3KLxcwl5y1+db4LaiQameOv6ZFahwWeMM4pBVUL/MZglS3L4yfhZEntw== X-Received: by 2002:a05:6000:1f96:b0:21d:8516:9ec9 with SMTP id bw22-20020a0560001f9600b0021d85169ec9mr19150822wrb.359.1658012894474; Sat, 16 Jul 2022 16:08:14 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id l13-20020a05600c2ccd00b003a2f2bb72d5sm15150755wmc.45.2022.07.16.16.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jul 2022 16:08:14 -0700 (PDT) From: Christian Marangi To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH v3 5/5] net: ethernet: stmicro: stmmac: permit MTU change with interface up Date: Sun, 17 Jul 2022 01:08:02 +0200 Message-Id: <20220716230802.20788-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220716230802.20788-1-ansuelsmth@gmail.com> References: <20220716230802.20788-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220716_160816_644466_2306F57D X-CRM114-Status: GOOD ( 18.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Remove the limitation where the interface needs to be down to change MTU by releasing and opening the stmmac driver to set the new MTU. Also call the set_filter function to correctly init the port. This permits to remove the EBUSY error while the ethernet port is running permitting a correct MTU change if for example a DSA request a MTU change for a switch CPU port. Signed-off-by: Christian Marangi --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 53e9dbff30ae..7425941fbb40 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5551,18 +5551,15 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu) { struct stmmac_priv *priv = netdev_priv(dev); int txfifosz = priv->plat->tx_fifo_size; + struct stmmac_dma_conf *dma_conf; const int mtu = new_mtu; + int ret; if (txfifosz == 0) txfifosz = priv->dma_cap.tx_fifo_size; txfifosz /= priv->plat->tx_queues_to_use; - if (netif_running(dev)) { - netdev_err(priv->dev, "must be stopped to change its MTU\n"); - return -EBUSY; - } - if (stmmac_xdp_is_enabled(priv) && new_mtu > ETH_DATA_LEN) { netdev_dbg(priv->dev, "Jumbo frames not supported for XDP\n"); return -EINVAL; @@ -5574,8 +5571,27 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu) if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB)) return -EINVAL; - dev->mtu = mtu; + if (netif_running(dev)) { + netdev_dbg(priv->dev, "restarting interface to change its MTU\n"); + /* Try to allocate the new DMA conf with the new mtu */ + dma_conf = stmmac_setup_dma_desc(priv, mtu); + if (IS_ERR(dma_conf)) { + netdev_err(priv->dev, "failed allocating new dma conf for new MTU %d\n", + mtu); + return PTR_ERR(dma_conf); + } + stmmac_release(dev); + + ret = __stmmac_open(dev, dma_conf); + kfree(dma_conf); + if (ret) { + netdev_err(priv->dev, "failed reopening the interface after MTU change\n"); + return ret; + } + } + + dev->mtu = mtu; netdev_update_features(dev); return 0;