From patchwork Mon Jul 23 21:26:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 142655 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp6512980ljj; Mon, 23 Jul 2018 14:27:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpenAAOUC2gJn0Frc/zJd/kQKzDbHdQIzd5n7OER4ZzWe/n9Q8Mi/g3+vCo8I0xhSNk8NZrj X-Received: by 2002:aa7:87d0:: with SMTP id i16-v6mr14825611pfo.82.1532381220245; Mon, 23 Jul 2018 14:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532381220; cv=none; d=google.com; s=arc-20160816; b=f5TtTS+xp4xVktjFOOKFIhnFyMgVIVRcIk9bXKAzfmGsGQQIvhOXzNnEc5yM+mhA1u eXRbAuLUvIX/x+PHhL9/HhHeQ/fGMd74mTg8wLo9SbgzSNnYRZ3zzrWvfeqjX1EuBfQQ brtzZp5akN7xNuoUu0/MZVEHLp+4jC+lPCnKfXF8nyMf7IFpCEphanAsrtjDVlPXv/PC zHgWtcVpsKs+jR54Qu15604tvRqoCkOTxIhyDDclXUKKPXGt0l8hmlnFA6LPec5YTQMu onwVa+LCJjG512a8IuA5mmX4uLeX2lec915JSHXCTZ0AwUHGghR8R8wSPd6fe9j6VMxU Lyhg== 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=d1Za27wcuN7sHeOL/0KokiwCWrvu5jc334Ssx7ln6cQ=; b=WjOoeDLZJV0SvOa0Vgo4XwZGsZRP45Y69QCTJwIH8qehKz1BFNPxhWo6NXaH0LCkfC GdGhl4h/WUM3xU25VdacihfkAbTWtXfVhoG9zQxqNYAF1FttUbnlMEzb9o/ASHiyMugn Z+f6pG59SjwWfsjLCh9/dggJDIajPKHzFLzlG9uhzM/eSD1BVpSIc8mSNX1EplXRCU/f SOOhmtFgLeSn+tu1k8btuP6gQV+ue0qpWGZ+QWcyTpUso1rSeG/ttuD5Qk6a4QMvZ7Ep BtwyQxcIQom8dHKwG2ZocetHnzMsL41LO89Xykq4zciFns34+opoDxqgSRl5q4U6ziKV JNZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VxLGjWVm; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 p5-v6si7925394pgb.598.2018.07.23.14.27.00; Mon, 23 Jul 2018 14:27:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=VxLGjWVm; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 S2388298AbeGWWaD (ORCPT + 10 others); Mon, 23 Jul 2018 18:30:03 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44107 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388283AbeGWWaD (ORCPT ); Mon, 23 Jul 2018 18:30:03 -0400 Received: by mail-lj1-f194.google.com with SMTP id q127-v6so1760396ljq.11 for ; Mon, 23 Jul 2018 14:26:56 -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=d1Za27wcuN7sHeOL/0KokiwCWrvu5jc334Ssx7ln6cQ=; b=VxLGjWVmg52DX/Z2bx/9MzKKF/eQFkgY/odRP6QZDV0aE0SyupBBBa34pdIf71ozlq XLgWvoh5sAd+QjroInR5X0xexI1lCZtoXeTASrdFOXtRVg0VR8Z2on0rrscn0ADmDfeH i5kB8ztBxosNweVWp/XJBpQMQXMw+6c85t6b4= 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=d1Za27wcuN7sHeOL/0KokiwCWrvu5jc334Ssx7ln6cQ=; b=DcPDYgL7Os4/9G5593kSEdeCWCDDjEGNyDzlI93Fu8VO3o+OyO/j4Z/AmVi+Yio8JG oAmCsNv8WwrIufN2yAo2hMSvahBRup8NDHWBqhUeRHl6nHrS7sbTWPtZbSLEs7PtIP5j CeiESLFP0+SfIu7w+ae34fJGTl2ibCitgD7cBM6Lzyv9CgTu4H3dDb2yzyfdkjqYdldn fjBAgwqq9CNRUPGZnXrBnVMXmvG6EjeMsTAm9xc4y1Pxbit7+Hw8n1RM5udO6fAezEgI +CsLXxHcfl2WigiLO85TLWrVro5ae2INJggV36ETfYjN+n5MbUdNarMMp40BEiHwFvZu gElA== X-Gm-Message-State: AOUpUlGzui5yx6Gvq5iATUHUediUfT0+RHa+eHwlL/+by8Z6aRn/c+CH IlCd09n3WZ+bZbaOStddvbFl9w== X-Received: by 2002:a2e:1004:: with SMTP id j4-v6mr10458738lje.2.1532381215695; Mon, 23 Jul 2018 14:26:55 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id q4-v6sm1990435ljh.36.2018.07.23.14.26.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 14:26:54 -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 v5 net-next 5/6] net: ethernet: ti: cpsw: restore shaper configuration while down/up Date: Tue, 24 Jul 2018 00:26:33 +0300 Message-Id: <20180723212634.3219-6-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723212634.3219-1-ivan.khoronzhuk@linaro.org> References: <20180723212634.3219-1-ivan.khoronzhuk@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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: Ilias Apalodimas Reviewed-by: Grygorii Strashko Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) -- 2.17.1 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;