[5/8] net/nfp: add the step of clearing the beat time

Message ID 20240115025419.2447759-6-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series optimize the firmware loading process |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Jan. 15, 2024, 2:54 a.m. UTC
  From: Peng Zhang <peng.zhang@corigine.com>

Add the step of clearing the beat time of specific
port when DPDK exit. Add the step of clearing the
beat time of other ports when reload firmware.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
 drivers/net/nfp/nfp_ethdev.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
  

Patch

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 25f5fe483f..46bb09a211 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -470,6 +470,27 @@  nfp_net_keepalive_start(struct nfp_multi_pf *multi_pf)
 	return 0;
 }
 
+static void
+nfp_net_keepalive_clear(uint8_t *beat_addr,
+		uint8_t function_id)
+{
+	nn_writeq(0, beat_addr + NFP_BEAT_OFFSET(function_id));
+}
+
+static void
+nfp_net_keepalive_clear_others(const struct nfp_dev_info *dev_info,
+		struct nfp_multi_pf *multi_pf)
+{
+	uint8_t port_num;
+
+	for (port_num = 0; port_num < dev_info->pf_num_per_unit; port_num++) {
+		if (port_num == multi_pf->function_id)
+			continue;
+
+		nfp_net_keepalive_clear(multi_pf->beat_addr, port_num);
+	}
+}
+
 static void
 nfp_net_keepalive_stop(struct nfp_multi_pf *multi_pf)
 {
@@ -524,6 +545,7 @@  nfp_pf_uninit(struct nfp_pf_dev *pf_dev)
 	free(pf_dev->sym_tbl);
 	if (pf_dev->multi_pf.enabled) {
 		nfp_net_keepalive_stop(&pf_dev->multi_pf);
+		nfp_net_keepalive_clear(pf_dev->multi_pf.beat_addr, pf_dev->multi_pf.function_id);
 		nfp_net_keepalive_uninit(&pf_dev->multi_pf);
 	}
 	free(pf_dev->nfp_eth_table);
@@ -1147,6 +1169,8 @@  nfp_fw_reload_for_multipf(struct nfp_nsp *nsp,
 		return err;
 	}
 
+	nfp_net_keepalive_clear_others(dev_info, multi_pf);
+
 	return 0;
 }
 
@@ -1779,6 +1803,7 @@  nfp_pf_init(struct rte_pci_device *pci_dev)
 fw_cleanup:
 	nfp_fw_unload(cpp);
 	nfp_net_keepalive_stop(&pf_dev->multi_pf);
+	nfp_net_keepalive_clear(pf_dev->multi_pf.beat_addr, pf_dev->multi_pf.function_id);
 	nfp_net_keepalive_uninit(&pf_dev->multi_pf);
 eth_table_cleanup:
 	free(nfp_eth_table);