[05/11] net/nfp: remove the redundancy macro

Message ID 20231028061558.1842855-6-chaoyong.he@corigine.com (mailing list archive)
State Superseded, 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:15 a.m. UTC
  Macro 'NFP_HASH_OFFSET' and 'NFP_HASH_TYPE_OFFSET' are unused, so remove
them.
Macro 'NFP_MAX_PHYPORTS' and 'MAX_FLOWER_PHYPORTS' are redundancy, so
just keep the first one.
Macro 'NFP_NET_CFG_SPARE_ADDR', 'NFP_NET_CFG_RX_OFFSET_ADDR' and
'NFP_NET_CFG_RX_OFFSET' are redundancy, we just keep the final one.
Remove the unneeded macro 'NFP_NET_DEV_PRIVATE_TO_PF', and adjust the
related logic, to make it easier to read.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h | 17 -----------------
 drivers/net/nfp/flower/nfp_flower.h  |  3 +--
 drivers/net/nfp/nfp_ethdev.c         | 12 ++++--------
 drivers/net/nfp/nfp_net_common.c     |  2 +-
 drivers/net/nfp/nfp_net_common.h     |  3 ---
 drivers/net/nfp/nfp_rxtx.h           |  3 ---
 6 files changed, 6 insertions(+), 34 deletions(-)
  

Patch

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index f92ce50fc0..7033c8ea00 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -196,11 +196,6 @@  struct nfp_net_fw_ver {
 #define NFP_NET_CFG_START_TXQ           0x0048
 #define NFP_NET_CFG_START_RXQ           0x004c
 
-/*
- * NFP-3200 workaround (0x0050 - 0x0058)
- * @NFP_NET_CFG_SPARE_ADDR:  DMA address for ME code to use (e.g. YDS-155 fix)
- */
-#define NFP_NET_CFG_SPARE_ADDR          0x0050
 /*
  * NFP6000/NFP4000 - Prepend configuration
  */
@@ -210,18 +205,6 @@  struct nfp_net_fw_ver {
 /* Start anchor of the TLV area */
 #define NFP_NET_CFG_TLV_BASE            0x0058
 
-/**
- * Reuse spare address to contain the offset from the start of
- * the host buffer where the first byte of the received frame
- * will land.  Any metadata will come prior to that offset.  If the
- * value in this field is 0, it means that the metadata will
- * always land starting at the first byte of the host buffer and
- * packet data will immediately follow the metadata.  As always,
- * the RX descriptor indicates the presence or absence of metadata
- * along with the length thereof.
- */
-#define NFP_NET_CFG_RX_OFFSET_ADDR      0x0050
-
 #define NFP_NET_CFG_VXLAN_PORT          0x0060
 #define NFP_NET_CFG_VXLAN_SZ            0x0008
 
diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h
index 7d442e3cb2..a989c4a8b8 100644
--- a/drivers/net/nfp/flower/nfp_flower.h
+++ b/drivers/net/nfp/flower/nfp_flower.h
@@ -31,7 +31,6 @@ 
  */
 #define FLOWER_PKT_DATA_OFFSET (NFP_NET_META_HEADER_SIZE + NFP_NET_META_FIELD_SIZE)
 
-#define MAX_FLOWER_PHYPORTS 8
 #define MAX_FLOWER_VFS 64
 
 /* Forward declaration */
@@ -78,7 +77,7 @@  struct nfp_app_fw_flower {
 	uint64_t ctrl_vnic_tx_count;
 
 	/** Array of phyport representors */
-	struct nfp_flower_representor *phy_reprs[MAX_FLOWER_PHYPORTS];
+	struct nfp_flower_representor *phy_reprs[NFP_MAX_PHYPORTS];
 
 	/** Array of VF representors */
 	struct nfp_flower_representor *vf_reprs[MAX_FLOWER_VFS];
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 8e69fa67b2..7c5b780e82 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -56,7 +56,7 @@  nfp_net_start(struct rte_eth_dev *dev)
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
 
 	net_hw = dev->data->dev_private;
-	pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	pf_dev = net_hw->pf_dev;
 	app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
 	hw = &net_hw->super;
 
@@ -261,8 +261,8 @@  nfp_net_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	hw = dev->data->dev_private;
+	pf_dev = hw->pf_dev;
 	pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
 
@@ -482,9 +482,10 @@  nfp_net_init(struct rte_eth_dev *eth_dev)
 	struct nfp_app_fw_nic *app_fw_nic;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	net_hw = eth_dev->data->dev_private;
 
 	/* Use backpointer here to the PF of this eth_dev */
-	pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(eth_dev->data->dev_private);
+	pf_dev = net_hw->pf_dev;
 
 	/* Use backpointer to the CoreNIC app struct */
 	app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
@@ -495,11 +496,6 @@  nfp_net_init(struct rte_eth_dev *eth_dev)
 		return -ENODEV;
 	}
 
-	/*
-	 * Use PF array of physical ports to get pointer to
-	 * this specific port.
-	 */
-	net_hw = app_fw_nic->ports[port];
 	hw = &net_hw->super;
 
 	PMD_INIT_LOG(DEBUG, "Working with physical port number: %hu, "
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 1260b9a3b1..e3c3fa9985 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1172,7 +1172,7 @@  nfp_net_common_init(struct rte_pci_device *pci_dev,
 	if (hw->ver.major < 2)
 		hw->rx_offset = NFP_NET_RX_OFFSET;
 	else
-		hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET_ADDR);
+		hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET);
 
 	hw->super.ctrl = 0;
 	hw->stride_rx = stride;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index a23b5be968..829e9c5333 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -238,9 +238,6 @@  int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size
 int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size);
 bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
 
-#define NFP_NET_DEV_PRIVATE_TO_PF(dev_priv)\
-	(((struct nfp_net_hw *)dev_priv)->pf_dev)
-
 #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
 	((struct nfp_app_fw_nic *)app_fw_priv)
 
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 956cc7a0d2..ff1019b690 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -10,9 +10,6 @@ 
 
 #define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
 
-#define NFP_HASH_OFFSET      ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 4)
-#define NFP_HASH_TYPE_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 8)
-
 #define RTE_MBUF_DMA_ADDR_DEFAULT(mb) \
 	((uint64_t)((mb)->buf_iova + RTE_PKTMBUF_HEADROOM))