net/bnxt: reduce cleanup time during reset recovery
[dpdk.git] / drivers / net / bnxt / bnxt_ethdev.c
index 5160ac0..69dafc4 100644 (file)
@@ -14,7 +14,6 @@
 #include <rte_alarm.h>
 
 #include "bnxt.h"
-#include "bnxt_cpr.h"
 #include "bnxt_filter.h"
 #include "bnxt_hwrm.h"
 #include "bnxt_irq.h"
@@ -27,7 +26,6 @@
 #include "bnxt_vnic.h"
 #include "hsi_struct_def_dpdk.h"
 #include "bnxt_nvm_defs.h"
-#include "bnxt_util.h"
 
 #define DRV_MODULE_NAME                "bnxt"
 static const char bnxt_version[] =
@@ -669,11 +667,28 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
                        return -ENOSPC;
                }
 
+               /* If a resource has already been allocated - in this case
+                * it is the async completion ring, free it. Reallocate it after
+                * resource reservation. This will ensure the resource counts
+                * are calculated correctly.
+                */
+               if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
+                       bnxt_disable_int(bp);
+                       bnxt_free_cp_ring(bp, bp->async_cp_ring);
+               }
+
                rc = bnxt_hwrm_func_reserve_vf_resc(bp, false);
                if (rc) {
                        PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc);
                        return -ENOSPC;
                }
+
+               if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
+                       rc = bnxt_alloc_async_cp_ring(bp);
+                       if (rc)
+                               return rc;
+                       bnxt_enable_int(bp);
+               }
        } else {
                /* legacy driver needs to get updated values */
                rc = bnxt_hwrm_func_qcaps(bp);
@@ -913,7 +928,7 @@ static int bnxt_dev_set_link_up_op(struct rte_eth_dev *eth_dev)
                eth_dev->data->dev_link.link_status = 1;
 
        bnxt_print_link_info(eth_dev);
-       return 0;
+       return rc;
 }
 
 static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev)
@@ -952,8 +967,12 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
                eth_dev->data->dev_link.link_status = 0;
        }
        bnxt_dev_set_link_down_op(eth_dev);
-       /* Wait for link to be reset and the async notification to process. */
-       rte_delay_ms(BNXT_LINK_WAIT_INTERVAL * 2);
+
+       /* Wait for link to be reset and the async notification to process.
+        * During reset recovery, there is no need to wait
+        */
+       if (!is_bnxt_in_error(bp))
+               rte_delay_ms(BNXT_LINK_WAIT_INTERVAL * 2);
 
        /* Clean queue intr-vector mapping */
        rte_intr_efd_disable(intr_handle);