Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4985708imm; Fri, 18 May 2018 14:18:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrDfqPHtbbpmmAUMDoouAfbXzvVIzFcN2nbm+Ztb9GgPLeQKPs9VVBtGohAMJrGbsqBoy/T X-Received: by 2002:a17:902:70c9:: with SMTP id l9-v6mr11018468plt.382.1526678286148; Fri, 18 May 2018 14:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526678286; cv=none; d=google.com; s=arc-20160816; b=mVSReLeRYozjfR1jTCWgM19p2RPtiG/fb2SZSF8zXgY7/RPHfT+zu7vEe9+LAzUDbN TPi4PyA8Y5rsiW+8wUe01brhMFPdNfNwcjI2e17h2VkcGpzDVU1cQO6ybNS5uxJi1Vg9 oJU+XQbr8nJfWAi59nz63i0io7OTGOQLi1ymWD5FuSHdGbQ8mWycc8nyNq4xrkR4SWcQ M93o90BYKuVPEtiQqQLrpr87DNQ/wnvzEKm9DUpDxKvblbqX5V4TXbsmiGtnYEh3ueuW omJ14CSewKw8KIdEoI/mBDcms72hqoNo3qoftAc6bKo4ikoV6CJktdaXgixVMTDfnatt IhOw== 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=ipc/qNQrKTE3lp0xIgbG2YftOJpAgeq9/oT0QY88PVM=; b=UVbDmib0SibZjLU1btHq24XXFDkwVANX2znRnWisO1q1rxv7/th4ZoBxQtLQpdtwBF q7oH3gVltJzbkwpDmwLwQUnVzUEGv7j51u0ifqdJjXapZFCL7fP1zVuOx5rixiWbecCZ dvtUxgv6AkQDN8XdVTzZJhVKJOCvtL6S6NqCvBj+nadt/usHHQ7A9v/D45VA+C8HTLMp UoGNBARJHrKrEwwIOxFjafffwYPdWmUGC+JXI3mBsrfHZ+yTLB4BkQZtLq4SDiykVMOG GpG3tPvMDDEauGYg/Ex7lB2EC7AMfd051l9Vkk1rKr58EdWOZy6YwWRkypxa0CfXjZIC a8vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cYLg6nVg; 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 s10-v6si6553965pgs.189.2018.05.18.14.17.51; Fri, 18 May 2018 14:18:06 -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=cYLg6nVg; 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 S1752537AbeERVQG (ORCPT + 99 others); Fri, 18 May 2018 17:16:06 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:46884 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215AbeERVPY (ORCPT ); Fri, 18 May 2018 17:15:24 -0400 Received: by mail-lf0-f67.google.com with SMTP id 16-v6so15882455lfs.13 for ; Fri, 18 May 2018 14:15: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=ipc/qNQrKTE3lp0xIgbG2YftOJpAgeq9/oT0QY88PVM=; b=cYLg6nVgAizCZaRcHDYMwkNLbvsEl/X3OuHR7MGL8URg4qSyVubNI3Y0DkGjdn+Fzw E3Ul2yLZQhINnJ/dIdmQiCrxlhbaFBFtUdck2yNIVLu1AGed2j0Px3K5L580JZ2GiRiJ v/oKeeE+LtPsjf38SVUjT9EPCnlOfSp/y+1lc= 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=ipc/qNQrKTE3lp0xIgbG2YftOJpAgeq9/oT0QY88PVM=; b=TGzPY1lmyKhVFtERPjzDMqBGBSYpyajKZEMHjw09VWlyvn5SFzmQutoul1ybR2eoOX uTYtoDIl22XDmnuWE9hYFk/Uvk1hzptcXJkLjAzNO/99spSXZx1pUVmKiDWUSNoqkcmJ Ww0pzRCZasqMq4u6Mfebef//HwOpS4hZGspSKQdxhjLC4QJ6ND+DttN/CpM7rr13zMH1 YPHZYd0lboayDKTsSKhDmmIINd0YgTmtc7anK5sEo4mghrmbL8SeXHO1Hr1NEEnEyGmQ xG2cgl9/WSijW0dKbFyJ4s/dhIDLcCu+iSLlVlq78UCXiKbf6Dl4QgM8zKYpIi7Sjg0N t4LQ== X-Gm-Message-State: ALKqPwdXb7nHsMg47+4tYWVhKYxFOosaCnTEUcMby1rafyy0W1ZjzNH3 kofKaxk2ZvG5dAOw3m+2iBkqYA== X-Received: by 2002:a19:e10c:: with SMTP id y12-v6mr19149717lfg.9.1526678122503; Fri, 18 May 2018 14:15: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 g20-v6sm2045991lfk.39.2018.05.18.14.15.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 14:15: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, Ivan Khoronzhuk Subject: [RFC PATCH 5/6] net: ethernet: ti: cpsw: restore shaper configuration while down/up Date: Sat, 19 May 2018 00:15:09 +0300 Message-Id: <20180518211510.13341-6-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518211510.13341-1-ivan.khoronzhuk@linaro.org> References: <20180518211510.13341-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 c7710b0e1c17..c3e88be36c1b 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.0