netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: macb: allow MTU change when the interface is up
@ 2024-03-25 15:27 thomas.perrot
  2024-03-25 20:54 ` Simon Horman
  0 siblings, 1 reply; 5+ messages in thread
From: thomas.perrot @ 2024-03-25 15:27 UTC (permalink / raw)
  To: Nicolas Ferre, Claudiu Beznea, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Thomas Perrot

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-26  9:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-25 15:27 [PATCH net-next] net: macb: allow MTU change when the interface is up thomas.perrot
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).