[1/4] net/nfp: add a new flag to indicate PF

Message ID 20240903014145.2635710-2-chaoyong.he@corigine.com (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers
Series Support new card using NFP 3800 chip |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Sept. 3, 2024, 1:41 a.m. UTC
Add a new flag field 'is_pf' into 'struct nfp_net_hw_priv', to indicate
if the device is PF or not.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
 drivers/net/nfp/nfp_ethdev.c     | 2 ++
 drivers/net/nfp/nfp_net_common.c | 6 +++---
 drivers/net/nfp/nfp_net_common.h | 2 ++
 3 files changed, 7 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index bd35df2dc9..181fd74efe 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -2298,6 +2298,7 @@  nfp_pf_init(struct rte_pci_device *pci_dev)
 	if (ret != 0)
 		goto vf_cfg_tbl_cleanup;
 
+	hw_priv->is_pf = true;
 	hw_priv->pf_dev = pf_dev;
 	hw_priv->dev_info = dev_info;
 
@@ -2544,6 +2545,7 @@  nfp_pf_secondary_init(struct rte_pci_device *pci_dev)
 	pf_dev->pci_dev = pci_dev;
 	pf_dev->sync = sync;
 
+	hw_priv->is_pf = true;
 	hw_priv->pf_dev = pf_dev;
 	hw_priv->dev_info = dev_info;
 
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 3d916cd147..b471fd032a 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -783,7 +783,7 @@  nfp_net_link_update_common(struct rte_eth_dev *dev,
 
 	hw_priv = dev->process_private;
 	if (link->link_status == RTE_ETH_LINK_UP) {
-		if (hw_priv->pf_dev != NULL) {
+		if (hw_priv->is_pf) {
 			nfp_net_speed_aneg_update(dev, hw, hw_priv, link);
 		} else {
 			/*
@@ -845,7 +845,7 @@  nfp_net_link_update(struct rte_eth_dev *dev,
 	 * Not applicable for VFs as the associated PF is still attached to the
 	 * kernel driver.
 	 */
-	if (hw_priv != NULL && hw_priv->pf_dev != NULL)
+	if (hw_priv != NULL && hw_priv->is_pf)
 		nfp_net_notify_port_speed(hw, &link);
 
 	return ret;
@@ -1366,7 +1366,7 @@  nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	}
 
 	/* Only PF supports getting speed capability. */
-	if (hw_priv->pf_dev != NULL)
+	if (hw_priv->is_pf)
 		dev_info->speed_capa = hw_priv->pf_dev->speed_capa;
 
 	return 0;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index bebb754ced..67ec5a2d89 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -207,6 +207,8 @@  struct nfp_net_hw_priv {
 
 	/** NFP ASIC params */
 	const struct nfp_dev_info *dev_info;
+
+	bool is_pf;
 };
 
 struct nfp_net_hw {