From: Ajit Khaparde Date: Mon, 8 Jan 2018 20:24:37 +0000 (-0800) Subject: net/bnxt: check on-chip resources X-Git-Tag: spdx-start~366 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f10d528250cd9f698778f3c4c6cb771479d8a3fa;p=dpdk.git net/bnxt: check on-chip resources 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 --- diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 41b23cc4f5..36c01fa694 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->max_rx_rings || + eth_dev->data->nb_tx_queues > bp->max_tx_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->max_tx_rings, bp->max_rx_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 c4da474e91..f7fbb28561 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 99dddddfc5..25c33f5e43 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;