From patchwork Sat Jul 23 14:29: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: 12927215 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 95D58C43334 for ; Sat, 23 Jul 2022 14:32:11 +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=3MopuvNjpeIrtwS53qi5Evboh+CieBtzczEwYTUFI10=; b=Xc4wHNIcZE8Yyv sxY4KVXQ8k+n5S/Yftqcdli3h6gxrNot7fU2JcqwL3PdcgOTLoIp0JZqchVgn5MX+W/yx96m8cRUO akSY6cz2G5nxIDDALagRcIH0GSrzgjeWEnjpDmTdTx7eplIWKEmCP4rNTBqzVQPu3Yyri0x2HN1CV QObYs4VtRHFVnEytPt2ZRU+vOLAIrQT5RhYStrqJUWpldjgNgpnFjgdphKqZuAKw+zUpnRg9AStQo wYxqNWGg58k/bOh9KwwHvDA4twIt84qilvtrgVTpRZ+IbP1xx+jzhv0ZNW0COZhSqFLEM4zfW+cuJ WXMc701UJi2XUKuactIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFG9b-0046oe-CQ; Sat, 23 Jul 2022 14:30:51 +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 1oFG8q-00465R-04 for linux-arm-kernel@lists.infradead.org; Sat, 23 Jul 2022 14:30:06 +0000 Received: by mail-wm1-x32d.google.com with SMTP id f24-20020a1cc918000000b003a30178c022so6744368wmb.3 for ; Sat, 23 Jul 2022 07:30:02 -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=GX0e7m5ZrkPjpxkJdIBL+iV+EyM6eAVNIs5WQVoDC5I=; b=GuUs35D+Od53ehyBq7jSWrPuxnPg2k3rYm9X0U1icEB1hrTVCqlqQBL8TjQJp8E9Fu UyD0jy55G4vAFxREf4ZMZVOKBCT5oCkzuLx9FMnVNRjKfN3h6OQ2eYIzl0RItI+9XMJr vNZ1uImREQXKLyZO9AvoWamfOWSQhYgUSQh1ZxrlAOxZLgYdU3dpew+Cbc+4tvsBPULQ 8MtbxGJe+v2wSYdspSqQPa8PFQYd685D1/Vwj3nmTOCHo7JlCqSmJ9qL9s2NoxmC+5G0 5Ho7csQZ/+WVE5zDHwe1NoeSCbh2Wkn43qweWXZNJgS01xQuE7cpYZ74F6srqK4GThyi aWFQ== 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=GX0e7m5ZrkPjpxkJdIBL+iV+EyM6eAVNIs5WQVoDC5I=; b=WgO+B/fjQjKuMBKXB0Z6nx7Pg1z9MHu+gLUqunpznh5gr/uXlyS5VyFKkjfqb2/r6r i2bY9LzQN83r+3Gw/Shvi26Auq/cR4NjrovErY5clvMG/B+akJgq6fMX7dPxzGlo9yID cpX93Bb2xabkIko2mTVude6wgmRsevbYrVrEjA7fgM0KuY1U4sQtec7Qty+DqofeEsOo k1a5eaEFgzONSTvXyPnSFwc0fdO/FM+bkmjr+DCckvEXdqc1hTxlW7XUzJ7Xd9wTlCVK HcVd3cvA4EemvGkzOxeH3en0CWK+jU1/sgi9UoROoTFuwKJ0uXSxejstTqND/JLQ9Rck hP7w== X-Gm-Message-State: AJIora9C2QBAamWphYKomIQPocs1MG+oIzh8n+HZlG/23ByexiclgFPQ 6K37iEUvtqob9iBIOGuxHdw= X-Google-Smtp-Source: AGRyM1vyEESD+gOYudb18RYonLwuCA9ecgk+Boyi9uzgAedUAyeJVXmG9G/HRzwQjgJRpYQqd/XNAQ== X-Received: by 2002:a05:600c:3ba3:b0:3a3:5dd:f10f with SMTP id n35-20020a05600c3ba300b003a305ddf10fmr3105539wms.185.1658586601145; Sat, 23 Jul 2022 07:30:01 -0700 (PDT) Received: from localhost.localdomain (host-87-7-207-127.retail.telecomitalia.it. [87.7.207.127]) by smtp.googlemail.com with ESMTPSA id q6-20020a1cf306000000b0039c5ab7167dsm11689717wmq.48.2022.07.23.07.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jul 2022 07:30: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 v5 5/5] net: ethernet: stmicro: stmmac: permit MTU change with interface up Date: Sat, 23 Jul 2022 16:29:33 +0200 Message-Id: <20220723142933.16030-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220723142933.16030-1-ansuelsmth@gmail.com> References: <20220723142933.16030-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220723_073004_126996_1D2721F3 X-CRM114-Status: GOOD ( 18.92 ) 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 | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 9a927ce17941..083d08b5ab0e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5552,18 +5552,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; @@ -5575,8 +5572,29 @@ 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; + } + + stmmac_set_rx_mode(dev); + } + + dev->mtu = mtu; netdev_update_features(dev); return 0;