From patchwork Tue Apr 4 12:18:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 746773 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vy7MK03D3z9s8H for ; Tue, 4 Apr 2017 22:19:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753156AbdDDMTJ (ORCPT ); Tue, 4 Apr 2017 08:19:09 -0400 Received: from bastet.se.axis.com ([195.60.68.11]:51860 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752889AbdDDMTG (ORCPT ); Tue, 4 Apr 2017 08:19:06 -0400 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id A3E9718117; Tue, 4 Apr 2017 14:19:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5vRdPg82oj6e; Tue, 4 Apr 2017 14:19:01 +0200 (CEST) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id 5C2EB180E6; Tue, 4 Apr 2017 14:19:00 +0200 (CEST) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 29C6B1E08A; Tue, 4 Apr 2017 14:19:00 +0200 (CEST) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1410F1E089; Tue, 4 Apr 2017 14:19:00 +0200 (CEST) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder03.se.axis.com (Postfix) with ESMTP; Tue, 4 Apr 2017 14:19:00 +0200 (CEST) Received: from XBOX02.axis.com (xbox02.axis.com [10.0.5.16]) by seth.se.axis.com (Postfix) with ESMTP id 077CF2817; Tue, 4 Apr 2017 14:19:00 +0200 (CEST) Received: from lnxartpec1.se.axis.com (10.0.5.60) by XBOX02.axis.com (10.0.5.16) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Tue, 4 Apr 2017 14:19:00 +0200 From: Niklas Cassel To: , , , CC: , , Niklas Cassel Subject: [PATCH net-next] net: stmmac: allow changing the MTU while the interface is running Date: Tue, 4 Apr 2017 14:18:54 +0200 Message-ID: <20170404121854.606-1-niklass@axis.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Originating-IP: [10.0.5.60] X-ClientProxiedBy: XBOX04.axis.com (10.0.5.18) To XBOX02.axis.com (10.0.5.16) X-TM-AS-GCONF: 00 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Niklas Cassel 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 --- 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; }