struct bnxt_tpa_info *tpa_info;
uint16_t i;
- if (!rxq)
+ if (!rxq || !rxq->rx_ring)
return;
rte_spinlock_lock(&rxq->lock);
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);
if (nb_desc < BNXT_MIN_RING_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) {
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;
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;
if (bnxt_alloc_rings(bp, queue_idx, NULL, rxq, rxq->cp_ring, NULL,
"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);
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;
}
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;
/* 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);
if (nb_desc < BNXT_MIN_RING_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) {
RTE_CACHE_LINE_SIZE, socket_id);
if (!txq) {
PMD_DRV_LOG(ERR, "bnxt_tx_queue allocation failed!");
- rc = -ENOMEM;
- goto out;
+ return -ENOMEM;
}
txq->free = rte_zmalloc_socket(NULL,
RTE_CACHE_LINE_SIZE, socket_id);
if (!txq->free) {
PMD_DRV_LOG(ERR, "allocation of tx mbuf free array failed!");
- rte_free(txq);
rc = -ENOMEM;
- goto out;
+ goto err;
}
txq->bp = bp;
txq->nb_tx_desc = nb_desc;
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;
if (bnxt_alloc_rings(bp, queue_idx, txq, NULL, txq->cp_ring, NULL,
"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;
txq->tx_started = false;
else
txq->tx_started = true;
-out:
+
+ return 0;
+err:
+ bnxt_tx_queue_release_op(txq);
return rc;
}