net/bnxt: fix ring calculation for representors
PATCH 1/1 net/bnxt: fix ring calculation for representors
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.
--- drivers/net/bnxt/bnxt.h | 2 +- drivers/net/bnxt/bnxt_reps.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/net/bnxt/bnxt.h +1 -1
@@ -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 8Uuint16_t max_nq_rings;uint16_t max_l2_ctx;
drivers/net/bnxt/bnxt_reps.c +10 -9
@@ -548,7 +548,8 @@ 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 =RTE_MIN (parent_bp->rx_nr_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 +630,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 +730,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 +806,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 +829,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 ;
Signature · 1 line
2.32.0 (Apple Git-132)
Quoted 8 lines · Ajit Khaparde
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.
Quoted 6 lines
Fixes 322bd6e70272 ("net/bnxt: add port representor infrastructure")Signed-off-by Ajit Khaparde <[email protected]>Reviewed-by Somnath Kotur <[email protected]>Reviewed-by Kalesh AP <[email protected]>
Patch applied to dpdk-next-net-brcm.
Quoted 86 lines
--- drivers/net/bnxt/bnxt.h | 2 +- drivers/net/bnxt/bnxt_reps.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-)drivers/net/bnxt/bnxt.h +1
-1@@ -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 8Uuint16_t max_nq_rings;uint16_t max_l2_ctx;drivers/net/bnxt/bnxt_reps.c +10
-10@@ -548,7 +548,8 @@ 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 =RTE_MIN (parent_bp->rx_nr_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 +630,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 +730,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 +806,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 +829,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)
Quoted 10 lines · Ajit Khaparde
Quoted 8 lines · Ajit Khaparde
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.
Quoted 7 lines
Quoted 6 lines
Fixes 322bd6e70272 ("net/bnxt: add port representor infrastructure")Signed-off-by Ajit Khaparde <[email protected]>Reviewed-by Somnath Kotur <[email protected]>Reviewed-by Kalesh AP <[email protected]>Patch applied to dpdk-next-net-brcm.
Reverting and sending a fresh version.
Quoted 87 lines
Quoted 87 lines
--- drivers/net/bnxt/bnxt.h | 2 +- drivers/net/bnxt/bnxt_reps.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-)drivers/net/bnxt/bnxt.h +1
-1@@ -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 8Uuint16_t max_nq_rings;uint16_t max_l2_ctx;drivers/net/bnxt/bnxt_reps.c +10
-10@@ -548,7 +548,8 @@ 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 =RTE_MIN (parent_bp->rx_nr_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 +630,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 +730,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 +806,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 +829,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)
PATCH v2 1/1 net/bnxt: fix ring calculation for representors
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.
--- drivers/net/bnxt/bnxt.h | 2 +- drivers/net/bnxt/bnxt_reps.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-)
drivers/net/bnxt/bnxt.h +1 -1
@@ -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 8Uuint16_t max_nq_rings;uint16_t max_l2_ctx;
drivers/net/bnxt/bnxt_reps.c +12 -9
@@ -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 ;
Signature · 1 line
2.32.0 (Apple Git-132)
Quoted 12 lines · Ajit Khaparde
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.
Quoted 6 lines
Fixes 322bd6e70272 ("net/bnxt: add port representor infrastructure")Signed-off-by Ajit Khaparde <[email protected]>Reviewed-by Somnath Kotur <[email protected]>Reviewed-by Kalesh AP <[email protected]>
v1->v2: sets a default queue count if under some cases we find to be 0.
Patch applied to dpdk-next-net-brcm.