[v3,04/11] net/nfp: standard the local variable coding style

Message ID 20231013060653.1006410-5-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series Unify the PMD coding style |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Oct. 13, 2023, 6:06 a.m. UTC
  There should only declare one local variable in each line, and the local
variable should obey the unify sequence.

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 |  6 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c  |  4 +-
 drivers/net/nfp/nfp_common.c        | 97 ++++++++++++++++-------------
 drivers/net/nfp/nfp_common.h        |  3 +-
 drivers/net/nfp/nfp_cpp_bridge.c    | 39 ++++++++----
 drivers/net/nfp/nfp_ethdev.c        | 47 +++++++-------
 drivers/net/nfp/nfp_ethdev_vf.c     | 23 +++----
 drivers/net/nfp/nfp_flow.c          | 28 ++++-----
 drivers/net/nfp/nfp_rxtx.c          | 38 +++++------
 9 files changed, 154 insertions(+), 131 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 7dd1423aaf..7a4e671178 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -24,9 +24,9 @@ 
 static void
 nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 {
+	uint16_t i;
 	struct nfp_net_hw *hw;
 	uint64_t enabled_queues = 0;
-	uint16_t i;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
@@ -50,9 +50,9 @@  nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 static void
 nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 {
-	struct nfp_net_hw *hw;
+	uint32_t update;
 	uint32_t new_ctrl;
-	uint32_t update = 0;
+	struct nfp_net_hw *hw;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 5a84629ed7..699f65ebef 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -228,13 +228,13 @@  nfp_net_nfd3_xmit_pkts_common(void *tx_queue,
 		bool repr_flag)
 {
 	uint16_t i;
+	uint8_t offset;
 	uint32_t pkt_size;
 	uint16_t dma_size;
-	uint8_t offset;
 	uint64_t dma_addr;
 	uint16_t free_descs;
-	uint16_t issued_descs;
 	struct rte_mbuf *pkt;
+	uint16_t issued_descs;
 	struct nfp_net_hw *hw;
 	struct rte_mbuf **lmbuf;
 	struct nfp_net_txq *txq;
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index cb2c2afbd7..18291a1cde 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -375,10 +375,10 @@  nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 int
 nfp_net_configure(struct rte_eth_dev *dev)
 {
+	struct nfp_net_hw *hw;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
 	struct rte_eth_txmode *txmode;
-	struct nfp_net_hw *hw;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -464,9 +464,9 @@  nfp_net_enbable_rxvlan_cap(struct nfp_net_hw *hw,
 void
 nfp_net_enable_queues(struct rte_eth_dev *dev)
 {
+	uint16_t i;
 	struct nfp_net_hw *hw;
 	uint64_t enabled_queues = 0;
-	uint16_t i;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -488,8 +488,9 @@  nfp_net_enable_queues(struct rte_eth_dev *dev)
 void
 nfp_net_disable_queues(struct rte_eth_dev *dev)
 {
+	uint32_t update;
+	uint32_t new_ctrl;
 	struct nfp_net_hw *hw;
-	uint32_t new_ctrl, update = 0;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -528,9 +529,10 @@  void
 nfp_net_write_mac(struct nfp_net_hw *hw,
 		uint8_t *mac)
 {
-	uint32_t mac0 = *(uint32_t *)mac;
+	uint32_t mac0;
 	uint16_t mac1;
 
+	mac0 = *(uint32_t *)mac;
 	nn_writel(rte_cpu_to_be_32(mac0), hw->ctrl_bar + NFP_NET_CFG_MACADDR);
 
 	mac += 4;
@@ -543,8 +545,9 @@  int
 nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 		struct rte_ether_addr *mac_addr)
 {
+	uint32_t ctrl;
+	uint32_t update;
 	struct nfp_net_hw *hw;
-	uint32_t update, ctrl;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
@@ -574,8 +577,8 @@  int
 nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 		struct rte_intr_handle *intr_handle)
 {
-	struct nfp_net_hw *hw;
 	uint16_t i;
+	struct nfp_net_hw *hw;
 
 	if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
 				dev->data->nb_rx_queues) != 0) {
@@ -615,11 +618,11 @@  nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 uint32_t
 nfp_check_offloads(struct rte_eth_dev *dev)
 {
+	uint32_t ctrl = 0;
 	struct nfp_net_hw *hw;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
 	struct rte_eth_txmode *txmode;
-	uint32_t ctrl = 0;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -682,9 +685,10 @@  nfp_check_offloads(struct rte_eth_dev *dev)
 int
 nfp_net_promisc_enable(struct rte_eth_dev *dev)
 {
-	uint32_t new_ctrl, update = 0;
-	struct nfp_net_hw *hw;
 	int ret;
+	uint32_t new_ctrl;
+	uint32_t update = 0;
+	struct nfp_net_hw *hw;
 	struct nfp_flower_representor *repr;
 
 	PMD_DRV_LOG(DEBUG, "Promiscuous mode enable");
@@ -725,9 +729,10 @@  nfp_net_promisc_enable(struct rte_eth_dev *dev)
 int
 nfp_net_promisc_disable(struct rte_eth_dev *dev)
 {
-	uint32_t new_ctrl, update = 0;
-	struct nfp_net_hw *hw;
 	int ret;
+	uint32_t new_ctrl;
+	uint32_t update = 0;
+	struct nfp_net_hw *hw;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -764,8 +769,8 @@  nfp_net_link_update(struct rte_eth_dev *dev,
 {
 	int ret;
 	uint32_t i;
-	uint32_t nn_link_status;
 	struct nfp_net_hw *hw;
+	uint32_t nn_link_status;
 	struct rte_eth_link link;
 	struct nfp_eth_table *nfp_eth_table;
 
@@ -988,12 +993,13 @@  nfp_net_stats_reset(struct rte_eth_dev *dev)
 uint32_t
 nfp_net_xstats_size(const struct rte_eth_dev *dev)
 {
-	/* If the device is a VF, then there will be no MAC stats */
-	struct nfp_net_hw *hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t count;
+	struct nfp_net_hw *hw;
 	const uint32_t size = RTE_DIM(nfp_net_xstats);
 
+	/* If the device is a VF, then there will be no MAC stats */
+	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	if (hw->mac_stats == NULL) {
-		uint32_t count;
 		for (count = 0; count < size; count++) {
 			if (nfp_net_xstats[count].group == NFP_XSTAT_GROUP_MAC)
 				break;
@@ -1396,9 +1402,9 @@  int
 nfp_rx_queue_intr_enable(struct rte_eth_dev *dev,
 		uint16_t queue_id)
 {
-	struct rte_pci_device *pci_dev;
-	struct nfp_net_hw *hw;
 	uint16_t base = 0;
+	struct nfp_net_hw *hw;
+	struct rte_pci_device *pci_dev;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	pci_dev = RTE_ETH_DEV_TO_PCI(dev);
@@ -1417,9 +1423,9 @@  int
 nfp_rx_queue_intr_disable(struct rte_eth_dev *dev,
 		uint16_t queue_id)
 {
-	struct rte_pci_device *pci_dev;
-	struct nfp_net_hw *hw;
 	uint16_t base = 0;
+	struct nfp_net_hw *hw;
+	struct rte_pci_device *pci_dev;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	pci_dev = RTE_ETH_DEV_TO_PCI(dev);
@@ -1436,8 +1442,8 @@  nfp_rx_queue_intr_disable(struct rte_eth_dev *dev,
 static void
 nfp_net_dev_link_status_print(struct rte_eth_dev *dev)
 {
-	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_eth_link link;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 
 	rte_eth_linkstatus_get(dev, &link);
 	if (link.link_status != 0)
@@ -1573,16 +1579,16 @@  int
 nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 		int mask)
 {
-	uint32_t new_ctrl, update;
+	int ret;
+	uint32_t update;
+	uint32_t new_ctrl;
 	struct nfp_net_hw *hw;
+	uint32_t rxvlan_ctrl = 0;
 	struct rte_eth_conf *dev_conf;
-	uint32_t rxvlan_ctrl;
-	int ret;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	dev_conf = &dev->data->dev_conf;
 	new_ctrl = hw->ctrl;
-	rxvlan_ctrl = 0;
 
 	nfp_net_enbable_rxvlan_cap(hw, &rxvlan_ctrl);
 
@@ -1619,12 +1625,15 @@  nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 		struct rte_eth_rss_reta_entry64 *reta_conf,
 		uint16_t reta_size)
 {
+	uint16_t i;
+	uint16_t j;
+	uint16_t idx;
 	uint8_t mask;
 	uint32_t reta;
-	uint16_t i, j;
-	uint16_t idx, shift;
-	struct nfp_net_hw *hw =
-		NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint16_t shift;
+	struct nfp_net_hw *hw;
+
+	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
 		PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
@@ -1670,11 +1679,11 @@  nfp_net_reta_update(struct rte_eth_dev *dev,
 		struct rte_eth_rss_reta_entry64 *reta_conf,
 		uint16_t reta_size)
 {
-	struct nfp_net_hw *hw =
-		NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t update;
 	int ret;
+	uint32_t update;
+	struct nfp_net_hw *hw;
 
+	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
@@ -1696,10 +1705,12 @@  nfp_net_reta_query(struct rte_eth_dev *dev,
 		struct rte_eth_rss_reta_entry64 *reta_conf,
 		uint16_t reta_size)
 {
-	uint16_t i, j;
+	uint16_t i;
+	uint16_t j;
+	uint16_t idx;
 	uint8_t mask;
-	uint16_t idx, shift;
 	uint32_t reta;
+	uint16_t shift;
 	struct nfp_net_hw *hw;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1742,11 +1753,11 @@  static int
 nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 		struct rte_eth_rss_conf *rss_conf)
 {
-	struct nfp_net_hw *hw;
+	uint8_t i;
+	uint8_t key;
 	uint64_t rss_hf;
+	struct nfp_net_hw *hw;
 	uint32_t cfg_rss_ctrl = 0;
-	uint8_t key;
-	uint8_t i;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -1834,10 +1845,10 @@  int
 nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 		struct rte_eth_rss_conf *rss_conf)
 {
+	uint8_t i;
+	uint8_t key;
 	uint64_t rss_hf;
 	uint32_t cfg_rss_ctrl;
-	uint8_t key;
-	uint8_t i;
 	struct nfp_net_hw *hw;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -1890,13 +1901,14 @@  nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 int
 nfp_net_rss_config_default(struct rte_eth_dev *dev)
 {
+	int ret;
+	uint8_t i;
+	uint8_t j;
+	uint16_t queue = 0;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rss_conf rss_conf;
-	struct rte_eth_rss_reta_entry64 nfp_reta_conf[2];
 	uint16_t rx_queues = dev->data->nb_rx_queues;
-	uint16_t queue;
-	uint8_t i, j;
-	int ret;
+	struct rte_eth_rss_reta_entry64 nfp_reta_conf[2];
 
 	PMD_DRV_LOG(INFO, "setting default RSS conf for %u queues",
 			rx_queues);
@@ -1904,7 +1916,6 @@  nfp_net_rss_config_default(struct rte_eth_dev *dev)
 	nfp_reta_conf[0].mask = ~0x0;
 	nfp_reta_conf[1].mask = ~0x0;
 
-	queue = 0;
 	for (i = 0; i < 0x40; i += 8) {
 		for (j = i; j < (i + 8); j++) {
 			nfp_reta_conf[0].reta[j] = queue;
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 71153ea25b..9cb889c4a6 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -222,8 +222,9 @@  nn_writew(uint16_t val,
 static inline uint64_t
 nn_readq(volatile void *addr)
 {
+	uint32_t low;
+	uint32_t high;
 	const volatile uint32_t *p = addr;
-	uint32_t low, high;
 
 	high = nn_readl((volatile const void *)(p + 1));
 	low = nn_readl((volatile const void *)p);
diff --git a/drivers/net/nfp/nfp_cpp_bridge.c b/drivers/net/nfp/nfp_cpp_bridge.c
index 85a8bf9235..727ec7a7b2 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.c
+++ b/drivers/net/nfp/nfp_cpp_bridge.c
@@ -119,12 +119,16 @@  static int
 nfp_cpp_bridge_serve_write(int sockfd,
 		struct nfp_cpp *cpp)
 {
-	struct nfp_cpp_area *area;
-	off_t offset, nfp_offset;
-	uint32_t cpp_id, pos, len;
+	int err;
+	off_t offset;
+	uint32_t pos;
+	uint32_t len;
+	size_t count;
+	size_t curlen;
+	uint32_t cpp_id;
+	off_t nfp_offset;
 	uint32_t tmpbuf[16];
-	size_t count, curlen;
-	int err = 0;
+	struct nfp_cpp_area *area;
 
 	PMD_CPP_LOG(DEBUG, "%s: offset size %zu, count_size: %zu\n", __func__,
 			sizeof(off_t), sizeof(size_t));
@@ -220,12 +224,16 @@  static int
 nfp_cpp_bridge_serve_read(int sockfd,
 		struct nfp_cpp *cpp)
 {
-	struct nfp_cpp_area *area;
-	off_t offset, nfp_offset;
-	uint32_t cpp_id, pos, len;
+	int err;
+	off_t offset;
+	uint32_t pos;
+	uint32_t len;
+	size_t count;
+	size_t curlen;
+	uint32_t cpp_id;
+	off_t nfp_offset;
 	uint32_t tmpbuf[16];
-	size_t count, curlen;
-	int err = 0;
+	struct nfp_cpp_area *area;
 
 	PMD_CPP_LOG(DEBUG, "%s: offset size %zu, count_size: %zu\n", __func__,
 			sizeof(off_t), sizeof(size_t));
@@ -319,8 +327,10 @@  static int
 nfp_cpp_bridge_serve_ioctl(int sockfd,
 		struct nfp_cpp *cpp)
 {
-	uint32_t cmd, ident_size, tmp;
 	int err;
+	uint32_t cmd;
+	uint32_t tmp;
+	uint32_t ident_size;
 
 	/* Reading now the IOCTL command */
 	err = recv(sockfd, &cmd, 4, 0);
@@ -375,10 +385,13 @@  nfp_cpp_bridge_serve_ioctl(int sockfd,
 static int
 nfp_cpp_bridge_service_func(void *args)
 {
-	struct sockaddr address;
+	int op;
+	int ret;
+	int sockfd;
+	int datafd;
 	struct nfp_cpp *cpp;
+	struct sockaddr address;
 	struct nfp_pf_dev *pf_dev;
-	int sockfd, datafd, op, ret;
 	struct timeval timeout = {1, 0};
 
 	unlink("/tmp/nfp_cpp");
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 140d20dcf7..7d149decfb 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -25,8 +25,8 @@  static int
 nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic,
 		uint16_t port)
 {
+	struct nfp_net_hw *hw;
 	struct nfp_eth_table *nfp_eth_table;
-	struct nfp_net_hw *hw = NULL;
 
 	/* Grab a pointer to the correct physical port */
 	hw = app_fw_nic->ports[port];
@@ -42,18 +42,19 @@  nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic,
 static int
 nfp_net_start(struct rte_eth_dev *dev)
 {
-	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
-	uint32_t new_ctrl, update = 0;
+	int ret;
+	uint32_t new_ctrl;
+	uint32_t update = 0;
 	uint32_t cap_extend;
-	uint32_t ctrl_extend = 0;
+	uint32_t intr_vector;
 	struct nfp_net_hw *hw;
+	uint32_t ctrl_extend = 0;
 	struct nfp_pf_dev *pf_dev;
-	struct nfp_app_fw_nic *app_fw_nic;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
-	uint32_t intr_vector;
-	int ret;
+	struct nfp_app_fw_nic *app_fw_nic;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -251,11 +252,11 @@  nfp_net_set_link_down(struct rte_eth_dev *dev)
 static int
 nfp_net_close(struct rte_eth_dev *dev)
 {
+	uint8_t i;
 	struct nfp_net_hw *hw;
-	struct rte_pci_device *pci_dev;
 	struct nfp_pf_dev *pf_dev;
+	struct rte_pci_device *pci_dev;
 	struct nfp_app_fw_nic *app_fw_nic;
-	uint8_t i;
 
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
@@ -480,15 +481,15 @@  nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw,
 static int
 nfp_net_init(struct rte_eth_dev *eth_dev)
 {
-	struct rte_pci_device *pci_dev;
+	int err;
+	uint16_t port;
+	uint64_t rx_base;
+	uint64_t tx_base;
+	struct nfp_net_hw *hw;
 	struct nfp_pf_dev *pf_dev;
+	struct rte_pci_device *pci_dev;
 	struct nfp_app_fw_nic *app_fw_nic;
-	struct nfp_net_hw *hw;
 	struct rte_ether_addr *tmp_ether_addr;
-	uint64_t rx_base;
-	uint64_t tx_base;
-	uint16_t port = 0;
-	int err;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -650,14 +651,14 @@  nfp_fw_upload(struct rte_pci_device *dev,
 		struct nfp_nsp *nsp,
 		char *card)
 {
-	struct nfp_cpp *cpp = nfp_nsp_cpp(nsp);
 	void *fw_buf;
-	char fw_name[125];
-	char serial[40];
 	size_t fsize;
+	char serial[40];
+	char fw_name[125];
 	uint16_t interface;
 	uint32_t cpp_serial_len;
 	const uint8_t *cpp_serial;
+	struct nfp_cpp *cpp = nfp_nsp_cpp(nsp);
 
 	cpp_serial_len = nfp_cpp_serial(cpp, &cpp_serial);
 	if (cpp_serial_len != NFP_SERIAL_LEN)
@@ -713,10 +714,10 @@  nfp_fw_setup(struct rte_pci_device *dev,
 		struct nfp_eth_table *nfp_eth_table,
 		struct nfp_hwinfo *hwinfo)
 {
+	int err;
+	char card_desc[100];
 	struct nfp_nsp *nsp;
 	const char *nfp_fw_model;
-	char card_desc[100];
-	int err = 0;
 
 	nfp_fw_model = nfp_hwinfo_lookup(hwinfo, "nffw.partno");
 	if (nfp_fw_model == NULL)
@@ -897,9 +898,9 @@  nfp_pf_init(struct rte_pci_device *pci_dev)
 	uint64_t addr;
 	uint32_t cpp_id;
 	struct nfp_cpp *cpp;
-	enum nfp_app_fw_id app_fw_id;
 	struct nfp_pf_dev *pf_dev;
 	struct nfp_hwinfo *hwinfo;
+	enum nfp_app_fw_id app_fw_id;
 	char name[RTE_ETH_NAME_MAX_LEN];
 	struct nfp_rtsym_table *sym_tbl;
 	struct nfp_eth_table *nfp_eth_table;
@@ -1220,8 +1221,8 @@  static const struct rte_pci_id pci_id_nfp_pf_net_map[] = {
 static int
 nfp_pci_uninit(struct rte_eth_dev *eth_dev)
 {
-	struct rte_pci_device *pci_dev;
 	uint16_t port_id;
+	struct rte_pci_device *pci_dev;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 892300a909..aaef6ea91a 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -29,14 +29,15 @@  nfp_netvf_read_mac(struct nfp_net_hw *hw)
 static int
 nfp_netvf_start(struct rte_eth_dev *dev)
 {
-	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
-	uint32_t new_ctrl, update = 0;
+	int ret;
+	uint32_t new_ctrl;
+	uint32_t update = 0;
+	uint32_t intr_vector;
 	struct nfp_net_hw *hw;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
-	uint32_t intr_vector;
-	int ret;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -254,15 +255,15 @@  nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw,
 static int
 nfp_netvf_init(struct rte_eth_dev *eth_dev)
 {
-	struct rte_pci_device *pci_dev;
-	struct nfp_net_hw *hw;
-	struct rte_ether_addr *tmp_ether_addr;
-
-	uint64_t tx_bar_off = 0, rx_bar_off = 0;
+	int err;
 	uint32_t start_q;
 	uint16_t port = 0;
-	int err;
+	struct nfp_net_hw *hw;
+	uint64_t tx_bar_off = 0;
+	uint64_t rx_bar_off = 0;
+	struct rte_pci_device *pci_dev;
 	const struct nfp_dev_info *dev_info;
+	struct rte_ether_addr *tmp_ether_addr;
 
 	PMD_INIT_FUNC_TRACE();
 
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index 4c9904e36c..84b48daf85 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -761,9 +761,9 @@  nfp_flow_compile_metadata(struct nfp_flow_priv *priv,
 		uint32_t stats_ctx,
 		uint64_t cookie)
 {
-	struct nfp_fl_rule_metadata *nfp_flow_meta;
-	char *mbuf_off_exact;
 	char *mbuf_off_mask;
+	char *mbuf_off_exact;
+	struct nfp_fl_rule_metadata *nfp_flow_meta;
 
 	/*
 	 * Convert to long words as firmware expects
@@ -974,9 +974,9 @@  nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
 	int ret = 0;
 	bool meter_flag = false;
 	bool tc_hl_flag = false;
-	bool mac_set_flag = false;
 	bool ip_set_flag = false;
 	bool tp_set_flag = false;
+	bool mac_set_flag = false;
 	bool ttl_tos_flag = false;
 	const struct rte_flow_action *action;
 
@@ -3201,11 +3201,11 @@  nfp_flow_action_geneve_encap_v4(struct nfp_app_fw_flower *app_fw_flower,
 {
 	uint64_t tun_id;
 	const struct rte_ether_hdr *eth;
+	struct nfp_fl_act_pre_tun *pre_tun;
+	struct nfp_fl_act_set_tun *set_tun;
 	const struct rte_flow_item_udp *udp;
 	const struct rte_flow_item_ipv4 *ipv4;
 	const struct rte_flow_item_geneve *geneve;
-	struct nfp_fl_act_pre_tun *pre_tun;
-	struct nfp_fl_act_set_tun *set_tun;
 	size_t act_pre_size = sizeof(struct nfp_fl_act_pre_tun);
 	size_t act_set_size = sizeof(struct nfp_fl_act_set_tun);
 
@@ -3241,11 +3241,11 @@  nfp_flow_action_geneve_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 	uint8_t tos;
 	uint64_t tun_id;
 	const struct rte_ether_hdr *eth;
+	struct nfp_fl_act_pre_tun *pre_tun;
+	struct nfp_fl_act_set_tun *set_tun;
 	const struct rte_flow_item_udp *udp;
 	const struct rte_flow_item_ipv6 *ipv6;
 	const struct rte_flow_item_geneve *geneve;
-	struct nfp_fl_act_pre_tun *pre_tun;
-	struct nfp_fl_act_set_tun *set_tun;
 	size_t act_pre_size = sizeof(struct nfp_fl_act_pre_tun);
 	size_t act_set_size = sizeof(struct nfp_fl_act_set_tun);
 
@@ -3281,10 +3281,10 @@  nfp_flow_action_nvgre_encap_v4(struct nfp_app_fw_flower *app_fw_flower,
 {
 	uint64_t tun_id;
 	const struct rte_ether_hdr *eth;
-	const struct rte_flow_item_ipv4 *ipv4;
-	const struct rte_flow_item_gre *gre;
 	struct nfp_fl_act_pre_tun *pre_tun;
 	struct nfp_fl_act_set_tun *set_tun;
+	const struct rte_flow_item_gre *gre;
+	const struct rte_flow_item_ipv4 *ipv4;
 	size_t act_pre_size = sizeof(struct nfp_fl_act_pre_tun);
 	size_t act_set_size = sizeof(struct nfp_fl_act_set_tun);
 
@@ -3319,10 +3319,10 @@  nfp_flow_action_nvgre_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 	uint8_t tos;
 	uint64_t tun_id;
 	const struct rte_ether_hdr *eth;
-	const struct rte_flow_item_ipv6 *ipv6;
-	const struct rte_flow_item_gre *gre;
 	struct nfp_fl_act_pre_tun *pre_tun;
 	struct nfp_fl_act_set_tun *set_tun;
+	const struct rte_flow_item_gre *gre;
+	const struct rte_flow_item_ipv6 *ipv6;
 	size_t act_pre_size = sizeof(struct nfp_fl_act_pre_tun);
 	size_t act_set_size = sizeof(struct nfp_fl_act_set_tun);
 
@@ -3467,12 +3467,12 @@  nfp_flow_compile_action(struct nfp_flower_representor *representor,
 	uint32_t count;
 	char *position;
 	char *action_data;
-	bool ttl_tos_flag = false;
-	bool tc_hl_flag = false;
 	bool drop_flag = false;
+	bool tc_hl_flag = false;
 	bool ip_set_flag = false;
 	bool tp_set_flag = false;
 	bool mac_set_flag = false;
+	bool ttl_tos_flag = false;
 	uint32_t total_actions = 0;
 	const struct rte_flow_action *action;
 	struct nfp_flower_meta_tci *meta_tci;
@@ -4283,10 +4283,10 @@  nfp_flow_priv_init(struct nfp_pf_dev *pf_dev)
 	size_t stats_size;
 	uint64_t ctx_count;
 	uint64_t ctx_split;
+	struct nfp_flow_priv *priv;
 	char mask_name[RTE_HASH_NAMESIZE];
 	char flow_name[RTE_HASH_NAMESIZE];
 	char pretun_name[RTE_HASH_NAMESIZE];
-	struct nfp_flow_priv *priv;
 	struct nfp_app_fw_flower *app_fw_flower;
 	const char *pci_name = strchr(pf_dev->pci_dev->name, ':') + 1;
 
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 8cbb9b74a2..db6122eac3 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -188,9 +188,9 @@  nfp_net_rx_cksum(struct nfp_net_rxq *rxq,
 static int
 nfp_net_rx_fill_freelist(struct nfp_net_rxq *rxq)
 {
-	struct nfp_net_dp_buf *rxe = rxq->rxbufs;
-	uint64_t dma_addr;
 	uint16_t i;
+	uint64_t dma_addr;
+	struct nfp_net_dp_buf *rxe = rxq->rxbufs;
 
 	PMD_RX_LOG(DEBUG, "Fill Rx Freelist for %u descriptors",
 			rxq->rx_count);
@@ -241,17 +241,15 @@  nfp_net_rx_freelist_setup(struct rte_eth_dev *dev)
 uint32_t
 nfp_net_rx_queue_count(void *rx_queue)
 {
+	uint32_t idx;
+	uint32_t count = 0;
 	struct nfp_net_rxq *rxq;
 	struct nfp_net_rx_desc *rxds;
-	uint32_t idx;
-	uint32_t count;
 
 	rxq = rx_queue;
 
 	idx = rxq->rd_p;
 
-	count = 0;
-
 	/*
 	 * Other PMDs are just checking the DD bit in intervals of 4
 	 * descriptors and counting all four if the first has the DD
@@ -282,9 +280,9 @@  nfp_net_parse_chained_meta(uint8_t *meta_base,
 		rte_be32_t meta_header,
 		struct nfp_meta_parsed *meta)
 {
-	uint8_t *meta_offset;
 	uint32_t meta_info;
 	uint32_t vlan_info;
+	uint8_t *meta_offset;
 
 	meta_info = rte_be_to_cpu_32(meta_header);
 	meta_offset = meta_base + 4;
@@ -683,15 +681,15 @@  nfp_net_recv_pkts(void *rx_queue,
 		struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts)
 {
-	struct nfp_net_rxq *rxq;
-	struct nfp_net_rx_desc *rxds;
-	struct nfp_net_dp_buf *rxb;
-	struct nfp_net_hw *hw;
+	uint64_t dma_addr;
+	uint16_t avail = 0;
 	struct rte_mbuf *mb;
+	uint16_t nb_hold = 0;
+	struct nfp_net_hw *hw;
 	struct rte_mbuf *new_mb;
-	uint16_t nb_hold;
-	uint64_t dma_addr;
-	uint16_t avail;
+	struct nfp_net_rxq *rxq;
+	struct nfp_net_dp_buf *rxb;
+	struct nfp_net_rx_desc *rxds;
 	uint16_t avail_multiplexed = 0;
 
 	rxq = rx_queue;
@@ -706,8 +704,6 @@  nfp_net_recv_pkts(void *rx_queue,
 
 	hw = rxq->hw;
 
-	avail = 0;
-	nb_hold = 0;
 	while (avail + avail_multiplexed < nb_pkts) {
 		rxb = &rxq->rxbufs[rxq->rd_p];
 		if (unlikely(rxb == NULL)) {
@@ -883,12 +879,12 @@  nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
 		const struct rte_eth_rxconf *rx_conf,
 		struct rte_mempool *mp)
 {
+	uint32_t rx_desc_sz;
 	uint16_t min_rx_desc;
 	uint16_t max_rx_desc;
-	const struct rte_memzone *tz;
-	struct nfp_net_rxq *rxq;
 	struct nfp_net_hw *hw;
-	uint32_t rx_desc_sz;
+	struct nfp_net_rxq *rxq;
+	const struct rte_memzone *tz;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -995,8 +991,8 @@  nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
 uint32_t
 nfp_net_tx_free_bufs(struct nfp_net_txq *txq)
 {
-	uint32_t qcp_rd_p;
 	uint32_t todo;
+	uint32_t qcp_rd_p;
 
 	PMD_TX_LOG(DEBUG, "queue %hu. Check for descriptor with a complete"
 			" status", txq->qidx);
@@ -1072,8 +1068,8 @@  nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
 		struct rte_mbuf *pkt,
 		uint8_t layer)
 {
-	uint16_t vlan_tci;
 	uint16_t tpid;
+	uint16_t vlan_tci;
 
 	tpid = RTE_ETHER_TYPE_VLAN;
 	vlan_tci = pkt->vlan_tci;