From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9E873A0524 for ; Thu, 4 Feb 2021 12:38:23 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 94B0524079B; Thu, 4 Feb 2021 12:38:23 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id CC2A6240773 for ; Thu, 4 Feb 2021 12:38:20 +0100 (CET) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l7cxo-0005jf-Jx; Thu, 04 Feb 2021 11:38:20 +0000 From: Christian Ehrhardt To: Sriharsha Basavapatna Cc: Somnath Kotur , Ajit Khaparde , dpdk stable Date: Thu, 4 Feb 2021 12:29:39 +0100 Message-Id: <20210204112954.2488123-124-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204112954.2488123-1-christian.ehrhardt@canonical.com> References: <20210204112954.2488123-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/bnxt: fix max rings computation' has been queued to stable release 19.11.7 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/06/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/aa28e799271805406646dd6834a2001ace7eb80d Thanks. Christian Ehrhardt --- >From aa28e799271805406646dd6834a2001ace7eb80d Mon Sep 17 00:00:00 2001 From: Sriharsha Basavapatna Date: Fri, 28 Aug 2020 07:13:22 -0400 Subject: [PATCH] net/bnxt: fix max rings computation [ upstream commit c72fe7ac3b63629f1f46e4d91d9abc0d7c064d93 ] The current max_rings computation does not take into account the case when max_nq_rings is <= num_async_cpr. This results in a wrong value like 0, when max_nq_rings is 1. Fix this by subtracting num_async_cpr only when max_cp_rings > num_async_cpr. Apart from this, the entire logic is currently spread across a few macros, making it hard to read and debug this code. Move this code into an inline function. max_msix is not used in the max_rings calculation. Apparently the max_msix field returned in HWRM_RESC_QCAPS is only valid for Thor and newer chips. On Wh+ it will be equal to min_compl_rings. Also, when a function reset is performed on an application quit, FW will not reset the VF resource pool as per design. This can lead to a strange condition wherein the max_msix field on Wh+ keeps changing on each application re-load thereby throwing throwing off the max_rings computation. Fixes: f03e66cb64ce ("net/bnxt: limit queue count for NS3/Stingray devices") Signed-off-by: Sriharsha Basavapatna Signed-off-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt.h | 41 +++++++++++++++++++++++----------- drivers/net/bnxt/bnxt_ethdev.c | 2 +- drivers/net/bnxt/bnxt_rxq.c | 7 +++--- drivers/net/bnxt/bnxt_txq.c | 2 +- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 940b41767c..0a0ecaafa8 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -620,19 +620,6 @@ struct bnxt { uint16_t max_tx_rings; uint16_t max_rx_rings; #define MAX_STINGRAY_RINGS 128U -/* For sake of symmetry, max Tx rings == max Rx rings, one stat ctx for each */ -#define BNXT_MAX_RX_RINGS(bp) \ - (BNXT_STINGRAY(bp) ? RTE_MIN(RTE_MIN(bp->max_rx_rings / 2U, \ - MAX_STINGRAY_RINGS), \ - bp->max_stat_ctx / 2U) : \ - RTE_MIN(bp->max_rx_rings / 2U, \ - bp->max_stat_ctx / 2U)) -#define BNXT_MAX_TX_RINGS(bp) \ - (RTE_MIN((bp)->max_tx_rings, BNXT_MAX_RX_RINGS(bp))) - -#define BNXT_MAX_RINGS(bp) \ - (RTE_MIN((((bp)->max_cp_rings - BNXT_NUM_ASYNC_CPR(bp)) / 2U), \ - BNXT_MAX_TX_RINGS(bp))) uint16_t max_nq_rings; uint16_t max_l2_ctx; uint16_t max_rx_em_flows; @@ -668,6 +655,34 @@ struct bnxt { struct bnxt_error_recovery_info *recovery_info; }; +static +inline uint16_t bnxt_max_rings(struct bnxt *bp) +{ + uint16_t max_tx_rings = bp->max_tx_rings; + uint16_t max_rx_rings = bp->max_rx_rings; + uint16_t max_cp_rings = bp->max_cp_rings; + uint16_t max_rings; + + /* For the sake of symmetry: + * max Tx rings == max Rx rings, one stat ctx for each. + */ + if (BNXT_STINGRAY(bp)) { + max_rx_rings = RTE_MIN(RTE_MIN(max_rx_rings / 2U, + MAX_STINGRAY_RINGS), + bp->max_stat_ctx / 2U); + } else { + max_rx_rings = RTE_MIN(max_rx_rings / 2U, + bp->max_stat_ctx / 2U); + } + + max_tx_rings = RTE_MIN(max_tx_rings, max_rx_rings); + if (max_cp_rings > BNXT_NUM_ASYNC_CPR(bp)) + max_cp_rings -= BNXT_NUM_ASYNC_CPR(bp); + max_rings = RTE_MIN(max_cp_rings / 2U, max_tx_rings); + + return max_rings; +} + int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu); int bnxt_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete, bool exp_link_status); diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 0279eeba8f..b499ca5a00 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -526,7 +526,7 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev, if (BNXT_PF(bp)) dev_info->max_vfs = pdev->max_vfs; - max_rx_rings = BNXT_MAX_RINGS(bp); + max_rx_rings = bnxt_max_rings(bp); /* For the sake of symmetry, max_rx_queues = max_tx_queues */ dev_info->max_rx_queues = max_rx_rings; dev_info->max_tx_queues = max_rx_rings; diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index d3a5ef5677..df00191c09 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -304,7 +304,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, if (rc) return rc; - if (queue_idx >= BNXT_MAX_RINGS(bp)) { + if (queue_idx >= bnxt_max_rings(bp)) { PMD_DRV_LOG(ERR, "Cannot create Rx ring %d. Only %d rings available\n", queue_idx, bp->max_rx_rings); @@ -356,8 +356,9 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, eth_dev->data->rx_queues[queue_idx] = rxq; /* Allocate RX ring hardware descriptors */ - if (bnxt_alloc_rings(bp, queue_idx, NULL, rxq, rxq->cp_ring, NULL, - "rxr")) { + rc = bnxt_alloc_rings(bp, queue_idx, NULL, rxq, rxq->cp_ring, NULL, + "rxr"); + if (rc) { PMD_DRV_LOG(ERR, "ring_dma_zone_reserve for rx_ring failed!\n"); goto err; diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c index 160e841576..78625eef60 100644 --- a/drivers/net/bnxt/bnxt_txq.c +++ b/drivers/net/bnxt/bnxt_txq.c @@ -98,7 +98,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, if (rc) return rc; - if (queue_idx >= BNXT_MAX_RINGS(bp)) { + if (queue_idx >= bnxt_max_rings(bp)) { PMD_DRV_LOG(ERR, "Cannot create Tx ring %d. Only %d rings available\n", queue_idx, bp->max_tx_rings); -- 2.30.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-04 12:04:33.088997661 +0100 +++ 0124-net-bnxt-fix-max-rings-computation.patch 2021-02-04 12:04:28.186789880 +0100 @@ -1 +1 @@ -From c72fe7ac3b63629f1f46e4d91d9abc0d7c064d93 Mon Sep 17 00:00:00 2001 +From aa28e799271805406646dd6834a2001ace7eb80d Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit c72fe7ac3b63629f1f46e4d91d9abc0d7c064d93 ] + @@ -25 +26,0 @@ -Cc: stable@dpdk.org @@ -38 +39 @@ -index 9c1c87489e..bc0935272a 100644 +index 940b41767c..0a0ecaafa8 100644 @@ -41 +42 @@ -@@ -752,19 +752,6 @@ struct bnxt { +@@ -620,19 +620,6 @@ struct bnxt { @@ -58,5 +59,5 @@ - - #define BNXT_MAX_VF_REP_RINGS 8 - -@@ -822,6 +809,34 @@ struct bnxt { - uint16_t tx_cfa_action; + uint16_t max_nq_rings; + uint16_t max_l2_ctx; + uint16_t max_rx_em_flows; +@@ -668,6 +655,34 @@ struct bnxt { + struct bnxt_error_recovery_info *recovery_info; @@ -93,3 +94,3 @@ - #define BNXT_FC_TIMER 1 /* Timer freq in Sec Flow Counters */ - - /** + int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu); + int bnxt_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete, + bool exp_link_status); @@ -97 +98 @@ -index 0b14ca2342..bf89635776 100644 +index 0279eeba8f..b499ca5a00 100644 @@ -100 +101 @@ -@@ -920,7 +920,7 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev, +@@ -526,7 +526,7 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev, @@ -110 +111 @@ -index 328cc994da..19e11e47bf 100644 +index d3a5ef5677..df00191c09 100644 @@ -113 +114 @@ -@@ -311,7 +311,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -304,7 +304,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -122 +123 @@ -@@ -364,8 +364,9 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -356,8 +356,9 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -135 +136 @@ -index c9792a2af2..99a31cef28 100644 +index 160e841576..78625eef60 100644