Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2053720pxb; Thu, 11 Feb 2021 03:11:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfs3K39VQEA/7ULnWcBUohZ2Qcff1uqs9vh4CT/8FwVP9jEtyzgIQKAi6VY8ZXXGdt5A5+ X-Received: by 2002:a17:906:e088:: with SMTP id gh8mr7933393ejb.294.1613041899906; Thu, 11 Feb 2021 03:11:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613041899; cv=none; d=google.com; s=arc-20160816; b=xFrGb+aZU5vzkR5pQITJtHymuVp4nM6w4bVpBLvpKY0yXQKYqyHSOi8eHX/p77hCwk 3xSnTA+N8yVPDccknCtBlDO2aUp11z2K7K+4OpbJ7Csf7giLFUKXHp09DRlGtWhXUrt4 S6GtUXrHcKJeqLy09BhArdqh/dQ4WLnjfK0ABaJ09WAkhNPT9RGLlguMJVkZljDBv9Fm EAKCvvOG0jD8cscVo/2vPe2Bygd9WER4HmKHOjKP1mIOewIdfZuSlc70DvTmaQv7x+13 52n9DSs47X/J/w/OtoggsfwSt+FX4iJZOmJL1RlbtKKKPsdPBi1nu3x4s8+UsZMJgk/+ wlgw== 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=jgkCBBxUlid5VADfl3sxxYhNrwuvqSIBm/j5kAyNZ5E=; b=oFrnHKux99XPf3Cb2k+AYXgGNqJkqd0Jud2Ug2s0rv8lJ/XVDAaOjJ9spNzAD77GwY v/J+ToSiuVyIz2sM6hpMTL5qd0/fxc9AqsDgH4v3e2uw6hasqrFyekLFMD+SkgElSp/0 iJg7SazLvA27rvvqPRqlRnQ/ah66MjAGDIK6GSqhkEXNyymOjuizLDaDfccbNOSOE0pd PF1dI5NtXPMgUG30uBVXo6FV+hdn4T+jE731JFUia28ZVW2WsGN3hbh98GQTG4k7Ar8l 3mVfu183zSpMEPPqp2rNkgOfASsifces92Wmbudm71MJrbLL9iPX1LIpNgIHc2BnxpYl 0hWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=KAj43dbh; 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 bl4si3974762ejb.47.2021.02.11.03.11.15; Thu, 11 Feb 2021 03:11: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=KAj43dbh; 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 S231307AbhBKLI6 (ORCPT + 99 others); Thu, 11 Feb 2021 06:08:58 -0500 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:12748 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231248AbhBKKww (ORCPT ); Thu, 11 Feb 2021 05:52:52 -0500 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11BAp9EZ017014; Thu, 11 Feb 2021 02:52:02 -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=jgkCBBxUlid5VADfl3sxxYhNrwuvqSIBm/j5kAyNZ5E=; b=KAj43dbhYzpFrcHWqSsJWZRRXdDNiCAXPonNedCDxhmNr0R1tO8tu01FgiadWPxnKDBj 28Qu29+2AkxYgf/+tk88JtWPiGBy8Te+QZs3nf/vaVOYXC+6706o2PUeVz9WStj9KCB4 bvTNnYEfh2i+iAilW7xMJynzbmTLbGnGvXO9TxV1xWNCX/7mHNLsTEs4xNlYE/Dee/eA QV5QiZy+J6+ew1KbK5ia3O6J2swtvIMFPl6k6lzVfrH7D3UlM3huhRDGLOAKOxoPXLqV ofh9iqZOD6Ynzp58ggff8oe6Va3T63IIazTRs+hPFt+EvgIlD1+x2dRQs+PCQVZEOy3+ SQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 36hugqefd5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 11 Feb 2021 02:52:02 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 11 Feb 2021 02:52:00 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 11 Feb 2021 02:51:59 -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; Thu, 11 Feb 2021 02:51:59 -0800 Received: from stefan-pc.marvell.com (stefan-pc.marvell.com [10.5.25.21]) by maili.marvell.com (Postfix) with ESMTP id BED903F703F; Thu, 11 Feb 2021 02:51:55 -0800 (PST) From: To: CC: , , , , , , , , , , , , , , , , Subject: [PATCH v13 net-next 07/15] net: mvpp2: add FCA periodic timer configurations Date: Thu, 11 Feb 2021 12:48:54 +0200 Message-ID: <1613040542-16500-8-git-send-email-stefanc@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1613040542-16500-1-git-send-email-stefanc@marvell.com> References: <1613040542-16500-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-11_05:2021-02-10,2021-02-11 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 Acked-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 13 ++++++ drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 45 ++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h index e7bbf0a..9239d80 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 @@ -751,6 +760,10 @@ #define MVPP2_TX_FIFO_THRESHOLD(kb) \ ((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN) +/* MSS Flow control */ +#define FC_QUANTA 0xFFFF +#define FC_CLK_DIVIDER 100 + /* RX buffer constants */ #define MVPP2_SKB_SHINFO_SIZE \ SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index 5730900..761f745 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -1280,6 +1280,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; @@ -1324,6 +1367,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