[v3,07/25] net/nfp: extract the ctrl BAR data field

Message ID 20231026064324.177531-8-chaoyong.he@corigine.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series add the NFP vDPA PMD |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Oct. 26, 2023, 6:43 a.m. UTC
  Extract the 'ctrl_bar' data filed into the super class, prepare for the
upcoming common library.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower.c |  8 ++++----
 drivers/net/nfp/nfp_ethdev.c        | 14 +++++++-------
 drivers/net/nfp/nfp_ethdev_vf.c     | 10 +++++-----
 drivers/net/nfp/nfp_net_common.c    |  4 ++--
 drivers/net/nfp/nfp_net_common.h    | 18 +++++++++---------
 drivers/net/nfp/nfp_net_ctrl.c      |  8 ++++----
 6 files changed, 31 insertions(+), 31 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 453080f521..c8455e0241 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -349,7 +349,7 @@  nfp_flower_init_vnic_common(struct nfp_net_hw *hw,
 	pf_dev = hw->pf_dev;
 	pci_dev = hw->pf_dev->pci_dev;
 
-	PMD_INIT_LOG(DEBUG, "%s vNIC ctrl bar: %p", vnic_type, hw->ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "%s vNIC ctrl bar: %p", vnic_type, hw->super.ctrl_bar);
 
 	err = nfp_net_common_init(pci_dev, hw);
 	if (err != 0)
@@ -873,7 +873,7 @@  nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev,
 
 	/* Fill in the PF vNIC and populate app struct */
 	app_fw_flower->pf_hw = pf_hw;
-	pf_hw->ctrl_bar = pf_dev->ctrl_bar;
+	pf_hw->super.ctrl_bar = pf_dev->ctrl_bar;
 	pf_hw->pf_dev = pf_dev;
 	pf_hw->cpp = pf_dev->cpp;
 	pf_hw->dev_info = dev_info;
@@ -891,9 +891,9 @@  nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev,
 	ctrl_hw = app_fw_flower->ctrl_hw;
 
 	/* Map the ctrl vNIC ctrl bar */
-	ctrl_hw->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, "_pf0_net_ctrl_bar",
+	ctrl_hw->super.ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, "_pf0_net_ctrl_bar",
 			NFP_NET_CFG_BAR_SZ, &ctrl_hw->ctrl_area);
-	if (ctrl_hw->ctrl_bar == NULL) {
+	if (ctrl_hw->super.ctrl_bar == NULL) {
 		PMD_INIT_LOG(ERR, "Cloud not map the ctrl vNIC ctrl bar");
 		ret = -ENODEV;
 		goto pf_cpp_area_cleanup;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 8ac2acea7b..b7c60b642f 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -506,16 +506,16 @@  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");
+	hw->super.ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->super.ctrl_bar == NULL) {
+		PMD_DRV_LOG(ERR, "hw->super.ctrl_bar is NULL. BAR0 not configured");
 		return -ENODEV;
 	}
 
 	if (port == 0) {
 		uint32_t min_size;
 
-		hw->ctrl_bar = pf_dev->ctrl_bar;
+		hw->super.ctrl_bar = pf_dev->ctrl_bar;
 		min_size = NFP_MAC_STATS_SIZE * hw->pf_dev->nfp_eth_table->max_index;
 		hw->mac_stats_bar = nfp_rtsym_map(hw->pf_dev->sym_tbl, "_mac_stats",
 				min_size, &hw->mac_stats_area);
@@ -530,12 +530,12 @@  nfp_net_init(struct rte_eth_dev *eth_dev)
 			return -ENODEV;
 
 		/* Use port offset in pf ctrl_bar for this ports control bar */
-		hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ);
+		hw->super.ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ);
 		hw->mac_stats = app_fw_nic->ports[0]->mac_stats_bar +
 				(hw->nfp_idx * NFP_MAC_STATS_SIZE);
 	}
 
-	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->super.ctrl_bar);
 	PMD_INIT_LOG(DEBUG, "MAC stats: %p", hw->mac_stats);
 
 	err = nfp_net_common_init(pci_dev, hw);
@@ -573,7 +573,7 @@  nfp_net_init(struct rte_eth_dev *eth_dev)
 	eth_dev->data->dev_private = hw;
 
 	PMD_INIT_LOG(DEBUG, "ctrl_bar: %p, tx_bar: %p, rx_bar: %p",
-			hw->ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
 
 	nfp_net_cfg_queue_setup(hw);
 	hw->mtu = RTE_ETHER_MTU;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 293d1ed53c..641fed6fcf 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -270,13 +270,13 @@  nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	hw->dev_info = dev_info;
 
-	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");
+	hw->super.ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->super.ctrl_bar == NULL) {
+		PMD_DRV_LOG(ERR, "hw->super.ctrl_bar is NULL. BAR0 not configured");
 		return -ENODEV;
 	}
 
-	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->super.ctrl_bar);
 
 	err = nfp_net_common_init(pci_dev, hw);
 	if (err != 0)
