Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3566129ybl; Mon, 12 Aug 2019 02:40:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwBrm6ZXWy0sArenJ4/VWkf/phHX6t8jclqh6W83SNDalEI3L+56RS3ywYtZkJSL7W1kkY X-Received: by 2002:a62:1808:: with SMTP id 8mr8652209pfy.177.1565602839705; Mon, 12 Aug 2019 02:40:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565602839; cv=none; d=google.com; s=arc-20160816; b=VaijgCxfrWLjHubBxicdWEGQ0sfLscwJ3ZCe/K/GEC6JvJePcJVFDTB6EML0vuh6UV Imjp+0N2KN++YPgkzCUhorBygSCU8NOywD3vS+f/FQ4vlyirvrVrlCakCkIByXOmRmlm vRG3NIATBAquibwhGEfU53ch2Xh9UucXikHfLr4Ah2PKFK5vcV+G/bNwdUUlSrZc7APu 1uuep9uLOwYCAdSk4YuwZE/guUNER3MIVr4eEMl8vrlUsDBQPMbfgtTSS9kMJ6B0BxVt rcB9xllbo4I8+sbqHx/qvamkTEJC5JX8ypSRMV11rw5gLLLeljk+Ql9mPuG5+LbdE0HX R8yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from; bh=PqpacRXIKN/fi5/k23YUQRiQ0RcjL0OO/WfM4zjd8E0=; b=XKMRRLE0cE9P7olQtVFQvyE0ctPis5bXV5x5D52j6FieHEsdX8M9M+d5s7+wMkmRwf AQDncVuhDoH4d0ac3RN1zUyvZjGnVSj5DdzO2YHePBqVZedPn7NGIePH6UzjIOt+BbpR Xtuhi8AIGqOthqqF8NXqX0dDK8S19S6DfovYsipaCwg0ixjMFGiUWL/++Ps5tyjQepB9 81kczZPRo+ghVK7yb+0QEx+lkNPM9QdobLf82quqzO91AUJH4K0uiPuA9A+DXi4fOCGW zqorOzJ10TYXAtzQxThrlrjgeGHMswCxkS/VtNxc/4S/wGdRvNoEP6gUyI9UR55gf0mH rRig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38si5753529pln.426.2019.08.12.02.40.24; Mon, 12 Aug 2019 02:40:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727540AbfHLJjp (ORCPT + 99 others); Mon, 12 Aug 2019 05:39:45 -0400 Received: from inva021.nxp.com ([92.121.34.21]:57636 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727490AbfHLJjh (ORCPT ); Mon, 12 Aug 2019 05:39:37 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 45E5A20031B; Mon, 12 Aug 2019 11:39:36 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 393F7200112; Mon, 12 Aug 2019 11:39:36 +0200 (CEST) Received: from fsr-ub1464-137.ea.freescale.net (fsr-ub1464-137.ea.freescale.net [10.171.82.114]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id ECBBD205ED; Mon, 12 Aug 2019 11:39:35 +0200 (CEST) From: Ioana Ciornei To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: andrew@lunn.ch, ruxandra.radulescu@nxp.com, Ioana Ciornei Subject: [PATCH 10/10] staging: fsl-dpaa2/ethsw: do not force user to bring interface down Date: Mon, 12 Aug 2019 12:39:18 +0300 Message-Id: <1565602758-14434-11-git-send-email-ioana.ciornei@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1565602758-14434-1-git-send-email-ioana.ciornei@nxp.com> References: <1565602758-14434-1-git-send-email-ioana.ciornei@nxp.com> Reply-to: ioana.ciornei@nxp.com X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Link settings can be changed only when the interface is down. Disable and re-enable the interface, if necessary, behind the scenes so that we do not force users to an if down/up sequence. Signed-off-by: Ioana Ciornei --- drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 32 ++++++++++++++++++------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c index 0f9f8345e534..99d658fefa14 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c @@ -88,16 +88,21 @@ static void ethsw_get_drvinfo(struct net_device *netdev, const struct ethtool_link_ksettings *link_ksettings) { struct ethsw_port_priv *port_priv = netdev_priv(netdev); + struct ethsw_core *ethsw = port_priv->ethsw_data; struct dpsw_link_cfg cfg = {0}; - int err = 0; - - /* Due to a temporary MC limitation, the DPSW port must be down - * in order to be able to change link settings. Taking steps to let - * the user know that. - */ - if (netif_running(netdev)) { - netdev_info(netdev, "Sorry, interface must be brought down first.\n"); - return -EACCES; + bool if_running; + int err = 0, ret; + + /* Interface needs to be down to change link settings */ + if_running = netif_running(netdev); + if (if_running) { + err = dpsw_if_disable(ethsw->mc_io, 0, + ethsw->dpsw_handle, + port_priv->idx); + if (err) { + netdev_err(netdev, "dpsw_if_disable err %d\n", err); + return err; + } } cfg.rate = link_ksettings->base.speed; @@ -115,6 +120,15 @@ static void ethsw_get_drvinfo(struct net_device *netdev, port_priv->idx, &cfg); + if (if_running) { + ret = dpsw_if_enable(ethsw->mc_io, 0, + ethsw->dpsw_handle, + port_priv->idx); + if (ret) { + return ret; + netdev_err(netdev, "dpsw_if_enable err %d\n", ret); + } + } return err; } -- 1.9.1