Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3861311imm; Sat, 21 Jul 2018 05:01:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc9fE9YN8QBmkqAusg+4/Czm9tDpVdcDj+QYD5j9LYYEJ0aEhsKXTpOgTKtLTT4llu86p7s X-Received: by 2002:a63:c608:: with SMTP id w8-v6mr5397891pgg.16.1532174462754; Sat, 21 Jul 2018 05:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532174462; cv=none; d=google.com; s=arc-20160816; b=MITGzCMpeueGHsXFlFvQDv3cHJfstW0lHA3iQvZWhZJVrOeAYYKklQI3JVCazj/6WP VUm13bqj/D4x4iUgy5ef0kjeTbCzwU+DmlbHJcr9prYGwzwa7SCLh6mY4+nYw1uQpIVe BrB+bBv+BbLCkHbDO3OYJHop/+t9yIvEXY1u1L7OwbI5nYVUELJ3CrkJXIjyvqLUThRl SObGPByrUSswweF6wJzijXrBwdpCa9oz56sLKBWUzILO14kTXIt+Vz02JYD602DIiPXd lbUbQaKJ9G14Nv4l7IDJmGhwodryNIPyNVdpul+On6cIO4Wiq1vmmBXwbUO0ZX4gl/oE g/bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=1YA/ffmI4lvPW6BD2uhQsoeiW5XV+DX4SZhSwKauGOw=; b=svF5ahyIRZ7tYIJvQYaTQ53hECL+sQe3CfUCfUxzu2Uj8gy/Jy77PLxYlMKvrT4OCt Qr/QAF7MnwosWk79HDQ6sjegxsTXfVv8RUzTXoMofAIdUKbc5GbrsklSnQKCaojOpijs 0KiFBmlu17KmeBDQyQ4aKfk6KnBvNrG+dXdmbr8Fb+jE7rxVgavKvsfw8H5aRbPBQtRv 0Mzaps1eH1ieED3ZaSyPjhC9TJKtHubLZBaVokBqVDe/TqYEt97+KUVENNINEv12NNKH EQRxuOggwX3KDbsUraV/jp/cdLS9kPeWU2lFg6ldXQVCSBONsAxUmCBGC/mLZa6L3cvb kReQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TQQ+xuPy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v129-v6si3721785pgv.610.2018.07.21.05.00.48; Sat, 21 Jul 2018 05:01:02 -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; dkim=pass header.i=@linaro.org header.s=google header.b=TQQ+xuPy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728271AbeGUMwM (ORCPT + 99 others); Sat, 21 Jul 2018 08:52:12 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:44469 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728028AbeGUMwL (ORCPT ); Sat, 21 Jul 2018 08:52:11 -0400 Received: by mail-lj1-f193.google.com with SMTP id q127-v6so13184294ljq.11 for ; Sat, 21 Jul 2018 04:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1YA/ffmI4lvPW6BD2uhQsoeiW5XV+DX4SZhSwKauGOw=; b=TQQ+xuPyV0qwrF/V1dFImuWPHaG+oPPFqLH9G6xdeRnk6knbT+TGup/Q07LJ2AYdS+ 4T9goXTzmz60Jtv97jEx7/937mxahREDDToQR7GDsu1dnjlZNPm4SJbCF7RXk1HQGM3j a0htMvw4NikRfNwgZkXp4jZG0Nos6CSfPsKy8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1YA/ffmI4lvPW6BD2uhQsoeiW5XV+DX4SZhSwKauGOw=; b=gQpgeGBgAE0fPRdKjgK3GyxR5nibCk5yL+C33bjyHmiEaG3gc8rBnhkSKDG3PJGF7F o1kHtNwQ9OZ0Pxp331LlY0KeD6lX89PNgTmyY1R012k2BiPK70klDfIk4b+wt9TELfSC SbpMfIBUob8N68WahgMmHW8i+PZW2Z2rTI2WGPXjT9rpCBHCFT19gHEwh3D/VbO8txcr QetLUoLeHrM+cRAZ8fr+0KBVvYtJ9XcW3AsrvlhqoKWlmSHkC3buDoTdvKR9+uRJx0XJ kZf55TVolWvzdYA0VzKpfScXMwo70ZEmuNr0xlIKu8JGJz+oALE0MJH2771MtasaWwJG Z29Q== X-Gm-Message-State: AOUpUlGEKJiyXkgPDdRQWjuHRiDkGCvvU5NItusTpEBMVe8ER81+98QW VMEaQ+ljgsD25v0aZuv+1BAVoA== X-Received: by 2002:a2e:800e:: with SMTP id j14-v6mr4134395ljg.114.1532174380338; Sat, 21 Jul 2018 04:59:40 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id 73-v6sm664260lfs.44.2018.07.21.04.59.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jul 2018 04:59:39 -0700 (PDT) From: Ivan Khoronzhuk To: davem@davemloft.net, grygorii.strashko@ti.com Cc: corbet@lwn.net, akpm@linux-foundation.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, vinicius.gomes@intel.com, henrik@austad.us, jesus.sanchez-palencia@intel.com, ilias.apalodimas@linaro.org, p-varis@ti.com, spatton@ti.com, francois.ozog@linaro.org, yogeshs@ti.com, nsekhar@ti.com, andrew@lunn.ch, Ivan Khoronzhuk Subject: [PATCH v4 net-next 5/6] net: ethernet: ti: cpsw: restore shaper configuration while down/up Date: Sat, 21 Jul 2018 14:59:22 +0300 Message-Id: <20180721115923.1389-6-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180721115923.1389-1-ivan.khoronzhuk@linaro.org> References: <20180721115923.1389-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Need to restore shapers configuration after interface was down/up. This is needed as appropriate configuration is still replicated in kernel settings. This only shapers context restore, so vlan configuration should be restored by user if needed, especially for devices with one port where vlan frames are sent via ALE. Reviewed-by: Grygorii Strashko Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 449dc7f1e5f8..171abcfb6184 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1808,6 +1808,51 @@ static int cpsw_set_cbs(struct net_device *ndev, return ret; } +static void cpsw_cbs_resume(struct cpsw_slave *slave, struct cpsw_priv *priv) +{ + int fifo, bw; + + for (fifo = CPSW_FIFO_SHAPERS_NUM; fifo > 0; fifo--) { + bw = priv->fifo_bw[fifo]; + if (!bw) + continue; + + cpsw_set_fifo_rlimit(priv, fifo, bw); + } +} + +static void cpsw_mqprio_resume(struct cpsw_slave *slave, struct cpsw_priv *priv) +{ + struct cpsw_common *cpsw = priv->cpsw; + u32 tx_prio_map = 0; + int i, tc, fifo; + u32 tx_prio_rg; + + if (!priv->mqprio_hw) + return; + + for (i = 0; i < 8; i++) { + tc = netdev_get_prio_tc_map(priv->ndev, i); + fifo = CPSW_FIFO_SHAPERS_NUM - tc; + tx_prio_map |= fifo << (4 * i); + } + + tx_prio_rg = cpsw->version == CPSW_VERSION_1 ? + CPSW1_TX_PRI_MAP : CPSW2_TX_PRI_MAP; + + slave_write(slave, tx_prio_map, tx_prio_rg); +} + +/* restore resources after port reset */ +static void cpsw_restore(struct cpsw_priv *priv) +{ + /* restore MQPRIO offload */ + for_each_slave(priv, cpsw_mqprio_resume, priv); + + /* restore CBS offload */ + for_each_slave(priv, cpsw_cbs_resume, priv); +} + static int cpsw_ndo_open(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); @@ -1887,6 +1932,8 @@ static int cpsw_ndo_open(struct net_device *ndev) } + cpsw_restore(priv); + /* Enable Interrupt pacing if configured */ if (cpsw->coal_intvl != 0) { struct ethtool_coalesce coal; -- 2.17.1