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 453E4A0A02 for ; Mon, 17 May 2021 18:11:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E7B44014E; Mon, 17 May 2021 18:11:22 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id C431E40041 for ; Mon, 17 May 2021 18:11:21 +0200 (CEST) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lifpx-0007ak-Fj; Mon, 17 May 2021 16:11:21 +0000 From: Christian Ehrhardt To: Lance Richardson Cc: Somnath Kotur , Ajit Khaparde , dpdk stable Date: Mon, 17 May 2021 18:07:25 +0200 Message-Id: <20210517161039.3132619-16-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> References: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/bnxt: fix Rx queue count' has been queued to stable release 19.11.9 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.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/19/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/138528f094f9489be127c86adee50d1fbcb7387c Thanks. Christian Ehrhardt --- >From 138528f094f9489be127c86adee50d1fbcb7387c Mon Sep 17 00:00:00 2001 From: Lance Richardson Date: Thu, 18 Feb 2021 13:19:20 -0500 Subject: [PATCH] net/bnxt: fix Rx queue count [ upstream commit 9f13e888ef77d36a97a3ace278e8e812a98e740d ] bnxt_rx_queue_count_op() incorrectly returns the number of filled but unprocessed completion queue entries instead of the number of filled but unprocessed received packet completions. Fix by properly accounting for the number of completion ring entries used by the various received packet completion types. Fixes: 34c0ba839bae ("net/bnxt: fix Rx queue count") Signed-off-by: Lance Richardson Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_cpr.h | 4 ++++ drivers/net/bnxt/bnxt_ethdev.c | 38 +++++++++++++++++++++++++++++----- drivers/net/bnxt/bnxt_rxr.c | 3 +-- drivers/net/bnxt/bnxt_rxr.h | 4 ++++ 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h index ff9697f4c8..c769bde619 100644 --- a/drivers/net/bnxt/bnxt_cpr.h +++ b/drivers/net/bnxt/bnxt_cpr.h @@ -26,6 +26,10 @@ struct bnxt_db_info; #define CMP_TYPE(cmp) \ (((struct cmpl_base *)cmp)->type & CMPL_BASE_TYPE_MASK) +/* Get completion length from completion type, in 16-byte units. */ +#define CMP_LEN(cmp_type) (((cmp_type) & 1) + 1) + + #define ADV_RAW_CMP(idx, n) ((idx) + (n)) #define NEXT_RAW_CMP(idx) ADV_RAW_CMP(idx, 1) #define RING_CMP(ring, idx) ((idx) & (ring)->ring_mask) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 06843d8ddb..7b3532760a 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -2379,8 +2379,8 @@ static uint32_t bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id) { struct bnxt *bp = (struct bnxt *)dev->data->dev_private; - uint32_t desc = 0, raw_cons = 0, cons; struct bnxt_cp_ring_info *cpr; + uint32_t desc = 0, raw_cons; struct bnxt_rx_queue *rxq; struct rx_pkt_cmpl *rxcmp; int rc; @@ -2394,15 +2394,43 @@ bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id) raw_cons = cpr->cp_raw_cons; while (1) { + uint32_t agg_cnt, cons, cmpl_type; + cons = RING_CMP(cpr->cp_ring_struct, raw_cons); - rte_prefetch0(&cpr->cp_desc_ring[cons]); rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons]; - if (!CMP_VALID(rxcmp, raw_cons, cpr->cp_ring_struct)) { + if (!CMP_VALID(rxcmp, raw_cons, cpr->cp_ring_struct)) break; - } else { - raw_cons++; + + cmpl_type = CMP_TYPE(rxcmp); + + switch (cmpl_type) { + case CMPL_BASE_TYPE_RX_L2: + case CMPL_BASE_TYPE_RX_L2_V2: + agg_cnt = BNXT_RX_L2_AGG_BUFS(rxcmp); + raw_cons = raw_cons + CMP_LEN(cmpl_type) + agg_cnt; desc++; + break; + + case CMPL_BASE_TYPE_RX_TPA_END: + if (BNXT_CHIP_P5(rxq->bp)) { + struct rx_tpa_v2_end_cmpl_hi *p5_tpa_end; + + p5_tpa_end = (void *)rxcmp; + agg_cnt = BNXT_TPA_END_AGG_BUFS_TH(p5_tpa_end); + } else { + struct rx_tpa_end_cmpl *tpa_end; + + tpa_end = (void *)rxcmp; + agg_cnt = BNXT_TPA_END_AGG_BUFS(tpa_end); + } + + raw_cons = raw_cons + CMP_LEN(cmpl_type) + agg_cnt; + desc++; + break; + + default: + raw_cons += CMP_LEN(cmpl_type); } } diff --git a/drivers/net/bnxt/bnxt_rxr.c b/drivers/net/bnxt/bnxt_rxr.c index 1cf8f3e17c..668b6aae9a 100644 --- a/drivers/net/bnxt/bnxt_rxr.c +++ b/drivers/net/bnxt/bnxt_rxr.c @@ -463,8 +463,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt, goto next_rx; } - agg_buf = (rxcmp->agg_bufs_v1 & RX_PKT_CMPL_AGG_BUFS_MASK) - >> RX_PKT_CMPL_AGG_BUFS_SFT; + agg_buf = BNXT_RX_L2_AGG_BUFS(rxcmp); if (agg_buf && !bnxt_agg_bufs_valid(cpr, agg_buf, tmp_raw_cons)) return -EBUSY; diff --git a/drivers/net/bnxt/bnxt_rxr.h b/drivers/net/bnxt/bnxt_rxr.h index 410b46016b..d5b7387144 100644 --- a/drivers/net/bnxt/bnxt_rxr.h +++ b/drivers/net/bnxt/bnxt_rxr.h @@ -147,6 +147,10 @@ static inline uint16_t bnxt_tpa_start_agg_id(struct bnxt *bp, #define RX_CMP_L4_CS_UNKNOWN(rxcmp1) \ !((rxcmp1)->flags2 & RX_CMP_L4_CS_BITS) +#define BNXT_RX_L2_AGG_BUFS(cmp) \ + (((cmp)->agg_bufs_v1 & RX_PKT_CMPL_AGG_BUFS_MASK) >> \ + RX_PKT_CMPL_AGG_BUFS_SFT) + #define RX_CMP_T_L4_CS_BITS \ rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_T_L4_CS_CALC) -- 2.31.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-17 17:40:30.177855818 +0200 +++ 0016-net-bnxt-fix-Rx-queue-count.patch 2021-05-17 17:40:29.123809097 +0200 @@ -1 +1 @@ -From 9f13e888ef77d36a97a3ace278e8e812a98e740d Mon Sep 17 00:00:00 2001 +From 138528f094f9489be127c86adee50d1fbcb7387c Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 9f13e888ef77d36a97a3ace278e8e812a98e740d ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -27 +28 @@ -index d7e0d4621a..28c0a9049c 100644 +index ff9697f4c8..c769bde619 100644 @@ -42 +43 @@ -index 22c880c5c3..9824cdb6d8 100644 +index 06843d8ddb..7b3532760a 100644 @@ -45 +46 @@ -@@ -2942,8 +2942,8 @@ static uint32_t +@@ -2379,8 +2379,8 @@ static uint32_t @@ -55 +56 @@ -@@ -2957,15 +2957,43 @@ bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id) +@@ -2394,15 +2394,43 @@ bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id) @@ -78 +79 @@ -+ desc++; + desc++; @@ -95 +96 @@ - desc++; ++ desc++; @@ -104 +105 @@ -index 91a00c7cf4..498811a732 100644 +index 1cf8f3e17c..668b6aae9a 100644 @@ -107 +108 @@ -@@ -827,8 +827,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt, +@@ -463,8 +463,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt, @@ -118 +119 @@ -index 0e31b37cad..06d10848da 100644 +index 410b46016b..d5b7387144 100644 @@ -121,3 +122,3 @@ -@@ -37,6 +37,10 @@ static inline uint16_t bnxt_tpa_start_agg_id(struct bnxt *bp, - #define BNXT_TPA_END_AGG_ID_TH(cmp) \ - rte_le_to_cpu_16((cmp)->agg_id) +@@ -147,6 +147,10 @@ static inline uint16_t bnxt_tpa_start_agg_id(struct bnxt *bp, + #define RX_CMP_L4_CS_UNKNOWN(rxcmp1) \ + !((rxcmp1)->flags2 & RX_CMP_L4_CS_BITS) @@ -129 +130,2 @@ - #define BNXT_RX_POST_THRESH 32 + #define RX_CMP_T_L4_CS_BITS \ + rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_T_L4_CS_CALC) @@ -131 +132,0 @@ - /* Number of descriptors to process per inner loop in vector mode. */