net/bnxt: inform firmware about IF state changes
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Wed, 2 Oct 2019 01:23:24 +0000 (18:23 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 8 Oct 2019 10:14:30 +0000 (12:14 +0200)
Use latest firmware API to inform firmware about IF state changes.
Firmware has the option to clean up resources during IF down and
to require the driver to reserve resources again during IF up.

During port start, HWRM_FUNC_DRV_IF_CHANGE command response
flags indicates that firmware has reset. Add logic to re-probe
the firmware and re-setup resources.

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt.h
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_hwrm.c
drivers/net/bnxt/bnxt_hwrm.h

index 8797b03..040cae3 100644 (file)
@@ -370,6 +370,8 @@ struct bnxt {
 #define BNXT_FLAG_STINGRAY     (1 << 14)
 #define BNXT_FLAG_FW_RESET     (1 << 15)
 #define BNXT_FLAG_FATAL_ERROR  (1 << 16)
+#define BNXT_FLAG_FW_CAP_IF_CHANGE     (1 << 17)
+#define BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE  (1 << 18)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED  (1 << 29)
 #define BNXT_FLAG_NEW_RM       (1 << 30)
 #define BNXT_FLAG_INIT_DONE    (1U << 31)
index 6bc006a..1bb84ea 100644 (file)
@@ -794,6 +794,25 @@ bnxt_transmit_function(__rte_unused struct rte_eth_dev *eth_dev)
        return bnxt_xmit_pkts;
 }
 
+static int bnxt_handle_if_change_status(struct bnxt *bp)
+{
+       int rc;
+
+       /* Since fw has undergone a reset and lost all contexts,
+        * set fatal flag to not issue hwrm during cleanup
+        */
+       bp->flags |= BNXT_FLAG_FATAL_ERROR;
+       bnxt_uninit_resources(bp, true);
+
+       /* clear fatal flag so that re-init happens */
+       bp->flags &= ~BNXT_FLAG_FATAL_ERROR;
+       rc = bnxt_init_resources(bp, true);
+
+       bp->flags &= ~BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE;
+
+       return rc;
+}
+
 static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 {
        struct bnxt *bp = eth_dev->data->dev_private;
@@ -807,6 +826,15 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
                        bp->rx_cp_nr_rings, RTE_ETHDEV_QUEUE_STAT_CNTRS);
        }
 
+       rc = bnxt_hwrm_if_change(bp, 1);
+       if (!rc) {
+               if (bp->flags & BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE) {
+                       rc = bnxt_handle_if_change_status(bp);
+                       if (rc)
+                               return rc;
+               }
+       }
+
        rc = bnxt_init_chip(bp);
        if (rc)
                goto error;
@@ -833,6 +861,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
        return 0;
 
 error:
+       bnxt_hwrm_if_change(bp, 0);
        bnxt_shutdown_nic(bp);
        bnxt_free_tx_mbufs(bp);
        bnxt_free_rx_mbufs(bp);
@@ -899,6 +928,7 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
        bnxt_free_tx_mbufs(bp);
        bnxt_free_rx_mbufs(bp);
        bnxt_shutdown_nic(bp);
+       bnxt_hwrm_if_change(bp, 0);
        bp->dev_stopped = 1;
 }
 
index abbad01..1bdbb14 100644 (file)
@@ -726,6 +726,11 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
        HWRM_CHECK_RESULT();
+
+       flags = rte_le_to_cpu_32(resp->flags);
+       if (flags & HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED)
+               bp->flags |= BNXT_FLAG_FW_CAP_IF_CHANGE;
+
        HWRM_UNLOCK();
 
        bp->flags |= BNXT_FLAG_REGISTERED;
@@ -4659,3 +4664,40 @@ int bnxt_hwrm_set_mac(struct bnxt *bp)
 
        return rc;
 }
+
+int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
+{
+       struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
+       struct hwrm_func_drv_if_change_input req = {0};
+       uint32_t flags;
+       int rc;
+
+       if (!(bp->flags & BNXT_FLAG_FW_CAP_IF_CHANGE))
+               return 0;
+
+       /* Do not issue FUNC_DRV_IF_CHANGE during reset recovery.
+        * If we issue FUNC_DRV_IF_CHANGE with flags down before
+        * FUNC_DRV_UNRGTR, FW resets before FUNC_DRV_UNRGTR
+        */
+       if (!up && (bp->flags & BNXT_FLAG_FW_RESET))
+               return 0;
+
+       HWRM_PREP(req, FUNC_DRV_IF_CHANGE, BNXT_USE_CHIMP_MB);
+
+       if (up)
+               req.flags =
+               rte_cpu_to_le_32(HWRM_FUNC_DRV_IF_CHANGE_INPUT_FLAGS_UP);
+
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+       HWRM_CHECK_RESULT();
+       flags = rte_le_to_cpu_32(resp->flags);
+       HWRM_UNLOCK();
+
+       if (flags & HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_HOT_FW_RESET_DONE) {
+               PMD_DRV_LOG(INFO, "FW reset happened while port was down\n");
+               bp->flags |= BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE;
+       }
+
+       return 0;
+}
index a036205..2f57e95 100644 (file)
@@ -201,4 +201,5 @@ int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type);
 int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
                                   uint16_t *dst_fid);
 int bnxt_hwrm_set_mac(struct bnxt *bp);
+int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 #endif