@@ -308,7 +308,7 @@  nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	hw->rx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + rx_bar_off;
 
 	PMD_INIT_LOG(DEBUG, "ctrl_bar: %p, tx_bar: %p, rx_bar: %p",
-			hw->ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
 
 	nfp_net_cfg_queue_setup(hw);
 	hw->mtu = RTE_ETHER_MTU;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index cb64fa13c5..29f836c31e 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -536,12 +536,12 @@  nfp_net_write_mac(struct nfp_net_hw *hw,
 	uint16_t mac1;
 
 	mac0 = *(uint32_t *)mac;
-	nn_writel(rte_cpu_to_be_32(mac0), hw->ctrl_bar + NFP_NET_CFG_MACADDR);
+	nn_writel(rte_cpu_to_be_32(mac0), hw->super.ctrl_bar + NFP_NET_CFG_MACADDR);
 
 	mac += 4;
 	mac1 = *(uint16_t *)mac;
 	nn_writew(rte_cpu_to_be_16(mac1),
-			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+			hw->super.ctrl_bar + NFP_NET_CFG_MACADDR + 6);
 }
 
 int
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 4bfb3174b0..dd62ec6d83 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -113,6 +113,7 @@  struct nfp_app_fw_nic {
 };
 
 struct nfp_hw {
+	uint8_t *ctrl_bar;
 	uint8_t *qcp_cfg;
 	uint32_t cap;
 	uint32_t cap_ext;
@@ -141,7 +142,6 @@  struct nfp_net_hw {
 	/** Current values for control */
 	uint32_t ctrl;
 
-	uint8_t *ctrl_bar;
 	uint8_t *tx_bar;
 	uint8_t *rx_bar;
 
@@ -251,7 +251,7 @@  static inline uint8_t
 nn_cfg_readb(struct nfp_net_hw *hw,
 		uint32_t off)
 {
-	return nn_readb(hw->ctrl_bar + off);
+	return nn_readb(hw->super.ctrl_bar + off);
 }
 
 static inline void
@@ -259,14 +259,14 @@  nn_cfg_writeb(struct nfp_net_hw *hw,
 		uint32_t off,
 		uint8_t val)
 {
-	nn_writeb(val, hw->ctrl_bar + off);
+	nn_writeb(val, hw->super.ctrl_bar + off);
 }
 
 static inline uint16_t
 nn_cfg_readw(struct nfp_net_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
+	return rte_le_to_cpu_16(nn_readw(hw->super.ctrl_bar + off));
 }
 
 static inline void
@@ -274,14 +274,14 @@  nn_cfg_writew(struct nfp_net_hw *hw,
 		uint32_t off,
 		uint16_t val)
 {
-	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
+	nn_writew(rte_cpu_to_le_16(val), hw->super.ctrl_bar + off);
 }
 
 static inline uint32_t
 nn_cfg_readl(struct nfp_net_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
+	return rte_le_to_cpu_32(nn_readl(hw->super.ctrl_bar + off));
 }
 
 static inline void
@@ -289,14 +289,14 @@  nn_cfg_writel(struct nfp_net_hw *hw,
 		uint32_t off,
 		uint32_t val)
 {
-	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
+	nn_writel(rte_cpu_to_le_32(val), hw->super.ctrl_bar + off);
 }
 
 static inline uint64_t
 nn_cfg_readq(struct nfp_net_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
+	return rte_le_to_cpu_64(nn_readq(hw->super.ctrl_bar + off));
 }
 
 static inline void
@@ -304,7 +304,7 @@  nn_cfg_writeq(struct nfp_net_hw *hw,
 		uint32_t off,
 		uint64_t val)
 {
-	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
+	nn_writeq(rte_cpu_to_le_64(val), hw->super.ctrl_bar + off);
 }
 
 /**
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index b0a427c98e..d469896a64 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -36,8 +36,8 @@  nfp_net_tlv_caps_parse(struct rte_eth_dev *dev)
 	caps = &hw->tlv_caps;
 	nfp_net_tlv_caps_reset(caps);
 
-	data = hw->ctrl_bar + NFP_NET_CFG_TLV_BASE;
-	end = hw->ctrl_bar + NFP_NET_CFG_BAR_SZ;
+	data = hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
+	end = hw->super.ctrl_bar + NFP_NET_CFG_BAR_SZ;
 
 	hdr = rte_read32(data);
 	if (hdr == 0) {
@@ -46,7 +46,7 @@  nfp_net_tlv_caps_parse(struct rte_eth_dev *dev)
 	}
 
 	for (; ; data += length) {
-		offset = data - hw->ctrl_bar;
+		offset = data - hw->super.ctrl_bar;
 
 		if (data + NFP_NET_CFG_TLV_VALUE > end) {
 			PMD_DRV_LOG(ERR, "Reached end of BAR without END TLV");
@@ -87,7 +87,7 @@  nfp_net_tlv_caps_parse(struct rte_eth_dev *dev)
 			caps->mbox_len = length;
 
 			if (length != 0)
-				caps->mbox_off = data - hw->ctrl_bar;
+				caps->mbox_off = data - hw->super.ctrl_bar;
 			else
 				caps->mbox_off = 0;
 			break;