From 705e0f32f62e3ee76ce8cd17c38091d3eb7fb965 Mon Sep 17 00:00:00 2001 From: Kalesh AP Date: Wed, 24 Feb 2021 21:25:50 +0530 Subject: [PATCH] net/bnxt: handle echo request async message 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 Reviewed-by: Lance Richardson Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_cpr.c | 11 +++++++++++ drivers/net/bnxt/bnxt_hwrm.c | 22 ++++++++++++++++++++++ drivers/net/bnxt/bnxt_hwrm.h | 4 ++++ 3 files changed, 37 insertions(+) diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c index 20b4f929ba..2c7fd78c3d 100644 --- a/drivers/net/bnxt/bnxt_cpr.c +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -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; diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 37fa78e79f..9142119954 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -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; +} diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 449cb911e5..c47c2498e9 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -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 -- 2.20.1