* [dpdk-stable] [PATCH 18.11 1/2] net/bnxt: fix checking VNIC in shutdown path
@ 2020-12-03 4:32 Somnath Kotur
2020-12-03 4:32 ` [dpdk-stable] [PATCH 18.11 2/2] net/bnxt: fix queue release Somnath Kotur
2020-12-03 16:43 ` [dpdk-stable] [PATCH 18.11 1/2] net/bnxt: fix checking VNIC in shutdown path Kevin Traynor
0 siblings, 2 replies; 3+ messages in thread
From: Somnath Kotur @ 2020-12-03 4:32 UTC (permalink / raw)
To: stable; +Cc: Somnath Kotur, Ajit Khaparde
[upstream commit 4b029f02de3a0ce9cdd9a3475b84ca2e42d74281]
Add a couple of NULL pointer checks in bnxt_free_all_filters()
and bnxt_free_vnics() respectively to guard against certain error
injection/recovery scenarios where it was found that the application
was crashing with the bp->vnic_info pointer being NULL.
Fixes: 51fafb89a9a0 ("net/bnxt: get rid of ff pools and use VNIC info array")
Cc: stable@dpdk.org
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_filter.c | 15 +++++++++------
drivers/net/bnxt/bnxt_vnic.c | 3 +++
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index b64ae1b20e..3dbd004924 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -80,6 +80,15 @@ void bnxt_free_all_filters(struct bnxt *bp)
struct bnxt_filter_info *filter, *temp_filter;
unsigned int i;
+ for (i = 0; i < bp->pf.max_vfs; i++) {
+ STAILQ_FOREACH(filter, &bp->pf.vf_info[i].filter, next) {
+ bnxt_hwrm_clear_l2_filter(bp, filter);
+ }
+ }
+
+ if (bp->vnic_info == NULL)
+ return;
+
for (i = 0; i < bp->nr_vnics; i++) {
vnic = &bp->vnic_info[i];
filter = STAILQ_FIRST(&vnic->filter);
@@ -93,12 +102,6 @@ void bnxt_free_all_filters(struct bnxt *bp)
}
STAILQ_INIT(&vnic->filter);
}
-
- for (i = 0; i < bp->pf.max_vfs; i++) {
- STAILQ_FOREACH(filter, &bp->pf.vf_info[i].filter, next) {
- bnxt_hwrm_clear_l2_filter(bp, filter);
- }
- }
}
void bnxt_free_filter_mem(struct bnxt *bp)
diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index 30af7a56c8..183a62d94c 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -78,6 +78,9 @@ void bnxt_free_all_vnics(struct bnxt *bp)
struct bnxt_vnic_info *temp;
unsigned int i;
+ if (bp->vnic_info == NULL)
+ return;
+
for (i = 0; i < bp->nr_vnics; i++) {
temp = &bp->vnic_info[i];
STAILQ_INSERT_TAIL(&bp->free_vnic_list, temp, next);
--
2.28.0.497.g54e85e7
^ permalink raw reply [flat|nested] 3+ messages in thread
* [dpdk-stable] [PATCH 18.11 2/2] net/bnxt: fix queue release
2020-12-03 4:32 [dpdk-stable] [PATCH 18.11 1/2] net/bnxt: fix checking VNIC in shutdown path Somnath Kotur
@ 2020-12-03 4:32 ` Somnath Kotur
2020-12-03 16:43 ` [dpdk-stable] [PATCH 18.11 1/2] net/bnxt: fix checking VNIC in shutdown path Kevin Traynor
1 sibling, 0 replies; 3+ messages in thread
From: Somnath Kotur @ 2020-12-03 4:32 UTC (permalink / raw)
To: stable; +Cc: Somnath Kotur, Ajit Khaparde
[upstream commit 97c3271781bf1094b0ab0235f472fb5a468b02d3]
Some of the ring related memory was not being freed in both the release
ops. Fix to free them now.
Add some more NULL ptr checks in the corresponding queue_release_mbufs()
and queue_release_op() respectively.
Also call queue_release_op() in the error path of the corresponding
queue_setup_op()
Fixes: 6133f207970c ("net/bnxt: add Rx queue create/destroy")
Fixes: 51c87ebafc7d ("net/bnxt: add Tx queue create/destroy")
Cc: stable@dpdk.org
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_rxq.c | 45 +++++++++++++++++++++++--------------
drivers/net/bnxt/bnxt_txq.c | 32 +++++++++++++++-----------
2 files changed, 47 insertions(+), 30 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index d1664dbc09..34dbb1dbdb 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -205,7 +205,7 @@ void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq)
struct bnxt_tpa_info *tpa_info;
uint16_t i;
- if (!rxq)
+ if (!rxq || !rxq->rx_ring)
return;
rte_spinlock_lock(&rxq->lock);
@@ -265,12 +265,21 @@ void bnxt_rx_queue_release_op(void *rx_queue)
bnxt_rx_queue_release_mbufs(rxq);
/* Free RX ring hardware descriptors */
- bnxt_free_ring(rxq->rx_ring->rx_ring_struct);
- /* Free RX Agg ring hardware descriptors */
- bnxt_free_ring(rxq->rx_ring->ag_ring_struct);
-
+ if (rxq->rx_ring) {
+ bnxt_free_ring(rxq->rx_ring->rx_ring_struct);
+ rte_free(rxq->rx_ring->rx_ring_struct);
+ /* Free RX Agg ring hardware descriptors */
+ bnxt_free_ring(rxq->rx_ring->ag_ring_struct);
+ rte_free(rxq->rx_ring->ag_ring_struct);
+
+ rte_free(rxq->rx_ring);
+ }
/* Free RX completion ring hardware descriptors */
- bnxt_free_ring(rxq->cp_ring->cp_ring_struct);
+ if (rxq->cp_ring) {
+ bnxt_free_ring(rxq->cp_ring->cp_ring_struct);
+ rte_free(rxq->cp_ring->cp_ring_struct);
+ rte_free(rxq->cp_ring);
+ }
bnxt_free_rxq_stats(rxq);
rte_memzone_free(rxq->mz);
@@ -302,8 +311,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
if (!nb_desc || nb_desc > MAX_RX_DESC_CNT) {
PMD_DRV_LOG(ERR, "nb_desc %d is invalid\n", nb_desc);
- rc = -EINVAL;
- goto out;
+ return -EINVAL;
}
if (eth_dev->data->rx_queues) {
@@ -315,8 +323,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
RTE_CACHE_LINE_SIZE, socket_id);
if (!rxq) {
PMD_DRV_LOG(ERR, "bnxt_rx_queue allocation failed!\n");
- rc = -ENOMEM;
- goto out;
+ return -ENOMEM;
}
rxq->bp = bp;
rxq->mb_pool = mp;
@@ -326,8 +333,11 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
PMD_DRV_LOG(DEBUG, "RX Buf MTU %d\n", eth_dev->data->mtu);
rc = bnxt_init_rx_ring_struct(rxq, socket_id);
- if (rc)
- goto out;
+ if (rc) {
+ PMD_DRV_LOG(ERR,
+ "init_rx_ring_struct failed!\n");
+ goto err;
+ }
PMD_DRV_LOG(DEBUG, "RX Buf size is %d\n", rxq->rx_buf_size);
rxq->queue_id = queue_idx;
@@ -342,10 +352,8 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
if (bnxt_alloc_rings(bp, queue_idx, NULL, rxq, rxq->cp_ring,
"rxr")) {
PMD_DRV_LOG(ERR,
- "ring_dma_zone_reserve for rx_ring failed!\n");
- bnxt_rx_queue_release_op(rxq);
- rc = -ENOMEM;
- goto out;
+ "ring_dma_zone_reserve for rx_ring failed!\n");
+ goto err;
}
rte_atomic64_init(&rxq->rx_mbuf_alloc_fail);
@@ -369,7 +377,10 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
/* Configure mtu if it is different from what was configured before */
if (!queue_idx)
bnxt_mtu_set_op(eth_dev, eth_dev->data->mtu);
-out:
+
+ return 0;
+err:
+ bnxt_rx_queue_release_op(rxq);
return rc;
}
diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c
index cf6ddfb69b..707712729d 100644
--- a/drivers/net/bnxt/bnxt_txq.c
+++ b/drivers/net/bnxt/bnxt_txq.c
@@ -28,7 +28,7 @@ static void bnxt_tx_queue_release_mbufs(struct bnxt_tx_queue *txq)
struct bnxt_sw_tx_bd *sw_ring;
uint16_t i;
- if (!txq)
+ if (!txq || !txq->tx_ring)
return;
sw_ring = txq->tx_ring->tx_buf_ring;
@@ -60,10 +60,18 @@ void bnxt_tx_queue_release_op(void *tx_queue)
if (txq) {
/* Free TX ring hardware descriptors */
bnxt_tx_queue_release_mbufs(txq);
- bnxt_free_ring(txq->tx_ring->tx_ring_struct);
+ if (txq->tx_ring) {
+ bnxt_free_ring(txq->tx_ring->tx_ring_struct);
+ rte_free(txq->tx_ring->tx_ring_struct);
+ rte_free(txq->tx_ring);
+ }
/* Free TX completion ring hardware descriptors */
- bnxt_free_ring(txq->cp_ring->cp_ring_struct);
+ if (txq->cp_ring) {
+ bnxt_free_ring(txq->cp_ring->cp_ring_struct);
+ rte_free(txq->cp_ring->cp_ring_struct);
+ rte_free(txq->cp_ring);
+ }
bnxt_free_txq_stats(txq);
rte_memzone_free(txq->mz);
@@ -92,8 +100,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) {
PMD_DRV_LOG(ERR, "nb_desc %d is invalid", nb_desc);
- rc = -EINVAL;
- goto out;
+ return -EINVAL;
}
if (eth_dev->data->tx_queues) {
@@ -107,8 +114,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
RTE_CACHE_LINE_SIZE, socket_id);
if (!txq) {
PMD_DRV_LOG(ERR, "bnxt_tx_queue allocation failed!");
- rc = -ENOMEM;
- goto out;
+ return -ENOMEM;
}
txq->bp = bp;
txq->nb_tx_desc = nb_desc;
@@ -117,7 +123,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
rc = bnxt_init_tx_ring_struct(txq, socket_id);
if (rc)
- goto out;
+ goto err;
txq->queue_id = queue_idx;
txq->port_id = eth_dev->data->port_id;
@@ -126,16 +132,14 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
if (bnxt_alloc_rings(bp, queue_idx, txq, NULL, txq->cp_ring,
"txr")) {
PMD_DRV_LOG(ERR, "ring_dma_zone_reserve for tx_ring failed!");
- bnxt_tx_queue_release_op(txq);
rc = -ENOMEM;
- goto out;
+ goto err;
}
if (bnxt_init_one_tx_ring(txq)) {
PMD_DRV_LOG(ERR, "bnxt_init_one_tx_ring failed!");
- bnxt_tx_queue_release_op(txq);
rc = -ENOMEM;
- goto out;
+ goto err;
}
eth_dev->data->tx_queues[queue_idx] = txq;
@@ -145,6 +149,8 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
else
txq->tx_started = true;
-out:
+ return 0;
+err:
+ bnxt_tx_queue_release_op(txq);
return rc;
}
--
2.28.0.497.g54e85e7
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-stable] [PATCH 18.11 1/2] net/bnxt: fix checking VNIC in shutdown path
2020-12-03 4:32 [dpdk-stable] [PATCH 18.11 1/2] net/bnxt: fix checking VNIC in shutdown path Somnath Kotur
2020-12-03 4:32 ` [dpdk-stable] [PATCH 18.11 2/2] net/bnxt: fix queue release Somnath Kotur
@ 2020-12-03 16:43 ` Kevin Traynor
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Traynor @ 2020-12-03 16:43 UTC (permalink / raw)
To: Somnath Kotur, stable; +Cc: Ajit Khaparde
On 03/12/2020 04:32, Somnath Kotur wrote:
> [upstream commit 4b029f02de3a0ce9cdd9a3475b84ca2e42d74281]
>
> Add a couple of NULL pointer checks in bnxt_free_all_filters()
> and bnxt_free_vnics() respectively to guard against certain error
> injection/recovery scenarios where it was found that the application
> was crashing with the bp->vnic_info pointer being NULL.
>
> Fixes: 51fafb89a9a0 ("net/bnxt: get rid of ff pools and use VNIC info array")
> Cc: stable@dpdk.org
>
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Applied series, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-03 16:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 4:32 [dpdk-stable] [PATCH 18.11 1/2] net/bnxt: fix checking VNIC in shutdown path Somnath Kotur
2020-12-03 4:32 ` [dpdk-stable] [PATCH 18.11 2/2] net/bnxt: fix queue release Somnath Kotur
2020-12-03 16:43 ` [dpdk-stable] [PATCH 18.11 1/2] net/bnxt: fix checking VNIC in shutdown path Kevin Traynor
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).