Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3187697pxb; Sun, 7 Feb 2021 00:29:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIPQGAFAunKt7NV2Lbw3tQq6ocfLFoy2mrVAgt0Kcs7fxqnvq/R+X05eJYw/pZgiSLDOnX X-Received: by 2002:a50:e0c1:: with SMTP id j1mr11652495edl.253.1612686569350; Sun, 07 Feb 2021 00:29:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612686569; cv=none; d=google.com; s=arc-20160816; b=v4ZOOzzzDEsyCPNz+24Ut7MicrkSyanI9b/sE1EnCtg7tjUaF4Zh7WqqXvdtUc6F+W 8+Jx0Swl8VLyjqayVdKJQy/bnhmUaX7lpJl5cZ7Ij0aidsuUQP3nQ/M6wgr8W/9i/uQY DHeUYNYzAegx25thkcZ8DCE9PsfTh9eVu6Nj0ZRIZc9yv1d74DVXNp6oN2s25m81d5s7 p2qJ5Te7Aft2VX6iyThxmYQSNZkgwFJ0vFDRoGOOf+00LVnE1jvnB+RF0Hs4LLS/924u UfszKXyyK9tiWFbzLGJpFX1G48BbPNQdXexOxhCg3kJnx7sRaJtp9G/r/jhdaSefMG2/ 37sQ== 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=7LwR1nLKUpv51GM9JH6RPwo2xhMdAQWWEf6bm82cJYo=; b=zJQeukPzB/LGuI9EISi/vAeRY2VLPHUtGkND0TbgDId+aR/Nh5QYFAF5Y1IGoZ9DQj WK5+JL5dExJhDwOOK0HJU1wzita0AdxRFYguFHzPqlXdcRvK9BbqMS4fiD3h9shWRfC7 M7rvsMTdgtbNSSnMaBBTyTmDxPEXOh3nAtbFkcEkmXlQmJsUN0bbhF3WCHU1OKQI1+CV B4sevoYmlAkiWE32hv9oIPTv3yPaIdNA33279IzgnOkQHJ4hsLn4LTqEBg5iBvbts8Pg s4D2mEcFobfvZ3N+Qi1gYJuXqyeBn+KTjy0g7In2aHYDdh6pagvoLM/hWfJPr8sCyBiC gHLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=OIVPqXyw; 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 d4si8792600edu.106.2021.02.07.00.29.06; Sun, 07 Feb 2021 00:29:29 -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=OIVPqXyw; 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 S229816AbhBGI2B (ORCPT + 99 others); Sun, 7 Feb 2021 03:28:01 -0500 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:4186 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbhBGIXH (ORCPT ); Sun, 7 Feb 2021 03:23:07 -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 1178LGJS025666; Sun, 7 Feb 2021 00:22:16 -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=7LwR1nLKUpv51GM9JH6RPwo2xhMdAQWWEf6bm82cJYo=; b=OIVPqXywKUioIF1XLTGEfNEyJ5tqgziU83ONROLNflDxTAF98ZRU1xSPpsipcPzyl5AK QdfRtdFuBNQ9hd0NdjmMv7v5NHuSwlR8Mi0EplxCJutNfKGfj4Gd8eMFmDzhKbNwSHTU A39gEComEU0IOBde4FhnTNYtvqzbAmXH1r/6v8uW1jcKWSNMsS8mtQINeQS5cmJ0Z99T +I/HhsF+wFwGsEGYGtb2a3VWpc6pt254oJP5FHMKCoN8bFg6ij/0wSz/d8yZf6c2u5af yvx6qxj4fBzm0FM55QCwrbF0cL5IrVB/VwR3GNTB66KY4khwG1Efk83QxeGu8gtdmOLf OA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 36hugq1m34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 07 Feb 2021 00:22:16 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 7 Feb 2021 00:22:14 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sun, 7 Feb 2021 00:22:14 -0800 Received: from stefan-pc.marvell.com (stefan-pc.marvell.com [10.5.25.21]) by maili.marvell.com (Postfix) with ESMTP id 4DC963F703F; Sun, 7 Feb 2021 00:22:10 -0800 (PST) From: To: CC: , , , , , , , , , , , , , , , , Subject: [RESEND PATCH v8 net-next 12/15] net: mvpp2: add BM protection underrun feature support Date: Sun, 7 Feb 2021 10:19:21 +0200 Message-ID: <1612685964-21890-13-git-send-email-stefanc@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1612685964-21890-1-git-send-email-stefanc@marvell.com> References: <1612685964-21890-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_03:2021-02-05,2021-02-07 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Chulski The PP2v23 hardware supports a feature allowing to double the size of BPPI by decreasing number of pools from 16 to 8. Increasing of BPPI size protect BM drop from BPPI underrun. Underrun could occurred due to stress on DDR and as result slow buffer transition from BPPE to BPPI. New BPPI threshold recommended by spec is: BPPI low threshold - 640 buffers BPPI high threshold - 832 buffers Supported only in PPv23. Signed-off-by: Stefan Chulski --- drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 8 +++++ drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 35 +++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h index 9071ab6..1967493 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h @@ -324,6 +324,10 @@ #define MVPP2_BM_HIGH_THRESH_MASK 0x7f0000 #define MVPP2_BM_HIGH_THRESH_VALUE(val) ((val) << \ MVPP2_BM_HIGH_THRESH_OFFS) +#define MVPP2_BM_BPPI_HIGH_THRESH 0x1E +#define MVPP2_BM_BPPI_LOW_THRESH 0x1C +#define MVPP23_BM_BPPI_HIGH_THRESH 0x34 +#define MVPP23_BM_BPPI_LOW_THRESH 0x28 #define MVPP2_BM_INTR_CAUSE_REG(pool) (0x6240 + ((pool) * 4)) #define MVPP2_BM_RELEASED_DELAY_MASK BIT(0) #define MVPP2_BM_ALLOC_FAILED_MASK BIT(1) @@ -352,6 +356,10 @@ #define MVPP2_OVERRUN_ETH_DROP 0x7000 #define MVPP2_CLS_ETH_DROP 0x7020 +#define MVPP22_BM_POOL_BASE_ADDR_HIGH_REG 0x6310 +#define MVPP22_BM_POOL_BASE_ADDR_HIGH_MASK 0xff +#define MVPP23_BM_8POOL_MODE BIT(8) + /* Hit counters registers */ #define MVPP2_CTRS_IDX 0x7040 #define MVPP22_CTRS_TX_CTR(port, txq) ((txq) | ((port) << 3) | BIT(7)) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index 5d80c5e..e41b173 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -70,6 +70,11 @@ enum mvpp2_bm_pool_log_num { module_param(queue_mode, int, 0444); MODULE_PARM_DESC(queue_mode, "Set queue_mode (single=0, multi=1)"); +static int bm_underrun_protect = 1; + +module_param(bm_underrun_protect, int, 0444); +MODULE_PARM_DESC(bm_underrun_protect, "Set BM underrun protect feature (0-1), def=1"); + /* Utility/helper methods */ void mvpp2_write(struct mvpp2 *priv, u32 offset, u32 data) @@ -424,6 +429,21 @@ static int mvpp2_bm_pool_create(struct device *dev, struct mvpp2 *priv, val = mvpp2_read(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id)); val |= MVPP2_BM_START_MASK; + + val &= ~MVPP2_BM_LOW_THRESH_MASK; + val &= ~MVPP2_BM_HIGH_THRESH_MASK; + + /* Set 8 Pools BPPI threshold if BM underrun protection feature + * was enabled + */ + if (priv->hw_version == MVPP23 && bm_underrun_protect) { + val |= MVPP2_BM_LOW_THRESH_VALUE(MVPP23_BM_BPPI_LOW_THRESH); + val |= MVPP2_BM_HIGH_THRESH_VALUE(MVPP23_BM_BPPI_HIGH_THRESH); + } else { + val |= MVPP2_BM_LOW_THRESH_VALUE(MVPP2_BM_BPPI_LOW_THRESH); + val |= MVPP2_BM_HIGH_THRESH_VALUE(MVPP2_BM_BPPI_HIGH_THRESH); + } + mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id), val); bm_pool->size = size; @@ -592,6 +612,16 @@ static int mvpp2_bm_pools_init(struct device *dev, struct mvpp2 *priv) return err; } +/* Routine enable PPv23 8 pool mode */ +static void mvpp23_bm_set_8pool_mode(struct mvpp2 *priv) +{ + int val; + + val = mvpp2_read(priv, MVPP22_BM_POOL_BASE_ADDR_HIGH_REG); + val |= MVPP23_BM_8POOL_MODE; + mvpp2_write(priv, MVPP22_BM_POOL_BASE_ADDR_HIGH_REG, val); +} + static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv) { enum dma_data_direction dma_dir = DMA_FROM_DEVICE; @@ -645,6 +675,9 @@ static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv) if (!priv->bm_pools) return -ENOMEM; + if (priv->hw_version == MVPP23 && bm_underrun_protect) + mvpp23_bm_set_8pool_mode(priv); + err = mvpp2_bm_pools_init(dev, priv); if (err < 0) return err; @@ -6491,7 +6524,7 @@ static void mvpp2_mac_link_up(struct phylink_config *config, val); } - if (port->priv->global_tx_fc) { + if (port->priv->global_tx_fc && bm_underrun_protect) { port->tx_fc = tx_pause; if (tx_pause) mvpp2_rxq_enable_fc(port); -- 1.9.1