[v2,06/11] net/nfp: remove redundancy logic of init control BAR

Message ID 20231028065315.1937188-7-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series Clean up NFP PMD |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Oct. 28, 2023, 6:53 a.m. UTC
  There are two initialize statements of control BAR in 'nfp_net_init()'
and the first one is unneeded, and what it really use is the check of
NULL value of the 'mem_resource'. So we move the check of 'mem_resource'
to the start of probe logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfp_ethdev.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 7c5b780e82..8057452799 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -503,12 +503,6 @@  nfp_net_init(struct rte_eth_dev *eth_dev)
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-	hw->ctrl_bar = pci_dev->mem_resource[0].addr;
-	if (hw->ctrl_bar == NULL) {
-		PMD_DRV_LOG(ERR, "hw->ctrl_bar is NULL. BAR0 not configured");
-		return -ENODEV;
-	}
-
 	if (port == 0) {
 		uint32_t min_size;
 
@@ -890,6 +884,11 @@  nfp_pf_init(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -ENODEV;
 
+	if (pci_dev->mem_resource[0].addr == NULL) {
+		PMD_INIT_LOG(ERR, "The address of BAR0 is NULL.");
+		return -ENODEV;
+	}
+
 	dev_info = nfp_dev_info_get(pci_dev->id.device_id);
 	if (dev_info == NULL) {
 		PMD_INIT_LOG(ERR, "Not supported device ID");
@@ -1089,6 +1088,11 @@  nfp_pf_secondary_init(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -ENODEV;
 
+	if (pci_dev->mem_resource[0].addr == NULL) {
+		PMD_INIT_LOG(ERR, "The address of BAR0 is NULL.");
+		return -ENODEV;
+	}
+
 	dev_info = nfp_dev_info_get(pci_dev->id.device_id);
 	if (dev_info == NULL) {
 		PMD_INIT_LOG(ERR, "Not supported device ID");