From: Niklas Cassel <niklas.cassel@axis•com>
To: <peppe.cavallaro@st•com>, <alexandre.torgue@st•com>,
<Joao.Pinto@synopsys•com>, <f.fainelli@gmail•com>
Cc: <netdev@vger•kernel.org>, <linux-kernel@vger•kernel.org>,
Niklas Cassel <niklass@axis•com>
Subject: [PATCH net-next] net: stmmac: allow changing the MTU while the interface is running
Date: Tue, 4 Apr 2017 14:18:54 +0200 [thread overview]
Message-ID: <20170404121854.606-1-niklass@axis.com> (raw)
From: Niklas Cassel <niklas.cassel@axis•com>
Setting ethtool ops for stmmac is only allowed when the interface is up.
Setting MTU (a netdev op) for stmmac is only allowed when the interface
is down.
It seems that the only reason why MTU cannot be changed when running is
that we have not bothered to implement a nice way to dealloc/alloc the
descriptor rings.
To make it less confusing for the user, call ndo_stop() and ndo_open()
from ndo_change_mtu(). This is not a nice way to dealloc/alloc the
descriptor rings, since it will announce that the interface is being
brought down/up to user space, but there are several other drivers doing
it this way, and it is arguably better than just returning -EBUSY.
Signed-off-by: Niklas Cassel <niklas.cassel@axis•com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c1c63197ff73..fd268dc0df02 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3109,17 +3109,15 @@ static void stmmac_set_rx_mode(struct net_device *dev)
*/
static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
{
- struct stmmac_priv *priv = netdev_priv(dev);
-
- if (netif_running(dev)) {
- netdev_err(priv->dev, "must be stopped to change its MTU\n");
- return -EBUSY;
- }
-
dev->mtu = new_mtu;
netdev_update_features(dev);
+ if (netif_running(dev)) {
+ stmmac_release(dev);
+ stmmac_open(dev);
+ }
+
return 0;
}
--
2.11.0
next reply other threads:[~2017-04-04 12:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-04 12:18 Niklas Cassel [this message]
2017-04-05 14:49 ` [PATCH net-next] net: stmmac: allow changing the MTU while the interface is running David Miller
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=20170404121854.606-1-niklass@axis.com \
--to=niklas.cassel@axis$(echo .)com \
--cc=Joao.Pinto@synopsys$(echo .)com \
--cc=alexandre.torgue@st$(echo .)com \
--cc=f.fainelli@gmail$(echo .)com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=niklass@axis$(echo .)com \
--cc=peppe.cavallaro@st$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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