Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2822968pxb; Sat, 6 Feb 2021 08:52:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNJCnYACOeJCq6DjvC+RCisOW+RuRXPF6dehdi0iNfJkfXTNLS8xNl/j7lyzjl0SrbQB4o X-Received: by 2002:a17:906:b6cc:: with SMTP id ec12mr9482827ejb.520.1612630359587; Sat, 06 Feb 2021 08:52:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612630359; cv=none; d=google.com; s=arc-20160816; b=KVpSajppeWOHXI3nxG199K9X0vHxccNf0cGudHZzPPSB0yPNjyIEy7FapZ4uU9fWsi gD6jVvIwF17hY2pXkWLHk0sYxsbAAtSa82IGKaTkLbvI9mk0oHW8gh0knr/NeUwKTH3D hu//K3eIP15z4eWqDdARKMK246xrbEwlXSf4i1TtWm5sgXYK+ZXIBPEe1rSdTO6CvvVP 4pyodI5BX+wdw+0tB9NXwjgALBfX35XQlgB3a9Es4bI598jBkdV62BM9keCVbruDbeYc fNma/ExsuofC8upHo+pLpzJfg7y12FtvVt5tRRc4QWukIEnGoorf/hx26YTLsZlwcOl6 Nlhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6pDdBO4FiW4J3ZSh6Q2cfqQ4yvjsrELQlYlAuzrXKH0=; b=GWo4nyzwgs4w3DbMhxRBSXZG+H/HcdAGHYcUu0lvt7viERa0o89PaFZhjqsvMHo5nb +E+0q+WCgsE2iRErziXN335VncCFxI1CGU9CkGoa+wlyrAKXmiDN2o/y/RzYxsmtYv3B yU9c+v0ut3tTG7CADyRlvOcbcuvHT98o8YNIblgNxtTrKbuG4FNOVMyGKyvrvib4zpwX MtVm+4H4GS+YjG1xiZ/c3lZhdrZ/q3kn8EfpufXCy67b7C6NTfxf65XC+oX30Is2aNqT mrONWm+fXQt8TSx+bt4ZwfLTfoNL0KS5sU/BB0hKF8beNB5vRSinHRQz6qTePzG+YoTD eLmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Mxxmg3Am; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p5si7714426edq.266.2021.02.06.08.52.14; Sat, 06 Feb 2021 08:52:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Mxxmg3Am; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbhBFQuK (ORCPT + 99 others); Sat, 6 Feb 2021 11:50:10 -0500 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:30408 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230439AbhBFQsM (ORCPT ); Sat, 6 Feb 2021 11:48:12 -0500 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 116Gj2qi021859; Sat, 6 Feb 2021 08:47:24 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=6pDdBO4FiW4J3ZSh6Q2cfqQ4yvjsrELQlYlAuzrXKH0=; b=Mxxmg3AmZHB97AwEZvkBQI+614WwSEx1vXK08n8fYIQdW9aqGgqXM+bAf7ELJ5fcHLtf 0hPkVxli+y7ChRUCxjqmEfRxXZOoqgjiVUz4OjY0Tp2m0yUoxzkrskzUPO0z6G29bO97 +C+R9glTEmQGxe8/VGt9Z4DYCIHrxdUNomoqWq6oEYcfj3yu3JS01dsmKlofv4L62fi9 g7fQObwYvdh9clR79jpnRvMUQHasVjzfawOyNFFyOOjdVXX+5SkXOl9mwNTKW2Ua6iY/ 6FtpTdNLF/l6cslwJCNnzNkOeHbvdj6CBFMZFsBDlNRk16YqFwYoxnpsTMKKxVcWLWK7 xw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 36hsbr8gve-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 06 Feb 2021 08:47:24 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 6 Feb 2021 08:47:22 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 6 Feb 2021 08:47:22 -0800 Received: from stefan-pc.marvell.com (stefan-pc.marvell.com [10.5.25.21]) by maili.marvell.com (Postfix) with ESMTP id EE6043F703F; Sat, 6 Feb 2021 08:47:19 -0800 (PST) From: To: CC: , , , , , , , , , , , Subject: [PATCH v8 net-next 07/15] net: mvpp2: add FCA periodic timer configurations Date: Sat, 6 Feb 2021 18:45:53 +0200 Message-ID: <1612629961-11583-8-git-send-email-stefanc@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1612629961-11583-1-git-send-email-stefanc@marvell.com> References: <1612629961-11583-1-git-send-email-stefanc@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.737 definitions=2021-02-06_06:2021-02-05,2021-02-06 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Chulski Flow Control periodic timer would be used if port in XOFF to transmit periodic XOFF frames. Signed-off-by: Stefan Chulski --- drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 13 +++++- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 45 ++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h index cac9885..73f087c 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h @@ -596,6 +596,15 @@ #define MVPP22_MPCS_CLK_RESET_DIV_RATIO(n) ((n) << 4) #define MVPP22_MPCS_CLK_RESET_DIV_SET BIT(11) +/* FCA registers. PPv2.2 and PPv2.3 */ +#define MVPP22_FCA_BASE(port) (0x7600 + (port) * 0x1000) +#define MVPP22_FCA_REG_SIZE 16 +#define MVPP22_FCA_REG_MASK 0xFFFF +#define MVPP22_FCA_CONTROL_REG 0x0 +#define MVPP22_FCA_ENABLE_PERIODIC BIT(11) +#define MVPP22_PERIODIC_COUNTER_LSB_REG (0x110) +#define MVPP22_PERIODIC_COUNTER_MSB_REG (0x114) + /* XPCS registers. PPv2.2 and PPv2.3 */ #define MVPP22_XPCS_BASE(port) (0x7400 + (port) * 0x1000) #define MVPP22_XPCS_CFG0 0x0 @@ -752,7 +761,9 @@ ((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN) /* MSS Flow control */ -#define MSS_SRAM_SIZE 0x800 +#define MSS_SRAM_SIZE 0x800 +#define FC_QUANTA 0xFFFF +#define FC_CLK_DIVIDER 100 /* RX buffer constants */ #define MVPP2_SKB_SHINFO_SIZE \ diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index d80947a..6e59d07 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -1281,6 +1281,49 @@ static void mvpp22_gop_init_10gkr(struct mvpp2_port *port) writel(val, mpcs + MVPP22_MPCS_CLK_RESET); } +static void mvpp22_gop_fca_enable_periodic(struct mvpp2_port *port, bool en) +{ + struct mvpp2 *priv = port->priv; + void __iomem *fca = priv->iface_base + MVPP22_FCA_BASE(port->gop_id); + u32 val; + + val = readl(fca + MVPP22_FCA_CONTROL_REG); + val &= ~MVPP22_FCA_ENABLE_PERIODIC; + if (en) + val |= MVPP22_FCA_ENABLE_PERIODIC; + writel(val, fca + MVPP22_FCA_CONTROL_REG); +} + +static void mvpp22_gop_fca_set_timer(struct mvpp2_port *port, u32 timer) +{ + struct mvpp2 *priv = port->priv; + void __iomem *fca = priv->iface_base + MVPP22_FCA_BASE(port->gop_id); + u32 lsb, msb; + + lsb = timer & MVPP22_FCA_REG_MASK; + msb = timer >> MVPP22_FCA_REG_SIZE; + + writel(lsb, fca + MVPP22_PERIODIC_COUNTER_LSB_REG); + writel(msb, fca + MVPP22_PERIODIC_COUNTER_MSB_REG); +} + +/* Set Flow Control timer x100 faster than pause quanta to ensure that link + * partner won't send traffic if port is in XOFF mode. + */ +static void mvpp22_gop_fca_set_periodic_timer(struct mvpp2_port *port) +{ + u32 timer; + + timer = (port->priv->tclk / (USEC_PER_SEC * FC_CLK_DIVIDER)) + * FC_QUANTA; + + mvpp22_gop_fca_enable_periodic(port, false); + + mvpp22_gop_fca_set_timer(port, timer); + + mvpp22_gop_fca_enable_periodic(port, true); +} + static int mvpp22_gop_init(struct mvpp2_port *port) { struct mvpp2 *priv = port->priv; @@ -1325,6 +1368,8 @@ static int mvpp22_gop_init(struct mvpp2_port *port) val |= GENCONF_SOFT_RESET1_GOP; regmap_write(priv->sysctrl_base, GENCONF_SOFT_RESET1, val); + mvpp22_gop_fca_set_periodic_timer(port); + unsupported_conf: return 0; -- 1.9.1