Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3476277pxb; Sun, 7 Feb 2021 10:44:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnrzql2n/YrViv6I+Aujf3N38KdZrng47yj+YCrmnzRGCc2gPgXLRP6bHYMTxqlieK/U5k X-Received: by 2002:a17:906:8292:: with SMTP id h18mr13468642ejx.342.1612723478437; Sun, 07 Feb 2021 10:44:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612723478; cv=none; d=google.com; s=arc-20160816; b=pniy52RV6LKdJvTHY2+SQwv9p6oZ7b+3dB29zpXDG5ZKIDBc09zGeRvcZC4TAPqRkC 1dQPVoWkE0tLAOEneeqUxC2GvJ8vY1ZHePIo0EFXZD0gy7AmrS0VPToOKvnLxTcQ+57s 666IUwPZ3qpFRn4EyQf/LQMCWPPsyPMuhePUdDtkYoXvVSOpZDBly/MqYoDMZM84T3vV /uEv2ym8QnMhON8TP/PxmDLarNZa7Cn9GsiVqOAaKu0UcIlBYvVP59ai/LiPxIlCvRlL C+7u53Y1Id5e7/z/qooJ8oa28sbhWk2XnlnhZEL7ASrNvfyC/tAmyYHaqgVApz5bnlCQ GP5g== 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=UrL4S17emqCRulz9TWUJtPhwJxRUYZLo7+JL/qJJ06c=; b=tNXWfI6IRs3nyghC2AMWmVyQVF4iW3cNcp7HJUuIjA2xJpsOcm5Z7Kk/qkVS4KAjnc MXtNyC4znr2LtntQcpogeSRzRL1GEboR43cz5+qVkT8koDWsHVyQZtI5ZcSSH6N8Cufn ACSZvaKaDdyHsksum40SACw/3JwUgCSYMVO0oaEPgHD5at/qSQVp0sfnYBfo+7TbAuwh ntgcZaac14kDsMvOqV8lGs+s+CbHDhD1+bYktqMmrMdgiPStJ58InKj4AJ2sxnZwfybk plfKZZRMiU9r93Zm16Ixbo9FaqgjJbmmVaMcEa6Si+/kyv9kbZWQbaRaWyLNbDJtbFSB WqYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=ZwQLJPb3; 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 q10si9615606edb.606.2021.02.07.10.44.15; Sun, 07 Feb 2021 10:44:38 -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=ZwQLJPb3; 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 S229621AbhBGSmj (ORCPT + 99 others); Sun, 7 Feb 2021 13:42:39 -0500 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:26440 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229854AbhBGSmb (ORCPT ); Sun, 7 Feb 2021 13:42:31 -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 117IUHpA027830; Sun, 7 Feb 2021 10:41:41 -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=UrL4S17emqCRulz9TWUJtPhwJxRUYZLo7+JL/qJJ06c=; b=ZwQLJPb3yTwhitr8eoJ9CYCu1pL/xSQP91gVpJuCG3x6uu7pwxDWcqec8hWf9H5MoNtN SSRBm6y+XGDqF4cOrjsOnLo5+1aCX3z1Z4nDzzrKndyEQrWiPYnSag1d25Rd7qU2iO0A FhExs1UcwNo2s0zfyzP28Unu4g4dL4E2fna6V5qbZ86fcdN82eG7NNqmSdZeqwrTckFY 7udtv0NchX4H7or0agGYvIpFDTTNVZn3oxPC1Idx4KDkpseuupuTIGe6WS7jXJGkg3lD 1kYbKeTbzW+Bdwak+nYe3gT8rvNlv59r+f1vrBPPSr4lonDSxOAQIYD0YkqvsiKElf2I cg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 36hugq2ev6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 07 Feb 2021 10:41:41 -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; Sun, 7 Feb 2021 10:41:39 -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; Sun, 7 Feb 2021 10:41:38 -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; Sun, 7 Feb 2021 10:41:38 -0800 Received: from stefan-pc.marvell.com (stefan-pc.marvell.com [10.5.25.21]) by maili.marvell.com (Postfix) with ESMTP id DE55E3F703F; Sun, 7 Feb 2021 10:41:34 -0800 (PST) From: To: CC: , , , , , , , , , , , , , , , , Subject: [PATCH v9 net-next 09/15] net: mvpp2: enable global flow control Date: Sun, 7 Feb 2021 20:38:51 +0200 Message-ID: <1612723137-18045-10-git-send-email-stefanc@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1612723137-18045-1-git-send-email-stefanc@marvell.com> References: <1612723137-18045-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-07_10:2021-02-05,2021-02-07 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Chulski This patch enables global flow control in FW and in the phylink validate mask. Signed-off-by: Stefan Chulski --- drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 11 +++++-- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 30 +++++++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h index d2cc513c..8945fb9 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h @@ -763,9 +763,11 @@ ((kb) * 1024 - MVPP2_TX_FIFO_THRESHOLD_MIN) /* MSS Flow control */ -#define FC_QUANTA 0xFFFF -#define FC_CLK_DIVIDER 100 -#define MSS_THRESHOLD_STOP 768 +#define MSS_FC_COM_REG 0 +#define FLOW_CONTROL_ENABLE_BIT BIT(0) +#define FC_QUANTA 0xFFFF +#define FC_CLK_DIVIDER 100 +#define MSS_THRESHOLD_STOP 768 /* RX buffer constants */ #define MVPP2_SKB_SHINFO_SIZE \ @@ -1017,6 +1019,9 @@ struct mvpp2 { /* page_pool allocator */ struct page_pool *page_pool[MVPP2_PORT_MAX_RXQ]; + + /* Global TX Flow Control config */ + bool global_tx_fc; }; struct mvpp2_pcpu_stats { diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index 8b4073c..027101b 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -91,6 +91,16 @@ static inline u32 mvpp2_cpu_to_thread(struct mvpp2 *priv, int cpu) return cpu % priv->nthreads; } +static void mvpp2_cm3_write(struct mvpp2 *priv, u32 offset, u32 data) +{ + writel(data, priv->cm3_base + offset); +} + +static u32 mvpp2_cm3_read(struct mvpp2 *priv, u32 offset) +{ + return readl(priv->cm3_base + offset); +} + static struct page_pool * mvpp2_create_page_pool(struct device *dev, int num, int len, enum dma_data_direction dma_dir) @@ -5950,6 +5960,11 @@ static void mvpp2_phylink_validate(struct phylink_config *config, phylink_set(mask, Autoneg); phylink_set_port_modes(mask); + if (port->priv->global_tx_fc) { + phylink_set(mask, Pause); + phylink_set(mask, Asym_Pause); + } + switch (state->interface) { case PHY_INTERFACE_MODE_10GBASER: case PHY_INTERFACE_MODE_XAUI: @@ -6951,7 +6966,7 @@ static int mvpp2_probe(struct platform_device *pdev) struct resource *res; void __iomem *base; int i, shared; - int err; + int err, val; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -7003,6 +7018,10 @@ static int mvpp2_probe(struct platform_device *pdev) err = mvpp2_get_sram(pdev, priv); if (err) dev_warn(&pdev->dev, "Fail to alloc CM3 SRAM\n"); + + /* Enable global Flow Control only if handler to SRAM not NULL */ + if (priv->cm3_base) + priv->global_tx_fc = true; } if (priv->hw_version != MVPP21 && dev_of_node(&pdev->dev)) { @@ -7168,6 +7187,15 @@ static int mvpp2_probe(struct platform_device *pdev) goto err_port_probe; } + /* Enable global flow control. In this stage global + * flow control enabled, but still disabled per port. + */ + if (priv->global_tx_fc && priv->hw_version != MVPP21) { + val = mvpp2_cm3_read(priv, MSS_FC_COM_REG); + val |= FLOW_CONTROL_ENABLE_BIT; + mvpp2_cm3_write(priv, MSS_FC_COM_REG, val); + } + mvpp2_dbgfs_init(priv, pdev->name); platform_set_drvdata(pdev, priv); -- 1.9.1