diff mbox series

[3/4] net/bnxt: minor refactoring of async handling code

Message ID 20210712080435.9149-4-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers show
Series bnxt PMD patches | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kalesh A P July 12, 2021, 8:04 a.m. UTC
From: Somnath Kotur <somnath.kotur@broadcom.com>

Store the async event completion data1 and data2 in separate variables
at the start of the function before the switch case for the different
events so they can be used by any of the event handlers.

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_cpr.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index 2c7fd78..500146b 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -103,7 +103,10 @@  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;
+	uint32_t data1, data2;
+
+	data1 = rte_le_to_cpu_32(async_cmp->event_data1);
+	data2 = rte_le_to_cpu_32(async_cmp->event_data2);
 
 	switch (event_id) {
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
@@ -136,7 +139,7 @@  void bnxt_handle_async_event(struct bnxt *bp,
 		}
 
 		pthread_mutex_lock(&bp->err_recovery_lock);
-		event_data = rte_le_to_cpu_32(async_cmp->event_data1);
+		event_data = data1;
 		/* timestamp_lo/hi values are in units of 100ms */
 		bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
 			rte_le_to_cpu_16(async_cmp->timestamp_hi) * 100 :
@@ -170,8 +173,7 @@  void bnxt_handle_async_event(struct bnxt *bp,
 		PMD_DRV_LOG(INFO, "Port %u: Error recovery async event received\n",
 			    port_id);
 
-		event_data = rte_le_to_cpu_32(async_cmp->event_data1) &
-				EVENT_DATA1_FLAGS_MASK;
+		event_data = data1 & EVENT_DATA1_FLAGS_MASK;
 
 		if (event_data & EVENT_DATA1_FLAGS_MASTER_FUNC)
 			info->flags |= BNXT_FLAG_MASTER_FUNC;
@@ -198,22 +200,18 @@  void bnxt_handle_async_event(struct bnxt *bp,
 		bnxt_schedule_fw_health_check(bp);
 		break;
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEBUG_NOTIFICATION:
-		PMD_DRV_LOG(INFO, "DNC event: evt_data1 %#x evt_data2 %#x\n",
-			    rte_le_to_cpu_32(async_cmp->event_data1),
-			    rte_le_to_cpu_32(async_cmp->event_data2));
+		PMD_DRV_LOG(INFO, "Port: %u DNC event: data1 %#x data2 %#x\n",
+			    port_id, data1, data2);
 		break;
 	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);
+			    port_id, data1, data2);
 		if (bp->recovery_info)
-			bnxt_hwrm_fw_echo_reply(bp, echo_req_data1,
-						echo_req_data2);
+			bnxt_hwrm_fw_echo_reply(bp, data1, data2);
 		break;
 	default:
 		PMD_DRV_LOG(DEBUG, "handle_async_event id = 0x%x\n", event_id);