diff mbox series

[12/18] net/bnxt: refactor bnxt_stop_rxtx() for reuse

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kalesh A P Jan. 4, 2022, 8:38 a.m. UTC
From: Somnath Kotur <somnath.kotur@broadcom.com>

By accepting rte_eth_dev as input, bnxt_stop_rxtx() can be used
in multiple scenarios such as representor devices.

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
 drivers/net/bnxt/bnxt_cpr.c    | 16 ++++++++--------
 drivers/net/bnxt/bnxt_cpr.h    |  2 +-
 drivers/net/bnxt/bnxt_ethdev.c |  5 ++---
 drivers/net/bnxt/bnxt_reps.c   |  3 +--
 4 files changed, 12 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index a43b22a..593eebf 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -149,7 +149,7 @@  void bnxt_handle_async_event(struct bnxt *bp,
 		 * Avoid any rx/tx packet processing during firmware reset
 		 * operation.
 		 */
-		bnxt_stop_rxtx(bp);
+		bnxt_stop_rxtx(bp->eth_dev);
 
 		/* Ignore reset notify async events when stopping the port */
 		if (!bp->eth_dev->data->dev_started) {
@@ -383,15 +383,15 @@  bool bnxt_is_recovery_enabled(struct bnxt *bp)
 	return false;
 }
 
-void bnxt_stop_rxtx(struct bnxt *bp)
+void bnxt_stop_rxtx(struct rte_eth_dev *eth_dev)
 {
-	bp->eth_dev->rx_pkt_burst = &bnxt_dummy_recv_pkts;
-	bp->eth_dev->tx_pkt_burst = &bnxt_dummy_xmit_pkts;
+	eth_dev->rx_pkt_burst = &bnxt_dummy_recv_pkts;
+	eth_dev->tx_pkt_burst = &bnxt_dummy_xmit_pkts;
 
-	rte_eth_fp_ops[bp->eth_dev->data->port_id].rx_pkt_burst =
-		bp->eth_dev->rx_pkt_burst;
-	rte_eth_fp_ops[bp->eth_dev->data->port_id].tx_pkt_burst =
-		bp->eth_dev->tx_pkt_burst;
+	rte_eth_fp_ops[eth_dev->data->port_id].rx_pkt_burst =
+		eth_dev->rx_pkt_burst;
+	rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst =
+		eth_dev->tx_pkt_burst;
 	rte_mb();
 
 	/* Allow time for threads to exit the real burst functions. */
diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h
index 73468ed..52db382 100644
--- a/drivers/net/bnxt/bnxt_cpr.h
+++ b/drivers/net/bnxt/bnxt_cpr.h
@@ -117,7 +117,7 @@  void bnxt_wait_for_device_shutdown(struct bnxt *bp);
 bool bnxt_is_recovery_enabled(struct bnxt *bp);
 bool bnxt_is_primary_func(struct bnxt *bp);
 
-void bnxt_stop_rxtx(struct bnxt *bp);
+void bnxt_stop_rxtx(struct rte_eth_dev *eth_dev);
 
 /**
  * Check validity of a completion ring entry. If the entry is valid, include a
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 00acdb7..cf3bd77 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1471,8 +1471,7 @@  static int bnxt_dev_stop(struct rte_eth_dev *eth_dev)
 	eth_dev->data->dev_started = 0;
 
 	/* Prevent crashes when queues are still in use */
-	eth_dev->rx_pkt_burst = &bnxt_dummy_recv_pkts;
-	eth_dev->tx_pkt_burst = &bnxt_dummy_xmit_pkts;
+	bnxt_stop_rxtx(eth_dev);
 
 	bnxt_disable_int(bp);
 
@@ -4557,7 +4556,7 @@  static void bnxt_check_fw_health(void *arg)
 	bp->flags |= BNXT_FLAG_FATAL_ERROR;
 	bp->flags |= BNXT_FLAG_FW_RESET;
 
-	bnxt_stop_rxtx(bp);
+	bnxt_stop_rxtx(bp->eth_dev);
 
 	PMD_DRV_LOG(ERR, "Detected FW dead condition\n");
 
diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index 22b76b7..f24f5ef 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -505,8 +505,7 @@  int bnxt_rep_dev_stop_op(struct rte_eth_dev *eth_dev)
 	struct bnxt_representor *vfr_bp = eth_dev->data->dev_private;
 
 	/* Avoid crashes as we are about to free queues */
-	eth_dev->rx_pkt_burst = &bnxt_dummy_recv_pkts;
-	eth_dev->tx_pkt_burst = &bnxt_dummy_xmit_pkts;
+	bnxt_stop_rxtx(eth_dev);
 
 	BNXT_TF_DBG(DEBUG, "BNXT Port:%d VFR stop\n", eth_dev->data->port_id);