net/bnxt: prevent device access when device is in reset
[dpdk.git] / drivers / net / bnxt / bnxt_rxq.c
index 31ab38f..d5fc526 100644 (file)
@@ -263,6 +263,9 @@ void bnxt_rx_queue_release_op(void *rx_queue)
        struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue;
 
        if (rxq) {
+               if (is_bnxt_in_error(rxq->bp))
+                       return;
+
                bnxt_rx_queue_release_mbufs(rxq);
 
                /* Free RX ring hardware descriptors */
@@ -294,6 +297,10 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
        int rc = 0;
        uint8_t queue_state;
 
+       rc = is_bnxt_in_error(bp);
+       if (rc)
+               return rc;
+
        if (queue_idx >= bp->max_rx_rings) {
                PMD_DRV_LOG(ERR,
                        "Cannot create Rx ring %d. Only %d rings available\n",
@@ -341,7 +348,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
        eth_dev->data->rx_queues[queue_idx] = rxq;
        /* Allocate RX ring hardware descriptors */
        if (bnxt_alloc_rings(bp, queue_idx, NULL, rxq, rxq->cp_ring,
-                       "rxr")) {
+                       rxq->nq_ring, "rxr")) {
                PMD_DRV_LOG(ERR,
                        "ring_dma_zone_reserve for rx_ring failed!\n");
                bnxt_rx_queue_release_op(rxq);
@@ -356,10 +363,6 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
        eth_dev->data->rx_queue_state[queue_idx] = queue_state;
        rte_spinlock_init(&rxq->lock);
 
-#ifdef RTE_ARCH_X86
-       bnxt_rxq_vec_setup(rxq);
-#endif
-
 out:
        return rc;
 }
@@ -367,10 +370,15 @@ out:
 int
 bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 {
+       struct bnxt *bp = eth_dev->data->dev_private;
        struct bnxt_rx_queue *rxq;
        struct bnxt_cp_ring_info *cpr;
        int rc = 0;
 
+       rc = is_bnxt_in_error(bp);
+       if (rc)
+               return rc;
+
        if (eth_dev->data->rx_queues) {
                rxq = eth_dev->data->rx_queues[queue_id];
                if (!rxq) {
@@ -378,7 +386,7 @@ bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
                        return rc;
                }
                cpr = rxq->cp_ring;
-               B_CP_DB_ARM(cpr);
+               B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
        }
        return rc;
 }
@@ -386,10 +394,15 @@ bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 int
 bnxt_rx_queue_intr_disable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 {
+       struct bnxt *bp = eth_dev->data->dev_private;
        struct bnxt_rx_queue *rxq;
        struct bnxt_cp_ring_info *cpr;
        int rc = 0;
 
+       rc = is_bnxt_in_error(bp);
+       if (rc)
+               return rc;
+
        if (eth_dev->data->rx_queues) {
                rxq = eth_dev->data->rx_queues[queue_id];
                if (!rxq) {
@@ -410,34 +423,50 @@ int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
        struct bnxt_vnic_info *vnic = NULL;
        int rc = 0;
 
+       rc = is_bnxt_in_error(bp);
+       if (rc)
+               return rc;
+
        if (rxq == NULL) {
                PMD_DRV_LOG(ERR, "Invalid Rx queue %d\n", rx_queue_id);
                return -EINVAL;
        }
 
-       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
-
        bnxt_free_hwrm_rx_ring(bp, rx_queue_id);
-       bnxt_alloc_hwrm_rx_ring(bp, rx_queue_id);
+       rc = bnxt_alloc_hwrm_rx_ring(bp, rx_queue_id);
+       if (rc)
+               return rc;
+
        PMD_DRV_LOG(INFO, "Rx queue started %d\n", rx_queue_id);
 
        if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
                vnic = rxq->vnic;
 
-               if (vnic->fw_grp_ids[rx_queue_id] != INVALID_HW_RING_ID)
-                       return 0;
+               if (BNXT_HAS_RING_GRPS(bp)) {
+                       if (vnic->fw_grp_ids[rx_queue_id] != INVALID_HW_RING_ID)
+                               return 0;
+
+                       vnic->fw_grp_ids[rx_queue_id] =
+                                       bp->grp_info[rx_queue_id].fw_grp_id;
+               }
 
                PMD_DRV_LOG(DEBUG,
                            "vnic = %p fw_grp_id = %d\n",
                            vnic, bp->grp_info[rx_queue_id].fw_grp_id);
 
-               vnic->fw_grp_ids[rx_queue_id] =
-                                       bp->grp_info[rx_queue_id].fw_grp_id;
                rc = bnxt_vnic_rss_configure(bp, vnic);
        }
 
-       if (rc == 0)
+       if (rc == 0) {
+               dev->data->rx_queue_state[rx_queue_id] =
+                               RTE_ETH_QUEUE_STATE_STARTED;
                rxq->rx_deferred_start = false;
+       }
+
+       PMD_DRV_LOG(INFO,
+                   "queue %d, rx_deferred_start %d, state %d!\n",
+                   rx_queue_id, rxq->rx_deferred_start,
+                   bp->eth_dev->data->rx_queue_state[rx_queue_id]);
 
        return rc;
 }
@@ -450,8 +479,15 @@ int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
        struct bnxt_rx_queue *rxq = NULL;
        int rc = 0;
 
-       /* Rx CQ 0 also works as Default CQ for async notifications */
-       if (!rx_queue_id) {
+       rc = is_bnxt_in_error(bp);
+       if (rc)
+               return rc;
+
+       /* For the stingray platform and other platforms needing tighter
+        * control of resource utilization, Rx CQ 0 also works as
+        * Default CQ for async notifications
+        */
+       if (!BNXT_NUM_ASYNC_CPR(bp) && !rx_queue_id) {
                PMD_DRV_LOG(ERR, "Cannot stop Rx queue id %d\n", rx_queue_id);
                return -EINVAL;
        }
@@ -469,7 +505,8 @@ int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 
        if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
                vnic = rxq->vnic;
-               vnic->fw_grp_ids[rx_queue_id] = INVALID_HW_RING_ID;
+               if (BNXT_HAS_RING_GRPS(bp))
+                       vnic->fw_grp_ids[rx_queue_id] = INVALID_HW_RING_ID;
                rc = bnxt_vnic_rss_configure(bp, vnic);
        }