Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1103332imm; Fri, 15 Jun 2018 11:14:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLO/cg2ifU7xESwTSslty1n4jA0wndDYNI7oIlrVlmPeayqJf743qt+IEjqAPl1QYWGCI7i X-Received: by 2002:a65:6356:: with SMTP id p22-v6mr2607754pgv.20.1529086453824; Fri, 15 Jun 2018 11:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529086453; cv=none; d=google.com; s=arc-20160816; b=ob3u4dEHebpxIw5EcgfiZEvgENYpXFJRL4v33LjM9ZgqWKmj+T8ghUVnAgP3ZGPa5d ZUwe1R9BS1bnGG7R8gPM03V7asNS72qnUeu+pVFnfpOPxM2yLkDl65B3T4nlvnc8BphJ vvmXDgR3/78IBzp1a/9Fzl/1+w4e9kpFGrwS0p2T1Tvvjo1zN9j4aqkP18OB8pNEu9gt t/iroUFptowklmtNkH57hy/SfUYMxGZR3lrwzDOYXFEXNH37/wEecnfipJ2dlUaZ2o6Q X6nGBTRrDmafOqbmzxWA2dKi6i8aoQ3SgGlSbvZ4bBdy5kbRohd4gZ1Jl087kNufECpL c/FA== 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=GKXqXY+mjPmPRZE5GHzSuesu2isoExZkPaVff6/WwVU=; b=X0SPfEVx/EZ+YuID1fGoppRqRxOO0awHoe8wfq1wJN4TTF3lWEeYzJtquezWIxwy62 /Y58Yn6He6sKL9RKsETCp/pBGe7wycBatwx7Vz3WQZRapudVlue2JAinSnUaUDFYTlCa WeG12fBOA3EEwrKh2BT/QmoGI0da6cWP0jGBVMkicposra7WDIU4op1GQTxVJg2bTfuR D+f5EGtQvKCBHbhkjBAru6d6VbX2msS6VM2fJmG7d56zkcIe/EDanmh6pNr5r02yNPlA 5Zg2hkJY2LXRcKSoLq1cJxi2rpgPjUMl712iapz4ukOGlRee/rIKGzSdjYZmF3Jo8T6a 1Uiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UX5bzRbr; 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 p7-v6si8168716plk.293.2018.06.15.11.13.59; Fri, 15 Jun 2018 11:14:13 -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=UX5bzRbr; 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 S1756438AbeFOSN3 (ORCPT + 99 others); Fri, 15 Jun 2018 14:13:29 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35828 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756357AbeFOSNY (ORCPT ); Fri, 15 Jun 2018 14:13:24 -0400 Received: by mail-lf0-f67.google.com with SMTP id i15-v6so15909454lfc.2 for ; Fri, 15 Jun 2018 11:13:23 -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=GKXqXY+mjPmPRZE5GHzSuesu2isoExZkPaVff6/WwVU=; b=UX5bzRbrSFHzSSL7MNjOYQWYl/I6RelZFDs35q5ITBMJOEq0AtCC2swpueD6v//HXh dhA3ZG+9dVflC0S+jUqPxhp4s1UFvQnkU4QVDfyDzxW7m1zILwLAfrxHAVPssYMCUrvf mH0qtP12fb/aqUmFiKJwFtZoMEvtaboVHfMqY= 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=GKXqXY+mjPmPRZE5GHzSuesu2isoExZkPaVff6/WwVU=; b=kldhsl7WF0fTluy76cHrG4qMJ8nqaNBh4U/4kW1HxVT+OFI80OwLkR43Q+OHa3mD/H 3H1IjrAiPdMlo0ngAUEJEVkFmcQmkVdzCbNfbHtQXPpfYtFlL3bjrbNWDOnMSNF/3E3O OBbJpTc4PgzHG+xXVs+zZSu4K37HW0t5HNv3IqslZ7yxxNwEWHEezcb9IS0JTfSosGY/ tR8LLAWaZPhNWuxmez+9V6/qmOhAvPZSU8NZT88aQthLGlAPNa7G69GiE5dE9F+xD/E8 Xt8LrpVy98w0AU/gfPoTNA80AoWtzD4v3n+CleMzuj3TtL61E8i63so3L2zPlJcSxLQE qRHw== X-Gm-Message-State: APt69E3Tl5qnCTSflyeaNkXJsbm4QPN4EVVb+7/oadx+bDHsNKvocZwr 2Na6CK1t69qOiahtHW8ct9FdoQ== X-Received: by 2002:a19:274e:: with SMTP id n75-v6mr1779216lfn.14.1529086402548; Fri, 15 Jun 2018 11:13:22 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id h4-v6sm1543260ljc.8.2018.06.15.11.13.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 11:13:21 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net 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 v3 net-next 5/6] net: ethernet: ti: cpsw: restore shaper configuration while down/up Date: Fri, 15 Jun 2018 21:13:09 +0300 Message-Id: <20180615181310.10437-6-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615181310.10437-1-ivan.khoronzhuk@linaro.org> References: <20180615181310.10437-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. 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 19573627a9bb..e745b4a519dd 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1807,6 +1807,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); @@ -1886,6 +1931,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