Skip to content

Commit

Permalink
net/bnxt: fix ring calculation for representors
Browse files Browse the repository at this point in the history
[ upstream commit 59e6281 ]

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: 322bd6e ("net/bnxt: add port representor infrastructure")

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>
  • Loading branch information
ajitkhaparde authored and bluca committed Feb 17, 2022
1 parent c9eb38c commit 045d6f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion drivers/net/bnxt/bnxt.h
Expand Up @@ -798,7 +798,7 @@ struct bnxt {
uint16_t max_rx_rings;
#define MAX_STINGRAY_RINGS 128U

#define BNXT_MAX_VF_REP_RINGS 8
#define BNXT_MAX_VF_REP_RINGS 8U

uint16_t max_nq_rings;
uint16_t max_l2_ctx;
Expand Down
21 changes: 12 additions & 9 deletions drivers/net/bnxt/bnxt_reps.c
Expand Up @@ -523,7 +523,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;
Expand Down Expand Up @@ -603,10 +606,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;
}

Expand Down Expand Up @@ -702,10 +705,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;
}

Expand Down Expand Up @@ -777,10 +780,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];
Expand All @@ -800,9 +803,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;
Expand Down

0 comments on commit 045d6f7

Please sign in to comment.