From: Kalesh AP <kalesh-anakkur.pura...@broadcom.com>

FW sets HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD
in HWRM_FUNC_QCAPS command, if device requires to invoke
fastboot FW during FW reset.

Wait for FW_STATUS to set the SHUTDOWN bit in health register
before the master function calls fastboot FW.

Signed-off-by: Kalesh AP <kalesh-anakkur.pura...@broadcom.com>
Reviewed-by: Rahul Gupta <rahul.gu...@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khapa...@broadcom.com>
---
 drivers/net/bnxt/bnxt.h                |  3 +++
 drivers/net/bnxt/bnxt_cpr.c            | 25 +++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.c           |  5 +++++
 drivers/net/bnxt/hsi_struct_def_dpdk.h |  8 ++++++++
 4 files changed, 41 insertions(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 7355acd4a..2e662b297 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -409,6 +409,8 @@ struct bnxt_error_recovery_info {
 #define BNXT_GRCP_WINDOW_2_BASE                0x2000
 #define BNXT_GRCP_WINDOW_3_BASE                0x3000
 
+#define BNXT_FW_STATUS_SHUTDOWN                0x100000
+
 #define BNXT_HWRM_SHORT_REQ_LEN                sizeof(struct hwrm_short_input)
 struct bnxt {
        void                            *bar0;
@@ -442,6 +444,7 @@ struct bnxt {
 #define BNXT_FLAG_EXT_STATS_SUPPORTED          BIT(20)
 #define BNXT_FLAG_NEW_RM                       BIT(21)
 #define BNXT_FLAG_INIT_DONE                    BIT(22)
+#define BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD    BIT(23)
 #define BNXT_PF(bp)            (!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)            ((bp)->flags & BNXT_FLAG_VF)
 #define BNXT_NPAR(bp)          ((bp)->port_partition_type)
diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index eb44d872d..de2b13c5d 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -5,6 +5,7 @@
 
 #include <rte_malloc.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include "bnxt.h"
 #include "bnxt_cpr.h"
@@ -12,6 +13,29 @@
 #include "bnxt_ring.h"
 #include "hsi_struct_def_dpdk.h"
 
+static void bnxt_handle_fatal_event(struct bnxt *bp)
+{
+       uint32_t val, timeout;
+
+       /* if HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD is set
+        * in HWRM_FUNC_QCAPS command, wait for FW_STATUS to set
+        * the SHUTDOWN bit in health register
+        */
+       if (!(bp->recovery_info &&
+             (bp->flags & BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD)))
+               return;
+
+       timeout = bp->fw_reset_min_msecs;
+       do {
+               val = bnxt_read_fw_status_reg(bp, BNXT_FW_STATUS_REG);
+               if (val & BNXT_FW_STATUS_SHUTDOWN)
+                       return;
+
+               rte_delay_ms(100);
+               timeout -= 100;
+       } while (timeout);
+}
+
 /*
  * Async event handling
  */
@@ -57,6 +81,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
                        PMD_DRV_LOG(INFO,
                                    "Firmware fatal reset event received\n");
                        bp->flags |= BNXT_FLAG_FATAL_ERROR;
+                       bnxt_handle_fatal_event(bp);
                } else {
                        PMD_DRV_LOG(INFO,
                                    "Firmware non-fatal reset event 
received\n");
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 1541dc3b6..bdc84c831 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -634,6 +634,11 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
                bp->flags &= ~BNXT_FLAG_FW_CAP_ERROR_RECOVERY;
        }
 
+       if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD)
+               bp->flags |= BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD;
+       else
+               bp->flags &= ~BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD;
+
        HWRM_UNLOCK();
 
        return rc;
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h 
b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 009571725..54f0c04c0 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -7327,6 +7327,14 @@ struct hwrm_func_qcaps_output {
         */
        #define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED \
                UINT32_C(0x1000000)
+       /*
+        * If the query is for a VF, then this flag shall be ignored.
+        * If this query is for a PF and this flag is set to 1, then host
+        * must initiate reset or reload (or fastboot) the firmware image
+        * upon detection of device shutdown state.
+        */
+       #define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD \
+               UINT32_C(0x2000000)
        /*
         * This value is current MAC address configured for this
         * function. A value of 00-00-00-00-00-00 indicates no
-- 
2.20.1 (Apple Git-117)

Reply via email to