From patchwork Sat Jul 16 18:45:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 12920240 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 C532CC433EF for ; Sat, 16 Jul 2022 18:50:07 +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=rj7SBRhW4uWDj9 29YDEIYRWAGvu4gjk6AXrzsy2iE6RYTdW3Ewp7Z8i2fO8yfjjCTESunn0H8u+wql1vHa2oD5Kw61z zeKWjTJCbRHBuWZi35aDkMH22Je1d8fEzVmGHE2PN0XvlvE347/NgFJtU7Q9I0CxgegdcNoq/naya x9NHzEYaINU2sllmpTkqxOhJRA9XnOJe0DP+kogGduKabcgcF74eKDyopz57EqDYndm6BYnu8bYe7 MJxWPPriJ5h6CPUih5KJ6EtVdLzyePpzaDomV+vaIdA3tCqstkHM0H7dcNHKxIMBhIakRtk45nN9/ M0rOeDiWd7aYa6U6mjLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCmqW-00056O-RK; Sat, 16 Jul 2022 18:48:57 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCmpe-0004bd-Sg for linux-arm-kernel@lists.infradead.org; Sat, 16 Jul 2022 18:48:07 +0000 Received: by mail-wm1-x32d.google.com with SMTP id j29-20020a05600c1c1d00b003a2fdafdefbso4960278wms.2 for ; Sat, 16 Jul 2022 11:48:01 -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=GPeiZoczfDK/M7OA6cgPAdDEQuy7q4oQ4/J0Jx+QD9pT2oclHHBVr8Lz1ShjwExYaF YWjfhslIg1G1XIe1UJLW9PzeAeBFxjz849F6WFNrnRzxOaZmOX/3xgMsO1rXu2YNpw1c m2oPJJPFnjC1cCZ4tJqbCAdFUgCaDippl5q5h9uKkVk/ARzxtQthiIADCrN7KwijKqVx ZLngAKi/21m3hyGJlfhFgRbqh55LttD+4GPrQlM/rWRo1bw9oEtGMWuxbNBB5s2fKbk3 korWpZ54MDYm8eZHrd/jE7O/cFgfTdjczol+2/fF/p3NzpevJ/bkyVLeK3VukOqjoV8V X8YA== 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=DQJYPcvZYwWWLl0auAWSIBvBi8E26zAbkC7O6IMq+Ye7OVqnSuxKpiqZfEFH0n9YAy WLm53FCwvyVFzpLmRI4hXP84cvcie+u8CHmfVW8B6y5h3ytl4jrUe7ictI4C9GxbHwyn YTRzymmgVpEjfCCcqq9Vze1Txu7LEYamO005T+oxAmXXHHCJiCRKauROVfTPYyX11S1o alsCy42B/tAI0J3MyBN4D4wEcZiKNEGGTHkVGoG0JWWGVtkoYn0bms4dTUtul8bGVpg5 FtinmampjbpxA6z/kNLAygc7pPkbcYS32pGgNLxxMAEe9SGkYCCyM6HX4LSIhr0ZPM4z fRgg== X-Gm-Message-State: AJIora9WZ5iucqOFCXhBtKJXM6/ZKRiVXEnl/e0rsXptXK6tTqg57fvs G8RAVsCE0X/GazokxqCuUZ8= X-Google-Smtp-Source: AGRyM1vp2hOuXQMemE8ele8pYLWZe5OAq75JOZbJjs6K+cujKRd6tR/8rnpOTd/sTSJ1znaSXShsVQ== X-Received: by 2002:a05:600c:34c4:b0:3a2:e259:925b with SMTP id d4-20020a05600c34c400b003a2e259925bmr19241509wmq.99.1657997280501; Sat, 16 Jul 2022 11:48:00 -0700 (PDT) Received: from localhost.localdomain (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.googlemail.com with ESMTPSA id u18-20020a05600c19d200b003973c54bd69sm13649961wmq.1.2022.07.16.11.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jul 2022 11:48:00 -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 v2 5/5] net: ethernet: stmicro: stmmac: permit MTU change with interface up Date: Sat, 16 Jul 2022 20:45:33 +0200 Message-Id: <20220716184533.2962-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220716184533.2962-1-ansuelsmth@gmail.com> References: <20220716184533.2962-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_114802_986389_DE24459F X-CRM114-Status: GOOD ( 18.94 ) 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;