linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next PATCH] net: ethernet: stmicro: stmmac: permit MTU change with interface up
@ 2022-06-14 22:41 Christian 'Ansuel' Marangi
  2022-06-16  2:55 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Christian 'Ansuel' Marangi @ 2022-06-14 22:41 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Maxime Coquelin, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel
  Cc: Christian 'Ansuel' Marangi

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 'Ansuel' Marangi <ansuelsmth@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index d1a7cf4567bc..a968a13b3183 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5448,11 +5448,6 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
 
 	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;
@@ -5466,6 +5461,14 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
 
 	dev->mtu = mtu;
 
+	if (netif_running(dev)) {
+		netdev_dbg(priv->dev, "restarting interface to change its MTU\n");
+		stmmac_release(dev);
+
+		stmmac_open(dev);
+		stmmac_set_filter(priv, priv->hw, dev);
+	}
+
 	netdev_update_features(dev);
 
 	return 0;
-- 
2.36.1


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

* Re: [net-next PATCH] net: ethernet: stmicro: stmmac: permit MTU change with interface up
  2022-06-14 22:41 [net-next PATCH] net: ethernet: stmicro: stmmac: permit MTU change with interface up Christian 'Ansuel' Marangi
@ 2022-06-16  2:55 ` Jakub Kicinski
  2022-06-16 12:04   ` Ansuel Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-06-16  2:55 UTC (permalink / raw)
  To: Christian 'Ansuel' Marangi
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Paolo Abeni, Maxime Coquelin,
	netdev, linux-stm32, linux-arm-kernel, linux-kernel

On Wed, 15 Jun 2022 00:41:41 +0200 Christian 'Ansuel' Marangi wrote:
> +	if (netif_running(dev)) {
> +		netdev_dbg(priv->dev, "restarting interface to change its MTU\n");
> +		stmmac_release(dev);
> +
> +		stmmac_open(dev);
> +		stmmac_set_filter(priv, priv->hw, dev);

What if stmmac_open() fails because the memory is low or is fragmented?

You'd need to invest more effort into this change and try to allocate
all the resources before shutting the device down.

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

* Re: [net-next PATCH] net: ethernet: stmicro: stmmac: permit MTU change with interface up
  2022-06-16  2:55 ` Jakub Kicinski
@ 2022-06-16 12:04   ` Ansuel Smith
  0 siblings, 0 replies; 3+ messages in thread
From: Ansuel Smith @ 2022-06-16 12:04 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Eric Dumazet, Paolo Abeni, Maxime Coquelin,
	netdev, linux-stm32, linux-arm-kernel, linux-kernel

On Wed, Jun 15, 2022 at 07:55:07PM -0700, Jakub Kicinski wrote:
> On Wed, 15 Jun 2022 00:41:41 +0200 Christian 'Ansuel' Marangi wrote:
> > +	if (netif_running(dev)) {
> > +		netdev_dbg(priv->dev, "restarting interface to change its MTU\n");
> > +		stmmac_release(dev);
> > +
> > +		stmmac_open(dev);
> > +		stmmac_set_filter(priv, priv->hw, dev);
> 
> What if stmmac_open() fails because the memory is low or is fragmented?
> 
> You'd need to invest more effort into this change and try to allocate
> all the resources before shutting the device down.

Well what I'm doing here is following what is done with other similar
function in stmmac. For example the reinit_queues and reinit_ringparam
doesn't do such check.

But ok you are right, will see a good solution to change stmmac_open to
preallocate the buffers.

-- 
	Ansuel

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

end of thread, other threads:[~2022-06-16 12:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-14 22:41 [net-next PATCH] net: ethernet: stmicro: stmmac: permit MTU change with interface up Christian 'Ansuel' Marangi
2022-06-16  2:55 ` Jakub Kicinski
2022-06-16 12:04   ` Ansuel Smith

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).