mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: thomas.perrot@bootlin.com
To: Nicolas Ferre <nicolas.ferre@microchip.com>,
	Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Thomas Perrot <thomas.perrot@bootlin.com>
Subject: [PATCH net-next] net: macb: allow MTU change when the interface is up
Date: Mon, 25 Mar 2024 16:27:35 +0100	[thread overview]
Message-ID: <20240325152735.1708636-1-thomas.perrot@bootlin.com> (raw)

From: Thomas Perrot <thomas.perrot@bootlin.com>

The macb_change_mtu callback doesn't allow MTU changes when the
interface is up because the MTU is used to set the buffer size on
GEM.

So, to be able to change the MTU from userspace it is necessary to
explicitly down then to up the interface, which is problematic in
some cases.

Then we suggest to reset the interface when the interface is already
up to allow to change the MTU, regardless of if the interface is up
or not.

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 898debfd4db3..5c20b162c5da 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3019,11 +3019,19 @@ static int macb_close(struct net_device *dev)
 
 static int macb_change_mtu(struct net_device *dev, int new_mtu)
 {
-	if (netif_running(dev))
-		return -EBUSY;
+	int reset = 0;
+
+	/* On GEM the buffer size is based on the MTU */
+	if (netif_running(dev)) {
+		macb_close(dev);
+		reset = 1;
+	}
 
 	dev->mtu = new_mtu;
 
+	if (reset)
+		macb_open(dev);
+
 	return 0;
 }
 
-- 
2.44.0


             reply	other threads:[~2024-03-25 15:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 15:27 thomas.perrot [this message]
2024-03-25 20:54 ` Simon Horman
2024-03-26  1:56   ` Jakub Kicinski
2024-03-26  8:49     ` Thomas Perrot
2024-03-26  9:30       ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240325152735.1708636-1-thomas.perrot@bootlin.com \
    --to=thomas.perrot@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®