From: Ajit Khaparde <ajitkhaparde@gmail.com>
To: dev@dpdk.org
Cc: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>,
stable@dpdk.org, Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [dpdk-stable] [PATCH v3 09/17] net/bnxt: fix max rings computation
Date: Wed, 9 Dec 2020 15:53:39 -0800 [thread overview]
Message-ID: <20201209235347.16180-10-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20201209235347.16180-1-ajit.khaparde@broadcom.com>
From: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
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")
Cc: stable@dpdk.org
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
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 9c1c87489..bc0935272 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -752,19 +752,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)))
#define BNXT_MAX_VF_REP_RINGS 8
@@ -822,6 +809,34 @@ struct bnxt {
uint16_t tx_cfa_action;
};
+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;
+}
+
#define BNXT_FC_TIMER 1 /* Timer freq in Sec Flow Counters */
/**
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 0b14ca234..bf8963577 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -920,7 +920,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 328cc994d..19e11e47b 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -311,7 +311,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);
@@ -364,8 +364,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 c9792a2af..99a31cef2 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.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-12-09 23:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20201209192233.6518-1-ajit.khaparde@broadcom.com>
2020-12-09 19:22 ` [dpdk-stable] [PATCH v2 01/17] net/bnxt: fix RX rings in RSS redirection table Ajit Khaparde
2020-12-09 19:22 ` [dpdk-stable] [PATCH v2 02/17] net/bnxt: fix VNIC config on Rx queue stop Ajit Khaparde
2020-12-09 19:22 ` [dpdk-stable] [PATCH v2 04/17] net/bnxt: release hwrm lock in the error case Ajit Khaparde
2020-12-09 19:22 ` [dpdk-stable] [PATCH v2 06/17] net/bnxt: fix to return error when fw command fails Ajit Khaparde
2020-12-09 19:22 ` [dpdk-stable] [PATCH v2 07/17] net/bnxt: fix cleanup on mutex init failure Ajit Khaparde
2020-12-09 19:22 ` [dpdk-stable] [PATCH v2 08/17] net/bnxt: fix format specifier for unsigned int Ajit Khaparde
2020-12-09 19:22 ` [dpdk-stable] [PATCH v2 09/17] net/bnxt: fix max rings computation Ajit Khaparde
2020-12-09 19:22 ` [dpdk-stable] [PATCH v2 13/17] net/bnxt: fix vnic RSS configure function Ajit Khaparde
2020-12-09 19:22 ` [dpdk-stable] [PATCH v2 14/17] net/bnxt: fix PF resource query Ajit Khaparde
[not found] ` <20201209235347.16180-1-ajit.khaparde@broadcom.com>
2020-12-09 23:53 ` [dpdk-stable] [PATCH v3 01/17] net/bnxt: fix RX rings in RSS redirection table Ajit Khaparde
2020-12-09 23:53 ` [dpdk-stable] [PATCH v3 02/17] net/bnxt: fix VNIC config on Rx queue stop Ajit Khaparde
2020-12-09 23:53 ` [dpdk-stable] [PATCH v3 04/17] net/bnxt: release hwrm lock in the error case Ajit Khaparde
2020-12-09 23:53 ` [dpdk-stable] [PATCH v3 06/17] net/bnxt: fix to return error when fw command fails Ajit Khaparde
2020-12-09 23:53 ` [dpdk-stable] [PATCH v3 07/17] net/bnxt: fix cleanup on mutex init failure Ajit Khaparde
2020-12-10 15:42 ` [dpdk-stable] [dpdk-dev] " Lance Richardson
2020-12-09 23:53 ` [dpdk-stable] [PATCH v3 08/17] net/bnxt: fix format specifier for unsigned int Ajit Khaparde
2020-12-10 15:54 ` [dpdk-stable] [dpdk-dev] " Lance Richardson
2020-12-09 23:53 ` Ajit Khaparde [this message]
2020-12-09 23:53 ` [dpdk-stable] [PATCH v3 13/17] net/bnxt: fix vnic RSS configure function Ajit Khaparde
2020-12-09 23:53 ` [dpdk-stable] [PATCH v3 14/17] net/bnxt: fix PF resource query Ajit Khaparde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201209235347.16180-10-ajit.khaparde@broadcom.com \
--to=ajitkhaparde@gmail.com \
--cc=dev@dpdk.org \
--cc=somnath.kotur@broadcom.com \
--cc=sriharsha.basavapatna@broadcom.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).