DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: stable@dpdk.org, Somnath Kotur <somnath.kotur@broadcom.com>,
	Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Subject: [PATCH v2] net/bnxt: fix ring calculation for representors
Date: Wed,  9 Feb 2022 09:42:19 -0800	[thread overview]
Message-ID: <20220209174219.35650-1-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <CACZ4nhtbscLu21LwkrkqspT2DL9eCoPWZVUhOpaGb2VxUF2ROQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3783 bytes --]

Currently the Tx and Rx ring count for representors is fixed.
It does not consider the number of rings created for the parent
function. And that can cause issues not only during initialization
but while running traffic.
Instead check the number of rings created for the parent function
while configuring the ring resources for representors.
In some cases VF rep ring init may happen before the parent function's
rings have been setup. And this can cause representor ring count to be
configured as 0. In such cases, initialize the VF representor
ring count to 8.

Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure")
Cc: stable@dpdk.org

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
 drivers/net/bnxt/bnxt.h      |  2 +-
 drivers/net/bnxt/bnxt_reps.c | 21 ++++++++++++---------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 433f1c80be..0cbb58b2cf 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -831,7 +831,7 @@ struct bnxt {
 	uint16_t		max_tx_rings;
 	uint16_t		max_rx_rings;
 #define MAX_STINGRAY_RINGS		236U
-#define BNXT_MAX_VF_REP_RINGS	8
+#define BNXT_MAX_VF_REP_RINGS	8U
 
 	uint16_t		max_nq_rings;
 	uint16_t		max_l2_ctx;
diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index 5e140f0cdb..e773932681 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -548,7 +548,10 @@ int bnxt_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
 	dev_info->max_mac_addrs = parent_bp->max_l2_ctx;
 	dev_info->max_hash_mac_addrs = 0;
 
-	max_rx_rings = BNXT_MAX_VF_REP_RINGS;
+	max_rx_rings = parent_bp->rx_nr_rings ?
+		RTE_MIN(parent_bp->rx_nr_rings, BNXT_MAX_VF_REP_RINGS) :
+		BNXT_MAX_VF_REP_RINGS;
+
 	/* 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;
@@ -629,10 +632,10 @@ int bnxt_rep_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	struct rte_mbuf **buf_ring;
 	int rc = 0;
 
-	if (queue_idx >= BNXT_MAX_VF_REP_RINGS) {
+	if (queue_idx >= rep_bp->rx_nr_rings) {
 		PMD_DRV_LOG(ERR,
 			    "Cannot create Rx ring %d. %d rings available\n",
-			    queue_idx, BNXT_MAX_VF_REP_RINGS);
+			    queue_idx, rep_bp->rx_nr_rings);
 		return -EINVAL;
 	}
 
@@ -729,10 +732,10 @@ int bnxt_rep_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	struct bnxt_tx_queue *parent_txq, *txq;
 	struct bnxt_vf_rep_tx_queue *vfr_txq;
 
-	if (queue_idx >= BNXT_MAX_VF_REP_RINGS) {
+	if (queue_idx >= rep_bp->rx_nr_rings) {
 		PMD_DRV_LOG(ERR,
 			    "Cannot create Tx rings %d. %d rings available\n",
-			    queue_idx, BNXT_MAX_VF_REP_RINGS);
+			    queue_idx, rep_bp->rx_nr_rings);
 		return -EINVAL;
 	}
 
@@ -805,10 +808,10 @@ int bnxt_rep_stats_get_op(struct rte_eth_dev *eth_dev,
 			     struct rte_eth_stats *stats)
 {
 	struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
-	int i;
+	unsigned int i;
 
 	memset(stats, 0, sizeof(*stats));
-	for (i = 0; i < BNXT_MAX_VF_REP_RINGS; i++) {
+	for (i = 0; i < rep_bp->rx_nr_rings; i++) {
 		stats->obytes += rep_bp->tx_bytes[i];
 		stats->opackets += rep_bp->tx_pkts[i];
 		stats->ibytes += rep_bp->rx_bytes[i];
@@ -828,9 +831,9 @@ int bnxt_rep_stats_get_op(struct rte_eth_dev *eth_dev,
 int bnxt_rep_stats_reset_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
-	int i;
+	unsigned int i;
 
-	for (i = 0; i < BNXT_MAX_VF_REP_RINGS; i++) {
+	for (i = 0; i < rep_bp->rx_nr_rings; i++) {
 		rep_bp->tx_pkts[i] = 0;
 		rep_bp->tx_bytes[i] = 0;
 		rep_bp->rx_pkts[i] = 0;
-- 
2.32.0 (Apple Git-132)


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]

  reply	other threads:[~2022-02-09 17:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09  5:58 [PATCH] " Ajit Khaparde
2022-02-09 15:37 ` Ajit Khaparde
2022-02-09 17:34   ` Ajit Khaparde
2022-02-09 17:42     ` Ajit Khaparde [this message]
2022-02-09 18:19       ` [PATCH v2] " 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=20220209174219.35650-1-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=somnath.kotur@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).