From patchwork Tue Jun 28 01:33:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 12897514 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 6DACCC43334 for ; Tue, 28 Jun 2022 01:36:25 +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=r1HyTjp/zK8h1XUbOX98fopAS6F4d6X4nNri5x8a6tk=; b=nMHGnVYaCuj61Q YGr/Qr0/DGJiNLeC9MsP4tPO4lQXXvq1iwLEnJi9n8QgFEuL2QKHHewY8km0Egc9CzqcBcv2XicHQ B5neDBJW76ATIpiAA7dHssOkc8DwJUtS7S0gn0NPB2Q6OmDOHlHdFozzii9I0851df3YXYJGFvoNc RU6cn2KZ7o7fWwOmvdG8/pDI9QUquMQAn9S8QIPlHOmZzgD1lWZGIk6WVHCT0j0/2a0+E9O9rC4q/ aNgUDJRmgOdphBcRnYhjC+eG/plN8XMFTjJ89mq5nPSRAjyip1PpTJB8n0rzelBpM0vOmO2EDa+0d 90u0YMzwBJLO56cCJlrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o608G-003Wb6-DV; Tue, 28 Jun 2022 01:35:12 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o607L-003WI6-74 for linux-arm-kernel@lists.infradead.org; Tue, 28 Jun 2022 01:34:18 +0000 Received: by mail-ej1-x635.google.com with SMTP id u12so22610920eja.8 for ; Mon, 27 Jun 2022 18:34:12 -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=VFjFynZy6Y6LV26469hAz6HcHpk+ATW9nFKisizAaS0=; b=HxBQCz+7pRrd8vYnRhzxjsYUhYVbh2740UtczLVj5Qadg66MxqD6v7B1UGENMsXSIh NZ95KoNdnEnToocmddB8hVQm3umvd7EQ4umzgQcF+7ZKMGvwj21qIm4vl50UEADmBO8W z/n9v0ZYxB6fIIjOLkTK7wQB9KorIFItL/CT/BUqj8or+kBD0Nu6JTxuVmz9x5N9Wrd3 Xvxps116OsXXejOkFAw3yct++Gvjy8/h29Uqxo0JpQx+hftir5R5vHETuPWv2Xepgycf 2xEUyuNHXxB0rkSuRMiahmG8E7kIlZRTSqiNp3yYJc/aCPu7xpb21I6Fji6+dgEIKsTG NsaQ== 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=VFjFynZy6Y6LV26469hAz6HcHpk+ATW9nFKisizAaS0=; b=tBzOF3mdNlmp9WrjdzuekN/BfWDb2b0s1eEfu/BoGwVAAP5GXiKiSyWd1hGcbsEY52 WCXfpCswPVRwmoj57Rwg4uG95yVit5V2nzDwedz/cUWPMNUPbnPEs/rkoY5jrM4dtYi2 4lxRM6Ik5/8CeP+P0PksO+5LEbH328py8qoley3pkuoJwjjHGhnqeC0DmJxM6m2vcDp6 25DdVuOeYlPkFdNqNGpUx3Syrmggas4ckrFAWWTYLm+qB8vRn8bpXQpPmnFr54zlvxMb 0faAYjr4ii3z6dH7z+q9IKp2oYUsBkOMtWIyl1e1XpNGsQekLb0aBRREm0rwQ6ZsIhij ak3Q== X-Gm-Message-State: AJIora8ItZgFdLtj/1PcUUkPMudl/1GKFLDw14DVZ8OHas6HyLwWf+7h 6MlJ+HRP1H+9lHlrh7A+o14= X-Google-Smtp-Source: AGRyM1uPYb3BGEYytx9I9d6gFT5JgkCfrvivXpMHCUnwEbmD4KdUhvJMfNpU409V+fTN58hTaPKq2A== X-Received: by 2002:a17:907:7251:b0:723:dc32:aefb with SMTP id ds17-20020a170907725100b00723dc32aefbmr15069172ejc.91.1656380051539; Mon, 27 Jun 2022 18:34:11 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id x13-20020a170906b08d00b00724261b592esm5693492ejy.186.2022.06.27.18.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 18:34:11 -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 RFC 5/5] net: ethernet: stmicro: stmmac: permit MTU change with interface up Date: Tue, 28 Jun 2022 03:33:42 +0200 Message-Id: <20220628013342.13581-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628013342.13581-1-ansuelsmth@gmail.com> References: <20220628013342.13581-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220627_183415_285004_22BD3607 X-CRM114-Status: GOOD ( 19.74 ) 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 330aac10a6e7..2e08be895cde 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5549,18 +5549,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; @@ -5572,8 +5569,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;