net/bnxt: handle echo request async message
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Wed, 24 Feb 2021 15:55:50 +0000 (21:25 +0530)
committerAjit Khaparde <ajit.khaparde@broadcom.com>
Fri, 12 Mar 2021 06:00:22 +0000 (07:00 +0100)
This is a new async message that the firmware can send to check if it
can communicate with the driver. This is an added error detection
scheme that firmware can use if it suspects errors in the PCIe
interface. When the driver receives this async message, it will reply
back echoing some data in the async message. If the firmware is not
getting the reply with the proper data after some retries, error
recovery will kick in.

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_cpr.c
drivers/net/bnxt/bnxt_hwrm.c
drivers/net/bnxt/bnxt_hwrm.h

index 20b4f92..2c7fd78 100644 (file)
@@ -103,6 +103,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
        uint16_t port_id = bp->eth_dev->data->port_id;
        struct bnxt_error_recovery_info *info;
        uint32_t event_data;
+       uint32_t echo_req_data1, echo_req_data2;
 
        switch (event_id) {
        case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
@@ -204,6 +205,16 @@ void bnxt_handle_async_event(struct bnxt *bp,
        case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE:
                bnxt_process_default_vnic_change(bp, async_cmp);
                break;
+       case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ECHO_REQUEST:
+               echo_req_data1 = rte_le_to_cpu_32(async_cmp->event_data1);
+               echo_req_data2 = rte_le_to_cpu_32(async_cmp->event_data2);
+               PMD_DRV_LOG(INFO,
+                           "Port %u: Received fw echo request: data1 %#x data2 %#x\n",
+                           port_id, echo_req_data1, echo_req_data2);
+               if (bp->recovery_info)
+                       bnxt_hwrm_fw_echo_reply(bp, echo_req_data1,
+                                               echo_req_data2);
+               break;
        default:
                PMD_DRV_LOG(DEBUG, "handle_async_event id = 0x%x\n", event_id);
                break;
index 37fa78e..9142119 100644 (file)
@@ -954,6 +954,9 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
                req.async_event_fwd[1] |=
                rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE);
 
+       req.async_event_fwd[2] |=
+               rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ECHO_REQUEST);
+
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
        HWRM_CHECK_RESULT();
@@ -5891,3 +5894,22 @@ int bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(struct bnxt *bp)
 
        return rc;
 }
+
+int bnxt_hwrm_fw_echo_reply(struct bnxt *bp, uint32_t echo_req_data1,
+                           uint32_t echo_req_data2)
+{
+       struct hwrm_func_echo_response_input req = {0};
+       struct hwrm_func_echo_response_output *resp = bp->hwrm_cmd_resp_addr;
+       int rc;
+
+       HWRM_PREP(&req, HWRM_FUNC_ECHO_RESPONSE, BNXT_USE_CHIMP_MB);
+       req.event_data1 = rte_cpu_to_le_32(echo_req_data1);
+       req.event_data2 = rte_cpu_to_le_32(echo_req_data2);
+
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+       HWRM_CHECK_RESULT();
+       HWRM_UNLOCK();
+
+       return rc;
+}
index 449cb91..c47c249 100644 (file)
@@ -35,6 +35,8 @@ struct hwrm_func_qstats_output;
        (1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEBUG_NOTIFICATION - 32))
 #define        ASYNC_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE \
        (1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEFAULT_VNIC_CHANGE - 32))
+#define        ASYNC_CMPL_EVENT_ID_ECHO_REQUEST        \
+       (1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ECHO_REQUEST - 64))
 
 #define HWRM_QUEUE_SERVICE_PROFILE_LOSSY \
        HWRM_QUEUE_QPORTCFG_OUTPUT_QUEUE_ID0_SERVICE_PROFILE_LOSSY
@@ -300,4 +302,6 @@ int bnxt_hwrm_first_vf_id_query(struct bnxt *bp, uint16_t fid,
 int bnxt_hwrm_cfa_pair_alloc(struct bnxt *bp, struct bnxt_representor *rep);
 int bnxt_hwrm_cfa_pair_free(struct bnxt *bp, struct bnxt_representor *rep);
 int bnxt_hwrm_cfa_adv_flow_mgmt_qcaps(struct bnxt *bp);
+int bnxt_hwrm_fw_echo_reply(struct bnxt *bp, uint32_t echo_req_data1,
+                           uint32_t echo_req_data2);
 #endif