DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH 13/13] net/bnxt: check on-chip resources
Date: Mon,  8 Jan 2018 12:24:37 -0800	[thread overview]
Message-ID: <20180108202437.56305-14-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20180108202437.56305-1-ajit.khaparde@broadcom.com>

Check for availability of on-chip resources - like Queue count,
number stat context, number of ring groups before inheriting and
initializing as per application requirements.
Also check before creating a Tx or Rx queue make sure there are
enough resources to complete the request.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 20 ++++++++++++++++++++
 drivers/net/bnxt/bnxt_rxq.c    |  7 +++++++
 drivers/net/bnxt/bnxt_txq.c    |  7 +++++++
 3 files changed, 34 insertions(+)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 41b23cc4f..87a07bab9 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -530,6 +530,26 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 	bp->tx_queues = (void *)eth_dev->data->tx_queues;
 
 	/* Inherit new configurations */
+	if (eth_dev->data->nb_rx_queues > bp->rx_nr_rings ||
+	    eth_dev->data->nb_tx_queues > bp->tx_nr_rings ||
+	    eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues + 1 >
+	    bp->max_cp_rings ||
+	    eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues >
+	    bp->max_stat_ctx ||
+	    (uint32_t)(eth_dev->data->nb_rx_queues + 1) > bp->max_ring_grps) {
+		RTE_LOG(ERR, PMD,
+			"Insufficient resources to support requested config\n");
+		RTE_LOG(ERR, PMD,
+			"Num Queues Requested: Tx %d, Rx %d\n",
+			eth_dev->data->nb_tx_queues,
+			eth_dev->data->nb_rx_queues);
+		RTE_LOG(ERR, PMD,
+			"Res available: TxQ %d, RxQ %d, CQ %d Stat %d, Grp %d\n",
+			bp->tx_nr_rings, bp->rx_nr_rings, bp->max_cp_rings,
+			bp->max_stat_ctx, bp->max_ring_grps);
+		return -ENOSPC;
+	}
+
 	bp->rx_nr_rings = eth_dev->data->nb_rx_queues;
 	bp->tx_nr_rings = eth_dev->data->nb_tx_queues;
 	bp->rx_cp_nr_rings = bp->rx_nr_rings;
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index c4da474e9..f7fbb2856 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -311,6 +311,13 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	struct bnxt_rx_queue *rxq;
 	int rc = 0;
 
+	if (queue_idx >= bp->max_rx_rings) {
+		RTE_LOG(ERR, PMD,
+			"Cannot create Rx ring %d. Only %d rings available\n",
+			queue_idx, bp->max_rx_rings);
+		return -ENOSPC;
+	}
+
 	if (!nb_desc || nb_desc > MAX_RX_DESC_CNT) {
 		RTE_LOG(ERR, PMD, "nb_desc %d is invalid\n", nb_desc);
 		rc = -EINVAL;
diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c
index 99dddddfc..25c33f5e4 100644
--- a/drivers/net/bnxt/bnxt_txq.c
+++ b/drivers/net/bnxt/bnxt_txq.c
@@ -108,6 +108,13 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	struct bnxt_tx_queue *txq;
 	int rc = 0;
 
+	if (queue_idx >= bp->max_tx_rings) {
+		RTE_LOG(ERR, PMD,
+			"Cannot create Tx ring %d. Only %d rings available\n",
+			queue_idx, bp->max_tx_rings);
+		return -ENOSPC;
+	}
+
 	if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) {
 		RTE_LOG(ERR, PMD, "nb_desc %d is invalid", nb_desc);
 		rc = -EINVAL;
-- 
2.14.3 (Apple Git-98)

  parent reply	other threads:[~2018-01-08 20:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-08 20:24 [dpdk-dev] [PATCH 00/13] bnxt atchset Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 01/13] net/bnxt: check return values in bnxt_dev_init Ajit Khaparde
2018-01-08 20:53   ` Stephen Hemminger
2018-01-08 20:24 ` [dpdk-dev] [PATCH 02/13] net/bnxt: fix double increment of idx during Tx ring alloc Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 03/13] net/bnxt: parse checksum offload flags Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 04/13] net/bnxt: fix grp_info usage Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 05/13] net/bnxt: return proper error code Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 06/13] net/bnxt: add check for multi host PF per port Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 07/13] net/bnxt: check if initialization is done before accessing stats Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 08/13] net/bnxt: fix check for ether_type Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 09/13] net/bnxt: remove unnecessary addition of a temporary filter Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 10/13] net/bnxt: fix duplicate filter pattern creation error Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 11/13] net/bnxt: fix bug with duplicate pattern for 5tuple filter Ajit Khaparde
2018-01-08 20:24 ` [dpdk-dev] [PATCH 12/13] bnxt/bnxt: free the aggregration ring while freeing all the HWRM rings Ajit Khaparde
2018-01-08 20:24 ` Ajit Khaparde [this message]
2018-01-10 20:32 ` [dpdk-dev] [PATCH 00/13] bnxt atchset Ferruh Yigit

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=20180108202437.56305-14-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /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).