DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 00/25] add the NFP vDPA PMD
@ 2023-10-17  5:45 Chaoyong He
  2023-10-17  5:45 ` [PATCH 01/25] drivers: introduce the NFP common library Chaoyong He
                   ` (25 more replies)
  0 siblings, 26 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series aims to add the NFP vDPA PMD, we also grab the common
logic into the `drivers/common/nfp` directory.

Chaoyong He (25):
  drivers: introduce the NFP common library
  net/nfp: make VF PMD using of NFP common module
  net/nfp: rename common module name
  net/nfp: rename ctrl module name
  net/nfp: extract the cap data field
  net/nfp: extract the qcp data field
  net/nfp: extract the ctrl BAR data field
  net/nfp: extract the ctrl data field
  net/nfp: change the parameter of APIs
  net/nfp: change the parameter of reconfig
  net/nfp: extract the MAC address data field
  net/nfp: rename parameter in related logic
  drivers: add the common ctrl module
  drivers: add the nfp common module
  drivers: move queue logic to common module
  drivers: move platform module to common library
  drivers: move device module to common library
  drivers/vdpa: introduce the NFP vDPA library
  drivers: add the basic framework of vDPA PMD
  vdpa/nfp: add the logic of remap PCI memory
  vdpa/nfp: add the hardware init logic
  drivers: add the datapath update logic
  vdpa/nfp: add the notify related logic
  vdpa/nfp: add nfp vDPA device operations
  doc: add the common and vDPA document

 .mailmap                                      |   1 +
 MAINTAINERS                                   |   8 +
 doc/guides/platform/index.rst                 |   1 +
 doc/guides/platform/nfp.rst                   |  30 +
 doc/guides/rel_notes/release_23_11.rst        |   5 +
 doc/guides/vdpadevs/features/nfp.ini          |   8 +
 doc/guides/vdpadevs/index.rst                 |   1 +
 doc/guides/vdpadevs/nfp.rst                   |  54 ++
 drivers/common/nfp/meson.build                |  16 +
 drivers/common/nfp/nfp_common.c               | 182 ++++
 drivers/common/nfp/nfp_common.h               | 234 +++++
 .../nfp/nfp_common_ctrl.h}                    | 209 +---
 drivers/common/nfp/nfp_common_log.c           |   8 +
 drivers/common/nfp/nfp_common_log.h           |  16 +
 drivers/common/nfp/nfp_common_pci.c           | 275 ++++++
 drivers/common/nfp/nfp_common_pci.h           |  45 +
 .../{net/nfp/nfpcore => common/nfp}/nfp_dev.c |   3 +-
 .../{net/nfp/nfpcore => common/nfp}/nfp_dev.h |   3 +
 .../nfp/nfpcore => common/nfp}/nfp_platform.h |   0
 drivers/common/nfp/version.map                |  15 +
 drivers/meson.build                           |   1 +
 drivers/net/nfp/flower/nfp_flower.c           |  56 +-
 drivers/net/nfp/flower/nfp_flower.h           |   2 +-
 .../net/nfp/flower/nfp_flower_representor.c   |  10 +-
 drivers/net/nfp/meson.build                   |  11 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c            |  16 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c            |  20 +-
 drivers/net/nfp/nfp_cpp_bridge.h              |   2 +-
 drivers/net/nfp/nfp_ethdev.c                  |  80 +-
 drivers/net/nfp/nfp_ethdev_vf.c               |  74 +-
 drivers/net/nfp/nfp_flow.h                    |   2 +-
 drivers/net/nfp/nfp_ipsec.c                   |  86 +-
 .../nfp/{nfp_common.c => nfp_net_common.c}    | 455 ++++-----
 .../nfp/{nfp_common.h => nfp_net_common.h}    | 217 +----
 .../net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c}    |  21 +-
 drivers/net/nfp/nfp_net_ctrl.h                | 211 ++++
 drivers/net/nfp/nfp_rxtx.c                    |  20 +-
 drivers/net/nfp/nfpcore/nfp6000_pcie.h        |   2 +-
 drivers/net/nfp/nfpcore/nfp_cppcore.c         |   3 +-
 drivers/net/nfp/nfpcore/nfp_nsp.c             |   2 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c         |   3 +-
 drivers/vdpa/meson.build                      |   1 +
 drivers/vdpa/nfp/meson.build                  |  24 +
 drivers/vdpa/nfp/nfp_vdpa.c                   | 909 ++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c              | 193 ++++
 drivers/vdpa/nfp/nfp_vdpa_core.h              |  51 +
 drivers/vdpa/nfp/nfp_vdpa_log.c               |   9 +
 drivers/vdpa/nfp/nfp_vdpa_log.h               |  21 +
 48 files changed, 2722 insertions(+), 894 deletions(-)
 create mode 100644 doc/guides/platform/nfp.rst
 create mode 100644 doc/guides/vdpadevs/features/nfp.ini
 create mode 100644 doc/guides/vdpadevs/nfp.rst
 create mode 100644 drivers/common/nfp/meson.build
 create mode 100644 drivers/common/nfp/nfp_common.c
 create mode 100644 drivers/common/nfp/nfp_common.h
 rename drivers/{net/nfp/nfp_ctrl.h => common/nfp/nfp_common_ctrl.h} (63%)
 create mode 100644 drivers/common/nfp/nfp_common_log.c
 create mode 100644 drivers/common/nfp/nfp_common_log.h
 create mode 100644 drivers/common/nfp/nfp_common_pci.c
 create mode 100644 drivers/common/nfp/nfp_common_pci.h
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c (98%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h (96%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_platform.h (100%)
 create mode 100644 drivers/common/nfp/version.map
 rename drivers/net/nfp/{nfp_common.c => nfp_net_common.c} (82%)
 rename drivers/net/nfp/{nfp_common.h => nfp_net_common.h} (65%)
 rename drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} (84%)
 create mode 100644 drivers/net/nfp/nfp_net_ctrl.h
 create mode 100644 drivers/vdpa/nfp/meson.build
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.h
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 01/25] drivers: introduce the NFP common library
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

A new NFP vdpa PMD will be added to support vdpa operations by NFP
adapters.

This vdpa PMD share some logic with the net/nfp PMD. So create a new
common library in drivers/common for NFP PMDs.

We import a 'nfp_class_driver' layer and which can support various
device type in addition to the ethernet device.

The shared logic will move into this common library in the following
commits.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 .mailmap                            |   1 +
 drivers/common/nfp/meson.build      |  14 ++
 drivers/common/nfp/nfp_common_log.c |   8 +
 drivers/common/nfp/nfp_common_log.h |  16 ++
 drivers/common/nfp/nfp_common_pci.c | 274 ++++++++++++++++++++++++++++
 drivers/common/nfp/nfp_common_pci.h |  44 +++++
 drivers/common/nfp/version.map      |   7 +
 drivers/meson.build                 |   1 +
 8 files changed, 365 insertions(+)
 create mode 100644 drivers/common/nfp/meson.build
 create mode 100644 drivers/common/nfp/nfp_common_log.c
 create mode 100644 drivers/common/nfp/nfp_common_log.h
 create mode 100644 drivers/common/nfp/nfp_common_pci.c
 create mode 100644 drivers/common/nfp/nfp_common_pci.h
 create mode 100644 drivers/common/nfp/version.map

diff --git a/.mailmap b/.mailmap
index f015c89db0..3040a26609 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1299,6 +1299,7 @@ Shuanglin Wang <shuanglin.wang@broadcom.com>
 Shuki Katzenelson <shuki@lightbitslabs.com>
 Shun Hao <shunh@nvidia.com>
 Shu Shen <shu.shen@radisys.com>
+Shujing Dong <shujing.dong@corigine.com>
 Shweta Choudaha <shweta.choudaha@att.com>
 Shyam Kumar Shrivastav <shrivastav.shyam@gmail.com>
 Shy Shyman <shys@nvidia.com> <shys@mellanox.com>
diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
new file mode 100644
index 0000000000..45871dfe35
--- /dev/null
+++ b/drivers/common/nfp/meson.build
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64-bit Linux'
+endif
+
+deps += ['bus_pci']
+
+sources = files(
+        'nfp_common_log.c',
+        'nfp_common_pci.c',
+)
diff --git a/drivers/common/nfp/nfp_common_log.c b/drivers/common/nfp/nfp_common_log.c
new file mode 100644
index 0000000000..e69e608eb9
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_log.c
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common_log.h"
+
+RTE_LOG_REGISTER_SUFFIX(nfp_logtype_common, common, NOTICE);
diff --git a/drivers/common/nfp/nfp_common_log.h b/drivers/common/nfp/nfp_common_log.h
new file mode 100644
index 0000000000..066e38e688
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_log.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_LOG_H__
+#define __NFP_COMMON_LOG_H__
+
+#include <rte_log.h>
+
+extern int nfp_logtype_common;
+#define PMD_DRV_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_logtype_common, \
+			"%s(): " fmt "\n", __func__, ## args)
+
+#endif/* __NFP_COMMON_LOG_H__ */
diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
new file mode 100644
index 0000000000..1aa8dd4bbd
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -0,0 +1,274 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common_pci.h"
+
+#include <string.h>
+
+#include <rte_class.h>
+#include <rte_devargs.h>
+#include <rte_kvargs.h>
+
+#include "nfp_common_log.h"
+
+/* Reported driver name. */
+#define NFP_PCI_DRIVER_NAME "nfp_common_pci"
+
+static struct rte_pci_driver nfp_common_pci_driver;
+
+/* PCI ID table is build dynamically based on registered nfp drivers. */
+static struct rte_pci_id *nfp_pci_id_table;
+
+/* Head of list of drivers. */
+static TAILQ_HEAD(nfp_drivers, nfp_class_driver) nfp_drivers_list =
+		TAILQ_HEAD_INITIALIZER(nfp_drivers_list);
+
+static bool nfp_common_initialized;
+
+static const struct {
+	const char *name;
+	enum nfp_class drv_class;
+} nfp_classes[] = {
+	{ .name = "eth",      .drv_class = NFP_CLASS_ETH },
+};
+
+static enum nfp_class
+nfp_class_name_to_value(const char *class_name)
+{
+	uint32_t i;
+
+	for (i = 0; i < RTE_DIM(nfp_classes); i++) {
+		if (strcmp(class_name, nfp_classes[i].name) == 0)
+			return nfp_classes[i].drv_class;
+	}
+
+	return NFP_CLASS_INVALID;
+}
+
+static uint32_t
+nfp_pci_id_table_size_get(const struct rte_pci_id *id_table)
+{
+	uint32_t table_size;
+
+	if (id_table == NULL)
+		return 0;
+
+	for (table_size = 0; id_table->vendor_id != 0; id_table++)
+		table_size++;
+
+	return table_size;
+}
+
+static bool
+nfp_pci_id_exists(const struct rte_pci_id *id,
+		const struct rte_pci_id *table,
+		uint32_t next_idx)
+{
+	uint32_t i;
+
+	if (next_idx == 0)
+		return false;
+
+	for (i = 0; i < next_idx; i++) {
+		if (id->device_id == table[i].device_id &&
+				id->vendor_id == table[i].vendor_id &&
+				id->subsystem_vendor_id == table[i].subsystem_vendor_id &&
+				id->subsystem_device_id == table[i].subsystem_device_id)
+			return true;
+	}
+
+	return false;
+}
+
+static void
+nfp_pci_id_insert(struct rte_pci_id *new_table,
+		uint32_t *next_idx,
+		const struct rte_pci_id *id_table)
+{
+	if (id_table == NULL)
+		return;
+
+	/* Add non duplicate entries to new table. */
+	for (; id_table->vendor_id != 0; id_table++) {
+		if (!nfp_pci_id_exists(id_table, new_table, *next_idx)) {
+			new_table[*next_idx] = *id_table;
+			(*next_idx)++;
+		}
+	}
+}
+
+static int
+nfp_pci_id_table_update(const struct rte_pci_id *driver_id_table)
+{
+	uint32_t i = 0;
+	uint32_t num_ids = 0;
+	struct rte_pci_id *old_table;
+	const struct rte_pci_id *id_iter;
+	struct rte_pci_id *updated_table;
+
+	old_table = nfp_pci_id_table;
+	if (old_table != NULL)
+		num_ids = nfp_pci_id_table_size_get(old_table);
+	num_ids += nfp_pci_id_table_size_get(driver_id_table);
+
+	/* Increase size by one for the termination entry of vendor_id = 0. */
+	num_ids += 1;
+	updated_table = calloc(num_ids, sizeof(struct rte_pci_id));
+	if (updated_table == NULL)
+		return -ENOMEM;
+
+	if (old_table == NULL) {
+		/* Copy the first driver's ID table. */
+		for (id_iter = driver_id_table; id_iter[i].vendor_id != 0; i++)
+			updated_table[i] = id_iter[i];
+	} else {
+		/* First copy existing table entries. */
+		for (id_iter = old_table; id_iter[i].vendor_id != 0; i++)
+			updated_table[i] = id_iter[i];
+		/* New id to be added at the end of current ID table. */
+		nfp_pci_id_insert(updated_table, &i, driver_id_table);
+
+		free(old_table);
+	}
+
+	/* Terminate table with empty entry. */
+	updated_table[i].vendor_id = 0;
+	nfp_pci_id_table = updated_table;
+	nfp_common_pci_driver.id_table = nfp_pci_id_table;
+
+	return 0;
+}
+
+static int
+nfp_kvarg_dev_class_handler(__rte_unused const char *key,
+		const char *class_str,
+		void *opaque)
+{
+	enum nfp_class *dev_class = opaque;
+
+	if (class_str == NULL)
+		return *dev_class;
+
+	*dev_class = nfp_class_name_to_value(class_str);
+
+	return 0;
+}
+
+static enum nfp_class
+nfp_parse_class_options(const struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvargs;
+	enum nfp_class dev_class = NFP_CLASS_ETH;
+
+	if (devargs == NULL)
+		return dev_class;
+
+	kvargs = rte_kvargs_parse(devargs->args, NULL);
+	if (kvargs == NULL)
+		return dev_class;
+
+	if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
+		rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
+				nfp_kvarg_dev_class_handler, &dev_class);
+	}
+
+	rte_kvargs_free(kvargs);
+
+	return dev_class;
+}
+
+static int
+nfp_drivers_probe(struct rte_pci_device *pci_dev,
+		enum nfp_class class)
+{
+	int32_t ret = 0;
+	struct nfp_class_driver *driver;
+
+	TAILQ_FOREACH(driver, &nfp_drivers_list, next) {
+		if ((driver->drv_class & class) == 0)
+			continue;
+
+		ret = driver->probe(pci_dev);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to load driver %s", driver->name);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_common_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+		struct rte_pci_device *pci_dev)
+{
+	enum nfp_class class;
+	struct rte_device *eal_dev = &pci_dev->device;
+
+	PMD_DRV_LOG(INFO, "probe device %s.", eal_dev->name);
+
+	class = nfp_parse_class_options(eal_dev->devargs);
+	if (class == NFP_CLASS_INVALID) {
+		PMD_DRV_LOG(ERR, "Unsupported nfp class type: %s",
+				eal_dev->devargs->args);
+		return -ENOTSUP;
+	}
+
+	return nfp_drivers_probe(pci_dev, class);
+}
+
+static int
+nfp_common_pci_remove(__rte_unused struct rte_pci_device *pci_dev)
+{
+	return 0;
+}
+
+static struct rte_pci_driver nfp_common_pci_driver = {
+	.driver = {
+		.name = NFP_PCI_DRIVER_NAME,
+	},
+	.probe = nfp_common_pci_probe,
+	.remove = nfp_common_pci_remove,
+};
+
+static void
+nfp_common_init(void)
+{
+	const struct rte_pci_id empty_table[] = {
+		{
+			.vendor_id = 0
+		},
+	};
+
+	if (nfp_common_initialized)
+		return;
+
+	/*
+	 * All the constructor of NFP PMDs run at same priority. So any of the PMD
+	 * including this one can register the PCI table first. If any other
+	 * PMD(s) have registered the PCI ID table, no need to register an empty
+	 * default one.
+	 */
+	if (nfp_pci_id_table == NULL && nfp_pci_id_table_update(empty_table) != 0)
+		return;
+
+	rte_pci_register(&nfp_common_pci_driver);
+	nfp_common_initialized = true;
+}
+
+void
+nfp_class_driver_register(struct nfp_class_driver *driver)
+{
+	nfp_common_init();
+
+	if (driver->id_table != NULL) {
+		if (nfp_pci_id_table_update(driver->id_table) != 0)
+			return;
+	}
+
+	nfp_common_pci_driver.drv_flags |= driver->drv_flags;
+
+	TAILQ_INSERT_TAIL(&nfp_drivers_list, driver, next);
+}
diff --git a/drivers/common/nfp/nfp_common_pci.h b/drivers/common/nfp/nfp_common_pci.h
new file mode 100644
index 0000000000..21465fca68
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_pci.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_PCI_H__
+#define __NFP_COMMON_PCI_H__
+
+#include <bus_pci_driver.h>
+
+/* Initialization function for the driver called during device probing. */
+typedef int (nfp_class_driver_probe_t)(struct rte_pci_device *dev);
+
+/* Uninitialization function for the driver called during hot-unplugging. */
+typedef int (nfp_class_driver_remove_t)(struct rte_pci_device *dev);
+
+enum nfp_class {
+	NFP_CLASS_ETH,
+	NFP_CLASS_INVALID,
+};
+
+/* Describing a nfp common class driver. */
+struct nfp_class_driver {
+	TAILQ_ENTRY(nfp_class_driver) next;
+	enum nfp_class drv_class;            /**< Class of this driver. */
+	const char *name;                    /**< Driver name. */
+	const struct rte_pci_id *id_table;   /**< ID table, NULL terminated. */
+	uint32_t drv_flags;                  /**< Flags RTE_PCI_DRV_*. */
+	nfp_class_driver_probe_t *probe;     /**< Device probe function. */
+	nfp_class_driver_remove_t *remove;   /**< Device remove function. */
+};
+
+/**
+ * Register a nfp device driver.
+ *
+ * @param driver
+ *   A pointer to a nfp_driver structure describing the driver
+ *   to be registered.
+ */
+__rte_internal
+void
+nfp_class_driver_register(struct nfp_class_driver *driver);
+
+#endif /* __NFP_COMMON_PCI_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
new file mode 100644
index 0000000000..25e48c39d6
--- /dev/null
+++ b/drivers/common/nfp/version.map
@@ -0,0 +1,7 @@
+INTERNAL {
+	global:
+
+	nfp_class_driver_register;
+
+	local: *;
+};
diff --git a/drivers/meson.build b/drivers/meson.build
index 8c775bbe62..af70ed322c 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -15,6 +15,7 @@ subdirs = [
         'common/mlx5',    # depends on bus.
         'common/qat',     # depends on bus.
         'common/sfc_efx', # depends on bus.
+        'common/nfp',     # depends on bus.
         'mempool',        # depends on common and bus.
         'dma',            # depends on common and bus.
         'net',            # depends on common, bus, mempool
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 02/25] net/nfp: make VF PMD using of NFP common module
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
  2023-10-17  5:45 ` [PATCH 01/25] drivers: introduce the NFP common library Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 03/25] net/nfp: rename common module name Chaoyong He
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Modify the logic of NFP VF PMD, make it using of the NFP common module
and link into the 'nfp_drivers_list'.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/meson.build     |  6 +++++-
 drivers/net/nfp/nfp_ethdev_vf.c | 14 ++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 40e9ef8524..f8581403fa 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -40,4 +40,8 @@ sources = files(
         'nfp_rxtx.c',
 )
 
-deps += ['hash', 'security']
+deps += ['hash', 'security', 'common_nfp']
+
+if not dpdk_conf.has('RTE_COMMON_NFP')
+    error('Missing internal dependency "common/nfp"')
+endif
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 3db35b90e8..b9d7a7c5c0 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -6,6 +6,7 @@
  */
 
 #include <rte_alarm.h>
+#include <nfp_common_pci.h>
 
 #include "nfd3/nfp_nfd3.h"
 #include "nfdk/nfp_nfdk.h"
@@ -399,8 +400,7 @@ nfp_vf_pci_uninit(struct rte_eth_dev *eth_dev)
 }
 
 static int
-nfp_vf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
-		struct rte_pci_device *pci_dev)
+nfp_vf_pci_probe(struct rte_pci_device *pci_dev)
 {
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 			sizeof(struct nfp_net_adapter), nfp_netvf_init);
@@ -412,13 +412,19 @@ nfp_vf_pci_remove(struct rte_pci_device *pci_dev)
 	return rte_eth_dev_pci_generic_remove(pci_dev, nfp_vf_pci_uninit);
 }
 
-static struct rte_pci_driver rte_nfp_net_vf_pmd = {
+static struct nfp_class_driver rte_nfp_net_vf_pmd = {
+	.drv_class = NFP_CLASS_ETH,
+	.name = RTE_STR(net_nfp_vf),
 	.id_table = pci_id_nfp_vf_net_map,
 	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
 	.probe = nfp_vf_pci_probe,
 	.remove = nfp_vf_pci_remove,
 };
 
-RTE_PMD_REGISTER_PCI(net_nfp_vf, rte_nfp_net_vf_pmd);
+RTE_INIT(rte_nfp_vf_pmd_init)
+{
+	nfp_class_driver_register(&rte_nfp_net_vf_pmd);
+}
+
 RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 03/25] net/nfp: rename common module name
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
  2023-10-17  5:45 ` [PATCH 01/25] drivers: introduce the NFP common library Chaoyong He
  2023-10-17  5:45 ` [PATCH 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 04/25] net/nfp: rename ctrl " Chaoyong He
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename the 'nfp_common' module into 'nfp_net_common' module, because
which is more suitable and we will add 'nfp_common' module in the
'drivers/common/nfp' directory.

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.h                | 2 +-
 drivers/net/nfp/meson.build                        | 2 +-
 drivers/net/nfp/nfp_cpp_bridge.h                   | 2 +-
 drivers/net/nfp/nfp_ctrl.c                         | 2 +-
 drivers/net/nfp/nfp_ethdev_vf.c                    | 2 +-
 drivers/net/nfp/nfp_flow.h                         | 2 +-
 drivers/net/nfp/nfp_ipsec.c                        | 2 +-
 drivers/net/nfp/{nfp_common.c => nfp_net_common.c} | 2 +-
 drivers/net/nfp/{nfp_common.h => nfp_net_common.h} | 6 +++---
 9 files changed, 11 insertions(+), 11 deletions(-)
 rename drivers/net/nfp/{nfp_common.c => nfp_net_common.c} (99%)
 rename drivers/net/nfp/{nfp_common.h => nfp_net_common.h} (99%)

diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h
index b7ea830209..7d442e3cb2 100644
--- a/drivers/net/nfp/flower/nfp_flower.h
+++ b/drivers/net/nfp/flower/nfp_flower.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_FLOWER_H__
 #define __NFP_FLOWER_H__
 
-#include "../nfp_common.h"
+#include "../nfp_net_common.h"
 
 /* Extra features bitmap. */
 #define NFP_FL_FEATS_GENEVE             RTE_BIT64(0)
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index f8581403fa..40748ccc98 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -28,7 +28,6 @@ sources = files(
         'nfpcore/nfp_rtsym.c',
         'nfpcore/nfp_target.c',
         'nfpcore/nfp6000_pcie.c',
-        'nfp_common.c',
         'nfp_cpp_bridge.c',
         'nfp_ctrl.c',
         'nfp_ethdev.c',
@@ -37,6 +36,7 @@ sources = files(
         'nfp_ipsec.c',
         'nfp_logs.c',
         'nfp_mtr.c',
+        'nfp_net_common.c',
         'nfp_rxtx.c',
 )
 
diff --git a/drivers/net/nfp/nfp_cpp_bridge.h b/drivers/net/nfp/nfp_cpp_bridge.h
index a1103e85e4..bf975ce7ba 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.h
+++ b/drivers/net/nfp/nfp_cpp_bridge.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_CPP_BRIDGE_H__
 #define __NFP_CPP_BRIDGE_H__
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 int nfp_enable_cpp_service(struct nfp_pf_dev *pf_dev);
 int nfp_map_service(uint32_t service_id);
diff --git a/drivers/net/nfp/nfp_ctrl.c b/drivers/net/nfp/nfp_ctrl.c
index 6fc8cffd2e..a95e35c9a5 100644
--- a/drivers/net/nfp/nfp_ctrl.c
+++ b/drivers/net/nfp/nfp_ctrl.c
@@ -9,8 +9,8 @@
 
 #include "nfpcore/nfp_platform.h"
 
-#include "nfp_common.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 
 static void
 nfp_net_tlv_caps_reset(struct nfp_net_tlv_caps *caps)
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index b9d7a7c5c0..51c474275e 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -12,8 +12,8 @@
 #include "nfdk/nfp_nfdk.h"
 #include "nfpcore/nfp_cpp.h"
 
-#include "nfp_common.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 
 static void
 nfp_netvf_read_mac(struct nfp_net_hw *hw)
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index aeb24458f3..09e5b30dd8 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_FLOW_H__
 #define __NFP_FLOW_H__
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 /* The firmware expects lengths in units of long words */
 #define NFP_FL_LW_SIZ                   2
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index a76ba2a91d..f137e4b50c 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -12,9 +12,9 @@
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
 
-#include "nfp_common.h"
 #include "nfp_ctrl.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 #include "nfp_rxtx.h"
 
 #define NFP_UDP_ESP_PORT            4500
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_net_common.c
similarity index 99%
rename from drivers/net/nfp/nfp_common.c
rename to drivers/net/nfp/nfp_net_common.c
index 2d4a7635ab..189f81bbb6 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -5,7 +5,7 @@
  * Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
  */
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 #include <rte_alarm.h>
 
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_net_common.h
similarity index 99%
rename from drivers/net/nfp/nfp_common.h
rename to drivers/net/nfp/nfp_net_common.h
index c7f467e33c..cf08df4618 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -3,8 +3,8 @@
  * All rights reserved.
  */
 
-#ifndef __NFP_COMMON_H__
-#define __NFP_COMMON_H__
+#ifndef __NFP_NET_COMMON_H__
+#define __NFP_NET_COMMON_H__
 
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
@@ -451,4 +451,4 @@ bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
 #define NFP_PRIV_TO_APP_FW_FLOWER(app_fw_priv)\
 	((struct nfp_app_fw_flower *)app_fw_priv)
 
-#endif /* __NFP_COMMON_H__ */
+#endif /* __NFP_NET_COMMON_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 04/25] net/nfp: rename ctrl module name
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (2 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 03/25] net/nfp: rename common module name Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 05/25] net/nfp: extract the cap data field Chaoyong He
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename the 'nfp_ctrl' module into 'nfp_net_ctrl' module, because which
is more suitable and we will add 'nfp_common_ctrl' module in the
'drivers/common/nfp' directory.

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/meson.build                    | 2 +-
 drivers/net/nfp/nfp_ipsec.c                    | 2 +-
 drivers/net/nfp/nfp_net_common.h               | 2 +-
 drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} | 2 +-
 drivers/net/nfp/{nfp_ctrl.h => nfp_net_ctrl.h} | 6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)
 rename drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} (98%)
 rename drivers/net/nfp/{nfp_ctrl.h => nfp_net_ctrl.h} (99%)

diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 40748ccc98..d54dca36e9 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -29,7 +29,6 @@ sources = files(
         'nfpcore/nfp_target.c',
         'nfpcore/nfp6000_pcie.c',
         'nfp_cpp_bridge.c',
-        'nfp_ctrl.c',
         'nfp_ethdev.c',
         'nfp_ethdev_vf.c',
         'nfp_flow.c',
@@ -37,6 +36,7 @@ sources = files(
         'nfp_logs.c',
         'nfp_mtr.c',
         'nfp_net_common.c',
+        'nfp_net_ctrl.c',
         'nfp_rxtx.c',
 )
 
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index f137e4b50c..af85e8575c 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -12,9 +12,9 @@
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
 
-#include "nfp_ctrl.h"
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
+#include "nfp_net_ctrl.h"
 #include "nfp_rxtx.h"
 
 #define NFP_UDP_ESP_PORT            4500
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index cf08df4618..8a02911c45 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -11,7 +11,7 @@
 #include <rte_io.h>
 #include <rte_spinlock.h>
 
-#include "nfp_ctrl.h"
+#include "nfp_net_ctrl.h"
 #include "nfpcore/nfp_dev.h"
 
 /* Macros for accessing the Queue Controller Peripheral 'CSRs' */
diff --git a/drivers/net/nfp/nfp_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
similarity index 98%
rename from drivers/net/nfp/nfp_ctrl.c
rename to drivers/net/nfp/nfp_net_ctrl.c
index a95e35c9a5..b0a427c98e 100644
--- a/drivers/net/nfp/nfp_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -3,7 +3,7 @@
  * All rights reserved.
  */
 
-#include "nfp_ctrl.h"
+#include "nfp_net_ctrl.h"
 
 #include <ethdev_pci.h>
 
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
similarity index 99%
rename from drivers/net/nfp/nfp_ctrl.h
rename to drivers/net/nfp/nfp_net_ctrl.h
index 9ec51e0a25..3772b28a66 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_net_ctrl.h
@@ -3,8 +3,8 @@
  * All rights reserved.
  */
 
-#ifndef __NFP_CTRL_H__
-#define __NFP_CTRL_H__
+#ifndef __NFP_NET_CTRL_H__
+#define __NFP_NET_CTRL_H__
 
 #include <stdint.h>
 
@@ -571,4 +571,4 @@ nfp_net_cfg_ctrl_rss(uint32_t hw_cap)
 	return NFP_NET_CFG_CTRL_RSS;
 }
 
-#endif /* __NFP_CTRL_H__ */
+#endif /* __NFP_NET_CTRL_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 05/25] net/nfp: extract the cap data field
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (3 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 04/25] net/nfp: rename ctrl " Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 06/25] net/nfp: extract the qcp " Chaoyong He
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'cap' data field into the super class, ready 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 |  6 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c  | 10 +--
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  | 12 ++--
 drivers/net/nfp/nfp_ethdev.c        | 12 ++--
 drivers/net/nfp/nfp_ethdev_vf.c     | 10 +--
 drivers/net/nfp/nfp_net_common.c    | 94 +++++++++++++++--------------
 drivers/net/nfp/nfp_net_common.h    |  8 ++-
 drivers/net/nfp/nfp_rxtx.c          |  2 +-
 8 files changed, 81 insertions(+), 73 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 0c54d7ed27..c758add734 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -65,7 +65,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
+	if (hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
@@ -101,7 +101,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_RSS;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS2) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS2;
 	else
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS;
@@ -111,7 +111,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index b64dbaca0d..e9a16371bc 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -30,7 +30,7 @@ nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
 		goto clean_txd;
 
 	ol_flags = mb->ol_flags;
@@ -69,7 +69,7 @@ nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
 		return;
 
 	ol_flags = mb->ol_flags;
@@ -127,8 +127,8 @@ nfp_net_nfd3_tx_vlan(struct nfp_net_txq *txq,
 {
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0 ||
-			(hw->cap & NFP_NET_CFG_CTRL_TXVLAN) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0 ||
+			(hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) == 0)
 		return;
 
 	if ((mb->ol_flags & RTE_MBUF_F_TX_VLAN) != 0) {
@@ -278,7 +278,7 @@ nfp_net_nfd3_xmit_pkts_common(void *tx_queue,
 		}
 
 		if (unlikely(pkt->nb_segs > 1 &&
-				(hw->cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
+				(hw->super.cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
 			PMD_TX_LOG(ERR, "Multisegment packet not supported");
 			goto xmit_end;
 		}
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 259039964a..533099278d 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -23,7 +23,7 @@ nfp_net_nfdk_tx_cksum(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
 		return flags;
 
 	ol_flags = mb->ol_flags;
@@ -57,7 +57,7 @@ nfp_net_nfdk_tx_tso(struct nfp_net_txq *txq,
 
 	txd.raw = 0;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
 		return txd.raw;
 
 	ol_flags = mb->ol_flags;
@@ -146,7 +146,7 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq,
 		return -EINVAL;
 
 	/* Count TSO descriptor */
-	if ((txq->hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+	if ((txq->hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 			(pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
 		n_descs++;
 
@@ -322,7 +322,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 			nfp_net_nfdk_set_meta_data(pkt, txq, &metadata);
 
 		if (unlikely(pkt->nb_segs > 1 &&
-				(hw->cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
+				(hw->super.cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
 			PMD_TX_LOG(ERR, "Multisegment packet not supported");
 			goto xmit_end;
 		}
@@ -332,7 +332,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 		 * multisegment packet, but TSO info needs to be in all of them.
 		 */
 		dma_len = pkt->data_len;
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 				(pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) {
 			type = NFDK_DESC_TX_TYPE_TSO;
 		} else if (pkt->next == NULL && dma_len <= NFDK_TX_MAX_DATA_PER_HEAD) {
@@ -405,7 +405,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 		ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_cksum(txq, temp_pkt, metadata));
 		ktxds++;
 
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 				(temp_pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) {
 			ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_tso(txq, temp_pkt));
 			ktxds++;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 20940072fe..329589e90f 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -119,7 +119,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
 	}
 
 	/* Enable device */
@@ -128,12 +128,12 @@ nfp_net_start(struct rte_eth_dev *dev)
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
 	/* Enable vxlan */
-	if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
 		new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
 		update |= NFP_NET_CFG_UPDATE_VXLAN;
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
@@ -580,8 +580,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
 	nfp_net_log_device_information(hw);
 
@@ -609,7 +609,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	/* Copying mac address to DPDK eth_dev struct */
 	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 51c474275e..293d1ed53c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -86,7 +86,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
 	}
 
 	/* Enable device */
@@ -94,7 +94,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
@@ -314,8 +314,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
 	nfp_net_log_device_information(hw);
 
@@ -341,7 +341,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	/* Copying mac address to DPDK eth_dev struct */
 	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 189f81bbb6..3cbf6bc021 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -408,7 +408,7 @@ nfp_net_configure(struct rte_eth_dev *dev)
 
 	/* Checking RX mode */
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+			(hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		PMD_DRV_LOG(ERR, "RSS not supported");
 		return -EINVAL;
 	}
@@ -426,27 +426,29 @@ nfp_net_configure(struct rte_eth_dev *dev)
 void
 nfp_net_log_device_information(const struct nfp_net_hw *hw)
 {
+	uint32_t cap = hw->super.cap;
+
 	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
 			hw->ver.major, hw->ver.minor, hw->max_mtu);
 
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
-			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
-			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2 ? "TXVLANv2 "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
-			hw->cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
-			hw->cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
-			hw->cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
-			hw->cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
-			hw->cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
+	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", cap,
+			cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
+			cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
+			cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
+			cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
+			cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
+			cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
+			cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
+			cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
+			cap & NFP_NET_CFG_CTRL_TXVLAN_V2 ? "TXVLANv2 "  : "",
+			cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
+			cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
+			cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
+			cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
+			cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
+			cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
+			cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
+			cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
 
 	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
 			hw->max_rx_queues, hw->max_tx_queues);
@@ -456,9 +458,9 @@ static inline void
 nfp_net_enable_rxvlan_cap(struct nfp_net_hw *hw,
 		uint32_t *ctrl)
 {
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0)
 		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN_V2;
-	else if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN) != 0)
+	else if ((hw->super.cap & NFP_NET_CFG_CTRL_RXVLAN) != 0)
 		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN;
 }
 
@@ -503,7 +505,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
@@ -552,7 +554,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
+			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
 	}
@@ -563,7 +565,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
+			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
 	/* Signal the NIC about the change */
@@ -631,7 +633,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	tx_offload = dev_conf->txmode.offloads;
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXCSUM;
 	}
 
@@ -639,25 +641,25 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 		nfp_net_enable_rxvlan_cap(hw, &ctrl);
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
 	hw->mtu = dev->data->mtu;
 
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2;
-		else if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
+		else if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
 	}
 
 	/* L2 broadcast */
-	if ((hw->cap & NFP_NET_CFG_CTRL_L2BC) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2BC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2BC;
 
 	/* L2 multicast */
-	if ((hw->cap & NFP_NET_CFG_CTRL_L2MC) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2MC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2MC;
 
 	/* TX checksum offload */
@@ -669,7 +671,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	/* LSO offload */
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 ||
 			(tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_LSO;
 		else
 			ctrl |= NFP_NET_CFG_CTRL_LSO2;
@@ -698,7 +700,7 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev)
 		hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(ERR, "Promiscuous mode not supported");
 		return -ENOTSUP;
 	}
@@ -1213,32 +1215,32 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
-	if ((hw->cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
+	if ((hw->super.cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
+	if ((hw->super.cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
 		dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
-		if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
 			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_GATHER) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_GATHER) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	cap_extend = hw->cap_ext;
@@ -1281,7 +1283,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG,
 	};
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
 		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
@@ -1334,7 +1336,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 		return -ENODEV;
 
 	/* Get some of the read-only fields from the config BAR */
-	hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
+	hw->super.cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
 	hw->cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
 	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
 	hw->flbufsz = DEFAULT_FLBUF_SIZE;
@@ -2025,14 +2027,14 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw)
 	 */
 	if (hw->ver.major == 4) {
 		hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
-	} else if ((hw->cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
+	} else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
 		hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
 		/*
-		 * RSS is incompatible with chained metadata. hw->cap just represents
+		 * RSS is incompatible with chained metadata. hw->super.cap just represents
 		 * firmware's ability rather than the firmware's configuration. We decide
-		 * to reduce the confusion to allow us can use hw->cap to identify RSS later.
+		 * to reduce the confusion to allow us can use hw->super.cap to identify RSS later.
 		 */
-		hw->cap &= ~NFP_NET_CFG_CTRL_RSS;
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_RSS;
 	} else {
 		hw->meta_format = NFP_NET_METAFORMAT_SINGLE;
 	}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 8a02911c45..269fb4930e 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -112,7 +112,14 @@ struct nfp_app_fw_nic {
 	uint8_t total_phyports;
 };
 
+struct nfp_hw {
+	uint32_t cap;
+};
+
 struct nfp_net_hw {
+	/** The parent class */
+	struct nfp_hw super;
+
 	/** Backpointer to the PF this port belongs to */
 	struct nfp_pf_dev *pf_dev;
 
@@ -122,7 +129,6 @@ struct nfp_net_hw {
 	/** Info from the firmware */
 	uint32_t cap_ext;
 	struct nfp_net_fw_ver ver;
-	uint32_t cap;
 	uint32_t max_mtu;
 	uint32_t mtu;
 	uint32_t rx_offset;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index efdca7fccf..a0c7e0e9b5 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -386,7 +386,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 	struct nfp_net_hw *hw = rxq->hw;
 
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
-			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
+			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
 	if (meta->vlan_layer < NFP_META_MAX_VLANS)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 06/25] net/nfp: extract the qcp data field
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (4 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 05/25] net/nfp: extract the cap data field Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'qcp_cfg' data field 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/nfp_net_common.c | 8 ++++----
 drivers/net/nfp/nfp_net_common.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 3cbf6bc021..a5548074fb 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -206,14 +206,14 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 	struct timespec wait;
 
 	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->qcp_cfg);
+			hw->super.qcp_cfg);
 
-	if (hw->qcp_cfg == NULL) {
+	if (hw->super.qcp_cfg == NULL) {
 		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
 		return -ENXIO;
 	}
 
-	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+	nfp_qcp_ptr_add(hw->super.qcp_cfg, NFP_QCP_WRITE_PTR, 1);
 
 	wait.tv_sec = 0;
 	wait.tv_nsec = 1000000; /* 1ms */
@@ -525,7 +525,7 @@ nfp_net_params_setup(struct nfp_net_hw *hw)
 void
 nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 {
-	hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
+	hw->super.qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }
 
 void
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 269fb4930e..cc7d438011 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 *qcp_cfg;
 	uint32_t cap;
 };
 
@@ -150,7 +151,6 @@ struct nfp_net_hw {
 	uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
 	uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
 
-	uint8_t *qcp_cfg;
 	rte_spinlock_t reconfig_lock;
 
 	uint32_t max_tx_queues;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 07/25] net/nfp: extract the ctrl BAR data field
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (5 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 06/25] net/nfp: extract the qcp " Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 08/25] net/nfp: extract the ctrl " Chaoyong He
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

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(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index c758add734..28bdb8e214 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -351,7 +351,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)
@@ -875,7 +875,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;
@@ -893,9 +893,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 329589e90f..9ff1c297a4 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -507,16 +507,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);
@@ -531,12 +531,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);
@@ -574,7 +574,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 a5548074fb..283f5ee627 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 cc7d438011..2f02803ea4 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;
 };
@@ -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;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 08/25] net/nfp: extract the ctrl data field
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (6 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 09/25] net/nfp: change the parameter of APIs Chaoyong He
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'ctrl' 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/nfd3/nfp_nfd3_dp.c  |  2 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  |  2 +-
 drivers/net/nfp/nfp_ethdev.c        |  2 +-
 drivers/net/nfp/nfp_ethdev_vf.c     |  2 +-
 drivers/net/nfp/nfp_net_common.c    | 46 ++++++++++++++---------------
 drivers/net/nfp/nfp_net_common.h    |  4 +--
 drivers/net/nfp/nfp_rxtx.c          | 12 ++++----
 8 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 28bdb8e214..2aa0d9939e 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -61,7 +61,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
 	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
@@ -72,7 +72,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 }
 
 int
@@ -123,7 +123,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 		return -EIO;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
@@ -723,7 +723,7 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 		return -EIO;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index e9a16371bc..9f03b56c0c 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -154,7 +154,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
 	cap_extend = hw->cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+			(hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
 		if (meta_data->length == 0)
 			meta_data->length = NFP_NET_META_HEADER_SIZE;
 		meta_data->length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 533099278d..bc027210af 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -187,7 +187,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 	cap_extend = hw->cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+			(hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
 		if (meta_data.length == 0)
 			meta_data.length = NFP_NET_META_HEADER_SIZE;
 		meta_data.length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 9ff1c297a4..ec9f6041fd 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -167,7 +167,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	else
 		nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 1);
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 641fed6fcf..684968903c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -110,7 +110,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 283f5ee627..25b8e3a613 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -500,7 +500,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
 	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
@@ -512,7 +512,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 }
 
 void
@@ -553,7 +553,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	struct nfp_net_hw *hw;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
 			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
@@ -563,8 +563,8 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
-	ctrl = hw->ctrl;
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+	ctrl = hw->super.ctrl;
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
 			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
@@ -613,7 +613,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 	}
 
 	/* Avoiding TX interrupts */
-	hw->ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
+	hw->super.ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
 	return 0;
 }
 
@@ -705,19 +705,19 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already enabled");
 		return 0;
 	}
 
-	new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->super.ctrl | NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -732,19 +732,19 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already disabled");
 		return 0;
 	}
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1349,7 +1349,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 	else
 		hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
 
-	hw->ctrl = 0;
+	hw->super.ctrl = 0;
 	hw->stride_rx = stride;
 	hw->stride_tx = stride;
 
@@ -1453,7 +1453,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
 	/* Make sure all updates are written before un-masking */
 	rte_wmb();
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
 		/* If MSI-X auto-masking is used, clear the entry */
 		rte_intr_ack(pci_dev->intr_handle);
 	} else {
@@ -1559,7 +1559,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	rx_offload = dev->data->dev_conf.rxmode.offloads;
-	new_ctrl = hw->ctrl;
+	new_ctrl = hw->super.ctrl;
 
 	/* VLAN stripping setting */
 	if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) {
@@ -1578,7 +1578,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 			new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
-	if (new_ctrl == hw->ctrl)
+	if (new_ctrl == hw->super.ctrl)
 		return 0;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
@@ -1587,7 +1587,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1660,7 +1660,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 	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)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size);
@@ -1669,7 +1669,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1690,7 +1690,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 	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)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
@@ -1795,7 +1795,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 	rss_hf = rss_conf->rss_hf;
 
 	/* Checking if RSS is enabled */
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		if (rss_hf != 0) {
 			PMD_DRV_LOG(ERR, "RSS unsupported");
 			return -EINVAL;
@@ -1813,7 +1813,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1831,7 +1831,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 2f02803ea4..375e26bfc2 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -116,6 +116,7 @@ struct nfp_hw {
 	uint8_t *ctrl_bar;
 	uint8_t *qcp_cfg;
 	uint32_t cap;
+	uint32_t ctrl;    /**< Current values for control */
 };
 
 struct nfp_net_hw {
@@ -139,9 +140,6 @@ struct nfp_net_hw {
 	/** NFP ASIC params */
 	const struct nfp_dev_info *dev_info;
 
-	/** Current values for control */
-	uint32_t ctrl;
-
 	uint8_t *tx_bar;
 	uint8_t *rx_bar;
 
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index a0c7e0e9b5..a9dd464a6a 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -143,7 +143,7 @@ nfp_net_rx_cksum(struct nfp_net_rxq *rxq,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
 		return;
 
 	/* If IPv4 and IP checksum error, fail */
@@ -307,7 +307,7 @@ nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return;
 
 	mbuf->hash.rss = meta->hash;
@@ -339,7 +339,7 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	struct nfp_net_hw *hw = rxq->hw;
 
 	/* Skip if firmware don't support setting vlan. */
-	if ((hw->ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
+	if ((hw->super.ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
 	/*
@@ -347,12 +347,12 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	 * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
 	 * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
 	 */
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
 		if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
 		}
-	} else if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+	} else if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
 		if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
@@ -385,7 +385,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
 			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 09/25] net/nfp: change the parameter of APIs
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (7 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 08/25] net/nfp: extract the ctrl " Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 10/25] net/nfp: change the parameter of reconfig Chaoyong He
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Change the parameter of some APIs from 'struct nfp_net_hw' into the
super class 'struct nfp_hw', 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           |  24 ++--
 .../net/nfp/flower/nfp_flower_representor.c   |  10 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c            |   4 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c            |   4 +-
 drivers/net/nfp/nfp_ethdev.c                  |   8 +-
 drivers/net/nfp/nfp_ethdev_vf.c               |  12 +-
 drivers/net/nfp/nfp_ipsec.c                   |   4 +-
 drivers/net/nfp/nfp_net_common.c              | 129 +++++++++---------
 drivers/net/nfp/nfp_net_common.h              |  32 ++---
 drivers/net/nfp/nfp_rxtx.c                    |   4 +-
 10 files changed, 116 insertions(+), 115 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 2aa0d9939e..0fc1342740 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -36,7 +36,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	enabled_queues = 0;
 
@@ -44,7 +44,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 static void
@@ -58,8 +58,8 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	repr = dev->data->dev_private;
 	hw = repr->app_fw_flower->pf_hw;
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
 
 	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
@@ -114,7 +114,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
 
 	/* If an error when reconfig we avoid to change hw state */
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
@@ -219,7 +219,7 @@ nfp_flower_pf_close(struct rte_eth_dev *dev)
 	/* Cancel possible impending LSC work here before releasing the port */
 	rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler, (void *)dev);
 
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
 
 	rte_eth_dev_release_port(dev);
 
@@ -358,9 +358,9 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw,
 		return err;
 
 	/* Work out where in the BAR the queues start */
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = (uint64_t)start_q * NFP_QCP_QUEUE_ADDR_SZ;
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = (uint64_t)start_q * NFP_QCP_QUEUE_ADDR_SZ;
 
 	hw->tx_bar = pf_dev->qc_bar + tx_bar_off;
@@ -545,8 +545,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 		 * Telling the HW about the physical address of the RX ring and number
 		 * of descriptors in log2 format.
 		 */
-		nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(i), rxq->dma);
-		nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
+		nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(i), rxq->dma);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
 	}
 
 	snprintf(ctrl_txring_name, sizeof(ctrl_txring_name), "%s_cttx_ring", pci_name);
@@ -610,8 +610,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 		 * Telling the HW about the physical address of the TX ring and number
 		 * of descriptors in log2 format.
 		 */
-		nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(i), txq->dma);
-		nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
+		nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(i), txq->dma);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
 	}
 
 	return 0;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 650f09a475..b52c6f514a 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -97,8 +97,8 @@ nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the RX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
@@ -181,8 +181,8 @@ nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
@@ -228,7 +228,7 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,
 				}
 			}
 		} else {
-			nn_link_status = nn_cfg_readw(pf_hw, NFP_NET_CFG_STS);
+			nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS);
 			nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) &
 					NFP_NET_CFG_STS_LINK_RATE_MASK;
 
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 9f03b56c0c..68a841b69e 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -465,8 +465,8 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
 
 	return 0;
 }
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index bc027210af..cef27b0d92 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -542,8 +542,8 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
 
 	return 0;
 }
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index ec9f6041fd..6a4455e50f 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -284,7 +284,7 @@ nfp_net_close(struct rte_eth_dev *dev)
 
 	/* Only free PF resources after all physical ports have been closed */
 	/* Mark this port as unused and free device priv resources */
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
 	app_fw_nic->ports[hw->idx] = NULL;
 	rte_eth_dev_release_port(dev);
 
@@ -566,8 +566,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* Work out where in the BAR the queues start. */
-	tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
-	rx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	tx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
+	rx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 
 	hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
 	hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
@@ -624,7 +624,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	rte_intr_callback_register(pci_dev->intr_handle,
 			nfp_net_dev_interrupt_handler, (void *)eth_dev);
 	/* Telling the firmware about the LSC interrupt entry */
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 	/* Recording current stats counters values */
 	nfp_net_stats_reset(eth_dev);
 
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 684968903c..7fb2a3d378 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -20,10 +20,10 @@ nfp_netvf_read_mac(struct nfp_net_hw *hw)
 {
 	uint32_t tmp;
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR));
 	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR + 4));
 	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
 }
 
@@ -97,7 +97,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
@@ -299,9 +299,9 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* Work out where in the BAR the queues start. */
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
 
 	hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
@@ -357,7 +357,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		rte_intr_callback_register(pci_dev->intr_handle,
 				nfp_net_dev_interrupt_handler, (void *)eth_dev);
 		/* Telling the firmware about the LSC interrupt entry */
-		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 		/* Recording current stats counters values */
 		nfp_net_stats_reset(eth_dev);
 	}
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index af85e8575c..db3b7492e1 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -445,7 +445,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	msg->rsp = NFP_IPSEC_CFG_MSG_OK;
 
 	for (i = 0; i < msg_size; i++)
-		nn_cfg_writel(hw, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
 
 	ret = nfp_net_mbox_reconfig(hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
 	if (ret < 0) {
@@ -459,7 +459,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	 * response. One example where the data is needed is for statistics.
 	 */
 	for (i = 0; i < msg_size; i++)
-		msg->raw[i] = nn_cfg_readl(hw, NFP_NET_CFG_MBOX_VAL + 4 * i);
+		msg->raw[i] = nn_cfg_readl(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
 
 	switch (msg->rsp) {
 	case NFP_IPSEC_CFG_MSG_OK:
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 25b8e3a613..4f830f2a2a 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -182,7 +182,8 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 	 * NFP_NET_CFG_STS_NSP_LINK_RATE.
 	 */
 	if (link->link_status == RTE_ETH_LINK_DOWN) {
-		nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE, NFP_NET_CFG_STS_LINK_RATE_UNKNOWN);
+		nn_cfg_writew(&hw->super, NFP_NET_CFG_STS_NSP_LINK_RATE,
+				NFP_NET_CFG_STS_LINK_RATE_UNKNOWN);
 		return;
 	}
 
@@ -190,7 +191,7 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 	 * Link is up so write the link speed from the eth_table to
 	 * NFP_NET_CFG_STS_NSP_LINK_RATE.
 	 */
-	nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE,
+	nn_cfg_writew(&hw->super, NFP_NET_CFG_STS_NSP_LINK_RATE,
 			nfp_net_link_speed_rte2nfp(link->link_speed));
 }
 
@@ -222,7 +223,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	/* Poll update field, waiting for NFP to ack the config */
 	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
+		new = nn_cfg_readl(&hw->super, NFP_NET_CFG_UPDATE);
 		if (new == 0)
 			break;
 
@@ -270,8 +271,8 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
@@ -314,8 +315,8 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
@@ -355,8 +356,8 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writeq(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
+	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
@@ -370,7 +371,7 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 		return -EIO;
 	}
 
-	return nn_cfg_readl(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
+	return nn_cfg_readl(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
 }
 
 /*
@@ -478,14 +479,14 @@ nfp_net_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	/* Enabling the required RX queues in the device */
 	enabled_queues = 0;
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 void
@@ -497,8 +498,8 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
 
 	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
@@ -518,8 +519,8 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 void
 nfp_net_params_setup(struct nfp_net_hw *hw)
 {
-	nn_cfg_writel(hw, NFP_NET_CFG_MTU, hw->mtu);
-	nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_MTU, hw->mtu);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
 }
 
 void
@@ -596,7 +597,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 	if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) {
 		PMD_DRV_LOG(INFO, "VF: enabling RX interrupt with UIO");
 		/* UIO just supports one queue and no LSC */
-		nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(0), 0);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_VEC(0), 0);
 		if (rte_intr_vec_list_index_set(intr_handle, 0, 0) != 0)
 			return -1;
 	} else {
@@ -606,7 +607,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 			 * The first msix vector is reserved for non
 			 * efd interrupts.
 			 */
-			nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(i), i + 1);
+			nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_VEC(i), i + 1);
 			if (rte_intr_vec_list_index_set(intr_handle, i, i + 1) != 0)
 				return -1;
 		}
@@ -771,7 +772,7 @@ nfp_net_link_update(struct rte_eth_dev *dev,
 	memset(&link, 0, sizeof(struct rte_eth_link));
 
 	/* Read link status */
-	nn_link_status = nn_cfg_readw(hw, NFP_NET_CFG_STS);
+	nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS);
 	if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0)
 		link.link_status = RTE_ETH_LINK_UP;
 
@@ -842,12 +843,12 @@ nfp_net_stats_get(struct rte_eth_dev *dev,
 			break;
 
 		nfp_dev_stats.q_ipackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i));
 		nfp_dev_stats.q_ipackets[i] -=
 				hw->eth_stats_base.q_ipackets[i];
 
 		nfp_dev_stats.q_ibytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i) + 0x8);
 		nfp_dev_stats.q_ibytes[i] -=
 				hw->eth_stats_base.q_ibytes[i];
 	}
@@ -858,42 +859,42 @@ nfp_net_stats_get(struct rte_eth_dev *dev,
 			break;
 
 		nfp_dev_stats.q_opackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i));
 		nfp_dev_stats.q_opackets[i] -= hw->eth_stats_base.q_opackets[i];
 
 		nfp_dev_stats.q_obytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i) + 0x8);
 		nfp_dev_stats.q_obytes[i] -= hw->eth_stats_base.q_obytes[i];
 	}
 
-	nfp_dev_stats.ipackets = nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES);
+	nfp_dev_stats.ipackets = nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_FRAMES);
 	nfp_dev_stats.ipackets -= hw->eth_stats_base.ipackets;
 
-	nfp_dev_stats.ibytes = nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS);
+	nfp_dev_stats.ibytes = nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_OCTETS);
 	nfp_dev_stats.ibytes -= hw->eth_stats_base.ibytes;
 
 	nfp_dev_stats.opackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_FRAMES);
 	nfp_dev_stats.opackets -= hw->eth_stats_base.opackets;
 
 	nfp_dev_stats.obytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_OCTETS);
 	nfp_dev_stats.obytes -= hw->eth_stats_base.obytes;
 
 	/* Reading general device stats */
 	nfp_dev_stats.ierrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_ERRORS);
 	nfp_dev_stats.ierrors -= hw->eth_stats_base.ierrors;
 
 	nfp_dev_stats.oerrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_ERRORS);
 	nfp_dev_stats.oerrors -= hw->eth_stats_base.oerrors;
 
 	/* RX ring mbuf allocation failures */
 	nfp_dev_stats.rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 
 	nfp_dev_stats.imissed =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_DISCARDS);
 	nfp_dev_stats.imissed -= hw->eth_stats_base.imissed;
 
 	memcpy(stats, &nfp_dev_stats, sizeof(*stats));
@@ -918,10 +919,10 @@ nfp_net_stats_reset(struct rte_eth_dev *dev)
 			break;
 
 		hw->eth_stats_base.q_ipackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i));
 
 		hw->eth_stats_base.q_ibytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i) + 0x8);
 	}
 
 	/* Reading per TX ring stats */
@@ -930,36 +931,36 @@ nfp_net_stats_reset(struct rte_eth_dev *dev)
 			break;
 
 		hw->eth_stats_base.q_opackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i));
 
 		hw->eth_stats_base.q_obytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i) + 0x8);
 	}
 
 	hw->eth_stats_base.ipackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_FRAMES);
 
 	hw->eth_stats_base.ibytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_OCTETS);
 
 	hw->eth_stats_base.opackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_FRAMES);
 
 	hw->eth_stats_base.obytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_OCTETS);
 
 	/* Reading general device stats */
 	hw->eth_stats_base.ierrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_ERRORS);
 
 	hw->eth_stats_base.oerrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_ERRORS);
 
 	/* RX ring mbuf allocation failures */
 	dev->data->rx_mbuf_alloc_failed = 0;
 
 	hw->eth_stats_base.imissed =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_DISCARDS);
 
 	return 0;
 }
@@ -1012,7 +1013,7 @@ nfp_net_xstats_value(const struct rte_eth_dev *dev,
 	if (xstat.group == NFP_XSTAT_GROUP_MAC)
 		value = nn_readq(hw->mac_stats + xstat.offset);
 	else
-		value = nn_cfg_readq(hw, xstat.offset);
+		value = nn_cfg_readq(&hw->super, xstat.offset);
 
 	if (raw)
 		return value;
@@ -1320,8 +1321,8 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 	hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
 	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
 
-	hw->max_rx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_RXRINGS);
-	hw->max_tx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_TXRINGS);
+	hw->max_rx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_RXRINGS);
+	hw->max_tx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_TXRINGS);
 	if (hw->max_rx_queues == 0 || hw->max_tx_queues == 0) {
 		PMD_INIT_LOG(ERR, "Device %s can not be used, there are no valid queue "
 				"pairs for use", pci_dev->name);
@@ -1336,9 +1337,9 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 		return -ENODEV;
 
 	/* Get some of the read-only fields from the config BAR */
-	hw->super.cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
-	hw->cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
-	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
+	hw->super.cap = nn_cfg_readl(&hw->super, NFP_NET_CFG_CAP);
+	hw->cap_ext = nn_cfg_readl(&hw->super, NFP_NET_CFG_CAP_WORD1);
+	hw->max_mtu = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_MTU);
 	hw->flbufsz = DEFAULT_FLBUF_SIZE;
 
 	nfp_net_init_metadata_format(hw);
@@ -1347,7 +1348,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, NFP_NET_CFG_RX_OFFSET_ADDR);
+		hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET_ADDR);
 
 	hw->super.ctrl = 0;
 	hw->stride_rx = stride;
@@ -1389,7 +1390,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev,
 	rte_wmb();
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id),
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id),
 			NFP_NET_CFG_ICR_UNMASKED);
 	return 0;
 }
@@ -1410,7 +1411,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev,
 	rte_wmb();
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX);
 
 	return 0;
 }
@@ -1457,7 +1458,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
 		/* If MSI-X auto-masking is used, clear the entry */
 		rte_intr_ack(pci_dev->intr_handle);
 	} else {
-		nn_cfg_writeb(hw, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX),
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX),
 				NFP_NET_CFG_ICR_UNMASKED);
 	}
 }
@@ -1539,7 +1540,7 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev,
 	}
 
 	/* Writing to configuration space */
-	nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_MTU, mtu);
 
 	hw->mtu = mtu;
 
@@ -1630,7 +1631,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 
 		/* If all 4 entries were set, don't need read RETA register */
 		if (mask != 0xF)
-			reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + i);
+			reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + i);
 
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
@@ -1643,7 +1644,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 			reta |= reta_conf[idx].reta[shift + j] << (8 * j);
 		}
 
-		nn_cfg_writel(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
 	}
 
 	return 0;
@@ -1713,7 +1714,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 		if (mask == 0)
 			continue;
 
-		reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
+		reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
 				continue;
@@ -1741,7 +1742,7 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	/* Writing the key byte by byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
 		memcpy(&key, &rss_conf->rss_key[i], 1);
-		nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY + i, key);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY + i, key);
 	}
 
 	rss_hf = rss_conf->rss_hf;
@@ -1774,10 +1775,10 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
-	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
 
 	/* Writing the key size */
-	nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
 
 	return 0;
 }
@@ -1835,7 +1836,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
-	cfg_rss_ctrl = nn_cfg_readl(hw, NFP_NET_CFG_RSS_CTRL);
+	cfg_rss_ctrl = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_CTRL);
 
 	if ((cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4) != 0)
 		rss_hf |= RTE_ETH_RSS_IPV4;
@@ -1865,11 +1866,11 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	rss_conf->rss_hf = rss_hf;
 
 	/* Reading the key size */
-	rss_conf->rss_key_len = nn_cfg_readl(hw, NFP_NET_CFG_RSS_KEY_SZ);
+	rss_conf->rss_key_len = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_KEY_SZ);
 
 	/* Reading the key byte a byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
-		key = nn_cfg_readb(hw, NFP_NET_CFG_RSS_KEY + i);
+		key = nn_cfg_readb(&hw->super, NFP_NET_CFG_RSS_KEY + i);
 		memcpy(&rss_conf->rss_key[i], &key, 1);
 	}
 
@@ -1983,13 +1984,13 @@ nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
 	hw->vxlan_ports[idx] = port;
 
 	for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) {
-		nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
 				(hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]);
 	}
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
 	rte_wmb();
 
 	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN);
@@ -2048,7 +2049,7 @@ nfp_net_cfg_read_version(struct nfp_net_hw *hw)
 		struct nfp_net_fw_ver split;
 	} version;
 
-	version.whole = nn_cfg_readl(hw, NFP_NET_CFG_VERSION);
+	version.whole = nn_cfg_readl(&hw->super, NFP_NET_CFG_VERSION);
 	hw->ver = version.split;
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 375e26bfc2..6576769214 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -246,63 +246,63 @@ nn_writeq(uint64_t val,
 }
 
 static inline uint8_t
-nn_cfg_readb(struct nfp_net_hw *hw,
+nn_cfg_readb(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return nn_readb(hw->super.ctrl_bar + off);
+	return nn_readb(hw->ctrl_bar + off);
 }
 
 static inline void
-nn_cfg_writeb(struct nfp_net_hw *hw,
+nn_cfg_writeb(struct nfp_hw *hw,
 		uint32_t off,
 		uint8_t val)
 {
-	nn_writeb(val, hw->super.ctrl_bar + off);
+	nn_writeb(val, hw->ctrl_bar + off);
 }
 
 static inline uint16_t
-nn_cfg_readw(struct nfp_net_hw *hw,
+nn_cfg_readw(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_16(nn_readw(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writew(struct nfp_net_hw *hw,
+nn_cfg_writew(struct nfp_hw *hw,
 		uint32_t off,
 		uint16_t val)
 {
-	nn_writew(rte_cpu_to_le_16(val), hw->super.ctrl_bar + off);
+	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
 }
 
 static inline uint32_t
-nn_cfg_readl(struct nfp_net_hw *hw,
+nn_cfg_readl(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_32(nn_readl(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writel(struct nfp_net_hw *hw,
+nn_cfg_writel(struct nfp_hw *hw,
 		uint32_t off,
 		uint32_t val)
 {
-	nn_writel(rte_cpu_to_le_32(val), hw->super.ctrl_bar + off);
+	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
 }
 
 static inline uint64_t
-nn_cfg_readq(struct nfp_net_hw *hw,
+nn_cfg_readq(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_64(nn_readq(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writeq(struct nfp_net_hw *hw,
+nn_cfg_writeq(struct nfp_hw *hw,
 		uint32_t off,
 		uint64_t val)
 {
-	nn_writeq(rte_cpu_to_le_64(val), hw->super.ctrl_bar + off);
+	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
 }
 
 /**
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index a9dd464a6a..f17cc13cc1 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -925,8 +925,8 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the RX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 10/25] net/nfp: change the parameter of reconfig
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (8 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 09/25] net/nfp: change the parameter of APIs Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 11/25] net/nfp: extract the MAC address data field Chaoyong He
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'reconfig_lock' data field into the super class, also change
the parameter of the related APIs, 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 |  50 +++++----
 drivers/net/nfp/nfp_ethdev.c        |  32 +++---
 drivers/net/nfp/nfp_ethdev_vf.c     |  20 ++--
 drivers/net/nfp/nfp_net_common.c    | 155 +++++++++++++++-------------
 drivers/net/nfp/nfp_net_common.h    |   5 +-
 5 files changed, 144 insertions(+), 118 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 0fc1342740..a68b63f4ee 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -52,27 +52,29 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 {
 	uint32_t update;
 	uint32_t new_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	net_hw = repr->app_fw_flower->pf_hw;
+	hw = &net_hw->super;
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if (hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG)
+	if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) < 0)
 		return;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 }
 
 int
@@ -80,13 +82,15 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	net_hw = repr->app_fw_flower->pf_hw;
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_pf_repr_disable_queues(dev);
@@ -97,11 +101,11 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	update |= NFP_NET_CFG_UPDATE_RSS;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS2) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS2;
 	else
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS;
@@ -111,19 +115,19 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
 
 	/* If an error when reconfig we avoid to change hw state */
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to reconfig PF vnic");
 		return -EIO;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
@@ -376,7 +380,7 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw,
 			vnic_type, hw->max_rx_queues, hw->max_tx_queues);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	return 0;
 }
@@ -692,14 +696,16 @@ nfp_flower_cleanup_ctrl_vnic(struct nfp_net_hw *hw)
 }
 
 static int
-nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
+nfp_flower_start_ctrl_vnic(struct nfp_net_hw *net_hw)
 {
 	int ret;
 	uint32_t update;
 	uint32_t new_ctrl;
+	struct nfp_hw *hw;
 	struct rte_eth_dev *dev;
 
-	dev = hw->eth_dev;
+	dev = net_hw->eth_dev;
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_net_disable_queues(dev);
@@ -708,7 +714,7 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 	nfp_net_enable_queues(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	new_ctrl = NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
@@ -717,13 +723,13 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 	rte_wmb();
 
 	/* If an error when reconfig we avoid to change hw state */
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to reconfig ctrl vnic");
 		return -EIO;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 6a4455e50f..2f8df1c936 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -45,12 +45,13 @@ nfp_net_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	uint32_t cap_extend;
 	uint32_t intr_vector;
-	struct nfp_net_hw *hw;
 	uint32_t ctrl_extend = 0;
+	struct nfp_net_hw *net_hw;
 	struct nfp_pf_dev *pf_dev;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
@@ -58,9 +59,10 @@ 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;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_net_disable_queues(dev);
@@ -100,9 +102,9 @@ nfp_net_start(struct rte_eth_dev *dev)
 	}
 
 	/* Checking MTU set */
-	if (dev->data->mtu > hw->flbufsz) {
+	if (dev->data->mtu > net_hw->flbufsz) {
 		PMD_INIT_LOG(ERR, "MTU (%u) can't be larger than the current NFP_FRAME_SIZE (%u)",
-				dev->data->mtu, hw->flbufsz);
+				dev->data->mtu, net_hw->flbufsz);
 		return -ERANGE;
 	}
 
@@ -111,7 +113,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	dev_conf = &dev->data->dev_conf;
 	rxmode = &dev_conf->rxmode;
@@ -119,7 +121,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
 	}
 
 	/* Enable device */
@@ -128,19 +130,19 @@ nfp_net_start(struct rte_eth_dev *dev)
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
 	/* Enable vxlan */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
+	if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
 		new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
 		update |= NFP_NET_CFG_UPDATE_VXLAN;
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/* Enable packet type offload by extend ctrl word1. */
-	cap_extend = hw->cap_ext;
+	cap_extend = net_hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
 		ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
 
@@ -149,7 +151,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 				| NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
-	if (nfp_net_ext_reconfig(hw, ctrl_extend, update) != 0)
+	if (nfp_net_ext_reconfig(net_hw, ctrl_extend, update) != 0)
 		return -EIO;
 
 	/*
@@ -163,11 +165,11 @@ nfp_net_start(struct rte_eth_dev *dev)
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		/* Configure the physical port up */
-		nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 1);
+		nfp_eth_set_configured(net_hw->cpp, net_hw->nfp_idx, 1);
 	else
-		nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 1);
+		nfp_eth_set_configured(dev->process_private, net_hw->nfp_idx, 1);
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
@@ -586,7 +588,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 7fb2a3d378..6ead7e02b8 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -32,10 +32,11 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	uint32_t intr_vector;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
@@ -77,8 +78,9 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nfp_net_params_setup(hw);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+	nfp_net_params_setup(net_hw);
 
 	dev_conf = &dev->data->dev_conf;
 	rxmode = &dev_conf->rxmode;
@@ -86,7 +88,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
 	}
 
 	/* Enable device */
@@ -94,11 +96,11 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/*
@@ -110,7 +112,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
@@ -320,7 +322,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 4f830f2a2a..94d9072740 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -199,7 +199,7 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 #define FW_VER_LEN        32
 
 static int
-__nfp_net_reconfig(struct nfp_net_hw *hw,
+nfp_reconfig_real(struct nfp_hw *hw,
 		uint32_t update)
 {
 	uint32_t cnt;
@@ -207,14 +207,14 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 	struct timespec wait;
 
 	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->super.qcp_cfg);
+			hw->qcp_cfg);
 
-	if (hw->super.qcp_cfg == NULL) {
+	if (hw->qcp_cfg == NULL) {
 		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
 		return -ENXIO;
 	}
 
-	nfp_qcp_ptr_add(hw->super.qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
 
 	wait.tv_sec = 0;
 	wait.tv_nsec = 1000000; /* 1ms */
@@ -223,7 +223,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	/* Poll update field, waiting for NFP to ack the config */
 	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(&hw->super, NFP_NET_CFG_UPDATE);
+		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
 		if (new == 0)
 			break;
 
@@ -263,7 +263,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure the device.
  */
 int
-nfp_net_reconfig(struct nfp_net_hw *hw,
+nfp_reconfig(struct nfp_hw *hw,
 		uint32_t ctrl,
 		uint32_t update)
 {
@@ -271,12 +271,12 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, update);
+	ret = nfp_reconfig_real(hw, update);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
@@ -313,16 +313,16 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
 {
 	int ret;
 
-	rte_spinlock_lock(&hw->reconfig_lock);
+	rte_spinlock_lock(&hw->super.reconfig_lock);
 
 	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
 	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, update);
+	ret = nfp_reconfig_real(&hw->super, update);
 
-	rte_spinlock_unlock(&hw->reconfig_lock);
+	rte_spinlock_unlock(&hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net ext reconfig: ctrl_ext=%#08x update=%#08x",
@@ -354,16 +354,16 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 
 	mbox = hw->tlv_caps.mbox_off;
 
-	rte_spinlock_lock(&hw->reconfig_lock);
+	rte_spinlock_lock(&hw->super.reconfig_lock);
 
 	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
 	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_MBOX);
+	ret = nfp_reconfig_real(&hw->super, NFP_NET_CFG_UPDATE_MBOX);
 
-	rte_spinlock_unlock(&hw->reconfig_lock);
+	rte_spinlock_unlock(&hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net mailbox reconfig: mbox=%#08x update=%#08x",
@@ -494,26 +494,28 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 {
 	uint32_t update;
 	uint32_t new_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 }
 
 void
@@ -551,26 +553,28 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 {
 	uint32_t ctrl;
 	uint32_t update;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
+	nfp_net_write_mac(net_hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
-	ctrl = hw->super.ctrl;
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
+	ctrl = hw->ctrl;
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
 	/* Signal the NIC about the change */
-	if (nfp_net_reconfig(hw, ctrl, update) != 0) {
+	if (nfp_reconfig(hw, ctrl, update) != 0) {
 		PMD_DRV_LOG(ERR, "MAC address update failed");
 		return -EIO;
 	}
@@ -689,36 +693,38 @@ int
 nfp_net_promisc_enable(struct rte_eth_dev *dev)
 {
 	int ret;
+	uint32_t update;
 	uint32_t new_ctrl;
-	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
 		repr = dev->data->dev_private;
-		hw = repr->app_fw_flower->pf_hw;
+		net_hw = repr->app_fw_flower->pf_hw;
 	} else {
-		hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+		net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	hw = &net_hw->super;
+	if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(ERR, "Promiscuous mode not supported");
 		return -ENOTSUP;
 	}
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already enabled");
 		return 0;
 	}
 
-	new_ctrl = hw->super.ctrl | NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -727,25 +733,27 @@ int
 nfp_net_promisc_disable(struct rte_eth_dev *dev)
 {
 	int ret;
+	uint32_t update;
 	uint32_t new_ctrl;
-	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already disabled");
 		return 0;
 	}
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1554,17 +1562,20 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 	int ret;
 	uint32_t update;
 	uint32_t new_ctrl;
+	struct nfp_hw *hw;
 	uint64_t rx_offload;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint32_t rxvlan_ctrl = 0;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
 	rx_offload = dev->data->dev_conf.rxmode.offloads;
-	new_ctrl = hw->super.ctrl;
+	new_ctrl = hw->ctrl;
 
 	/* VLAN stripping setting */
 	if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) {
-		nfp_net_enable_rxvlan_cap(hw, &rxvlan_ctrl);
+		nfp_net_enable_rxvlan_cap(net_hw, &rxvlan_ctrl);
 		if ((rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) != 0)
 			new_ctrl |= rxvlan_ctrl;
 		else
@@ -1579,16 +1590,16 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 			new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
-	if (new_ctrl == hw->super.ctrl)
+	if (new_ctrl == hw->ctrl)
 		return 0;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1658,10 +1669,13 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 {
 	int ret;
 	uint32_t update;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size);
@@ -1670,7 +1684,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
+	if (nfp_reconfig(hw, hw->ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1789,14 +1803,16 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 {
 	uint32_t update;
 	uint64_t rss_hf;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	rss_hf = rss_conf->rss_hf;
 
 	/* Checking if RSS is enabled */
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		if (rss_hf != 0) {
 			PMD_DRV_LOG(ERR, "RSS unsupported");
 			return -EINVAL;
@@ -1814,7 +1830,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
+	if (nfp_reconfig(hw, hw->ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1969,31 +1985,32 @@ nfp_net_close_tx_queue(struct rte_eth_dev *dev)
 }
 
 int
-nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
+nfp_net_set_vxlan_port(struct nfp_net_hw *net_hw,
 		size_t idx,
 		uint16_t port)
 {
 	int ret;
 	uint32_t i;
+	struct nfp_hw *hw = &net_hw->super;
 
 	if (idx >= NFP_NET_N_VXLAN_PORTS) {
 		PMD_DRV_LOG(ERR, "The idx value is out of range.");
 		return -ERANGE;
 	}
 
-	hw->vxlan_ports[idx] = port;
+	net_hw->vxlan_ports[idx] = port;
 
 	for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) {
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
-				(hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]);
+		nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
+				(net_hw->vxlan_ports[i + 1] << 16) | net_hw->vxlan_ports[i]);
 	}
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN);
+	ret = nfp_reconfig_real(hw, NFP_NET_CFG_UPDATE_VXLAN);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 6576769214..02ec854498 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -117,6 +117,7 @@ struct nfp_hw {
 	uint8_t *qcp_cfg;
 	uint32_t cap;
 	uint32_t ctrl;    /**< Current values for control */
+	rte_spinlock_t reconfig_lock;
 };
 
 struct nfp_net_hw {
@@ -149,8 +150,6 @@ struct nfp_net_hw {
 	uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
 	uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
 
-	rte_spinlock_t reconfig_lock;
-
 	uint32_t max_tx_queues;
 	uint32_t max_rx_queues;
 	uint16_t flbufsz;
@@ -367,7 +366,7 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 }
 
 /* Prototypes for common NFP functions */
-int nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update);
+int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
 int nfp_net_ext_reconfig(struct nfp_net_hw *hw, uint32_t ctrl_ext, uint32_t update);
 int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
 int nfp_net_configure(struct rte_eth_dev *dev);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 11/25] net/nfp: extract the MAC address data field
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (9 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 10/25] net/nfp: change the parameter of reconfig Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 12/25] net/nfp: rename parameter in related logic Chaoyong He
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'mac_addr' 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/nfp_ethdev.c     | 14 +++++++-------
 drivers/net/nfp/nfp_ethdev_vf.c  | 18 +++++++++---------
 drivers/net/nfp/nfp_net_common.c |  8 ++++----
 drivers/net/nfp/nfp_net_common.h |  5 ++---
 4 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 2f8df1c936..afa3a37763 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -33,7 +33,7 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic,
 
 	nfp_eth_table = nfp_eth_read_ports(app_fw_nic->pf_dev->cpp);
 
-	rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->mac_addr);
+	rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->super.mac_addr);
 
 	free(nfp_eth_table);
 
@@ -598,18 +598,18 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+	nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 
-	tmp_ether_addr = &hw->mac_addr;
+	tmp_ether_addr = &hw->super.mac_addr;
 	if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
 
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -620,7 +620,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			eth_dev->data->port_id, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
 
 	/* Registering LSC interrupt handler */
 	rte_intr_callback_register(pci_dev->intr_handle,
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 6ead7e02b8..dead6ca5ab 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -16,14 +16,14 @@
 #include "nfp_net_common.h"
 
 static void
-nfp_netvf_read_mac(struct nfp_net_hw *hw)
+nfp_netvf_read_mac(struct nfp_hw *hw)
 {
 	uint32_t tmp;
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
 	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR + 4));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
 	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
 }
 
@@ -332,16 +332,16 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(hw);
-	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
+	nfp_netvf_read_mac(&hw->super);
+	if (rte_is_valid_assigned_ether_addr(&hw->super.mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
 
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -352,7 +352,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			port, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		/* Registering LSC interrupt handler */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 94d9072740..cd199b1d4e 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -532,19 +532,19 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 }
 
 void
-nfp_net_write_mac(struct nfp_net_hw *hw,
+nfp_net_write_mac(struct nfp_hw *hw,
 		uint8_t *mac)
 {
 	uint32_t mac0;
 	uint16_t mac1;
 
 	mac0 = *(uint32_t *)mac;
-	nn_writel(rte_cpu_to_be_32(mac0), hw->super.ctrl_bar + NFP_NET_CFG_MACADDR);
+	nn_writel(rte_cpu_to_be_32(mac0), hw->ctrl_bar + NFP_NET_CFG_MACADDR);
 
 	mac += 4;
 	mac1 = *(uint16_t *)mac;
 	nn_writew(rte_cpu_to_be_16(mac1),
-			hw->super.ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
 }
 
 int
@@ -565,7 +565,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(net_hw, (uint8_t *)mac_addr);
+	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 02ec854498..02a5ffefd8 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -118,6 +118,7 @@ struct nfp_hw {
 	uint32_t cap;
 	uint32_t ctrl;    /**< Current values for control */
 	rte_spinlock_t reconfig_lock;
+	struct rte_ether_addr mac_addr;
 };
 
 struct nfp_net_hw {
@@ -158,8 +159,6 @@ struct nfp_net_hw {
 	uint16_t subsystem_device_id;
 	uint16_t subsystem_vendor_id;
 
-	struct rte_ether_addr mac_addr;
-
 	/** Records starting point for counters */
 	struct rte_eth_stats eth_stats_base;
 	struct rte_eth_xstat *eth_xstats_base;
@@ -375,7 +374,7 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac);
+void nfp_net_write_mac(struct nfp_hw *hw, uint8_t *mac);
 int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 		struct rte_intr_handle *intr_handle);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 12/25] net/nfp: rename parameter in related logic
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (10 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 11/25] net/nfp: extract the MAC address data field Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 13/25] drivers: add the common ctrl module Chaoyong He
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename parameter 'hw' into 'net_hw' in the related logic, to make the
name more accurate.

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        |  86 ++++++++++-----------
 drivers/net/nfp/nfp_ethdev_vf.c     |  62 ++++++++-------
 drivers/net/nfp/nfp_ipsec.c         |  82 ++++++++++----------
 drivers/net/nfp/nfp_net_common.c    | 116 ++++++++++++++++------------
 drivers/net/nfp/nfp_net_ctrl.c      |  14 ++--
 drivers/net/nfp/nfp_rxtx.c          |  16 ++--
 7 files changed, 200 insertions(+), 184 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index a68b63f4ee..89982b502c 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -25,18 +25,18 @@ static void
 nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 {
 	uint16_t i;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
 	uint64_t enabled_queues = 0;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	hw = &repr->app_fw_flower->pf_hw->super;
 
 	/* Enabling the required TX queues in the device */
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	enabled_queues = 0;
 
@@ -44,7 +44,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 static void
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index afa3a37763..c6147ef01e 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -478,11 +478,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	uint16_t port;
 	uint64_t rx_base;
 	uint64_t tx_base;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_pf_dev *pf_dev;
 	struct rte_pci_device *pci_dev;
 	struct nfp_app_fw_nic *app_fw_nic;
-	struct rte_ether_addr *tmp_ether_addr;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 
@@ -502,46 +502,47 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	 * Use PF array of physical ports to get pointer to
 	 * this specific port.
 	 */
-	hw = app_fw_nic->ports[port];
+	net_hw = app_fw_nic->ports[port];
+	hw = &net_hw->super;
 
 	PMD_INIT_LOG(DEBUG, "Working with physical port number: %hu, "
-			"NFP internal port number: %d", port, hw->nfp_idx);
+			"NFP internal port number: %d", port, net_hw->nfp_idx);
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-	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");
+	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;
 
-		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);
-		if (hw->mac_stats_bar == NULL) {
+		hw->ctrl_bar = pf_dev->ctrl_bar;
+		min_size = NFP_MAC_STATS_SIZE * net_hw->pf_dev->nfp_eth_table->max_index;
+		net_hw->mac_stats_bar = nfp_rtsym_map(net_hw->pf_dev->sym_tbl, "_mac_stats",
+				min_size, &net_hw->mac_stats_area);
+		if (net_hw->mac_stats_bar == NULL) {
 			PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for _mac_stats_bar");
 			return -EIO;
 		}
 
-		hw->mac_stats = hw->mac_stats_bar;
+		net_hw->mac_stats = net_hw->mac_stats_bar;
 	} else {
 		if (pf_dev->ctrl_bar == NULL)
 			return -ENODEV;
 
 		/* Use port offset in pf ctrl_bar for this ports control bar */
-		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);
+		hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ);
+		net_hw->mac_stats = app_fw_nic->ports[0]->mac_stats_bar +
+				(net_hw->nfp_idx * NFP_MAC_STATS_SIZE);
 	}
 
-	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->super.ctrl_bar);
-	PMD_INIT_LOG(DEBUG, "MAC stats: %p", hw->mac_stats);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "MAC stats: %p", net_hw->mac_stats);
 
-	err = nfp_net_common_init(pci_dev, hw);
+	err = nfp_net_common_init(pci_dev, net_hw);
 	if (err != 0)
 		return err;
 
@@ -557,38 +558,38 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 		return err;
 	}
 
-	nfp_net_ethdev_ops_mount(hw, eth_dev);
+	nfp_net_ethdev_ops_mount(net_hw, eth_dev);
 
-	hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *
+	net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *
 			nfp_net_xstats_size(eth_dev), 0);
-	if (hw->eth_xstats_base == NULL) {
+	if (net_hw->eth_xstats_base == NULL) {
 		PMD_INIT_LOG(ERR, "no memory for xstats base values on device %s!",
 				pci_dev->device.name);
 		return -ENOMEM;
 	}
 
 	/* Work out where in the BAR the queues start. */
-	tx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
-	rx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
+	tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	rx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
 
-	hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
-	hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
-	eth_dev->data->dev_private = hw;
+	net_hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
+	net_hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
+	eth_dev->data->dev_private = net_hw;
 
 	PMD_INIT_LOG(DEBUG, "ctrl_bar: %p, tx_bar: %p, rx_bar: %p",
-			hw->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->ctrl_bar, net_hw->tx_bar, net_hw->rx_bar);
 
-	nfp_net_cfg_queue_setup(hw);
-	hw->mtu = RTE_ETHER_MTU;
+	nfp_net_cfg_queue_setup(net_hw);
+	net_hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
-	nfp_net_log_device_information(hw);
+	nfp_net_log_device_information(net_hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->super.reconfig_lock);
+	rte_spinlock_init(&hw->reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
@@ -598,20 +599,19 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 
-	tmp_ether_addr = &hw->super.mac_addr;
-	if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) {
+	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
@@ -620,13 +620,13 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			eth_dev->data->port_id, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
 
 	/* Registering LSC interrupt handler */
 	rte_intr_callback_register(pci_dev->intr_handle,
 			nfp_net_dev_interrupt_handler, (void *)eth_dev);
 	/* Telling the firmware about the LSC interrupt entry */
-	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 	/* Recording current stats counters values */
 	nfp_net_stats_reset(eth_dev);
 
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index dead6ca5ab..049728d30c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -254,7 +254,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	int err;
 	uint16_t port;
 	uint32_t start_q;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint64_t tx_bar_off = 0;
 	uint64_t rx_bar_off = 0;
 	struct rte_pci_device *pci_dev;
@@ -269,22 +270,23 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		return -ENODEV;
 	}
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	hw->dev_info = dev_info;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw->dev_info = dev_info;
+	hw = &net_hw->super;
 
-	hw->super.ctrl_bar = pci_dev->mem_resource[0].addr;
-	if (hw->super.ctrl_bar == NULL) {
+	hw->ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->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->super.ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
 
-	err = nfp_net_common_init(pci_dev, hw);
+	err = nfp_net_common_init(pci_dev, net_hw);
 	if (err != 0)
 		return err;
 
-	nfp_netvf_ethdev_ops_mount(hw, eth_dev);
+	nfp_netvf_ethdev_ops_mount(net_hw, eth_dev);
 
 	/* For secondary processes, the primary has done all the work */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -292,37 +294,37 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-	hw->eth_xstats_base = rte_malloc("rte_eth_xstat",
+	net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat",
 			sizeof(struct rte_eth_xstat) * nfp_net_xstats_size(eth_dev), 0);
-	if (hw->eth_xstats_base == NULL) {
+	if (net_hw->eth_xstats_base == NULL) {
 		PMD_INIT_LOG(ERR, "No memory for xstats base values on device %s!",
 				pci_dev->device.name);
 		return -ENOMEM;
 	}
 
 	/* Work out where in the BAR the queues start. */
-	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
-	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
 
-	hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
-	hw->rx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + rx_bar_off;
+	net_hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
+	net_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->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->ctrl_bar, net_hw->tx_bar, net_hw->rx_bar);
 
-	nfp_net_cfg_queue_setup(hw);
-	hw->mtu = RTE_ETHER_MTU;
+	nfp_net_cfg_queue_setup(net_hw);
+	net_hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
-	nfp_net_log_device_information(hw);
+	nfp_net_log_device_information(net_hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->super.reconfig_lock);
+	rte_spinlock_init(&hw->reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
@@ -332,18 +334,18 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(&hw->super);
-	if (rte_is_valid_assigned_ether_addr(&hw->super.mac_addr) == 0) {
+	nfp_netvf_read_mac(hw);
+	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
@@ -352,14 +354,14 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			port, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		/* Registering LSC interrupt handler */
 		rte_intr_callback_register(pci_dev->intr_handle,
 				nfp_net_dev_interrupt_handler, (void *)eth_dev);
 		/* Telling the firmware about the LSC interrupt entry */
-		nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 		/* Recording current stats counters values */
 		nfp_net_stats_reset(eth_dev);
 	}
@@ -367,7 +369,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	return 0;
 
 dev_err_ctrl_map:
-		nfp_cpp_area_free(hw->ctrl_area);
+		nfp_cpp_area_free(net_hw->ctrl_area);
 
 	return err;
 }
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index db3b7492e1..37ea60884d 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -434,7 +434,7 @@ enum nfp_ipsec_df_type {
 };
 
 static int
-nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
+nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *net_hw,
 		struct nfp_ipsec_msg *msg)
 {
 	int ret;
@@ -445,9 +445,9 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	msg->rsp = NFP_IPSEC_CFG_MSG_OK;
 
 	for (i = 0; i < msg_size; i++)
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
+		nn_cfg_writel(&net_hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
 
-	ret = nfp_net_mbox_reconfig(hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
+	ret = nfp_net_mbox_reconfig(net_hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to IPsec reconfig mbox");
 		return ret;
@@ -459,7 +459,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	 * response. One example where the data is needed is for statistics.
 	 */
 	for (i = 0; i < msg_size; i++)
-		msg->raw[i] = nn_cfg_readl(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
+		msg->raw[i] = nn_cfg_readl(&net_hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
 
 	switch (msg->rsp) {
 	case NFP_IPSEC_CFG_MSG_OK:
@@ -577,10 +577,10 @@ nfp_aead_map(struct rte_eth_dev *eth_dev,
 	uint32_t device_id;
 	const char *iv_str;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 	offset = 0;
 
 	switch (aead->algo) {
@@ -665,10 +665,10 @@ nfp_cipher_map(struct rte_eth_dev *eth_dev,
 	uint32_t i;
 	uint32_t device_id;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 
 	switch (cipher->algo) {
 	case RTE_CRYPTO_CIPHER_NULL:
@@ -801,15 +801,15 @@ nfp_auth_map(struct rte_eth_dev *eth_dev,
 	uint8_t key_length;
 	uint32_t device_id;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
 	if (digest_length == 0) {
 		PMD_DRV_LOG(ERR, "Auth digest length is illegal!");
 		return -EINVAL;
 	}
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 	digest_length = digest_length << 3;
 
 	switch (auth->algo) {
@@ -1068,7 +1068,7 @@ nfp_crypto_create_session(void *device,
 {
 	int ret;
 	int sa_idx;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg msg;
 	struct rte_eth_dev *eth_dev;
 	struct nfp_ipsec_session *priv_session;
@@ -1082,14 +1082,14 @@ nfp_crypto_create_session(void *device,
 	sa_idx = -1;
 	eth_dev = device;
 	priv_session = SECURITY_GET_SESS_PRIV(session);
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-	if (hw->ipsec_data->sa_free_cnt == 0) {
+	if (net_hw->ipsec_data->sa_free_cnt == 0) {
 		PMD_DRV_LOG(ERR, "No space in SA table, spi: %d", conf->ipsec.spi);
 		return -EINVAL;
 	}
 
-	nfp_get_sa_entry(hw->ipsec_data, &sa_idx);
+	nfp_get_sa_entry(net_hw->ipsec_data, &sa_idx);
 
 	if (sa_idx < 0) {
 		PMD_DRV_LOG(ERR, "Failed to get SA entry!");
@@ -1105,7 +1105,7 @@ nfp_crypto_create_session(void *device,
 
 	msg.cmd = NFP_IPSEC_CFG_MSG_ADD_SA;
 	msg.sa_idx = sa_idx;
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &msg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to add SA to nic");
 		return -EINVAL;
@@ -1118,8 +1118,8 @@ nfp_crypto_create_session(void *device,
 	priv_session->dev = eth_dev;
 	priv_session->user_data = conf->userdata;
 
-	hw->ipsec_data->sa_free_cnt--;
-	hw->ipsec_data->sa_entries[sa_idx] = priv_session;
+	net_hw->ipsec_data->sa_free_cnt--;
+	net_hw->ipsec_data->sa_entries[sa_idx] = priv_session;
 
 	return 0;
 }
@@ -1156,19 +1156,19 @@ nfp_security_set_pkt_metadata(void *device,
 {
 	int offset;
 	uint64_t *sqn;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct rte_eth_dev *eth_dev;
 	struct nfp_ipsec_session *priv_session;
 
 	sqn = params;
 	eth_dev = device;
 	priv_session = SECURITY_GET_SESS_PRIV(session);
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
 	if (priv_session->ipsec.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
 		struct nfp_tx_ipsec_desc_msg *desc_md;
 
-		offset = hw->ipsec_data->pkt_dynfield_offset;
+		offset = net_hw->ipsec_data->pkt_dynfield_offset;
 		desc_md = RTE_MBUF_DYNFIELD(m, offset, struct nfp_tx_ipsec_desc_msg *);
 
 		if (priv_session->msg.ctrl_word.ext_seq != 0 && sqn != NULL) {
@@ -1223,7 +1223,7 @@ nfp_security_session_get_stats(void *device,
 		struct rte_security_stats *stats)
 {
 	int ret;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg msg;
 	struct rte_eth_dev *eth_dev;
 	struct ipsec_get_sa_stats *cfg_s;
@@ -1236,9 +1236,9 @@ nfp_security_session_get_stats(void *device,
 	memset(&msg, 0, sizeof(msg));
 	msg.cmd = NFP_IPSEC_CFG_MSG_GET_SA_STATS;
 	msg.sa_idx = priv_session->sa_index;
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &msg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to get SA stats");
 		return ret;
@@ -1284,22 +1284,22 @@ nfp_crypto_remove_sa(struct rte_eth_dev *eth_dev,
 {
 	int ret;
 	uint32_t sa_index;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg cfg;
 
 	sa_index = priv_session->sa_index;
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
 	cfg.cmd = NFP_IPSEC_CFG_MSG_INV_SA;
 	cfg.sa_idx = sa_index;
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &cfg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &cfg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to remove SA!");
 		return -EINVAL;
 	}
 
-	hw->ipsec_data->sa_free_cnt++;
-	hw->ipsec_data->sa_entries[sa_index] = NULL;
+	net_hw->ipsec_data->sa_free_cnt++;
+	net_hw->ipsec_data->sa_entries[sa_index] = NULL;
 
 	return 0;
 }
@@ -1377,12 +1377,12 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint32_t cap_extend;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_net_ipsec_data *data;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->cap_ext;
+	cap_extend = net_hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return 0;
@@ -1396,7 +1396,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 
 	data->pkt_dynfield_offset = -1;
 	data->sa_free_cnt = NFP_NET_IPSEC_MAX_SA_CNT;
-	hw->ipsec_data = data;
+	net_hw->ipsec_data = data;
 
 	ret = nfp_ipsec_ctx_create(dev, data);
 	if (ret != 0) {
@@ -1424,12 +1424,12 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 {
 	uint16_t i;
 	uint32_t cap_extend;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_session *priv_session;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->cap_ext;
+	cap_extend = net_hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return;
@@ -1437,17 +1437,17 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 
 	nfp_ipsec_ctx_destroy(dev);
 
-	if (hw->ipsec_data == NULL) {
+	if (net_hw->ipsec_data == NULL) {
 		PMD_INIT_LOG(INFO, "IPsec data is NULL!");
 		return;
 	}
 
 	for (i = 0; i < NFP_NET_IPSEC_MAX_SA_CNT; i++) {
-		priv_session = hw->ipsec_data->sa_entries[i];
+		priv_session = net_hw->ipsec_data->sa_entries[i];
 		if (priv_session != NULL)
 			memset(priv_session, 0, sizeof(struct nfp_ipsec_session));
 	}
 
-	rte_free(hw->ipsec_data);
+	rte_free(net_hw->ipsec_data);
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index cd199b1d4e..22222a9773 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -295,7 +295,7 @@ nfp_reconfig(struct nfp_hw *hw,
  * Write the update word to the BAR and ping the reconfig queue. Then poll
  * until the firmware has acknowledged the update by zeroing the update word.
  *
- * @param hw
+ * @param net_hw
  *   Device to reconfigure.
  * @param ctrl_ext
  *   The value for the first word of extend ctrl field in the BAR config.
@@ -307,22 +307,22 @@ nfp_reconfig(struct nfp_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure the device.
  */
 int
-nfp_net_ext_reconfig(struct nfp_net_hw *hw,
+nfp_net_ext_reconfig(struct nfp_net_hw *net_hw,
 		uint32_t ctrl_ext,
 		uint32_t update)
 {
 	int ret;
 
-	rte_spinlock_lock(&hw->super.reconfig_lock);
+	rte_spinlock_lock(&net_hw->super.reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(&net_hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(&net_hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
-	ret = nfp_reconfig_real(&hw->super, update);
+	ret = nfp_reconfig_real(&net_hw->super, update);
 
-	rte_spinlock_unlock(&hw->super.reconfig_lock);
+	rte_spinlock_unlock(&net_hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net ext reconfig: ctrl_ext=%#08x update=%#08x",
@@ -336,7 +336,7 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
 /**
  * Reconfigure the firmware via the mailbox
  *
- * @param hw
+ * @param net_hw
  *   Device to reconfigure
  * @param mbox_cmd
  *   The value for the mailbox command
@@ -346,24 +346,24 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure by the mailbox
  */
 int
-nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
+nfp_net_mbox_reconfig(struct nfp_net_hw *net_hw,
 		uint32_t mbox_cmd)
 {
 	int ret;
 	uint32_t mbox;
 
-	mbox = hw->tlv_caps.mbox_off;
+	mbox = net_hw->tlv_caps.mbox_off;
 
-	rte_spinlock_lock(&hw->super.reconfig_lock);
+	rte_spinlock_lock(&net_hw->super.reconfig_lock);
 
-	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
+	nn_cfg_writeq(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
+	nn_cfg_writel(&net_hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
-	ret = nfp_reconfig_real(&hw->super, NFP_NET_CFG_UPDATE_MBOX);
+	ret = nfp_reconfig_real(&net_hw->super, NFP_NET_CFG_UPDATE_MBOX);
 
-	rte_spinlock_unlock(&hw->super.reconfig_lock);
+	rte_spinlock_unlock(&net_hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net mailbox reconfig: mbox=%#08x update=%#08x",
@@ -371,7 +371,7 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 		return -EIO;
 	}
 
-	return nn_cfg_readl(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
+	return nn_cfg_readl(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
 }
 
 /*
@@ -625,6 +625,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 uint32_t
 nfp_check_offloads(struct rte_eth_dev *dev)
 {
+	uint32_t cap;
 	uint32_t ctrl = 0;
 	uint64_t rx_offload;
 	uint64_t tx_offload;
@@ -632,13 +633,14 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	struct rte_eth_conf *dev_conf;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	cap = hw->super.cap;
 
 	dev_conf = &dev->data->dev_conf;
 	rx_offload = dev_conf->rxmode.offloads;
 	tx_offload = dev_conf->txmode.offloads;
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXCSUM;
 	}
 
@@ -646,25 +648,25 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 		nfp_net_enable_rxvlan_cap(hw, &ctrl);
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
 	hw->mtu = dev->data->mtu;
 
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2;
-		else if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
+		else if ((cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
 	}
 
 	/* L2 broadcast */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2BC) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_L2BC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2BC;
 
 	/* L2 multicast */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2MC) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_L2MC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2MC;
 
 	/* TX checksum offload */
@@ -676,7 +678,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	/* LSO offload */
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 ||
 			(tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_LSO) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_LSO;
 		else
 			ctrl |= NFP_NET_CFG_CTRL_LSO2;
@@ -1194,6 +1196,7 @@ nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
 int
 nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
+	uint32_t cap;
 	uint32_t cap_extend;
 	uint16_t min_rx_desc;
 	uint16_t max_rx_desc;
@@ -1224,32 +1227,34 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
-	if ((hw->super.cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
+	cap = hw->super.cap;
+
+	if ((cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->super.cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
+	if ((cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
 		dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
+	if ((cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
 			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_GATHER) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_GATHER) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	cap_extend = hw->cap_ext;
@@ -1292,7 +1297,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG,
 	};
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+	if ((cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
 		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
@@ -1615,9 +1620,11 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 	uint8_t mask;
 	uint32_t reta;
 	uint16_t shift;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
 		PMD_DRV_LOG(ERR, "The size of hash lookup table configured (%hu)"
@@ -1642,7 +1649,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 
 		/* If all 4 entries were set, don't need read RETA register */
 		if (mask != 0xF)
-			reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + i);
+			reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + i);
 
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
@@ -1655,7 +1662,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 			reta |= reta_conf[idx].reta[shift + j] << (8 * j);
 		}
 
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
+		nn_cfg_writel(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
 	}
 
 	return 0;
@@ -1702,10 +1709,13 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 	uint8_t mask;
 	uint32_t reta;
 	uint16_t shift;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
@@ -1728,7 +1738,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 		if (mask == 0)
 			continue;
 
-		reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
+		reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
 				continue;
@@ -1748,15 +1758,17 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	uint8_t i;
 	uint8_t key;
 	uint64_t rss_hf;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint32_t cfg_rss_ctrl = 0;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	/* Writing the key byte by byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
 		memcpy(&key, &rss_conf->rss_key[i], 1);
-		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY + i, key);
+		nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY + i, key);
 	}
 
 	rss_hf = rss_conf->rss_hf;
@@ -1789,10 +1801,10 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
 
 	/* Writing the key size */
-	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
+	nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
 
 	return 0;
 }
@@ -1843,16 +1855,18 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	uint8_t i;
 	uint8_t key;
 	uint64_t rss_hf;
+	struct nfp_hw *hw;
 	uint32_t cfg_rss_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
-	cfg_rss_ctrl = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_CTRL);
+	cfg_rss_ctrl = nn_cfg_readl(hw, NFP_NET_CFG_RSS_CTRL);
 
 	if ((cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4) != 0)
 		rss_hf |= RTE_ETH_RSS_IPV4;
@@ -1882,11 +1896,11 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	rss_conf->rss_hf = rss_hf;
 
 	/* Reading the key size */
-	rss_conf->rss_key_len = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_KEY_SZ);
+	rss_conf->rss_key_len = nn_cfg_readl(hw, NFP_NET_CFG_RSS_KEY_SZ);
 
 	/* Reading the key byte a byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
-		key = nn_cfg_readb(&hw->super, NFP_NET_CFG_RSS_KEY + i);
+		key = nn_cfg_readb(hw, NFP_NET_CFG_RSS_KEY + i);
 		memcpy(&rss_conf->rss_key[i], &key, 1);
 	}
 
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index d469896a64..8848fa38fe 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -29,15 +29,15 @@ nfp_net_tlv_caps_parse(struct rte_eth_dev *dev)
 	uint32_t length;
 	uint32_t offset;
 	uint32_t tlv_type;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_net_tlv_caps *caps;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	caps = &hw->tlv_caps;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	caps = &net_hw->tlv_caps;
 	nfp_net_tlv_caps_reset(caps);
 
-	data = hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
-	end = hw->super.ctrl_bar + NFP_NET_CFG_BAR_SZ;
+	data = net_hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
+	end = net_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->super.ctrl_bar;
+		offset = data - net_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->super.ctrl_bar;
+				caps->mbox_off = data - net_hw->super.ctrl_bar;
 			else
 				caps->mbox_off = 0;
 			break;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index f17cc13cc1..fc94e5f0b9 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -336,10 +336,10 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 		struct nfp_net_rxq *rxq,
 		struct rte_mbuf *mb)
 {
-	struct nfp_net_hw *hw = rxq->hw;
+	uint32_t ctrl = rxq->hw->super.ctrl;
 
-	/* Skip if firmware don't support setting vlan. */
-	if ((hw->super.ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
+	/* Skip if hardware don't support setting vlan. */
+	if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
 	/*
@@ -347,12 +347,12 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	 * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
 	 * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
 	 */
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+	if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
 		if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
 		}
-	} else if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+	} else if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
 		if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
@@ -383,10 +383,10 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 		struct nfp_net_rxq *rxq,
 		struct rte_mbuf *mb)
 {
-	struct nfp_net_hw *hw = rxq->hw;
+	struct nfp_hw *hw = &rxq->hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
-			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
 	if (meta->vlan_layer < NFP_META_MAX_VLANS)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 13/25] drivers: add the common ctrl module
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (11 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 12/25] net/nfp: rename parameter in related logic Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 14/25] drivers: add the nfp common module Chaoyong He
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the common ctrl module.

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/common/nfp/nfp_common_ctrl.h | 374 +++++++++++++++++++++++++++
 drivers/net/nfp/nfp_net_ctrl.h       | 365 +-------------------------
 2 files changed, 375 insertions(+), 364 deletions(-)
 create mode 100644 drivers/common/nfp/nfp_common_ctrl.h

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
new file mode 100644
index 0000000000..3c8cd916cf
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -0,0 +1,374 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_CTRL_H__
+#define __NFP_COMMON_CTRL_H__
+
+/*
+ * Configuration BAR size.
+ *
+ * On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
+ */
+#define NFP_NET_CFG_BAR_SZ              (32 * 1024)
+
+/* Offset in Freelist buffer where packet starts on RX */
+#define NFP_NET_RX_OFFSET               32
+
+/* Working with metadata api (NFD version > 3.0) */
+#define NFP_NET_META_FIELD_SIZE         4
+#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
+#define NFP_NET_META_HEADER_SIZE        4
+#define NFP_NET_META_NFDK_LENGTH        8
+
+/* Working with metadata vlan api (NFD version >= 2.0) */
+#define NFP_NET_META_VLAN_INFO          16
+#define NFP_NET_META_VLAN_OFFLOAD       31
+#define NFP_NET_META_VLAN_TPID          3
+#define NFP_NET_META_VLAN_MASK          ((1 << NFP_NET_META_VLAN_INFO) - 1)
+#define NFP_NET_META_VLAN_TPID_MASK     ((1 << NFP_NET_META_VLAN_TPID) - 1)
+#define NFP_NET_META_TPID(d)            (((d) >> NFP_NET_META_VLAN_INFO) & \
+						NFP_NET_META_VLAN_TPID_MASK)
+
+/* Prepend field types */
+#define NFP_NET_META_HASH               1 /* Next field carries hash type */
+#define NFP_NET_META_VLAN               4
+#define NFP_NET_META_PORTID             5
+#define NFP_NET_META_IPSEC              9
+
+#define NFP_META_PORT_ID_CTRL           ~0U
+
+/* Hash type prepended when a RSS hash was computed */
+#define NFP_NET_RSS_NONE                0
+#define NFP_NET_RSS_IPV4                1
+#define NFP_NET_RSS_IPV6                2
+#define NFP_NET_RSS_IPV6_EX             3
+#define NFP_NET_RSS_IPV4_TCP            4
+#define NFP_NET_RSS_IPV6_TCP            5
+#define NFP_NET_RSS_IPV6_EX_TCP         6
+#define NFP_NET_RSS_IPV4_UDP            7
+#define NFP_NET_RSS_IPV6_UDP            8
+#define NFP_NET_RSS_IPV6_EX_UDP         9
+#define NFP_NET_RSS_IPV4_SCTP           10
+#define NFP_NET_RSS_IPV6_SCTP           11
+
+/*
+ * @NFP_NET_TXR_MAX:         Maximum number of TX rings
+ * @NFP_NET_TXR_MASK:        Mask for TX rings
+ * @NFP_NET_RXR_MAX:         Maximum number of RX rings
+ * @NFP_NET_RXR_MASK:        Mask for RX rings
+ */
+#define NFP_NET_TXR_MAX                 64
+#define NFP_NET_TXR_MASK                (NFP_NET_TXR_MAX - 1)
+#define NFP_NET_RXR_MAX                 64
+#define NFP_NET_RXR_MASK                (NFP_NET_RXR_MAX - 1)
+
+/*
+ * Read/Write config words (0x0000 - 0x002c)
+ * @NFP_NET_CFG_CTRL:        Global control
+ * @NFP_NET_CFG_UPDATE:      Indicate which fields are updated
+ * @NFP_NET_CFG_TXRS_ENABLE: Bitmask of enabled TX rings
+ * @NFP_NET_CFG_RXRS_ENABLE: Bitmask of enabled RX rings
+ * @NFP_NET_CFG_MTU:         Set MTU size
+ * @NFP_NET_CFG_FLBUFSZ:     Set freelist buffer size (must be larger than MTU)
+ * @NFP_NET_CFG_EXN:         MSI-X table entry for exceptions
+ * @NFP_NET_CFG_LSC:         MSI-X table entry for link state changes
+ * @NFP_NET_CFG_MACADDR:     MAC address
+ *
+ * TODO:
+ * - define Error details in UPDATE
+ */
+#define NFP_NET_CFG_CTRL                0x0000
+#define   NFP_NET_CFG_CTRL_ENABLE         (0x1 <<  0) /* Global enable */
+#define   NFP_NET_CFG_CTRL_PROMISC        (0x1 <<  1) /* Enable Promisc mode */
+#define   NFP_NET_CFG_CTRL_L2BC           (0x1 <<  2) /* Allow L2 Broadcast */
+#define   NFP_NET_CFG_CTRL_L2MC           (0x1 <<  3) /* Allow L2 Multicast */
+#define   NFP_NET_CFG_CTRL_RXCSUM         (0x1 <<  4) /* Enable RX Checksum */
+#define   NFP_NET_CFG_CTRL_TXCSUM         (0x1 <<  5) /* Enable TX Checksum */
+#define   NFP_NET_CFG_CTRL_RXVLAN         (0x1 <<  6) /* Enable VLAN strip */
+#define   NFP_NET_CFG_CTRL_TXVLAN         (0x1 <<  7) /* Enable VLAN insert */
+#define   NFP_NET_CFG_CTRL_SCATTER        (0x1 <<  8) /* Scatter DMA */
+#define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
+#define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
+#define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
+#define   NFP_NET_CFG_CTRL_RXVLAN_V2      (0x1 << 15) /* Enable VLAN strip with metadata */
+#define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
+#define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
+#define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
+#define   NFP_NET_CFG_CTRL_RINGPRIO       (0x1 << 19) /* Ring priorities */
+#define   NFP_NET_CFG_CTRL_MSIXAUTO       (0x1 << 20) /* MSI-X auto-masking */
+#define   NFP_NET_CFG_CTRL_TXRWB          (0x1 << 21) /* Write-back of TX ring */
+#define   NFP_NET_CFG_CTRL_L2SWITCH       (0x1 << 22) /* L2 Switch */
+#define   NFP_NET_CFG_CTRL_TXVLAN_V2      (0x1 << 23) /* Enable VLAN insert with metadata */
+#define   NFP_NET_CFG_CTRL_VXLAN          (0x1 << 24) /* Enable VXLAN */
+#define   NFP_NET_CFG_CTRL_NVGRE          (0x1 << 25) /* Enable NVGRE */
+#define   NFP_NET_CFG_CTRL_MSIX_TX_OFF    (0x1 << 26) /* Disable MSIX for TX */
+#define   NFP_NET_CFG_CTRL_LSO2           (0x1 << 28) /* LSO/TSO (version 2) */
+#define   NFP_NET_CFG_CTRL_RSS2           (0x1 << 29) /* RSS (version 2) */
+#define   NFP_NET_CFG_CTRL_CSUM_COMPLETE  (0x1 << 30) /* Checksum complete */
+#define   NFP_NET_CFG_CTRL_LIVE_ADDR      (0x1U << 31) /* Live MAC addr change */
+#define NFP_NET_CFG_UPDATE              0x0004
+#define   NFP_NET_CFG_UPDATE_GEN          (0x1 <<  0) /* General update */
+#define   NFP_NET_CFG_UPDATE_RING         (0x1 <<  1) /* Ring config change */
+#define   NFP_NET_CFG_UPDATE_RSS          (0x1 <<  2) /* RSS config change */
+#define   NFP_NET_CFG_UPDATE_TXRPRIO      (0x1 <<  3) /* TX Ring prio change */
+#define   NFP_NET_CFG_UPDATE_RXRPRIO      (0x1 <<  4) /* RX Ring prio change */
+#define   NFP_NET_CFG_UPDATE_MSIX         (0x1 <<  5) /* MSI-X change */
+#define   NFP_NET_CFG_UPDATE_L2SWITCH     (0x1 <<  6) /* Switch changes */
+#define   NFP_NET_CFG_UPDATE_RESET        (0x1 <<  7) /* Update due to FLR */
+#define   NFP_NET_CFG_UPDATE_IRQMOD       (0x1 <<  8) /* IRQ mod change */
+#define   NFP_NET_CFG_UPDATE_VXLAN        (0x1 <<  9) /* VXLAN port change */
+#define   NFP_NET_CFG_UPDATE_MACADDR      (0x1 << 11) /* MAC address change */
+#define   NFP_NET_CFG_UPDATE_MBOX         (0x1 << 12) /* Mailbox update */
+#define   NFP_NET_CFG_UPDATE_ERR          (0x1U << 31) /* A error occurred */
+#define NFP_NET_CFG_TXRS_ENABLE         0x0008
+#define NFP_NET_CFG_RXRS_ENABLE         0x0010
+#define NFP_NET_CFG_MTU                 0x0018
+#define NFP_NET_CFG_FLBUFSZ             0x001c
+#define NFP_NET_CFG_EXN                 0x001f
+#define NFP_NET_CFG_LSC                 0x0020
+#define NFP_NET_CFG_MACADDR             0x0024
+
+#define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2)
+#define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2)
+
+#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \
+					NFP_NET_CFG_CTRL_CSUM_COMPLETE)
+
+/* Version number helper defines */
+struct nfp_net_fw_ver {
+	uint8_t minor;
+	uint8_t major;
+	uint8_t class;
+	/**
+	 * This byte can be extended for more use.
+	 * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx
+	 * BIT[7:1]: reserved
+	 */
+	uint8_t extend;
+};
+
+/*
+ * Read-only words (0x0030 - 0x0050):
+ * @NFP_NET_CFG_VERSION:     Firmware version number
+ * @NFP_NET_CFG_STS:         Status
+ * @NFP_NET_CFG_CAP:         Capabilities (same bits as @NFP_NET_CFG_CTRL)
+ * @NFP_NET_MAX_TXRINGS:     Maximum number of TX rings
+ * @NFP_NET_MAX_RXRINGS:     Maximum number of RX rings
+ * @NFP_NET_MAX_MTU:         Maximum support MTU
+ * @NFP_NET_CFG_START_TXQ:   Start Queue Control Queue to use for TX (PF only)
+ * @NFP_NET_CFG_START_RXQ:   Start Queue Control Queue to use for RX (PF only)
+ *
+ * TODO:
+ * - define more STS bits
+ */
+#define NFP_NET_CFG_VERSION             0x0030
+#define   NFP_NET_CFG_VERSION_DP_NFD3   0
+#define   NFP_NET_CFG_VERSION_DP_NFDK   1
+#define NFP_NET_CFG_STS                 0x0034
+#define   NFP_NET_CFG_STS_LINK            (0x1 << 0) /* Link up or down */
+/* Link rate */
+#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
+#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
+#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
+#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN       1
+#define   NFP_NET_CFG_STS_LINK_RATE_1G            2
+#define   NFP_NET_CFG_STS_LINK_RATE_10G           3
+#define   NFP_NET_CFG_STS_LINK_RATE_25G           4
+#define   NFP_NET_CFG_STS_LINK_RATE_40G           5
+#define   NFP_NET_CFG_STS_LINK_RATE_50G           6
+#define   NFP_NET_CFG_STS_LINK_RATE_100G          7
+
+/*
+ * NSP Link rate is a 16-bit word. It is no longer determined by
+ * firmware, instead it is read from the nfp_eth_table of the
+ * associated pf_dev and written to the NFP_NET_CFG_STS_NSP_LINK_RATE
+ * address by the PMD each time the port is reconfigured.
+ */
+#define NFP_NET_CFG_STS_NSP_LINK_RATE   0x0036
+
+#define NFP_NET_CFG_CAP                 0x0038
+#define NFP_NET_CFG_MAX_TXRINGS         0x003c
+#define NFP_NET_CFG_MAX_RXRINGS         0x0040
+#define NFP_NET_CFG_MAX_MTU             0x0044
+/* Next two words are being used by VFs for solving THB350 issue */
+#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
+ */
+#define NFP_NET_CFG_RX_OFFSET           0x0050
+#define NFP_NET_CFG_RX_OFFSET_DYNAMIC          0    /* Prepend mode */
+
+/* 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
+
+/* Offload definitions */
+#define NFP_NET_N_VXLAN_PORTS  (NFP_NET_CFG_VXLAN_SZ / sizeof(uint16_t))
+
+/*
+ * 3 words reserved for extended ctrl words (0x0098 - 0x00a4)
+ * 3 words reserved for extended cap words (0x00a4 - 0x00b0)
+ * Currently only one word is used, can be extended in future.
+ */
+#define NFP_NET_CFG_CTRL_WORD1          0x0098
+#define NFP_NET_CFG_CTRL_PKT_TYPE         (0x1 << 0)
+#define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
+#define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
+#define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
+
+#define NFP_NET_CFG_CAP_WORD1           0x00a4
+
+/* 16B reserved for future use (0x00b0 - 0x00c0). */
+#define NFP_NET_CFG_RESERVED            0x00b0
+#define NFP_NET_CFG_RESERVED_SZ         0x0010
+
+/*
+ * RSS configuration (0x0100 - 0x01ac):
+ * Used only when NFP_NET_CFG_CTRL_RSS_ANY is enabled
+ * @NFP_NET_CFG_RSS_CFG:     RSS configuration word
+ * @NFP_NET_CFG_RSS_KEY:     RSS "secret" key
+ * @NFP_NET_CFG_RSS_ITBL:    RSS indirection table
+ */
+#define NFP_NET_CFG_RSS_BASE            0x0100
+#define NFP_NET_CFG_RSS_CTRL            NFP_NET_CFG_RSS_BASE
+#define   NFP_NET_CFG_RSS_MASK            (0x7f)
+#define   NFP_NET_CFG_RSS_MASK_of(_x)     ((_x) & 0x7f)
+#define   NFP_NET_CFG_RSS_IPV4            (1 <<  8) /* RSS for IPv4 */
+#define   NFP_NET_CFG_RSS_IPV6            (1 <<  9) /* RSS for IPv6 */
+#define   NFP_NET_CFG_RSS_IPV4_TCP        (1 << 10) /* RSS for IPv4/TCP */
+#define   NFP_NET_CFG_RSS_IPV4_UDP        (1 << 11) /* RSS for IPv4/UDP */
+#define   NFP_NET_CFG_RSS_IPV6_TCP        (1 << 12) /* RSS for IPv6/TCP */
+#define   NFP_NET_CFG_RSS_IPV6_UDP        (1 << 13) /* RSS for IPv6/UDP */
+#define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
+#define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
+#define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
+#define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
+#define NFP_NET_CFG_RSS_KEY_SZ          0x28
+#define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
+					 NFP_NET_CFG_RSS_KEY_SZ)
+#define NFP_NET_CFG_RSS_ITBL_SZ         0x80
+
+/*
+ * TX ring configuration (0x200 - 0x800)
+ * @NFP_NET_CFG_TXR_BASE:    Base offset for TX ring configuration
+ * @NFP_NET_CFG_TXR_ADDR:    Per TX ring DMA address (8B entries)
+ * @NFP_NET_CFG_TXR_WB_ADDR: Per TX ring write back DMA address (8B entries)
+ * @NFP_NET_CFG_TXR_SZ:      Per TX ring size (1B entries)
+ * @NFP_NET_CFG_TXR_VEC:     Per TX ring MSI-X table entry (1B entries)
+ * @NFP_NET_CFG_TXR_PRIO:    Per TX ring priority (1B entries)
+ * @NFP_NET_CFG_TXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
+ */
+#define NFP_NET_CFG_TXR_BASE            0x0200
+#define NFP_NET_CFG_TXR_ADDR(_x)        (NFP_NET_CFG_TXR_BASE + ((_x) * 0x8))
+#define NFP_NET_CFG_TXR_WB_ADDR(_x)     (NFP_NET_CFG_TXR_BASE + 0x200 + \
+					 ((_x) * 0x8))
+#define NFP_NET_CFG_TXR_SZ(_x)          (NFP_NET_CFG_TXR_BASE + 0x400 + (_x))
+#define NFP_NET_CFG_TXR_VEC(_x)         (NFP_NET_CFG_TXR_BASE + 0x440 + (_x))
+#define NFP_NET_CFG_TXR_PRIO(_x)        (NFP_NET_CFG_TXR_BASE + 0x480 + (_x))
+#define NFP_NET_CFG_TXR_IRQ_MOD(_x)     (NFP_NET_CFG_TXR_BASE + 0x500 + \
+					 ((_x) * 0x4))
+
+/*
+ * RX ring configuration (0x0800 - 0x0c00)
+ * @NFP_NET_CFG_RXR_BASE:    Base offset for RX ring configuration
+ * @NFP_NET_CFG_RXR_ADDR:    Per TX ring DMA address (8B entries)
+ * @NFP_NET_CFG_RXR_SZ:      Per TX ring size (1B entries)
+ * @NFP_NET_CFG_RXR_VEC:     Per TX ring MSI-X table entry (1B entries)
+ * @NFP_NET_CFG_RXR_PRIO:    Per TX ring priority (1B entries)
+ * @NFP_NET_CFG_RXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
+ */
+#define NFP_NET_CFG_RXR_BASE            0x0800
+#define NFP_NET_CFG_RXR_ADDR(_x)        (NFP_NET_CFG_RXR_BASE + ((_x) * 0x8))
+#define NFP_NET_CFG_RXR_SZ(_x)          (NFP_NET_CFG_RXR_BASE + 0x200 + (_x))
+#define NFP_NET_CFG_RXR_VEC(_x)         (NFP_NET_CFG_RXR_BASE + 0x240 + (_x))
+#define NFP_NET_CFG_RXR_PRIO(_x)        (NFP_NET_CFG_RXR_BASE + 0x280 + (_x))
+#define NFP_NET_CFG_RXR_IRQ_MOD(_x)     (NFP_NET_CFG_RXR_BASE + 0x300 + \
+					 ((_x) * 0x4))
+
+/*
+ * Interrupt Control/Cause registers (0x0c00 - 0x0d00)
+ * These registers are only used when MSI-X auto-masking is not
+ * enabled (@NFP_NET_CFG_CTRL_MSIXAUTO not set).  The array is index
+ * by MSI-X entry and are 1B in size.  If an entry is zero, the
+ * corresponding entry is enabled.  If the FW generates an interrupt,
+ * it writes a cause into the corresponding field.  This also masks
+ * the MSI-X entry and the host driver must clear the register to
+ * re-enable the interrupt.
+ */
+#define NFP_NET_CFG_ICR_BASE            0x0c00
+#define NFP_NET_CFG_ICR(_x)             (NFP_NET_CFG_ICR_BASE + (_x))
+#define   NFP_NET_CFG_ICR_UNMASKED      0x0
+#define   NFP_NET_CFG_ICR_RXTX          0x1
+#define   NFP_NET_CFG_ICR_LSC           0x2
+
+/*
+ * General device stats (0x0d00 - 0x0d90)
+ * All counters are 64bit.
+ */
+#define NFP_NET_CFG_STATS_BASE          0x0d00
+#define NFP_NET_CFG_STATS_RX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x00)
+#define NFP_NET_CFG_STATS_RX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x08)
+#define NFP_NET_CFG_STATS_RX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x10)
+#define NFP_NET_CFG_STATS_RX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x18)
+#define NFP_NET_CFG_STATS_RX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x20)
+#define NFP_NET_CFG_STATS_RX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x28)
+#define NFP_NET_CFG_STATS_RX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x30)
+#define NFP_NET_CFG_STATS_RX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x38)
+#define NFP_NET_CFG_STATS_RX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x40)
+
+#define NFP_NET_CFG_STATS_TX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x48)
+#define NFP_NET_CFG_STATS_TX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x50)
+#define NFP_NET_CFG_STATS_TX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x58)
+#define NFP_NET_CFG_STATS_TX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x60)
+#define NFP_NET_CFG_STATS_TX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x68)
+#define NFP_NET_CFG_STATS_TX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x70)
+#define NFP_NET_CFG_STATS_TX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x78)
+#define NFP_NET_CFG_STATS_TX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x80)
+#define NFP_NET_CFG_STATS_TX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x88)
+
+#define NFP_NET_CFG_STATS_APP0_FRAMES   (NFP_NET_CFG_STATS_BASE + 0x90)
+#define NFP_NET_CFG_STATS_APP0_BYTES    (NFP_NET_CFG_STATS_BASE + 0x98)
+#define NFP_NET_CFG_STATS_APP1_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xa0)
+#define NFP_NET_CFG_STATS_APP1_BYTES    (NFP_NET_CFG_STATS_BASE + 0xa8)
+#define NFP_NET_CFG_STATS_APP2_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xb0)
+#define NFP_NET_CFG_STATS_APP2_BYTES    (NFP_NET_CFG_STATS_BASE + 0xb8)
+#define NFP_NET_CFG_STATS_APP3_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xc0)
+#define NFP_NET_CFG_STATS_APP3_BYTES    (NFP_NET_CFG_STATS_BASE + 0xc8)
+
+/*
+ * Per ring stats (0x1000 - 0x1800)
+ * Options, 64bit per entry
+ * @NFP_NET_CFG_TXR_STATS:   TX ring statistics (Packet and Byte count)
+ * @NFP_NET_CFG_RXR_STATS:   RX ring statistics (Packet and Byte count)
+ */
+#define NFP_NET_CFG_TXR_STATS_BASE      0x1000
+#define NFP_NET_CFG_TXR_STATS(_x)       (NFP_NET_CFG_TXR_STATS_BASE + \
+					 ((_x) * 0x10))
+#define NFP_NET_CFG_RXR_STATS_BASE      0x1400
+#define NFP_NET_CFG_RXR_STATS(_x)       (NFP_NET_CFG_RXR_STATS_BASE + \
+					 ((_x) * 0x10))
+
+#endif /* __NFP_COMMON_CTRL_H__ */
diff --git a/drivers/net/nfp/nfp_net_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
index 3772b28a66..ee1b784bb1 100644
--- a/drivers/net/nfp/nfp_net_ctrl.h
+++ b/drivers/net/nfp/nfp_net_ctrl.h
@@ -10,370 +10,7 @@
 
 #include <ethdev_driver.h>
 
-/*
- * Configuration BAR size.
- *
- * On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
- */
-#define NFP_NET_CFG_BAR_SZ              (32 * 1024)
-
-/* Offset in Freelist buffer where packet starts on RX */
-#define NFP_NET_RX_OFFSET               32
-
-/* Working with metadata api (NFD version > 3.0) */
-#define NFP_NET_META_FIELD_SIZE         4
-#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
-#define NFP_NET_META_HEADER_SIZE        4
-#define NFP_NET_META_NFDK_LENGTH        8
-
-/* Working with metadata vlan api (NFD version >= 2.0) */
-#define NFP_NET_META_VLAN_INFO          16
-#define NFP_NET_META_VLAN_OFFLOAD       31
-#define NFP_NET_META_VLAN_TPID          3
-#define NFP_NET_META_VLAN_MASK          ((1 << NFP_NET_META_VLAN_INFO) - 1)
-#define NFP_NET_META_VLAN_TPID_MASK     ((1 << NFP_NET_META_VLAN_TPID) - 1)
-#define NFP_NET_META_TPID(d)            (((d) >> NFP_NET_META_VLAN_INFO) & \
-						NFP_NET_META_VLAN_TPID_MASK)
-
-/* Prepend field types */
-#define NFP_NET_META_HASH               1 /* Next field carries hash type */
-#define NFP_NET_META_VLAN               4
-#define NFP_NET_META_PORTID             5
-#define NFP_NET_META_IPSEC              9
-
-#define NFP_META_PORT_ID_CTRL           ~0U
-
-/* Hash type prepended when a RSS hash was computed */
-#define NFP_NET_RSS_NONE                0
-#define NFP_NET_RSS_IPV4                1
-#define NFP_NET_RSS_IPV6                2
-#define NFP_NET_RSS_IPV6_EX             3
-#define NFP_NET_RSS_IPV4_TCP            4
-#define NFP_NET_RSS_IPV6_TCP            5
-#define NFP_NET_RSS_IPV6_EX_TCP         6
-#define NFP_NET_RSS_IPV4_UDP            7
-#define NFP_NET_RSS_IPV6_UDP            8
-#define NFP_NET_RSS_IPV6_EX_UDP         9
-#define NFP_NET_RSS_IPV4_SCTP           10
-#define NFP_NET_RSS_IPV6_SCTP           11
-
-/*
- * @NFP_NET_TXR_MAX:         Maximum number of TX rings
- * @NFP_NET_TXR_MASK:        Mask for TX rings
- * @NFP_NET_RXR_MAX:         Maximum number of RX rings
- * @NFP_NET_RXR_MASK:        Mask for RX rings
- */
-#define NFP_NET_TXR_MAX                 64
-#define NFP_NET_TXR_MASK                (NFP_NET_TXR_MAX - 1)
-#define NFP_NET_RXR_MAX                 64
-#define NFP_NET_RXR_MASK                (NFP_NET_RXR_MAX - 1)
-
-/*
- * Read/Write config words (0x0000 - 0x002c)
- * @NFP_NET_CFG_CTRL:        Global control
- * @NFP_NET_CFG_UPDATE:      Indicate which fields are updated
- * @NFP_NET_CFG_TXRS_ENABLE: Bitmask of enabled TX rings
- * @NFP_NET_CFG_RXRS_ENABLE: Bitmask of enabled RX rings
- * @NFP_NET_CFG_MTU:         Set MTU size
- * @NFP_NET_CFG_FLBUFSZ:     Set freelist buffer size (must be larger than MTU)
- * @NFP_NET_CFG_EXN:         MSI-X table entry for exceptions
- * @NFP_NET_CFG_LSC:         MSI-X table entry for link state changes
- * @NFP_NET_CFG_MACADDR:     MAC address
- *
- * TODO:
- * - define Error details in UPDATE
- */
-#define NFP_NET_CFG_CTRL                0x0000
-#define   NFP_NET_CFG_CTRL_ENABLE         (0x1 <<  0) /* Global enable */
-#define   NFP_NET_CFG_CTRL_PROMISC        (0x1 <<  1) /* Enable Promisc mode */
-#define   NFP_NET_CFG_CTRL_L2BC           (0x1 <<  2) /* Allow L2 Broadcast */
-#define   NFP_NET_CFG_CTRL_L2MC           (0x1 <<  3) /* Allow L2 Multicast */
-#define   NFP_NET_CFG_CTRL_RXCSUM         (0x1 <<  4) /* Enable RX Checksum */
-#define   NFP_NET_CFG_CTRL_TXCSUM         (0x1 <<  5) /* Enable TX Checksum */
-#define   NFP_NET_CFG_CTRL_RXVLAN         (0x1 <<  6) /* Enable VLAN strip */
-#define   NFP_NET_CFG_CTRL_TXVLAN         (0x1 <<  7) /* Enable VLAN insert */
-#define   NFP_NET_CFG_CTRL_SCATTER        (0x1 <<  8) /* Scatter DMA */
-#define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
-#define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
-#define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
-#define   NFP_NET_CFG_CTRL_RXVLAN_V2      (0x1 << 15) /* Enable VLAN strip with metadata */
-#define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
-#define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
-#define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
-#define   NFP_NET_CFG_CTRL_RINGPRIO       (0x1 << 19) /* Ring priorities */
-#define   NFP_NET_CFG_CTRL_MSIXAUTO       (0x1 << 20) /* MSI-X auto-masking */
-#define   NFP_NET_CFG_CTRL_TXRWB          (0x1 << 21) /* Write-back of TX ring */
-#define   NFP_NET_CFG_CTRL_L2SWITCH       (0x1 << 22) /* L2 Switch */
-#define   NFP_NET_CFG_CTRL_TXVLAN_V2      (0x1 << 23) /* Enable VLAN insert with metadata */
-#define   NFP_NET_CFG_CTRL_VXLAN          (0x1 << 24) /* Enable VXLAN */
-#define   NFP_NET_CFG_CTRL_NVGRE          (0x1 << 25) /* Enable NVGRE */
-#define   NFP_NET_CFG_CTRL_MSIX_TX_OFF    (0x1 << 26) /* Disable MSIX for TX */
-#define   NFP_NET_CFG_CTRL_LSO2           (0x1 << 28) /* LSO/TSO (version 2) */
-#define   NFP_NET_CFG_CTRL_RSS2           (0x1 << 29) /* RSS (version 2) */
-#define   NFP_NET_CFG_CTRL_CSUM_COMPLETE  (0x1 << 30) /* Checksum complete */
-#define   NFP_NET_CFG_CTRL_LIVE_ADDR      (0x1U << 31) /* Live MAC addr change */
-#define NFP_NET_CFG_UPDATE              0x0004
-#define   NFP_NET_CFG_UPDATE_GEN          (0x1 <<  0) /* General update */
-#define   NFP_NET_CFG_UPDATE_RING         (0x1 <<  1) /* Ring config change */
-#define   NFP_NET_CFG_UPDATE_RSS          (0x1 <<  2) /* RSS config change */
-#define   NFP_NET_CFG_UPDATE_TXRPRIO      (0x1 <<  3) /* TX Ring prio change */
-#define   NFP_NET_CFG_UPDATE_RXRPRIO      (0x1 <<  4) /* RX Ring prio change */
-#define   NFP_NET_CFG_UPDATE_MSIX         (0x1 <<  5) /* MSI-X change */
-#define   NFP_NET_CFG_UPDATE_L2SWITCH     (0x1 <<  6) /* Switch changes */
-#define   NFP_NET_CFG_UPDATE_RESET        (0x1 <<  7) /* Update due to FLR */
-#define   NFP_NET_CFG_UPDATE_IRQMOD       (0x1 <<  8) /* IRQ mod change */
-#define   NFP_NET_CFG_UPDATE_VXLAN        (0x1 <<  9) /* VXLAN port change */
-#define   NFP_NET_CFG_UPDATE_MACADDR      (0x1 << 11) /* MAC address change */
-#define   NFP_NET_CFG_UPDATE_MBOX         (0x1 << 12) /* Mailbox update */
-#define   NFP_NET_CFG_UPDATE_ERR          (0x1U << 31) /* A error occurred */
-#define NFP_NET_CFG_TXRS_ENABLE         0x0008
-#define NFP_NET_CFG_RXRS_ENABLE         0x0010
-#define NFP_NET_CFG_MTU                 0x0018
-#define NFP_NET_CFG_FLBUFSZ             0x001c
-#define NFP_NET_CFG_EXN                 0x001f
-#define NFP_NET_CFG_LSC                 0x0020
-#define NFP_NET_CFG_MACADDR             0x0024
-
-#define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2)
-#define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2)
-
-#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \
-					NFP_NET_CFG_CTRL_CSUM_COMPLETE)
-
-/* Version number helper defines */
-struct nfp_net_fw_ver {
-	uint8_t minor;
-	uint8_t major;
-	uint8_t class;
-	/**
-	 * This byte can be extended for more use.
-	 * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx
-	 * BIT[7:1]: reserved
-	 */
-	uint8_t extend;
-};
-
-/*
- * Read-only words (0x0030 - 0x0050):
- * @NFP_NET_CFG_VERSION:     Firmware version number
- * @NFP_NET_CFG_STS:         Status
- * @NFP_NET_CFG_CAP:         Capabilities (same bits as @NFP_NET_CFG_CTRL)
- * @NFP_NET_MAX_TXRINGS:     Maximum number of TX rings
- * @NFP_NET_MAX_RXRINGS:     Maximum number of RX rings
- * @NFP_NET_MAX_MTU:         Maximum support MTU
- * @NFP_NET_CFG_START_TXQ:   Start Queue Control Queue to use for TX (PF only)
- * @NFP_NET_CFG_START_RXQ:   Start Queue Control Queue to use for RX (PF only)
- *
- * TODO:
- * - define more STS bits
- */
-#define NFP_NET_CFG_VERSION             0x0030
-#define   NFP_NET_CFG_VERSION_DP_NFD3   0
-#define   NFP_NET_CFG_VERSION_DP_NFDK   1
-#define NFP_NET_CFG_STS                 0x0034
-#define   NFP_NET_CFG_STS_LINK            (0x1 << 0) /* Link up or down */
-/* Link rate */
-#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
-#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
-#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
-#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN       1
-#define   NFP_NET_CFG_STS_LINK_RATE_1G            2
-#define   NFP_NET_CFG_STS_LINK_RATE_10G           3
-#define   NFP_NET_CFG_STS_LINK_RATE_25G           4
-#define   NFP_NET_CFG_STS_LINK_RATE_40G           5
-#define   NFP_NET_CFG_STS_LINK_RATE_50G           6
-#define   NFP_NET_CFG_STS_LINK_RATE_100G          7
-
-/*
- * NSP Link rate is a 16-bit word. It is no longer determined by
- * firmware, instead it is read from the nfp_eth_table of the
- * associated pf_dev and written to the NFP_NET_CFG_STS_NSP_LINK_RATE
- * address by the PMD each time the port is reconfigured.
- */
-#define NFP_NET_CFG_STS_NSP_LINK_RATE   0x0036
-
-#define NFP_NET_CFG_CAP                 0x0038
-#define NFP_NET_CFG_MAX_TXRINGS         0x003c
-#define NFP_NET_CFG_MAX_RXRINGS         0x0040
-#define NFP_NET_CFG_MAX_MTU             0x0044
-/* Next two words are being used by VFs for solving THB350 issue */
-#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
- */
-#define NFP_NET_CFG_RX_OFFSET           0x0050
-#define NFP_NET_CFG_RX_OFFSET_DYNAMIC          0    /* Prepend mode */
-
-/* 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
-
-/* Offload definitions */
-#define NFP_NET_N_VXLAN_PORTS  (NFP_NET_CFG_VXLAN_SZ / sizeof(uint16_t))
-
-/*
- * 3 words reserved for extended ctrl words (0x0098 - 0x00a4)
- * 3 words reserved for extended cap words (0x00a4 - 0x00b0)
- * Currently only one word is used, can be extended in future.
- */
-#define NFP_NET_CFG_CTRL_WORD1          0x0098
-#define NFP_NET_CFG_CTRL_PKT_TYPE         (0x1 << 0)
-#define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
-#define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
-#define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
-
-#define NFP_NET_CFG_CAP_WORD1           0x00a4
-
-/* 16B reserved for future use (0x00b0 - 0x00c0). */
-#define NFP_NET_CFG_RESERVED            0x00b0
-#define NFP_NET_CFG_RESERVED_SZ         0x0010
-
-/*
- * RSS configuration (0x0100 - 0x01ac):
- * Used only when NFP_NET_CFG_CTRL_RSS_ANY is enabled
- * @NFP_NET_CFG_RSS_CFG:     RSS configuration word
- * @NFP_NET_CFG_RSS_KEY:     RSS "secret" key
- * @NFP_NET_CFG_RSS_ITBL:    RSS indirection table
- */
-#define NFP_NET_CFG_RSS_BASE            0x0100
-#define NFP_NET_CFG_RSS_CTRL            NFP_NET_CFG_RSS_BASE
-#define   NFP_NET_CFG_RSS_MASK            (0x7f)
-#define   NFP_NET_CFG_RSS_MASK_of(_x)     ((_x) & 0x7f)
-#define   NFP_NET_CFG_RSS_IPV4            (1 <<  8) /* RSS for IPv4 */
-#define   NFP_NET_CFG_RSS_IPV6            (1 <<  9) /* RSS for IPv6 */
-#define   NFP_NET_CFG_RSS_IPV4_TCP        (1 << 10) /* RSS for IPv4/TCP */
-#define   NFP_NET_CFG_RSS_IPV4_UDP        (1 << 11) /* RSS for IPv4/UDP */
-#define   NFP_NET_CFG_RSS_IPV6_TCP        (1 << 12) /* RSS for IPv6/TCP */
-#define   NFP_NET_CFG_RSS_IPV6_UDP        (1 << 13) /* RSS for IPv6/UDP */
-#define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
-#define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
-#define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
-#define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
-#define NFP_NET_CFG_RSS_KEY_SZ          0x28
-#define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
-					 NFP_NET_CFG_RSS_KEY_SZ)
-#define NFP_NET_CFG_RSS_ITBL_SZ         0x80
-
-/*
- * TX ring configuration (0x200 - 0x800)
- * @NFP_NET_CFG_TXR_BASE:    Base offset for TX ring configuration
- * @NFP_NET_CFG_TXR_ADDR:    Per TX ring DMA address (8B entries)
- * @NFP_NET_CFG_TXR_WB_ADDR: Per TX ring write back DMA address (8B entries)
- * @NFP_NET_CFG_TXR_SZ:      Per TX ring size (1B entries)
- * @NFP_NET_CFG_TXR_VEC:     Per TX ring MSI-X table entry (1B entries)
- * @NFP_NET_CFG_TXR_PRIO:    Per TX ring priority (1B entries)
- * @NFP_NET_CFG_TXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
- */
-#define NFP_NET_CFG_TXR_BASE            0x0200
-#define NFP_NET_CFG_TXR_ADDR(_x)        (NFP_NET_CFG_TXR_BASE + ((_x) * 0x8))
-#define NFP_NET_CFG_TXR_WB_ADDR(_x)     (NFP_NET_CFG_TXR_BASE + 0x200 + \
-					 ((_x) * 0x8))
-#define NFP_NET_CFG_TXR_SZ(_x)          (NFP_NET_CFG_TXR_BASE + 0x400 + (_x))
-#define NFP_NET_CFG_TXR_VEC(_x)         (NFP_NET_CFG_TXR_BASE + 0x440 + (_x))
-#define NFP_NET_CFG_TXR_PRIO(_x)        (NFP_NET_CFG_TXR_BASE + 0x480 + (_x))
-#define NFP_NET_CFG_TXR_IRQ_MOD(_x)     (NFP_NET_CFG_TXR_BASE + 0x500 + \
-					 ((_x) * 0x4))
-
-/*
- * RX ring configuration (0x0800 - 0x0c00)
- * @NFP_NET_CFG_RXR_BASE:    Base offset for RX ring configuration
- * @NFP_NET_CFG_RXR_ADDR:    Per TX ring DMA address (8B entries)
- * @NFP_NET_CFG_RXR_SZ:      Per TX ring size (1B entries)
- * @NFP_NET_CFG_RXR_VEC:     Per TX ring MSI-X table entry (1B entries)
- * @NFP_NET_CFG_RXR_PRIO:    Per TX ring priority (1B entries)
- * @NFP_NET_CFG_RXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
- */
-#define NFP_NET_CFG_RXR_BASE            0x0800
-#define NFP_NET_CFG_RXR_ADDR(_x)        (NFP_NET_CFG_RXR_BASE + ((_x) * 0x8))
-#define NFP_NET_CFG_RXR_SZ(_x)          (NFP_NET_CFG_RXR_BASE + 0x200 + (_x))
-#define NFP_NET_CFG_RXR_VEC(_x)         (NFP_NET_CFG_RXR_BASE + 0x240 + (_x))
-#define NFP_NET_CFG_RXR_PRIO(_x)        (NFP_NET_CFG_RXR_BASE + 0x280 + (_x))
-#define NFP_NET_CFG_RXR_IRQ_MOD(_x)     (NFP_NET_CFG_RXR_BASE + 0x300 + \
-					 ((_x) * 0x4))
-
-/*
- * Interrupt Control/Cause registers (0x0c00 - 0x0d00)
- * These registers are only used when MSI-X auto-masking is not
- * enabled (@NFP_NET_CFG_CTRL_MSIXAUTO not set).  The array is index
- * by MSI-X entry and are 1B in size.  If an entry is zero, the
- * corresponding entry is enabled.  If the FW generates an interrupt,
- * it writes a cause into the corresponding field.  This also masks
- * the MSI-X entry and the host driver must clear the register to
- * re-enable the interrupt.
- */
-#define NFP_NET_CFG_ICR_BASE            0x0c00
-#define NFP_NET_CFG_ICR(_x)             (NFP_NET_CFG_ICR_BASE + (_x))
-#define   NFP_NET_CFG_ICR_UNMASKED      0x0
-#define   NFP_NET_CFG_ICR_RXTX          0x1
-#define   NFP_NET_CFG_ICR_LSC           0x2
-
-/*
- * General device stats (0x0d00 - 0x0d90)
- * All counters are 64bit.
- */
-#define NFP_NET_CFG_STATS_BASE          0x0d00
-#define NFP_NET_CFG_STATS_RX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x00)
-#define NFP_NET_CFG_STATS_RX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x08)
-#define NFP_NET_CFG_STATS_RX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x10)
-#define NFP_NET_CFG_STATS_RX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x18)
-#define NFP_NET_CFG_STATS_RX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x20)
-#define NFP_NET_CFG_STATS_RX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x28)
-#define NFP_NET_CFG_STATS_RX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x30)
-#define NFP_NET_CFG_STATS_RX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x38)
-#define NFP_NET_CFG_STATS_RX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x40)
-
-#define NFP_NET_CFG_STATS_TX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x48)
-#define NFP_NET_CFG_STATS_TX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x50)
-#define NFP_NET_CFG_STATS_TX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x58)
-#define NFP_NET_CFG_STATS_TX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x60)
-#define NFP_NET_CFG_STATS_TX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x68)
-#define NFP_NET_CFG_STATS_TX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x70)
-#define NFP_NET_CFG_STATS_TX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x78)
-#define NFP_NET_CFG_STATS_TX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x80)
-#define NFP_NET_CFG_STATS_TX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x88)
-
-#define NFP_NET_CFG_STATS_APP0_FRAMES   (NFP_NET_CFG_STATS_BASE + 0x90)
-#define NFP_NET_CFG_STATS_APP0_BYTES    (NFP_NET_CFG_STATS_BASE + 0x98)
-#define NFP_NET_CFG_STATS_APP1_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xa0)
-#define NFP_NET_CFG_STATS_APP1_BYTES    (NFP_NET_CFG_STATS_BASE + 0xa8)
-#define NFP_NET_CFG_STATS_APP2_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xb0)
-#define NFP_NET_CFG_STATS_APP2_BYTES    (NFP_NET_CFG_STATS_BASE + 0xb8)
-#define NFP_NET_CFG_STATS_APP3_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xc0)
-#define NFP_NET_CFG_STATS_APP3_BYTES    (NFP_NET_CFG_STATS_BASE + 0xc8)
-
-/*
- * Per ring stats (0x1000 - 0x1800)
- * Options, 64bit per entry
- * @NFP_NET_CFG_TXR_STATS:   TX ring statistics (Packet and Byte count)
- * @NFP_NET_CFG_RXR_STATS:   RX ring statistics (Packet and Byte count)
- */
-#define NFP_NET_CFG_TXR_STATS_BASE      0x1000
-#define NFP_NET_CFG_TXR_STATS(_x)       (NFP_NET_CFG_TXR_STATS_BASE + \
-					 ((_x) * 0x10))
-#define NFP_NET_CFG_RXR_STATS_BASE      0x1400
-#define NFP_NET_CFG_RXR_STATS(_x)       (NFP_NET_CFG_RXR_STATS_BASE + \
-					 ((_x) * 0x10))
+#include <nfp_common_ctrl.h>
 
 /*
  * Mac stats (0x0000 - 0x0200)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 14/25] drivers: add the nfp common module
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (12 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 13/25] drivers: add the common ctrl module Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 15/25] drivers: move queue logic to " Chaoyong He
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the nfp common module in the nfp 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/common/nfp/meson.build   |   3 +-
 drivers/common/nfp/nfp_common.c  | 133 ++++++++++++++++++
 drivers/common/nfp/nfp_common.h  | 227 +++++++++++++++++++++++++++++++
 drivers/common/nfp/version.map   |   5 +
 drivers/net/nfp/nfp_ethdev.c     |   4 +-
 drivers/net/nfp/nfp_ethdev_vf.c  |  16 +--
 drivers/net/nfp/nfp_net_common.c | 109 +--------------
 drivers/net/nfp/nfp_net_common.h | 203 +--------------------------
 8 files changed, 373 insertions(+), 327 deletions(-)
 create mode 100644 drivers/common/nfp/nfp_common.c
 create mode 100644 drivers/common/nfp/nfp_common.h

diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
index 45871dfe35..727d21e00b 100644
--- a/drivers/common/nfp/meson.build
+++ b/drivers/common/nfp/meson.build
@@ -6,9 +6,10 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
     reason = 'only supported on 64-bit Linux'
 endif
 
-deps += ['bus_pci']
+deps += ['bus_pci', 'net']
 
 sources = files(
+        'nfp_common.c',
         'nfp_common_log.c',
         'nfp_common_pci.c',
 )
diff --git a/drivers/common/nfp/nfp_common.c b/drivers/common/nfp/nfp_common.c
new file mode 100644
index 0000000000..00dad4736e
--- /dev/null
+++ b/drivers/common/nfp/nfp_common.c
@@ -0,0 +1,133 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common.h"
+
+#include "nfp_common_log.h"
+
+/*
+ * This is used by the reconfig protocol. It sets the maximum time waiting in
+ * milliseconds before a reconfig timeout happens.
+ */
+#define NFP_NET_POLL_TIMEOUT    5000
+
+int
+nfp_reconfig_real(struct nfp_hw *hw,
+		uint32_t update)
+{
+	uint32_t cnt;
+	uint32_t new;
+	struct timespec wait;
+
+	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
+			hw->qcp_cfg);
+
+	if (hw->qcp_cfg == NULL) {
+		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
+		return -ENXIO;
+	}
+
+	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+
+	wait.tv_sec = 0;
+	wait.tv_nsec = 1000000; /* 1ms */
+
+	PMD_DRV_LOG(DEBUG, "Polling for update ack...");
+
+	/* Poll update field, waiting for NFP to ack the config */
+	for (cnt = 0; ; cnt++) {
+		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
+		if (new == 0)
+			break;
+
+		if ((new & NFP_NET_CFG_UPDATE_ERR) != 0) {
+			PMD_DRV_LOG(ERR, "Reconfig error: %#08x", new);
+			return -1;
+		}
+
+		if (cnt >= NFP_NET_POLL_TIMEOUT) {
+			PMD_DRV_LOG(ERR, "Reconfig timeout for %#08x after %u ms",
+					update, cnt);
+			return -EIO;
+		}
+
+		nanosleep(&wait, 0); /* waiting for a 1ms */
+	}
+
+	PMD_DRV_LOG(DEBUG, "Ack DONE");
+	return 0;
+}
+
+/**
+ * Reconfigure the NIC.
+ *
+ * Write the update word to the BAR and ping the reconfig queue. Then poll
+ * until the firmware has acknowledged the update by zeroing the update word.
+ *
+ * @param hw
+ *   Device to reconfigure.
+ * @param ctrl
+ *   The value for the ctrl field in the BAR config.
+ * @param update
+ *   The value for the update field in the BAR config.
+ *
+ * @return
+ *   - (0) if OK to reconfigure the device.
+ *   - (-EIO) if I/O err and fail to reconfigure the device.
+ */
+int
+nfp_reconfig(struct nfp_hw *hw,
+		uint32_t ctrl,
+		uint32_t update)
+{
+	int ret;
+
+	rte_spinlock_lock(&hw->reconfig_lock);
+
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+
+	rte_wmb();
+
+	ret = nfp_reconfig_real(hw, update);
+
+	rte_spinlock_unlock(&hw->reconfig_lock);
+
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Error nfp net reconfig: ctrl=%#08x update=%#08x",
+				ctrl, update);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+void
+nfp_read_mac(struct nfp_hw *hw)
+{
+	uint32_t tmp;
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
+}
+
+void
+nfp_write_mac(struct nfp_hw *hw,
+		uint8_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;
+	mac1 = *(uint16_t *)mac;
+	nn_writew(rte_cpu_to_be_16(mac1),
+			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+}
diff --git a/drivers/common/nfp/nfp_common.h b/drivers/common/nfp/nfp_common.h
new file mode 100644
index 0000000000..c3645b6ec5
--- /dev/null
+++ b/drivers/common/nfp/nfp_common.h
@@ -0,0 +1,227 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_H__
+#define __NFP_COMMON_H__
+
+#include <rte_byteorder.h>
+#include <rte_ether.h>
+#include <rte_io.h>
+#include <rte_spinlock.h>
+
+#include "nfp_common_ctrl.h"
+
+#define NFP_QCP_QUEUE_ADDR_SZ   (0x800)
+
+/* Macros for accessing the Queue Controller Peripheral 'CSRs' */
+#define NFP_QCP_QUEUE_OFF(_x)                 ((_x) * 0x800)
+#define NFP_QCP_QUEUE_ADD_RPTR                  0x0000
+#define NFP_QCP_QUEUE_ADD_WPTR                  0x0004
+#define NFP_QCP_QUEUE_STS_LO                    0x0008
+#define NFP_QCP_QUEUE_STS_LO_READPTR_MASK     (0x3ffff)
+#define NFP_QCP_QUEUE_STS_HI                    0x000c
+#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK    (0x3ffff)
+
+/* Read or Write Pointer of a queue */
+enum nfp_qcp_ptr {
+	NFP_QCP_READ_PTR = 0,
+	NFP_QCP_WRITE_PTR
+};
+
+struct nfp_hw {
+	uint8_t *ctrl_bar;
+	uint8_t *qcp_cfg;
+	uint32_t cap;
+	uint32_t ctrl;    /**< Current values for control */
+	rte_spinlock_t reconfig_lock;
+	struct rte_ether_addr mac_addr;
+};
+
+static inline uint8_t
+nn_readb(volatile const void *addr)
+{
+	return rte_read8(addr);
+}
+
+static inline void
+nn_writeb(uint8_t val,
+		volatile void *addr)
+{
+	rte_write8(val, addr);
+}
+
+static inline uint32_t
+nn_readl(volatile const void *addr)
+{
+	return rte_read32(addr);
+}
+
+static inline void
+nn_writel(uint32_t val,
+		volatile void *addr)
+{
+	rte_write32(val, addr);
+}
+
+static inline uint16_t
+nn_readw(volatile const void *addr)
+{
+	return rte_read16(addr);
+}
+
+static inline void
+nn_writew(uint16_t val,
+		volatile void *addr)
+{
+	rte_write16(val, addr);
+}
+
+static inline uint64_t
+nn_readq(volatile void *addr)
+{
+	uint32_t low;
+	uint32_t high;
+	const volatile uint32_t *p = addr;
+
+	high = nn_readl((volatile const void *)(p + 1));
+	low = nn_readl((volatile const void *)p);
+
+	return low + ((uint64_t)high << 32);
+}
+
+static inline void
+nn_writeq(uint64_t val,
+		volatile void *addr)
+{
+	nn_writel(val >> 32, (volatile char *)addr + 4);
+	nn_writel(val, addr);
+}
+
+static inline uint8_t
+nn_cfg_readb(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return nn_readb(hw->ctrl_bar + off);
+}
+
+static inline void
+nn_cfg_writeb(struct nfp_hw *hw,
+		uint32_t off,
+		uint8_t val)
+{
+	nn_writeb(val, hw->ctrl_bar + off);
+}
+
+static inline uint16_t
+nn_cfg_readw(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writew(struct nfp_hw *hw,
+		uint32_t off,
+		uint16_t val)
+{
+	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
+}
+
+static inline uint32_t
+nn_cfg_readl(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writel(struct nfp_hw *hw,
+		uint32_t off,
+		uint32_t val)
+{
+	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
+}
+
+static inline uint64_t
+nn_cfg_readq(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writeq(struct nfp_hw *hw,
+		uint32_t off,
+		uint64_t val)
+{
+	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
+}
+
+/**
+ * Add the value to the selected pointer of a queue.
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Add to the read or write pointer
+ * @param val
+ *   Value to add to the queue pointer
+ */
+static inline void
+nfp_qcp_ptr_add(uint8_t *queue,
+		enum nfp_qcp_ptr ptr,
+		uint32_t val)
+{
+	uint32_t off;
+
+	if (ptr == NFP_QCP_READ_PTR)
+		off = NFP_QCP_QUEUE_ADD_RPTR;
+	else
+		off = NFP_QCP_QUEUE_ADD_WPTR;
+
+	nn_writel(rte_cpu_to_le_32(val), queue + off);
+}
+
+/**
+ * Read the current read/write pointer value for a queue.
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Read or Write pointer
+ */
+static inline uint32_t
+nfp_qcp_read(uint8_t *queue,
+		enum nfp_qcp_ptr ptr)
+{
+	uint32_t off;
+	uint32_t val;
+
+	if (ptr == NFP_QCP_READ_PTR)
+		off = NFP_QCP_QUEUE_STS_LO;
+	else
+		off = NFP_QCP_QUEUE_STS_HI;
+
+	val = rte_cpu_to_le_32(nn_readl(queue + off));
+
+	if (ptr == NFP_QCP_READ_PTR)
+		return val & NFP_QCP_QUEUE_STS_LO_READPTR_MASK;
+	else
+		return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK;
+}
+
+__rte_internal
+int nfp_reconfig_real(struct nfp_hw *hw, uint32_t update);
+
+__rte_internal
+int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
+
+__rte_internal
+void nfp_read_mac(struct nfp_hw *hw);
+
+__rte_internal
+void nfp_write_mac(struct nfp_hw *hw, uint8_t *mac);
+
+#endif/* __NFP_COMMON_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index 25e48c39d6..56db63f29c 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -3,5 +3,10 @@ INTERNAL {
 
 	nfp_class_driver_register;
 
+	nfp_reconfig;
+	nfp_reconfig_real;
+	nfp_read_mac;
+	nfp_write_mac;
+
 	local: *;
 };
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index c6147ef01e..7b4439585b 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -599,13 +599,13 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+	nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 
 	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
 		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 049728d30c..b9cfb48021 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -15,18 +15,6 @@
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
 
-static void
-nfp_netvf_read_mac(struct nfp_hw *hw)
-{
-	uint32_t tmp;
-
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
-	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
-
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
-	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
-}
-
 static int
 nfp_netvf_start(struct rte_eth_dev *dev)
 {
@@ -334,12 +322,12 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(hw);
+	nfp_read_mac(hw);
 	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
 		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 22222a9773..6d525648eb 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -198,97 +198,6 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 /* The length of firmware version string */
 #define FW_VER_LEN        32
 
-static int
-nfp_reconfig_real(struct nfp_hw *hw,
-		uint32_t update)
-{
-	uint32_t cnt;
-	uint32_t new;
-	struct timespec wait;
-
-	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->qcp_cfg);
-
-	if (hw->qcp_cfg == NULL) {
-		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
-		return -ENXIO;
-	}
-
-	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
-
-	wait.tv_sec = 0;
-	wait.tv_nsec = 1000000; /* 1ms */
-
-	PMD_DRV_LOG(DEBUG, "Polling for update ack...");
-
-	/* Poll update field, waiting for NFP to ack the config */
-	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
-		if (new == 0)
-			break;
-
-		if ((new & NFP_NET_CFG_UPDATE_ERR) != 0) {
-			PMD_DRV_LOG(ERR, "Reconfig error: %#08x", new);
-			return -1;
-		}
-
-		if (cnt >= NFP_NET_POLL_TIMEOUT) {
-			PMD_DRV_LOG(ERR, "Reconfig timeout for %#08x after %u ms",
-					update, cnt);
-			return -EIO;
-		}
-
-		nanosleep(&wait, 0); /* Waiting for a 1ms */
-	}
-
-	PMD_DRV_LOG(DEBUG, "Ack DONE");
-	return 0;
-}
-
-/**
- * Reconfigure the NIC.
- *
- * Write the update word to the BAR and ping the reconfig queue. Then poll
- * until the firmware has acknowledged the update by zeroing the update word.
- *
- * @param hw
- *   Device to reconfigure.
- * @param ctrl
- *   The value for the ctrl field in the BAR config.
- * @param update
- *   The value for the update field in the BAR config.
- *
- * @return
- *   - (0) if OK to reconfigure the device.
- *   - (-EIO) if I/O err and fail to reconfigure the device.
- */
-int
-nfp_reconfig(struct nfp_hw *hw,
-		uint32_t ctrl,
-		uint32_t update)
-{
-	int ret;
-
-	rte_spinlock_lock(&hw->reconfig_lock);
-
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
-
-	rte_wmb();
-
-	ret = nfp_reconfig_real(hw, update);
-
-	rte_spinlock_unlock(&hw->reconfig_lock);
-
-	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp net reconfig: ctrl=%#08x update=%#08x",
-				ctrl, update);
-		return -EIO;
-	}
-
-	return 0;
-}
-
 /**
  * Reconfigure the NIC for the extend ctrl BAR.
  *
@@ -531,22 +440,6 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 	hw->super.qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }
 
-void
-nfp_net_write_mac(struct nfp_hw *hw,
-		uint8_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;
-	mac1 = *(uint16_t *)mac;
-	nn_writew(rte_cpu_to_be_16(mac1),
-			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
-}
-
 int
 nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 		struct rte_ether_addr *mac_addr)
@@ -565,7 +458,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
+	nfp_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 02a5ffefd8..0ded35a874 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -8,21 +8,12 @@
 
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
-#include <rte_io.h>
+#include <nfp_common.h>
 #include <rte_spinlock.h>
 
 #include "nfp_net_ctrl.h"
 #include "nfpcore/nfp_dev.h"
 
-/* Macros for accessing the Queue Controller Peripheral 'CSRs' */
-#define NFP_QCP_QUEUE_OFF(_x)                 ((_x) * 0x800)
-#define NFP_QCP_QUEUE_ADD_RPTR                  0x0000
-#define NFP_QCP_QUEUE_ADD_WPTR                  0x0004
-#define NFP_QCP_QUEUE_STS_LO                    0x0008
-#define NFP_QCP_QUEUE_STS_LO_READPTR_MASK     (0x3ffff)
-#define NFP_QCP_QUEUE_STS_HI                    0x000c
-#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK    (0x3ffff)
-
 /* Interrupt definitions */
 #define NFP_NET_IRQ_LSC_IDX             0
 
@@ -42,8 +33,6 @@
 /* Alignment for dma zones */
 #define NFP_MEMZONE_ALIGN       128
 
-#define NFP_QCP_QUEUE_ADDR_SZ   (0x800)
-
 /* Number of supported physical ports */
 #define NFP_MAX_PHYPORTS        12
 
@@ -53,12 +42,6 @@ enum nfp_app_fw_id {
 	NFP_APP_FW_FLOWER_NIC             = 0x3,
 };
 
-/* Read or Write Pointer of a queue */
-enum nfp_qcp_ptr {
-	NFP_QCP_READ_PTR = 0,
-	NFP_QCP_WRITE_PTR
-};
-
 enum nfp_net_meta_format {
 	NFP_NET_METAFORMAT_SINGLE,
 	NFP_NET_METAFORMAT_CHAINED,
@@ -112,15 +95,6 @@ struct nfp_app_fw_nic {
 	uint8_t total_phyports;
 };
 
-struct nfp_hw {
-	uint8_t *ctrl_bar;
-	uint8_t *qcp_cfg;
-	uint32_t cap;
-	uint32_t ctrl;    /**< Current values for control */
-	rte_spinlock_t reconfig_lock;
-	struct rte_ether_addr mac_addr;
-};
-
 struct nfp_net_hw {
 	/** The parent class */
 	struct nfp_hw super;
@@ -183,179 +157,6 @@ struct nfp_net_adapter {
 	struct nfp_net_hw hw;
 };
 
-static inline uint8_t
-nn_readb(volatile const void *addr)
-{
-	return rte_read8(addr);
-}
-
-static inline void
-nn_writeb(uint8_t val,
-		volatile void *addr)
-{
-	rte_write8(val, addr);
-}
-
-static inline uint32_t
-nn_readl(volatile const void *addr)
-{
-	return rte_read32(addr);
-}
-
-static inline void
-nn_writel(uint32_t val,
-		volatile void *addr)
-{
-	rte_write32(val, addr);
-}
-
-static inline uint16_t
-nn_readw(volatile const void *addr)
-{
-	return rte_read16(addr);
-}
-
-static inline void
-nn_writew(uint16_t val,
-		volatile void *addr)
-{
-	rte_write16(val, addr);
-}
-
-static inline uint64_t
-nn_readq(volatile void *addr)
-{
-	uint32_t low;
-	uint32_t high;
-	const volatile uint32_t *p = addr;
-
-	high = nn_readl((volatile const void *)(p + 1));
-	low = nn_readl((volatile const void *)p);
-
-	return low + ((uint64_t)high << 32);
-}
-
-static inline void
-nn_writeq(uint64_t val,
-		volatile void *addr)
-{
-	nn_writel(val >> 32, (volatile char *)addr + 4);
-	nn_writel(val, addr);
-}
-
-static inline uint8_t
-nn_cfg_readb(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return nn_readb(hw->ctrl_bar + off);
-}
-
-static inline void
-nn_cfg_writeb(struct nfp_hw *hw,
-		uint32_t off,
-		uint8_t val)
-{
-	nn_writeb(val, hw->ctrl_bar + off);
-}
-
-static inline uint16_t
-nn_cfg_readw(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writew(struct nfp_hw *hw,
-		uint32_t off,
-		uint16_t val)
-{
-	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
-}
-
-static inline uint32_t
-nn_cfg_readl(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writel(struct nfp_hw *hw,
-		uint32_t off,
-		uint32_t val)
-{
-	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
-}
-
-static inline uint64_t
-nn_cfg_readq(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writeq(struct nfp_hw *hw,
-		uint32_t off,
-		uint64_t val)
-{
-	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
-}
-
-/**
- * Add the value to the selected pointer of a queue.
- *
- * @param queue
- *   Base address for queue structure
- * @param ptr
- *   Add to the read or write pointer
- * @param val
- *   Value to add to the queue pointer
- */
-static inline void
-nfp_qcp_ptr_add(uint8_t *queue,
-		enum nfp_qcp_ptr ptr,
-		uint32_t val)
-{
-	uint32_t off;
-
-	if (ptr == NFP_QCP_READ_PTR)
-		off = NFP_QCP_QUEUE_ADD_RPTR;
-	else
-		off = NFP_QCP_QUEUE_ADD_WPTR;
-
-	nn_writel(rte_cpu_to_le_32(val), queue + off);
-}
-
-/**
- * Read the current read/write pointer value for a queue.
- *
- * @param queue
- *   Base address for queue structure
- * @param ptr
- *   Read or Write pointer
- */
-static inline uint32_t
-nfp_qcp_read(uint8_t *queue,
-		enum nfp_qcp_ptr ptr)
-{
-	uint32_t off;
-	uint32_t val;
-
-	if (ptr == NFP_QCP_READ_PTR)
-		off = NFP_QCP_QUEUE_STS_LO;
-	else
-		off = NFP_QCP_QUEUE_STS_HI;
-
-	val = rte_cpu_to_le_32(nn_readl(queue + off));
-
-	if (ptr == NFP_QCP_READ_PTR)
-		return val & NFP_QCP_QUEUE_STS_LO_READPTR_MASK;
-	else
-		return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK;
-}
-
 static inline uint32_t
 nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 		uint16_t queue)
@@ -365,7 +166,6 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 }
 
 /* Prototypes for common NFP functions */
-int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
 int nfp_net_ext_reconfig(struct nfp_net_hw *hw, uint32_t ctrl_ext, uint32_t update);
 int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
 int nfp_net_configure(struct rte_eth_dev *dev);
@@ -374,7 +174,6 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_net_write_mac(struct nfp_hw *hw, uint8_t *mac);
 int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 		struct rte_intr_handle *intr_handle);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 15/25] drivers: move queue logic to common module
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (13 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 14/25] drivers: add the nfp common module Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 16/25] drivers: move platform module to common library Chaoyong He
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the queue enable/disable logic to the 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/common/nfp/nfp_common.c  | 49 ++++++++++++++++++++++++++++++++
 drivers/common/nfp/nfp_common.h  |  7 +++++
 drivers/common/nfp/version.map   |  2 ++
 drivers/net/nfp/nfp_net_common.c | 38 ++-----------------------
 4 files changed, 61 insertions(+), 35 deletions(-)

diff --git a/drivers/common/nfp/nfp_common.c b/drivers/common/nfp/nfp_common.c
index 00dad4736e..055bb5adb8 100644
--- a/drivers/common/nfp/nfp_common.c
+++ b/drivers/common/nfp/nfp_common.c
@@ -131,3 +131,52 @@ nfp_write_mac(struct nfp_hw *hw,
 	nn_writew(rte_cpu_to_be_16(mac1),
 			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
 }
+
+void
+nfp_enable_queues(struct nfp_hw *hw,
+		uint16_t nb_rx_queues,
+		uint16_t nb_tx_queues)
+{
+	int i;
+	uint64_t enabled_queues;
+
+	/* Enabling the required TX queues in the device */
+	enabled_queues = 0;
+	for (i = 0; i < nb_tx_queues; i++)
+		enabled_queues |= (1 << i);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+
+	/* Enabling the required RX queues in the device */
+	enabled_queues = 0;
+	for (i = 0; i < nb_rx_queues; i++)
+		enabled_queues |= (1 << i);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+}
+
+void
+nfp_disable_queues(struct nfp_hw *hw)
+{
+	int ret;
+	uint32_t update;
+	uint32_t new_ctrl;
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	update = NFP_NET_CFG_UPDATE_GEN |
+			NFP_NET_CFG_UPDATE_RING |
+			NFP_NET_CFG_UPDATE_MSIX;
+
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
+
+	/* If an error when reconfig we avoid to change hw state */
+	ret = nfp_reconfig(hw, new_ctrl, update);
+	if (ret < 0)
+		return;
+
+	hw->ctrl = new_ctrl;
+}
diff --git a/drivers/common/nfp/nfp_common.h b/drivers/common/nfp/nfp_common.h
index c3645b6ec5..71418d3500 100644
--- a/drivers/common/nfp/nfp_common.h
+++ b/drivers/common/nfp/nfp_common.h
@@ -224,4 +224,11 @@ void nfp_read_mac(struct nfp_hw *hw);
 __rte_internal
 void nfp_write_mac(struct nfp_hw *hw, uint8_t *mac);
 
+__rte_internal
+void nfp_enable_queues(struct nfp_hw *hw, uint16_t nb_rx_queues,
+		uint16_t nb_tx_queues);
+
+__rte_internal
+void nfp_disable_queues(struct nfp_hw *hw);
+
 #endif/* __NFP_COMMON_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index 56db63f29c..55ef81701f 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -7,6 +7,8 @@ INTERNAL {
 	nfp_reconfig_real;
 	nfp_read_mac;
 	nfp_write_mac;
+	nfp_enable_queues;
+	nfp_disable_queues;
 
 	local: *;
 };
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 6d525648eb..b5a4dc72cb 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -377,54 +377,22 @@ nfp_net_enable_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;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	/* Enabling the required TX queues in the device */
-	enabled_queues = 0;
-	for (i = 0; i < dev->data->nb_tx_queues; i++)
-		enabled_queues |= (1 << i);
-
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
-
-	/* Enabling the required RX queues in the device */
-	enabled_queues = 0;
-	for (i = 0; i < dev->data->nb_rx_queues; i++)
-		enabled_queues |= (1 << i);
-
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nfp_enable_queues(&hw->super, dev->data->nb_rx_queues,
+			dev->data->nb_tx_queues);
 }
 
 void
 nfp_net_disable_queues(struct rte_eth_dev *dev)
 {
-	uint32_t update;
-	uint32_t new_ctrl;
-	struct nfp_hw *hw;
 	struct nfp_net_hw *net_hw;
 
 	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	hw = &net_hw->super;
-
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
-
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
-	update = NFP_NET_CFG_UPDATE_GEN |
-			NFP_NET_CFG_UPDATE_RING |
-			NFP_NET_CFG_UPDATE_MSIX;
-
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
-		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
-	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_reconfig(hw, new_ctrl, update) != 0)
-		return;
-
-	hw->ctrl = new_ctrl;
+	nfp_disable_queues(&net_hw->super);
 }
 
 void
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 16/25] drivers: move platform module to common library
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (14 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 15/25] drivers: move queue logic to " Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 17/25] drivers: move device " Chaoyong He
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the platform module to the 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/nfpcore => common/nfp}/nfp_platform.h | 0
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c                     | 2 +-
 drivers/net/nfp/nfp_net_ctrl.c                         | 3 +--
 drivers/net/nfp/nfpcore/nfp_cppcore.c                  | 3 ++-
 drivers/net/nfp/nfpcore/nfp_dev.c                      | 3 +--
 drivers/net/nfp/nfpcore/nfp_nsp.c                      | 2 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c                  | 3 ++-
 7 files changed, 8 insertions(+), 8 deletions(-)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_platform.h (100%)

diff --git a/drivers/net/nfp/nfpcore/nfp_platform.h b/drivers/common/nfp/nfp_platform.h
similarity index 100%
rename from drivers/net/nfp/nfpcore/nfp_platform.h
rename to drivers/common/nfp/nfp_platform.h
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index cef27b0d92..0ee4815651 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -6,10 +6,10 @@
 #include "nfp_nfdk.h"
 
 #include <bus_pci_driver.h>
+#include <nfp_platform.h>
 #include <rte_malloc.h>
 
 #include "../flower/nfp_flower.h"
-#include "../nfpcore/nfp_platform.h"
 #include "../nfp_logs.h"
 
 #define NFDK_TX_DESC_GATHER_MAX         17
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index 8848fa38fe..5135a1ad27 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -6,8 +6,7 @@
 #include "nfp_net_ctrl.h"
 
 #include <ethdev_pci.h>
-
-#include "nfpcore/nfp_platform.h"
+#include <nfp_platform.h>
 
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index f9b08a12b6..0e6045f2f0 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -5,8 +5,9 @@
 
 #include "nfp_cpp.h"
 
+#include <nfp_platform.h>
+
 #include "nfp_logs.h"
-#include "nfp_platform.h"
 #include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
 #include "nfp6000/nfp_xpb.h"
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.c b/drivers/net/nfp/nfpcore/nfp_dev.c
index 7799fa699a..f29b7e0711 100644
--- a/drivers/net/nfp/nfpcore/nfp_dev.c
+++ b/drivers/net/nfp/nfpcore/nfp_dev.c
@@ -5,10 +5,9 @@
 
 #include "nfp_dev.h"
 
+#include <nfp_platform.h>
 #include <rte_bitops.h>
 
-#include "nfp_platform.h"
-
 /*
  * Note: The value of 'max_qc_size' is different from kernel driver,
  * because DPDK use 'uint16_t' as the data type.
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index 5b804f6174..a680b972b8 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -5,10 +5,10 @@
 
 #include "nfp_nsp.h"
 
+#include <nfp_platform.h>
 #include <rte_common.h>
 
 #include "nfp_logs.h"
-#include "nfp_platform.h"
 #include "nfp_resource.h"
 
 /* Offsets relative to the CSR base */
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
index cc472907ca..75f6d40fea 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
@@ -3,9 +3,10 @@
  * All rights reserved.
  */
 
+#include <nfp_platform.h>
+
 #include "nfp_logs.h"
 #include "nfp_nsp.h"
-#include "nfp_platform.h"
 
 #define NSP_ETH_NBI_PORT_COUNT          24
 #define NSP_ETH_MAX_COUNT               (2 * NSP_ETH_NBI_PORT_COUNT)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 17/25] drivers: move device module to common library
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (15 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 16/25] drivers: move platform module to common library Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the device module to the 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/common/nfp/meson.build                    | 1 +
 drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c | 0
 drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h | 3 +++
 drivers/common/nfp/version.map                    | 1 +
 drivers/net/nfp/meson.build                       | 1 -
 drivers/net/nfp/nfp_net_common.h                  | 2 +-
 drivers/net/nfp/nfpcore/nfp6000_pcie.h            | 2 +-
 7 files changed, 7 insertions(+), 3 deletions(-)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c (100%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h (96%)

diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
index 727d21e00b..7f496c2da5 100644
--- a/drivers/common/nfp/meson.build
+++ b/drivers/common/nfp/meson.build
@@ -12,4 +12,5 @@ sources = files(
         'nfp_common.c',
         'nfp_common_log.c',
         'nfp_common_pci.c',
+        'nfp_dev.c',
 )
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.c b/drivers/common/nfp/nfp_dev.c
similarity index 100%
rename from drivers/net/nfp/nfpcore/nfp_dev.c
rename to drivers/common/nfp/nfp_dev.c
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.h b/drivers/common/nfp/nfp_dev.h
similarity index 96%
rename from drivers/net/nfp/nfpcore/nfp_dev.h
rename to drivers/common/nfp/nfp_dev.h
index b0fffff619..ffcdd17227 100644
--- a/drivers/net/nfp/nfpcore/nfp_dev.h
+++ b/drivers/common/nfp/nfp_dev.h
@@ -8,6 +8,8 @@
 
 #include <stdint.h>
 
+#include <rte_compat.h>
+
 #define PCI_VENDOR_ID_NETRONOME         0x19ee
 #define PCI_VENDOR_ID_CORIGINE          0x1da8
 
@@ -39,6 +41,7 @@ struct nfp_dev_info {
 	uint8_t pf_num_per_unit;
 };
 
+__rte_internal
 const struct nfp_dev_info *nfp_dev_info_get(uint16_t device_id);
 
 #endif /* __NFP_DEV_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index 55ef81701f..cedd34974e 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -9,6 +9,7 @@ INTERNAL {
 	nfp_write_mac;
 	nfp_enable_queues;
 	nfp_disable_queues;
+	nfp_dev_info_get;
 
 	local: *;
 };
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index d54dca36e9..c566c6d2e6 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -16,7 +16,6 @@ sources = files(
         'nfdk/nfp_nfdk_dp.c',
         'nfpcore/nfp_cppcore.c',
         'nfpcore/nfp_crc.c',
-        'nfpcore/nfp_dev.c',
         'nfpcore/nfp_hwinfo.c',
         'nfpcore/nfp_mip.c',
         'nfpcore/nfp_mutex.c',
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 0ded35a874..aae20d1d6f 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -9,10 +9,10 @@
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
 #include <nfp_common.h>
+#include <nfp_dev.h>
 #include <rte_spinlock.h>
 
 #include "nfp_net_ctrl.h"
-#include "nfpcore/nfp_dev.h"
 
 /* Interrupt definitions */
 #define NFP_NET_IRQ_LSC_IDX             0
diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.h b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
index 8e2cfb69e6..59b58ddd04 100644
--- a/drivers/net/nfp/nfpcore/nfp6000_pcie.h
+++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
@@ -7,9 +7,9 @@
 #define __NFP6000_PCIE_H__
 
 #include <ethdev_pci.h>
+#include <nfp_dev.h>
 
 #include "nfp_cpp.h"
-#include "nfp_dev.h"
 
 const struct nfp_cpp_operations *nfp_cpp_transport_operations(void);
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 18/25] drivers/vdpa: introduce the NFP vDPA library
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (16 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 17/25] drivers: move device " Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Introduce the very basic NFP vDPA library.

Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
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/vdpa/meson.build        |  1 +
 drivers/vdpa/nfp/meson.build    | 16 ++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_log.c |  9 +++++++++
 drivers/vdpa/nfp/nfp_vdpa_log.h | 21 +++++++++++++++++++++
 4 files changed, 47 insertions(+)
 create mode 100644 drivers/vdpa/nfp/meson.build
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.h

diff --git a/drivers/vdpa/meson.build b/drivers/vdpa/meson.build
index 77412c7d09..896e8e0304 100644
--- a/drivers/vdpa/meson.build
+++ b/drivers/vdpa/meson.build
@@ -8,6 +8,7 @@ endif
 drivers = [
         'ifc',
         'mlx5',
+        'nfp',
         'sfc',
 ]
 std_deps = ['bus_pci', 'kvargs']
diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
new file mode 100644
index 0000000000..b17866e157
--- /dev/null
+++ b/drivers/vdpa/nfp/meson.build
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64-bit Linux'
+endif
+
+if not dpdk_conf.has('RTE_LIB_VHOST')
+    build = false
+    reason = 'missing dependency, DPDK vhost library'
+endif
+
+sources = files(
+        'nfp_vdpa_log.c',
+)
diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.c b/drivers/vdpa/nfp/nfp_vdpa_log.c
new file mode 100644
index 0000000000..8c957d59ea
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_log.c
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_vdpa_log.h"
+
+RTE_LOG_REGISTER_SUFFIX(nfp_core_logtype, driver, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(nfp_vdpa_logtype, driver, NOTICE);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.h b/drivers/vdpa/nfp/nfp_vdpa_log.h
new file mode 100644
index 0000000000..c3fb274cb5
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_log.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_VDPA_LOG_H__
+#define __NFP_VDPA_LOG_H__
+
+#include <rte_log.h>
+
+extern int nfp_vdpa_logtype;
+#define DRV_VDPA_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_vdpa_logtype, \
+		"NFP_VDPA: %s(): " fmt "\n", __func__, ## args)
+
+extern int nfp_core_logtype;
+#define DRV_CORE_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_core_logtype, \
+		"NFP_CORE: %s(): " fmt "\n", __func__, ## args)
+
+#endif /* __NFP_VDPA_LOG_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 19/25] drivers: add the basic framework of vDPA PMD
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (17 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the basic framework of vDPA PMD.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_pci.c |   1 +
 drivers/common/nfp/nfp_common_pci.h |   1 +
 drivers/vdpa/nfp/meson.build        |   7 ++
 drivers/vdpa/nfp/nfp_vdpa.c         | 153 ++++++++++++++++++++++++++++
 4 files changed, 162 insertions(+)
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa.c

diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
index 1aa8dd4bbd..c73f4888a9 100644
--- a/drivers/common/nfp/nfp_common_pci.c
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -32,6 +32,7 @@ static const struct {
 	enum nfp_class drv_class;
 } nfp_classes[] = {
 	{ .name = "eth",      .drv_class = NFP_CLASS_ETH },
+	{ .name = "vdpa",     .drv_class = NFP_CLASS_VDPA },
 };
 
 static enum nfp_class
diff --git a/drivers/common/nfp/nfp_common_pci.h b/drivers/common/nfp/nfp_common_pci.h
index 21465fca68..80c027c3a5 100644
--- a/drivers/common/nfp/nfp_common_pci.h
+++ b/drivers/common/nfp/nfp_common_pci.h
@@ -16,6 +16,7 @@ typedef int (nfp_class_driver_remove_t)(struct rte_pci_device *dev);
 
 enum nfp_class {
 	NFP_CLASS_ETH,
+	NFP_CLASS_VDPA,
 	NFP_CLASS_INVALID,
 };
 
diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
index b17866e157..e1cc244578 100644
--- a/drivers/vdpa/nfp/meson.build
+++ b/drivers/vdpa/nfp/meson.build
@@ -12,5 +12,12 @@ if not dpdk_conf.has('RTE_LIB_VHOST')
 endif
 
 sources = files(
+        'nfp_vdpa.c',
         'nfp_vdpa_log.c',
 )
+
+deps += ['common_nfp']
+
+if not dpdk_conf.has('RTE_COMMON_NFP')
+    error('Missing internal dependency "common/nfp"')
+endif
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
new file mode 100644
index 0000000000..ef4ae4946a
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -0,0 +1,153 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include <pthread.h>
+
+#include <nfp_common_pci.h>
+#include <nfp_dev.h>
+#include <vdpa_driver.h>
+
+#include "nfp_vdpa_log.h"
+
+#define NFP_VDPA_DRIVER_NAME nfp_vdpa
+
+struct nfp_vdpa_dev {
+	struct rte_pci_device *pci_dev;
+	struct rte_vdpa_device *vdev;
+};
+
+struct nfp_vdpa_dev_node {
+	TAILQ_ENTRY(nfp_vdpa_dev_node) next;
+	struct nfp_vdpa_dev *device;
+};
+
+TAILQ_HEAD(vdpa_dev_list_head, nfp_vdpa_dev_node);
+
+static struct vdpa_dev_list_head vdpa_dev_list =
+	TAILQ_HEAD_INITIALIZER(vdpa_dev_list);
+
+static pthread_mutex_t vdpa_list_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static struct nfp_vdpa_dev_node *
+nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
+{
+	bool found = false;
+	struct nfp_vdpa_dev_node *node;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+
+	TAILQ_FOREACH(node, &vdpa_dev_list, next) {
+		if (pdev == node->device->pci_dev) {
+			found = true;
+			break;
+		}
+	}
+
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	if (found)
+		return node;
+
+	return NULL;
+}
+
+struct rte_vdpa_dev_ops nfp_vdpa_ops = {
+};
+
+static int
+nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
+{
+	struct nfp_vdpa_dev *device;
+	struct nfp_vdpa_dev_node *node;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	node = calloc(1, sizeof(*node));
+	if (node == NULL)
+		return -ENOMEM;
+
+	device = calloc(1, sizeof(*device));
+	if (device == NULL)
+		goto free_node;
+
+	device->pci_dev = pci_dev;
+
+	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
+	if (device->vdev == NULL) {
+		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
+		goto free_device;
+	}
+
+	node->device = device;
+	pthread_mutex_lock(&vdpa_list_lock);
+	TAILQ_INSERT_TAIL(&vdpa_dev_list, node, next);
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	return 0;
+
+free_device:
+	free(device);
+free_node:
+	free(node);
+
+	return -1;
+}
+
+static int
+nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
+{
+	struct nfp_vdpa_dev *device;
+	struct nfp_vdpa_dev_node *node;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	node = nfp_vdpa_find_node_by_pdev(pci_dev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid device: %s", pci_dev->name);
+		return -ENODEV;
+	}
+
+	device = node->device;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+	TAILQ_REMOVE(&vdpa_dev_list, node, next);
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	rte_vdpa_unregister_device(device->vdev);
+
+	free(device);
+	free(node);
+
+	return 0;
+}
+
+static const struct rte_pci_id pci_id_nfp_vdpa_map[] = {
+	{
+		RTE_PCI_DEVICE(PCI_VENDOR_ID_NETRONOME,
+				PCI_DEVICE_ID_NFP6000_VF_NIC)
+	},
+	{
+		.vendor_id = 0,
+	},
+};
+
+static struct nfp_class_driver nfp_vdpa = {
+	.drv_class = NFP_CLASS_VDPA,
+	.name = RTE_STR(NFP_VDPA_DRIVER_NAME),
+	.id_table = pci_id_nfp_vdpa_map,
+	.drv_flags =  RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+	.probe = nfp_vdpa_pci_probe,
+	.remove = nfp_vdpa_pci_remove,
+};
+
+RTE_INIT(nfp_vdpa_init)
+{
+	nfp_class_driver_register(&nfp_vdpa);
+}
+
+RTE_PMD_REGISTER_PCI_TABLE(NFP_VDPA_DRIVER_NAME, pci_id_nfp_vdpa_map);
+RTE_PMD_REGISTER_KMOD_DEP(NFP_VDPA_DRIVER_NAME, "* vfio-pci");
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 20/25] vdpa/nfp: add the logic of remap PCI memory
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (18 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the logic of remap PCI memory.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c | 65 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index ef4ae4946a..824b0d681a 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -7,6 +7,7 @@
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
+#include <rte_vfio.h>
 #include <vdpa_driver.h>
 
 #include "nfp_vdpa_log.h"
@@ -16,6 +17,11 @@
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
+
+	int vfio_container_fd;
+	int vfio_group_fd;
+	int vfio_dev_fd;
+	int iommu_group;
 };
 
 struct nfp_vdpa_dev_node {
@@ -53,12 +59,62 @@ nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
 	return NULL;
 }
 
+static int
+nfp_vdpa_vfio_setup(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	char dev_name[RTE_DEV_NAME_MAX_LEN] = {0};
+	struct rte_pci_device *pci_dev = device->pci_dev;
+
+	rte_pci_unmap_device(pci_dev);
+
+	rte_pci_device_name(&pci_dev->addr, dev_name, RTE_DEV_NAME_MAX_LEN);
+	rte_vfio_get_group_num(rte_pci_get_sysfs_path(), dev_name,
+			&device->iommu_group);
+
+	device->vfio_container_fd = rte_vfio_container_create();
+	if (device->vfio_container_fd < 0)
+		return -1;
+
+	device->vfio_group_fd = rte_vfio_container_group_bind(
+			device->vfio_container_fd, device->iommu_group);
+	if (device->vfio_group_fd < 0)
+		goto container_destroy;
+
+	DRV_VDPA_LOG(DEBUG, "container_fd=%d, group_fd=%d,\n",
+			device->vfio_container_fd, device->vfio_group_fd);
+
+	ret = rte_pci_map_device(pci_dev);
+	if (ret != 0)
+		goto group_unbind;
+
+	device->vfio_dev_fd = rte_intr_dev_fd_get(pci_dev->intr_handle);
+
+	return 0;
+
+group_unbind:
+	rte_vfio_container_group_unbind(device->vfio_container_fd, device->iommu_group);
+container_destroy:
+	rte_vfio_container_destroy(device->vfio_container_fd);
+
+	return -1;
+}
+
+static void
+nfp_vdpa_vfio_teardown(struct nfp_vdpa_dev *device)
+{
+	rte_pci_unmap_device(device->pci_dev);
+	rte_vfio_container_group_unbind(device->vfio_container_fd, device->iommu_group);
+	rte_vfio_container_destroy(device->vfio_container_fd);
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
 };
 
 static int
 nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 {
+	int ret;
 	struct nfp_vdpa_dev *device;
 	struct nfp_vdpa_dev_node *node;
 
@@ -75,10 +131,14 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 
 	device->pci_dev = pci_dev;
 
+	ret = nfp_vdpa_vfio_setup(device);
+	if (ret != 0)
+		goto free_device;
+
 	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
 	if (device->vdev == NULL) {
 		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
-		goto free_device;
+		goto vfio_teardown;
 	}
 
 	node->device = device;
@@ -88,6 +148,8 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 
 	return 0;
 
+vfio_teardown:
+	nfp_vdpa_vfio_teardown(device);
 free_device:
 	free(device);
 free_node:
@@ -118,6 +180,7 @@ nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
 	pthread_mutex_unlock(&vdpa_list_lock);
 
 	rte_vdpa_unregister_device(device->vdev);
+	nfp_vdpa_vfio_teardown(device);
 
 	free(device);
 	free(node);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 21/25] vdpa/nfp: add the hardware init logic
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (19 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 22/25] drivers: add the datapath update logic Chaoyong He
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the hardware initialize logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/meson.build     |  1 +
 drivers/vdpa/nfp/nfp_vdpa.c      | 10 ++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c | 54 ++++++++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h | 32 +++++++++++++++++++
 4 files changed, 97 insertions(+)
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.h

diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
index e1cc244578..27eb1a6276 100644
--- a/drivers/vdpa/nfp/meson.build
+++ b/drivers/vdpa/nfp/meson.build
@@ -13,6 +13,7 @@ endif
 
 sources = files(
         'nfp_vdpa.c',
+        'nfp_vdpa_core.c',
         'nfp_vdpa_log.c',
 )
 
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 824b0d681a..00d8f7e007 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -10,6 +10,7 @@
 #include <rte_vfio.h>
 #include <vdpa_driver.h>
 
+#include "nfp_vdpa_core.h"
 #include "nfp_vdpa_log.h"
 
 #define NFP_VDPA_DRIVER_NAME nfp_vdpa
@@ -17,11 +18,14 @@
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_hw hw;
 
 	int vfio_container_fd;
 	int vfio_group_fd;
 	int vfio_dev_fd;
 	int iommu_group;
+
+	uint16_t max_queues;
 };
 
 struct nfp_vdpa_dev_node {
@@ -135,6 +139,12 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 	if (ret != 0)
 		goto free_device;
 
+	ret = nfp_vdpa_hw_init(&device->hw, pci_dev);
+	if (ret != 0)
+		goto vfio_teardown;
+
+	device->max_queues = NFP_VDPA_MAX_QUEUES;
+
 	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
 	if (device->vdev == NULL) {
 		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
new file mode 100644
index 0000000000..a7e15fa88a
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_vdpa_core.h"
+
+#include <rte_vhost.h>
+
+#include "nfp_vdpa_log.h"
+
+/* Available and used descs are in same order */
+#ifndef VIRTIO_F_IN_ORDER
+#define VIRTIO_F_IN_ORDER      35
+#endif
+
+int
+nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
+		struct rte_pci_device *pci_dev)
+{
+	uint32_t queue;
+	struct nfp_hw *hw;
+	uint8_t *notify_base;
+
+	hw = &vdpa_hw->super;
+	hw->ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->ctrl_bar == NULL) {
+		DRV_CORE_LOG(ERR, "hw->ctrl_bar is NULL. BAR0 not configured.");
+		return -ENODEV;
+	}
+
+	notify_base = hw->ctrl_bar + NFP_VDPA_NOTIFY_ADDR_BASE;
+	for (queue = 0; queue < NFP_VDPA_MAX_QUEUES; queue++) {
+		uint32_t idx = queue * 2;
+
+		/* RX */
+		vdpa_hw->notify_addr[idx] = notify_base;
+		notify_base += NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+		/* TX */
+		vdpa_hw->notify_addr[idx + 1] = notify_base;
+		notify_base += NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+
+		vdpa_hw->notify_region = queue;
+		DRV_CORE_LOG(DEBUG, "notify_addr[%d] at %p, notify_addr[%d] at %p",
+				idx, vdpa_hw->notify_addr[idx],
+				idx + 1, vdpa_hw->notify_addr[idx + 1]);
+	}
+
+	vdpa_hw->features = (1ULL << VIRTIO_F_VERSION_1) |
+			(1ULL << VIRTIO_F_IN_ORDER) |
+			(1ULL << VHOST_USER_F_PROTOCOL_FEATURES);
+
+	return 0;
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
new file mode 100644
index 0000000000..c9403e0ea4
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_VDPA_CORE_H__
+#define __NFP_VDPA_CORE_H__
+
+#include <bus_pci_driver.h>
+#include <nfp_common.h>
+#include <rte_ether.h>
+
+#define NFP_VDPA_MAX_QUEUES         1
+
+#define NFP_VDPA_NOTIFY_ADDR_BASE        0x4000
+#define NFP_VDPA_NOTIFY_ADDR_INTERVAL    0x1000
+
+struct nfp_vdpa_hw {
+	struct nfp_hw super;
+
+	uint64_t features;
+	uint64_t req_features;
+
+	uint8_t *notify_addr[NFP_VDPA_MAX_QUEUES * 2];
+
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+	uint8_t notify_region;
+};
+
+int nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, struct rte_pci_device *dev);
+
+#endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 22/25] drivers: add the datapath update logic
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (20 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 23/25] vdpa/nfp: add the notify related logic Chaoyong He
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the vDPA datapath update logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h |   1 +
 drivers/vdpa/nfp/nfp_vdpa.c          | 315 +++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c     |  78 +++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h     |  15 ++
 4 files changed, 409 insertions(+)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 3c8cd916cf..f92ce50fc0 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -238,6 +238,7 @@ struct nfp_net_fw_ver {
 #define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
 #define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
 #define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
+#define NFP_NET_CFG_CTRL_IN_ORDER         (0x1 << 11) /**< Virtio in-order flag */
 
 #define NFP_NET_CFG_CAP_WORD1           0x00a4
 
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 00d8f7e007..465ee4841d 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -4,6 +4,7 @@
  */
 
 #include <pthread.h>
+#include <sys/ioctl.h>
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
@@ -15,6 +16,9 @@
 
 #define NFP_VDPA_DRIVER_NAME nfp_vdpa
 
+#define MSIX_IRQ_SET_BUF_LEN (sizeof(struct vfio_irq_set) + \
+		sizeof(int) * (NFP_VDPA_MAX_QUEUES * 2 + 1))
+
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
@@ -25,7 +29,15 @@ struct nfp_vdpa_dev {
 	int vfio_dev_fd;
 	int iommu_group;
 
+	int vid;
 	uint16_t max_queues;
+	uint32_t started;
+	uint32_t dev_attached;
+	uint32_t running;
+	rte_spinlock_t lock;
+
+	/** Eventfd for used ring interrupt */
+	int intr_fd[NFP_VDPA_MAX_QUEUES * 2];
 };
 
 struct nfp_vdpa_dev_node {
@@ -112,6 +124,302 @@ nfp_vdpa_vfio_teardown(struct nfp_vdpa_dev *device)
 	rte_vfio_container_destroy(device->vfio_container_fd);
 }
 
+static int
+nfp_vdpa_dma_do_unmap(struct rte_vhost_memory *mem,
+		uint32_t times,
+		int vfio_container_fd)
+{
+	uint32_t i;
+	int ret = 0;
+	struct rte_vhost_mem_region *region;
+
+	for (i = 0; i < times; i++) {
+		region = &mem->regions[i];
+
+		ret = rte_vfio_container_dma_unmap(vfio_container_fd,
+				region->host_user_addr, region->guest_phys_addr,
+				region->size);
+		if (ret < 0) {
+			/* Here should not return, even error happened. */
+			DRV_VDPA_LOG(ERR, "DMA unmap failed. Times: %u", i);
+		}
+	}
+
+	return ret;
+}
+
+static int
+nfp_vdpa_dma_do_map(struct rte_vhost_memory *mem,
+		uint32_t times,
+		int vfio_container_fd)
+{
+	int ret;
+	uint32_t i;
+	struct rte_vhost_mem_region *region;
+
+	for (i = 0; i < times; i++) {
+		region = &mem->regions[i];
+
+		ret = rte_vfio_container_dma_map(vfio_container_fd,
+				region->host_user_addr, region->guest_phys_addr,
+				region->size);
+		if (ret < 0) {
+			DRV_VDPA_LOG(ERR, "DMA map failed.");
+			nfp_vdpa_dma_do_unmap(mem, i, vfio_container_fd);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_dma_map(struct nfp_vdpa_dev *device,
+		bool do_map)
+{
+	int ret;
+	int vfio_container_fd;
+	struct rte_vhost_memory *mem = NULL;
+
+	ret = rte_vhost_get_mem_table(device->vid, &mem);
+	if (ret < 0) {
+		DRV_VDPA_LOG(ERR, "Failed to get memory layout.");
+		return ret;
+	}
+
+	vfio_container_fd = device->vfio_container_fd;
+	DRV_VDPA_LOG(DEBUG, "vfio_container_fd %d", vfio_container_fd);
+
+	if (do_map)
+		ret = nfp_vdpa_dma_do_map(mem, mem->nregions, vfio_container_fd);
+	else
+		ret = nfp_vdpa_dma_do_unmap(mem, mem->nregions, vfio_container_fd);
+
+	free(mem);
+
+	return ret;
+}
+
+static uint64_t
+nfp_vdpa_qva_to_gpa(int vid,
+		uint64_t qva)
+{
+	int ret;
+	uint32_t i;
+	uint64_t gpa = 0;
+	struct rte_vhost_memory *mem = NULL;
+	struct rte_vhost_mem_region *region;
+
+	ret = rte_vhost_get_mem_table(vid, &mem);
+	if (ret < 0) {
+		DRV_VDPA_LOG(ERR, "Failed to get memory layout.");
+		return gpa;
+	}
+
+	for (i = 0; i < mem->nregions; i++) {
+		region = &mem->regions[i];
+
+		if (qva >= region->host_user_addr &&
+				qva < region->host_user_addr + region->size) {
+			gpa = qva - region->host_user_addr + region->guest_phys_addr;
+			break;
+		}
+	}
+
+	free(mem);
+
+	return gpa;
+}
+
+static int
+nfp_vdpa_start(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	int vid;
+	uint16_t i;
+	uint64_t gpa;
+	struct rte_vhost_vring vring;
+	struct nfp_vdpa_hw *vdpa_hw = &device->hw;
+
+	vid = device->vid;
+	vdpa_hw->nr_vring = rte_vhost_get_vring_num(vid);
+
+	ret = rte_vhost_get_negotiated_features(vid, &vdpa_hw->req_features);
+	if (ret != 0)
+		return ret;
+
+	for (i = 0; i < vdpa_hw->nr_vring; i++) {
+		ret = rte_vhost_get_vhost_vring(vid, i, &vring);
+		if (ret != 0)
+			return ret;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.desc);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for descriptor ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].desc = gpa;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.avail);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for available ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].avail = gpa;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.used);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for used ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].used = gpa;
+
+		vdpa_hw->vring[i].size = vring.size;
+
+		ret = rte_vhost_get_vring_base(vid, i,
+				&vdpa_hw->vring[i].last_avail_idx,
+				&vdpa_hw->vring[i].last_used_idx);
+		if (ret != 0)
+			return ret;
+	}
+
+	return nfp_vdpa_hw_start(&device->hw, vid);
+}
+
+static void
+nfp_vdpa_stop(struct nfp_vdpa_dev *device)
+{
+	int vid;
+	uint32_t i;
+	struct nfp_vdpa_hw *vdpa_hw = &device->hw;
+
+	nfp_vdpa_hw_stop(vdpa_hw);
+
+	vid = device->vid;
+	for (i = 0; i < vdpa_hw->nr_vring; i++)
+		rte_vhost_set_vring_base(vid, i,
+				vdpa_hw->vring[i].last_avail_idx,
+				vdpa_hw->vring[i].last_used_idx);
+}
+
+static int
+nfp_vdpa_enable_vfio_intr(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	uint16_t i;
+	int *fd_ptr;
+	uint16_t nr_vring;
+	struct vfio_irq_set *irq_set;
+	struct rte_vhost_vring vring;
+	char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
+
+	nr_vring = rte_vhost_get_vring_num(device->vid);
+
+	irq_set = (struct vfio_irq_set *)irq_set_buf;
+	irq_set->argsz = sizeof(irq_set_buf);
+	irq_set->count = nr_vring + 1;
+	irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;
+	irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
+	irq_set->start = 0;
+
+	fd_ptr = (int *)&irq_set->data;
+	fd_ptr[RTE_INTR_VEC_ZERO_OFFSET] = rte_intr_fd_get(device->pci_dev->intr_handle);
+
+	for (i = 0; i < nr_vring; i++)
+		device->intr_fd[i] = -1;
+
+	for (i = 0; i < nr_vring; i++) {
+		rte_vhost_get_vhost_vring(device->vid, i, &vring);
+		fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = vring.callfd;
+	}
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Error enabling MSI-X interrupts.");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_disable_vfio_intr(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	struct vfio_irq_set *irq_set;
+	char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
+
+	irq_set = (struct vfio_irq_set *)irq_set_buf;
+	irq_set->argsz = sizeof(irq_set_buf);
+	irq_set->count = 0;
+	irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER;
+	irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
+	irq_set->start = 0;
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Error disabling MSI-X interrupts.");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int
+update_datapath(struct nfp_vdpa_dev *device)
+{
+	int ret;
+
+	rte_spinlock_lock(&device->lock);
+
+	if ((__atomic_load_n(&device->running, __ATOMIC_RELAXED) == 0) &&
+			(__atomic_load_n(&device->started, __ATOMIC_RELAXED) != 0) &&
+			(__atomic_load_n(&device->dev_attached, __ATOMIC_RELAXED) != 0)) {
+		ret = nfp_vdpa_dma_map(device, true);
+		if (ret != 0)
+			goto unlock_exit;
+
+		ret = nfp_vdpa_enable_vfio_intr(device);
+		if (ret != 0)
+			goto dma_map_rollback;
+
+		ret = nfp_vdpa_start(device);
+		if (ret != 0)
+			goto disable_vfio_intr;
+
+		__atomic_store_n(&device->running, 1, __ATOMIC_RELAXED);
+	} else if ((__atomic_load_n(&device->running, __ATOMIC_RELAXED) != 0) &&
+			((__atomic_load_n(&device->started, __ATOMIC_RELAXED) != 0) ||
+			(__atomic_load_n(&device->dev_attached, __ATOMIC_RELAXED) != 0))) {
+
+		nfp_vdpa_stop(device);
+
+		ret = nfp_vdpa_disable_vfio_intr(device);
+		if (ret != 0)
+			goto unlock_exit;
+
+		ret = nfp_vdpa_dma_map(device, false);
+		if (ret != 0)
+			goto unlock_exit;
+
+		__atomic_store_n(&device->running, 0, __ATOMIC_RELAXED);
+	}
+
+	rte_spinlock_unlock(&device->lock);
+	return 0;
+
+disable_vfio_intr:
+	nfp_vdpa_disable_vfio_intr(device);
+dma_map_rollback:
+	nfp_vdpa_dma_map(device, false);
+unlock_exit:
+	rte_spinlock_unlock(&device->lock);
+	return ret;
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
 };
 
@@ -156,6 +464,10 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 	TAILQ_INSERT_TAIL(&vdpa_dev_list, node, next);
 	pthread_mutex_unlock(&vdpa_list_lock);
 
+	rte_spinlock_init(&device->lock);
+	__atomic_store_n(&device->started, 1, __ATOMIC_RELAXED);
+	update_datapath(device);
+
 	return 0;
 
 vfio_teardown:
@@ -185,6 +497,9 @@ nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
 
 	device = node->device;
 
+	__atomic_store_n(&device->started, 0, __ATOMIC_RELAXED);
+	update_datapath(device);
+
 	pthread_mutex_lock(&vdpa_list_lock);
 	TAILQ_REMOVE(&vdpa_dev_list, node, next);
 	pthread_mutex_unlock(&vdpa_list_lock);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
index a7e15fa88a..db9b8462b4 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.c
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -5,6 +5,7 @@
 
 #include "nfp_vdpa_core.h"
 
+#include <nfp_common.h>
 #include <rte_vhost.h>
 
 #include "nfp_vdpa_log.h"
@@ -52,3 +53,80 @@ nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
 
 	return 0;
 }
+
+static uint32_t
+nfp_vdpa_check_offloads(void)
+{
+	return NFP_NET_CFG_CTRL_SCATTER |
+			NFP_NET_CFG_CTRL_IN_ORDER;
+}
+
+int
+nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw,
+		int vid)
+{
+	int ret;
+	uint32_t update;
+	uint32_t new_ctrl;
+	struct timespec wait_tst;
+	struct nfp_hw *hw = &vdpa_hw->super;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(0), vdpa_hw->vring[1].desc);
+	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(0), rte_log2_u32(vdpa_hw->vring[1].size));
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(1), vdpa_hw->vring[1].avail);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(2), vdpa_hw->vring[1].used);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(0), vdpa_hw->vring[0].desc);
+	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(0), rte_log2_u32(vdpa_hw->vring[0].size));
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(1), vdpa_hw->vring[0].avail);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(2), vdpa_hw->vring[0].used);
+
+	rte_wmb();
+
+	nfp_disable_queues(hw);
+	nfp_enable_queues(hw, NFP_VDPA_MAX_QUEUES, NFP_VDPA_MAX_QUEUES);
+
+	new_ctrl = nfp_vdpa_check_offloads();
+
+	nn_cfg_writel(hw, NFP_NET_CFG_MTU, 9216);
+	nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, 10240);
+
+	/* TODO: Temporary set MAC to fixed value fe:1b:ac:05:a5:22 */
+	mac_addr[0] = 0xfe;
+	mac_addr[1] = 0x1b;
+	mac_addr[2] = 0xac;
+	mac_addr[3] = 0x05;
+	mac_addr[4] = 0xa5;
+	mac_addr[5] = (0x22 + vid);
+
+	/* Writing new MAC to the specific port BAR address */
+	nfp_write_mac(hw, (uint8_t *)mac_addr);
+
+	/* Enable device */
+	new_ctrl |= NFP_NET_CFG_CTRL_ENABLE;
+
+	/* Signal the NIC about the change */
+	update = NFP_NET_CFG_UPDATE_MACADDR |
+			NFP_NET_CFG_UPDATE_GEN |
+			NFP_NET_CFG_UPDATE_RING;
+
+	ret = nfp_reconfig(hw, new_ctrl, update);
+	if (ret < 0)
+		return -EIO;
+
+	hw->ctrl = new_ctrl;
+
+	DRV_CORE_LOG(DEBUG, "Enabling the device, sleep 1 seconds...");
+	wait_tst.tv_sec = 1;
+	wait_tst.tv_nsec = 0;
+	nanosleep(&wait_tst, 0);
+
+	return 0;
+}
+
+void
+nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw)
+{
+	nfp_disable_queues(&vdpa_hw->super);
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
index c9403e0ea4..a88de768dd 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.h
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -15,6 +15,15 @@
 #define NFP_VDPA_NOTIFY_ADDR_BASE        0x4000
 #define NFP_VDPA_NOTIFY_ADDR_INTERVAL    0x1000
 
+struct nfp_vdpa_vring {
+	uint64_t desc;
+	uint64_t avail;
+	uint64_t used;
+	uint16_t size;
+	uint16_t last_avail_idx;
+	uint16_t last_used_idx;
+};
+
 struct nfp_vdpa_hw {
 	struct nfp_hw super;
 
@@ -22,11 +31,17 @@ struct nfp_vdpa_hw {
 	uint64_t req_features;
 
 	uint8_t *notify_addr[NFP_VDPA_MAX_QUEUES * 2];
+	struct nfp_vdpa_vring vring[NFP_VDPA_MAX_QUEUES * 2];
 
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t notify_region;
+	uint8_t nr_vring;
 };
 
 int nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, struct rte_pci_device *dev);
 
+int nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw, int vid);
+
+void nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw);
+
 #endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 23/25] vdpa/nfp: add the notify related logic
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (21 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 22/25] drivers: add the datapath update logic Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the logic to process vDPA notify relay.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c      | 155 +++++++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c |  61 ++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h |   4 +
 3 files changed, 220 insertions(+)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 465ee4841d..01a59e2cfd 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -4,7 +4,9 @@
  */
 
 #include <pthread.h>
+#include <sys/epoll.h>
 #include <sys/ioctl.h>
+#include <unistd.h>
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
@@ -29,6 +31,9 @@ struct nfp_vdpa_dev {
 	int vfio_dev_fd;
 	int iommu_group;
 
+	pthread_t tid;    /**< Thread for notify relay */
+	int epoll_fd;
+
 	int vid;
 	uint16_t max_queues;
 	uint32_t started;
@@ -368,6 +373,148 @@ nfp_vdpa_disable_vfio_intr(struct nfp_vdpa_dev *device)
 	return 0;
 }
 
+static void
+nfp_vdpa_read_kickfd(int kickfd)
+{
+	int bytes;
+	uint64_t buf;
+
+	for (;;) {
+		bytes = read(kickfd, &buf, 8);
+		if (bytes >= 0)
+			break;
+
+		if (errno != EINTR && errno != EWOULDBLOCK &&
+				errno != EAGAIN) {
+			DRV_VDPA_LOG(ERR, "Error reading kickfd");
+			break;
+		}
+	}
+}
+
+static int
+nfp_vdpa_notify_epoll_ctl(uint32_t queue_num,
+		struct nfp_vdpa_dev *device)
+{
+	int ret;
+	uint32_t qid;
+
+	for (qid = 0; qid < queue_num; qid++) {
+		struct epoll_event ev;
+		struct rte_vhost_vring vring;
+
+		ev.events = EPOLLIN | EPOLLPRI;
+		rte_vhost_get_vhost_vring(device->vid, qid, &vring);
+		ev.data.u64 = qid | (uint64_t)vring.kickfd << 32;
+		ret = epoll_ctl(device->epoll_fd, EPOLL_CTL_ADD, vring.kickfd, &ev);
+		if (ret < 0) {
+			DRV_VDPA_LOG(ERR, "Epoll add error for queue %d", qid);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_notify_epoll_wait(uint32_t queue_num,
+		struct nfp_vdpa_dev *device)
+{
+	int i;
+	int fds;
+	int kickfd;
+	uint32_t qid;
+	struct epoll_event events[NFP_VDPA_MAX_QUEUES * 2];
+
+	for (;;) {
+		fds = epoll_wait(device->epoll_fd, events, queue_num, -1);
+		if (fds < 0) {
+			if (errno == EINTR)
+				continue;
+
+			DRV_VDPA_LOG(ERR, "Epoll wait fail");
+			return -EACCES;
+		}
+
+		for (i = 0; i < fds; i++) {
+			qid = events[i].data.u32;
+			kickfd = (uint32_t)(events[i].data.u64 >> 32);
+
+			nfp_vdpa_read_kickfd(kickfd);
+			nfp_vdpa_notify_queue(&device->hw, qid);
+		}
+	}
+
+	return 0;
+}
+
+static void *
+nfp_vdpa_notify_relay(void *arg)
+{
+	int ret;
+	int epoll_fd;
+	uint32_t queue_num;
+	struct nfp_vdpa_dev *device = arg;
+
+	epoll_fd = epoll_create(NFP_VDPA_MAX_QUEUES * 2);
+	if (epoll_fd < 0) {
+		DRV_VDPA_LOG(ERR, "failed to create epoll instance.");
+		return NULL;
+	}
+
+	device->epoll_fd = epoll_fd;
+
+	queue_num = rte_vhost_get_vring_num(device->vid);
+
+	ret = nfp_vdpa_notify_epoll_ctl(queue_num, device);
+	if (ret != 0)
+		goto notify_exit;
+
+	ret = nfp_vdpa_notify_epoll_wait(queue_num, device);
+	if (ret != 0)
+		goto notify_exit;
+
+	return 0;
+
+notify_exit:
+	close(device->epoll_fd);
+	device->epoll_fd = -1;
+
+	return NULL;
+}
+
+static int
+nfp_vdpa_setup_notify_relay(struct nfp_vdpa_dev *device)
+{
+	int ret;
+
+	ret = pthread_create(&device->tid, NULL, nfp_vdpa_notify_relay,
+			(void *)device);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Failed to create notify relay pthread.");
+		return -1;
+	}
+
+	return 0;
+}
+
+static void
+nfp_vdpa_unset_notify_relay(struct nfp_vdpa_dev *device)
+{
+	void *status;
+
+	if (device->tid != 0) {
+		pthread_cancel(device->tid);
+		pthread_join(device->tid, &status);
+		device->tid = 0;
+	}
+
+	if (device->epoll_fd >= 0) {
+		close(device->epoll_fd);
+		device->epoll_fd = -1;
+	}
+}
+
 static int
 update_datapath(struct nfp_vdpa_dev *device)
 {
@@ -390,11 +537,17 @@ update_datapath(struct nfp_vdpa_dev *device)
 		if (ret != 0)
 			goto disable_vfio_intr;
 
+		ret = nfp_vdpa_setup_notify_relay(device);
+		if (ret != 0)
+			goto vdpa_stop;
+
 		__atomic_store_n(&device->running, 1, __ATOMIC_RELAXED);
 	} else if ((__atomic_load_n(&device->running, __ATOMIC_RELAXED) != 0) &&
 			((__atomic_load_n(&device->started, __ATOMIC_RELAXED) != 0) ||
 			(__atomic_load_n(&device->dev_attached, __ATOMIC_RELAXED) != 0))) {
 
+		nfp_vdpa_unset_notify_relay(device);
+
 		nfp_vdpa_stop(device);
 
 		ret = nfp_vdpa_disable_vfio_intr(device);
@@ -411,6 +564,8 @@ update_datapath(struct nfp_vdpa_dev *device)
 	rte_spinlock_unlock(&device->lock);
 	return 0;
 
+vdpa_stop:
+	nfp_vdpa_stop(device);
 disable_vfio_intr:
 	nfp_vdpa_disable_vfio_intr(device);
 dma_map_rollback:
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
index db9b8462b4..e2a6253ae5 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.c
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -15,6 +15,41 @@
 #define VIRTIO_F_IN_ORDER      35
 #endif
 
+#define NFP_QCP_NOTIFY_MAX_ADD    0x7f
+
+enum nfp_qcp_notify_ptr {
+	NFP_QCP_NOTIFY_WRITE_PTR = 0,
+	NFP_QCP_NOTIFY_READ_PTR
+};
+
+/**
+ * Add the value to the selected pointer of a queue
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Add to the Read or Write pointer
+ * @param val
+ *   Value to add to the queue pointer
+ */
+static inline void
+nfp_qcp_notify_ptr_add(uint8_t *q,
+		enum nfp_qcp_notify_ptr ptr,
+		uint32_t val)
+{
+	uint32_t off;
+
+	if (ptr == NFP_QCP_NOTIFY_WRITE_PTR)
+		off = NFP_QCP_QUEUE_ADD_RPTR;
+	else
+		off = NFP_QCP_QUEUE_ADD_WPTR;
+
+	for (; val > NFP_QCP_NOTIFY_MAX_ADD; val -= NFP_QCP_NOTIFY_MAX_ADD)
+		nn_writel(rte_cpu_to_le_32(NFP_QCP_NOTIFY_MAX_ADD), q + off);
+
+	nn_writel(rte_cpu_to_le_32(val), q + off);
+}
+
 int
 nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
 		struct rte_pci_device *pci_dev)
@@ -130,3 +165,29 @@ nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw)
 {
 	nfp_disable_queues(&vdpa_hw->super);
 }
+
+/*
+ * This offset is used for mmaping the notify area. It implies it needs
+ * to be a multiple of PAGE_SIZE.
+ * For debugging, using notify region 0 with an offset of 4K. This should
+ * point to the conf bar.
+ */
+uint64_t
+nfp_vdpa_get_queue_notify_offset(struct nfp_vdpa_hw *vdpa_hw __rte_unused,
+		int qid)
+{
+	return NFP_VDPA_NOTIFY_ADDR_BASE + (qid * NFP_VDPA_NOTIFY_ADDR_INTERVAL);
+}
+
+/*
+ * With just one queue the increment is 0, which does not
+ * incremente the counter but will raise a queue event due
+ * to queue configured for watermark events.
+ */
+void
+nfp_vdpa_notify_queue(struct nfp_vdpa_hw *vdpa_hw,
+		uint16_t qid)
+{
+	nfp_qcp_notify_ptr_add(vdpa_hw->notify_addr[qid],
+			NFP_QCP_NOTIFY_WRITE_PTR, qid);
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
index a88de768dd..a8e0d6dd70 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.h
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -44,4 +44,8 @@ int nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw, int vid);
 
 void nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw);
 
+void nfp_vdpa_notify_queue(struct nfp_vdpa_hw *vdpa_hw, uint16_t qid);
+
+uint64_t nfp_vdpa_get_queue_notify_offset(struct nfp_vdpa_hw *vdpa_hw, int qid);
+
 #endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 24/25] vdpa/nfp: add nfp vDPA device operations
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (22 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 23/25] vdpa/nfp: add the notify related logic Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-17  5:45 ` [PATCH 25/25] doc: add the common and vDPA document Chaoyong He
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Implement the corresponding nfp vDPA opetation functions.

Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
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/vdpa/nfp/nfp_vdpa.c | 213 ++++++++++++++++++++++++++++++++++++
 1 file changed, 213 insertions(+)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 01a59e2cfd..860b5cce63 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -57,6 +57,29 @@ static struct vdpa_dev_list_head vdpa_dev_list =
 
 static pthread_mutex_t vdpa_list_lock = PTHREAD_MUTEX_INITIALIZER;
 
+static struct nfp_vdpa_dev_node *
+nfp_vdpa_find_node_by_vdev(struct rte_vdpa_device *vdev)
+{
+	bool found = false;
+	struct nfp_vdpa_dev_node *node;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+
+	TAILQ_FOREACH(node, &vdpa_dev_list, next) {
+		if (vdev == node->device->vdev) {
+			found = true;
+			break;
+		}
+	}
+
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	if (found)
+		return node;
+
+	return NULL;
+}
+
 static struct nfp_vdpa_dev_node *
 nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
 {
@@ -575,7 +598,197 @@ update_datapath(struct nfp_vdpa_dev *device)
 	return ret;
 }
 
+static int
+nfp_vdpa_dev_config(int vid)
+{
+	int ret;
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	device->vid = vid;
+	__atomic_store_n(&device->dev_attached, 1, __ATOMIC_RELAXED);
+	update_datapath(device);
+
+	ret = rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true);
+	if (ret != 0)
+		DRV_VDPA_LOG(INFO, "vDPA (%s): software relay is used.",
+				vdev->device->name);
+
+	return 0;
+}
+
+static int
+nfp_vdpa_dev_close(int vid)
+{
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	__atomic_store_n(&device->dev_attached, 0, __ATOMIC_RELAXED);
+	update_datapath(device);
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_vfio_group_fd(int vid)
+{
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	return node->device->vfio_group_fd;
+}
+
+static int
+nfp_vdpa_get_vfio_device_fd(int vid)
+{
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	return node->device->vfio_dev_fd;
+}
+
+static int
+nfp_vdpa_get_notify_area(int vid,
+		int qid,
+		uint64_t *offset,
+		uint64_t *size)
+{
+	int ret;
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+	struct vfio_region_info region = {
+		.argsz = sizeof(region)
+	};
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR,  "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	region.index = device->hw.notify_region;
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, &region);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Get not get device region info.");
+		return -EIO;
+	}
+
+	*offset = nfp_vdpa_get_queue_notify_offset(&device->hw, qid) + region.offset;
+	*size = NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_queue_num(struct rte_vdpa_device *vdev,
+		uint32_t *queue_num)
+{
+	struct nfp_vdpa_dev_node *node;
+
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	*queue_num = node->device->max_queues;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_vdpa_features(struct rte_vdpa_device *vdev,
+		uint64_t *features)
+{
+	struct nfp_vdpa_dev_node *node;
+
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR,  "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	*features = node->device->hw.features;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_protocol_features(struct rte_vdpa_device *vdev __rte_unused,
+		uint64_t *features)
+{
+	*features = 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD |
+			1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK |
+			1ULL << VHOST_USER_PROTOCOL_F_BACKEND_REQ |
+			1ULL << VHOST_USER_PROTOCOL_F_BACKEND_SEND_FD |
+			1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_set_features(int32_t vid)
+{
+	DRV_VDPA_LOG(DEBUG, "Start vid=%d", vid);
+	return 0;
+}
+
+static int
+nfp_vdpa_set_vring_state(int vid,
+		int vring,
+		int state)
+{
+	DRV_VDPA_LOG(DEBUG, "Start vid=%d, vring=%d, state=%d", vid, vring, state);
+	return 0;
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
+	.get_queue_num = nfp_vdpa_get_queue_num,
+	.get_features = nfp_vdpa_get_vdpa_features,
+	.get_protocol_features = nfp_vdpa_get_protocol_features,
+	.dev_conf = nfp_vdpa_dev_config,
+	.dev_close = nfp_vdpa_dev_close,
+	.set_vring_state = nfp_vdpa_set_vring_state,
+	.set_features = nfp_vdpa_set_features,
+	.get_vfio_group_fd = nfp_vdpa_get_vfio_group_fd,
+	.get_vfio_device_fd = nfp_vdpa_get_vfio_device_fd,
+	.get_notify_area = nfp_vdpa_get_notify_area,
 };
 
 static int
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH 25/25] doc: add the common and vDPA document
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (23 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
@ 2023-10-17  5:45 ` Chaoyong He
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
  25 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-17  5:45 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the document for nfp common library and vDPA PMD.

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>
---
 MAINTAINERS                            |  8 ++++
 doc/guides/platform/index.rst          |  1 +
 doc/guides/platform/nfp.rst            | 30 ++++++++++++++
 doc/guides/rel_notes/release_23_11.rst |  5 +++
 doc/guides/vdpadevs/features/nfp.ini   |  8 ++++
 doc/guides/vdpadevs/index.rst          |  1 +
 doc/guides/vdpadevs/nfp.rst            | 54 ++++++++++++++++++++++++++
 7 files changed, 107 insertions(+)
 create mode 100644 doc/guides/platform/nfp.rst
 create mode 100644 doc/guides/vdpadevs/features/nfp.ini
 create mode 100644 doc/guides/vdpadevs/nfp.rst

diff --git a/MAINTAINERS b/MAINTAINERS
index 80e071d13e..4891bb6203 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -904,9 +904,11 @@ F: doc/guides/nics/features/nfb.ini
 Netronome nfp
 M: Chaoyong He <chaoyong.he@corigine.com>
 M: Niklas Soderlund <niklas.soderlund@corigine.com>
+F: drivers/common/nfp/
 F: drivers/net/nfp/
 F: doc/guides/nics/nfp.rst
 F: doc/guides/nics/features/nfp*.ini
+F: doc/guides/platform/nfp.rst
 
 NXP dpaa
 M: Hemant Agrawal <hemant.agrawal@nxp.com>
@@ -1310,6 +1312,12 @@ F: drivers/vdpa/ifc/
 F: doc/guides/vdpadevs/ifc.rst
 F: doc/guides/vdpadevs/features/ifcvf.ini
 
+Corigine nfp vDPA
+M: Chaoyong He <chaoyong.he@corigine.com>
+F: drivers/vdpa/nfp/
+F: doc/guides/vpdadevs/nfp.rst
+F: doc/guides/vdpadevs/features/nfp.ini
+
 NVIDIA mlx5 vDPA
 M: Matan Azrad <matan@nvidia.com>
 M: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
diff --git a/doc/guides/platform/index.rst b/doc/guides/platform/index.rst
index b1ba11df73..07dd273821 100644
--- a/doc/guides/platform/index.rst
+++ b/doc/guides/platform/index.rst
@@ -15,4 +15,5 @@ The following are platform specific guides and setup information.
     dpaa
     dpaa2
     mlx5
+    nfp
     octeontx
diff --git a/doc/guides/platform/nfp.rst b/doc/guides/platform/nfp.rst
new file mode 100644
index 0000000000..f6c7be6fff
--- /dev/null
+++ b/doc/guides/platform/nfp.rst
@@ -0,0 +1,30 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (c) 2023 Corigine, Inc.
+
+NFP Common Driver
+=================
+
+The NFP common driver library (**librte_common_nfp**) provides support for
+the Netronome and Corigine's NFP-6xxx, NFP-4xxx and NFP-38xx product lines.
+
+Classes
+-------
+
+One NFP device can be probed by a number of different PMDs.
+To select a specific PMD, its name should be specified as a device parameter
+(e.g. ``0000:08:00.1,class=eth``).
+
+
+Supported Classes
+~~~~~~~~~~~~~~~~~
+
+- ``class=eth`` for :doc:`../nics/nfp`.
+- ``class=vdpa`` for :doc:`../vdpadevs/nfp`.
+
+By default, the NFP device will be probed by the ``eth`` PMD.
+
+
+Limitations
+~~~~~~~~~~~
+
+- ``eth`` and ``vdpa`` PMDs cannot be probed at the same time.
diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index d0c8b8364c..64e1e113a7 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -158,6 +158,11 @@ New Features
 
   * Added inline IPsec offload based on the security framework.
 
+* **Add new vDPA PMD based on Corigine NFP devices.**
+
+  Added a new Corigine NFP vDPA (``nfp_vdpa``) PMD.
+  See the :doc:`../vdpadevs/nfp` guide for more details on this driver.
+
 * **Updated Wangxun ngbe driver.**
 
   * Added 100M and auto-neg support in YT PHY fiber mode.
diff --git a/doc/guides/vdpadevs/features/nfp.ini b/doc/guides/vdpadevs/features/nfp.ini
new file mode 100644
index 0000000000..d830feafe0
--- /dev/null
+++ b/doc/guides/vdpadevs/features/nfp.ini
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'nfp' vDPA driver.
+;
+; Refer to default.ini for the full list of available driver features.
+;
+[Features]
+Linux                   = Y
+x86-64                  = Y
diff --git a/doc/guides/vdpadevs/index.rst b/doc/guides/vdpadevs/index.rst
index cc2f858042..b0191a3a1d 100644
--- a/doc/guides/vdpadevs/index.rst
+++ b/doc/guides/vdpadevs/index.rst
@@ -14,4 +14,5 @@ which can be used from an application through vhost API.
     features_overview
     ifc
     mlx5
+    nfp
     sfc
diff --git a/doc/guides/vdpadevs/nfp.rst b/doc/guides/vdpadevs/nfp.rst
new file mode 100644
index 0000000000..63636b2882
--- /dev/null
+++ b/doc/guides/vdpadevs/nfp.rst
@@ -0,0 +1,54 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (c) 2023 Corigine, Inc.
+
+NFP vDPA driver
+===============
+
+The NFP vDPA (vhost data path acceleration) driver (**librte_nfp_vdpa**)
+provides support for the Netronome and Corigine's NFP-6xxx, NFP-4xxx
+and NFP-38xx product lines.
+
+NFP vDPA implementation
+-----------------------
+
+NFP VF device can be configured in the net device or vDPA mode.
+Adding "class=vdpa" parameter helps to specify that this device is to
+be used in vDPA mode. If this parameter is not specified, device
+will be probed by net/nfp driver and will used as a VF net device.
+
+This PMD uses (common/nfp) code to access the device firmware.
+
+Per-Device Parameters
+~~~~~~~~~~~~~~~~~~~~~
+
+The following per-device parameters can be passed via EAL PCI device
+allowlist option like "-a 02:00.0,arg1=value1,...".
+
+- ``class`` [net|vdpa] (default **net**)
+
+  Choose the mode of operation of nfp device.
+  **net** device will work as network device and will be probed by net/nfp driver.
+  **vdpa** device will work as vdpa device and will be probed by vdpa/nfp driver.
+  If this parameter is not specified then nfp device will operate as network device.
+
+Dynamic Logging Parameters
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+One may leverage EAL option "--log-level" to change default levels
+for the log types supported by the driver. The option is used with
+an argument typically consisting of two parts separated by a colon.
+
+Level value is the last part which takes a symbolic name (or integer).
+Log type is the former part which may shell match syntax.
+Depending on the choice of the expression, the given log level may
+be used either for some specific log type or for a subset of types.
+
+NFP vDPA PMD provides the following log types available for control:
+
+- ``pmd.vdpa.nfp.vdpa`` (default level is **notice**)
+
+  Affects driver-wide messages unrelated to any particular devices.
+
+- ``pmd.vdpa.nfp.core`` (default level is **notice**)
+
+  Affects the core logic of this PMD.
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 00/25] add the NFP vDPA PMD
  2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
                   ` (24 preceding siblings ...)
  2023-10-17  5:45 ` [PATCH 25/25] doc: add the common and vDPA document Chaoyong He
@ 2023-10-24  2:28 ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 01/25] drivers: introduce the NFP common library Chaoyong He
                     ` (26 more replies)
  25 siblings, 27 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series aims to add the NFP vDPA PMD, we also grab the common
logic into the `drivers/common/nfp` directory.

---
v2:
* Grab more logic into the `drivers/common/nfp` directory.
* Delete some logic which should be when moving logic.
---

Chaoyong He (25):
  drivers: introduce the NFP common library
  net/nfp: make VF PMD using of NFP common module
  net/nfp: rename common module name
  net/nfp: rename ctrl module name
  net/nfp: extract the cap data field
  net/nfp: extract the qcp data field
  net/nfp: extract the ctrl BAR data field
  net/nfp: extract the ctrl data field
  net/nfp: change the parameter of APIs
  net/nfp: change the parameter of reconfig
  net/nfp: extract the MAC address data field
  net/nfp: rename parameter in related logic
  drivers: add the common ctrl module
  drivers: add the nfp common module
  drivers: move queue logic to common module
  drivers: move platform module to common library
  drivers: move device module to common library
  drivers/vdpa: introduce the NFP vDPA library
  drivers: add the basic framework of vDPA PMD
  vdpa/nfp: add the logic of remap PCI memory
  vdpa/nfp: add the hardware init logic
  drivers: add the datapath update logic
  vdpa/nfp: add the notify related logic
  vdpa/nfp: add nfp vDPA device operations
  doc: add the common and vDPA document

 .mailmap                                      |   1 +
 MAINTAINERS                                   |   8 +
 doc/guides/platform/index.rst                 |   1 +
 doc/guides/platform/nfp.rst                   |  30 +
 doc/guides/rel_notes/release_23_11.rst        |   5 +
 doc/guides/vdpadevs/features/nfp.ini          |   8 +
 doc/guides/vdpadevs/index.rst                 |   1 +
 doc/guides/vdpadevs/nfp.rst                   |  54 ++
 drivers/common/nfp/meson.build                |  16 +
 drivers/common/nfp/nfp_common.c               | 226 +++++
 drivers/common/nfp/nfp_common.h               | 239 +++++
 .../nfp/nfp_common_ctrl.h}                    | 209 +---
 drivers/common/nfp/nfp_common_log.c           |   8 +
 drivers/common/nfp/nfp_common_log.h           |  16 +
 drivers/common/nfp/nfp_common_pci.c           | 275 ++++++
 drivers/common/nfp/nfp_common_pci.h           |  45 +
 .../{net/nfp/nfpcore => common/nfp}/nfp_dev.c |   3 +-
 .../{net/nfp/nfpcore => common/nfp}/nfp_dev.h |   3 +
 .../nfp/nfpcore => common/nfp}/nfp_platform.h |   0
 drivers/common/nfp/version.map                |  16 +
 drivers/meson.build                           |   1 +
 drivers/net/nfp/flower/nfp_flower.c           |  56 +-
 drivers/net/nfp/flower/nfp_flower.h           |   2 +-
 .../net/nfp/flower/nfp_flower_representor.c   |  10 +-
 drivers/net/nfp/meson.build                   |  11 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c            |  18 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c            |  22 +-
 drivers/net/nfp/nfp_cpp_bridge.h              |   2 +-
 drivers/net/nfp/nfp_ethdev.c                  |  80 +-
 drivers/net/nfp/nfp_ethdev_vf.c               |  74 +-
 drivers/net/nfp/nfp_flow.h                    |   2 +-
 drivers/net/nfp/nfp_ipsec.c                   |  86 +-
 .../nfp/{nfp_common.c => nfp_net_common.c}    | 493 ++++------
 .../nfp/{nfp_common.h => nfp_net_common.h}    | 219 +----
 .../net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c}    |  21 +-
 drivers/net/nfp/nfp_net_ctrl.h                | 211 ++++
 drivers/net/nfp/nfp_rxtx.c                    |  20 +-
 drivers/net/nfp/nfpcore/nfp6000_pcie.h        |   2 +-
 drivers/net/nfp/nfpcore/nfp_cppcore.c         |   3 +-
 drivers/net/nfp/nfpcore/nfp_nsp.c             |   2 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c         |   3 +-
 drivers/vdpa/meson.build                      |   1 +
 drivers/vdpa/nfp/meson.build                  |  24 +
 drivers/vdpa/nfp/nfp_vdpa.c                   | 909 ++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c              | 193 ++++
 drivers/vdpa/nfp/nfp_vdpa_core.h              |  51 +
 drivers/vdpa/nfp/nfp_vdpa_log.c               |   9 +
 drivers/vdpa/nfp/nfp_vdpa_log.h               |  21 +
 48 files changed, 2769 insertions(+), 941 deletions(-)
 create mode 100644 doc/guides/platform/nfp.rst
 create mode 100644 doc/guides/vdpadevs/features/nfp.ini
 create mode 100644 doc/guides/vdpadevs/nfp.rst
 create mode 100644 drivers/common/nfp/meson.build
 create mode 100644 drivers/common/nfp/nfp_common.c
 create mode 100644 drivers/common/nfp/nfp_common.h
 rename drivers/{net/nfp/nfp_ctrl.h => common/nfp/nfp_common_ctrl.h} (63%)
 create mode 100644 drivers/common/nfp/nfp_common_log.c
 create mode 100644 drivers/common/nfp/nfp_common_log.h
 create mode 100644 drivers/common/nfp/nfp_common_pci.c
 create mode 100644 drivers/common/nfp/nfp_common_pci.h
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c (98%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h (96%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_platform.h (100%)
 create mode 100644 drivers/common/nfp/version.map
 rename drivers/net/nfp/{nfp_common.c => nfp_net_common.c} (80%)
 rename drivers/net/nfp/{nfp_common.h => nfp_net_common.h} (64%)
 rename drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} (84%)
 create mode 100644 drivers/net/nfp/nfp_net_ctrl.h
 create mode 100644 drivers/vdpa/nfp/meson.build
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.h
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 01/25] drivers: introduce the NFP common library
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
                     ` (25 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

A new NFP vdpa PMD will be added to support vdpa operations by NFP
adapters.

This vdpa PMD share some logic with the net/nfp PMD. So create a new
common library in drivers/common for NFP PMDs.

We import a 'nfp_class_driver' layer and which can support various
device type in addition to the ethernet device.

The shared logic will move into this common library in the following
commits.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 .mailmap                            |   1 +
 drivers/common/nfp/meson.build      |  14 ++
 drivers/common/nfp/nfp_common_log.c |   8 +
 drivers/common/nfp/nfp_common_log.h |  16 ++
 drivers/common/nfp/nfp_common_pci.c | 274 ++++++++++++++++++++++++++++
 drivers/common/nfp/nfp_common_pci.h |  44 +++++
 drivers/common/nfp/version.map      |   7 +
 drivers/meson.build                 |   1 +
 8 files changed, 365 insertions(+)
 create mode 100644 drivers/common/nfp/meson.build
 create mode 100644 drivers/common/nfp/nfp_common_log.c
 create mode 100644 drivers/common/nfp/nfp_common_log.h
 create mode 100644 drivers/common/nfp/nfp_common_pci.c
 create mode 100644 drivers/common/nfp/nfp_common_pci.h
 create mode 100644 drivers/common/nfp/version.map

diff --git a/.mailmap b/.mailmap
index 3f5bab26a8..9d9e015607 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1299,6 +1299,7 @@ Shuanglin Wang <shuanglin.wang@broadcom.com>
 Shuki Katzenelson <shuki@lightbitslabs.com>
 Shun Hao <shunh@nvidia.com>
 Shu Shen <shu.shen@radisys.com>
+Shujing Dong <shujing.dong@corigine.com>
 Shweta Choudaha <shweta.choudaha@att.com>
 Shyam Kumar Shrivastav <shrivastav.shyam@gmail.com>
 Shy Shyman <shys@nvidia.com> <shys@mellanox.com>
diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
new file mode 100644
index 0000000000..45871dfe35
--- /dev/null
+++ b/drivers/common/nfp/meson.build
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64-bit Linux'
+endif
+
+deps += ['bus_pci']
+
+sources = files(
+        'nfp_common_log.c',
+        'nfp_common_pci.c',
+)
diff --git a/drivers/common/nfp/nfp_common_log.c b/drivers/common/nfp/nfp_common_log.c
new file mode 100644
index 0000000000..e69e608eb9
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_log.c
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common_log.h"
+
+RTE_LOG_REGISTER_SUFFIX(nfp_logtype_common, common, NOTICE);
diff --git a/drivers/common/nfp/nfp_common_log.h b/drivers/common/nfp/nfp_common_log.h
new file mode 100644
index 0000000000..066e38e688
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_log.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_LOG_H__
+#define __NFP_COMMON_LOG_H__
+
+#include <rte_log.h>
+
+extern int nfp_logtype_common;
+#define PMD_DRV_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_logtype_common, \
+			"%s(): " fmt "\n", __func__, ## args)
+
+#endif/* __NFP_COMMON_LOG_H__ */
diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
new file mode 100644
index 0000000000..1aa8dd4bbd
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -0,0 +1,274 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common_pci.h"
+
+#include <string.h>
+
+#include <rte_class.h>
+#include <rte_devargs.h>
+#include <rte_kvargs.h>
+
+#include "nfp_common_log.h"
+
+/* Reported driver name. */
+#define NFP_PCI_DRIVER_NAME "nfp_common_pci"
+
+static struct rte_pci_driver nfp_common_pci_driver;
+
+/* PCI ID table is build dynamically based on registered nfp drivers. */
+static struct rte_pci_id *nfp_pci_id_table;
+
+/* Head of list of drivers. */
+static TAILQ_HEAD(nfp_drivers, nfp_class_driver) nfp_drivers_list =
+		TAILQ_HEAD_INITIALIZER(nfp_drivers_list);
+
+static bool nfp_common_initialized;
+
+static const struct {
+	const char *name;
+	enum nfp_class drv_class;
+} nfp_classes[] = {
+	{ .name = "eth",      .drv_class = NFP_CLASS_ETH },
+};
+
+static enum nfp_class
+nfp_class_name_to_value(const char *class_name)
+{
+	uint32_t i;
+
+	for (i = 0; i < RTE_DIM(nfp_classes); i++) {
+		if (strcmp(class_name, nfp_classes[i].name) == 0)
+			return nfp_classes[i].drv_class;
+	}
+
+	return NFP_CLASS_INVALID;
+}
+
+static uint32_t
+nfp_pci_id_table_size_get(const struct rte_pci_id *id_table)
+{
+	uint32_t table_size;
+
+	if (id_table == NULL)
+		return 0;
+
+	for (table_size = 0; id_table->vendor_id != 0; id_table++)
+		table_size++;
+
+	return table_size;
+}
+
+static bool
+nfp_pci_id_exists(const struct rte_pci_id *id,
+		const struct rte_pci_id *table,
+		uint32_t next_idx)
+{
+	uint32_t i;
+
+	if (next_idx == 0)
+		return false;
+
+	for (i = 0; i < next_idx; i++) {
+		if (id->device_id == table[i].device_id &&
+				id->vendor_id == table[i].vendor_id &&
+				id->subsystem_vendor_id == table[i].subsystem_vendor_id &&
+				id->subsystem_device_id == table[i].subsystem_device_id)
+			return true;
+	}
+
+	return false;
+}
+
+static void
+nfp_pci_id_insert(struct rte_pci_id *new_table,
+		uint32_t *next_idx,
+		const struct rte_pci_id *id_table)
+{
+	if (id_table == NULL)
+		return;
+
+	/* Add non duplicate entries to new table. */
+	for (; id_table->vendor_id != 0; id_table++) {
+		if (!nfp_pci_id_exists(id_table, new_table, *next_idx)) {
+			new_table[*next_idx] = *id_table;
+			(*next_idx)++;
+		}
+	}
+}
+
+static int
+nfp_pci_id_table_update(const struct rte_pci_id *driver_id_table)
+{
+	uint32_t i = 0;
+	uint32_t num_ids = 0;
+	struct rte_pci_id *old_table;
+	const struct rte_pci_id *id_iter;
+	struct rte_pci_id *updated_table;
+
+	old_table = nfp_pci_id_table;
+	if (old_table != NULL)
+		num_ids = nfp_pci_id_table_size_get(old_table);
+	num_ids += nfp_pci_id_table_size_get(driver_id_table);
+
+	/* Increase size by one for the termination entry of vendor_id = 0. */
+	num_ids += 1;
+	updated_table = calloc(num_ids, sizeof(struct rte_pci_id));
+	if (updated_table == NULL)
+		return -ENOMEM;
+
+	if (old_table == NULL) {
+		/* Copy the first driver's ID table. */
+		for (id_iter = driver_id_table; id_iter[i].vendor_id != 0; i++)
+			updated_table[i] = id_iter[i];
+	} else {
+		/* First copy existing table entries. */
+		for (id_iter = old_table; id_iter[i].vendor_id != 0; i++)
+			updated_table[i] = id_iter[i];
+		/* New id to be added at the end of current ID table. */
+		nfp_pci_id_insert(updated_table, &i, driver_id_table);
+
+		free(old_table);
+	}
+
+	/* Terminate table with empty entry. */
+	updated_table[i].vendor_id = 0;
+	nfp_pci_id_table = updated_table;
+	nfp_common_pci_driver.id_table = nfp_pci_id_table;
+
+	return 0;
+}
+
+static int
+nfp_kvarg_dev_class_handler(__rte_unused const char *key,
+		const char *class_str,
+		void *opaque)
+{
+	enum nfp_class *dev_class = opaque;
+
+	if (class_str == NULL)
+		return *dev_class;
+
+	*dev_class = nfp_class_name_to_value(class_str);
+
+	return 0;
+}
+
+static enum nfp_class
+nfp_parse_class_options(const struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvargs;
+	enum nfp_class dev_class = NFP_CLASS_ETH;
+
+	if (devargs == NULL)
+		return dev_class;
+
+	kvargs = rte_kvargs_parse(devargs->args, NULL);
+	if (kvargs == NULL)
+		return dev_class;
+
+	if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
+		rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
+				nfp_kvarg_dev_class_handler, &dev_class);
+	}
+
+	rte_kvargs_free(kvargs);
+
+	return dev_class;
+}
+
+static int
+nfp_drivers_probe(struct rte_pci_device *pci_dev,
+		enum nfp_class class)
+{
+	int32_t ret = 0;
+	struct nfp_class_driver *driver;
+
+	TAILQ_FOREACH(driver, &nfp_drivers_list, next) {
+		if ((driver->drv_class & class) == 0)
+			continue;
+
+		ret = driver->probe(pci_dev);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to load driver %s", driver->name);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_common_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+		struct rte_pci_device *pci_dev)
+{
+	enum nfp_class class;
+	struct rte_device *eal_dev = &pci_dev->device;
+
+	PMD_DRV_LOG(INFO, "probe device %s.", eal_dev->name);
+
+	class = nfp_parse_class_options(eal_dev->devargs);
+	if (class == NFP_CLASS_INVALID) {
+		PMD_DRV_LOG(ERR, "Unsupported nfp class type: %s",
+				eal_dev->devargs->args);
+		return -ENOTSUP;
+	}
+
+	return nfp_drivers_probe(pci_dev, class);
+}
+
+static int
+nfp_common_pci_remove(__rte_unused struct rte_pci_device *pci_dev)
+{
+	return 0;
+}
+
+static struct rte_pci_driver nfp_common_pci_driver = {
+	.driver = {
+		.name = NFP_PCI_DRIVER_NAME,
+	},
+	.probe = nfp_common_pci_probe,
+	.remove = nfp_common_pci_remove,
+};
+
+static void
+nfp_common_init(void)
+{
+	const struct rte_pci_id empty_table[] = {
+		{
+			.vendor_id = 0
+		},
+	};
+
+	if (nfp_common_initialized)
+		return;
+
+	/*
+	 * All the constructor of NFP PMDs run at same priority. So any of the PMD
+	 * including this one can register the PCI table first. If any other
+	 * PMD(s) have registered the PCI ID table, no need to register an empty
+	 * default one.
+	 */
+	if (nfp_pci_id_table == NULL && nfp_pci_id_table_update(empty_table) != 0)
+		return;
+
+	rte_pci_register(&nfp_common_pci_driver);
+	nfp_common_initialized = true;
+}
+
+void
+nfp_class_driver_register(struct nfp_class_driver *driver)
+{
+	nfp_common_init();
+
+	if (driver->id_table != NULL) {
+		if (nfp_pci_id_table_update(driver->id_table) != 0)
+			return;
+	}
+
+	nfp_common_pci_driver.drv_flags |= driver->drv_flags;
+
+	TAILQ_INSERT_TAIL(&nfp_drivers_list, driver, next);
+}
diff --git a/drivers/common/nfp/nfp_common_pci.h b/drivers/common/nfp/nfp_common_pci.h
new file mode 100644
index 0000000000..21465fca68
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_pci.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_PCI_H__
+#define __NFP_COMMON_PCI_H__
+
+#include <bus_pci_driver.h>
+
+/* Initialization function for the driver called during device probing. */
+typedef int (nfp_class_driver_probe_t)(struct rte_pci_device *dev);
+
+/* Uninitialization function for the driver called during hot-unplugging. */
+typedef int (nfp_class_driver_remove_t)(struct rte_pci_device *dev);
+
+enum nfp_class {
+	NFP_CLASS_ETH,
+	NFP_CLASS_INVALID,
+};
+
+/* Describing a nfp common class driver. */
+struct nfp_class_driver {
+	TAILQ_ENTRY(nfp_class_driver) next;
+	enum nfp_class drv_class;            /**< Class of this driver. */
+	const char *name;                    /**< Driver name. */
+	const struct rte_pci_id *id_table;   /**< ID table, NULL terminated. */
+	uint32_t drv_flags;                  /**< Flags RTE_PCI_DRV_*. */
+	nfp_class_driver_probe_t *probe;     /**< Device probe function. */
+	nfp_class_driver_remove_t *remove;   /**< Device remove function. */
+};
+
+/**
+ * Register a nfp device driver.
+ *
+ * @param driver
+ *   A pointer to a nfp_driver structure describing the driver
+ *   to be registered.
+ */
+__rte_internal
+void
+nfp_class_driver_register(struct nfp_class_driver *driver);
+
+#endif /* __NFP_COMMON_PCI_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
new file mode 100644
index 0000000000..25e48c39d6
--- /dev/null
+++ b/drivers/common/nfp/version.map
@@ -0,0 +1,7 @@
+INTERNAL {
+	global:
+
+	nfp_class_driver_register;
+
+	local: *;
+};
diff --git a/drivers/meson.build b/drivers/meson.build
index 8c775bbe62..af70ed322c 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -15,6 +15,7 @@ subdirs = [
         'common/mlx5',    # depends on bus.
         'common/qat',     # depends on bus.
         'common/sfc_efx', # depends on bus.
+        'common/nfp',     # depends on bus.
         'mempool',        # depends on common and bus.
         'dma',            # depends on common and bus.
         'net',            # depends on common, bus, mempool
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 02/25] net/nfp: make VF PMD using of NFP common module
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 01/25] drivers: introduce the NFP common library Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-25 16:09     ` Ferruh Yigit
  2023-10-24  2:28   ` [PATCH v2 03/25] net/nfp: rename common module name Chaoyong He
                     ` (24 subsequent siblings)
  26 siblings, 1 reply; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Modify the logic of NFP VF PMD, make it using of the NFP common module
and link into the 'nfp_drivers_list'.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/meson.build     |  6 +++++-
 drivers/net/nfp/nfp_ethdev_vf.c | 14 ++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 40e9ef8524..f8581403fa 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -40,4 +40,8 @@ sources = files(
         'nfp_rxtx.c',
 )
 
-deps += ['hash', 'security']
+deps += ['hash', 'security', 'common_nfp']
+
+if not dpdk_conf.has('RTE_COMMON_NFP')
+    error('Missing internal dependency "common/nfp"')
+endif
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 3db35b90e8..b9d7a7c5c0 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -6,6 +6,7 @@
  */
 
 #include <rte_alarm.h>
+#include <nfp_common_pci.h>
 
 #include "nfd3/nfp_nfd3.h"
 #include "nfdk/nfp_nfdk.h"
@@ -399,8 +400,7 @@ nfp_vf_pci_uninit(struct rte_eth_dev *eth_dev)
 }
 
 static int
-nfp_vf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
-		struct rte_pci_device *pci_dev)
+nfp_vf_pci_probe(struct rte_pci_device *pci_dev)
 {
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 			sizeof(struct nfp_net_adapter), nfp_netvf_init);
@@ -412,13 +412,19 @@ nfp_vf_pci_remove(struct rte_pci_device *pci_dev)
 	return rte_eth_dev_pci_generic_remove(pci_dev, nfp_vf_pci_uninit);
 }
 
-static struct rte_pci_driver rte_nfp_net_vf_pmd = {
+static struct nfp_class_driver rte_nfp_net_vf_pmd = {
+	.drv_class = NFP_CLASS_ETH,
+	.name = RTE_STR(net_nfp_vf),
 	.id_table = pci_id_nfp_vf_net_map,
 	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
 	.probe = nfp_vf_pci_probe,
 	.remove = nfp_vf_pci_remove,
 };
 
-RTE_PMD_REGISTER_PCI(net_nfp_vf, rte_nfp_net_vf_pmd);
+RTE_INIT(rte_nfp_vf_pmd_init)
+{
+	nfp_class_driver_register(&rte_nfp_net_vf_pmd);
+}
+
 RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 03/25] net/nfp: rename common module name
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 01/25] drivers: introduce the NFP common library Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 04/25] net/nfp: rename ctrl " Chaoyong He
                     ` (23 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename the 'nfp_common' module into 'nfp_net_common' module, because
which is more suitable and we will add 'nfp_common' module in the
'drivers/common/nfp' directory.

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.h                | 2 +-
 drivers/net/nfp/meson.build                        | 2 +-
 drivers/net/nfp/nfp_cpp_bridge.h                   | 2 +-
 drivers/net/nfp/nfp_ctrl.c                         | 2 +-
 drivers/net/nfp/nfp_ethdev_vf.c                    | 2 +-
 drivers/net/nfp/nfp_flow.h                         | 2 +-
 drivers/net/nfp/nfp_ipsec.c                        | 2 +-
 drivers/net/nfp/{nfp_common.c => nfp_net_common.c} | 2 +-
 drivers/net/nfp/{nfp_common.h => nfp_net_common.h} | 6 +++---
 9 files changed, 11 insertions(+), 11 deletions(-)
 rename drivers/net/nfp/{nfp_common.c => nfp_net_common.c} (99%)
 rename drivers/net/nfp/{nfp_common.h => nfp_net_common.h} (99%)

diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h
index b7ea830209..7d442e3cb2 100644
--- a/drivers/net/nfp/flower/nfp_flower.h
+++ b/drivers/net/nfp/flower/nfp_flower.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_FLOWER_H__
 #define __NFP_FLOWER_H__
 
-#include "../nfp_common.h"
+#include "../nfp_net_common.h"
 
 /* Extra features bitmap. */
 #define NFP_FL_FEATS_GENEVE             RTE_BIT64(0)
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index f8581403fa..40748ccc98 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -28,7 +28,6 @@ sources = files(
         'nfpcore/nfp_rtsym.c',
         'nfpcore/nfp_target.c',
         'nfpcore/nfp6000_pcie.c',
-        'nfp_common.c',
         'nfp_cpp_bridge.c',
         'nfp_ctrl.c',
         'nfp_ethdev.c',
@@ -37,6 +36,7 @@ sources = files(
         'nfp_ipsec.c',
         'nfp_logs.c',
         'nfp_mtr.c',
+        'nfp_net_common.c',
         'nfp_rxtx.c',
 )
 
diff --git a/drivers/net/nfp/nfp_cpp_bridge.h b/drivers/net/nfp/nfp_cpp_bridge.h
index a1103e85e4..bf975ce7ba 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.h
+++ b/drivers/net/nfp/nfp_cpp_bridge.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_CPP_BRIDGE_H__
 #define __NFP_CPP_BRIDGE_H__
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 int nfp_enable_cpp_service(struct nfp_pf_dev *pf_dev);
 int nfp_map_service(uint32_t service_id);
diff --git a/drivers/net/nfp/nfp_ctrl.c b/drivers/net/nfp/nfp_ctrl.c
index 6fc8cffd2e..a95e35c9a5 100644
--- a/drivers/net/nfp/nfp_ctrl.c
+++ b/drivers/net/nfp/nfp_ctrl.c
@@ -9,8 +9,8 @@
 
 #include "nfpcore/nfp_platform.h"
 
-#include "nfp_common.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 
 static void
 nfp_net_tlv_caps_reset(struct nfp_net_tlv_caps *caps)
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index b9d7a7c5c0..51c474275e 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -12,8 +12,8 @@
 #include "nfdk/nfp_nfdk.h"
 #include "nfpcore/nfp_cpp.h"
 
-#include "nfp_common.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 
 static void
 nfp_netvf_read_mac(struct nfp_net_hw *hw)
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index aeb24458f3..09e5b30dd8 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_FLOW_H__
 #define __NFP_FLOW_H__
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 /* The firmware expects lengths in units of long words */
 #define NFP_FL_LW_SIZ                   2
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index a76ba2a91d..f137e4b50c 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -12,9 +12,9 @@
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
 
-#include "nfp_common.h"
 #include "nfp_ctrl.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 #include "nfp_rxtx.h"
 
 #define NFP_UDP_ESP_PORT            4500
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_net_common.c
similarity index 99%
rename from drivers/net/nfp/nfp_common.c
rename to drivers/net/nfp/nfp_net_common.c
index 2d4a7635ab..189f81bbb6 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -5,7 +5,7 @@
  * Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
  */
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 #include <rte_alarm.h>
 
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_net_common.h
similarity index 99%
rename from drivers/net/nfp/nfp_common.h
rename to drivers/net/nfp/nfp_net_common.h
index c7f467e33c..cf08df4618 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -3,8 +3,8 @@
  * All rights reserved.
  */
 
-#ifndef __NFP_COMMON_H__
-#define __NFP_COMMON_H__
+#ifndef __NFP_NET_COMMON_H__
+#define __NFP_NET_COMMON_H__
 
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
@@ -451,4 +451,4 @@ bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
 #define NFP_PRIV_TO_APP_FW_FLOWER(app_fw_priv)\
 	((struct nfp_app_fw_flower *)app_fw_priv)
 
-#endif /* __NFP_COMMON_H__ */
+#endif /* __NFP_NET_COMMON_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 04/25] net/nfp: rename ctrl module name
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (2 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 03/25] net/nfp: rename common module name Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 05/25] net/nfp: extract the cap data field Chaoyong He
                     ` (22 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename the 'nfp_ctrl' module into 'nfp_net_ctrl' module, because which
is more suitable and we will add 'nfp_common_ctrl' module in the
'drivers/common/nfp' directory.

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/meson.build                    | 2 +-
 drivers/net/nfp/nfp_ipsec.c                    | 2 +-
 drivers/net/nfp/nfp_net_common.h               | 2 +-
 drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} | 2 +-
 drivers/net/nfp/{nfp_ctrl.h => nfp_net_ctrl.h} | 6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)
 rename drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} (98%)
 rename drivers/net/nfp/{nfp_ctrl.h => nfp_net_ctrl.h} (99%)

diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 40748ccc98..d54dca36e9 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -29,7 +29,6 @@ sources = files(
         'nfpcore/nfp_target.c',
         'nfpcore/nfp6000_pcie.c',
         'nfp_cpp_bridge.c',
-        'nfp_ctrl.c',
         'nfp_ethdev.c',
         'nfp_ethdev_vf.c',
         'nfp_flow.c',
@@ -37,6 +36,7 @@ sources = files(
         'nfp_logs.c',
         'nfp_mtr.c',
         'nfp_net_common.c',
+        'nfp_net_ctrl.c',
         'nfp_rxtx.c',
 )
 
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index f137e4b50c..af85e8575c 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -12,9 +12,9 @@
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
 
-#include "nfp_ctrl.h"
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
+#include "nfp_net_ctrl.h"
 #include "nfp_rxtx.h"
 
 #define NFP_UDP_ESP_PORT            4500
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index cf08df4618..8a02911c45 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -11,7 +11,7 @@
 #include <rte_io.h>
 #include <rte_spinlock.h>
 
-#include "nfp_ctrl.h"
+#include "nfp_net_ctrl.h"
 #include "nfpcore/nfp_dev.h"
 
 /* Macros for accessing the Queue Controller Peripheral 'CSRs' */
diff --git a/drivers/net/nfp/nfp_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
similarity index 98%
rename from drivers/net/nfp/nfp_ctrl.c
rename to drivers/net/nfp/nfp_net_ctrl.c
index a95e35c9a5..b0a427c98e 100644
--- a/drivers/net/nfp/nfp_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -3,7 +3,7 @@
  * All rights reserved.
  */
 
-#include "nfp_ctrl.h"
+#include "nfp_net_ctrl.h"
 
 #include <ethdev_pci.h>
 
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
similarity index 99%
rename from drivers/net/nfp/nfp_ctrl.h
rename to drivers/net/nfp/nfp_net_ctrl.h
index 9ec51e0a25..3772b28a66 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_net_ctrl.h
@@ -3,8 +3,8 @@
  * All rights reserved.
  */
 
-#ifndef __NFP_CTRL_H__
-#define __NFP_CTRL_H__
+#ifndef __NFP_NET_CTRL_H__
+#define __NFP_NET_CTRL_H__
 
 #include <stdint.h>
 
@@ -571,4 +571,4 @@ nfp_net_cfg_ctrl_rss(uint32_t hw_cap)
 	return NFP_NET_CFG_CTRL_RSS;
 }
 
-#endif /* __NFP_CTRL_H__ */
+#endif /* __NFP_NET_CTRL_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 05/25] net/nfp: extract the cap data field
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (3 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 04/25] net/nfp: rename ctrl " Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 06/25] net/nfp: extract the qcp " Chaoyong He
                     ` (21 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'cap' and 'cap_ext' data field into the super class, ready
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 |  6 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c  | 12 ++--
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  | 14 ++---
 drivers/net/nfp/nfp_ethdev.c        | 14 ++---
 drivers/net/nfp/nfp_ethdev_vf.c     | 10 +--
 drivers/net/nfp/nfp_ipsec.c         |  4 +-
 drivers/net/nfp/nfp_net_common.c    | 98 +++++++++++++++--------------
 drivers/net/nfp/nfp_net_common.h    | 10 ++-
 drivers/net/nfp/nfp_rxtx.c          |  2 +-
 9 files changed, 89 insertions(+), 81 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 60d843451e..453080f521 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -65,7 +65,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
+	if (hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
@@ -101,7 +101,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_RSS;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS2) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS2;
 	else
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS;
@@ -111,7 +111,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index b64dbaca0d..bbf4530ae9 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -30,7 +30,7 @@ nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
 		goto clean_txd;
 
 	ol_flags = mb->ol_flags;
@@ -69,7 +69,7 @@ nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
 		return;
 
 	ol_flags = mb->ol_flags;
@@ -127,8 +127,8 @@ nfp_net_nfd3_tx_vlan(struct nfp_net_txq *txq,
 {
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0 ||
-			(hw->cap & NFP_NET_CFG_CTRL_TXVLAN) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0 ||
+			(hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) == 0)
 		return;
 
 	if ((mb->ol_flags & RTE_MBUF_F_TX_VLAN) != 0) {
@@ -151,7 +151,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
 	uint8_t ipsec_layer = 0;
 
 	hw = txq->hw;
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
 			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
@@ -278,7 +278,7 @@ nfp_net_nfd3_xmit_pkts_common(void *tx_queue,
 		}
 
 		if (unlikely(pkt->nb_segs > 1 &&
-				(hw->cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
+				(hw->super.cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
 			PMD_TX_LOG(ERR, "Multisegment packet not supported");
 			goto xmit_end;
 		}
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 259039964a..807666686f 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -23,7 +23,7 @@ nfp_net_nfdk_tx_cksum(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
 		return flags;
 
 	ol_flags = mb->ol_flags;
@@ -57,7 +57,7 @@ nfp_net_nfdk_tx_tso(struct nfp_net_txq *txq,
 
 	txd.raw = 0;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
 		return txd.raw;
 
 	ol_flags = mb->ol_flags;
@@ -146,7 +146,7 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq,
 		return -EINVAL;
 
 	/* Count TSO descriptor */
-	if ((txq->hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+	if ((txq->hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 			(pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
 		n_descs++;
 
@@ -184,7 +184,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 
 	memset(&meta_data, 0, sizeof(meta_data));
 	hw = txq->hw;
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
 			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
@@ -322,7 +322,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 			nfp_net_nfdk_set_meta_data(pkt, txq, &metadata);
 
 		if (unlikely(pkt->nb_segs > 1 &&
-				(hw->cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
+				(hw->super.cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
 			PMD_TX_LOG(ERR, "Multisegment packet not supported");
 			goto xmit_end;
 		}
@@ -332,7 +332,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 		 * multisegment packet, but TSO info needs to be in all of them.
 		 */
 		dma_len = pkt->data_len;
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 				(pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) {
 			type = NFDK_DESC_TX_TYPE_TSO;
 		} else if (pkt->next == NULL && dma_len <= NFDK_TX_MAX_DATA_PER_HEAD) {
@@ -405,7 +405,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 		ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_cksum(txq, temp_pkt, metadata));
 		ktxds++;
 
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 				(temp_pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) {
 			ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_tso(txq, temp_pkt));
 			ktxds++;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index d32a82210c..8ac2acea7b 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -119,7 +119,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
 	}
 
 	/* Enable device */
@@ -128,19 +128,19 @@ nfp_net_start(struct rte_eth_dev *dev)
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
 	/* Enable vxlan */
-	if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
 		new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
 		update |= NFP_NET_CFG_UPDATE_VXLAN;
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/* Enable packet type offload by extend ctrl word1. */
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
 		ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
 
@@ -579,8 +579,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
 	nfp_net_log_device_information(hw);
 
@@ -608,7 +608,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	/* Copying mac address to DPDK eth_dev struct */
 	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 51c474275e..293d1ed53c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -86,7 +86,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
 	}
 
 	/* Enable device */
@@ -94,7 +94,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
@@ -314,8 +314,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
 	nfp_net_log_device_information(hw);
 
@@ -341,7 +341,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	/* Copying mac address to DPDK eth_dev struct */
 	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index af85e8575c..e080e71db2 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -1382,7 +1382,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return 0;
@@ -1429,7 +1429,7 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 189f81bbb6..77c0652642 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -408,7 +408,7 @@ nfp_net_configure(struct rte_eth_dev *dev)
 
 	/* Checking RX mode */
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+			(hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		PMD_DRV_LOG(ERR, "RSS not supported");
 		return -EINVAL;
 	}
@@ -426,27 +426,29 @@ nfp_net_configure(struct rte_eth_dev *dev)
 void
 nfp_net_log_device_information(const struct nfp_net_hw *hw)
 {
+	uint32_t cap = hw->super.cap;
+
 	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
 			hw->ver.major, hw->ver.minor, hw->max_mtu);
 
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
-			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
-			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2 ? "TXVLANv2 "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
-			hw->cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
-			hw->cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
-			hw->cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
-			hw->cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
-			hw->cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
+	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", cap,
+			cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
+			cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
+			cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
+			cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
+			cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
+			cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
+			cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
+			cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
+			cap & NFP_NET_CFG_CTRL_TXVLAN_V2 ? "TXVLANv2 "  : "",
+			cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
+			cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
+			cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
+			cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
+			cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
+			cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
+			cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
+			cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
 
 	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
 			hw->max_rx_queues, hw->max_tx_queues);
@@ -456,9 +458,9 @@ static inline void
 nfp_net_enable_rxvlan_cap(struct nfp_net_hw *hw,
 		uint32_t *ctrl)
 {
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0)
 		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN_V2;
-	else if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN) != 0)
+	else if ((hw->super.cap & NFP_NET_CFG_CTRL_RXVLAN) != 0)
 		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN;
 }
 
@@ -503,7 +505,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
@@ -552,7 +554,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
+			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
 	}
@@ -563,7 +565,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
+			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
 	/* Signal the NIC about the change */
@@ -631,7 +633,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	tx_offload = dev_conf->txmode.offloads;
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXCSUM;
 	}
 
@@ -639,25 +641,25 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 		nfp_net_enable_rxvlan_cap(hw, &ctrl);
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
 	hw->mtu = dev->data->mtu;
 
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2;
-		else if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
+		else if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
 	}
 
 	/* L2 broadcast */
-	if ((hw->cap & NFP_NET_CFG_CTRL_L2BC) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2BC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2BC;
 
 	/* L2 multicast */
-	if ((hw->cap & NFP_NET_CFG_CTRL_L2MC) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2MC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2MC;
 
 	/* TX checksum offload */
@@ -669,7 +671,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	/* LSO offload */
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 ||
 			(tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_LSO;
 		else
 			ctrl |= NFP_NET_CFG_CTRL_LSO2;
@@ -698,7 +700,7 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev)
 		hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(ERR, "Promiscuous mode not supported");
 		return -ENOTSUP;
 	}
@@ -1213,35 +1215,35 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
-	if ((hw->cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
+	if ((hw->super.cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
+	if ((hw->super.cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
 		dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
-		if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
 			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_GATHER) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_GATHER) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SECURITY;
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SECURITY;
@@ -1281,7 +1283,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG,
 	};
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
 		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
@@ -1334,8 +1336,8 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 		return -ENODEV;
 
 	/* Get some of the read-only fields from the config BAR */
-	hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
-	hw->cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	hw->super.cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
+	hw->super.cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
 	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
 	hw->flbufsz = DEFAULT_FLBUF_SIZE;
 
@@ -2025,14 +2027,14 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw)
 	 */
 	if (hw->ver.major == 4) {
 		hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
-	} else if ((hw->cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
+	} else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
 		hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
 		/*
-		 * RSS is incompatible with chained metadata. hw->cap just represents
+		 * RSS is incompatible with chained metadata. hw->super.cap just represents
 		 * firmware's ability rather than the firmware's configuration. We decide
-		 * to reduce the confusion to allow us can use hw->cap to identify RSS later.
+		 * to reduce the confusion to allow us can use hw->super.cap to identify RSS later.
 		 */
-		hw->cap &= ~NFP_NET_CFG_CTRL_RSS;
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_RSS;
 	} else {
 		hw->meta_format = NFP_NET_METAFORMAT_SINGLE;
 	}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 8a02911c45..7bcdd9295f 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -112,7 +112,15 @@ struct nfp_app_fw_nic {
 	uint8_t total_phyports;
 };
 
+struct nfp_hw {
+	uint32_t cap;
+	uint32_t cap_ext;
+};
+
 struct nfp_net_hw {
+	/** The parent class */
+	struct nfp_hw super;
+
 	/** Backpointer to the PF this port belongs to */
 	struct nfp_pf_dev *pf_dev;
 
@@ -120,9 +128,7 @@ struct nfp_net_hw {
 	struct rte_eth_dev *eth_dev;
 
 	/** Info from the firmware */
-	uint32_t cap_ext;
 	struct nfp_net_fw_ver ver;
-	uint32_t cap;
 	uint32_t max_mtu;
 	uint32_t mtu;
 	uint32_t rx_offset;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index efdca7fccf..a0c7e0e9b5 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -386,7 +386,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 	struct nfp_net_hw *hw = rxq->hw;
 
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
-			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
+			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
 	if (meta->vlan_layer < NFP_META_MAX_VLANS)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 06/25] net/nfp: extract the qcp data field
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (4 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 05/25] net/nfp: extract the cap data field Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
                     ` (20 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'qcp_cfg' data field 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/nfp_net_common.c | 8 ++++----
 drivers/net/nfp/nfp_net_common.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 77c0652642..cb64fa13c5 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -206,14 +206,14 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 	struct timespec wait;
 
 	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->qcp_cfg);
+			hw->super.qcp_cfg);
 
-	if (hw->qcp_cfg == NULL) {
+	if (hw->super.qcp_cfg == NULL) {
 		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
 		return -ENXIO;
 	}
 
-	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+	nfp_qcp_ptr_add(hw->super.qcp_cfg, NFP_QCP_WRITE_PTR, 1);
 
 	wait.tv_sec = 0;
 	wait.tv_nsec = 1000000; /* 1ms */
@@ -525,7 +525,7 @@ nfp_net_params_setup(struct nfp_net_hw *hw)
 void
 nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 {
-	hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
+	hw->super.qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }
 
 void
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 7bcdd9295f..4bfb3174b0 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 *qcp_cfg;
 	uint32_t cap;
 	uint32_t cap_ext;
 };
@@ -150,7 +151,6 @@ struct nfp_net_hw {
 	uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
 	uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
 
-	uint8_t *qcp_cfg;
 	rte_spinlock_t reconfig_lock;
 
 	uint32_t max_tx_queues;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 07/25] net/nfp: extract the ctrl BAR data field
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (5 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 06/25] net/nfp: extract the qcp " Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 08/25] net/nfp: extract the ctrl " Chaoyong He
                     ` (19 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

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(-)

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;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 08/25] net/nfp: extract the ctrl data field
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (6 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 09/25] net/nfp: change the parameter of APIs Chaoyong He
                     ` (18 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'ctrl' 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/nfd3/nfp_nfd3_dp.c  |  2 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  |  2 +-
 drivers/net/nfp/nfp_ethdev.c        |  4 ++-
 drivers/net/nfp/nfp_ethdev_vf.c     |  2 +-
 drivers/net/nfp/nfp_net_common.c    | 46 ++++++++++++++---------------
 drivers/net/nfp/nfp_net_common.h    |  5 ++--
 drivers/net/nfp/nfp_rxtx.c          | 12 ++++----
 8 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index c8455e0241..8bb5914888 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -61,7 +61,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
 	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
@@ -72,7 +72,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 }
 
 int
@@ -123,7 +123,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 		return -EIO;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
@@ -721,7 +721,7 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 		return -EIO;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index bbf4530ae9..3045533857 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -154,7 +154,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
 	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+			(hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
 		if (meta_data->length == 0)
 			meta_data->length = NFP_NET_META_HEADER_SIZE;
 		meta_data->length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 807666686f..63421ba796 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -187,7 +187,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+			(hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
 		if (meta_data.length == 0)
 			meta_data.length = NFP_NET_META_HEADER_SIZE;
 		meta_data.length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index b7c60b642f..0f6f97be8e 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -152,6 +152,8 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if (nfp_net_ext_reconfig(hw, ctrl_extend, update) != 0)
 		return -EIO;
 
+	hw->super.ctrl_ext = ctrl_extend;
+
 	/*
 	 * Allocating rte mbufs for configured rx queues.
 	 * This requires queues being enabled before.
@@ -167,7 +169,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	else
 		nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 1);
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 641fed6fcf..684968903c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -110,7 +110,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 29f836c31e..058260bda3 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -500,7 +500,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
 	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
@@ -512,7 +512,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 }
 
 void
@@ -553,7 +553,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	struct nfp_net_hw *hw;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
 			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
@@ -563,8 +563,8 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
-	ctrl = hw->ctrl;
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+	ctrl = hw->super.ctrl;
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
 			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
@@ -613,7 +613,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 	}
 
 	/* Avoiding TX interrupts */
-	hw->ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
+	hw->super.ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
 	return 0;
 }
 
@@ -705,19 +705,19 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already enabled");
 		return 0;
 	}
 
-	new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->super.ctrl | NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -732,19 +732,19 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already disabled");
 		return 0;
 	}
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1349,7 +1349,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 	else
 		hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
 
-	hw->ctrl = 0;
+	hw->super.ctrl = 0;
 	hw->stride_rx = stride;
 	hw->stride_tx = stride;
 
@@ -1453,7 +1453,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
 	/* Make sure all updates are written before un-masking */
 	rte_wmb();
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
 		/* If MSI-X auto-masking is used, clear the entry */
 		rte_intr_ack(pci_dev->intr_handle);
 	} else {
@@ -1559,7 +1559,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	rx_offload = dev->data->dev_conf.rxmode.offloads;
-	new_ctrl = hw->ctrl;
+	new_ctrl = hw->super.ctrl;
 
 	/* VLAN stripping setting */
 	if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) {
@@ -1578,7 +1578,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 			new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
-	if (new_ctrl == hw->ctrl)
+	if (new_ctrl == hw->super.ctrl)
 		return 0;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
@@ -1587,7 +1587,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1660,7 +1660,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 	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)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size);
@@ -1669,7 +1669,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1690,7 +1690,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 	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)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
@@ -1795,7 +1795,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 	rss_hf = rss_conf->rss_hf;
 
 	/* Checking if RSS is enabled */
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		if (rss_hf != 0) {
 			PMD_DRV_LOG(ERR, "RSS unsupported");
 			return -EINVAL;
@@ -1813,7 +1813,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1831,7 +1831,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index dd62ec6d83..3fb3b34613 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -117,6 +117,8 @@ struct nfp_hw {
 	uint8_t *qcp_cfg;
 	uint32_t cap;
 	uint32_t cap_ext;
+	uint32_t ctrl;
+	uint32_t ctrl_ext;
 };
 
 struct nfp_net_hw {
@@ -139,9 +141,6 @@ struct nfp_net_hw {
 	/** NFP ASIC params */
 	const struct nfp_dev_info *dev_info;
 
-	/** Current values for control */
-	uint32_t ctrl;
-
 	uint8_t *tx_bar;
 	uint8_t *rx_bar;
 
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index a0c7e0e9b5..a9dd464a6a 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -143,7 +143,7 @@ nfp_net_rx_cksum(struct nfp_net_rxq *rxq,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
 		return;
 
 	/* If IPv4 and IP checksum error, fail */
@@ -307,7 +307,7 @@ nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return;
 
 	mbuf->hash.rss = meta->hash;
@@ -339,7 +339,7 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	struct nfp_net_hw *hw = rxq->hw;
 
 	/* Skip if firmware don't support setting vlan. */
-	if ((hw->ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
+	if ((hw->super.ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
 	/*
@@ -347,12 +347,12 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	 * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
 	 * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
 	 */
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
 		if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
 		}
-	} else if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+	} else if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
 		if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
@@ -385,7 +385,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
 			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 09/25] net/nfp: change the parameter of APIs
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (7 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 08/25] net/nfp: extract the ctrl " Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 10/25] net/nfp: change the parameter of reconfig Chaoyong He
                     ` (17 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Change the parameter of some APIs from 'struct nfp_net_hw' into the
super class 'struct nfp_hw', 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           |  24 ++--
 .../net/nfp/flower/nfp_flower_representor.c   |  10 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c            |   4 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c            |   4 +-
 drivers/net/nfp/nfp_ethdev.c                  |   8 +-
 drivers/net/nfp/nfp_ethdev_vf.c               |  12 +-
 drivers/net/nfp/nfp_ipsec.c                   |   4 +-
 drivers/net/nfp/nfp_net_common.c              | 129 +++++++++---------
 drivers/net/nfp/nfp_net_common.h              |  32 ++---
 drivers/net/nfp/nfp_rxtx.c                    |   4 +-
 10 files changed, 116 insertions(+), 115 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 8bb5914888..ccb579541b 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -36,7 +36,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	enabled_queues = 0;
 
@@ -44,7 +44,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 static void
@@ -58,8 +58,8 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	repr = dev->data->dev_private;
 	hw = repr->app_fw_flower->pf_hw;
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
 
 	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
@@ -114,7 +114,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
 
 	/* If an error when reconfig we avoid to change hw state */
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
@@ -219,7 +219,7 @@ nfp_flower_pf_close(struct rte_eth_dev *dev)
 	/* Cancel possible impending LSC work here before releasing the port */
 	rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler, (void *)dev);
 
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
 
 	/* Now it is safe to free all PF resources */
 	PMD_DRV_LOG(INFO, "Freeing PF resources");
@@ -356,9 +356,9 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw,
 		return err;
 
 	/* Work out where in the BAR the queues start */
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = (uint64_t)start_q * NFP_QCP_QUEUE_ADDR_SZ;
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = (uint64_t)start_q * NFP_QCP_QUEUE_ADDR_SZ;
 
 	hw->tx_bar = pf_dev->qc_bar + tx_bar_off;
@@ -543,8 +543,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 		 * Telling the HW about the physical address of the RX ring and number
 		 * of descriptors in log2 format.
 		 */
-		nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(i), rxq->dma);
-		nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
+		nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(i), rxq->dma);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
 	}
 
 	snprintf(ctrl_txring_name, sizeof(ctrl_txring_name), "%s_cttx_ring", pci_name);
@@ -608,8 +608,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 		 * Telling the HW about the physical address of the TX ring and number
 		 * of descriptors in log2 format.
 		 */
-		nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(i), txq->dma);
-		nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
+		nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(i), txq->dma);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
 	}
 
 	return 0;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 650f09a475..b52c6f514a 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -97,8 +97,8 @@ nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the RX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
@@ -181,8 +181,8 @@ nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
@@ -228,7 +228,7 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,
 				}
 			}
 		} else {
-			nn_link_status = nn_cfg_readw(pf_hw, NFP_NET_CFG_STS);
+			nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS);
 			nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) &
 					NFP_NET_CFG_STS_LINK_RATE_MASK;
 
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 3045533857..c85fadc80d 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -465,8 +465,8 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
 
 	return 0;
 }
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 63421ba796..3f8d25aa29 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -542,8 +542,8 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
 
 	return 0;
 }
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 0f6f97be8e..a773a81e55 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -286,7 +286,7 @@ nfp_net_close(struct rte_eth_dev *dev)
 
 	/* Only free PF resources after all physical ports have been closed */
 	/* Mark this port as unused and free device priv resources */
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
 	app_fw_nic->ports[hw->idx] = NULL;
 
 	for (i = 0; i < app_fw_nic->total_phyports; i++) {
@@ -567,8 +567,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* Work out where in the BAR the queues start. */
-	tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
-	rx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	tx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
+	rx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 
 	hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
 	hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
@@ -625,7 +625,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	rte_intr_callback_register(pci_dev->intr_handle,
 			nfp_net_dev_interrupt_handler, (void *)eth_dev);
 	/* Telling the firmware about the LSC interrupt entry */
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 	/* Recording current stats counters values */
 	nfp_net_stats_reset(eth_dev);
 
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 684968903c..7fb2a3d378 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -20,10 +20,10 @@ nfp_netvf_read_mac(struct nfp_net_hw *hw)
 {
 	uint32_t tmp;
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR));
 	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR + 4));
 	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
 }
 
@@ -97,7 +97,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
@@ -299,9 +299,9 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* Work out where in the BAR the queues start. */
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
 
 	hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
@@ -357,7 +357,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		rte_intr_callback_register(pci_dev->intr_handle,
 				nfp_net_dev_interrupt_handler, (void *)eth_dev);
 		/* Telling the firmware about the LSC interrupt entry */
-		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 		/* Recording current stats counters values */
 		nfp_net_stats_reset(eth_dev);
 	}
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index e080e71db2..0da5c2a3d2 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -445,7 +445,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	msg->rsp = NFP_IPSEC_CFG_MSG_OK;
 
 	for (i = 0; i < msg_size; i++)
-		nn_cfg_writel(hw, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
 
 	ret = nfp_net_mbox_reconfig(hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
 	if (ret < 0) {
@@ -459,7 +459,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	 * response. One example where the data is needed is for statistics.
 	 */
 	for (i = 0; i < msg_size; i++)
-		msg->raw[i] = nn_cfg_readl(hw, NFP_NET_CFG_MBOX_VAL + 4 * i);
+		msg->raw[i] = nn_cfg_readl(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
 
 	switch (msg->rsp) {
 	case NFP_IPSEC_CFG_MSG_OK:
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 058260bda3..2ab8d8fadd 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -182,7 +182,8 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 	 * NFP_NET_CFG_STS_NSP_LINK_RATE.
 	 */
 	if (link->link_status == RTE_ETH_LINK_DOWN) {
-		nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE, NFP_NET_CFG_STS_LINK_RATE_UNKNOWN);
+		nn_cfg_writew(&hw->super, NFP_NET_CFG_STS_NSP_LINK_RATE,
+				NFP_NET_CFG_STS_LINK_RATE_UNKNOWN);
 		return;
 	}
 
@@ -190,7 +191,7 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 	 * Link is up so write the link speed from the eth_table to
 	 * NFP_NET_CFG_STS_NSP_LINK_RATE.
 	 */
-	nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE,
+	nn_cfg_writew(&hw->super, NFP_NET_CFG_STS_NSP_LINK_RATE,
 			nfp_net_link_speed_rte2nfp(link->link_speed));
 }
 
@@ -222,7 +223,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	/* Poll update field, waiting for NFP to ack the config */
 	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
+		new = nn_cfg_readl(&hw->super, NFP_NET_CFG_UPDATE);
 		if (new == 0)
 			break;
 
@@ -270,8 +271,8 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
@@ -314,8 +315,8 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
@@ -355,8 +356,8 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writeq(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
+	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
@@ -370,7 +371,7 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 		return -EIO;
 	}
 
-	return nn_cfg_readl(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
+	return nn_cfg_readl(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
 }
 
 /*
@@ -478,14 +479,14 @@ nfp_net_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	/* Enabling the required RX queues in the device */
 	enabled_queues = 0;
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 void
@@ -497,8 +498,8 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
 
 	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
@@ -518,8 +519,8 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 void
 nfp_net_params_setup(struct nfp_net_hw *hw)
 {
-	nn_cfg_writel(hw, NFP_NET_CFG_MTU, hw->mtu);
-	nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_MTU, hw->mtu);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
 }
 
 void
@@ -596,7 +597,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 	if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) {
 		PMD_DRV_LOG(INFO, "VF: enabling RX interrupt with UIO");
 		/* UIO just supports one queue and no LSC */
-		nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(0), 0);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_VEC(0), 0);
 		if (rte_intr_vec_list_index_set(intr_handle, 0, 0) != 0)
 			return -1;
 	} else {
@@ -606,7 +607,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 			 * The first msix vector is reserved for non
 			 * efd interrupts.
 			 */
-			nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(i), i + 1);
+			nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_VEC(i), i + 1);
 			if (rte_intr_vec_list_index_set(intr_handle, i, i + 1) != 0)
 				return -1;
 		}
@@ -771,7 +772,7 @@ nfp_net_link_update(struct rte_eth_dev *dev,
 	memset(&link, 0, sizeof(struct rte_eth_link));
 
 	/* Read link status */
-	nn_link_status = nn_cfg_readw(hw, NFP_NET_CFG_STS);
+	nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS);
 	if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0)
 		link.link_status = RTE_ETH_LINK_UP;
 
@@ -842,12 +843,12 @@ nfp_net_stats_get(struct rte_eth_dev *dev,
 			break;
 
 		nfp_dev_stats.q_ipackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i));
 		nfp_dev_stats.q_ipackets[i] -=
 				hw->eth_stats_base.q_ipackets[i];
 
 		nfp_dev_stats.q_ibytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i) + 0x8);
 		nfp_dev_stats.q_ibytes[i] -=
 				hw->eth_stats_base.q_ibytes[i];
 	}
@@ -858,42 +859,42 @@ nfp_net_stats_get(struct rte_eth_dev *dev,
 			break;
 
 		nfp_dev_stats.q_opackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i));
 		nfp_dev_stats.q_opackets[i] -= hw->eth_stats_base.q_opackets[i];
 
 		nfp_dev_stats.q_obytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i) + 0x8);
 		nfp_dev_stats.q_obytes[i] -= hw->eth_stats_base.q_obytes[i];
 	}
 
-	nfp_dev_stats.ipackets = nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES);
+	nfp_dev_stats.ipackets = nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_FRAMES);
 	nfp_dev_stats.ipackets -= hw->eth_stats_base.ipackets;
 
-	nfp_dev_stats.ibytes = nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS);
+	nfp_dev_stats.ibytes = nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_OCTETS);
 	nfp_dev_stats.ibytes -= hw->eth_stats_base.ibytes;
 
 	nfp_dev_stats.opackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_FRAMES);
 	nfp_dev_stats.opackets -= hw->eth_stats_base.opackets;
 
 	nfp_dev_stats.obytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_OCTETS);
 	nfp_dev_stats.obytes -= hw->eth_stats_base.obytes;
 
 	/* Reading general device stats */
 	nfp_dev_stats.ierrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_ERRORS);
 	nfp_dev_stats.ierrors -= hw->eth_stats_base.ierrors;
 
 	nfp_dev_stats.oerrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_ERRORS);
 	nfp_dev_stats.oerrors -= hw->eth_stats_base.oerrors;
 
 	/* RX ring mbuf allocation failures */
 	nfp_dev_stats.rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 
 	nfp_dev_stats.imissed =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_DISCARDS);
 	nfp_dev_stats.imissed -= hw->eth_stats_base.imissed;
 
 	memcpy(stats, &nfp_dev_stats, sizeof(*stats));
@@ -918,10 +919,10 @@ nfp_net_stats_reset(struct rte_eth_dev *dev)
 			break;
 
 		hw->eth_stats_base.q_ipackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i));
 
 		hw->eth_stats_base.q_ibytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i) + 0x8);
 	}
 
 	/* Reading per TX ring stats */
@@ -930,36 +931,36 @@ nfp_net_stats_reset(struct rte_eth_dev *dev)
 			break;
 
 		hw->eth_stats_base.q_opackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i));
 
 		hw->eth_stats_base.q_obytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i) + 0x8);
 	}
 
 	hw->eth_stats_base.ipackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_FRAMES);
 
 	hw->eth_stats_base.ibytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_OCTETS);
 
 	hw->eth_stats_base.opackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_FRAMES);
 
 	hw->eth_stats_base.obytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_OCTETS);
 
 	/* Reading general device stats */
 	hw->eth_stats_base.ierrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_ERRORS);
 
 	hw->eth_stats_base.oerrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_ERRORS);
 
 	/* RX ring mbuf allocation failures */
 	dev->data->rx_mbuf_alloc_failed = 0;
 
 	hw->eth_stats_base.imissed =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_DISCARDS);
 
 	return 0;
 }
@@ -1012,7 +1013,7 @@ nfp_net_xstats_value(const struct rte_eth_dev *dev,
 	if (xstat.group == NFP_XSTAT_GROUP_MAC)
 		value = nn_readq(hw->mac_stats + xstat.offset);
 	else
-		value = nn_cfg_readq(hw, xstat.offset);
+		value = nn_cfg_readq(&hw->super, xstat.offset);
 
 	if (raw)
 		return value;
@@ -1320,8 +1321,8 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 	hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
 	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
 
-	hw->max_rx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_RXRINGS);
-	hw->max_tx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_TXRINGS);
+	hw->max_rx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_RXRINGS);
+	hw->max_tx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_TXRINGS);
 	if (hw->max_rx_queues == 0 || hw->max_tx_queues == 0) {
 		PMD_INIT_LOG(ERR, "Device %s can not be used, there are no valid queue "
 				"pairs for use", pci_dev->name);
@@ -1336,9 +1337,9 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 		return -ENODEV;
 
 	/* Get some of the read-only fields from the config BAR */
-	hw->super.cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
-	hw->super.cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
-	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
+	hw->super.cap = nn_cfg_readl(&hw->super, NFP_NET_CFG_CAP);
+	hw->super.cap_ext = nn_cfg_readl(&hw->super, NFP_NET_CFG_CAP_WORD1);
+	hw->max_mtu = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_MTU);
 	hw->flbufsz = DEFAULT_FLBUF_SIZE;
 
 	nfp_net_init_metadata_format(hw);
@@ -1347,7 +1348,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, NFP_NET_CFG_RX_OFFSET_ADDR);
+		hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET_ADDR);
 
 	hw->super.ctrl = 0;
 	hw->stride_rx = stride;
@@ -1389,7 +1390,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev,
 	rte_wmb();
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id),
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id),
 			NFP_NET_CFG_ICR_UNMASKED);
 	return 0;
 }
@@ -1410,7 +1411,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev,
 	rte_wmb();
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX);
 
 	return 0;
 }
@@ -1457,7 +1458,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
 		/* If MSI-X auto-masking is used, clear the entry */
 		rte_intr_ack(pci_dev->intr_handle);
 	} else {
-		nn_cfg_writeb(hw, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX),
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX),
 				NFP_NET_CFG_ICR_UNMASKED);
 	}
 }
@@ -1539,7 +1540,7 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev,
 	}
 
 	/* Writing to configuration space */
-	nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_MTU, mtu);
 
 	hw->mtu = mtu;
 
@@ -1630,7 +1631,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 
 		/* If all 4 entries were set, don't need read RETA register */
 		if (mask != 0xF)
-			reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + i);
+			reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + i);
 
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
@@ -1643,7 +1644,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 			reta |= reta_conf[idx].reta[shift + j] << (8 * j);
 		}
 
-		nn_cfg_writel(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
 	}
 
 	return 0;
@@ -1713,7 +1714,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 		if (mask == 0)
 			continue;
 
-		reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
+		reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
 				continue;
@@ -1741,7 +1742,7 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	/* Writing the key byte by byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
 		memcpy(&key, &rss_conf->rss_key[i], 1);
-		nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY + i, key);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY + i, key);
 	}
 
 	rss_hf = rss_conf->rss_hf;
@@ -1774,10 +1775,10 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
-	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
 
 	/* Writing the key size */
-	nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
 
 	return 0;
 }
@@ -1835,7 +1836,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
-	cfg_rss_ctrl = nn_cfg_readl(hw, NFP_NET_CFG_RSS_CTRL);
+	cfg_rss_ctrl = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_CTRL);
 
 	if ((cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4) != 0)
 		rss_hf |= RTE_ETH_RSS_IPV4;
@@ -1865,11 +1866,11 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	rss_conf->rss_hf = rss_hf;
 
 	/* Reading the key size */
-	rss_conf->rss_key_len = nn_cfg_readl(hw, NFP_NET_CFG_RSS_KEY_SZ);
+	rss_conf->rss_key_len = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_KEY_SZ);
 
 	/* Reading the key byte a byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
-		key = nn_cfg_readb(hw, NFP_NET_CFG_RSS_KEY + i);
+		key = nn_cfg_readb(&hw->super, NFP_NET_CFG_RSS_KEY + i);
 		memcpy(&rss_conf->rss_key[i], &key, 1);
 	}
 
@@ -1983,13 +1984,13 @@ nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
 	hw->vxlan_ports[idx] = port;
 
 	for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) {
-		nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
 				(hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]);
 	}
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
 	rte_wmb();
 
 	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN);
@@ -2048,7 +2049,7 @@ nfp_net_cfg_read_version(struct nfp_net_hw *hw)
 		struct nfp_net_fw_ver split;
 	} version;
 
-	version.whole = nn_cfg_readl(hw, NFP_NET_CFG_VERSION);
+	version.whole = nn_cfg_readl(&hw->super, NFP_NET_CFG_VERSION);
 	hw->ver = version.split;
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 3fb3b34613..3fe3e96107 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -247,63 +247,63 @@ nn_writeq(uint64_t val,
 }
 
 static inline uint8_t
-nn_cfg_readb(struct nfp_net_hw *hw,
+nn_cfg_readb(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return nn_readb(hw->super.ctrl_bar + off);
+	return nn_readb(hw->ctrl_bar + off);
 }
 
 static inline void
-nn_cfg_writeb(struct nfp_net_hw *hw,
+nn_cfg_writeb(struct nfp_hw *hw,
 		uint32_t off,
 		uint8_t val)
 {
-	nn_writeb(val, hw->super.ctrl_bar + off);
+	nn_writeb(val, hw->ctrl_bar + off);
 }
 
 static inline uint16_t
-nn_cfg_readw(struct nfp_net_hw *hw,
+nn_cfg_readw(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_16(nn_readw(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writew(struct nfp_net_hw *hw,
+nn_cfg_writew(struct nfp_hw *hw,
 		uint32_t off,
 		uint16_t val)
 {
-	nn_writew(rte_cpu_to_le_16(val), hw->super.ctrl_bar + off);
+	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
 }
 
 static inline uint32_t
-nn_cfg_readl(struct nfp_net_hw *hw,
+nn_cfg_readl(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_32(nn_readl(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writel(struct nfp_net_hw *hw,
+nn_cfg_writel(struct nfp_hw *hw,
 		uint32_t off,
 		uint32_t val)
 {
-	nn_writel(rte_cpu_to_le_32(val), hw->super.ctrl_bar + off);
+	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
 }
 
 static inline uint64_t
-nn_cfg_readq(struct nfp_net_hw *hw,
+nn_cfg_readq(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_64(nn_readq(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writeq(struct nfp_net_hw *hw,
+nn_cfg_writeq(struct nfp_hw *hw,
 		uint32_t off,
 		uint64_t val)
 {
-	nn_writeq(rte_cpu_to_le_64(val), hw->super.ctrl_bar + off);
+	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
 }
 
 /**
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index a9dd464a6a..f17cc13cc1 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -925,8 +925,8 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the RX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 10/25] net/nfp: change the parameter of reconfig
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (8 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 09/25] net/nfp: change the parameter of APIs Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 11/25] net/nfp: extract the MAC address data field Chaoyong He
                     ` (16 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'reconfig_lock' data field into the super class, also change
the parameter of the related APIs, 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 |  50 +++++----
 drivers/net/nfp/nfp_ethdev.c        |  34 +++---
 drivers/net/nfp/nfp_ethdev_vf.c     |  20 ++--
 drivers/net/nfp/nfp_net_common.c    | 161 +++++++++++++++-------------
 drivers/net/nfp/nfp_net_common.h    |   7 +-
 5 files changed, 149 insertions(+), 123 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index ccb579541b..831f4a7265 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -52,27 +52,29 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 {
 	uint32_t update;
 	uint32_t new_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	net_hw = repr->app_fw_flower->pf_hw;
+	hw = &net_hw->super;
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if (hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG)
+	if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) < 0)
 		return;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 }
 
 int
@@ -80,13 +82,15 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	net_hw = repr->app_fw_flower->pf_hw;
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_pf_repr_disable_queues(dev);
@@ -97,11 +101,11 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	update |= NFP_NET_CFG_UPDATE_RSS;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS2) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS2;
 	else
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS;
@@ -111,19 +115,19 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
 
 	/* If an error when reconfig we avoid to change hw state */
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to reconfig PF vnic");
 		return -EIO;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
@@ -374,7 +378,7 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw,
 			vnic_type, hw->max_rx_queues, hw->max_tx_queues);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	return 0;
 }
@@ -690,14 +694,16 @@ nfp_flower_cleanup_ctrl_vnic(struct nfp_net_hw *hw)
 }
 
 static int
-nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
+nfp_flower_start_ctrl_vnic(struct nfp_net_hw *net_hw)
 {
 	int ret;
 	uint32_t update;
 	uint32_t new_ctrl;
+	struct nfp_hw *hw;
 	struct rte_eth_dev *dev;
 
-	dev = hw->eth_dev;
+	dev = net_hw->eth_dev;
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_net_disable_queues(dev);
@@ -706,7 +712,7 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 	nfp_net_enable_queues(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	new_ctrl = NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
@@ -715,13 +721,13 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 	rte_wmb();
 
 	/* If an error when reconfig we avoid to change hw state */
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to reconfig ctrl vnic");
 		return -EIO;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index a773a81e55..1378545d22 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -45,12 +45,13 @@ nfp_net_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	uint32_t cap_extend;
 	uint32_t intr_vector;
-	struct nfp_net_hw *hw;
 	uint32_t ctrl_extend = 0;
+	struct nfp_net_hw *net_hw;
 	struct nfp_pf_dev *pf_dev;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
@@ -58,9 +59,10 @@ 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;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_net_disable_queues(dev);
@@ -100,9 +102,9 @@ nfp_net_start(struct rte_eth_dev *dev)
 	}
 
 	/* Checking MTU set */
-	if (dev->data->mtu > hw->flbufsz) {
+	if (dev->data->mtu > net_hw->flbufsz) {
 		PMD_INIT_LOG(ERR, "MTU (%u) can't be larger than the current NFP_FRAME_SIZE (%u)",
-				dev->data->mtu, hw->flbufsz);
+				dev->data->mtu, net_hw->flbufsz);
 		return -ERANGE;
 	}
 
@@ -111,7 +113,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	dev_conf = &dev->data->dev_conf;
 	rxmode = &dev_conf->rxmode;
@@ -119,7 +121,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
 	}
 
 	/* Enable device */
@@ -128,19 +130,19 @@ nfp_net_start(struct rte_eth_dev *dev)
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
 	/* Enable vxlan */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
+	if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
 		new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
 		update |= NFP_NET_CFG_UPDATE_VXLAN;
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/* Enable packet type offload by extend ctrl word1. */
-	cap_extend = hw->super.cap_ext;
+	cap_extend = hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
 		ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
 
@@ -149,10 +151,10 @@ nfp_net_start(struct rte_eth_dev *dev)
 				| NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
-	if (nfp_net_ext_reconfig(hw, ctrl_extend, update) != 0)
+	if (nfp_ext_reconfig(hw, ctrl_extend, update) != 0)
 		return -EIO;
 
-	hw->super.ctrl_ext = ctrl_extend;
+	hw->ctrl_ext = ctrl_extend;
 
 	/*
 	 * Allocating rte mbufs for configured rx queues.
@@ -165,11 +167,11 @@ nfp_net_start(struct rte_eth_dev *dev)
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		/* Configure the physical port up */
-		nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 1);
+		nfp_eth_set_configured(net_hw->cpp, net_hw->nfp_idx, 1);
 	else
-		nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 1);
+		nfp_eth_set_configured(dev->process_private, net_hw->nfp_idx, 1);
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
@@ -587,7 +589,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 7fb2a3d378..6ead7e02b8 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -32,10 +32,11 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	uint32_t intr_vector;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
@@ -77,8 +78,9 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nfp_net_params_setup(hw);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+	nfp_net_params_setup(net_hw);
 
 	dev_conf = &dev->data->dev_conf;
 	rxmode = &dev_conf->rxmode;
@@ -86,7 +88,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
 	}
 
 	/* Enable device */
@@ -94,11 +96,11 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/*
@@ -110,7 +112,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
@@ -320,7 +322,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 2ab8d8fadd..9e6d2fa490 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -199,7 +199,7 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 #define FW_VER_LEN        32
 
 static int
-__nfp_net_reconfig(struct nfp_net_hw *hw,
+nfp_reconfig_real(struct nfp_hw *hw,
 		uint32_t update)
 {
 	uint32_t cnt;
@@ -207,14 +207,14 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 	struct timespec wait;
 
 	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->super.qcp_cfg);
+			hw->qcp_cfg);
 
-	if (hw->super.qcp_cfg == NULL) {
+	if (hw->qcp_cfg == NULL) {
 		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
 		return -ENXIO;
 	}
 
-	nfp_qcp_ptr_add(hw->super.qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
 
 	wait.tv_sec = 0;
 	wait.tv_nsec = 1000000; /* 1ms */
@@ -223,7 +223,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	/* Poll update field, waiting for NFP to ack the config */
 	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(&hw->super, NFP_NET_CFG_UPDATE);
+		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
 		if (new == 0)
 			break;
 
@@ -263,7 +263,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure the device.
  */
 int
-nfp_net_reconfig(struct nfp_net_hw *hw,
+nfp_reconfig(struct nfp_hw *hw,
 		uint32_t ctrl,
 		uint32_t update)
 {
@@ -271,17 +271,17 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, update);
+	ret = nfp_reconfig_real(hw, update);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
 	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp net reconfig: ctrl=%#08x update=%#08x",
+		PMD_DRV_LOG(ERR, "Error nfp reconfig: ctrl=%#08x update=%#08x",
 				ctrl, update);
 		return -EIO;
 	}
@@ -307,7 +307,7 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure the device.
  */
 int
-nfp_net_ext_reconfig(struct nfp_net_hw *hw,
+nfp_ext_reconfig(struct nfp_hw *hw,
 		uint32_t ctrl_ext,
 		uint32_t update)
 {
@@ -315,17 +315,17 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, update);
+	ret = nfp_reconfig_real(hw, update);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
 	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nft net ext reconfig: ctrl_ext=%#08x update=%#08x",
+		PMD_DRV_LOG(ERR, "Error nfp ext reconfig: ctrl_ext=%#08x update=%#08x",
 				ctrl_ext, update);
 		return -EIO;
 	}
@@ -354,16 +354,16 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 
 	mbox = hw->tlv_caps.mbox_off;
 
-	rte_spinlock_lock(&hw->reconfig_lock);
+	rte_spinlock_lock(&hw->super.reconfig_lock);
 
 	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
 	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_MBOX);
+	ret = nfp_reconfig_real(&hw->super, NFP_NET_CFG_UPDATE_MBOX);
 
-	rte_spinlock_unlock(&hw->reconfig_lock);
+	rte_spinlock_unlock(&hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net mailbox reconfig: mbox=%#08x update=%#08x",
@@ -494,26 +494,28 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 {
 	uint32_t update;
 	uint32_t new_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 }
 
 void
@@ -551,26 +553,28 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 {
 	uint32_t ctrl;
 	uint32_t update;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
+	nfp_net_write_mac(net_hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
-	ctrl = hw->super.ctrl;
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
+	ctrl = hw->ctrl;
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
 	/* Signal the NIC about the change */
-	if (nfp_net_reconfig(hw, ctrl, update) != 0) {
+	if (nfp_reconfig(hw, ctrl, update) != 0) {
 		PMD_DRV_LOG(ERR, "MAC address update failed");
 		return -EIO;
 	}
@@ -689,36 +693,38 @@ int
 nfp_net_promisc_enable(struct rte_eth_dev *dev)
 {
 	int ret;
+	uint32_t update;
 	uint32_t new_ctrl;
-	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
 		repr = dev->data->dev_private;
-		hw = repr->app_fw_flower->pf_hw;
+		net_hw = repr->app_fw_flower->pf_hw;
 	} else {
-		hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+		net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	hw = &net_hw->super;
+	if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(ERR, "Promiscuous mode not supported");
 		return -ENOTSUP;
 	}
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already enabled");
 		return 0;
 	}
 
-	new_ctrl = hw->super.ctrl | NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -727,25 +733,27 @@ int
 nfp_net_promisc_disable(struct rte_eth_dev *dev)
 {
 	int ret;
+	uint32_t update;
 	uint32_t new_ctrl;
-	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already disabled");
 		return 0;
 	}
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1554,17 +1562,20 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 	int ret;
 	uint32_t update;
 	uint32_t new_ctrl;
+	struct nfp_hw *hw;
 	uint64_t rx_offload;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint32_t rxvlan_ctrl = 0;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
 	rx_offload = dev->data->dev_conf.rxmode.offloads;
-	new_ctrl = hw->super.ctrl;
+	new_ctrl = hw->ctrl;
 
 	/* VLAN stripping setting */
 	if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) {
-		nfp_net_enable_rxvlan_cap(hw, &rxvlan_ctrl);
+		nfp_net_enable_rxvlan_cap(net_hw, &rxvlan_ctrl);
 		if ((rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) != 0)
 			new_ctrl |= rxvlan_ctrl;
 		else
@@ -1579,16 +1590,16 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 			new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
-	if (new_ctrl == hw->super.ctrl)
+	if (new_ctrl == hw->ctrl)
 		return 0;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1658,10 +1669,13 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 {
 	int ret;
 	uint32_t update;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size);
@@ -1670,7 +1684,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
+	if (nfp_reconfig(hw, hw->ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1789,14 +1803,16 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 {
 	uint32_t update;
 	uint64_t rss_hf;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	rss_hf = rss_conf->rss_hf;
 
 	/* Checking if RSS is enabled */
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		if (rss_hf != 0) {
 			PMD_DRV_LOG(ERR, "RSS unsupported");
 			return -EINVAL;
@@ -1814,7 +1830,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
+	if (nfp_reconfig(hw, hw->ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1969,31 +1985,32 @@ nfp_net_close_tx_queue(struct rte_eth_dev *dev)
 }
 
 int
-nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
+nfp_net_set_vxlan_port(struct nfp_net_hw *net_hw,
 		size_t idx,
 		uint16_t port)
 {
 	int ret;
 	uint32_t i;
+	struct nfp_hw *hw = &net_hw->super;
 
 	if (idx >= NFP_NET_N_VXLAN_PORTS) {
 		PMD_DRV_LOG(ERR, "The idx value is out of range.");
 		return -ERANGE;
 	}
 
-	hw->vxlan_ports[idx] = port;
+	net_hw->vxlan_ports[idx] = port;
 
 	for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) {
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
-				(hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]);
+		nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
+				(net_hw->vxlan_ports[i + 1] << 16) | net_hw->vxlan_ports[i]);
 	}
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN);
+	ret = nfp_reconfig_real(hw, NFP_NET_CFG_UPDATE_VXLAN);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 3fe3e96107..d418cd2b99 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -119,6 +119,7 @@ struct nfp_hw {
 	uint32_t cap_ext;
 	uint32_t ctrl;
 	uint32_t ctrl_ext;
+	rte_spinlock_t reconfig_lock;
 };
 
 struct nfp_net_hw {
@@ -150,8 +151,6 @@ struct nfp_net_hw {
 	uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
 	uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
 
-	rte_spinlock_t reconfig_lock;
-
 	uint32_t max_tx_queues;
 	uint32_t max_rx_queues;
 	uint16_t flbufsz;
@@ -368,8 +367,8 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 }
 
 /* Prototypes for common NFP functions */
-int nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update);
-int nfp_net_ext_reconfig(struct nfp_net_hw *hw, uint32_t ctrl_ext, uint32_t update);
+int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
+int nfp_ext_reconfig(struct nfp_hw *hw, uint32_t ctrl_ext, uint32_t update);
 int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
 int nfp_net_configure(struct rte_eth_dev *dev);
 int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 11/25] net/nfp: extract the MAC address data field
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (9 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 10/25] net/nfp: change the parameter of reconfig Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 12/25] net/nfp: rename parameter in related logic Chaoyong He
                     ` (15 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'mac_addr' 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/nfp_ethdev.c     | 14 +++++++-------
 drivers/net/nfp/nfp_ethdev_vf.c  | 18 +++++++++---------
 drivers/net/nfp/nfp_net_common.c |  8 ++++----
 drivers/net/nfp/nfp_net_common.h |  5 ++---
 4 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 1378545d22..a93742a205 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -33,7 +33,7 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic,
 
 	nfp_eth_table = nfp_eth_read_ports(app_fw_nic->pf_dev->cpp);
 
-	rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->mac_addr);
+	rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->super.mac_addr);
 
 	free(nfp_eth_table);
 
@@ -599,18 +599,18 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+	nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 
-	tmp_ether_addr = &hw->mac_addr;
+	tmp_ether_addr = &hw->super.mac_addr;
 	if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
 
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -621,7 +621,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			eth_dev->data->port_id, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
 
 	/* Registering LSC interrupt handler */
 	rte_intr_callback_register(pci_dev->intr_handle,
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 6ead7e02b8..dead6ca5ab 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -16,14 +16,14 @@
 #include "nfp_net_common.h"
 
 static void
-nfp_netvf_read_mac(struct nfp_net_hw *hw)
+nfp_netvf_read_mac(struct nfp_hw *hw)
 {
 	uint32_t tmp;
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
 	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR + 4));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
 	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
 }
 
@@ -332,16 +332,16 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(hw);
-	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
+	nfp_netvf_read_mac(&hw->super);
+	if (rte_is_valid_assigned_ether_addr(&hw->super.mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
 
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -352,7 +352,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			port, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		/* Registering LSC interrupt handler */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 9e6d2fa490..a760fcf0d2 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -532,19 +532,19 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 }
 
 void
-nfp_net_write_mac(struct nfp_net_hw *hw,
+nfp_net_write_mac(struct nfp_hw *hw,
 		uint8_t *mac)
 {
 	uint32_t mac0;
 	uint16_t mac1;
 
 	mac0 = *(uint32_t *)mac;
-	nn_writel(rte_cpu_to_be_32(mac0), hw->super.ctrl_bar + NFP_NET_CFG_MACADDR);
+	nn_writel(rte_cpu_to_be_32(mac0), hw->ctrl_bar + NFP_NET_CFG_MACADDR);
 
 	mac += 4;
 	mac1 = *(uint16_t *)mac;
 	nn_writew(rte_cpu_to_be_16(mac1),
-			hw->super.ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
 }
 
 int
@@ -565,7 +565,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(net_hw, (uint8_t *)mac_addr);
+	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index d418cd2b99..e997756091 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -120,6 +120,7 @@ struct nfp_hw {
 	uint32_t ctrl;
 	uint32_t ctrl_ext;
 	rte_spinlock_t reconfig_lock;
+	struct rte_ether_addr mac_addr;
 };
 
 struct nfp_net_hw {
@@ -159,8 +160,6 @@ struct nfp_net_hw {
 	uint16_t subsystem_device_id;
 	uint16_t subsystem_vendor_id;
 
-	struct rte_ether_addr mac_addr;
-
 	/** Records starting point for counters */
 	struct rte_eth_stats eth_stats_base;
 	struct rte_eth_xstat *eth_xstats_base;
@@ -376,7 +375,7 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac);
+void nfp_net_write_mac(struct nfp_hw *hw, uint8_t *mac);
 int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 		struct rte_intr_handle *intr_handle);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 12/25] net/nfp: rename parameter in related logic
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (10 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 11/25] net/nfp: extract the MAC address data field Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 13/25] drivers: add the common ctrl module Chaoyong He
                     ` (14 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename parameter 'hw' into 'net_hw' in the related logic, to make the
name more accurate.

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        |  86 +++++++++++------------
 drivers/net/nfp/nfp_ethdev_vf.c     |  62 +++++++++--------
 drivers/net/nfp/nfp_ipsec.c         |  82 +++++++++++-----------
 drivers/net/nfp/nfp_net_common.c    | 102 ++++++++++++++++------------
 drivers/net/nfp/nfp_net_ctrl.c      |  14 ++--
 drivers/net/nfp/nfp_rxtx.c          |  16 ++---
 7 files changed, 193 insertions(+), 177 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 831f4a7265..f3fedbf7e5 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -25,18 +25,18 @@ static void
 nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 {
 	uint16_t i;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
 	uint64_t enabled_queues = 0;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	hw = &repr->app_fw_flower->pf_hw->super;
 
 	/* Enabling the required TX queues in the device */
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	enabled_queues = 0;
 
@@ -44,7 +44,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 static void
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index a93742a205..3d4b78fbf1 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -479,11 +479,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	uint16_t port;
 	uint64_t rx_base;
 	uint64_t tx_base;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_pf_dev *pf_dev;
 	struct rte_pci_device *pci_dev;
 	struct nfp_app_fw_nic *app_fw_nic;
-	struct rte_ether_addr *tmp_ether_addr;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 
@@ -503,46 +503,47 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	 * Use PF array of physical ports to get pointer to
 	 * this specific port.
 	 */
-	hw = app_fw_nic->ports[port];
+	net_hw = app_fw_nic->ports[port];
+	hw = &net_hw->super;
 
 	PMD_INIT_LOG(DEBUG, "Working with physical port number: %hu, "
-			"NFP internal port number: %d", port, hw->nfp_idx);
+			"NFP internal port number: %d", port, net_hw->nfp_idx);
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-	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");
+	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;
 
-		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);
-		if (hw->mac_stats_bar == NULL) {
+		hw->ctrl_bar = pf_dev->ctrl_bar;
+		min_size = NFP_MAC_STATS_SIZE * net_hw->pf_dev->nfp_eth_table->max_index;
+		net_hw->mac_stats_bar = nfp_rtsym_map(net_hw->pf_dev->sym_tbl, "_mac_stats",
+				min_size, &net_hw->mac_stats_area);
+		if (net_hw->mac_stats_bar == NULL) {
 			PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for _mac_stats_bar");
 			return -EIO;
 		}
 
-		hw->mac_stats = hw->mac_stats_bar;
+		net_hw->mac_stats = net_hw->mac_stats_bar;
 	} else {
 		if (pf_dev->ctrl_bar == NULL)
 			return -ENODEV;
 
 		/* Use port offset in pf ctrl_bar for this ports control bar */
-		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);
+		hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ);
+		net_hw->mac_stats = app_fw_nic->ports[0]->mac_stats_bar +
+				(net_hw->nfp_idx * NFP_MAC_STATS_SIZE);
 	}
 
-	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->super.ctrl_bar);
-	PMD_INIT_LOG(DEBUG, "MAC stats: %p", hw->mac_stats);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "MAC stats: %p", net_hw->mac_stats);
 
-	err = nfp_net_common_init(pci_dev, hw);
+	err = nfp_net_common_init(pci_dev, net_hw);
 	if (err != 0)
 		return err;
 
@@ -558,38 +559,38 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 		return err;
 	}
 
-	nfp_net_ethdev_ops_mount(hw, eth_dev);
+	nfp_net_ethdev_ops_mount(net_hw, eth_dev);
 
-	hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *
+	net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *
 			nfp_net_xstats_size(eth_dev), 0);
-	if (hw->eth_xstats_base == NULL) {
+	if (net_hw->eth_xstats_base == NULL) {
 		PMD_INIT_LOG(ERR, "no memory for xstats base values on device %s!",
 				pci_dev->device.name);
 		return -ENOMEM;
 	}
 
 	/* Work out where in the BAR the queues start. */
-	tx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
-	rx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
+	tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	rx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
 
-	hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
-	hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
-	eth_dev->data->dev_private = hw;
+	net_hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
+	net_hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
+	eth_dev->data->dev_private = net_hw;
 
 	PMD_INIT_LOG(DEBUG, "ctrl_bar: %p, tx_bar: %p, rx_bar: %p",
-			hw->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->ctrl_bar, net_hw->tx_bar, net_hw->rx_bar);
 
-	nfp_net_cfg_queue_setup(hw);
-	hw->mtu = RTE_ETHER_MTU;
+	nfp_net_cfg_queue_setup(net_hw);
+	net_hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
-	nfp_net_log_device_information(hw);
+	nfp_net_log_device_information(net_hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->super.reconfig_lock);
+	rte_spinlock_init(&hw->reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
@@ -599,20 +600,19 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 
-	tmp_ether_addr = &hw->super.mac_addr;
-	if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) {
+	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
@@ -621,13 +621,13 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			eth_dev->data->port_id, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
 
 	/* Registering LSC interrupt handler */
 	rte_intr_callback_register(pci_dev->intr_handle,
 			nfp_net_dev_interrupt_handler, (void *)eth_dev);
 	/* Telling the firmware about the LSC interrupt entry */
-	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 	/* Recording current stats counters values */
 	nfp_net_stats_reset(eth_dev);
 
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index dead6ca5ab..049728d30c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -254,7 +254,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	int err;
 	uint16_t port;
 	uint32_t start_q;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint64_t tx_bar_off = 0;
 	uint64_t rx_bar_off = 0;
 	struct rte_pci_device *pci_dev;
@@ -269,22 +270,23 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		return -ENODEV;
 	}
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	hw->dev_info = dev_info;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw->dev_info = dev_info;
+	hw = &net_hw->super;
 
-	hw->super.ctrl_bar = pci_dev->mem_resource[0].addr;
-	if (hw->super.ctrl_bar == NULL) {
+	hw->ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->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->super.ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
 
-	err = nfp_net_common_init(pci_dev, hw);
+	err = nfp_net_common_init(pci_dev, net_hw);
 	if (err != 0)
 		return err;
 
-	nfp_netvf_ethdev_ops_mount(hw, eth_dev);
+	nfp_netvf_ethdev_ops_mount(net_hw, eth_dev);
 
 	/* For secondary processes, the primary has done all the work */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -292,37 +294,37 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-	hw->eth_xstats_base = rte_malloc("rte_eth_xstat",
+	net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat",
 			sizeof(struct rte_eth_xstat) * nfp_net_xstats_size(eth_dev), 0);
-	if (hw->eth_xstats_base == NULL) {
+	if (net_hw->eth_xstats_base == NULL) {
 		PMD_INIT_LOG(ERR, "No memory for xstats base values on device %s!",
 				pci_dev->device.name);
 		return -ENOMEM;
 	}
 
 	/* Work out where in the BAR the queues start. */
-	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
-	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
 
-	hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
-	hw->rx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + rx_bar_off;
+	net_hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
+	net_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->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->ctrl_bar, net_hw->tx_bar, net_hw->rx_bar);
 
-	nfp_net_cfg_queue_setup(hw);
-	hw->mtu = RTE_ETHER_MTU;
+	nfp_net_cfg_queue_setup(net_hw);
+	net_hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
-	nfp_net_log_device_information(hw);
+	nfp_net_log_device_information(net_hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->super.reconfig_lock);
+	rte_spinlock_init(&hw->reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
@@ -332,18 +334,18 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(&hw->super);
-	if (rte_is_valid_assigned_ether_addr(&hw->super.mac_addr) == 0) {
+	nfp_netvf_read_mac(hw);
+	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
@@ -352,14 +354,14 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			port, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		/* Registering LSC interrupt handler */
 		rte_intr_callback_register(pci_dev->intr_handle,
 				nfp_net_dev_interrupt_handler, (void *)eth_dev);
 		/* Telling the firmware about the LSC interrupt entry */
-		nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 		/* Recording current stats counters values */
 		nfp_net_stats_reset(eth_dev);
 	}
@@ -367,7 +369,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	return 0;
 
 dev_err_ctrl_map:
-		nfp_cpp_area_free(hw->ctrl_area);
+		nfp_cpp_area_free(net_hw->ctrl_area);
 
 	return err;
 }
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index 0da5c2a3d2..7e26977dc1 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -434,7 +434,7 @@ enum nfp_ipsec_df_type {
 };
 
 static int
-nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
+nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *net_hw,
 		struct nfp_ipsec_msg *msg)
 {
 	int ret;
@@ -445,9 +445,9 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	msg->rsp = NFP_IPSEC_CFG_MSG_OK;
 
 	for (i = 0; i < msg_size; i++)
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
+		nn_cfg_writel(&net_hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
 
-	ret = nfp_net_mbox_reconfig(hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
+	ret = nfp_net_mbox_reconfig(net_hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to IPsec reconfig mbox");
 		return ret;
@@ -459,7 +459,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	 * response. One example where the data is needed is for statistics.
 	 */
 	for (i = 0; i < msg_size; i++)
-		msg->raw[i] = nn_cfg_readl(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
+		msg->raw[i] = nn_cfg_readl(&net_hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
 
 	switch (msg->rsp) {
 	case NFP_IPSEC_CFG_MSG_OK:
@@ -577,10 +577,10 @@ nfp_aead_map(struct rte_eth_dev *eth_dev,
 	uint32_t device_id;
 	const char *iv_str;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 	offset = 0;
 
 	switch (aead->algo) {
@@ -665,10 +665,10 @@ nfp_cipher_map(struct rte_eth_dev *eth_dev,
 	uint32_t i;
 	uint32_t device_id;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 
 	switch (cipher->algo) {
 	case RTE_CRYPTO_CIPHER_NULL:
@@ -801,15 +801,15 @@ nfp_auth_map(struct rte_eth_dev *eth_dev,
 	uint8_t key_length;
 	uint32_t device_id;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
 	if (digest_length == 0) {
 		PMD_DRV_LOG(ERR, "Auth digest length is illegal!");
 		return -EINVAL;
 	}
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 	digest_length = digest_length << 3;
 
 	switch (auth->algo) {
@@ -1068,7 +1068,7 @@ nfp_crypto_create_session(void *device,
 {
 	int ret;
 	int sa_idx;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg msg;
 	struct rte_eth_dev *eth_dev;
 	struct nfp_ipsec_session *priv_session;
@@ -1082,14 +1082,14 @@ nfp_crypto_create_session(void *device,
 	sa_idx = -1;
 	eth_dev = device;
 	priv_session = SECURITY_GET_SESS_PRIV(session);
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-	if (hw->ipsec_data->sa_free_cnt == 0) {
+	if (net_hw->ipsec_data->sa_free_cnt == 0) {
 		PMD_DRV_LOG(ERR, "No space in SA table, spi: %d", conf->ipsec.spi);
 		return -EINVAL;
 	}
 
-	nfp_get_sa_entry(hw->ipsec_data, &sa_idx);
+	nfp_get_sa_entry(net_hw->ipsec_data, &sa_idx);
 
 	if (sa_idx < 0) {
 		PMD_DRV_LOG(ERR, "Failed to get SA entry!");
@@ -1105,7 +1105,7 @@ nfp_crypto_create_session(void *device,
 
 	msg.cmd = NFP_IPSEC_CFG_MSG_ADD_SA;
 	msg.sa_idx = sa_idx;
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &msg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to add SA to nic");
 		return -EINVAL;
@@ -1118,8 +1118,8 @@ nfp_crypto_create_session(void *device,
 	priv_session->dev = eth_dev;
 	priv_session->user_data = conf->userdata;
 
-	hw->ipsec_data->sa_free_cnt--;
-	hw->ipsec_data->sa_entries[sa_idx] = priv_session;
+	net_hw->ipsec_data->sa_free_cnt--;
+	net_hw->ipsec_data->sa_entries[sa_idx] = priv_session;
 
 	return 0;
 }
@@ -1156,19 +1156,19 @@ nfp_security_set_pkt_metadata(void *device,
 {
 	int offset;
 	uint64_t *sqn;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct rte_eth_dev *eth_dev;
 	struct nfp_ipsec_session *priv_session;
 
 	sqn = params;
 	eth_dev = device;
 	priv_session = SECURITY_GET_SESS_PRIV(session);
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
 	if (priv_session->ipsec.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
 		struct nfp_tx_ipsec_desc_msg *desc_md;
 
-		offset = hw->ipsec_data->pkt_dynfield_offset;
+		offset = net_hw->ipsec_data->pkt_dynfield_offset;
 		desc_md = RTE_MBUF_DYNFIELD(m, offset, struct nfp_tx_ipsec_desc_msg *);
 
 		if (priv_session->msg.ctrl_word.ext_seq != 0 && sqn != NULL) {
@@ -1223,7 +1223,7 @@ nfp_security_session_get_stats(void *device,
 		struct rte_security_stats *stats)
 {
 	int ret;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg msg;
 	struct rte_eth_dev *eth_dev;
 	struct ipsec_get_sa_stats *cfg_s;
@@ -1236,9 +1236,9 @@ nfp_security_session_get_stats(void *device,
 	memset(&msg, 0, sizeof(msg));
 	msg.cmd = NFP_IPSEC_CFG_MSG_GET_SA_STATS;
 	msg.sa_idx = priv_session->sa_index;
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &msg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to get SA stats");
 		return ret;
@@ -1284,22 +1284,22 @@ nfp_crypto_remove_sa(struct rte_eth_dev *eth_dev,
 {
 	int ret;
 	uint32_t sa_index;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg cfg;
 
 	sa_index = priv_session->sa_index;
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
 	cfg.cmd = NFP_IPSEC_CFG_MSG_INV_SA;
 	cfg.sa_idx = sa_index;
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &cfg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &cfg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to remove SA!");
 		return -EINVAL;
 	}
 
-	hw->ipsec_data->sa_free_cnt++;
-	hw->ipsec_data->sa_entries[sa_index] = NULL;
+	net_hw->ipsec_data->sa_free_cnt++;
+	net_hw->ipsec_data->sa_entries[sa_index] = NULL;
 
 	return 0;
 }
@@ -1377,12 +1377,12 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint32_t cap_extend;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_net_ipsec_data *data;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->super.cap_ext;
+	cap_extend = net_hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return 0;
@@ -1396,7 +1396,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 
 	data->pkt_dynfield_offset = -1;
 	data->sa_free_cnt = NFP_NET_IPSEC_MAX_SA_CNT;
-	hw->ipsec_data = data;
+	net_hw->ipsec_data = data;
 
 	ret = nfp_ipsec_ctx_create(dev, data);
 	if (ret != 0) {
@@ -1424,12 +1424,12 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 {
 	uint16_t i;
 	uint32_t cap_extend;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_session *priv_session;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->super.cap_ext;
+	cap_extend = net_hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return;
@@ -1437,17 +1437,17 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 
 	nfp_ipsec_ctx_destroy(dev);
 
-	if (hw->ipsec_data == NULL) {
+	if (net_hw->ipsec_data == NULL) {
 		PMD_INIT_LOG(INFO, "IPsec data is NULL!");
 		return;
 	}
 
 	for (i = 0; i < NFP_NET_IPSEC_MAX_SA_CNT; i++) {
-		priv_session = hw->ipsec_data->sa_entries[i];
+		priv_session = net_hw->ipsec_data->sa_entries[i];
 		if (priv_session != NULL)
 			memset(priv_session, 0, sizeof(struct nfp_ipsec_session));
 	}
 
-	rte_free(hw->ipsec_data);
+	rte_free(net_hw->ipsec_data);
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index a760fcf0d2..01574de963 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -336,7 +336,7 @@ nfp_ext_reconfig(struct nfp_hw *hw,
 /**
  * Reconfigure the firmware via the mailbox
  *
- * @param hw
+ * @param net_hw
  *   Device to reconfigure
  * @param mbox_cmd
  *   The value for the mailbox command
@@ -346,24 +346,24 @@ nfp_ext_reconfig(struct nfp_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure by the mailbox
  */
 int
-nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
+nfp_net_mbox_reconfig(struct nfp_net_hw *net_hw,
 		uint32_t mbox_cmd)
 {
 	int ret;
 	uint32_t mbox;
 
-	mbox = hw->tlv_caps.mbox_off;
+	mbox = net_hw->tlv_caps.mbox_off;
 
-	rte_spinlock_lock(&hw->super.reconfig_lock);
+	rte_spinlock_lock(&net_hw->super.reconfig_lock);
 
-	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
+	nn_cfg_writeq(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
+	nn_cfg_writel(&net_hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
-	ret = nfp_reconfig_real(&hw->super, NFP_NET_CFG_UPDATE_MBOX);
+	ret = nfp_reconfig_real(&net_hw->super, NFP_NET_CFG_UPDATE_MBOX);
 
-	rte_spinlock_unlock(&hw->super.reconfig_lock);
+	rte_spinlock_unlock(&net_hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net mailbox reconfig: mbox=%#08x update=%#08x",
@@ -371,7 +371,7 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 		return -EIO;
 	}
 
-	return nn_cfg_readl(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
+	return nn_cfg_readl(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
 }
 
 /*
@@ -625,6 +625,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 uint32_t
 nfp_check_offloads(struct rte_eth_dev *dev)
 {
+	uint32_t cap;
 	uint32_t ctrl = 0;
 	uint64_t rx_offload;
 	uint64_t tx_offload;
@@ -632,13 +633,14 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	struct rte_eth_conf *dev_conf;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	cap = hw->super.cap;
 
 	dev_conf = &dev->data->dev_conf;
 	rx_offload = dev_conf->rxmode.offloads;
 	tx_offload = dev_conf->txmode.offloads;
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXCSUM;
 	}
 
@@ -646,25 +648,25 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 		nfp_net_enable_rxvlan_cap(hw, &ctrl);
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
 	hw->mtu = dev->data->mtu;
 
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2;
-		else if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
+		else if ((cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
 	}
 
 	/* L2 broadcast */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2BC) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_L2BC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2BC;
 
 	/* L2 multicast */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2MC) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_L2MC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2MC;
 
 	/* TX checksum offload */
@@ -676,7 +678,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	/* LSO offload */
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 ||
 			(tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_LSO) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_LSO;
 		else
 			ctrl |= NFP_NET_CFG_CTRL_LSO2;
@@ -1194,6 +1196,7 @@ nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
 int
 nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
+	uint32_t cap;
 	uint32_t cap_extend;
 	uint16_t min_rx_desc;
 	uint16_t max_rx_desc;
@@ -1224,32 +1227,34 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
-	if ((hw->super.cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
+	cap = hw->super.cap;
+
+	if ((cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->super.cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
+	if ((cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
 		dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
+	if ((cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
 			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_GATHER) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_GATHER) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	cap_extend = hw->super.cap_ext;
@@ -1292,7 +1297,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG,
 	};
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+	if ((cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
 		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
@@ -1615,9 +1620,11 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 	uint8_t mask;
 	uint32_t reta;
 	uint16_t shift;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
 		PMD_DRV_LOG(ERR, "The size of hash lookup table configured (%hu)"
@@ -1642,7 +1649,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 
 		/* If all 4 entries were set, don't need read RETA register */
 		if (mask != 0xF)
-			reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + i);
+			reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + i);
 
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
@@ -1655,7 +1662,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 			reta |= reta_conf[idx].reta[shift + j] << (8 * j);
 		}
 
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
+		nn_cfg_writel(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
 	}
 
 	return 0;
@@ -1702,10 +1709,13 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 	uint8_t mask;
 	uint32_t reta;
 	uint16_t shift;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
@@ -1728,7 +1738,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 		if (mask == 0)
 			continue;
 
-		reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
+		reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
 				continue;
@@ -1748,15 +1758,17 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	uint8_t i;
 	uint8_t key;
 	uint64_t rss_hf;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint32_t cfg_rss_ctrl = 0;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	/* Writing the key byte by byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
 		memcpy(&key, &rss_conf->rss_key[i], 1);
-		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY + i, key);
+		nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY + i, key);
 	}
 
 	rss_hf = rss_conf->rss_hf;
@@ -1789,10 +1801,10 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
 
 	/* Writing the key size */
-	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
+	nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
 
 	return 0;
 }
@@ -1843,16 +1855,18 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	uint8_t i;
 	uint8_t key;
 	uint64_t rss_hf;
+	struct nfp_hw *hw;
 	uint32_t cfg_rss_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
-	cfg_rss_ctrl = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_CTRL);
+	cfg_rss_ctrl = nn_cfg_readl(hw, NFP_NET_CFG_RSS_CTRL);
 
 	if ((cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4) != 0)
 		rss_hf |= RTE_ETH_RSS_IPV4;
@@ -1882,11 +1896,11 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	rss_conf->rss_hf = rss_hf;
 
 	/* Reading the key size */
-	rss_conf->rss_key_len = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_KEY_SZ);
+	rss_conf->rss_key_len = nn_cfg_readl(hw, NFP_NET_CFG_RSS_KEY_SZ);
 
 	/* Reading the key byte a byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
-		key = nn_cfg_readb(&hw->super, NFP_NET_CFG_RSS_KEY + i);
+		key = nn_cfg_readb(hw, NFP_NET_CFG_RSS_KEY + i);
 		memcpy(&rss_conf->rss_key[i], &key, 1);
 	}
 
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index d469896a64..8848fa38fe 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -29,15 +29,15 @@ nfp_net_tlv_caps_parse(struct rte_eth_dev *dev)
 	uint32_t length;
 	uint32_t offset;
 	uint32_t tlv_type;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_net_tlv_caps *caps;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	caps = &hw->tlv_caps;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	caps = &net_hw->tlv_caps;
 	nfp_net_tlv_caps_reset(caps);
 
-	data = hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
-	end = hw->super.ctrl_bar + NFP_NET_CFG_BAR_SZ;
+	data = net_hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
+	end = net_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->super.ctrl_bar;
+		offset = data - net_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->super.ctrl_bar;
+				caps->mbox_off = data - net_hw->super.ctrl_bar;
 			else
 				caps->mbox_off = 0;
 			break;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index f17cc13cc1..fc94e5f0b9 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -336,10 +336,10 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 		struct nfp_net_rxq *rxq,
 		struct rte_mbuf *mb)
 {
-	struct nfp_net_hw *hw = rxq->hw;
+	uint32_t ctrl = rxq->hw->super.ctrl;
 
-	/* Skip if firmware don't support setting vlan. */
-	if ((hw->super.ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
+	/* Skip if hardware don't support setting vlan. */
+	if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
 	/*
@@ -347,12 +347,12 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	 * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
 	 * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
 	 */
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+	if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
 		if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
 		}
-	} else if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+	} else if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
 		if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
@@ -383,10 +383,10 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 		struct nfp_net_rxq *rxq,
 		struct rte_mbuf *mb)
 {
-	struct nfp_net_hw *hw = rxq->hw;
+	struct nfp_hw *hw = &rxq->hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
-			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
 	if (meta->vlan_layer < NFP_META_MAX_VLANS)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 13/25] drivers: add the common ctrl module
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (11 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 12/25] net/nfp: rename parameter in related logic Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 14/25] drivers: add the nfp common module Chaoyong He
                     ` (13 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the common ctrl module.

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/common/nfp/nfp_common_ctrl.h | 374 +++++++++++++++++++++++++++
 drivers/net/nfp/nfp_net_ctrl.h       | 365 +-------------------------
 2 files changed, 375 insertions(+), 364 deletions(-)
 create mode 100644 drivers/common/nfp/nfp_common_ctrl.h

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
new file mode 100644
index 0000000000..3c8cd916cf
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -0,0 +1,374 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_CTRL_H__
+#define __NFP_COMMON_CTRL_H__
+
+/*
+ * Configuration BAR size.
+ *
+ * On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
+ */
+#define NFP_NET_CFG_BAR_SZ              (32 * 1024)
+
+/* Offset in Freelist buffer where packet starts on RX */
+#define NFP_NET_RX_OFFSET               32
+
+/* Working with metadata api (NFD version > 3.0) */
+#define NFP_NET_META_FIELD_SIZE         4
+#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
+#define NFP_NET_META_HEADER_SIZE        4
+#define NFP_NET_META_NFDK_LENGTH        8
+
+/* Working with metadata vlan api (NFD version >= 2.0) */
+#define NFP_NET_META_VLAN_INFO          16
+#define NFP_NET_META_VLAN_OFFLOAD       31
+#define NFP_NET_META_VLAN_TPID          3
+#define NFP_NET_META_VLAN_MASK          ((1 << NFP_NET_META_VLAN_INFO) - 1)
+#define NFP_NET_META_VLAN_TPID_MASK     ((1 << NFP_NET_META_VLAN_TPID) - 1)
+#define NFP_NET_META_TPID(d)            (((d) >> NFP_NET_META_VLAN_INFO) & \
+						NFP_NET_META_VLAN_TPID_MASK)
+
+/* Prepend field types */
+#define NFP_NET_META_HASH               1 /* Next field carries hash type */
+#define NFP_NET_META_VLAN               4
+#define NFP_NET_META_PORTID             5
+#define NFP_NET_META_IPSEC              9
+
+#define NFP_META_PORT_ID_CTRL           ~0U
+
+/* Hash type prepended when a RSS hash was computed */
+#define NFP_NET_RSS_NONE                0
+#define NFP_NET_RSS_IPV4                1
+#define NFP_NET_RSS_IPV6                2
+#define NFP_NET_RSS_IPV6_EX             3
+#define NFP_NET_RSS_IPV4_TCP            4
+#define NFP_NET_RSS_IPV6_TCP            5
+#define NFP_NET_RSS_IPV6_EX_TCP         6
+#define NFP_NET_RSS_IPV4_UDP            7
+#define NFP_NET_RSS_IPV6_UDP            8
+#define NFP_NET_RSS_IPV6_EX_UDP         9
+#define NFP_NET_RSS_IPV4_SCTP           10
+#define NFP_NET_RSS_IPV6_SCTP           11
+
+/*
+ * @NFP_NET_TXR_MAX:         Maximum number of TX rings
+ * @NFP_NET_TXR_MASK:        Mask for TX rings
+ * @NFP_NET_RXR_MAX:         Maximum number of RX rings
+ * @NFP_NET_RXR_MASK:        Mask for RX rings
+ */
+#define NFP_NET_TXR_MAX                 64
+#define NFP_NET_TXR_MASK                (NFP_NET_TXR_MAX - 1)
+#define NFP_NET_RXR_MAX                 64
+#define NFP_NET_RXR_MASK                (NFP_NET_RXR_MAX - 1)
+
+/*
+ * Read/Write config words (0x0000 - 0x002c)
+ * @NFP_NET_CFG_CTRL:        Global control
+ * @NFP_NET_CFG_UPDATE:      Indicate which fields are updated
+ * @NFP_NET_CFG_TXRS_ENABLE: Bitmask of enabled TX rings
+ * @NFP_NET_CFG_RXRS_ENABLE: Bitmask of enabled RX rings
+ * @NFP_NET_CFG_MTU:         Set MTU size
+ * @NFP_NET_CFG_FLBUFSZ:     Set freelist buffer size (must be larger than MTU)
+ * @NFP_NET_CFG_EXN:         MSI-X table entry for exceptions
+ * @NFP_NET_CFG_LSC:         MSI-X table entry for link state changes
+ * @NFP_NET_CFG_MACADDR:     MAC address
+ *
+ * TODO:
+ * - define Error details in UPDATE
+ */
+#define NFP_NET_CFG_CTRL                0x0000
+#define   NFP_NET_CFG_CTRL_ENABLE         (0x1 <<  0) /* Global enable */
+#define   NFP_NET_CFG_CTRL_PROMISC        (0x1 <<  1) /* Enable Promisc mode */
+#define   NFP_NET_CFG_CTRL_L2BC           (0x1 <<  2) /* Allow L2 Broadcast */
+#define   NFP_NET_CFG_CTRL_L2MC           (0x1 <<  3) /* Allow L2 Multicast */
+#define   NFP_NET_CFG_CTRL_RXCSUM         (0x1 <<  4) /* Enable RX Checksum */
+#define   NFP_NET_CFG_CTRL_TXCSUM         (0x1 <<  5) /* Enable TX Checksum */
+#define   NFP_NET_CFG_CTRL_RXVLAN         (0x1 <<  6) /* Enable VLAN strip */
+#define   NFP_NET_CFG_CTRL_TXVLAN         (0x1 <<  7) /* Enable VLAN insert */
+#define   NFP_NET_CFG_CTRL_SCATTER        (0x1 <<  8) /* Scatter DMA */
+#define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
+#define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
+#define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
+#define   NFP_NET_CFG_CTRL_RXVLAN_V2      (0x1 << 15) /* Enable VLAN strip with metadata */
+#define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
+#define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
+#define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
+#define   NFP_NET_CFG_CTRL_RINGPRIO       (0x1 << 19) /* Ring priorities */
+#define   NFP_NET_CFG_CTRL_MSIXAUTO       (0x1 << 20) /* MSI-X auto-masking */
+#define   NFP_NET_CFG_CTRL_TXRWB          (0x1 << 21) /* Write-back of TX ring */
+#define   NFP_NET_CFG_CTRL_L2SWITCH       (0x1 << 22) /* L2 Switch */
+#define   NFP_NET_CFG_CTRL_TXVLAN_V2      (0x1 << 23) /* Enable VLAN insert with metadata */
+#define   NFP_NET_CFG_CTRL_VXLAN          (0x1 << 24) /* Enable VXLAN */
+#define   NFP_NET_CFG_CTRL_NVGRE          (0x1 << 25) /* Enable NVGRE */
+#define   NFP_NET_CFG_CTRL_MSIX_TX_OFF    (0x1 << 26) /* Disable MSIX for TX */
+#define   NFP_NET_CFG_CTRL_LSO2           (0x1 << 28) /* LSO/TSO (version 2) */
+#define   NFP_NET_CFG_CTRL_RSS2           (0x1 << 29) /* RSS (version 2) */
+#define   NFP_NET_CFG_CTRL_CSUM_COMPLETE  (0x1 << 30) /* Checksum complete */
+#define   NFP_NET_CFG_CTRL_LIVE_ADDR      (0x1U << 31) /* Live MAC addr change */
+#define NFP_NET_CFG_UPDATE              0x0004
+#define   NFP_NET_CFG_UPDATE_GEN          (0x1 <<  0) /* General update */
+#define   NFP_NET_CFG_UPDATE_RING         (0x1 <<  1) /* Ring config change */
+#define   NFP_NET_CFG_UPDATE_RSS          (0x1 <<  2) /* RSS config change */
+#define   NFP_NET_CFG_UPDATE_TXRPRIO      (0x1 <<  3) /* TX Ring prio change */
+#define   NFP_NET_CFG_UPDATE_RXRPRIO      (0x1 <<  4) /* RX Ring prio change */
+#define   NFP_NET_CFG_UPDATE_MSIX         (0x1 <<  5) /* MSI-X change */
+#define   NFP_NET_CFG_UPDATE_L2SWITCH     (0x1 <<  6) /* Switch changes */
+#define   NFP_NET_CFG_UPDATE_RESET        (0x1 <<  7) /* Update due to FLR */
+#define   NFP_NET_CFG_UPDATE_IRQMOD       (0x1 <<  8) /* IRQ mod change */
+#define   NFP_NET_CFG_UPDATE_VXLAN        (0x1 <<  9) /* VXLAN port change */
+#define   NFP_NET_CFG_UPDATE_MACADDR      (0x1 << 11) /* MAC address change */
+#define   NFP_NET_CFG_UPDATE_MBOX         (0x1 << 12) /* Mailbox update */
+#define   NFP_NET_CFG_UPDATE_ERR          (0x1U << 31) /* A error occurred */
+#define NFP_NET_CFG_TXRS_ENABLE         0x0008
+#define NFP_NET_CFG_RXRS_ENABLE         0x0010
+#define NFP_NET_CFG_MTU                 0x0018
+#define NFP_NET_CFG_FLBUFSZ             0x001c
+#define NFP_NET_CFG_EXN                 0x001f
+#define NFP_NET_CFG_LSC                 0x0020
+#define NFP_NET_CFG_MACADDR             0x0024
+
+#define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2)
+#define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2)
+
+#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \
+					NFP_NET_CFG_CTRL_CSUM_COMPLETE)
+
+/* Version number helper defines */
+struct nfp_net_fw_ver {
+	uint8_t minor;
+	uint8_t major;
+	uint8_t class;
+	/**
+	 * This byte can be extended for more use.
+	 * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx
+	 * BIT[7:1]: reserved
+	 */
+	uint8_t extend;
+};
+
+/*
+ * Read-only words (0x0030 - 0x0050):
+ * @NFP_NET_CFG_VERSION:     Firmware version number
+ * @NFP_NET_CFG_STS:         Status
+ * @NFP_NET_CFG_CAP:         Capabilities (same bits as @NFP_NET_CFG_CTRL)
+ * @NFP_NET_MAX_TXRINGS:     Maximum number of TX rings
+ * @NFP_NET_MAX_RXRINGS:     Maximum number of RX rings
+ * @NFP_NET_MAX_MTU:         Maximum support MTU
+ * @NFP_NET_CFG_START_TXQ:   Start Queue Control Queue to use for TX (PF only)
+ * @NFP_NET_CFG_START_RXQ:   Start Queue Control Queue to use for RX (PF only)
+ *
+ * TODO:
+ * - define more STS bits
+ */
+#define NFP_NET_CFG_VERSION             0x0030
+#define   NFP_NET_CFG_VERSION_DP_NFD3   0
+#define   NFP_NET_CFG_VERSION_DP_NFDK   1
+#define NFP_NET_CFG_STS                 0x0034
+#define   NFP_NET_CFG_STS_LINK            (0x1 << 0) /* Link up or down */
+/* Link rate */
+#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
+#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
+#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
+#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN       1
+#define   NFP_NET_CFG_STS_LINK_RATE_1G            2
+#define   NFP_NET_CFG_STS_LINK_RATE_10G           3
+#define   NFP_NET_CFG_STS_LINK_RATE_25G           4
+#define   NFP_NET_CFG_STS_LINK_RATE_40G           5
+#define   NFP_NET_CFG_STS_LINK_RATE_50G           6
+#define   NFP_NET_CFG_STS_LINK_RATE_100G          7
+
+/*
+ * NSP Link rate is a 16-bit word. It is no longer determined by
+ * firmware, instead it is read from the nfp_eth_table of the
+ * associated pf_dev and written to the NFP_NET_CFG_STS_NSP_LINK_RATE
+ * address by the PMD each time the port is reconfigured.
+ */
+#define NFP_NET_CFG_STS_NSP_LINK_RATE   0x0036
+
+#define NFP_NET_CFG_CAP                 0x0038
+#define NFP_NET_CFG_MAX_TXRINGS         0x003c
+#define NFP_NET_CFG_MAX_RXRINGS         0x0040
+#define NFP_NET_CFG_MAX_MTU             0x0044
+/* Next two words are being used by VFs for solving THB350 issue */
+#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
+ */
+#define NFP_NET_CFG_RX_OFFSET           0x0050
+#define NFP_NET_CFG_RX_OFFSET_DYNAMIC          0    /* Prepend mode */
+
+/* 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
+
+/* Offload definitions */
+#define NFP_NET_N_VXLAN_PORTS  (NFP_NET_CFG_VXLAN_SZ / sizeof(uint16_t))
+
+/*
+ * 3 words reserved for extended ctrl words (0x0098 - 0x00a4)
+ * 3 words reserved for extended cap words (0x00a4 - 0x00b0)
+ * Currently only one word is used, can be extended in future.
+ */
+#define NFP_NET_CFG_CTRL_WORD1          0x0098
+#define NFP_NET_CFG_CTRL_PKT_TYPE         (0x1 << 0)
+#define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
+#define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
+#define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
+
+#define NFP_NET_CFG_CAP_WORD1           0x00a4
+
+/* 16B reserved for future use (0x00b0 - 0x00c0). */
+#define NFP_NET_CFG_RESERVED            0x00b0
+#define NFP_NET_CFG_RESERVED_SZ         0x0010
+
+/*
+ * RSS configuration (0x0100 - 0x01ac):
+ * Used only when NFP_NET_CFG_CTRL_RSS_ANY is enabled
+ * @NFP_NET_CFG_RSS_CFG:     RSS configuration word
+ * @NFP_NET_CFG_RSS_KEY:     RSS "secret" key
+ * @NFP_NET_CFG_RSS_ITBL:    RSS indirection table
+ */
+#define NFP_NET_CFG_RSS_BASE            0x0100
+#define NFP_NET_CFG_RSS_CTRL            NFP_NET_CFG_RSS_BASE
+#define   NFP_NET_CFG_RSS_MASK            (0x7f)
+#define   NFP_NET_CFG_RSS_MASK_of(_x)     ((_x) & 0x7f)
+#define   NFP_NET_CFG_RSS_IPV4            (1 <<  8) /* RSS for IPv4 */
+#define   NFP_NET_CFG_RSS_IPV6            (1 <<  9) /* RSS for IPv6 */
+#define   NFP_NET_CFG_RSS_IPV4_TCP        (1 << 10) /* RSS for IPv4/TCP */
+#define   NFP_NET_CFG_RSS_IPV4_UDP        (1 << 11) /* RSS for IPv4/UDP */
+#define   NFP_NET_CFG_RSS_IPV6_TCP        (1 << 12) /* RSS for IPv6/TCP */
+#define   NFP_NET_CFG_RSS_IPV6_UDP        (1 << 13) /* RSS for IPv6/UDP */
+#define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
+#define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
+#define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
+#define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
+#define NFP_NET_CFG_RSS_KEY_SZ          0x28
+#define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
+					 NFP_NET_CFG_RSS_KEY_SZ)
+#define NFP_NET_CFG_RSS_ITBL_SZ         0x80
+
+/*
+ * TX ring configuration (0x200 - 0x800)
+ * @NFP_NET_CFG_TXR_BASE:    Base offset for TX ring configuration
+ * @NFP_NET_CFG_TXR_ADDR:    Per TX ring DMA address (8B entries)
+ * @NFP_NET_CFG_TXR_WB_ADDR: Per TX ring write back DMA address (8B entries)
+ * @NFP_NET_CFG_TXR_SZ:      Per TX ring size (1B entries)
+ * @NFP_NET_CFG_TXR_VEC:     Per TX ring MSI-X table entry (1B entries)
+ * @NFP_NET_CFG_TXR_PRIO:    Per TX ring priority (1B entries)
+ * @NFP_NET_CFG_TXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
+ */
+#define NFP_NET_CFG_TXR_BASE            0x0200
+#define NFP_NET_CFG_TXR_ADDR(_x)        (NFP_NET_CFG_TXR_BASE + ((_x) * 0x8))
+#define NFP_NET_CFG_TXR_WB_ADDR(_x)     (NFP_NET_CFG_TXR_BASE + 0x200 + \
+					 ((_x) * 0x8))
+#define NFP_NET_CFG_TXR_SZ(_x)          (NFP_NET_CFG_TXR_BASE + 0x400 + (_x))
+#define NFP_NET_CFG_TXR_VEC(_x)         (NFP_NET_CFG_TXR_BASE + 0x440 + (_x))
+#define NFP_NET_CFG_TXR_PRIO(_x)        (NFP_NET_CFG_TXR_BASE + 0x480 + (_x))
+#define NFP_NET_CFG_TXR_IRQ_MOD(_x)     (NFP_NET_CFG_TXR_BASE + 0x500 + \
+					 ((_x) * 0x4))
+
+/*
+ * RX ring configuration (0x0800 - 0x0c00)
+ * @NFP_NET_CFG_RXR_BASE:    Base offset for RX ring configuration
+ * @NFP_NET_CFG_RXR_ADDR:    Per TX ring DMA address (8B entries)
+ * @NFP_NET_CFG_RXR_SZ:      Per TX ring size (1B entries)
+ * @NFP_NET_CFG_RXR_VEC:     Per TX ring MSI-X table entry (1B entries)
+ * @NFP_NET_CFG_RXR_PRIO:    Per TX ring priority (1B entries)
+ * @NFP_NET_CFG_RXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
+ */
+#define NFP_NET_CFG_RXR_BASE            0x0800
+#define NFP_NET_CFG_RXR_ADDR(_x)        (NFP_NET_CFG_RXR_BASE + ((_x) * 0x8))
+#define NFP_NET_CFG_RXR_SZ(_x)          (NFP_NET_CFG_RXR_BASE + 0x200 + (_x))
+#define NFP_NET_CFG_RXR_VEC(_x)         (NFP_NET_CFG_RXR_BASE + 0x240 + (_x))
+#define NFP_NET_CFG_RXR_PRIO(_x)        (NFP_NET_CFG_RXR_BASE + 0x280 + (_x))
+#define NFP_NET_CFG_RXR_IRQ_MOD(_x)     (NFP_NET_CFG_RXR_BASE + 0x300 + \
+					 ((_x) * 0x4))
+
+/*
+ * Interrupt Control/Cause registers (0x0c00 - 0x0d00)
+ * These registers are only used when MSI-X auto-masking is not
+ * enabled (@NFP_NET_CFG_CTRL_MSIXAUTO not set).  The array is index
+ * by MSI-X entry and are 1B in size.  If an entry is zero, the
+ * corresponding entry is enabled.  If the FW generates an interrupt,
+ * it writes a cause into the corresponding field.  This also masks
+ * the MSI-X entry and the host driver must clear the register to
+ * re-enable the interrupt.
+ */
+#define NFP_NET_CFG_ICR_BASE            0x0c00
+#define NFP_NET_CFG_ICR(_x)             (NFP_NET_CFG_ICR_BASE + (_x))
+#define   NFP_NET_CFG_ICR_UNMASKED      0x0
+#define   NFP_NET_CFG_ICR_RXTX          0x1
+#define   NFP_NET_CFG_ICR_LSC           0x2
+
+/*
+ * General device stats (0x0d00 - 0x0d90)
+ * All counters are 64bit.
+ */
+#define NFP_NET_CFG_STATS_BASE          0x0d00
+#define NFP_NET_CFG_STATS_RX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x00)
+#define NFP_NET_CFG_STATS_RX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x08)
+#define NFP_NET_CFG_STATS_RX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x10)
+#define NFP_NET_CFG_STATS_RX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x18)
+#define NFP_NET_CFG_STATS_RX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x20)
+#define NFP_NET_CFG_STATS_RX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x28)
+#define NFP_NET_CFG_STATS_RX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x30)
+#define NFP_NET_CFG_STATS_RX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x38)
+#define NFP_NET_CFG_STATS_RX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x40)
+
+#define NFP_NET_CFG_STATS_TX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x48)
+#define NFP_NET_CFG_STATS_TX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x50)
+#define NFP_NET_CFG_STATS_TX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x58)
+#define NFP_NET_CFG_STATS_TX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x60)
+#define NFP_NET_CFG_STATS_TX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x68)
+#define NFP_NET_CFG_STATS_TX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x70)
+#define NFP_NET_CFG_STATS_TX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x78)
+#define NFP_NET_CFG_STATS_TX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x80)
+#define NFP_NET_CFG_STATS_TX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x88)
+
+#define NFP_NET_CFG_STATS_APP0_FRAMES   (NFP_NET_CFG_STATS_BASE + 0x90)
+#define NFP_NET_CFG_STATS_APP0_BYTES    (NFP_NET_CFG_STATS_BASE + 0x98)
+#define NFP_NET_CFG_STATS_APP1_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xa0)
+#define NFP_NET_CFG_STATS_APP1_BYTES    (NFP_NET_CFG_STATS_BASE + 0xa8)
+#define NFP_NET_CFG_STATS_APP2_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xb0)
+#define NFP_NET_CFG_STATS_APP2_BYTES    (NFP_NET_CFG_STATS_BASE + 0xb8)
+#define NFP_NET_CFG_STATS_APP3_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xc0)
+#define NFP_NET_CFG_STATS_APP3_BYTES    (NFP_NET_CFG_STATS_BASE + 0xc8)
+
+/*
+ * Per ring stats (0x1000 - 0x1800)
+ * Options, 64bit per entry
+ * @NFP_NET_CFG_TXR_STATS:   TX ring statistics (Packet and Byte count)
+ * @NFP_NET_CFG_RXR_STATS:   RX ring statistics (Packet and Byte count)
+ */
+#define NFP_NET_CFG_TXR_STATS_BASE      0x1000
+#define NFP_NET_CFG_TXR_STATS(_x)       (NFP_NET_CFG_TXR_STATS_BASE + \
+					 ((_x) * 0x10))
+#define NFP_NET_CFG_RXR_STATS_BASE      0x1400
+#define NFP_NET_CFG_RXR_STATS(_x)       (NFP_NET_CFG_RXR_STATS_BASE + \
+					 ((_x) * 0x10))
+
+#endif /* __NFP_COMMON_CTRL_H__ */
diff --git a/drivers/net/nfp/nfp_net_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
index 3772b28a66..ee1b784bb1 100644
--- a/drivers/net/nfp/nfp_net_ctrl.h
+++ b/drivers/net/nfp/nfp_net_ctrl.h
@@ -10,370 +10,7 @@
 
 #include <ethdev_driver.h>
 
-/*
- * Configuration BAR size.
- *
- * On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
- */
-#define NFP_NET_CFG_BAR_SZ              (32 * 1024)
-
-/* Offset in Freelist buffer where packet starts on RX */
-#define NFP_NET_RX_OFFSET               32
-
-/* Working with metadata api (NFD version > 3.0) */
-#define NFP_NET_META_FIELD_SIZE         4
-#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
-#define NFP_NET_META_HEADER_SIZE        4
-#define NFP_NET_META_NFDK_LENGTH        8
-
-/* Working with metadata vlan api (NFD version >= 2.0) */
-#define NFP_NET_META_VLAN_INFO          16
-#define NFP_NET_META_VLAN_OFFLOAD       31
-#define NFP_NET_META_VLAN_TPID          3
-#define NFP_NET_META_VLAN_MASK          ((1 << NFP_NET_META_VLAN_INFO) - 1)
-#define NFP_NET_META_VLAN_TPID_MASK     ((1 << NFP_NET_META_VLAN_TPID) - 1)
-#define NFP_NET_META_TPID(d)            (((d) >> NFP_NET_META_VLAN_INFO) & \
-						NFP_NET_META_VLAN_TPID_MASK)
-
-/* Prepend field types */
-#define NFP_NET_META_HASH               1 /* Next field carries hash type */
-#define NFP_NET_META_VLAN               4
-#define NFP_NET_META_PORTID             5
-#define NFP_NET_META_IPSEC              9
-
-#define NFP_META_PORT_ID_CTRL           ~0U
-
-/* Hash type prepended when a RSS hash was computed */
-#define NFP_NET_RSS_NONE                0
-#define NFP_NET_RSS_IPV4                1
-#define NFP_NET_RSS_IPV6                2
-#define NFP_NET_RSS_IPV6_EX             3
-#define NFP_NET_RSS_IPV4_TCP            4
-#define NFP_NET_RSS_IPV6_TCP            5
-#define NFP_NET_RSS_IPV6_EX_TCP         6
-#define NFP_NET_RSS_IPV4_UDP            7
-#define NFP_NET_RSS_IPV6_UDP            8
-#define NFP_NET_RSS_IPV6_EX_UDP         9
-#define NFP_NET_RSS_IPV4_SCTP           10
-#define NFP_NET_RSS_IPV6_SCTP           11
-
-/*
- * @NFP_NET_TXR_MAX:         Maximum number of TX rings
- * @NFP_NET_TXR_MASK:        Mask for TX rings
- * @NFP_NET_RXR_MAX:         Maximum number of RX rings
- * @NFP_NET_RXR_MASK:        Mask for RX rings
- */
-#define NFP_NET_TXR_MAX                 64
-#define NFP_NET_TXR_MASK                (NFP_NET_TXR_MAX - 1)
-#define NFP_NET_RXR_MAX                 64
-#define NFP_NET_RXR_MASK                (NFP_NET_RXR_MAX - 1)
-
-/*
- * Read/Write config words (0x0000 - 0x002c)
- * @NFP_NET_CFG_CTRL:        Global control
- * @NFP_NET_CFG_UPDATE:      Indicate which fields are updated
- * @NFP_NET_CFG_TXRS_ENABLE: Bitmask of enabled TX rings
- * @NFP_NET_CFG_RXRS_ENABLE: Bitmask of enabled RX rings
- * @NFP_NET_CFG_MTU:         Set MTU size
- * @NFP_NET_CFG_FLBUFSZ:     Set freelist buffer size (must be larger than MTU)
- * @NFP_NET_CFG_EXN:         MSI-X table entry for exceptions
- * @NFP_NET_CFG_LSC:         MSI-X table entry for link state changes
- * @NFP_NET_CFG_MACADDR:     MAC address
- *
- * TODO:
- * - define Error details in UPDATE
- */
-#define NFP_NET_CFG_CTRL                0x0000
-#define   NFP_NET_CFG_CTRL_ENABLE         (0x1 <<  0) /* Global enable */
-#define   NFP_NET_CFG_CTRL_PROMISC        (0x1 <<  1) /* Enable Promisc mode */
-#define   NFP_NET_CFG_CTRL_L2BC           (0x1 <<  2) /* Allow L2 Broadcast */
-#define   NFP_NET_CFG_CTRL_L2MC           (0x1 <<  3) /* Allow L2 Multicast */
-#define   NFP_NET_CFG_CTRL_RXCSUM         (0x1 <<  4) /* Enable RX Checksum */
-#define   NFP_NET_CFG_CTRL_TXCSUM         (0x1 <<  5) /* Enable TX Checksum */
-#define   NFP_NET_CFG_CTRL_RXVLAN         (0x1 <<  6) /* Enable VLAN strip */
-#define   NFP_NET_CFG_CTRL_TXVLAN         (0x1 <<  7) /* Enable VLAN insert */
-#define   NFP_NET_CFG_CTRL_SCATTER        (0x1 <<  8) /* Scatter DMA */
-#define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
-#define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
-#define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
-#define   NFP_NET_CFG_CTRL_RXVLAN_V2      (0x1 << 15) /* Enable VLAN strip with metadata */
-#define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
-#define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
-#define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
-#define   NFP_NET_CFG_CTRL_RINGPRIO       (0x1 << 19) /* Ring priorities */
-#define   NFP_NET_CFG_CTRL_MSIXAUTO       (0x1 << 20) /* MSI-X auto-masking */
-#define   NFP_NET_CFG_CTRL_TXRWB          (0x1 << 21) /* Write-back of TX ring */
-#define   NFP_NET_CFG_CTRL_L2SWITCH       (0x1 << 22) /* L2 Switch */
-#define   NFP_NET_CFG_CTRL_TXVLAN_V2      (0x1 << 23) /* Enable VLAN insert with metadata */
-#define   NFP_NET_CFG_CTRL_VXLAN          (0x1 << 24) /* Enable VXLAN */
-#define   NFP_NET_CFG_CTRL_NVGRE          (0x1 << 25) /* Enable NVGRE */
-#define   NFP_NET_CFG_CTRL_MSIX_TX_OFF    (0x1 << 26) /* Disable MSIX for TX */
-#define   NFP_NET_CFG_CTRL_LSO2           (0x1 << 28) /* LSO/TSO (version 2) */
-#define   NFP_NET_CFG_CTRL_RSS2           (0x1 << 29) /* RSS (version 2) */
-#define   NFP_NET_CFG_CTRL_CSUM_COMPLETE  (0x1 << 30) /* Checksum complete */
-#define   NFP_NET_CFG_CTRL_LIVE_ADDR      (0x1U << 31) /* Live MAC addr change */
-#define NFP_NET_CFG_UPDATE              0x0004
-#define   NFP_NET_CFG_UPDATE_GEN          (0x1 <<  0) /* General update */
-#define   NFP_NET_CFG_UPDATE_RING         (0x1 <<  1) /* Ring config change */
-#define   NFP_NET_CFG_UPDATE_RSS          (0x1 <<  2) /* RSS config change */
-#define   NFP_NET_CFG_UPDATE_TXRPRIO      (0x1 <<  3) /* TX Ring prio change */
-#define   NFP_NET_CFG_UPDATE_RXRPRIO      (0x1 <<  4) /* RX Ring prio change */
-#define   NFP_NET_CFG_UPDATE_MSIX         (0x1 <<  5) /* MSI-X change */
-#define   NFP_NET_CFG_UPDATE_L2SWITCH     (0x1 <<  6) /* Switch changes */
-#define   NFP_NET_CFG_UPDATE_RESET        (0x1 <<  7) /* Update due to FLR */
-#define   NFP_NET_CFG_UPDATE_IRQMOD       (0x1 <<  8) /* IRQ mod change */
-#define   NFP_NET_CFG_UPDATE_VXLAN        (0x1 <<  9) /* VXLAN port change */
-#define   NFP_NET_CFG_UPDATE_MACADDR      (0x1 << 11) /* MAC address change */
-#define   NFP_NET_CFG_UPDATE_MBOX         (0x1 << 12) /* Mailbox update */
-#define   NFP_NET_CFG_UPDATE_ERR          (0x1U << 31) /* A error occurred */
-#define NFP_NET_CFG_TXRS_ENABLE         0x0008
-#define NFP_NET_CFG_RXRS_ENABLE         0x0010
-#define NFP_NET_CFG_MTU                 0x0018
-#define NFP_NET_CFG_FLBUFSZ             0x001c
-#define NFP_NET_CFG_EXN                 0x001f
-#define NFP_NET_CFG_LSC                 0x0020
-#define NFP_NET_CFG_MACADDR             0x0024
-
-#define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2)
-#define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2)
-
-#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \
-					NFP_NET_CFG_CTRL_CSUM_COMPLETE)
-
-/* Version number helper defines */
-struct nfp_net_fw_ver {
-	uint8_t minor;
-	uint8_t major;
-	uint8_t class;
-	/**
-	 * This byte can be extended for more use.
-	 * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx
-	 * BIT[7:1]: reserved
-	 */
-	uint8_t extend;
-};
-
-/*
- * Read-only words (0x0030 - 0x0050):
- * @NFP_NET_CFG_VERSION:     Firmware version number
- * @NFP_NET_CFG_STS:         Status
- * @NFP_NET_CFG_CAP:         Capabilities (same bits as @NFP_NET_CFG_CTRL)
- * @NFP_NET_MAX_TXRINGS:     Maximum number of TX rings
- * @NFP_NET_MAX_RXRINGS:     Maximum number of RX rings
- * @NFP_NET_MAX_MTU:         Maximum support MTU
- * @NFP_NET_CFG_START_TXQ:   Start Queue Control Queue to use for TX (PF only)
- * @NFP_NET_CFG_START_RXQ:   Start Queue Control Queue to use for RX (PF only)
- *
- * TODO:
- * - define more STS bits
- */
-#define NFP_NET_CFG_VERSION             0x0030
-#define   NFP_NET_CFG_VERSION_DP_NFD3   0
-#define   NFP_NET_CFG_VERSION_DP_NFDK   1
-#define NFP_NET_CFG_STS                 0x0034
-#define   NFP_NET_CFG_STS_LINK            (0x1 << 0) /* Link up or down */
-/* Link rate */
-#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
-#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
-#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
-#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN       1
-#define   NFP_NET_CFG_STS_LINK_RATE_1G            2
-#define   NFP_NET_CFG_STS_LINK_RATE_10G           3
-#define   NFP_NET_CFG_STS_LINK_RATE_25G           4
-#define   NFP_NET_CFG_STS_LINK_RATE_40G           5
-#define   NFP_NET_CFG_STS_LINK_RATE_50G           6
-#define   NFP_NET_CFG_STS_LINK_RATE_100G          7
-
-/*
- * NSP Link rate is a 16-bit word. It is no longer determined by
- * firmware, instead it is read from the nfp_eth_table of the
- * associated pf_dev and written to the NFP_NET_CFG_STS_NSP_LINK_RATE
- * address by the PMD each time the port is reconfigured.
- */
-#define NFP_NET_CFG_STS_NSP_LINK_RATE   0x0036
-
-#define NFP_NET_CFG_CAP                 0x0038
-#define NFP_NET_CFG_MAX_TXRINGS         0x003c
-#define NFP_NET_CFG_MAX_RXRINGS         0x0040
-#define NFP_NET_CFG_MAX_MTU             0x0044
-/* Next two words are being used by VFs for solving THB350 issue */
-#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
- */
-#define NFP_NET_CFG_RX_OFFSET           0x0050
-#define NFP_NET_CFG_RX_OFFSET_DYNAMIC          0    /* Prepend mode */
-
-/* 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
-
-/* Offload definitions */
-#define NFP_NET_N_VXLAN_PORTS  (NFP_NET_CFG_VXLAN_SZ / sizeof(uint16_t))
-
-/*
- * 3 words reserved for extended ctrl words (0x0098 - 0x00a4)
- * 3 words reserved for extended cap words (0x00a4 - 0x00b0)
- * Currently only one word is used, can be extended in future.
- */
-#define NFP_NET_CFG_CTRL_WORD1          0x0098
-#define NFP_NET_CFG_CTRL_PKT_TYPE         (0x1 << 0)
-#define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
-#define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
-#define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
-
-#define NFP_NET_CFG_CAP_WORD1           0x00a4
-
-/* 16B reserved for future use (0x00b0 - 0x00c0). */
-#define NFP_NET_CFG_RESERVED            0x00b0
-#define NFP_NET_CFG_RESERVED_SZ         0x0010
-
-/*
- * RSS configuration (0x0100 - 0x01ac):
- * Used only when NFP_NET_CFG_CTRL_RSS_ANY is enabled
- * @NFP_NET_CFG_RSS_CFG:     RSS configuration word
- * @NFP_NET_CFG_RSS_KEY:     RSS "secret" key
- * @NFP_NET_CFG_RSS_ITBL:    RSS indirection table
- */
-#define NFP_NET_CFG_RSS_BASE            0x0100
-#define NFP_NET_CFG_RSS_CTRL            NFP_NET_CFG_RSS_BASE
-#define   NFP_NET_CFG_RSS_MASK            (0x7f)
-#define   NFP_NET_CFG_RSS_MASK_of(_x)     ((_x) & 0x7f)
-#define   NFP_NET_CFG_RSS_IPV4            (1 <<  8) /* RSS for IPv4 */
-#define   NFP_NET_CFG_RSS_IPV6            (1 <<  9) /* RSS for IPv6 */
-#define   NFP_NET_CFG_RSS_IPV4_TCP        (1 << 10) /* RSS for IPv4/TCP */
-#define   NFP_NET_CFG_RSS_IPV4_UDP        (1 << 11) /* RSS for IPv4/UDP */
-#define   NFP_NET_CFG_RSS_IPV6_TCP        (1 << 12) /* RSS for IPv6/TCP */
-#define   NFP_NET_CFG_RSS_IPV6_UDP        (1 << 13) /* RSS for IPv6/UDP */
-#define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
-#define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
-#define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
-#define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
-#define NFP_NET_CFG_RSS_KEY_SZ          0x28
-#define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
-					 NFP_NET_CFG_RSS_KEY_SZ)
-#define NFP_NET_CFG_RSS_ITBL_SZ         0x80
-
-/*
- * TX ring configuration (0x200 - 0x800)
- * @NFP_NET_CFG_TXR_BASE:    Base offset for TX ring configuration
- * @NFP_NET_CFG_TXR_ADDR:    Per TX ring DMA address (8B entries)
- * @NFP_NET_CFG_TXR_WB_ADDR: Per TX ring write back DMA address (8B entries)
- * @NFP_NET_CFG_TXR_SZ:      Per TX ring size (1B entries)
- * @NFP_NET_CFG_TXR_VEC:     Per TX ring MSI-X table entry (1B entries)
- * @NFP_NET_CFG_TXR_PRIO:    Per TX ring priority (1B entries)
- * @NFP_NET_CFG_TXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
- */
-#define NFP_NET_CFG_TXR_BASE            0x0200
-#define NFP_NET_CFG_TXR_ADDR(_x)        (NFP_NET_CFG_TXR_BASE + ((_x) * 0x8))
-#define NFP_NET_CFG_TXR_WB_ADDR(_x)     (NFP_NET_CFG_TXR_BASE + 0x200 + \
-					 ((_x) * 0x8))
-#define NFP_NET_CFG_TXR_SZ(_x)          (NFP_NET_CFG_TXR_BASE + 0x400 + (_x))
-#define NFP_NET_CFG_TXR_VEC(_x)         (NFP_NET_CFG_TXR_BASE + 0x440 + (_x))
-#define NFP_NET_CFG_TXR_PRIO(_x)        (NFP_NET_CFG_TXR_BASE + 0x480 + (_x))
-#define NFP_NET_CFG_TXR_IRQ_MOD(_x)     (NFP_NET_CFG_TXR_BASE + 0x500 + \
-					 ((_x) * 0x4))
-
-/*
- * RX ring configuration (0x0800 - 0x0c00)
- * @NFP_NET_CFG_RXR_BASE:    Base offset for RX ring configuration
- * @NFP_NET_CFG_RXR_ADDR:    Per TX ring DMA address (8B entries)
- * @NFP_NET_CFG_RXR_SZ:      Per TX ring size (1B entries)
- * @NFP_NET_CFG_RXR_VEC:     Per TX ring MSI-X table entry (1B entries)
- * @NFP_NET_CFG_RXR_PRIO:    Per TX ring priority (1B entries)
- * @NFP_NET_CFG_RXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
- */
-#define NFP_NET_CFG_RXR_BASE            0x0800
-#define NFP_NET_CFG_RXR_ADDR(_x)        (NFP_NET_CFG_RXR_BASE + ((_x) * 0x8))
-#define NFP_NET_CFG_RXR_SZ(_x)          (NFP_NET_CFG_RXR_BASE + 0x200 + (_x))
-#define NFP_NET_CFG_RXR_VEC(_x)         (NFP_NET_CFG_RXR_BASE + 0x240 + (_x))
-#define NFP_NET_CFG_RXR_PRIO(_x)        (NFP_NET_CFG_RXR_BASE + 0x280 + (_x))
-#define NFP_NET_CFG_RXR_IRQ_MOD(_x)     (NFP_NET_CFG_RXR_BASE + 0x300 + \
-					 ((_x) * 0x4))
-
-/*
- * Interrupt Control/Cause registers (0x0c00 - 0x0d00)
- * These registers are only used when MSI-X auto-masking is not
- * enabled (@NFP_NET_CFG_CTRL_MSIXAUTO not set).  The array is index
- * by MSI-X entry and are 1B in size.  If an entry is zero, the
- * corresponding entry is enabled.  If the FW generates an interrupt,
- * it writes a cause into the corresponding field.  This also masks
- * the MSI-X entry and the host driver must clear the register to
- * re-enable the interrupt.
- */
-#define NFP_NET_CFG_ICR_BASE            0x0c00
-#define NFP_NET_CFG_ICR(_x)             (NFP_NET_CFG_ICR_BASE + (_x))
-#define   NFP_NET_CFG_ICR_UNMASKED      0x0
-#define   NFP_NET_CFG_ICR_RXTX          0x1
-#define   NFP_NET_CFG_ICR_LSC           0x2
-
-/*
- * General device stats (0x0d00 - 0x0d90)
- * All counters are 64bit.
- */
-#define NFP_NET_CFG_STATS_BASE          0x0d00
-#define NFP_NET_CFG_STATS_RX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x00)
-#define NFP_NET_CFG_STATS_RX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x08)
-#define NFP_NET_CFG_STATS_RX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x10)
-#define NFP_NET_CFG_STATS_RX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x18)
-#define NFP_NET_CFG_STATS_RX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x20)
-#define NFP_NET_CFG_STATS_RX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x28)
-#define NFP_NET_CFG_STATS_RX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x30)
-#define NFP_NET_CFG_STATS_RX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x38)
-#define NFP_NET_CFG_STATS_RX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x40)
-
-#define NFP_NET_CFG_STATS_TX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x48)
-#define NFP_NET_CFG_STATS_TX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x50)
-#define NFP_NET_CFG_STATS_TX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x58)
-#define NFP_NET_CFG_STATS_TX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x60)
-#define NFP_NET_CFG_STATS_TX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x68)
-#define NFP_NET_CFG_STATS_TX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x70)
-#define NFP_NET_CFG_STATS_TX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x78)
-#define NFP_NET_CFG_STATS_TX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x80)
-#define NFP_NET_CFG_STATS_TX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x88)
-
-#define NFP_NET_CFG_STATS_APP0_FRAMES   (NFP_NET_CFG_STATS_BASE + 0x90)
-#define NFP_NET_CFG_STATS_APP0_BYTES    (NFP_NET_CFG_STATS_BASE + 0x98)
-#define NFP_NET_CFG_STATS_APP1_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xa0)
-#define NFP_NET_CFG_STATS_APP1_BYTES    (NFP_NET_CFG_STATS_BASE + 0xa8)
-#define NFP_NET_CFG_STATS_APP2_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xb0)
-#define NFP_NET_CFG_STATS_APP2_BYTES    (NFP_NET_CFG_STATS_BASE + 0xb8)
-#define NFP_NET_CFG_STATS_APP3_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xc0)
-#define NFP_NET_CFG_STATS_APP3_BYTES    (NFP_NET_CFG_STATS_BASE + 0xc8)
-
-/*
- * Per ring stats (0x1000 - 0x1800)
- * Options, 64bit per entry
- * @NFP_NET_CFG_TXR_STATS:   TX ring statistics (Packet and Byte count)
- * @NFP_NET_CFG_RXR_STATS:   RX ring statistics (Packet and Byte count)
- */
-#define NFP_NET_CFG_TXR_STATS_BASE      0x1000
-#define NFP_NET_CFG_TXR_STATS(_x)       (NFP_NET_CFG_TXR_STATS_BASE + \
-					 ((_x) * 0x10))
-#define NFP_NET_CFG_RXR_STATS_BASE      0x1400
-#define NFP_NET_CFG_RXR_STATS(_x)       (NFP_NET_CFG_RXR_STATS_BASE + \
-					 ((_x) * 0x10))
+#include <nfp_common_ctrl.h>
 
 /*
  * Mac stats (0x0000 - 0x0200)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 14/25] drivers: add the nfp common module
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (12 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 13/25] drivers: add the common ctrl module Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 15/25] drivers: move queue logic to " Chaoyong He
                     ` (12 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the nfp common module in the nfp 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/common/nfp/meson.build   |   3 +-
 drivers/common/nfp/nfp_common.c  | 177 +++++++++++++++++++++++
 drivers/common/nfp/nfp_common.h  | 232 +++++++++++++++++++++++++++++++
 drivers/common/nfp/version.map   |   6 +
 drivers/net/nfp/nfp_ethdev.c     |   4 +-
 drivers/net/nfp/nfp_ethdev_vf.c  |  16 +--
 drivers/net/nfp/nfp_net_common.c | 159 +--------------------
 drivers/net/nfp/nfp_net_common.h | 206 +--------------------------
 8 files changed, 423 insertions(+), 380 deletions(-)
 create mode 100644 drivers/common/nfp/nfp_common.c
 create mode 100644 drivers/common/nfp/nfp_common.h

diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
index 45871dfe35..727d21e00b 100644
--- a/drivers/common/nfp/meson.build
+++ b/drivers/common/nfp/meson.build
@@ -6,9 +6,10 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
     reason = 'only supported on 64-bit Linux'
 endif
 
-deps += ['bus_pci']
+deps += ['bus_pci', 'net']
 
 sources = files(
+        'nfp_common.c',
         'nfp_common_log.c',
         'nfp_common_pci.c',
 )
diff --git a/drivers/common/nfp/nfp_common.c b/drivers/common/nfp/nfp_common.c
new file mode 100644
index 0000000000..1a98326980
--- /dev/null
+++ b/drivers/common/nfp/nfp_common.c
@@ -0,0 +1,177 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common.h"
+
+#include "nfp_common_log.h"
+
+/*
+ * This is used by the reconfig protocol. It sets the maximum time waiting in
+ * milliseconds before a reconfig timeout happens.
+ */
+#define NFP_NET_POLL_TIMEOUT    5000
+
+int
+nfp_reconfig_real(struct nfp_hw *hw,
+		uint32_t update)
+{
+	uint32_t cnt;
+	uint32_t new;
+	struct timespec wait;
+
+	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
+			hw->qcp_cfg);
+
+	if (hw->qcp_cfg == NULL) {
+		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
+		return -ENXIO;
+	}
+
+	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+
+	wait.tv_sec = 0;
+	wait.tv_nsec = 1000000; /* 1ms */
+
+	PMD_DRV_LOG(DEBUG, "Polling for update ack...");
+
+	/* Poll update field, waiting for NFP to ack the config */
+	for (cnt = 0; ; cnt++) {
+		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
+		if (new == 0)
+			break;
+
+		if ((new & NFP_NET_CFG_UPDATE_ERR) != 0) {
+			PMD_DRV_LOG(ERR, "Reconfig error: %#08x", new);
+			return -1;
+		}
+
+		if (cnt >= NFP_NET_POLL_TIMEOUT) {
+			PMD_DRV_LOG(ERR, "Reconfig timeout for %#08x after %u ms",
+					update, cnt);
+			return -EIO;
+		}
+
+		nanosleep(&wait, 0); /* waiting for a 1ms */
+	}
+
+	PMD_DRV_LOG(DEBUG, "Ack DONE");
+	return 0;
+}
+
+/**
+ * Reconfigure the NIC.
+ *
+ * Write the update word to the BAR and ping the reconfig queue. Then poll
+ * until the firmware has acknowledged the update by zeroing the update word.
+ *
+ * @param hw
+ *   Device to reconfigure.
+ * @param ctrl
+ *   The value for the ctrl field in the BAR config.
+ * @param update
+ *   The value for the update field in the BAR config.
+ *
+ * @return
+ *   - (0) if OK to reconfigure the device.
+ *   - (-EIO) if I/O err and fail to reconfigure the device.
+ */
+int
+nfp_reconfig(struct nfp_hw *hw,
+		uint32_t ctrl,
+		uint32_t update)
+{
+	int ret;
+
+	rte_spinlock_lock(&hw->reconfig_lock);
+
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+
+	rte_wmb();
+
+	ret = nfp_reconfig_real(hw, update);
+
+	rte_spinlock_unlock(&hw->reconfig_lock);
+
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Error nfp reconfig: ctrl=%#08x update=%#08x",
+				ctrl, update);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+/**
+ * Reconfigure the NIC for the extend ctrl BAR.
+ *
+ * Write the update word to the BAR and ping the reconfig queue. Then poll
+ * until the firmware has acknowledged the update by zeroing the update word.
+ *
+ * @param hw
+ *   Device to reconfigure.
+ * @param ctrl_ext
+ *   The value for the first word of extend ctrl field in the BAR config.
+ * @param update
+ *   The value for the update field in the BAR config.
+ *
+ * @return
+ *   - (0) if OK to reconfigure the device.
+ *   - (-EIO) if I/O err and fail to reconfigure the device.
+ */
+int
+nfp_ext_reconfig(struct nfp_hw *hw,
+		uint32_t ctrl_ext,
+		uint32_t update)
+{
+	int ret;
+
+	rte_spinlock_lock(&hw->reconfig_lock);
+
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+
+	rte_wmb();
+
+	ret = nfp_reconfig_real(hw, update);
+
+	rte_spinlock_unlock(&hw->reconfig_lock);
+
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Error nfp ext reconfig: ctrl_ext=%#08x update=%#08x",
+				ctrl_ext, update);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+void
+nfp_read_mac(struct nfp_hw *hw)
+{
+	uint32_t tmp;
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
+}
+
+void
+nfp_write_mac(struct nfp_hw *hw,
+		uint8_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;
+	mac1 = *(uint16_t *)mac;
+	nn_writew(rte_cpu_to_be_16(mac1),
+			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+}
diff --git a/drivers/common/nfp/nfp_common.h b/drivers/common/nfp/nfp_common.h
new file mode 100644
index 0000000000..5615cde6af
--- /dev/null
+++ b/drivers/common/nfp/nfp_common.h
@@ -0,0 +1,232 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_H__
+#define __NFP_COMMON_H__
+
+#include <rte_byteorder.h>
+#include <rte_ether.h>
+#include <rte_io.h>
+#include <rte_spinlock.h>
+
+#include "nfp_common_ctrl.h"
+
+#define NFP_QCP_QUEUE_ADDR_SZ   (0x800)
+
+/* Macros for accessing the Queue Controller Peripheral 'CSRs' */
+#define NFP_QCP_QUEUE_OFF(_x)                 ((_x) * 0x800)
+#define NFP_QCP_QUEUE_ADD_RPTR                  0x0000
+#define NFP_QCP_QUEUE_ADD_WPTR                  0x0004
+#define NFP_QCP_QUEUE_STS_LO                    0x0008
+#define NFP_QCP_QUEUE_STS_LO_READPTR_MASK     (0x3ffff)
+#define NFP_QCP_QUEUE_STS_HI                    0x000c
+#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK    (0x3ffff)
+
+/* Read or Write Pointer of a queue */
+enum nfp_qcp_ptr {
+	NFP_QCP_READ_PTR = 0,
+	NFP_QCP_WRITE_PTR
+};
+
+struct nfp_hw {
+	uint8_t *ctrl_bar;
+	uint8_t *qcp_cfg;
+	uint32_t cap;
+	uint32_t cap_ext;
+	uint32_t ctrl;
+	uint32_t ctrl_ext;
+	rte_spinlock_t reconfig_lock;
+	struct rte_ether_addr mac_addr;
+};
+
+static inline uint8_t
+nn_readb(volatile const void *addr)
+{
+	return rte_read8(addr);
+}
+
+static inline void
+nn_writeb(uint8_t val,
+		volatile void *addr)
+{
+	rte_write8(val, addr);
+}
+
+static inline uint32_t
+nn_readl(volatile const void *addr)
+{
+	return rte_read32(addr);
+}
+
+static inline void
+nn_writel(uint32_t val,
+		volatile void *addr)
+{
+	rte_write32(val, addr);
+}
+
+static inline uint16_t
+nn_readw(volatile const void *addr)
+{
+	return rte_read16(addr);
+}
+
+static inline void
+nn_writew(uint16_t val,
+		volatile void *addr)
+{
+	rte_write16(val, addr);
+}
+
+static inline uint64_t
+nn_readq(volatile void *addr)
+{
+	uint32_t low;
+	uint32_t high;
+	const volatile uint32_t *p = addr;
+
+	high = nn_readl((volatile const void *)(p + 1));
+	low = nn_readl((volatile const void *)p);
+
+	return low + ((uint64_t)high << 32);
+}
+
+static inline void
+nn_writeq(uint64_t val,
+		volatile void *addr)
+{
+	nn_writel(val >> 32, (volatile char *)addr + 4);
+	nn_writel(val, addr);
+}
+
+static inline uint8_t
+nn_cfg_readb(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return nn_readb(hw->ctrl_bar + off);
+}
+
+static inline void
+nn_cfg_writeb(struct nfp_hw *hw,
+		uint32_t off,
+		uint8_t val)
+{
+	nn_writeb(val, hw->ctrl_bar + off);
+}
+
+static inline uint16_t
+nn_cfg_readw(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writew(struct nfp_hw *hw,
+		uint32_t off,
+		uint16_t val)
+{
+	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
+}
+
+static inline uint32_t
+nn_cfg_readl(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writel(struct nfp_hw *hw,
+		uint32_t off,
+		uint32_t val)
+{
+	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
+}
+
+static inline uint64_t
+nn_cfg_readq(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writeq(struct nfp_hw *hw,
+		uint32_t off,
+		uint64_t val)
+{
+	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
+}
+
+/**
+ * Add the value to the selected pointer of a queue.
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Add to the read or write pointer
+ * @param val
+ *   Value to add to the queue pointer
+ */
+static inline void
+nfp_qcp_ptr_add(uint8_t *queue,
+		enum nfp_qcp_ptr ptr,
+		uint32_t val)
+{
+	uint32_t off;
+
+	if (ptr == NFP_QCP_READ_PTR)
+		off = NFP_QCP_QUEUE_ADD_RPTR;
+	else
+		off = NFP_QCP_QUEUE_ADD_WPTR;
+
+	nn_writel(rte_cpu_to_le_32(val), queue + off);
+}
+
+/**
+ * Read the current read/write pointer value for a queue.
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Read or Write pointer
+ */
+static inline uint32_t
+nfp_qcp_read(uint8_t *queue,
+		enum nfp_qcp_ptr ptr)
+{
+	uint32_t off;
+	uint32_t val;
+
+	if (ptr == NFP_QCP_READ_PTR)
+		off = NFP_QCP_QUEUE_STS_LO;
+	else
+		off = NFP_QCP_QUEUE_STS_HI;
+
+	val = rte_cpu_to_le_32(nn_readl(queue + off));
+
+	if (ptr == NFP_QCP_READ_PTR)
+		return val & NFP_QCP_QUEUE_STS_LO_READPTR_MASK;
+	else
+		return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK;
+}
+
+__rte_internal
+int nfp_reconfig_real(struct nfp_hw *hw, uint32_t update);
+
+__rte_internal
+int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
+
+__rte_internal
+int nfp_ext_reconfig(struct nfp_hw *hw, uint32_t ctrl_ext, uint32_t update);
+
+__rte_internal
+void nfp_read_mac(struct nfp_hw *hw);
+
+__rte_internal
+void nfp_write_mac(struct nfp_hw *hw, uint8_t *mac);
+
+#endif/* __NFP_COMMON_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index 25e48c39d6..f6a54a97cd 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -3,5 +3,11 @@ INTERNAL {
 
 	nfp_class_driver_register;
 
+	nfp_reconfig;
+	nfp_ext_reconfig;
+	nfp_reconfig_real;
+	nfp_read_mac;
+	nfp_write_mac;
+
 	local: *;
 };
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 3d4b78fbf1..76317925ec 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -600,13 +600,13 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+	nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 
 	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
 		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 049728d30c..b9cfb48021 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -15,18 +15,6 @@
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
 
-static void
-nfp_netvf_read_mac(struct nfp_hw *hw)
-{
-	uint32_t tmp;
-
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
-	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
-
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
-	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
-}
-
 static int
 nfp_netvf_start(struct rte_eth_dev *dev)
 {
@@ -334,12 +322,12 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(hw);
+	nfp_read_mac(hw);
 	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
 		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 01574de963..711532b466 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -19,12 +19,6 @@
 #define NFP_TX_MAX_SEG       UINT8_MAX
 #define NFP_TX_MAX_MTU_SEG   8
 
-/*
- * This is used by the reconfig protocol. It sets the maximum time waiting in
- * milliseconds before a reconfig timeout happens.
- */
-#define NFP_NET_POLL_TIMEOUT    5000
-
 #define NFP_NET_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
 #define NFP_NET_LINK_UP_CHECK_TIMEOUT   1000 /* ms */
 
@@ -198,141 +192,6 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 /* The length of firmware version string */
 #define FW_VER_LEN        32
 
-static int
-nfp_reconfig_real(struct nfp_hw *hw,
-		uint32_t update)
-{
-	uint32_t cnt;
-	uint32_t new;
-	struct timespec wait;
-
-	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->qcp_cfg);
-
-	if (hw->qcp_cfg == NULL) {
-		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
-		return -ENXIO;
-	}
-
-	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
-
-	wait.tv_sec = 0;
-	wait.tv_nsec = 1000000; /* 1ms */
-
-	PMD_DRV_LOG(DEBUG, "Polling for update ack...");
-
-	/* Poll update field, waiting for NFP to ack the config */
-	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
-		if (new == 0)
-			break;
-
-		if ((new & NFP_NET_CFG_UPDATE_ERR) != 0) {
-			PMD_DRV_LOG(ERR, "Reconfig error: %#08x", new);
-			return -1;
-		}
-
-		if (cnt >= NFP_NET_POLL_TIMEOUT) {
-			PMD_DRV_LOG(ERR, "Reconfig timeout for %#08x after %u ms",
-					update, cnt);
-			return -EIO;
-		}
-
-		nanosleep(&wait, 0); /* Waiting for a 1ms */
-	}
-
-	PMD_DRV_LOG(DEBUG, "Ack DONE");
-	return 0;
-}
-
-/**
- * Reconfigure the NIC.
- *
- * Write the update word to the BAR and ping the reconfig queue. Then poll
- * until the firmware has acknowledged the update by zeroing the update word.
- *
- * @param hw
- *   Device to reconfigure.
- * @param ctrl
- *   The value for the ctrl field in the BAR config.
- * @param update
- *   The value for the update field in the BAR config.
- *
- * @return
- *   - (0) if OK to reconfigure the device.
- *   - (-EIO) if I/O err and fail to reconfigure the device.
- */
-int
-nfp_reconfig(struct nfp_hw *hw,
-		uint32_t ctrl,
-		uint32_t update)
-{
-	int ret;
-
-	rte_spinlock_lock(&hw->reconfig_lock);
-
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
-
-	rte_wmb();
-
-	ret = nfp_reconfig_real(hw, update);
-
-	rte_spinlock_unlock(&hw->reconfig_lock);
-
-	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp reconfig: ctrl=%#08x update=%#08x",
-				ctrl, update);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-/**
- * Reconfigure the NIC for the extend ctrl BAR.
- *
- * Write the update word to the BAR and ping the reconfig queue. Then poll
- * until the firmware has acknowledged the update by zeroing the update word.
- *
- * @param hw
- *   Device to reconfigure.
- * @param ctrl_ext
- *   The value for the first word of extend ctrl field in the BAR config.
- * @param update
- *   The value for the update field in the BAR config.
- *
- * @return
- *   - (0) if OK to reconfigure the device.
- *   - (-EIO) if I/O err and fail to reconfigure the device.
- */
-int
-nfp_ext_reconfig(struct nfp_hw *hw,
-		uint32_t ctrl_ext,
-		uint32_t update)
-{
-	int ret;
-
-	rte_spinlock_lock(&hw->reconfig_lock);
-
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
-
-	rte_wmb();
-
-	ret = nfp_reconfig_real(hw, update);
-
-	rte_spinlock_unlock(&hw->reconfig_lock);
-
-	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp ext reconfig: ctrl_ext=%#08x update=%#08x",
-				ctrl_ext, update);
-		return -EIO;
-	}
-
-	return 0;
-}
-
 /**
  * Reconfigure the firmware via the mailbox
  *
@@ -531,22 +390,6 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 	hw->super.qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }
 
-void
-nfp_net_write_mac(struct nfp_hw *hw,
-		uint8_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;
-	mac1 = *(uint16_t *)mac;
-	nn_writew(rte_cpu_to_be_16(mac1),
-			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
-}
-
 int
 nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 		struct rte_ether_addr *mac_addr)
@@ -565,7 +408,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
+	nfp_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index e997756091..9461440d0b 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -8,21 +8,12 @@
 
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
-#include <rte_io.h>
+#include <nfp_common.h>
 #include <rte_spinlock.h>
 
 #include "nfp_net_ctrl.h"
 #include "nfpcore/nfp_dev.h"
 
-/* Macros for accessing the Queue Controller Peripheral 'CSRs' */
-#define NFP_QCP_QUEUE_OFF(_x)                 ((_x) * 0x800)
-#define NFP_QCP_QUEUE_ADD_RPTR                  0x0000
-#define NFP_QCP_QUEUE_ADD_WPTR                  0x0004
-#define NFP_QCP_QUEUE_STS_LO                    0x0008
-#define NFP_QCP_QUEUE_STS_LO_READPTR_MASK     (0x3ffff)
-#define NFP_QCP_QUEUE_STS_HI                    0x000c
-#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK    (0x3ffff)
-
 /* Interrupt definitions */
 #define NFP_NET_IRQ_LSC_IDX             0
 
@@ -42,8 +33,6 @@
 /* Alignment for dma zones */
 #define NFP_MEMZONE_ALIGN       128
 
-#define NFP_QCP_QUEUE_ADDR_SZ   (0x800)
-
 /* Number of supported physical ports */
 #define NFP_MAX_PHYPORTS        12
 
@@ -53,12 +42,6 @@ enum nfp_app_fw_id {
 	NFP_APP_FW_FLOWER_NIC             = 0x3,
 };
 
-/* Read or Write Pointer of a queue */
-enum nfp_qcp_ptr {
-	NFP_QCP_READ_PTR = 0,
-	NFP_QCP_WRITE_PTR
-};
-
 enum nfp_net_meta_format {
 	NFP_NET_METAFORMAT_SINGLE,
 	NFP_NET_METAFORMAT_CHAINED,
@@ -112,17 +95,6 @@ struct nfp_app_fw_nic {
 	uint8_t total_phyports;
 };
 
-struct nfp_hw {
-	uint8_t *ctrl_bar;
-	uint8_t *qcp_cfg;
-	uint32_t cap;
-	uint32_t cap_ext;
-	uint32_t ctrl;
-	uint32_t ctrl_ext;
-	rte_spinlock_t reconfig_lock;
-	struct rte_ether_addr mac_addr;
-};
-
 struct nfp_net_hw {
 	/** The parent class */
 	struct nfp_hw super;
@@ -184,179 +156,6 @@ struct nfp_net_adapter {
 	struct nfp_net_hw hw;
 };
 
-static inline uint8_t
-nn_readb(volatile const void *addr)
-{
-	return rte_read8(addr);
-}
-
-static inline void
-nn_writeb(uint8_t val,
-		volatile void *addr)
-{
-	rte_write8(val, addr);
-}
-
-static inline uint32_t
-nn_readl(volatile const void *addr)
-{
-	return rte_read32(addr);
-}
-
-static inline void
-nn_writel(uint32_t val,
-		volatile void *addr)
-{
-	rte_write32(val, addr);
-}
-
-static inline uint16_t
-nn_readw(volatile const void *addr)
-{
-	return rte_read16(addr);
-}
-
-static inline void
-nn_writew(uint16_t val,
-		volatile void *addr)
-{
-	rte_write16(val, addr);
-}
-
-static inline uint64_t
-nn_readq(volatile void *addr)
-{
-	uint32_t low;
-	uint32_t high;
-	const volatile uint32_t *p = addr;
-
-	high = nn_readl((volatile const void *)(p + 1));
-	low = nn_readl((volatile const void *)p);
-
-	return low + ((uint64_t)high << 32);
-}
-
-static inline void
-nn_writeq(uint64_t val,
-		volatile void *addr)
-{
-	nn_writel(val >> 32, (volatile char *)addr + 4);
-	nn_writel(val, addr);
-}
-
-static inline uint8_t
-nn_cfg_readb(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return nn_readb(hw->ctrl_bar + off);
-}
-
-static inline void
-nn_cfg_writeb(struct nfp_hw *hw,
-		uint32_t off,
-		uint8_t val)
-{
-	nn_writeb(val, hw->ctrl_bar + off);
-}
-
-static inline uint16_t
-nn_cfg_readw(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writew(struct nfp_hw *hw,
-		uint32_t off,
-		uint16_t val)
-{
-	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
-}
-
-static inline uint32_t
-nn_cfg_readl(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writel(struct nfp_hw *hw,
-		uint32_t off,
-		uint32_t val)
-{
-	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
-}
-
-static inline uint64_t
-nn_cfg_readq(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writeq(struct nfp_hw *hw,
-		uint32_t off,
-		uint64_t val)
-{
-	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
-}
-
-/**
- * Add the value to the selected pointer of a queue.
- *
- * @param queue
- *   Base address for queue structure
- * @param ptr
- *   Add to the read or write pointer
- * @param val
- *   Value to add to the queue pointer
- */
-static inline void
-nfp_qcp_ptr_add(uint8_t *queue,
-		enum nfp_qcp_ptr ptr,
-		uint32_t val)
-{
-	uint32_t off;
-
-	if (ptr == NFP_QCP_READ_PTR)
-		off = NFP_QCP_QUEUE_ADD_RPTR;
-	else
-		off = NFP_QCP_QUEUE_ADD_WPTR;
-
-	nn_writel(rte_cpu_to_le_32(val), queue + off);
-}
-
-/**
- * Read the current read/write pointer value for a queue.
- *
- * @param queue
- *   Base address for queue structure
- * @param ptr
- *   Read or Write pointer
- */
-static inline uint32_t
-nfp_qcp_read(uint8_t *queue,
-		enum nfp_qcp_ptr ptr)
-{
-	uint32_t off;
-	uint32_t val;
-
-	if (ptr == NFP_QCP_READ_PTR)
-		off = NFP_QCP_QUEUE_STS_LO;
-	else
-		off = NFP_QCP_QUEUE_STS_HI;
-
-	val = rte_cpu_to_le_32(nn_readl(queue + off));
-
-	if (ptr == NFP_QCP_READ_PTR)
-		return val & NFP_QCP_QUEUE_STS_LO_READPTR_MASK;
-	else
-		return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK;
-}
-
 static inline uint32_t
 nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 		uint16_t queue)
@@ -366,8 +165,6 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 }
 
 /* Prototypes for common NFP functions */
-int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
-int nfp_ext_reconfig(struct nfp_hw *hw, uint32_t ctrl_ext, uint32_t update);
 int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
 int nfp_net_configure(struct rte_eth_dev *dev);
 int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw);
@@ -375,7 +172,6 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_net_write_mac(struct nfp_hw *hw, uint8_t *mac);
 int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 		struct rte_intr_handle *intr_handle);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 15/25] drivers: move queue logic to common module
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (13 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 14/25] drivers: add the nfp common module Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 16/25] drivers: move platform module to common library Chaoyong He
                     ` (11 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the queue enable/disable logic to the 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/common/nfp/nfp_common.c  | 49 ++++++++++++++++++++++++++++++++
 drivers/common/nfp/nfp_common.h  |  7 +++++
 drivers/common/nfp/version.map   |  2 ++
 drivers/net/nfp/nfp_net_common.c | 38 ++-----------------------
 4 files changed, 61 insertions(+), 35 deletions(-)

diff --git a/drivers/common/nfp/nfp_common.c b/drivers/common/nfp/nfp_common.c
index 1a98326980..4c94c9d59a 100644
--- a/drivers/common/nfp/nfp_common.c
+++ b/drivers/common/nfp/nfp_common.c
@@ -175,3 +175,52 @@ nfp_write_mac(struct nfp_hw *hw,
 	nn_writew(rte_cpu_to_be_16(mac1),
 			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
 }
+
+void
+nfp_enable_queues(struct nfp_hw *hw,
+		uint16_t nb_rx_queues,
+		uint16_t nb_tx_queues)
+{
+	int i;
+	uint64_t enabled_queues;
+
+	/* Enabling the required TX queues in the device */
+	enabled_queues = 0;
+	for (i = 0; i < nb_tx_queues; i++)
+		enabled_queues |= (1 << i);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+
+	/* Enabling the required RX queues in the device */
+	enabled_queues = 0;
+	for (i = 0; i < nb_rx_queues; i++)
+		enabled_queues |= (1 << i);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+}
+
+void
+nfp_disable_queues(struct nfp_hw *hw)
+{
+	int ret;
+	uint32_t update;
+	uint32_t new_ctrl;
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	update = NFP_NET_CFG_UPDATE_GEN |
+			NFP_NET_CFG_UPDATE_RING |
+			NFP_NET_CFG_UPDATE_MSIX;
+
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
+
+	/* If an error when reconfig we avoid to change hw state */
+	ret = nfp_reconfig(hw, new_ctrl, update);
+	if (ret < 0)
+		return;
+
+	hw->ctrl = new_ctrl;
+}
diff --git a/drivers/common/nfp/nfp_common.h b/drivers/common/nfp/nfp_common.h
index 5615cde6af..7597d4090b 100644
--- a/drivers/common/nfp/nfp_common.h
+++ b/drivers/common/nfp/nfp_common.h
@@ -229,4 +229,11 @@ void nfp_read_mac(struct nfp_hw *hw);
 __rte_internal
 void nfp_write_mac(struct nfp_hw *hw, uint8_t *mac);
 
+__rte_internal
+void nfp_enable_queues(struct nfp_hw *hw, uint16_t nb_rx_queues,
+		uint16_t nb_tx_queues);
+
+__rte_internal
+void nfp_disable_queues(struct nfp_hw *hw);
+
 #endif/* __NFP_COMMON_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index f6a54a97cd..c1e03d8b8d 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -8,6 +8,8 @@ INTERNAL {
 	nfp_reconfig_real;
 	nfp_read_mac;
 	nfp_write_mac;
+	nfp_enable_queues;
+	nfp_disable_queues;
 
 	local: *;
 };
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 711532b466..090feb0e39 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -327,54 +327,22 @@ nfp_net_enable_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;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	/* Enabling the required TX queues in the device */
-	enabled_queues = 0;
-	for (i = 0; i < dev->data->nb_tx_queues; i++)
-		enabled_queues |= (1 << i);
-
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
-
-	/* Enabling the required RX queues in the device */
-	enabled_queues = 0;
-	for (i = 0; i < dev->data->nb_rx_queues; i++)
-		enabled_queues |= (1 << i);
-
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nfp_enable_queues(&hw->super, dev->data->nb_rx_queues,
+			dev->data->nb_tx_queues);
 }
 
 void
 nfp_net_disable_queues(struct rte_eth_dev *dev)
 {
-	uint32_t update;
-	uint32_t new_ctrl;
-	struct nfp_hw *hw;
 	struct nfp_net_hw *net_hw;
 
 	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	hw = &net_hw->super;
-
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
-
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
-	update = NFP_NET_CFG_UPDATE_GEN |
-			NFP_NET_CFG_UPDATE_RING |
-			NFP_NET_CFG_UPDATE_MSIX;
-
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
-		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
-	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_reconfig(hw, new_ctrl, update) != 0)
-		return;
-
-	hw->ctrl = new_ctrl;
+	nfp_disable_queues(&net_hw->super);
 }
 
 void
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 16/25] drivers: move platform module to common library
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (14 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 15/25] drivers: move queue logic to " Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 17/25] drivers: move device " Chaoyong He
                     ` (10 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the platform module to the 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/nfpcore => common/nfp}/nfp_platform.h | 0
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c                     | 2 +-
 drivers/net/nfp/nfp_net_ctrl.c                         | 3 +--
 drivers/net/nfp/nfpcore/nfp_cppcore.c                  | 3 ++-
 drivers/net/nfp/nfpcore/nfp_dev.c                      | 3 +--
 drivers/net/nfp/nfpcore/nfp_nsp.c                      | 2 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c                  | 3 ++-
 7 files changed, 8 insertions(+), 8 deletions(-)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_platform.h (100%)

diff --git a/drivers/net/nfp/nfpcore/nfp_platform.h b/drivers/common/nfp/nfp_platform.h
similarity index 100%
rename from drivers/net/nfp/nfpcore/nfp_platform.h
rename to drivers/common/nfp/nfp_platform.h
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 3f8d25aa29..10e6982c95 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -6,10 +6,10 @@
 #include "nfp_nfdk.h"
 
 #include <bus_pci_driver.h>
+#include <nfp_platform.h>
 #include <rte_malloc.h>
 
 #include "../flower/nfp_flower.h"
-#include "../nfpcore/nfp_platform.h"
 #include "../nfp_logs.h"
 
 #define NFDK_TX_DESC_GATHER_MAX         17
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index 8848fa38fe..5135a1ad27 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -6,8 +6,7 @@
 #include "nfp_net_ctrl.h"
 
 #include <ethdev_pci.h>
-
-#include "nfpcore/nfp_platform.h"
+#include <nfp_platform.h>
 
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index f9b08a12b6..0e6045f2f0 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -5,8 +5,9 @@
 
 #include "nfp_cpp.h"
 
+#include <nfp_platform.h>
+
 #include "nfp_logs.h"
-#include "nfp_platform.h"
 #include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
 #include "nfp6000/nfp_xpb.h"
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.c b/drivers/net/nfp/nfpcore/nfp_dev.c
index 7799fa699a..f29b7e0711 100644
--- a/drivers/net/nfp/nfpcore/nfp_dev.c
+++ b/drivers/net/nfp/nfpcore/nfp_dev.c
@@ -5,10 +5,9 @@
 
 #include "nfp_dev.h"
 
+#include <nfp_platform.h>
 #include <rte_bitops.h>
 
-#include "nfp_platform.h"
-
 /*
  * Note: The value of 'max_qc_size' is different from kernel driver,
  * because DPDK use 'uint16_t' as the data type.
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index 5b804f6174..a680b972b8 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -5,10 +5,10 @@
 
 #include "nfp_nsp.h"
 
+#include <nfp_platform.h>
 #include <rte_common.h>
 
 #include "nfp_logs.h"
-#include "nfp_platform.h"
 #include "nfp_resource.h"
 
 /* Offsets relative to the CSR base */
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
index cc472907ca..75f6d40fea 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
@@ -3,9 +3,10 @@
  * All rights reserved.
  */
 
+#include <nfp_platform.h>
+
 #include "nfp_logs.h"
 #include "nfp_nsp.h"
-#include "nfp_platform.h"
 
 #define NSP_ETH_NBI_PORT_COUNT          24
 #define NSP_ETH_MAX_COUNT               (2 * NSP_ETH_NBI_PORT_COUNT)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 17/25] drivers: move device module to common library
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (15 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 16/25] drivers: move platform module to common library Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
                     ` (9 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the device module to the 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/common/nfp/meson.build                    | 1 +
 drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c | 0
 drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h | 3 +++
 drivers/common/nfp/version.map                    | 1 +
 drivers/net/nfp/meson.build                       | 1 -
 drivers/net/nfp/nfp_net_common.h                  | 2 +-
 drivers/net/nfp/nfpcore/nfp6000_pcie.h            | 2 +-
 7 files changed, 7 insertions(+), 3 deletions(-)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c (100%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h (96%)

diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
index 727d21e00b..7f496c2da5 100644
--- a/drivers/common/nfp/meson.build
+++ b/drivers/common/nfp/meson.build
@@ -12,4 +12,5 @@ sources = files(
         'nfp_common.c',
         'nfp_common_log.c',
         'nfp_common_pci.c',
+        'nfp_dev.c',
 )
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.c b/drivers/common/nfp/nfp_dev.c
similarity index 100%
rename from drivers/net/nfp/nfpcore/nfp_dev.c
rename to drivers/common/nfp/nfp_dev.c
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.h b/drivers/common/nfp/nfp_dev.h
similarity index 96%
rename from drivers/net/nfp/nfpcore/nfp_dev.h
rename to drivers/common/nfp/nfp_dev.h
index b0fffff619..ffcdd17227 100644
--- a/drivers/net/nfp/nfpcore/nfp_dev.h
+++ b/drivers/common/nfp/nfp_dev.h
@@ -8,6 +8,8 @@
 
 #include <stdint.h>
 
+#include <rte_compat.h>
+
 #define PCI_VENDOR_ID_NETRONOME         0x19ee
 #define PCI_VENDOR_ID_CORIGINE          0x1da8
 
@@ -39,6 +41,7 @@ struct nfp_dev_info {
 	uint8_t pf_num_per_unit;
 };
 
+__rte_internal
 const struct nfp_dev_info *nfp_dev_info_get(uint16_t device_id);
 
 #endif /* __NFP_DEV_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index c1e03d8b8d..c8a04b1b95 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -10,6 +10,7 @@ INTERNAL {
 	nfp_write_mac;
 	nfp_enable_queues;
 	nfp_disable_queues;
+	nfp_dev_info_get;
 
 	local: *;
 };
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index d54dca36e9..c566c6d2e6 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -16,7 +16,6 @@ sources = files(
         'nfdk/nfp_nfdk_dp.c',
         'nfpcore/nfp_cppcore.c',
         'nfpcore/nfp_crc.c',
-        'nfpcore/nfp_dev.c',
         'nfpcore/nfp_hwinfo.c',
         'nfpcore/nfp_mip.c',
         'nfpcore/nfp_mutex.c',
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 9461440d0b..6607175460 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -9,10 +9,10 @@
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
 #include <nfp_common.h>
+#include <nfp_dev.h>
 #include <rte_spinlock.h>
 
 #include "nfp_net_ctrl.h"
-#include "nfpcore/nfp_dev.h"
 
 /* Interrupt definitions */
 #define NFP_NET_IRQ_LSC_IDX             0
diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.h b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
index 8e2cfb69e6..59b58ddd04 100644
--- a/drivers/net/nfp/nfpcore/nfp6000_pcie.h
+++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
@@ -7,9 +7,9 @@
 #define __NFP6000_PCIE_H__
 
 #include <ethdev_pci.h>
+#include <nfp_dev.h>
 
 #include "nfp_cpp.h"
-#include "nfp_dev.h"
 
 const struct nfp_cpp_operations *nfp_cpp_transport_operations(void);
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 18/25] drivers/vdpa: introduce the NFP vDPA library
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (16 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 17/25] drivers: move device " Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-25 16:09     ` Ferruh Yigit
  2023-10-24  2:28   ` [PATCH v2 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
                     ` (8 subsequent siblings)
  26 siblings, 1 reply; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Introduce the very basic NFP vDPA library.

Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
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/vdpa/meson.build        |  1 +
 drivers/vdpa/nfp/meson.build    | 16 ++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_log.c |  9 +++++++++
 drivers/vdpa/nfp/nfp_vdpa_log.h | 21 +++++++++++++++++++++
 4 files changed, 47 insertions(+)
 create mode 100644 drivers/vdpa/nfp/meson.build
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.h

diff --git a/drivers/vdpa/meson.build b/drivers/vdpa/meson.build
index 77412c7d09..896e8e0304 100644
--- a/drivers/vdpa/meson.build
+++ b/drivers/vdpa/meson.build
@@ -8,6 +8,7 @@ endif
 drivers = [
         'ifc',
         'mlx5',
+        'nfp',
         'sfc',
 ]
 std_deps = ['bus_pci', 'kvargs']
diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
new file mode 100644
index 0000000000..b17866e157
--- /dev/null
+++ b/drivers/vdpa/nfp/meson.build
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64-bit Linux'
+endif
+
+if not dpdk_conf.has('RTE_LIB_VHOST')
+    build = false
+    reason = 'missing dependency, DPDK vhost library'
+endif
+
+sources = files(
+        'nfp_vdpa_log.c',
+)
diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.c b/drivers/vdpa/nfp/nfp_vdpa_log.c
new file mode 100644
index 0000000000..8c957d59ea
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_log.c
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_vdpa_log.h"
+
+RTE_LOG_REGISTER_SUFFIX(nfp_core_logtype, driver, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(nfp_vdpa_logtype, driver, NOTICE);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.h b/drivers/vdpa/nfp/nfp_vdpa_log.h
new file mode 100644
index 0000000000..c3fb274cb5
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_log.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_VDPA_LOG_H__
+#define __NFP_VDPA_LOG_H__
+
+#include <rte_log.h>
+
+extern int nfp_vdpa_logtype;
+#define DRV_VDPA_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_vdpa_logtype, \
+		"NFP_VDPA: %s(): " fmt "\n", __func__, ## args)
+
+extern int nfp_core_logtype;
+#define DRV_CORE_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_core_logtype, \
+		"NFP_CORE: %s(): " fmt "\n", __func__, ## args)
+
+#endif /* __NFP_VDPA_LOG_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 19/25] drivers: add the basic framework of vDPA PMD
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (17 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-25 16:10     ` Ferruh Yigit
  2023-10-24  2:28   ` [PATCH v2 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
                     ` (7 subsequent siblings)
  26 siblings, 1 reply; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the basic framework of vDPA PMD.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_pci.c |   1 +
 drivers/common/nfp/nfp_common_pci.h |   1 +
 drivers/vdpa/nfp/meson.build        |   7 ++
 drivers/vdpa/nfp/nfp_vdpa.c         | 153 ++++++++++++++++++++++++++++
 4 files changed, 162 insertions(+)
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa.c

diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
index 1aa8dd4bbd..c73f4888a9 100644
--- a/drivers/common/nfp/nfp_common_pci.c
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -32,6 +32,7 @@ static const struct {
 	enum nfp_class drv_class;
 } nfp_classes[] = {
 	{ .name = "eth",      .drv_class = NFP_CLASS_ETH },
+	{ .name = "vdpa",     .drv_class = NFP_CLASS_VDPA },
 };
 
 static enum nfp_class
diff --git a/drivers/common/nfp/nfp_common_pci.h b/drivers/common/nfp/nfp_common_pci.h
index 21465fca68..80c027c3a5 100644
--- a/drivers/common/nfp/nfp_common_pci.h
+++ b/drivers/common/nfp/nfp_common_pci.h
@@ -16,6 +16,7 @@ typedef int (nfp_class_driver_remove_t)(struct rte_pci_device *dev);
 
 enum nfp_class {
 	NFP_CLASS_ETH,
+	NFP_CLASS_VDPA,
 	NFP_CLASS_INVALID,
 };
 
diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
index b17866e157..e1cc244578 100644
--- a/drivers/vdpa/nfp/meson.build
+++ b/drivers/vdpa/nfp/meson.build
@@ -12,5 +12,12 @@ if not dpdk_conf.has('RTE_LIB_VHOST')
 endif
 
 sources = files(
+        'nfp_vdpa.c',
         'nfp_vdpa_log.c',
 )
+
+deps += ['common_nfp']
+
+if not dpdk_conf.has('RTE_COMMON_NFP')
+    error('Missing internal dependency "common/nfp"')
+endif
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
new file mode 100644
index 0000000000..ef4ae4946a
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -0,0 +1,153 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include <pthread.h>
+
+#include <nfp_common_pci.h>
+#include <nfp_dev.h>
+#include <vdpa_driver.h>
+
+#include "nfp_vdpa_log.h"
+
+#define NFP_VDPA_DRIVER_NAME nfp_vdpa
+
+struct nfp_vdpa_dev {
+	struct rte_pci_device *pci_dev;
+	struct rte_vdpa_device *vdev;
+};
+
+struct nfp_vdpa_dev_node {
+	TAILQ_ENTRY(nfp_vdpa_dev_node) next;
+	struct nfp_vdpa_dev *device;
+};
+
+TAILQ_HEAD(vdpa_dev_list_head, nfp_vdpa_dev_node);
+
+static struct vdpa_dev_list_head vdpa_dev_list =
+	TAILQ_HEAD_INITIALIZER(vdpa_dev_list);
+
+static pthread_mutex_t vdpa_list_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static struct nfp_vdpa_dev_node *
+nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
+{
+	bool found = false;
+	struct nfp_vdpa_dev_node *node;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+
+	TAILQ_FOREACH(node, &vdpa_dev_list, next) {
+		if (pdev == node->device->pci_dev) {
+			found = true;
+			break;
+		}
+	}
+
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	if (found)
+		return node;
+
+	return NULL;
+}
+
+struct rte_vdpa_dev_ops nfp_vdpa_ops = {
+};
+
+static int
+nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
+{
+	struct nfp_vdpa_dev *device;
+	struct nfp_vdpa_dev_node *node;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	node = calloc(1, sizeof(*node));
+	if (node == NULL)
+		return -ENOMEM;
+
+	device = calloc(1, sizeof(*device));
+	if (device == NULL)
+		goto free_node;
+
+	device->pci_dev = pci_dev;
+
+	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
+	if (device->vdev == NULL) {
+		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
+		goto free_device;
+	}
+
+	node->device = device;
+	pthread_mutex_lock(&vdpa_list_lock);
+	TAILQ_INSERT_TAIL(&vdpa_dev_list, node, next);
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	return 0;
+
+free_device:
+	free(device);
+free_node:
+	free(node);
+
+	return -1;
+}
+
+static int
+nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
+{
+	struct nfp_vdpa_dev *device;
+	struct nfp_vdpa_dev_node *node;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	node = nfp_vdpa_find_node_by_pdev(pci_dev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid device: %s", pci_dev->name);
+		return -ENODEV;
+	}
+
+	device = node->device;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+	TAILQ_REMOVE(&vdpa_dev_list, node, next);
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	rte_vdpa_unregister_device(device->vdev);
+
+	free(device);
+	free(node);
+
+	return 0;
+}
+
+static const struct rte_pci_id pci_id_nfp_vdpa_map[] = {
+	{
+		RTE_PCI_DEVICE(PCI_VENDOR_ID_NETRONOME,
+				PCI_DEVICE_ID_NFP6000_VF_NIC)
+	},
+	{
+		.vendor_id = 0,
+	},
+};
+
+static struct nfp_class_driver nfp_vdpa = {
+	.drv_class = NFP_CLASS_VDPA,
+	.name = RTE_STR(NFP_VDPA_DRIVER_NAME),
+	.id_table = pci_id_nfp_vdpa_map,
+	.drv_flags =  RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+	.probe = nfp_vdpa_pci_probe,
+	.remove = nfp_vdpa_pci_remove,
+};
+
+RTE_INIT(nfp_vdpa_init)
+{
+	nfp_class_driver_register(&nfp_vdpa);
+}
+
+RTE_PMD_REGISTER_PCI_TABLE(NFP_VDPA_DRIVER_NAME, pci_id_nfp_vdpa_map);
+RTE_PMD_REGISTER_KMOD_DEP(NFP_VDPA_DRIVER_NAME, "* vfio-pci");
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 20/25] vdpa/nfp: add the logic of remap PCI memory
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (18 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
                     ` (6 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the logic of remap PCI memory.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c | 65 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index ef4ae4946a..824b0d681a 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -7,6 +7,7 @@
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
+#include <rte_vfio.h>
 #include <vdpa_driver.h>
 
 #include "nfp_vdpa_log.h"
@@ -16,6 +17,11 @@
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
+
+	int vfio_container_fd;
+	int vfio_group_fd;
+	int vfio_dev_fd;
+	int iommu_group;
 };
 
 struct nfp_vdpa_dev_node {
@@ -53,12 +59,62 @@ nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
 	return NULL;
 }
 
+static int
+nfp_vdpa_vfio_setup(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	char dev_name[RTE_DEV_NAME_MAX_LEN] = {0};
+	struct rte_pci_device *pci_dev = device->pci_dev;
+
+	rte_pci_unmap_device(pci_dev);
+
+	rte_pci_device_name(&pci_dev->addr, dev_name, RTE_DEV_NAME_MAX_LEN);
+	rte_vfio_get_group_num(rte_pci_get_sysfs_path(), dev_name,
+			&device->iommu_group);
+
+	device->vfio_container_fd = rte_vfio_container_create();
+	if (device->vfio_container_fd < 0)
+		return -1;
+
+	device->vfio_group_fd = rte_vfio_container_group_bind(
+			device->vfio_container_fd, device->iommu_group);
+	if (device->vfio_group_fd < 0)
+		goto container_destroy;
+
+	DRV_VDPA_LOG(DEBUG, "container_fd=%d, group_fd=%d,\n",
+			device->vfio_container_fd, device->vfio_group_fd);
+
+	ret = rte_pci_map_device(pci_dev);
+	if (ret != 0)
+		goto group_unbind;
+
+	device->vfio_dev_fd = rte_intr_dev_fd_get(pci_dev->intr_handle);
+
+	return 0;
+
+group_unbind:
+	rte_vfio_container_group_unbind(device->vfio_container_fd, device->iommu_group);
+container_destroy:
+	rte_vfio_container_destroy(device->vfio_container_fd);
+
+	return -1;
+}
+
+static void
+nfp_vdpa_vfio_teardown(struct nfp_vdpa_dev *device)
+{
+	rte_pci_unmap_device(device->pci_dev);
+	rte_vfio_container_group_unbind(device->vfio_container_fd, device->iommu_group);
+	rte_vfio_container_destroy(device->vfio_container_fd);
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
 };
 
 static int
 nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 {
+	int ret;
 	struct nfp_vdpa_dev *device;
 	struct nfp_vdpa_dev_node *node;
 
@@ -75,10 +131,14 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 
 	device->pci_dev = pci_dev;
 
+	ret = nfp_vdpa_vfio_setup(device);
+	if (ret != 0)
+		goto free_device;
+
 	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
 	if (device->vdev == NULL) {
 		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
-		goto free_device;
+		goto vfio_teardown;
 	}
 
 	node->device = device;
@@ -88,6 +148,8 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 
 	return 0;
 
+vfio_teardown:
+	nfp_vdpa_vfio_teardown(device);
 free_device:
 	free(device);
 free_node:
@@ -118,6 +180,7 @@ nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
 	pthread_mutex_unlock(&vdpa_list_lock);
 
 	rte_vdpa_unregister_device(device->vdev);
+	nfp_vdpa_vfio_teardown(device);
 
 	free(device);
 	free(node);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 21/25] vdpa/nfp: add the hardware init logic
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (19 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 22/25] drivers: add the datapath update logic Chaoyong He
                     ` (5 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the hardware initialize logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/meson.build     |  1 +
 drivers/vdpa/nfp/nfp_vdpa.c      | 10 ++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c | 54 ++++++++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h | 32 +++++++++++++++++++
 4 files changed, 97 insertions(+)
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.h

diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
index e1cc244578..27eb1a6276 100644
--- a/drivers/vdpa/nfp/meson.build
+++ b/drivers/vdpa/nfp/meson.build
@@ -13,6 +13,7 @@ endif
 
 sources = files(
         'nfp_vdpa.c',
+        'nfp_vdpa_core.c',
         'nfp_vdpa_log.c',
 )
 
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 824b0d681a..00d8f7e007 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -10,6 +10,7 @@
 #include <rte_vfio.h>
 #include <vdpa_driver.h>
 
+#include "nfp_vdpa_core.h"
 #include "nfp_vdpa_log.h"
 
 #define NFP_VDPA_DRIVER_NAME nfp_vdpa
@@ -17,11 +18,14 @@
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_hw hw;
 
 	int vfio_container_fd;
 	int vfio_group_fd;
 	int vfio_dev_fd;
 	int iommu_group;
+
+	uint16_t max_queues;
 };
 
 struct nfp_vdpa_dev_node {
@@ -135,6 +139,12 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 	if (ret != 0)
 		goto free_device;
 
+	ret = nfp_vdpa_hw_init(&device->hw, pci_dev);
+	if (ret != 0)
+		goto vfio_teardown;
+
+	device->max_queues = NFP_VDPA_MAX_QUEUES;
+
 	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
 	if (device->vdev == NULL) {
 		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
new file mode 100644
index 0000000000..a7e15fa88a
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_vdpa_core.h"
+
+#include <rte_vhost.h>
+
+#include "nfp_vdpa_log.h"
+
+/* Available and used descs are in same order */
+#ifndef VIRTIO_F_IN_ORDER
+#define VIRTIO_F_IN_ORDER      35
+#endif
+
+int
+nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
+		struct rte_pci_device *pci_dev)
+{
+	uint32_t queue;
+	struct nfp_hw *hw;
+	uint8_t *notify_base;
+
+	hw = &vdpa_hw->super;
+	hw->ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->ctrl_bar == NULL) {
+		DRV_CORE_LOG(ERR, "hw->ctrl_bar is NULL. BAR0 not configured.");
+		return -ENODEV;
+	}
+
+	notify_base = hw->ctrl_bar + NFP_VDPA_NOTIFY_ADDR_BASE;
+	for (queue = 0; queue < NFP_VDPA_MAX_QUEUES; queue++) {
+		uint32_t idx = queue * 2;
+
+		/* RX */
+		vdpa_hw->notify_addr[idx] = notify_base;
+		notify_base += NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+		/* TX */
+		vdpa_hw->notify_addr[idx + 1] = notify_base;
+		notify_base += NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+
+		vdpa_hw->notify_region = queue;
+		DRV_CORE_LOG(DEBUG, "notify_addr[%d] at %p, notify_addr[%d] at %p",
+				idx, vdpa_hw->notify_addr[idx],
+				idx + 1, vdpa_hw->notify_addr[idx + 1]);
+	}
+
+	vdpa_hw->features = (1ULL << VIRTIO_F_VERSION_1) |
+			(1ULL << VIRTIO_F_IN_ORDER) |
+			(1ULL << VHOST_USER_F_PROTOCOL_FEATURES);
+
+	return 0;
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
new file mode 100644
index 0000000000..c9403e0ea4
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_VDPA_CORE_H__
+#define __NFP_VDPA_CORE_H__
+
+#include <bus_pci_driver.h>
+#include <nfp_common.h>
+#include <rte_ether.h>
+
+#define NFP_VDPA_MAX_QUEUES         1
+
+#define NFP_VDPA_NOTIFY_ADDR_BASE        0x4000
+#define NFP_VDPA_NOTIFY_ADDR_INTERVAL    0x1000
+
+struct nfp_vdpa_hw {
+	struct nfp_hw super;
+
+	uint64_t features;
+	uint64_t req_features;
+
+	uint8_t *notify_addr[NFP_VDPA_MAX_QUEUES * 2];
+
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+	uint8_t notify_region;
+};
+
+int nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, struct rte_pci_device *dev);
+
+#endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 22/25] drivers: add the datapath update logic
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (20 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 23/25] vdpa/nfp: add the notify related logic Chaoyong He
                     ` (4 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the vDPA datapath update logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h |   1 +
 drivers/vdpa/nfp/nfp_vdpa.c          | 315 +++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c     |  78 +++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h     |  15 ++
 4 files changed, 409 insertions(+)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 3c8cd916cf..f92ce50fc0 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -238,6 +238,7 @@ struct nfp_net_fw_ver {
 #define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
 #define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
 #define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
+#define NFP_NET_CFG_CTRL_IN_ORDER         (0x1 << 11) /**< Virtio in-order flag */
 
 #define NFP_NET_CFG_CAP_WORD1           0x00a4
 
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 00d8f7e007..465ee4841d 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -4,6 +4,7 @@
  */
 
 #include <pthread.h>
+#include <sys/ioctl.h>
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
@@ -15,6 +16,9 @@
 
 #define NFP_VDPA_DRIVER_NAME nfp_vdpa
 
+#define MSIX_IRQ_SET_BUF_LEN (sizeof(struct vfio_irq_set) + \
+		sizeof(int) * (NFP_VDPA_MAX_QUEUES * 2 + 1))
+
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
@@ -25,7 +29,15 @@ struct nfp_vdpa_dev {
 	int vfio_dev_fd;
 	int iommu_group;
 
+	int vid;
 	uint16_t max_queues;
+	uint32_t started;
+	uint32_t dev_attached;
+	uint32_t running;
+	rte_spinlock_t lock;
+
+	/** Eventfd for used ring interrupt */
+	int intr_fd[NFP_VDPA_MAX_QUEUES * 2];
 };
 
 struct nfp_vdpa_dev_node {
@@ -112,6 +124,302 @@ nfp_vdpa_vfio_teardown(struct nfp_vdpa_dev *device)
 	rte_vfio_container_destroy(device->vfio_container_fd);
 }
 
+static int
+nfp_vdpa_dma_do_unmap(struct rte_vhost_memory *mem,
+		uint32_t times,
+		int vfio_container_fd)
+{
+	uint32_t i;
+	int ret = 0;
+	struct rte_vhost_mem_region *region;
+
+	for (i = 0; i < times; i++) {
+		region = &mem->regions[i];
+
+		ret = rte_vfio_container_dma_unmap(vfio_container_fd,
+				region->host_user_addr, region->guest_phys_addr,
+				region->size);
+		if (ret < 0) {
+			/* Here should not return, even error happened. */
+			DRV_VDPA_LOG(ERR, "DMA unmap failed. Times: %u", i);
+		}
+	}
+
+	return ret;
+}
+
+static int
+nfp_vdpa_dma_do_map(struct rte_vhost_memory *mem,
+		uint32_t times,
+		int vfio_container_fd)
+{
+	int ret;
+	uint32_t i;
+	struct rte_vhost_mem_region *region;
+
+	for (i = 0; i < times; i++) {
+		region = &mem->regions[i];
+
+		ret = rte_vfio_container_dma_map(vfio_container_fd,
+				region->host_user_addr, region->guest_phys_addr,
+				region->size);
+		if (ret < 0) {
+			DRV_VDPA_LOG(ERR, "DMA map failed.");
+			nfp_vdpa_dma_do_unmap(mem, i, vfio_container_fd);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_dma_map(struct nfp_vdpa_dev *device,
+		bool do_map)
+{
+	int ret;
+	int vfio_container_fd;
+	struct rte_vhost_memory *mem = NULL;
+
+	ret = rte_vhost_get_mem_table(device->vid, &mem);
+	if (ret < 0) {
+		DRV_VDPA_LOG(ERR, "Failed to get memory layout.");
+		return ret;
+	}
+
+	vfio_container_fd = device->vfio_container_fd;
+	DRV_VDPA_LOG(DEBUG, "vfio_container_fd %d", vfio_container_fd);
+
+	if (do_map)
+		ret = nfp_vdpa_dma_do_map(mem, mem->nregions, vfio_container_fd);
+	else
+		ret = nfp_vdpa_dma_do_unmap(mem, mem->nregions, vfio_container_fd);
+
+	free(mem);
+
+	return ret;
+}
+
+static uint64_t
+nfp_vdpa_qva_to_gpa(int vid,
+		uint64_t qva)
+{
+	int ret;
+	uint32_t i;
+	uint64_t gpa = 0;
+	struct rte_vhost_memory *mem = NULL;
+	struct rte_vhost_mem_region *region;
+
+	ret = rte_vhost_get_mem_table(vid, &mem);
+	if (ret < 0) {
+		DRV_VDPA_LOG(ERR, "Failed to get memory layout.");
+		return gpa;
+	}
+
+	for (i = 0; i < mem->nregions; i++) {
+		region = &mem->regions[i];
+
+		if (qva >= region->host_user_addr &&
+				qva < region->host_user_addr + region->size) {
+			gpa = qva - region->host_user_addr + region->guest_phys_addr;
+			break;
+		}
+	}
+
+	free(mem);
+
+	return gpa;
+}
+
+static int
+nfp_vdpa_start(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	int vid;
+	uint16_t i;
+	uint64_t gpa;
+	struct rte_vhost_vring vring;
+	struct nfp_vdpa_hw *vdpa_hw = &device->hw;
+
+	vid = device->vid;
+	vdpa_hw->nr_vring = rte_vhost_get_vring_num(vid);
+
+	ret = rte_vhost_get_negotiated_features(vid, &vdpa_hw->req_features);
+	if (ret != 0)
+		return ret;
+
+	for (i = 0; i < vdpa_hw->nr_vring; i++) {
+		ret = rte_vhost_get_vhost_vring(vid, i, &vring);
+		if (ret != 0)
+			return ret;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.desc);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for descriptor ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].desc = gpa;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.avail);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for available ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].avail = gpa;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.used);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for used ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].used = gpa;
+
+		vdpa_hw->vring[i].size = vring.size;
+
+		ret = rte_vhost_get_vring_base(vid, i,
+				&vdpa_hw->vring[i].last_avail_idx,
+				&vdpa_hw->vring[i].last_used_idx);
+		if (ret != 0)
+			return ret;
+	}
+
+	return nfp_vdpa_hw_start(&device->hw, vid);
+}
+
+static void
+nfp_vdpa_stop(struct nfp_vdpa_dev *device)
+{
+	int vid;
+	uint32_t i;
+	struct nfp_vdpa_hw *vdpa_hw = &device->hw;
+
+	nfp_vdpa_hw_stop(vdpa_hw);
+
+	vid = device->vid;
+	for (i = 0; i < vdpa_hw->nr_vring; i++)
+		rte_vhost_set_vring_base(vid, i,
+				vdpa_hw->vring[i].last_avail_idx,
+				vdpa_hw->vring[i].last_used_idx);
+}
+
+static int
+nfp_vdpa_enable_vfio_intr(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	uint16_t i;
+	int *fd_ptr;
+	uint16_t nr_vring;
+	struct vfio_irq_set *irq_set;
+	struct rte_vhost_vring vring;
+	char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
+
+	nr_vring = rte_vhost_get_vring_num(device->vid);
+
+	irq_set = (struct vfio_irq_set *)irq_set_buf;
+	irq_set->argsz = sizeof(irq_set_buf);
+	irq_set->count = nr_vring + 1;
+	irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;
+	irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
+	irq_set->start = 0;
+
+	fd_ptr = (int *)&irq_set->data;
+	fd_ptr[RTE_INTR_VEC_ZERO_OFFSET] = rte_intr_fd_get(device->pci_dev->intr_handle);
+
+	for (i = 0; i < nr_vring; i++)
+		device->intr_fd[i] = -1;
+
+	for (i = 0; i < nr_vring; i++) {
+		rte_vhost_get_vhost_vring(device->vid, i, &vring);
+		fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = vring.callfd;
+	}
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Error enabling MSI-X interrupts.");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_disable_vfio_intr(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	struct vfio_irq_set *irq_set;
+	char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
+
+	irq_set = (struct vfio_irq_set *)irq_set_buf;
+	irq_set->argsz = sizeof(irq_set_buf);
+	irq_set->count = 0;
+	irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER;
+	irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
+	irq_set->start = 0;
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Error disabling MSI-X interrupts.");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int
+update_datapath(struct nfp_vdpa_dev *device)
+{
+	int ret;
+
+	rte_spinlock_lock(&device->lock);
+
+	if ((__atomic_load_n(&device->running, __ATOMIC_RELAXED) == 0) &&
+			(__atomic_load_n(&device->started, __ATOMIC_RELAXED) != 0) &&
+			(__atomic_load_n(&device->dev_attached, __ATOMIC_RELAXED) != 0)) {
+		ret = nfp_vdpa_dma_map(device, true);
+		if (ret != 0)
+			goto unlock_exit;
+
+		ret = nfp_vdpa_enable_vfio_intr(device);
+		if (ret != 0)
+			goto dma_map_rollback;
+
+		ret = nfp_vdpa_start(device);
+		if (ret != 0)
+			goto disable_vfio_intr;
+
+		__atomic_store_n(&device->running, 1, __ATOMIC_RELAXED);
+	} else if ((__atomic_load_n(&device->running, __ATOMIC_RELAXED) != 0) &&
+			((__atomic_load_n(&device->started, __ATOMIC_RELAXED) != 0) ||
+			(__atomic_load_n(&device->dev_attached, __ATOMIC_RELAXED) != 0))) {
+
+		nfp_vdpa_stop(device);
+
+		ret = nfp_vdpa_disable_vfio_intr(device);
+		if (ret != 0)
+			goto unlock_exit;
+
+		ret = nfp_vdpa_dma_map(device, false);
+		if (ret != 0)
+			goto unlock_exit;
+
+		__atomic_store_n(&device->running, 0, __ATOMIC_RELAXED);
+	}
+
+	rte_spinlock_unlock(&device->lock);
+	return 0;
+
+disable_vfio_intr:
+	nfp_vdpa_disable_vfio_intr(device);
+dma_map_rollback:
+	nfp_vdpa_dma_map(device, false);
+unlock_exit:
+	rte_spinlock_unlock(&device->lock);
+	return ret;
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
 };
 
@@ -156,6 +464,10 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 	TAILQ_INSERT_TAIL(&vdpa_dev_list, node, next);
 	pthread_mutex_unlock(&vdpa_list_lock);
 
+	rte_spinlock_init(&device->lock);
+	__atomic_store_n(&device->started, 1, __ATOMIC_RELAXED);
+	update_datapath(device);
+
 	return 0;
 
 vfio_teardown:
@@ -185,6 +497,9 @@ nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
 
 	device = node->device;
 
+	__atomic_store_n(&device->started, 0, __ATOMIC_RELAXED);
+	update_datapath(device);
+
 	pthread_mutex_lock(&vdpa_list_lock);
 	TAILQ_REMOVE(&vdpa_dev_list, node, next);
 	pthread_mutex_unlock(&vdpa_list_lock);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
index a7e15fa88a..db9b8462b4 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.c
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -5,6 +5,7 @@
 
 #include "nfp_vdpa_core.h"
 
+#include <nfp_common.h>
 #include <rte_vhost.h>
 
 #include "nfp_vdpa_log.h"
@@ -52,3 +53,80 @@ nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
 
 	return 0;
 }
+
+static uint32_t
+nfp_vdpa_check_offloads(void)
+{
+	return NFP_NET_CFG_CTRL_SCATTER |
+			NFP_NET_CFG_CTRL_IN_ORDER;
+}
+
+int
+nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw,
+		int vid)
+{
+	int ret;
+	uint32_t update;
+	uint32_t new_ctrl;
+	struct timespec wait_tst;
+	struct nfp_hw *hw = &vdpa_hw->super;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(0), vdpa_hw->vring[1].desc);
+	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(0), rte_log2_u32(vdpa_hw->vring[1].size));
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(1), vdpa_hw->vring[1].avail);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(2), vdpa_hw->vring[1].used);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(0), vdpa_hw->vring[0].desc);
+	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(0), rte_log2_u32(vdpa_hw->vring[0].size));
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(1), vdpa_hw->vring[0].avail);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(2), vdpa_hw->vring[0].used);
+
+	rte_wmb();
+
+	nfp_disable_queues(hw);
+	nfp_enable_queues(hw, NFP_VDPA_MAX_QUEUES, NFP_VDPA_MAX_QUEUES);
+
+	new_ctrl = nfp_vdpa_check_offloads();
+
+	nn_cfg_writel(hw, NFP_NET_CFG_MTU, 9216);
+	nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, 10240);
+
+	/* TODO: Temporary set MAC to fixed value fe:1b:ac:05:a5:22 */
+	mac_addr[0] = 0xfe;
+	mac_addr[1] = 0x1b;
+	mac_addr[2] = 0xac;
+	mac_addr[3] = 0x05;
+	mac_addr[4] = 0xa5;
+	mac_addr[5] = (0x22 + vid);
+
+	/* Writing new MAC to the specific port BAR address */
+	nfp_write_mac(hw, (uint8_t *)mac_addr);
+
+	/* Enable device */
+	new_ctrl |= NFP_NET_CFG_CTRL_ENABLE;
+
+	/* Signal the NIC about the change */
+	update = NFP_NET_CFG_UPDATE_MACADDR |
+			NFP_NET_CFG_UPDATE_GEN |
+			NFP_NET_CFG_UPDATE_RING;
+
+	ret = nfp_reconfig(hw, new_ctrl, update);
+	if (ret < 0)
+		return -EIO;
+
+	hw->ctrl = new_ctrl;
+
+	DRV_CORE_LOG(DEBUG, "Enabling the device, sleep 1 seconds...");
+	wait_tst.tv_sec = 1;
+	wait_tst.tv_nsec = 0;
+	nanosleep(&wait_tst, 0);
+
+	return 0;
+}
+
+void
+nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw)
+{
+	nfp_disable_queues(&vdpa_hw->super);
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
index c9403e0ea4..a88de768dd 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.h
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -15,6 +15,15 @@
 #define NFP_VDPA_NOTIFY_ADDR_BASE        0x4000
 #define NFP_VDPA_NOTIFY_ADDR_INTERVAL    0x1000
 
+struct nfp_vdpa_vring {
+	uint64_t desc;
+	uint64_t avail;
+	uint64_t used;
+	uint16_t size;
+	uint16_t last_avail_idx;
+	uint16_t last_used_idx;
+};
+
 struct nfp_vdpa_hw {
 	struct nfp_hw super;
 
@@ -22,11 +31,17 @@ struct nfp_vdpa_hw {
 	uint64_t req_features;
 
 	uint8_t *notify_addr[NFP_VDPA_MAX_QUEUES * 2];
+	struct nfp_vdpa_vring vring[NFP_VDPA_MAX_QUEUES * 2];
 
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t notify_region;
+	uint8_t nr_vring;
 };
 
 int nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, struct rte_pci_device *dev);
 
+int nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw, int vid);
+
+void nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw);
+
 #endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 23/25] vdpa/nfp: add the notify related logic
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (21 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 22/25] drivers: add the datapath update logic Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
                     ` (3 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the logic to process vDPA notify relay.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c      | 155 +++++++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c |  61 ++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h |   4 +
 3 files changed, 220 insertions(+)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 465ee4841d..01a59e2cfd 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -4,7 +4,9 @@
  */
 
 #include <pthread.h>
+#include <sys/epoll.h>
 #include <sys/ioctl.h>
+#include <unistd.h>
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
@@ -29,6 +31,9 @@ struct nfp_vdpa_dev {
 	int vfio_dev_fd;
 	int iommu_group;
 
+	pthread_t tid;    /**< Thread for notify relay */
+	int epoll_fd;
+
 	int vid;
 	uint16_t max_queues;
 	uint32_t started;
@@ -368,6 +373,148 @@ nfp_vdpa_disable_vfio_intr(struct nfp_vdpa_dev *device)
 	return 0;
 }
 
+static void
+nfp_vdpa_read_kickfd(int kickfd)
+{
+	int bytes;
+	uint64_t buf;
+
+	for (;;) {
+		bytes = read(kickfd, &buf, 8);
+		if (bytes >= 0)
+			break;
+
+		if (errno != EINTR && errno != EWOULDBLOCK &&
+				errno != EAGAIN) {
+			DRV_VDPA_LOG(ERR, "Error reading kickfd");
+			break;
+		}
+	}
+}
+
+static int
+nfp_vdpa_notify_epoll_ctl(uint32_t queue_num,
+		struct nfp_vdpa_dev *device)
+{
+	int ret;
+	uint32_t qid;
+
+	for (qid = 0; qid < queue_num; qid++) {
+		struct epoll_event ev;
+		struct rte_vhost_vring vring;
+
+		ev.events = EPOLLIN | EPOLLPRI;
+		rte_vhost_get_vhost_vring(device->vid, qid, &vring);
+		ev.data.u64 = qid | (uint64_t)vring.kickfd << 32;
+		ret = epoll_ctl(device->epoll_fd, EPOLL_CTL_ADD, vring.kickfd, &ev);
+		if (ret < 0) {
+			DRV_VDPA_LOG(ERR, "Epoll add error for queue %d", qid);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_notify_epoll_wait(uint32_t queue_num,
+		struct nfp_vdpa_dev *device)
+{
+	int i;
+	int fds;
+	int kickfd;
+	uint32_t qid;
+	struct epoll_event events[NFP_VDPA_MAX_QUEUES * 2];
+
+	for (;;) {
+		fds = epoll_wait(device->epoll_fd, events, queue_num, -1);
+		if (fds < 0) {
+			if (errno == EINTR)
+				continue;
+
+			DRV_VDPA_LOG(ERR, "Epoll wait fail");
+			return -EACCES;
+		}
+
+		for (i = 0; i < fds; i++) {
+			qid = events[i].data.u32;
+			kickfd = (uint32_t)(events[i].data.u64 >> 32);
+
+			nfp_vdpa_read_kickfd(kickfd);
+			nfp_vdpa_notify_queue(&device->hw, qid);
+		}
+	}
+
+	return 0;
+}
+
+static void *
+nfp_vdpa_notify_relay(void *arg)
+{
+	int ret;
+	int epoll_fd;
+	uint32_t queue_num;
+	struct nfp_vdpa_dev *device = arg;
+
+	epoll_fd = epoll_create(NFP_VDPA_MAX_QUEUES * 2);
+	if (epoll_fd < 0) {
+		DRV_VDPA_LOG(ERR, "failed to create epoll instance.");
+		return NULL;
+	}
+
+	device->epoll_fd = epoll_fd;
+
+	queue_num = rte_vhost_get_vring_num(device->vid);
+
+	ret = nfp_vdpa_notify_epoll_ctl(queue_num, device);
+	if (ret != 0)
+		goto notify_exit;
+
+	ret = nfp_vdpa_notify_epoll_wait(queue_num, device);
+	if (ret != 0)
+		goto notify_exit;
+
+	return 0;
+
+notify_exit:
+	close(device->epoll_fd);
+	device->epoll_fd = -1;
+
+	return NULL;
+}
+
+static int
+nfp_vdpa_setup_notify_relay(struct nfp_vdpa_dev *device)
+{
+	int ret;
+
+	ret = pthread_create(&device->tid, NULL, nfp_vdpa_notify_relay,
+			(void *)device);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Failed to create notify relay pthread.");
+		return -1;
+	}
+
+	return 0;
+}
+
+static void
+nfp_vdpa_unset_notify_relay(struct nfp_vdpa_dev *device)
+{
+	void *status;
+
+	if (device->tid != 0) {
+		pthread_cancel(device->tid);
+		pthread_join(device->tid, &status);
+		device->tid = 0;
+	}
+
+	if (device->epoll_fd >= 0) {
+		close(device->epoll_fd);
+		device->epoll_fd = -1;
+	}
+}
+
 static int
 update_datapath(struct nfp_vdpa_dev *device)
 {
@@ -390,11 +537,17 @@ update_datapath(struct nfp_vdpa_dev *device)
 		if (ret != 0)
 			goto disable_vfio_intr;
 
+		ret = nfp_vdpa_setup_notify_relay(device);
+		if (ret != 0)
+			goto vdpa_stop;
+
 		__atomic_store_n(&device->running, 1, __ATOMIC_RELAXED);
 	} else if ((__atomic_load_n(&device->running, __ATOMIC_RELAXED) != 0) &&
 			((__atomic_load_n(&device->started, __ATOMIC_RELAXED) != 0) ||
 			(__atomic_load_n(&device->dev_attached, __ATOMIC_RELAXED) != 0))) {
 
+		nfp_vdpa_unset_notify_relay(device);
+
 		nfp_vdpa_stop(device);
 
 		ret = nfp_vdpa_disable_vfio_intr(device);
@@ -411,6 +564,8 @@ update_datapath(struct nfp_vdpa_dev *device)
 	rte_spinlock_unlock(&device->lock);
 	return 0;
 
+vdpa_stop:
+	nfp_vdpa_stop(device);
 disable_vfio_intr:
 	nfp_vdpa_disable_vfio_intr(device);
 dma_map_rollback:
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
index db9b8462b4..e2a6253ae5 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.c
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -15,6 +15,41 @@
 #define VIRTIO_F_IN_ORDER      35
 #endif
 
+#define NFP_QCP_NOTIFY_MAX_ADD    0x7f
+
+enum nfp_qcp_notify_ptr {
+	NFP_QCP_NOTIFY_WRITE_PTR = 0,
+	NFP_QCP_NOTIFY_READ_PTR
+};
+
+/**
+ * Add the value to the selected pointer of a queue
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Add to the Read or Write pointer
+ * @param val
+ *   Value to add to the queue pointer
+ */
+static inline void
+nfp_qcp_notify_ptr_add(uint8_t *q,
+		enum nfp_qcp_notify_ptr ptr,
+		uint32_t val)
+{
+	uint32_t off;
+
+	if (ptr == NFP_QCP_NOTIFY_WRITE_PTR)
+		off = NFP_QCP_QUEUE_ADD_RPTR;
+	else
+		off = NFP_QCP_QUEUE_ADD_WPTR;
+
+	for (; val > NFP_QCP_NOTIFY_MAX_ADD; val -= NFP_QCP_NOTIFY_MAX_ADD)
+		nn_writel(rte_cpu_to_le_32(NFP_QCP_NOTIFY_MAX_ADD), q + off);
+
+	nn_writel(rte_cpu_to_le_32(val), q + off);
+}
+
 int
 nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
 		struct rte_pci_device *pci_dev)
@@ -130,3 +165,29 @@ nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw)
 {
 	nfp_disable_queues(&vdpa_hw->super);
 }
+
+/*
+ * This offset is used for mmaping the notify area. It implies it needs
+ * to be a multiple of PAGE_SIZE.
+ * For debugging, using notify region 0 with an offset of 4K. This should
+ * point to the conf bar.
+ */
+uint64_t
+nfp_vdpa_get_queue_notify_offset(struct nfp_vdpa_hw *vdpa_hw __rte_unused,
+		int qid)
+{
+	return NFP_VDPA_NOTIFY_ADDR_BASE + (qid * NFP_VDPA_NOTIFY_ADDR_INTERVAL);
+}
+
+/*
+ * With just one queue the increment is 0, which does not
+ * incremente the counter but will raise a queue event due
+ * to queue configured for watermark events.
+ */
+void
+nfp_vdpa_notify_queue(struct nfp_vdpa_hw *vdpa_hw,
+		uint16_t qid)
+{
+	nfp_qcp_notify_ptr_add(vdpa_hw->notify_addr[qid],
+			NFP_QCP_NOTIFY_WRITE_PTR, qid);
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
index a88de768dd..a8e0d6dd70 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.h
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -44,4 +44,8 @@ int nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw, int vid);
 
 void nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw);
 
+void nfp_vdpa_notify_queue(struct nfp_vdpa_hw *vdpa_hw, uint16_t qid);
+
+uint64_t nfp_vdpa_get_queue_notify_offset(struct nfp_vdpa_hw *vdpa_hw, int qid);
+
 #endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 24/25] vdpa/nfp: add nfp vDPA device operations
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (22 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 23/25] vdpa/nfp: add the notify related logic Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-24  2:28   ` [PATCH v2 25/25] doc: add the common and vDPA document Chaoyong He
                     ` (2 subsequent siblings)
  26 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Implement the corresponding nfp vDPA opetation functions.

Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
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/vdpa/nfp/nfp_vdpa.c | 213 ++++++++++++++++++++++++++++++++++++
 1 file changed, 213 insertions(+)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 01a59e2cfd..860b5cce63 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -57,6 +57,29 @@ static struct vdpa_dev_list_head vdpa_dev_list =
 
 static pthread_mutex_t vdpa_list_lock = PTHREAD_MUTEX_INITIALIZER;
 
+static struct nfp_vdpa_dev_node *
+nfp_vdpa_find_node_by_vdev(struct rte_vdpa_device *vdev)
+{
+	bool found = false;
+	struct nfp_vdpa_dev_node *node;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+
+	TAILQ_FOREACH(node, &vdpa_dev_list, next) {
+		if (vdev == node->device->vdev) {
+			found = true;
+			break;
+		}
+	}
+
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	if (found)
+		return node;
+
+	return NULL;
+}
+
 static struct nfp_vdpa_dev_node *
 nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
 {
@@ -575,7 +598,197 @@ update_datapath(struct nfp_vdpa_dev *device)
 	return ret;
 }
 
+static int
+nfp_vdpa_dev_config(int vid)
+{
+	int ret;
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	device->vid = vid;
+	__atomic_store_n(&device->dev_attached, 1, __ATOMIC_RELAXED);
+	update_datapath(device);
+
+	ret = rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true);
+	if (ret != 0)
+		DRV_VDPA_LOG(INFO, "vDPA (%s): software relay is used.",
+				vdev->device->name);
+
+	return 0;
+}
+
+static int
+nfp_vdpa_dev_close(int vid)
+{
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	__atomic_store_n(&device->dev_attached, 0, __ATOMIC_RELAXED);
+	update_datapath(device);
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_vfio_group_fd(int vid)
+{
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	return node->device->vfio_group_fd;
+}
+
+static int
+nfp_vdpa_get_vfio_device_fd(int vid)
+{
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	return node->device->vfio_dev_fd;
+}
+
+static int
+nfp_vdpa_get_notify_area(int vid,
+		int qid,
+		uint64_t *offset,
+		uint64_t *size)
+{
+	int ret;
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+	struct vfio_region_info region = {
+		.argsz = sizeof(region)
+	};
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR,  "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	region.index = device->hw.notify_region;
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, &region);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Get not get device region info.");
+		return -EIO;
+	}
+
+	*offset = nfp_vdpa_get_queue_notify_offset(&device->hw, qid) + region.offset;
+	*size = NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_queue_num(struct rte_vdpa_device *vdev,
+		uint32_t *queue_num)
+{
+	struct nfp_vdpa_dev_node *node;
+
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	*queue_num = node->device->max_queues;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_vdpa_features(struct rte_vdpa_device *vdev,
+		uint64_t *features)
+{
+	struct nfp_vdpa_dev_node *node;
+
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR,  "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	*features = node->device->hw.features;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_protocol_features(struct rte_vdpa_device *vdev __rte_unused,
+		uint64_t *features)
+{
+	*features = 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD |
+			1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK |
+			1ULL << VHOST_USER_PROTOCOL_F_BACKEND_REQ |
+			1ULL << VHOST_USER_PROTOCOL_F_BACKEND_SEND_FD |
+			1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_set_features(int32_t vid)
+{
+	DRV_VDPA_LOG(DEBUG, "Start vid=%d", vid);
+	return 0;
+}
+
+static int
+nfp_vdpa_set_vring_state(int vid,
+		int vring,
+		int state)
+{
+	DRV_VDPA_LOG(DEBUG, "Start vid=%d, vring=%d, state=%d", vid, vring, state);
+	return 0;
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
+	.get_queue_num = nfp_vdpa_get_queue_num,
+	.get_features = nfp_vdpa_get_vdpa_features,
+	.get_protocol_features = nfp_vdpa_get_protocol_features,
+	.dev_conf = nfp_vdpa_dev_config,
+	.dev_close = nfp_vdpa_dev_close,
+	.set_vring_state = nfp_vdpa_set_vring_state,
+	.set_features = nfp_vdpa_set_features,
+	.get_vfio_group_fd = nfp_vdpa_get_vfio_group_fd,
+	.get_vfio_device_fd = nfp_vdpa_get_vfio_device_fd,
+	.get_notify_area = nfp_vdpa_get_notify_area,
 };
 
 static int
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v2 25/25] doc: add the common and vDPA document
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (23 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
@ 2023-10-24  2:28   ` Chaoyong He
  2023-10-25 16:11     ` Ferruh Yigit
  2023-10-25 16:09   ` [PATCH v2 00/25] add the NFP vDPA PMD Ferruh Yigit
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
  26 siblings, 1 reply; 121+ messages in thread
From: Chaoyong He @ 2023-10-24  2:28 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the document for nfp common library and vDPA PMD.

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>
---
 MAINTAINERS                            |  8 ++++
 doc/guides/platform/index.rst          |  1 +
 doc/guides/platform/nfp.rst            | 30 ++++++++++++++
 doc/guides/rel_notes/release_23_11.rst |  5 +++
 doc/guides/vdpadevs/features/nfp.ini   |  8 ++++
 doc/guides/vdpadevs/index.rst          |  1 +
 doc/guides/vdpadevs/nfp.rst            | 54 ++++++++++++++++++++++++++
 7 files changed, 107 insertions(+)
 create mode 100644 doc/guides/platform/nfp.rst
 create mode 100644 doc/guides/vdpadevs/features/nfp.ini
 create mode 100644 doc/guides/vdpadevs/nfp.rst

diff --git a/MAINTAINERS b/MAINTAINERS
index 4083658697..b28cdab54c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -900,9 +900,11 @@ F: doc/guides/nics/features/nfb.ini
 
 Netronome nfp
 M: Chaoyong He <chaoyong.he@corigine.com>
+F: drivers/common/nfp/
 F: drivers/net/nfp/
 F: doc/guides/nics/nfp.rst
 F: doc/guides/nics/features/nfp*.ini
+F: doc/guides/platform/nfp.rst
 
 NXP dpaa
 M: Hemant Agrawal <hemant.agrawal@nxp.com>
@@ -1306,6 +1308,12 @@ F: drivers/vdpa/ifc/
 F: doc/guides/vdpadevs/ifc.rst
 F: doc/guides/vdpadevs/features/ifcvf.ini
 
+Corigine nfp vDPA
+M: Chaoyong He <chaoyong.he@corigine.com>
+F: drivers/vdpa/nfp/
+F: doc/guides/vpdadevs/nfp.rst
+F: doc/guides/vdpadevs/features/nfp.ini
+
 NVIDIA mlx5 vDPA
 M: Matan Azrad <matan@nvidia.com>
 M: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
diff --git a/doc/guides/platform/index.rst b/doc/guides/platform/index.rst
index b1ba11df73..07dd273821 100644
--- a/doc/guides/platform/index.rst
+++ b/doc/guides/platform/index.rst
@@ -15,4 +15,5 @@ The following are platform specific guides and setup information.
     dpaa
     dpaa2
     mlx5
+    nfp
     octeontx
diff --git a/doc/guides/platform/nfp.rst b/doc/guides/platform/nfp.rst
new file mode 100644
index 0000000000..f6c7be6fff
--- /dev/null
+++ b/doc/guides/platform/nfp.rst
@@ -0,0 +1,30 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (c) 2023 Corigine, Inc.
+
+NFP Common Driver
+=================
+
+The NFP common driver library (**librte_common_nfp**) provides support for
+the Netronome and Corigine's NFP-6xxx, NFP-4xxx and NFP-38xx product lines.
+
+Classes
+-------
+
+One NFP device can be probed by a number of different PMDs.
+To select a specific PMD, its name should be specified as a device parameter
+(e.g. ``0000:08:00.1,class=eth``).
+
+
+Supported Classes
+~~~~~~~~~~~~~~~~~
+
+- ``class=eth`` for :doc:`../nics/nfp`.
+- ``class=vdpa`` for :doc:`../vdpadevs/nfp`.
+
+By default, the NFP device will be probed by the ``eth`` PMD.
+
+
+Limitations
+~~~~~~~~~~~
+
+- ``eth`` and ``vdpa`` PMDs cannot be probed at the same time.
diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index 0a6fc76a9d..f6dde6fb9d 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -153,6 +153,11 @@ New Features
 
   * Added inline IPsec offload based on the security framework.
 
+* **Add new vDPA PMD based on Corigine NFP devices.**
+
+  Added a new Corigine NFP vDPA (``nfp_vdpa``) PMD.
+  See the :doc:`../vdpadevs/nfp` guide for more details on this driver.
+
 * **Updated Wangxun ngbe driver.**
 
   * Added 100M and auto-neg support in YT PHY fiber mode.
diff --git a/doc/guides/vdpadevs/features/nfp.ini b/doc/guides/vdpadevs/features/nfp.ini
new file mode 100644
index 0000000000..d830feafe0
--- /dev/null
+++ b/doc/guides/vdpadevs/features/nfp.ini
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'nfp' vDPA driver.
+;
+; Refer to default.ini for the full list of available driver features.
+;
+[Features]
+Linux                   = Y
+x86-64                  = Y
diff --git a/doc/guides/vdpadevs/index.rst b/doc/guides/vdpadevs/index.rst
index cc2f858042..b0191a3a1d 100644
--- a/doc/guides/vdpadevs/index.rst
+++ b/doc/guides/vdpadevs/index.rst
@@ -14,4 +14,5 @@ which can be used from an application through vhost API.
     features_overview
     ifc
     mlx5
+    nfp
     sfc
diff --git a/doc/guides/vdpadevs/nfp.rst b/doc/guides/vdpadevs/nfp.rst
new file mode 100644
index 0000000000..63636b2882
--- /dev/null
+++ b/doc/guides/vdpadevs/nfp.rst
@@ -0,0 +1,54 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (c) 2023 Corigine, Inc.
+
+NFP vDPA driver
+===============
+
+The NFP vDPA (vhost data path acceleration) driver (**librte_nfp_vdpa**)
+provides support for the Netronome and Corigine's NFP-6xxx, NFP-4xxx
+and NFP-38xx product lines.
+
+NFP vDPA implementation
+-----------------------
+
+NFP VF device can be configured in the net device or vDPA mode.
+Adding "class=vdpa" parameter helps to specify that this device is to
+be used in vDPA mode. If this parameter is not specified, device
+will be probed by net/nfp driver and will used as a VF net device.
+
+This PMD uses (common/nfp) code to access the device firmware.
+
+Per-Device Parameters
+~~~~~~~~~~~~~~~~~~~~~
+
+The following per-device parameters can be passed via EAL PCI device
+allowlist option like "-a 02:00.0,arg1=value1,...".
+
+- ``class`` [net|vdpa] (default **net**)
+
+  Choose the mode of operation of nfp device.
+  **net** device will work as network device and will be probed by net/nfp driver.
+  **vdpa** device will work as vdpa device and will be probed by vdpa/nfp driver.
+  If this parameter is not specified then nfp device will operate as network device.
+
+Dynamic Logging Parameters
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+One may leverage EAL option "--log-level" to change default levels
+for the log types supported by the driver. The option is used with
+an argument typically consisting of two parts separated by a colon.
+
+Level value is the last part which takes a symbolic name (or integer).
+Log type is the former part which may shell match syntax.
+Depending on the choice of the expression, the given log level may
+be used either for some specific log type or for a subset of types.
+
+NFP vDPA PMD provides the following log types available for control:
+
+- ``pmd.vdpa.nfp.vdpa`` (default level is **notice**)
+
+  Affects driver-wide messages unrelated to any particular devices.
+
+- ``pmd.vdpa.nfp.core`` (default level is **notice**)
+
+  Affects the core logic of this PMD.
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v2 00/25] add the NFP vDPA PMD
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (24 preceding siblings ...)
  2023-10-24  2:28   ` [PATCH v2 25/25] doc: add the common and vDPA document Chaoyong He
@ 2023-10-25 16:09   ` Ferruh Yigit
  2023-10-26  1:33     ` Chaoyong He
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
  26 siblings, 1 reply; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-25 16:09 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers

On 10/24/2023 3:28 AM, Chaoyong He wrote:
> This patch series aims to add the NFP vDPA PMD, we also grab the common
> logic into the `drivers/common/nfp` directory.
> 
> ---
> v2:
> * Grab more logic into the `drivers/common/nfp` directory.
> * Delete some logic which should be when moving logic.
> ---
> 
> Chaoyong He (25):
>   drivers: introduce the NFP common library
>   net/nfp: make VF PMD using of NFP common module
>   net/nfp: rename common module name
>   net/nfp: rename ctrl module name
>   net/nfp: extract the cap data field
>   net/nfp: extract the qcp data field
>   net/nfp: extract the ctrl BAR data field
>   net/nfp: extract the ctrl data field
>   net/nfp: change the parameter of APIs
>   net/nfp: change the parameter of reconfig
>   net/nfp: extract the MAC address data field
>   net/nfp: rename parameter in related logic
>   drivers: add the common ctrl module
>   drivers: add the nfp common module
>   drivers: move queue logic to common module
>   drivers: move platform module to common library
>   drivers: move device module to common library
>   drivers/vdpa: introduce the NFP vDPA library
>   drivers: add the basic framework of vDPA PMD
>   vdpa/nfp: add the logic of remap PCI memory
>   vdpa/nfp: add the hardware init logic
>   drivers: add the datapath update logic
>   vdpa/nfp: add the notify related logic
>   vdpa/nfp: add nfp vDPA device operations
>   doc: add the common and vDPA document
> 

Overall pretty clean set, but there are a few minor issues, commented on
patches.


Also can you please address checkpatch warnings:

  ### [PATCH] drivers: add the datapath update logic

    Warning in drivers/vdpa/nfp/nfp_vdpa.c:
    Using __atomic_xxx built-ins, prefer rte_atomic_xxx

  ### [PATCH] vdpa/nfp: add the notify related logic

    Warning in drivers/vdpa/nfp/nfp_vdpa.c:
    Using pthread functions, prefer rte_thread

  ### [PATCH] vdpa/nfp: add nfp vDPA device operations

    Warning in drivers/vdpa/nfp/nfp_vdpa.c:
    Using __atomic_xxx built-ins, prefer rte_atomic_xxx


And some typos:
  vdpa/nfp: add nfp vDPA device operations
  opetation


^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v2 02/25] net/nfp: make VF PMD using of NFP common module
  2023-10-24  2:28   ` [PATCH v2 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
@ 2023-10-25 16:09     ` Ferruh Yigit
  2023-10-26  1:34       ` Chaoyong He
  0 siblings, 1 reply; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-25 16:09 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Shujing Dong, Long Wu, Peng Zhang

On 10/24/2023 3:28 AM, Chaoyong He wrote:
> Modify the logic of NFP VF PMD, make it using of the NFP common module
> and link into the 'nfp_drivers_list'.
> 
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
> Reviewed-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> ---
>  drivers/net/nfp/meson.build     |  6 +++++-
>  drivers/net/nfp/nfp_ethdev_vf.c | 14 ++++++++++----
>  2 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
> index 40e9ef8524..f8581403fa 100644
> --- a/drivers/net/nfp/meson.build
> +++ b/drivers/net/nfp/meson.build
> @@ -40,4 +40,8 @@ sources = files(
>          'nfp_rxtx.c',
>  )
>  
> -deps += ['hash', 'security']
> +deps += ['hash', 'security', 'common_nfp']
> +
> +if not dpdk_conf.has('RTE_COMMON_NFP')
> +    error('Missing internal dependency "common/nfp"')
> +endif
>

This will break the build for the cases 'common/nfp' is disabled, above
'deps' updates should be sufficient, which should prevent to build the
driver when 'common/nfp' is missing, instead of failing.

So can you please drop above check.


^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v2 18/25] drivers/vdpa: introduce the NFP vDPA library
  2023-10-24  2:28   ` [PATCH v2 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
@ 2023-10-25 16:09     ` Ferruh Yigit
  2023-10-26  1:39       ` Chaoyong He
  0 siblings, 1 reply; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-25 16:09 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Shujing Dong, Long Wu, Peng Zhang

On 10/24/2023 3:28 AM, Chaoyong He wrote:
> Introduce the very basic NFP vDPA library.
> 
> Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
> 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>

<...>

> --- /dev/null
> +++ b/drivers/vdpa/nfp/meson.build
> @@ -0,0 +1,16 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright (c) 2023 Corigine, Inc.
> +
> +if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
> +    build = false
> +    reason = 'only supported on 64-bit Linux'
> +endif
> +
> +if not dpdk_conf.has('RTE_LIB_VHOST')
> +    build = false
> +    reason = 'missing dependency, DPDK vhost library'
> +endif
> +

Similar to previous comment, this may break the build.
Instead of this check, it is possible to add vhost and common/nfp as
dependency to this driver, using 'deps'.


> +sources = files(
> +        'nfp_vdpa_log.c',
> +)
> diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.c b/drivers/vdpa/nfp/nfp_vdpa_log.c
> new file mode 100644
> index 0000000000..8c957d59ea
> --- /dev/null
> +++ b/drivers/vdpa/nfp/nfp_vdpa_log.c
> @@ -0,0 +1,9 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright (c) 2023 Corigine, Inc.
> + * All rights reserved.
> + */
> +
> +#include "nfp_vdpa_log.h"
> +
> +RTE_LOG_REGISTER_SUFFIX(nfp_core_logtype, driver, NOTICE);
> +RTE_LOG_REGISTER_SUFFIX(nfp_vdpa_logtype, driver, NOTICE);
>

Both has 'driver' has suffix, I assume copy/paste error.


^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v2 19/25] drivers: add the basic framework of vDPA PMD
  2023-10-24  2:28   ` [PATCH v2 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
@ 2023-10-25 16:10     ` Ferruh Yigit
  2023-10-26  1:39       ` Chaoyong He
  0 siblings, 1 reply; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-25 16:10 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Shujing Dong, Long Wu, Peng Zhang

On 10/24/2023 3:28 AM, Chaoyong He wrote:
> Add the basic framework of vDPA PMD.
> 
> Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
> Reviewed-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>

<...>

> @@ -12,5 +12,12 @@ if not dpdk_conf.has('RTE_LIB_VHOST')
>  endif
>  
>  sources = files(
> +        'nfp_vdpa.c',
>          'nfp_vdpa_log.c',
>  )
> +
> +deps += ['common_nfp']
> +
> +if not dpdk_conf.has('RTE_COMMON_NFP')
> +    error('Missing internal dependency "common/nfp"')
> +endif
>

Same comment with previous patches, please drop above check.



^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v2 25/25] doc: add the common and vDPA document
  2023-10-24  2:28   ` [PATCH v2 25/25] doc: add the common and vDPA document Chaoyong He
@ 2023-10-25 16:11     ` Ferruh Yigit
  2023-10-26  1:41       ` Chaoyong He
  0 siblings, 1 reply; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-25 16:11 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Long Wu, Peng Zhang

On 10/24/2023 3:28 AM, Chaoyong He wrote:
> Add the document for nfp common library and vDPA PMD.
> 

Can you please distribute this patch to other patches in set, details below.

> 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>
> ---
>  MAINTAINERS                            |  8 ++++
>  doc/guides/platform/index.rst          |  1 +
>  doc/guides/platform/nfp.rst            | 30 ++++++++++++++
>  doc/guides/rel_notes/release_23_11.rst |  5 +++
>  doc/guides/vdpadevs/features/nfp.ini   |  8 ++++
>  doc/guides/vdpadevs/index.rst          |  1 +
>  doc/guides/vdpadevs/nfp.rst            | 54 ++++++++++++++++++++++++++
>  7 files changed, 107 insertions(+)
>  create mode 100644 doc/guides/platform/nfp.rst
>  create mode 100644 doc/guides/vdpadevs/features/nfp.ini
>  create mode 100644 doc/guides/vdpadevs/nfp.rst
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 4083658697..b28cdab54c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -900,9 +900,11 @@ F: doc/guides/nics/features/nfb.ini
>  
>  Netronome nfp
>  M: Chaoyong He <chaoyong.he@corigine.com>
> +F: drivers/common/nfp/
>

This part can go into first patch that introduces common/nfp

>  F: drivers/net/nfp/
>  F: doc/guides/nics/nfp.rst
>  F: doc/guides/nics/features/nfp*.ini
> +F: doc/guides/platform/nfp.rst
>  

Is a platform guide needed for nfp, it has only net and vdpa at this
stage and both has its own documentation, for a nic (not a SoC or
platform), a platform guide seems excessive to me, what do you think to
distribute this information to net and vdpa documentation of driver?


>  NXP dpaa
>  M: Hemant Agrawal <hemant.agrawal@nxp.com>
> @@ -1306,6 +1308,12 @@ F: drivers/vdpa/ifc/
>  F: doc/guides/vdpadevs/ifc.rst
>  F: doc/guides/vdpadevs/features/ifcvf.ini
>  
> +Corigine nfp vDPA
> +M: Chaoyong He <chaoyong.he@corigine.com>
> +F: drivers/vdpa/nfp/
> +F: doc/guides/vpdadevs/nfp.rst
> +F: doc/guides/vdpadevs/features/nfp.ini
> +

Above part can go into patch that introduces vdpa/nfp, like
18/25] drivers/vdpa: introduce the NFP vDPA library

including other vdpa related documentation:
doc/guides/vdpadevs/features/nfp.ini
doc/guides/vdpadevs/index.rst
doc/guides/vdpadevs/nfp.rst


^ permalink raw reply	[flat|nested] 121+ messages in thread

* RE: [PATCH v2 00/25] add the NFP vDPA PMD
  2023-10-25 16:09   ` [PATCH v2 00/25] add the NFP vDPA PMD Ferruh Yigit
@ 2023-10-26  1:33     ` Chaoyong He
  2023-10-26  2:50       ` Chaoyong He
  0 siblings, 1 reply; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  1:33 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers

> On 10/24/2023 3:28 AM, Chaoyong He wrote:
> > This patch series aims to add the NFP vDPA PMD, we also grab the
> > common logic into the `drivers/common/nfp` directory.
> >
> > ---
> > v2:
> > * Grab more logic into the `drivers/common/nfp` directory.
> > * Delete some logic which should be when moving logic.
> > ---
> >
> > Chaoyong He (25):
> >   drivers: introduce the NFP common library
> >   net/nfp: make VF PMD using of NFP common module
> >   net/nfp: rename common module name
> >   net/nfp: rename ctrl module name
> >   net/nfp: extract the cap data field
> >   net/nfp: extract the qcp data field
> >   net/nfp: extract the ctrl BAR data field
> >   net/nfp: extract the ctrl data field
> >   net/nfp: change the parameter of APIs
> >   net/nfp: change the parameter of reconfig
> >   net/nfp: extract the MAC address data field
> >   net/nfp: rename parameter in related logic
> >   drivers: add the common ctrl module
> >   drivers: add the nfp common module
> >   drivers: move queue logic to common module
> >   drivers: move platform module to common library
> >   drivers: move device module to common library
> >   drivers/vdpa: introduce the NFP vDPA library
> >   drivers: add the basic framework of vDPA PMD
> >   vdpa/nfp: add the logic of remap PCI memory
> >   vdpa/nfp: add the hardware init logic
> >   drivers: add the datapath update logic
> >   vdpa/nfp: add the notify related logic
> >   vdpa/nfp: add nfp vDPA device operations
> >   doc: add the common and vDPA document
> >
> 
> Overall pretty clean set, but there are a few minor issues, commented on
> patches.
> 
> 
> Also can you please address checkpatch warnings:
> 
>   ### [PATCH] drivers: add the datapath update logic
> 
>     Warning in drivers/vdpa/nfp/nfp_vdpa.c:
>     Using __atomic_xxx built-ins, prefer rte_atomic_xxx
> 

Oh, Sorry, we choose '__atomic_xxx' because we see the document in https://doc.dpdk.org/guides/prog_guide/writing_efficient_code.html?highlight=atomic%20operations%20use%20c11%20atomic%20builtins#atomic-operations-use-c11-atomic-builtins.
Maybe we misunderstood it, we will change to the `rte_atomic_xxx` in next version, thanks.

>   ### [PATCH] vdpa/nfp: add the notify related logic
> 
>     Warning in drivers/vdpa/nfp/nfp_vdpa.c:
>     Using pthread functions, prefer rte_thread
> 

Okay, will revise in the next version.

>   ### [PATCH] vdpa/nfp: add nfp vDPA device operations
> 
>     Warning in drivers/vdpa/nfp/nfp_vdpa.c:
>     Using __atomic_xxx built-ins, prefer rte_atomic_xxx
> 
> 
> And some typos:
>   vdpa/nfp: add nfp vDPA device operations
>   opetation

Will change in next version, thanks.


^ permalink raw reply	[flat|nested] 121+ messages in thread

* RE: [PATCH v2 02/25] net/nfp: make VF PMD using of NFP common module
  2023-10-25 16:09     ` Ferruh Yigit
@ 2023-10-26  1:34       ` Chaoyong He
  0 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  1:34 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers, Shujing Dong, Long Wu, Nole Zhang

> On 10/24/2023 3:28 AM, Chaoyong He wrote:
> > Modify the logic of NFP VF PMD, make it using of the NFP common module
> > and link into the 'nfp_drivers_list'.
> >
> > Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> > Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
> > Reviewed-by: Long Wu <long.wu@corigine.com>
> > Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> > ---
> >  drivers/net/nfp/meson.build     |  6 +++++-
> >  drivers/net/nfp/nfp_ethdev_vf.c | 14 ++++++++++----
> >  2 files changed, 15 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
> > index 40e9ef8524..f8581403fa 100644
> > --- a/drivers/net/nfp/meson.build
> > +++ b/drivers/net/nfp/meson.build
> > @@ -40,4 +40,8 @@ sources = files(
> >          'nfp_rxtx.c',
> >  )
> >
> > -deps += ['hash', 'security']
> > +deps += ['hash', 'security', 'common_nfp']
> > +
> > +if not dpdk_conf.has('RTE_COMMON_NFP')
> > +    error('Missing internal dependency "common/nfp"') endif
> >
> 
> This will break the build for the cases 'common/nfp' is disabled, above 'deps'
> updates should be sufficient, which should prevent to build the driver when
> 'common/nfp' is missing, instead of failing.
> 
> So can you please drop above check.

Okay, will drop it in the next version, thanks.

^ permalink raw reply	[flat|nested] 121+ messages in thread

* RE: [PATCH v2 18/25] drivers/vdpa: introduce the NFP vDPA library
  2023-10-25 16:09     ` Ferruh Yigit
@ 2023-10-26  1:39       ` Chaoyong He
  0 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  1:39 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers, Shujing Dong, Long Wu, Nole Zhang

> On 10/24/2023 3:28 AM, Chaoyong He wrote:
> > Introduce the very basic NFP vDPA library.
> >
> > Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
> > 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>
> 
> <...>
> 
> > --- /dev/null
> > +++ b/drivers/vdpa/nfp/meson.build
> > @@ -0,0 +1,16 @@
> > +# SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2023
> > +Corigine, Inc.
> > +
> > +if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
> > +    build = false
> > +    reason = 'only supported on 64-bit Linux'
> > +endif
> > +
> > +if not dpdk_conf.has('RTE_LIB_VHOST')
> > +    build = false
> > +    reason = 'missing dependency, DPDK vhost library'
> > +endif
> > +
> 
> Similar to previous comment, this may break the build.
> Instead of this check, it is possible to add vhost and common/nfp as
> dependency to this driver, using 'deps'.
> 

Sorry for that, I will drop it in the next version.

> 
> > +sources = files(
> > +        'nfp_vdpa_log.c',
> > +)
> > diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.c
> > b/drivers/vdpa/nfp/nfp_vdpa_log.c new file mode 100644 index
> > 0000000000..8c957d59ea
> > --- /dev/null
> > +++ b/drivers/vdpa/nfp/nfp_vdpa_log.c
> > @@ -0,0 +1,9 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright (c) 2023 Corigine, Inc.
> > + * All rights reserved.
> > + */
> > +
> > +#include "nfp_vdpa_log.h"
> > +
> > +RTE_LOG_REGISTER_SUFFIX(nfp_core_logtype, driver, NOTICE);
> > +RTE_LOG_REGISTER_SUFFIX(nfp_vdpa_logtype, driver, NOTICE);
> >
> 
> Both has 'driver' has suffix, I assume copy/paste error.

Thanks point that out, will revise in the next version.


^ permalink raw reply	[flat|nested] 121+ messages in thread

* RE: [PATCH v2 19/25] drivers: add the basic framework of vDPA PMD
  2023-10-25 16:10     ` Ferruh Yigit
@ 2023-10-26  1:39       ` Chaoyong He
  0 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  1:39 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers, Shujing Dong, Long Wu, Nole Zhang

> On 10/24/2023 3:28 AM, Chaoyong He wrote:
> > Add the basic framework of vDPA PMD.
> >
> > Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
> > Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
> > Reviewed-by: Long Wu <long.wu@corigine.com>
> > Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> 
> <...>
> 
> > @@ -12,5 +12,12 @@ if not dpdk_conf.has('RTE_LIB_VHOST')  endif
> >
> >  sources = files(
> > +        'nfp_vdpa.c',
> >          'nfp_vdpa_log.c',
> >  )
> > +
> > +deps += ['common_nfp']
> > +
> > +if not dpdk_conf.has('RTE_COMMON_NFP')
> > +    error('Missing internal dependency "common/nfp"') endif
> >
> 
> Same comment with previous patches, please drop above check.
> 

Sorry for that, will drop it in the next version.


^ permalink raw reply	[flat|nested] 121+ messages in thread

* RE: [PATCH v2 25/25] doc: add the common and vDPA document
  2023-10-25 16:11     ` Ferruh Yigit
@ 2023-10-26  1:41       ` Chaoyong He
  0 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  1:41 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers, Long Wu, Nole Zhang

> On 10/24/2023 3:28 AM, Chaoyong He wrote:
> > Add the document for nfp common library and vDPA PMD.
> >
> 
> Can you please distribute this patch to other patches in set, details below.
> 
> > 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>
> > ---
> >  MAINTAINERS                            |  8 ++++
> >  doc/guides/platform/index.rst          |  1 +
> >  doc/guides/platform/nfp.rst            | 30 ++++++++++++++
> >  doc/guides/rel_notes/release_23_11.rst |  5 +++
> >  doc/guides/vdpadevs/features/nfp.ini   |  8 ++++
> >  doc/guides/vdpadevs/index.rst          |  1 +
> >  doc/guides/vdpadevs/nfp.rst            | 54 ++++++++++++++++++++++++++
> >  7 files changed, 107 insertions(+)
> >  create mode 100644 doc/guides/platform/nfp.rst  create mode 100644
> > doc/guides/vdpadevs/features/nfp.ini
> >  create mode 100644 doc/guides/vdpadevs/nfp.rst
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS index 4083658697..b28cdab54c
> > 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -900,9 +900,11 @@ F: doc/guides/nics/features/nfb.ini
> >
> >  Netronome nfp
> >  M: Chaoyong He <chaoyong.he@corigine.com>
> > +F: drivers/common/nfp/
> >
> 
> This part can go into first patch that introduces common/nfp
> 

Okay.

> >  F: drivers/net/nfp/
> >  F: doc/guides/nics/nfp.rst
> >  F: doc/guides/nics/features/nfp*.ini
> > +F: doc/guides/platform/nfp.rst
> >
> 
> Is a platform guide needed for nfp, it has only net and vdpa at this stage and
> both has its own documentation, for a nic (not a SoC or platform), a platform
> guide seems excessive to me, what do you think to distribute this information
> to net and vdpa documentation of driver?
> 

I will drop this file in the next version, thanks.

> 
> >  NXP dpaa
> >  M: Hemant Agrawal <hemant.agrawal@nxp.com> @@ -1306,6 +1308,12
> @@ F:
> > drivers/vdpa/ifc/
> >  F: doc/guides/vdpadevs/ifc.rst
> >  F: doc/guides/vdpadevs/features/ifcvf.ini
> >
> > +Corigine nfp vDPA
> > +M: Chaoyong He <chaoyong.he@corigine.com>
> > +F: drivers/vdpa/nfp/
> > +F: doc/guides/vpdadevs/nfp.rst
> > +F: doc/guides/vdpadevs/features/nfp.ini
> > +
> 
> Above part can go into patch that introduces vdpa/nfp, like 18/25]
> drivers/vdpa: introduce the NFP vDPA library
> 
> including other vdpa related documentation:
> doc/guides/vdpadevs/features/nfp.ini
> doc/guides/vdpadevs/index.rst
> doc/guides/vdpadevs/nfp.rst

Okay, will do as you said in the next version, thanks.


^ permalink raw reply	[flat|nested] 121+ messages in thread

* RE: [PATCH v2 00/25] add the NFP vDPA PMD
  2023-10-26  1:33     ` Chaoyong He
@ 2023-10-26  2:50       ` Chaoyong He
  2023-10-26 11:30         ` Ferruh Yigit
  0 siblings, 1 reply; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  2:50 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers

> > On 10/24/2023 3:28 AM, Chaoyong He wrote:
> > > This patch series aims to add the NFP vDPA PMD, we also grab the
> > > common logic into the `drivers/common/nfp` directory.
> > >
> > > ---
> > > v2:
> > > * Grab more logic into the `drivers/common/nfp` directory.
> > > * Delete some logic which should be when moving logic.
> > > ---
> > >
> > > Chaoyong He (25):
> > >   drivers: introduce the NFP common library
> > >   net/nfp: make VF PMD using of NFP common module
> > >   net/nfp: rename common module name
> > >   net/nfp: rename ctrl module name
> > >   net/nfp: extract the cap data field
> > >   net/nfp: extract the qcp data field
> > >   net/nfp: extract the ctrl BAR data field
> > >   net/nfp: extract the ctrl data field
> > >   net/nfp: change the parameter of APIs
> > >   net/nfp: change the parameter of reconfig
> > >   net/nfp: extract the MAC address data field
> > >   net/nfp: rename parameter in related logic
> > >   drivers: add the common ctrl module
> > >   drivers: add the nfp common module
> > >   drivers: move queue logic to common module
> > >   drivers: move platform module to common library
> > >   drivers: move device module to common library
> > >   drivers/vdpa: introduce the NFP vDPA library
> > >   drivers: add the basic framework of vDPA PMD
> > >   vdpa/nfp: add the logic of remap PCI memory
> > >   vdpa/nfp: add the hardware init logic
> > >   drivers: add the datapath update logic
> > >   vdpa/nfp: add the notify related logic
> > >   vdpa/nfp: add nfp vDPA device operations
> > >   doc: add the common and vDPA document
> > >
> >
> > Overall pretty clean set, but there are a few minor issues, commented
> > on patches.
> >
> >
> > Also can you please address checkpatch warnings:
> >
> >   ### [PATCH] drivers: add the datapath update logic
> >
> >     Warning in drivers/vdpa/nfp/nfp_vdpa.c:
> >     Using __atomic_xxx built-ins, prefer rte_atomic_xxx
> >
> 
> Oh, Sorry, we choose '__atomic_xxx' because we see the document in
> https://doc.dpdk.org/guides/prog_guide/writing_efficient_code.html?highlig
> ht=atomic%20operations%20use%20c11%20atomic%20builtins#atomic-
> operations-use-c11-atomic-builtins.
> Maybe we misunderstood it, we will change to the `rte_atomic_xxx` in next
> version, thanks.

As the notes in the 'doc/guides/rel_notes/deprecation.rst':
---
  rte_atomicNN_xxx: These APIs do not take memory order parameter. This does
  not allow for writing optimized code for all the CPU architectures supported
  in DPDK. DPDK has adopted the atomic operations from
  https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html. These
  operations must be used for patches that need to be merged in 20.08 onwards.
  This change will not introduce any performance degradation.
---
The '__atomic_xxx' is the preferred choice? So maybe it's the 'checkpatches.sh' should update?
And seems there are many logics using the '__atomic_xxx'.

Spend some time and confused about this now.
What is the right APIs I should use?
Please make it clear, thanks.

> 
> >   ### [PATCH] vdpa/nfp: add the notify related logic
> >
> >     Warning in drivers/vdpa/nfp/nfp_vdpa.c:
> >     Using pthread functions, prefer rte_thread
> >
> 
> Okay, will revise in the next version.
> 
> >   ### [PATCH] vdpa/nfp: add nfp vDPA device operations
> >
> >     Warning in drivers/vdpa/nfp/nfp_vdpa.c:
> >     Using __atomic_xxx built-ins, prefer rte_atomic_xxx
> >
> >
> > And some typos:
> >   vdpa/nfp: add nfp vDPA device operations
> >   opetation
> 
> Will change in next version, thanks.


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 00/25] add the NFP vDPA PMD
  2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
                     ` (25 preceding siblings ...)
  2023-10-25 16:09   ` [PATCH v2 00/25] add the NFP vDPA PMD Ferruh Yigit
@ 2023-10-26  6:42   ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 01/25] drivers: introduce the NFP common library Chaoyong He
                       ` (27 more replies)
  26 siblings, 28 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:42 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series aims to add the NFP vDPA PMD, we also grab the common
logic into the `drivers/common/nfp` directory.

---
v3:
* Replace 'pthread_xxx' API with 'rte_thread_xxx' API.
* Replace '__atomic_xxx' built-ins with 'rte_atomic_xxx'.
* Drop the check statement in meson.build file which prevent build of
  PMD.
* Fix a problem about the logtype prefix.
* Move the document modification to the commit which should be.
v2:
* Grab more logic into the `drivers/common/nfp` directory.
* Delete some logic which should be when moving logic.
---

Chaoyong He (25):
  drivers: introduce the NFP common library
  net/nfp: make VF PMD using of NFP common module
  net/nfp: rename common module name
  net/nfp: rename ctrl module name
  net/nfp: extract the cap data field
  net/nfp: extract the qcp data field
  net/nfp: extract the ctrl BAR data field
  net/nfp: extract the ctrl data field
  net/nfp: change the parameter of APIs
  net/nfp: change the parameter of reconfig
  net/nfp: extract the MAC address data field
  net/nfp: rename parameter in related logic
  drivers: add the common ctrl module
  drivers: add the nfp common module
  drivers: move queue logic to common module
  drivers: move platform module to common library
  drivers: move device module to common library
  drivers/vdpa: introduce the NFP vDPA library
  drivers: add the basic framework of vDPA PMD
  vdpa/nfp: add the logic of remap PCI memory
  vdpa/nfp: add the hardware init logic
  drivers: add the datapath update logic
  vdpa/nfp: add the notify related logic
  vdpa/nfp: add nfp vDPA device operations
  doc: add a entry in the release notes

 .mailmap                                      |   1 +
 MAINTAINERS                                   |   7 +
 doc/guides/rel_notes/release_23_11.rst        |   5 +
 doc/guides/vdpadevs/features/nfp.ini          |   8 +
 doc/guides/vdpadevs/index.rst                 |   1 +
 doc/guides/vdpadevs/nfp.rst                   |  54 ++
 drivers/common/nfp/meson.build                |  16 +
 drivers/common/nfp/nfp_common.c               | 226 +++++
 drivers/common/nfp/nfp_common.h               | 239 +++++
 .../nfp/nfp_common_ctrl.h}                    | 209 +---
 drivers/common/nfp/nfp_common_log.c           |   8 +
 drivers/common/nfp/nfp_common_log.h           |  16 +
 drivers/common/nfp/nfp_common_pci.c           | 275 ++++++
 drivers/common/nfp/nfp_common_pci.h           |  45 +
 .../{net/nfp/nfpcore => common/nfp}/nfp_dev.c |   3 +-
 .../{net/nfp/nfpcore => common/nfp}/nfp_dev.h |   3 +
 .../nfp/nfpcore => common/nfp}/nfp_platform.h |   0
 drivers/common/nfp/version.map                |  16 +
 drivers/meson.build                           |   1 +
 drivers/net/nfp/flower/nfp_flower.c           |  56 +-
 drivers/net/nfp/flower/nfp_flower.h           |   2 +-
 .../net/nfp/flower/nfp_flower_representor.c   |  10 +-
 drivers/net/nfp/meson.build                   |   7 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c            |  18 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c            |  22 +-
 drivers/net/nfp/nfp_cpp_bridge.h              |   2 +-
 drivers/net/nfp/nfp_ethdev.c                  |  80 +-
 drivers/net/nfp/nfp_ethdev_vf.c               |  74 +-
 drivers/net/nfp/nfp_flow.h                    |   2 +-
 drivers/net/nfp/nfp_ipsec.c                   |  86 +-
 .../nfp/{nfp_common.c => nfp_net_common.c}    | 493 ++++------
 .../nfp/{nfp_common.h => nfp_net_common.h}    | 219 +----
 .../net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c}    |  21 +-
 drivers/net/nfp/nfp_net_ctrl.h                | 211 ++++
 drivers/net/nfp/nfp_rxtx.c                    |  20 +-
 drivers/net/nfp/nfpcore/nfp6000_pcie.h        |   2 +-
 drivers/net/nfp/nfpcore/nfp_cppcore.c         |   3 +-
 drivers/net/nfp/nfpcore/nfp_nsp.c             |   2 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c         |   3 +-
 drivers/vdpa/meson.build                      |   1 +
 drivers/vdpa/nfp/meson.build                  |  15 +
 drivers/vdpa/nfp/nfp_vdpa.c                   | 912 ++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c              | 193 ++++
 drivers/vdpa/nfp/nfp_vdpa_core.h              |  51 +
 drivers/vdpa/nfp/nfp_vdpa_log.c               |   9 +
 drivers/vdpa/nfp/nfp_vdpa_log.h               |  21 +
 46 files changed, 2727 insertions(+), 941 deletions(-)
 create mode 100644 doc/guides/vdpadevs/features/nfp.ini
 create mode 100644 doc/guides/vdpadevs/nfp.rst
 create mode 100644 drivers/common/nfp/meson.build
 create mode 100644 drivers/common/nfp/nfp_common.c
 create mode 100644 drivers/common/nfp/nfp_common.h
 rename drivers/{net/nfp/nfp_ctrl.h => common/nfp/nfp_common_ctrl.h} (63%)
 create mode 100644 drivers/common/nfp/nfp_common_log.c
 create mode 100644 drivers/common/nfp/nfp_common_log.h
 create mode 100644 drivers/common/nfp/nfp_common_pci.c
 create mode 100644 drivers/common/nfp/nfp_common_pci.h
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c (98%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h (96%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_platform.h (100%)
 create mode 100644 drivers/common/nfp/version.map
 rename drivers/net/nfp/{nfp_common.c => nfp_net_common.c} (80%)
 rename drivers/net/nfp/{nfp_common.h => nfp_net_common.h} (64%)
 rename drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} (84%)
 create mode 100644 drivers/net/nfp/nfp_net_ctrl.h
 create mode 100644 drivers/vdpa/nfp/meson.build
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.h
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 01/25] drivers: introduce the NFP common library
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
                       ` (26 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

A new NFP vdpa PMD will be added to support vdpa operations by NFP
adapters.

This vdpa PMD share some logic with the net/nfp PMD. So create a new
common library in drivers/common for NFP PMDs.

We import a 'nfp_class_driver' layer and which can support various
device type in addition to the ethernet device.

The shared logic will move into this common library in the following
commits.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 .mailmap                            |   1 +
 MAINTAINERS                         |   1 +
 drivers/common/nfp/meson.build      |  14 ++
 drivers/common/nfp/nfp_common_log.c |   8 +
 drivers/common/nfp/nfp_common_log.h |  16 ++
 drivers/common/nfp/nfp_common_pci.c | 274 ++++++++++++++++++++++++++++
 drivers/common/nfp/nfp_common_pci.h |  44 +++++
 drivers/common/nfp/version.map      |   7 +
 drivers/meson.build                 |   1 +
 9 files changed, 366 insertions(+)
 create mode 100644 drivers/common/nfp/meson.build
 create mode 100644 drivers/common/nfp/nfp_common_log.c
 create mode 100644 drivers/common/nfp/nfp_common_log.h
 create mode 100644 drivers/common/nfp/nfp_common_pci.c
 create mode 100644 drivers/common/nfp/nfp_common_pci.h
 create mode 100644 drivers/common/nfp/version.map

diff --git a/.mailmap b/.mailmap
index 3f5bab26a8..9d9e015607 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1299,6 +1299,7 @@ Shuanglin Wang <shuanglin.wang@broadcom.com>
 Shuki Katzenelson <shuki@lightbitslabs.com>
 Shun Hao <shunh@nvidia.com>
 Shu Shen <shu.shen@radisys.com>
+Shujing Dong <shujing.dong@corigine.com>
 Shweta Choudaha <shweta.choudaha@att.com>
 Shyam Kumar Shrivastav <shrivastav.shyam@gmail.com>
 Shy Shyman <shys@nvidia.com> <shys@mellanox.com>
diff --git a/MAINTAINERS b/MAINTAINERS
index 4083658697..5273ab9812 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -900,6 +900,7 @@ F: doc/guides/nics/features/nfb.ini
 
 Netronome nfp
 M: Chaoyong He <chaoyong.he@corigine.com>
+F: drivers/common/nfp/
 F: drivers/net/nfp/
 F: doc/guides/nics/nfp.rst
 F: doc/guides/nics/features/nfp*.ini
diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
new file mode 100644
index 0000000000..cda5a930c7
--- /dev/null
+++ b/drivers/common/nfp/meson.build
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64-bit Linux'
+endif
+
+sources = files(
+        'nfp_common_log.c',
+        'nfp_common_pci.c',
+)
+
+deps += ['bus_pci']
diff --git a/drivers/common/nfp/nfp_common_log.c b/drivers/common/nfp/nfp_common_log.c
new file mode 100644
index 0000000000..e69e608eb9
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_log.c
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common_log.h"
+
+RTE_LOG_REGISTER_SUFFIX(nfp_logtype_common, common, NOTICE);
diff --git a/drivers/common/nfp/nfp_common_log.h b/drivers/common/nfp/nfp_common_log.h
new file mode 100644
index 0000000000..066e38e688
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_log.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_LOG_H__
+#define __NFP_COMMON_LOG_H__
+
+#include <rte_log.h>
+
+extern int nfp_logtype_common;
+#define PMD_DRV_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_logtype_common, \
+			"%s(): " fmt "\n", __func__, ## args)
+
+#endif/* __NFP_COMMON_LOG_H__ */
diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
new file mode 100644
index 0000000000..65f189b05e
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -0,0 +1,274 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common_pci.h"
+
+#include <string.h>
+
+#include <rte_class.h>
+#include <rte_devargs.h>
+#include <rte_kvargs.h>
+
+#include "nfp_common_log.h"
+
+/* Reported driver name. */
+#define NFP_PCI_DRIVER_NAME "nfp_common_pci"
+
+static struct rte_pci_driver nfp_common_pci_driver;
+
+/* PCI ID table is build dynamically based on registered nfp drivers. */
+static struct rte_pci_id *nfp_pci_id_table;
+
+/* Head of list of drivers. */
+static TAILQ_HEAD(nfp_drivers, nfp_class_driver) nfp_drivers_list =
+		TAILQ_HEAD_INITIALIZER(nfp_drivers_list);
+
+static bool nfp_common_initialized;
+
+static const struct {
+	const char *name;
+	enum nfp_class drv_class;
+} nfp_classes[] = {
+	{ .name = "eth",      .drv_class = NFP_CLASS_ETH },
+};
+
+static enum nfp_class
+nfp_class_name_to_value(const char *class_name)
+{
+	uint32_t i;
+
+	for (i = 0; i < RTE_DIM(nfp_classes); i++) {
+		if (strcmp(class_name, nfp_classes[i].name) == 0)
+			return nfp_classes[i].drv_class;
+	}
+
+	return NFP_CLASS_INVALID;
+}
+
+static uint32_t
+nfp_pci_id_table_size_get(const struct rte_pci_id *id_table)
+{
+	uint32_t table_size;
+
+	if (id_table == NULL)
+		return 0;
+
+	for (table_size = 0; id_table->vendor_id != 0; id_table++)
+		table_size++;
+
+	return table_size;
+}
+
+static bool
+nfp_pci_id_exists(const struct rte_pci_id *id,
+		const struct rte_pci_id *table,
+		uint32_t next_idx)
+{
+	uint32_t i;
+
+	if (next_idx == 0)
+		return false;
+
+	for (i = 0; i < next_idx; i++) {
+		if (id->device_id == table[i].device_id &&
+				id->vendor_id == table[i].vendor_id &&
+				id->subsystem_vendor_id == table[i].subsystem_vendor_id &&
+				id->subsystem_device_id == table[i].subsystem_device_id)
+			return true;
+	}
+
+	return false;
+}
+
+static void
+nfp_pci_id_insert(struct rte_pci_id *new_table,
+		uint32_t *next_idx,
+		const struct rte_pci_id *id_table)
+{
+	if (id_table == NULL)
+		return;
+
+	/* Add non duplicate entries to new table. */
+	for (; id_table->vendor_id != 0; id_table++) {
+		if (!nfp_pci_id_exists(id_table, new_table, *next_idx)) {
+			new_table[*next_idx] = *id_table;
+			(*next_idx)++;
+		}
+	}
+}
+
+static int
+nfp_pci_id_table_update(const struct rte_pci_id *driver_id_table)
+{
+	uint32_t i = 0;
+	uint32_t num_ids = 0;
+	struct rte_pci_id *old_table;
+	const struct rte_pci_id *id_iter;
+	struct rte_pci_id *updated_table;
+
+	old_table = nfp_pci_id_table;
+	if (old_table != NULL)
+		num_ids = nfp_pci_id_table_size_get(old_table);
+	num_ids += nfp_pci_id_table_size_get(driver_id_table);
+
+	/* Increase size by one for the termination entry of vendor_id = 0. */
+	num_ids += 1;
+	updated_table = calloc(num_ids, sizeof(struct rte_pci_id));
+	if (updated_table == NULL)
+		return -ENOMEM;
+
+	if (old_table == NULL) {
+		/* Copy the first driver's ID table. */
+		for (id_iter = driver_id_table; id_iter[i].vendor_id != 0; i++)
+			updated_table[i] = id_iter[i];
+	} else {
+		/* First copy existing table entries. */
+		for (id_iter = old_table; id_iter[i].vendor_id != 0; i++)
+			updated_table[i] = id_iter[i];
+		/* New id to be added at the end of current ID table. */
+		nfp_pci_id_insert(updated_table, &i, driver_id_table);
+
+		free(old_table);
+	}
+
+	/* Terminate table with empty entry. */
+	updated_table[i].vendor_id = 0;
+	nfp_pci_id_table = updated_table;
+	nfp_common_pci_driver.id_table = nfp_pci_id_table;
+
+	return 0;
+}
+
+static int
+nfp_kvarg_dev_class_handler(__rte_unused const char *key,
+		const char *class_str,
+		void *opaque)
+{
+	enum nfp_class *dev_class = opaque;
+
+	if (class_str == NULL)
+		return *dev_class;
+
+	*dev_class = nfp_class_name_to_value(class_str);
+
+	return 0;
+}
+
+static enum nfp_class
+nfp_parse_class_options(const struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvargs;
+	enum nfp_class dev_class = NFP_CLASS_ETH;
+
+	if (devargs == NULL)
+		return dev_class;
+
+	kvargs = rte_kvargs_parse(devargs->args, NULL);
+	if (kvargs == NULL)
+		return dev_class;
+
+	if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
+		rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
+				nfp_kvarg_dev_class_handler, &dev_class);
+	}
+
+	rte_kvargs_free(kvargs);
+
+	return dev_class;
+}
+
+static int
+nfp_drivers_probe(struct rte_pci_device *pci_dev,
+		enum nfp_class class)
+{
+	int32_t ret = 0;
+	struct nfp_class_driver *driver;
+
+	TAILQ_FOREACH(driver, &nfp_drivers_list, next) {
+		if (driver->drv_class != class)
+			continue;
+
+		ret = driver->probe(pci_dev);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to load driver %s", driver->name);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_common_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+		struct rte_pci_device *pci_dev)
+{
+	enum nfp_class class;
+	struct rte_device *eal_dev = &pci_dev->device;
+
+	PMD_DRV_LOG(INFO, "probe device %s.", eal_dev->name);
+
+	class = nfp_parse_class_options(eal_dev->devargs);
+	if (class == NFP_CLASS_INVALID) {
+		PMD_DRV_LOG(ERR, "Unsupported nfp class type: %s",
+				eal_dev->devargs->args);
+		return -ENOTSUP;
+	}
+
+	return nfp_drivers_probe(pci_dev, class);
+}
+
+static int
+nfp_common_pci_remove(__rte_unused struct rte_pci_device *pci_dev)
+{
+	return 0;
+}
+
+static struct rte_pci_driver nfp_common_pci_driver = {
+	.driver = {
+		.name = NFP_PCI_DRIVER_NAME,
+	},
+	.probe = nfp_common_pci_probe,
+	.remove = nfp_common_pci_remove,
+};
+
+static void
+nfp_common_init(void)
+{
+	const struct rte_pci_id empty_table[] = {
+		{
+			.vendor_id = 0
+		},
+	};
+
+	if (nfp_common_initialized)
+		return;
+
+	/*
+	 * All the constructor of NFP PMDs run at same priority. So any of the PMD
+	 * including this one can register the PCI table first. If any other
+	 * PMD(s) have registered the PCI ID table, no need to register an empty
+	 * default one.
+	 */
+	if (nfp_pci_id_table == NULL && nfp_pci_id_table_update(empty_table) != 0)
+		return;
+
+	rte_pci_register(&nfp_common_pci_driver);
+	nfp_common_initialized = true;
+}
+
+void
+nfp_class_driver_register(struct nfp_class_driver *driver)
+{
+	nfp_common_init();
+
+	if (driver->id_table != NULL) {
+		if (nfp_pci_id_table_update(driver->id_table) != 0)
+			return;
+	}
+
+	nfp_common_pci_driver.drv_flags |= driver->drv_flags;
+
+	TAILQ_INSERT_TAIL(&nfp_drivers_list, driver, next);
+}
diff --git a/drivers/common/nfp/nfp_common_pci.h b/drivers/common/nfp/nfp_common_pci.h
new file mode 100644
index 0000000000..21465fca68
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_pci.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_PCI_H__
+#define __NFP_COMMON_PCI_H__
+
+#include <bus_pci_driver.h>
+
+/* Initialization function for the driver called during device probing. */
+typedef int (nfp_class_driver_probe_t)(struct rte_pci_device *dev);
+
+/* Uninitialization function for the driver called during hot-unplugging. */
+typedef int (nfp_class_driver_remove_t)(struct rte_pci_device *dev);
+
+enum nfp_class {
+	NFP_CLASS_ETH,
+	NFP_CLASS_INVALID,
+};
+
+/* Describing a nfp common class driver. */
+struct nfp_class_driver {
+	TAILQ_ENTRY(nfp_class_driver) next;
+	enum nfp_class drv_class;            /**< Class of this driver. */
+	const char *name;                    /**< Driver name. */
+	const struct rte_pci_id *id_table;   /**< ID table, NULL terminated. */
+	uint32_t drv_flags;                  /**< Flags RTE_PCI_DRV_*. */
+	nfp_class_driver_probe_t *probe;     /**< Device probe function. */
+	nfp_class_driver_remove_t *remove;   /**< Device remove function. */
+};
+
+/**
+ * Register a nfp device driver.
+ *
+ * @param driver
+ *   A pointer to a nfp_driver structure describing the driver
+ *   to be registered.
+ */
+__rte_internal
+void
+nfp_class_driver_register(struct nfp_class_driver *driver);
+
+#endif /* __NFP_COMMON_PCI_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
new file mode 100644
index 0000000000..25e48c39d6
--- /dev/null
+++ b/drivers/common/nfp/version.map
@@ -0,0 +1,7 @@
+INTERNAL {
+	global:
+
+	nfp_class_driver_register;
+
+	local: *;
+};
diff --git a/drivers/meson.build b/drivers/meson.build
index 8c775bbe62..af70ed322c 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -15,6 +15,7 @@ subdirs = [
         'common/mlx5',    # depends on bus.
         'common/qat',     # depends on bus.
         'common/sfc_efx', # depends on bus.
+        'common/nfp',     # depends on bus.
         'mempool',        # depends on common and bus.
         'dma',            # depends on common and bus.
         'net',            # depends on common, bus, mempool
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 02/25] net/nfp: make VF PMD using of NFP common module
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 01/25] drivers: introduce the NFP common library Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 03/25] net/nfp: rename common module name Chaoyong He
                       ` (25 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Modify the logic of NFP VF PMD, make it using of the NFP common module
and link into the 'nfp_drivers_list'.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/meson.build     |  2 +-
 drivers/net/nfp/nfp_ethdev_vf.c | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 40e9ef8524..4702f1cdf4 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -40,4 +40,4 @@ sources = files(
         'nfp_rxtx.c',
 )
 
-deps += ['hash', 'security']
+deps += ['hash', 'security', 'common_nfp']
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 3db35b90e8..b9d7a7c5c0 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -6,6 +6,7 @@
  */
 
 #include <rte_alarm.h>
+#include <nfp_common_pci.h>
 
 #include "nfd3/nfp_nfd3.h"
 #include "nfdk/nfp_nfdk.h"
@@ -399,8 +400,7 @@ nfp_vf_pci_uninit(struct rte_eth_dev *eth_dev)
 }
 
 static int
-nfp_vf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
-		struct rte_pci_device *pci_dev)
+nfp_vf_pci_probe(struct rte_pci_device *pci_dev)
 {
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 			sizeof(struct nfp_net_adapter), nfp_netvf_init);
@@ -412,13 +412,19 @@ nfp_vf_pci_remove(struct rte_pci_device *pci_dev)
 	return rte_eth_dev_pci_generic_remove(pci_dev, nfp_vf_pci_uninit);
 }
 
-static struct rte_pci_driver rte_nfp_net_vf_pmd = {
+static struct nfp_class_driver rte_nfp_net_vf_pmd = {
+	.drv_class = NFP_CLASS_ETH,
+	.name = RTE_STR(net_nfp_vf),
 	.id_table = pci_id_nfp_vf_net_map,
 	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
 	.probe = nfp_vf_pci_probe,
 	.remove = nfp_vf_pci_remove,
 };
 
-RTE_PMD_REGISTER_PCI(net_nfp_vf, rte_nfp_net_vf_pmd);
+RTE_INIT(rte_nfp_vf_pmd_init)
+{
+	nfp_class_driver_register(&rte_nfp_net_vf_pmd);
+}
+
 RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 03/25] net/nfp: rename common module name
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 01/25] drivers: introduce the NFP common library Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 04/25] net/nfp: rename ctrl " Chaoyong He
                       ` (24 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename the 'nfp_common' module into 'nfp_net_common' module, because
which is more suitable and we will add 'nfp_common' module in the
'drivers/common/nfp' directory.

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.h                | 2 +-
 drivers/net/nfp/meson.build                        | 2 +-
 drivers/net/nfp/nfp_cpp_bridge.h                   | 2 +-
 drivers/net/nfp/nfp_ctrl.c                         | 2 +-
 drivers/net/nfp/nfp_ethdev_vf.c                    | 2 +-
 drivers/net/nfp/nfp_flow.h                         | 2 +-
 drivers/net/nfp/nfp_ipsec.c                        | 2 +-
 drivers/net/nfp/{nfp_common.c => nfp_net_common.c} | 2 +-
 drivers/net/nfp/{nfp_common.h => nfp_net_common.h} | 6 +++---
 9 files changed, 11 insertions(+), 11 deletions(-)
 rename drivers/net/nfp/{nfp_common.c => nfp_net_common.c} (99%)
 rename drivers/net/nfp/{nfp_common.h => nfp_net_common.h} (99%)

diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h
index b7ea830209..7d442e3cb2 100644
--- a/drivers/net/nfp/flower/nfp_flower.h
+++ b/drivers/net/nfp/flower/nfp_flower.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_FLOWER_H__
 #define __NFP_FLOWER_H__
 
-#include "../nfp_common.h"
+#include "../nfp_net_common.h"
 
 /* Extra features bitmap. */
 #define NFP_FL_FEATS_GENEVE             RTE_BIT64(0)
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 4702f1cdf4..4b4c587d5d 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -28,7 +28,6 @@ sources = files(
         'nfpcore/nfp_rtsym.c',
         'nfpcore/nfp_target.c',
         'nfpcore/nfp6000_pcie.c',
-        'nfp_common.c',
         'nfp_cpp_bridge.c',
         'nfp_ctrl.c',
         'nfp_ethdev.c',
@@ -37,6 +36,7 @@ sources = files(
         'nfp_ipsec.c',
         'nfp_logs.c',
         'nfp_mtr.c',
+        'nfp_net_common.c',
         'nfp_rxtx.c',
 )
 
diff --git a/drivers/net/nfp/nfp_cpp_bridge.h b/drivers/net/nfp/nfp_cpp_bridge.h
index a1103e85e4..bf975ce7ba 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.h
+++ b/drivers/net/nfp/nfp_cpp_bridge.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_CPP_BRIDGE_H__
 #define __NFP_CPP_BRIDGE_H__
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 int nfp_enable_cpp_service(struct nfp_pf_dev *pf_dev);
 int nfp_map_service(uint32_t service_id);
diff --git a/drivers/net/nfp/nfp_ctrl.c b/drivers/net/nfp/nfp_ctrl.c
index 6fc8cffd2e..a95e35c9a5 100644
--- a/drivers/net/nfp/nfp_ctrl.c
+++ b/drivers/net/nfp/nfp_ctrl.c
@@ -9,8 +9,8 @@
 
 #include "nfpcore/nfp_platform.h"
 
-#include "nfp_common.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 
 static void
 nfp_net_tlv_caps_reset(struct nfp_net_tlv_caps *caps)
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index b9d7a7c5c0..51c474275e 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -12,8 +12,8 @@
 #include "nfdk/nfp_nfdk.h"
 #include "nfpcore/nfp_cpp.h"
 
-#include "nfp_common.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 
 static void
 nfp_netvf_read_mac(struct nfp_net_hw *hw)
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index aeb24458f3..09e5b30dd8 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_FLOW_H__
 #define __NFP_FLOW_H__
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 /* The firmware expects lengths in units of long words */
 #define NFP_FL_LW_SIZ                   2
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index a76ba2a91d..f137e4b50c 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -12,9 +12,9 @@
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
 
-#include "nfp_common.h"
 #include "nfp_ctrl.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 #include "nfp_rxtx.h"
 
 #define NFP_UDP_ESP_PORT            4500
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_net_common.c
similarity index 99%
rename from drivers/net/nfp/nfp_common.c
rename to drivers/net/nfp/nfp_net_common.c
index 2d4a7635ab..189f81bbb6 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -5,7 +5,7 @@
  * Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
  */
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 #include <rte_alarm.h>
 
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_net_common.h
similarity index 99%
rename from drivers/net/nfp/nfp_common.h
rename to drivers/net/nfp/nfp_net_common.h
index c7f467e33c..cf08df4618 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -3,8 +3,8 @@
  * All rights reserved.
  */
 
-#ifndef __NFP_COMMON_H__
-#define __NFP_COMMON_H__
+#ifndef __NFP_NET_COMMON_H__
+#define __NFP_NET_COMMON_H__
 
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
@@ -451,4 +451,4 @@ bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
 #define NFP_PRIV_TO_APP_FW_FLOWER(app_fw_priv)\
 	((struct nfp_app_fw_flower *)app_fw_priv)
 
-#endif /* __NFP_COMMON_H__ */
+#endif /* __NFP_NET_COMMON_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 04/25] net/nfp: rename ctrl module name
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (2 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 03/25] net/nfp: rename common module name Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 05/25] net/nfp: extract the cap data field Chaoyong He
                       ` (23 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename the 'nfp_ctrl' module into 'nfp_net_ctrl' module, because which
is more suitable and we will add 'nfp_common_ctrl' module in the
'drivers/common/nfp' directory.

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/meson.build                    | 2 +-
 drivers/net/nfp/nfp_ipsec.c                    | 2 +-
 drivers/net/nfp/nfp_net_common.h               | 2 +-
 drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} | 2 +-
 drivers/net/nfp/{nfp_ctrl.h => nfp_net_ctrl.h} | 6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)
 rename drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} (98%)
 rename drivers/net/nfp/{nfp_ctrl.h => nfp_net_ctrl.h} (99%)

diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 4b4c587d5d..fa99c3b6aa 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -29,7 +29,6 @@ sources = files(
         'nfpcore/nfp_target.c',
         'nfpcore/nfp6000_pcie.c',
         'nfp_cpp_bridge.c',
-        'nfp_ctrl.c',
         'nfp_ethdev.c',
         'nfp_ethdev_vf.c',
         'nfp_flow.c',
@@ -37,6 +36,7 @@ sources = files(
         'nfp_logs.c',
         'nfp_mtr.c',
         'nfp_net_common.c',
+        'nfp_net_ctrl.c',
         'nfp_rxtx.c',
 )
 
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index f137e4b50c..af85e8575c 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -12,9 +12,9 @@
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
 
-#include "nfp_ctrl.h"
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
+#include "nfp_net_ctrl.h"
 #include "nfp_rxtx.h"
 
 #define NFP_UDP_ESP_PORT            4500
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index cf08df4618..8a02911c45 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -11,7 +11,7 @@
 #include <rte_io.h>
 #include <rte_spinlock.h>
 
-#include "nfp_ctrl.h"
+#include "nfp_net_ctrl.h"
 #include "nfpcore/nfp_dev.h"
 
 /* Macros for accessing the Queue Controller Peripheral 'CSRs' */
diff --git a/drivers/net/nfp/nfp_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
similarity index 98%
rename from drivers/net/nfp/nfp_ctrl.c
rename to drivers/net/nfp/nfp_net_ctrl.c
index a95e35c9a5..b0a427c98e 100644
--- a/drivers/net/nfp/nfp_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -3,7 +3,7 @@
  * All rights reserved.
  */
 
-#include "nfp_ctrl.h"
+#include "nfp_net_ctrl.h"
 
 #include <ethdev_pci.h>
 
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
similarity index 99%
rename from drivers/net/nfp/nfp_ctrl.h
rename to drivers/net/nfp/nfp_net_ctrl.h
index 9ec51e0a25..3772b28a66 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_net_ctrl.h
@@ -3,8 +3,8 @@
  * All rights reserved.
  */
 
-#ifndef __NFP_CTRL_H__
-#define __NFP_CTRL_H__
+#ifndef __NFP_NET_CTRL_H__
+#define __NFP_NET_CTRL_H__
 
 #include <stdint.h>
 
@@ -571,4 +571,4 @@ nfp_net_cfg_ctrl_rss(uint32_t hw_cap)
 	return NFP_NET_CFG_CTRL_RSS;
 }
 
-#endif /* __NFP_CTRL_H__ */
+#endif /* __NFP_NET_CTRL_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 05/25] net/nfp: extract the cap data field
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (3 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 04/25] net/nfp: rename ctrl " Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 06/25] net/nfp: extract the qcp " Chaoyong He
                       ` (22 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'cap' and 'cap_ext' data field into the super class, ready
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 |  6 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c  | 12 ++--
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  | 14 ++---
 drivers/net/nfp/nfp_ethdev.c        | 14 ++---
 drivers/net/nfp/nfp_ethdev_vf.c     | 10 +--
 drivers/net/nfp/nfp_ipsec.c         |  4 +-
 drivers/net/nfp/nfp_net_common.c    | 98 +++++++++++++++--------------
 drivers/net/nfp/nfp_net_common.h    | 10 ++-
 drivers/net/nfp/nfp_rxtx.c          |  2 +-
 9 files changed, 89 insertions(+), 81 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 60d843451e..453080f521 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -65,7 +65,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
+	if (hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
@@ -101,7 +101,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_RSS;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS2) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS2;
 	else
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS;
@@ -111,7 +111,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index b64dbaca0d..bbf4530ae9 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -30,7 +30,7 @@ nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
 		goto clean_txd;
 
 	ol_flags = mb->ol_flags;
@@ -69,7 +69,7 @@ nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
 		return;
 
 	ol_flags = mb->ol_flags;
@@ -127,8 +127,8 @@ nfp_net_nfd3_tx_vlan(struct nfp_net_txq *txq,
 {
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0 ||
-			(hw->cap & NFP_NET_CFG_CTRL_TXVLAN) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0 ||
+			(hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) == 0)
 		return;
 
 	if ((mb->ol_flags & RTE_MBUF_F_TX_VLAN) != 0) {
@@ -151,7 +151,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
 	uint8_t ipsec_layer = 0;
 
 	hw = txq->hw;
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
 			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
@@ -278,7 +278,7 @@ nfp_net_nfd3_xmit_pkts_common(void *tx_queue,
 		}
 
 		if (unlikely(pkt->nb_segs > 1 &&
-				(hw->cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
+				(hw->super.cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
 			PMD_TX_LOG(ERR, "Multisegment packet not supported");
 			goto xmit_end;
 		}
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 259039964a..807666686f 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -23,7 +23,7 @@ nfp_net_nfdk_tx_cksum(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
 		return flags;
 
 	ol_flags = mb->ol_flags;
@@ -57,7 +57,7 @@ nfp_net_nfdk_tx_tso(struct nfp_net_txq *txq,
 
 	txd.raw = 0;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
 		return txd.raw;
 
 	ol_flags = mb->ol_flags;
@@ -146,7 +146,7 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq,
 		return -EINVAL;
 
 	/* Count TSO descriptor */
-	if ((txq->hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+	if ((txq->hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 			(pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
 		n_descs++;
 
@@ -184,7 +184,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 
 	memset(&meta_data, 0, sizeof(meta_data));
 	hw = txq->hw;
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
 			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
@@ -322,7 +322,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 			nfp_net_nfdk_set_meta_data(pkt, txq, &metadata);
 
 		if (unlikely(pkt->nb_segs > 1 &&
-				(hw->cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
+				(hw->super.cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
 			PMD_TX_LOG(ERR, "Multisegment packet not supported");
 			goto xmit_end;
 		}
@@ -332,7 +332,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 		 * multisegment packet, but TSO info needs to be in all of them.
 		 */
 		dma_len = pkt->data_len;
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 				(pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) {
 			type = NFDK_DESC_TX_TYPE_TSO;
 		} else if (pkt->next == NULL && dma_len <= NFDK_TX_MAX_DATA_PER_HEAD) {
@@ -405,7 +405,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 		ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_cksum(txq, temp_pkt, metadata));
 		ktxds++;
 
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 				(temp_pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) {
 			ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_tso(txq, temp_pkt));
 			ktxds++;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index d32a82210c..8ac2acea7b 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -119,7 +119,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
 	}
 
 	/* Enable device */
@@ -128,19 +128,19 @@ nfp_net_start(struct rte_eth_dev *dev)
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
 	/* Enable vxlan */
-	if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
 		new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
 		update |= NFP_NET_CFG_UPDATE_VXLAN;
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/* Enable packet type offload by extend ctrl word1. */
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
 		ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
 
@@ -579,8 +579,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
 	nfp_net_log_device_information(hw);
 
@@ -608,7 +608,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	/* Copying mac address to DPDK eth_dev struct */
 	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 51c474275e..293d1ed53c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -86,7 +86,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
 	}
 
 	/* Enable device */
@@ -94,7 +94,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
@@ -314,8 +314,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
 	nfp_net_log_device_information(hw);
 
@@ -341,7 +341,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	/* Copying mac address to DPDK eth_dev struct */
 	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index af85e8575c..e080e71db2 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -1382,7 +1382,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return 0;
@@ -1429,7 +1429,7 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 189f81bbb6..77c0652642 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -408,7 +408,7 @@ nfp_net_configure(struct rte_eth_dev *dev)
 
 	/* Checking RX mode */
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+			(hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		PMD_DRV_LOG(ERR, "RSS not supported");
 		return -EINVAL;
 	}
@@ -426,27 +426,29 @@ nfp_net_configure(struct rte_eth_dev *dev)
 void
 nfp_net_log_device_information(const struct nfp_net_hw *hw)
 {
+	uint32_t cap = hw->super.cap;
+
 	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
 			hw->ver.major, hw->ver.minor, hw->max_mtu);
 
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
-			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
-			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2 ? "TXVLANv2 "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
-			hw->cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
-			hw->cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
-			hw->cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
-			hw->cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
-			hw->cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
+	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", cap,
+			cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
+			cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
+			cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
+			cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
+			cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
+			cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
+			cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
+			cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
+			cap & NFP_NET_CFG_CTRL_TXVLAN_V2 ? "TXVLANv2 "  : "",
+			cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
+			cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
+			cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
+			cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
+			cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
+			cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
+			cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
+			cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
 
 	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
 			hw->max_rx_queues, hw->max_tx_queues);
@@ -456,9 +458,9 @@ static inline void
 nfp_net_enable_rxvlan_cap(struct nfp_net_hw *hw,
 		uint32_t *ctrl)
 {
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0)
 		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN_V2;
-	else if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN) != 0)
+	else if ((hw->super.cap & NFP_NET_CFG_CTRL_RXVLAN) != 0)
 		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN;
 }
 
@@ -503,7 +505,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
@@ -552,7 +554,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
+			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
 	}
@@ -563,7 +565,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
+			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
 	/* Signal the NIC about the change */
@@ -631,7 +633,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	tx_offload = dev_conf->txmode.offloads;
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXCSUM;
 	}
 
@@ -639,25 +641,25 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 		nfp_net_enable_rxvlan_cap(hw, &ctrl);
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
 	hw->mtu = dev->data->mtu;
 
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2;
-		else if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
+		else if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
 	}
 
 	/* L2 broadcast */
-	if ((hw->cap & NFP_NET_CFG_CTRL_L2BC) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2BC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2BC;
 
 	/* L2 multicast */
-	if ((hw->cap & NFP_NET_CFG_CTRL_L2MC) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2MC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2MC;
 
 	/* TX checksum offload */
@@ -669,7 +671,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	/* LSO offload */
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 ||
 			(tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_LSO;
 		else
 			ctrl |= NFP_NET_CFG_CTRL_LSO2;
@@ -698,7 +700,7 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev)
 		hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(ERR, "Promiscuous mode not supported");
 		return -ENOTSUP;
 	}
@@ -1213,35 +1215,35 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
-	if ((hw->cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
+	if ((hw->super.cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
+	if ((hw->super.cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
 		dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
-		if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
 			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_GATHER) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_GATHER) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SECURITY;
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SECURITY;
@@ -1281,7 +1283,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG,
 	};
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
 		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
@@ -1334,8 +1336,8 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 		return -ENODEV;
 
 	/* Get some of the read-only fields from the config BAR */
-	hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
-	hw->cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	hw->super.cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
+	hw->super.cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
 	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
 	hw->flbufsz = DEFAULT_FLBUF_SIZE;
 
@@ -2025,14 +2027,14 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw)
 	 */
 	if (hw->ver.major == 4) {
 		hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
-	} else if ((hw->cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
+	} else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
 		hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
 		/*
-		 * RSS is incompatible with chained metadata. hw->cap just represents
+		 * RSS is incompatible with chained metadata. hw->super.cap just represents
 		 * firmware's ability rather than the firmware's configuration. We decide
-		 * to reduce the confusion to allow us can use hw->cap to identify RSS later.
+		 * to reduce the confusion to allow us can use hw->super.cap to identify RSS later.
 		 */
-		hw->cap &= ~NFP_NET_CFG_CTRL_RSS;
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_RSS;
 	} else {
 		hw->meta_format = NFP_NET_METAFORMAT_SINGLE;
 	}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 8a02911c45..7bcdd9295f 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -112,7 +112,15 @@ struct nfp_app_fw_nic {
 	uint8_t total_phyports;
 };
 
+struct nfp_hw {
+	uint32_t cap;
+	uint32_t cap_ext;
+};
+
 struct nfp_net_hw {
+	/** The parent class */
+	struct nfp_hw super;
+
 	/** Backpointer to the PF this port belongs to */
 	struct nfp_pf_dev *pf_dev;
 
@@ -120,9 +128,7 @@ struct nfp_net_hw {
 	struct rte_eth_dev *eth_dev;
 
 	/** Info from the firmware */
-	uint32_t cap_ext;
 	struct nfp_net_fw_ver ver;
-	uint32_t cap;
 	uint32_t max_mtu;
 	uint32_t mtu;
 	uint32_t rx_offset;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index efdca7fccf..a0c7e0e9b5 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -386,7 +386,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 	struct nfp_net_hw *hw = rxq->hw;
 
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
-			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
+			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
 	if (meta->vlan_layer < NFP_META_MAX_VLANS)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 06/25] net/nfp: extract the qcp data field
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (4 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 05/25] net/nfp: extract the cap data field Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
                       ` (21 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'qcp_cfg' data field 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/nfp_net_common.c | 8 ++++----
 drivers/net/nfp/nfp_net_common.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 77c0652642..cb64fa13c5 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -206,14 +206,14 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 	struct timespec wait;
 
 	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->qcp_cfg);
+			hw->super.qcp_cfg);
 
-	if (hw->qcp_cfg == NULL) {
+	if (hw->super.qcp_cfg == NULL) {
 		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
 		return -ENXIO;
 	}
 
-	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+	nfp_qcp_ptr_add(hw->super.qcp_cfg, NFP_QCP_WRITE_PTR, 1);
 
 	wait.tv_sec = 0;
 	wait.tv_nsec = 1000000; /* 1ms */
@@ -525,7 +525,7 @@ nfp_net_params_setup(struct nfp_net_hw *hw)
 void
 nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 {
-	hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
+	hw->super.qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }
 
 void
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 7bcdd9295f..4bfb3174b0 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 *qcp_cfg;
 	uint32_t cap;
 	uint32_t cap_ext;
 };
@@ -150,7 +151,6 @@ struct nfp_net_hw {
 	uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
 	uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
 
-	uint8_t *qcp_cfg;
 	rte_spinlock_t reconfig_lock;
 
 	uint32_t max_tx_queues;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 07/25] net/nfp: extract the ctrl BAR data field
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (5 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 06/25] net/nfp: extract the qcp " Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 08/25] net/nfp: extract the ctrl " Chaoyong He
                       ` (20 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

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(-)

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;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 08/25] net/nfp: extract the ctrl data field
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (6 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 09/25] net/nfp: change the parameter of APIs Chaoyong He
                       ` (19 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'ctrl' 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/nfd3/nfp_nfd3_dp.c  |  2 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  |  2 +-
 drivers/net/nfp/nfp_ethdev.c        |  4 ++-
 drivers/net/nfp/nfp_ethdev_vf.c     |  2 +-
 drivers/net/nfp/nfp_net_common.c    | 46 ++++++++++++++---------------
 drivers/net/nfp/nfp_net_common.h    |  5 ++--
 drivers/net/nfp/nfp_rxtx.c          | 12 ++++----
 8 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index c8455e0241..8bb5914888 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -61,7 +61,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
 	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
@@ -72,7 +72,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 }
 
 int
@@ -123,7 +123,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 		return -EIO;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
@@ -721,7 +721,7 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 		return -EIO;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index bbf4530ae9..3045533857 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -154,7 +154,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
 	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+			(hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
 		if (meta_data->length == 0)
 			meta_data->length = NFP_NET_META_HEADER_SIZE;
 		meta_data->length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 807666686f..63421ba796 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -187,7 +187,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+			(hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
 		if (meta_data.length == 0)
 			meta_data.length = NFP_NET_META_HEADER_SIZE;
 		meta_data.length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index b7c60b642f..0f6f97be8e 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -152,6 +152,8 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if (nfp_net_ext_reconfig(hw, ctrl_extend, update) != 0)
 		return -EIO;
 
+	hw->super.ctrl_ext = ctrl_extend;
+
 	/*
 	 * Allocating rte mbufs for configured rx queues.
 	 * This requires queues being enabled before.
@@ -167,7 +169,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	else
 		nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 1);
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 641fed6fcf..684968903c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -110,7 +110,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 29f836c31e..058260bda3 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -500,7 +500,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
 	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
@@ -512,7 +512,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 }
 
 void
@@ -553,7 +553,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	struct nfp_net_hw *hw;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
 			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
@@ -563,8 +563,8 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
-	ctrl = hw->ctrl;
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+	ctrl = hw->super.ctrl;
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
 			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
@@ -613,7 +613,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 	}
 
 	/* Avoiding TX interrupts */
-	hw->ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
+	hw->super.ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
 	return 0;
 }
 
@@ -705,19 +705,19 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already enabled");
 		return 0;
 	}
 
-	new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->super.ctrl | NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -732,19 +732,19 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already disabled");
 		return 0;
 	}
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1349,7 +1349,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 	else
 		hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
 
-	hw->ctrl = 0;
+	hw->super.ctrl = 0;
 	hw->stride_rx = stride;
 	hw->stride_tx = stride;
 
@@ -1453,7 +1453,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
 	/* Make sure all updates are written before un-masking */
 	rte_wmb();
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
 		/* If MSI-X auto-masking is used, clear the entry */
 		rte_intr_ack(pci_dev->intr_handle);
 	} else {
@@ -1559,7 +1559,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	rx_offload = dev->data->dev_conf.rxmode.offloads;
-	new_ctrl = hw->ctrl;
+	new_ctrl = hw->super.ctrl;
 
 	/* VLAN stripping setting */
 	if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) {
@@ -1578,7 +1578,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 			new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
-	if (new_ctrl == hw->ctrl)
+	if (new_ctrl == hw->super.ctrl)
 		return 0;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
@@ -1587,7 +1587,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1660,7 +1660,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 	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)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size);
@@ -1669,7 +1669,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1690,7 +1690,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 	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)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
@@ -1795,7 +1795,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 	rss_hf = rss_conf->rss_hf;
 
 	/* Checking if RSS is enabled */
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		if (rss_hf != 0) {
 			PMD_DRV_LOG(ERR, "RSS unsupported");
 			return -EINVAL;
@@ -1813,7 +1813,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1831,7 +1831,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index dd62ec6d83..3fb3b34613 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -117,6 +117,8 @@ struct nfp_hw {
 	uint8_t *qcp_cfg;
 	uint32_t cap;
 	uint32_t cap_ext;
+	uint32_t ctrl;
+	uint32_t ctrl_ext;
 };
 
 struct nfp_net_hw {
@@ -139,9 +141,6 @@ struct nfp_net_hw {
 	/** NFP ASIC params */
 	const struct nfp_dev_info *dev_info;
 
-	/** Current values for control */
-	uint32_t ctrl;
-
 	uint8_t *tx_bar;
 	uint8_t *rx_bar;
 
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index a0c7e0e9b5..a9dd464a6a 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -143,7 +143,7 @@ nfp_net_rx_cksum(struct nfp_net_rxq *rxq,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
 		return;
 
 	/* If IPv4 and IP checksum error, fail */
@@ -307,7 +307,7 @@ nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return;
 
 	mbuf->hash.rss = meta->hash;
@@ -339,7 +339,7 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	struct nfp_net_hw *hw = rxq->hw;
 
 	/* Skip if firmware don't support setting vlan. */
-	if ((hw->ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
+	if ((hw->super.ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
 	/*
@@ -347,12 +347,12 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	 * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
 	 * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
 	 */
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
 		if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
 		}
-	} else if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+	} else if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
 		if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
@@ -385,7 +385,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
 			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 09/25] net/nfp: change the parameter of APIs
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (7 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 08/25] net/nfp: extract the ctrl " Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 10/25] net/nfp: change the parameter of reconfig Chaoyong He
                       ` (18 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Change the parameter of some APIs from 'struct nfp_net_hw' into the
super class 'struct nfp_hw', 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           |  24 ++--
 .../net/nfp/flower/nfp_flower_representor.c   |  10 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c            |   4 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c            |   4 +-
 drivers/net/nfp/nfp_ethdev.c                  |   8 +-
 drivers/net/nfp/nfp_ethdev_vf.c               |  12 +-
 drivers/net/nfp/nfp_ipsec.c                   |   4 +-
 drivers/net/nfp/nfp_net_common.c              | 129 +++++++++---------
 drivers/net/nfp/nfp_net_common.h              |  32 ++---
 drivers/net/nfp/nfp_rxtx.c                    |   4 +-
 10 files changed, 116 insertions(+), 115 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 8bb5914888..ccb579541b 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -36,7 +36,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	enabled_queues = 0;
 
@@ -44,7 +44,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 static void
@@ -58,8 +58,8 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	repr = dev->data->dev_private;
 	hw = repr->app_fw_flower->pf_hw;
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
 
 	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
@@ -114,7 +114,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
 
 	/* If an error when reconfig we avoid to change hw state */
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
@@ -219,7 +219,7 @@ nfp_flower_pf_close(struct rte_eth_dev *dev)
 	/* Cancel possible impending LSC work here before releasing the port */
 	rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler, (void *)dev);
 
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
 
 	/* Now it is safe to free all PF resources */
 	PMD_DRV_LOG(INFO, "Freeing PF resources");
@@ -356,9 +356,9 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw,
 		return err;
 
 	/* Work out where in the BAR the queues start */
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = (uint64_t)start_q * NFP_QCP_QUEUE_ADDR_SZ;
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = (uint64_t)start_q * NFP_QCP_QUEUE_ADDR_SZ;
 
 	hw->tx_bar = pf_dev->qc_bar + tx_bar_off;
@@ -543,8 +543,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 		 * Telling the HW about the physical address of the RX ring and number
 		 * of descriptors in log2 format.
 		 */
-		nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(i), rxq->dma);
-		nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
+		nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(i), rxq->dma);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
 	}
 
 	snprintf(ctrl_txring_name, sizeof(ctrl_txring_name), "%s_cttx_ring", pci_name);
@@ -608,8 +608,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 		 * Telling the HW about the physical address of the TX ring and number
 		 * of descriptors in log2 format.
 		 */
-		nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(i), txq->dma);
-		nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
+		nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(i), txq->dma);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
 	}
 
 	return 0;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 650f09a475..b52c6f514a 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -97,8 +97,8 @@ nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the RX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
@@ -181,8 +181,8 @@ nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
@@ -228,7 +228,7 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,
 				}
 			}
 		} else {
-			nn_link_status = nn_cfg_readw(pf_hw, NFP_NET_CFG_STS);
+			nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS);
 			nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) &
 					NFP_NET_CFG_STS_LINK_RATE_MASK;
 
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 3045533857..c85fadc80d 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -465,8 +465,8 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
 
 	return 0;
 }
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 63421ba796..3f8d25aa29 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -542,8 +542,8 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
 
 	return 0;
 }
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 0f6f97be8e..a773a81e55 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -286,7 +286,7 @@ nfp_net_close(struct rte_eth_dev *dev)
 
 	/* Only free PF resources after all physical ports have been closed */
 	/* Mark this port as unused and free device priv resources */
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
 	app_fw_nic->ports[hw->idx] = NULL;
 
 	for (i = 0; i < app_fw_nic->total_phyports; i++) {
@@ -567,8 +567,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* Work out where in the BAR the queues start. */
-	tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
-	rx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	tx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
+	rx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 
 	hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
 	hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
@@ -625,7 +625,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	rte_intr_callback_register(pci_dev->intr_handle,
 			nfp_net_dev_interrupt_handler, (void *)eth_dev);
 	/* Telling the firmware about the LSC interrupt entry */
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 	/* Recording current stats counters values */
 	nfp_net_stats_reset(eth_dev);
 
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 684968903c..7fb2a3d378 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -20,10 +20,10 @@ nfp_netvf_read_mac(struct nfp_net_hw *hw)
 {
 	uint32_t tmp;
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR));
 	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR + 4));
 	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
 }
 
@@ -97,7 +97,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
@@ -299,9 +299,9 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* Work out where in the BAR the queues start. */
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
 
 	hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
@@ -357,7 +357,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		rte_intr_callback_register(pci_dev->intr_handle,
 				nfp_net_dev_interrupt_handler, (void *)eth_dev);
 		/* Telling the firmware about the LSC interrupt entry */
-		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 		/* Recording current stats counters values */
 		nfp_net_stats_reset(eth_dev);
 	}
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index e080e71db2..0da5c2a3d2 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -445,7 +445,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	msg->rsp = NFP_IPSEC_CFG_MSG_OK;
 
 	for (i = 0; i < msg_size; i++)
-		nn_cfg_writel(hw, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
 
 	ret = nfp_net_mbox_reconfig(hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
 	if (ret < 0) {
@@ -459,7 +459,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	 * response. One example where the data is needed is for statistics.
 	 */
 	for (i = 0; i < msg_size; i++)
-		msg->raw[i] = nn_cfg_readl(hw, NFP_NET_CFG_MBOX_VAL + 4 * i);
+		msg->raw[i] = nn_cfg_readl(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
 
 	switch (msg->rsp) {
 	case NFP_IPSEC_CFG_MSG_OK:
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 058260bda3..2ab8d8fadd 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -182,7 +182,8 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 	 * NFP_NET_CFG_STS_NSP_LINK_RATE.
 	 */
 	if (link->link_status == RTE_ETH_LINK_DOWN) {
-		nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE, NFP_NET_CFG_STS_LINK_RATE_UNKNOWN);
+		nn_cfg_writew(&hw->super, NFP_NET_CFG_STS_NSP_LINK_RATE,
+				NFP_NET_CFG_STS_LINK_RATE_UNKNOWN);
 		return;
 	}
 
@@ -190,7 +191,7 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 	 * Link is up so write the link speed from the eth_table to
 	 * NFP_NET_CFG_STS_NSP_LINK_RATE.
 	 */
-	nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE,
+	nn_cfg_writew(&hw->super, NFP_NET_CFG_STS_NSP_LINK_RATE,
 			nfp_net_link_speed_rte2nfp(link->link_speed));
 }
 
@@ -222,7 +223,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	/* Poll update field, waiting for NFP to ack the config */
 	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
+		new = nn_cfg_readl(&hw->super, NFP_NET_CFG_UPDATE);
 		if (new == 0)
 			break;
 
@@ -270,8 +271,8 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
@@ -314,8 +315,8 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
@@ -355,8 +356,8 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writeq(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
+	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
@@ -370,7 +371,7 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 		return -EIO;
 	}
 
-	return nn_cfg_readl(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
+	return nn_cfg_readl(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
 }
 
 /*
@@ -478,14 +479,14 @@ nfp_net_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	/* Enabling the required RX queues in the device */
 	enabled_queues = 0;
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 void
@@ -497,8 +498,8 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
 
 	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
@@ -518,8 +519,8 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 void
 nfp_net_params_setup(struct nfp_net_hw *hw)
 {
-	nn_cfg_writel(hw, NFP_NET_CFG_MTU, hw->mtu);
-	nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_MTU, hw->mtu);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
 }
 
 void
@@ -596,7 +597,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 	if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) {
 		PMD_DRV_LOG(INFO, "VF: enabling RX interrupt with UIO");
 		/* UIO just supports one queue and no LSC */
-		nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(0), 0);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_VEC(0), 0);
 		if (rte_intr_vec_list_index_set(intr_handle, 0, 0) != 0)
 			return -1;
 	} else {
@@ -606,7 +607,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 			 * The first msix vector is reserved for non
 			 * efd interrupts.
 			 */
-			nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(i), i + 1);
+			nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_VEC(i), i + 1);
 			if (rte_intr_vec_list_index_set(intr_handle, i, i + 1) != 0)
 				return -1;
 		}
@@ -771,7 +772,7 @@ nfp_net_link_update(struct rte_eth_dev *dev,
 	memset(&link, 0, sizeof(struct rte_eth_link));
 
 	/* Read link status */
-	nn_link_status = nn_cfg_readw(hw, NFP_NET_CFG_STS);
+	nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS);
 	if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0)
 		link.link_status = RTE_ETH_LINK_UP;
 
@@ -842,12 +843,12 @@ nfp_net_stats_get(struct rte_eth_dev *dev,
 			break;
 
 		nfp_dev_stats.q_ipackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i));
 		nfp_dev_stats.q_ipackets[i] -=
 				hw->eth_stats_base.q_ipackets[i];
 
 		nfp_dev_stats.q_ibytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i) + 0x8);
 		nfp_dev_stats.q_ibytes[i] -=
 				hw->eth_stats_base.q_ibytes[i];
 	}
@@ -858,42 +859,42 @@ nfp_net_stats_get(struct rte_eth_dev *dev,
 			break;
 
 		nfp_dev_stats.q_opackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i));
 		nfp_dev_stats.q_opackets[i] -= hw->eth_stats_base.q_opackets[i];
 
 		nfp_dev_stats.q_obytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i) + 0x8);
 		nfp_dev_stats.q_obytes[i] -= hw->eth_stats_base.q_obytes[i];
 	}
 
-	nfp_dev_stats.ipackets = nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES);
+	nfp_dev_stats.ipackets = nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_FRAMES);
 	nfp_dev_stats.ipackets -= hw->eth_stats_base.ipackets;
 
-	nfp_dev_stats.ibytes = nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS);
+	nfp_dev_stats.ibytes = nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_OCTETS);
 	nfp_dev_stats.ibytes -= hw->eth_stats_base.ibytes;
 
 	nfp_dev_stats.opackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_FRAMES);
 	nfp_dev_stats.opackets -= hw->eth_stats_base.opackets;
 
 	nfp_dev_stats.obytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_OCTETS);
 	nfp_dev_stats.obytes -= hw->eth_stats_base.obytes;
 
 	/* Reading general device stats */
 	nfp_dev_stats.ierrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_ERRORS);
 	nfp_dev_stats.ierrors -= hw->eth_stats_base.ierrors;
 
 	nfp_dev_stats.oerrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_ERRORS);
 	nfp_dev_stats.oerrors -= hw->eth_stats_base.oerrors;
 
 	/* RX ring mbuf allocation failures */
 	nfp_dev_stats.rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 
 	nfp_dev_stats.imissed =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_DISCARDS);
 	nfp_dev_stats.imissed -= hw->eth_stats_base.imissed;
 
 	memcpy(stats, &nfp_dev_stats, sizeof(*stats));
@@ -918,10 +919,10 @@ nfp_net_stats_reset(struct rte_eth_dev *dev)
 			break;
 
 		hw->eth_stats_base.q_ipackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i));
 
 		hw->eth_stats_base.q_ibytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i) + 0x8);
 	}
 
 	/* Reading per TX ring stats */
@@ -930,36 +931,36 @@ nfp_net_stats_reset(struct rte_eth_dev *dev)
 			break;
 
 		hw->eth_stats_base.q_opackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i));
 
 		hw->eth_stats_base.q_obytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i) + 0x8);
 	}
 
 	hw->eth_stats_base.ipackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_FRAMES);
 
 	hw->eth_stats_base.ibytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_OCTETS);
 
 	hw->eth_stats_base.opackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_FRAMES);
 
 	hw->eth_stats_base.obytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_OCTETS);
 
 	/* Reading general device stats */
 	hw->eth_stats_base.ierrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_ERRORS);
 
 	hw->eth_stats_base.oerrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_ERRORS);
 
 	/* RX ring mbuf allocation failures */
 	dev->data->rx_mbuf_alloc_failed = 0;
 
 	hw->eth_stats_base.imissed =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_DISCARDS);
 
 	return 0;
 }
@@ -1012,7 +1013,7 @@ nfp_net_xstats_value(const struct rte_eth_dev *dev,
 	if (xstat.group == NFP_XSTAT_GROUP_MAC)
 		value = nn_readq(hw->mac_stats + xstat.offset);
 	else
-		value = nn_cfg_readq(hw, xstat.offset);
+		value = nn_cfg_readq(&hw->super, xstat.offset);
 
 	if (raw)
 		return value;
@@ -1320,8 +1321,8 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 	hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
 	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
 
-	hw->max_rx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_RXRINGS);
-	hw->max_tx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_TXRINGS);
+	hw->max_rx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_RXRINGS);
+	hw->max_tx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_TXRINGS);
 	if (hw->max_rx_queues == 0 || hw->max_tx_queues == 0) {
 		PMD_INIT_LOG(ERR, "Device %s can not be used, there are no valid queue "
 				"pairs for use", pci_dev->name);
@@ -1336,9 +1337,9 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 		return -ENODEV;
 
 	/* Get some of the read-only fields from the config BAR */
-	hw->super.cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
-	hw->super.cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
-	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
+	hw->super.cap = nn_cfg_readl(&hw->super, NFP_NET_CFG_CAP);
+	hw->super.cap_ext = nn_cfg_readl(&hw->super, NFP_NET_CFG_CAP_WORD1);
+	hw->max_mtu = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_MTU);
 	hw->flbufsz = DEFAULT_FLBUF_SIZE;
 
 	nfp_net_init_metadata_format(hw);
@@ -1347,7 +1348,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, NFP_NET_CFG_RX_OFFSET_ADDR);
+		hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET_ADDR);
 
 	hw->super.ctrl = 0;
 	hw->stride_rx = stride;
@@ -1389,7 +1390,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev,
 	rte_wmb();
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id),
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id),
 			NFP_NET_CFG_ICR_UNMASKED);
 	return 0;
 }
@@ -1410,7 +1411,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev,
 	rte_wmb();
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX);
 
 	return 0;
 }
@@ -1457,7 +1458,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
 		/* If MSI-X auto-masking is used, clear the entry */
 		rte_intr_ack(pci_dev->intr_handle);
 	} else {
-		nn_cfg_writeb(hw, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX),
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX),
 				NFP_NET_CFG_ICR_UNMASKED);
 	}
 }
@@ -1539,7 +1540,7 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev,
 	}
 
 	/* Writing to configuration space */
-	nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_MTU, mtu);
 
 	hw->mtu = mtu;
 
@@ -1630,7 +1631,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 
 		/* If all 4 entries were set, don't need read RETA register */
 		if (mask != 0xF)
-			reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + i);
+			reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + i);
 
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
@@ -1643,7 +1644,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 			reta |= reta_conf[idx].reta[shift + j] << (8 * j);
 		}
 
-		nn_cfg_writel(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
 	}
 
 	return 0;
@@ -1713,7 +1714,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 		if (mask == 0)
 			continue;
 
-		reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
+		reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
 				continue;
@@ -1741,7 +1742,7 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	/* Writing the key byte by byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
 		memcpy(&key, &rss_conf->rss_key[i], 1);
-		nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY + i, key);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY + i, key);
 	}
 
 	rss_hf = rss_conf->rss_hf;
@@ -1774,10 +1775,10 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
-	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
 
 	/* Writing the key size */
-	nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
 
 	return 0;
 }
@@ -1835,7 +1836,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
-	cfg_rss_ctrl = nn_cfg_readl(hw, NFP_NET_CFG_RSS_CTRL);
+	cfg_rss_ctrl = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_CTRL);
 
 	if ((cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4) != 0)
 		rss_hf |= RTE_ETH_RSS_IPV4;
@@ -1865,11 +1866,11 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	rss_conf->rss_hf = rss_hf;
 
 	/* Reading the key size */
-	rss_conf->rss_key_len = nn_cfg_readl(hw, NFP_NET_CFG_RSS_KEY_SZ);
+	rss_conf->rss_key_len = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_KEY_SZ);
 
 	/* Reading the key byte a byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
-		key = nn_cfg_readb(hw, NFP_NET_CFG_RSS_KEY + i);
+		key = nn_cfg_readb(&hw->super, NFP_NET_CFG_RSS_KEY + i);
 		memcpy(&rss_conf->rss_key[i], &key, 1);
 	}
 
@@ -1983,13 +1984,13 @@ nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
 	hw->vxlan_ports[idx] = port;
 
 	for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) {
-		nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
 				(hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]);
 	}
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
 	rte_wmb();
 
 	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN);
@@ -2048,7 +2049,7 @@ nfp_net_cfg_read_version(struct nfp_net_hw *hw)
 		struct nfp_net_fw_ver split;
 	} version;
 
-	version.whole = nn_cfg_readl(hw, NFP_NET_CFG_VERSION);
+	version.whole = nn_cfg_readl(&hw->super, NFP_NET_CFG_VERSION);
 	hw->ver = version.split;
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 3fb3b34613..3fe3e96107 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -247,63 +247,63 @@ nn_writeq(uint64_t val,
 }
 
 static inline uint8_t
-nn_cfg_readb(struct nfp_net_hw *hw,
+nn_cfg_readb(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return nn_readb(hw->super.ctrl_bar + off);
+	return nn_readb(hw->ctrl_bar + off);
 }
 
 static inline void
-nn_cfg_writeb(struct nfp_net_hw *hw,
+nn_cfg_writeb(struct nfp_hw *hw,
 		uint32_t off,
 		uint8_t val)
 {
-	nn_writeb(val, hw->super.ctrl_bar + off);
+	nn_writeb(val, hw->ctrl_bar + off);
 }
 
 static inline uint16_t
-nn_cfg_readw(struct nfp_net_hw *hw,
+nn_cfg_readw(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_16(nn_readw(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writew(struct nfp_net_hw *hw,
+nn_cfg_writew(struct nfp_hw *hw,
 		uint32_t off,
 		uint16_t val)
 {
-	nn_writew(rte_cpu_to_le_16(val), hw->super.ctrl_bar + off);
+	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
 }
 
 static inline uint32_t
-nn_cfg_readl(struct nfp_net_hw *hw,
+nn_cfg_readl(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_32(nn_readl(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writel(struct nfp_net_hw *hw,
+nn_cfg_writel(struct nfp_hw *hw,
 		uint32_t off,
 		uint32_t val)
 {
-	nn_writel(rte_cpu_to_le_32(val), hw->super.ctrl_bar + off);
+	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
 }
 
 static inline uint64_t
-nn_cfg_readq(struct nfp_net_hw *hw,
+nn_cfg_readq(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_64(nn_readq(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writeq(struct nfp_net_hw *hw,
+nn_cfg_writeq(struct nfp_hw *hw,
 		uint32_t off,
 		uint64_t val)
 {
-	nn_writeq(rte_cpu_to_le_64(val), hw->super.ctrl_bar + off);
+	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
 }
 
 /**
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index a9dd464a6a..f17cc13cc1 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -925,8 +925,8 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the RX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 10/25] net/nfp: change the parameter of reconfig
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (8 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 09/25] net/nfp: change the parameter of APIs Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 11/25] net/nfp: extract the MAC address data field Chaoyong He
                       ` (17 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'reconfig_lock' data field into the super class, also change
the parameter of the related APIs, 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 |  50 +++++----
 drivers/net/nfp/nfp_ethdev.c        |  34 +++---
 drivers/net/nfp/nfp_ethdev_vf.c     |  20 ++--
 drivers/net/nfp/nfp_net_common.c    | 161 +++++++++++++++-------------
 drivers/net/nfp/nfp_net_common.h    |   7 +-
 5 files changed, 149 insertions(+), 123 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index ccb579541b..831f4a7265 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -52,27 +52,29 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 {
 	uint32_t update;
 	uint32_t new_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	net_hw = repr->app_fw_flower->pf_hw;
+	hw = &net_hw->super;
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if (hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG)
+	if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) < 0)
 		return;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 }
 
 int
@@ -80,13 +82,15 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	net_hw = repr->app_fw_flower->pf_hw;
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_pf_repr_disable_queues(dev);
@@ -97,11 +101,11 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	update |= NFP_NET_CFG_UPDATE_RSS;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS2) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS2;
 	else
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS;
@@ -111,19 +115,19 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
 
 	/* If an error when reconfig we avoid to change hw state */
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to reconfig PF vnic");
 		return -EIO;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
@@ -374,7 +378,7 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw,
 			vnic_type, hw->max_rx_queues, hw->max_tx_queues);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	return 0;
 }
@@ -690,14 +694,16 @@ nfp_flower_cleanup_ctrl_vnic(struct nfp_net_hw *hw)
 }
 
 static int
-nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
+nfp_flower_start_ctrl_vnic(struct nfp_net_hw *net_hw)
 {
 	int ret;
 	uint32_t update;
 	uint32_t new_ctrl;
+	struct nfp_hw *hw;
 	struct rte_eth_dev *dev;
 
-	dev = hw->eth_dev;
+	dev = net_hw->eth_dev;
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_net_disable_queues(dev);
@@ -706,7 +712,7 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 	nfp_net_enable_queues(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	new_ctrl = NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
@@ -715,13 +721,13 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 	rte_wmb();
 
 	/* If an error when reconfig we avoid to change hw state */
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to reconfig ctrl vnic");
 		return -EIO;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index a773a81e55..1378545d22 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -45,12 +45,13 @@ nfp_net_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	uint32_t cap_extend;
 	uint32_t intr_vector;
-	struct nfp_net_hw *hw;
 	uint32_t ctrl_extend = 0;
+	struct nfp_net_hw *net_hw;
 	struct nfp_pf_dev *pf_dev;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
@@ -58,9 +59,10 @@ 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;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_net_disable_queues(dev);
@@ -100,9 +102,9 @@ nfp_net_start(struct rte_eth_dev *dev)
 	}
 
 	/* Checking MTU set */
-	if (dev->data->mtu > hw->flbufsz) {
+	if (dev->data->mtu > net_hw->flbufsz) {
 		PMD_INIT_LOG(ERR, "MTU (%u) can't be larger than the current NFP_FRAME_SIZE (%u)",
-				dev->data->mtu, hw->flbufsz);
+				dev->data->mtu, net_hw->flbufsz);
 		return -ERANGE;
 	}
 
@@ -111,7 +113,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	dev_conf = &dev->data->dev_conf;
 	rxmode = &dev_conf->rxmode;
@@ -119,7 +121,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
 	}
 
 	/* Enable device */
@@ -128,19 +130,19 @@ nfp_net_start(struct rte_eth_dev *dev)
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
 	/* Enable vxlan */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
+	if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
 		new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
 		update |= NFP_NET_CFG_UPDATE_VXLAN;
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/* Enable packet type offload by extend ctrl word1. */
-	cap_extend = hw->super.cap_ext;
+	cap_extend = hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
 		ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
 
@@ -149,10 +151,10 @@ nfp_net_start(struct rte_eth_dev *dev)
 				| NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
-	if (nfp_net_ext_reconfig(hw, ctrl_extend, update) != 0)
+	if (nfp_ext_reconfig(hw, ctrl_extend, update) != 0)
 		return -EIO;
 
-	hw->super.ctrl_ext = ctrl_extend;
+	hw->ctrl_ext = ctrl_extend;
 
 	/*
 	 * Allocating rte mbufs for configured rx queues.
@@ -165,11 +167,11 @@ nfp_net_start(struct rte_eth_dev *dev)
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		/* Configure the physical port up */
-		nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 1);
+		nfp_eth_set_configured(net_hw->cpp, net_hw->nfp_idx, 1);
 	else
-		nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 1);
+		nfp_eth_set_configured(dev->process_private, net_hw->nfp_idx, 1);
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
@@ -587,7 +589,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 7fb2a3d378..6ead7e02b8 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -32,10 +32,11 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	uint32_t intr_vector;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
@@ -77,8 +78,9 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nfp_net_params_setup(hw);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+	nfp_net_params_setup(net_hw);
 
 	dev_conf = &dev->data->dev_conf;
 	rxmode = &dev_conf->rxmode;
@@ -86,7 +88,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
 	}
 
 	/* Enable device */
@@ -94,11 +96,11 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/*
@@ -110,7 +112,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
@@ -320,7 +322,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 2ab8d8fadd..9e6d2fa490 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -199,7 +199,7 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 #define FW_VER_LEN        32
 
 static int
-__nfp_net_reconfig(struct nfp_net_hw *hw,
+nfp_reconfig_real(struct nfp_hw *hw,
 		uint32_t update)
 {
 	uint32_t cnt;
@@ -207,14 +207,14 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 	struct timespec wait;
 
 	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->super.qcp_cfg);
+			hw->qcp_cfg);
 
-	if (hw->super.qcp_cfg == NULL) {
+	if (hw->qcp_cfg == NULL) {
 		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
 		return -ENXIO;
 	}
 
-	nfp_qcp_ptr_add(hw->super.qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
 
 	wait.tv_sec = 0;
 	wait.tv_nsec = 1000000; /* 1ms */
@@ -223,7 +223,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	/* Poll update field, waiting for NFP to ack the config */
 	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(&hw->super, NFP_NET_CFG_UPDATE);
+		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
 		if (new == 0)
 			break;
 
@@ -263,7 +263,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure the device.
  */
 int
-nfp_net_reconfig(struct nfp_net_hw *hw,
+nfp_reconfig(struct nfp_hw *hw,
 		uint32_t ctrl,
 		uint32_t update)
 {
@@ -271,17 +271,17 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, update);
+	ret = nfp_reconfig_real(hw, update);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
 	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp net reconfig: ctrl=%#08x update=%#08x",
+		PMD_DRV_LOG(ERR, "Error nfp reconfig: ctrl=%#08x update=%#08x",
 				ctrl, update);
 		return -EIO;
 	}
@@ -307,7 +307,7 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure the device.
  */
 int
-nfp_net_ext_reconfig(struct nfp_net_hw *hw,
+nfp_ext_reconfig(struct nfp_hw *hw,
 		uint32_t ctrl_ext,
 		uint32_t update)
 {
@@ -315,17 +315,17 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, update);
+	ret = nfp_reconfig_real(hw, update);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
 	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nft net ext reconfig: ctrl_ext=%#08x update=%#08x",
+		PMD_DRV_LOG(ERR, "Error nfp ext reconfig: ctrl_ext=%#08x update=%#08x",
 				ctrl_ext, update);
 		return -EIO;
 	}
@@ -354,16 +354,16 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 
 	mbox = hw->tlv_caps.mbox_off;
 
-	rte_spinlock_lock(&hw->reconfig_lock);
+	rte_spinlock_lock(&hw->super.reconfig_lock);
 
 	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
 	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_MBOX);
+	ret = nfp_reconfig_real(&hw->super, NFP_NET_CFG_UPDATE_MBOX);
 
-	rte_spinlock_unlock(&hw->reconfig_lock);
+	rte_spinlock_unlock(&hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net mailbox reconfig: mbox=%#08x update=%#08x",
@@ -494,26 +494,28 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 {
 	uint32_t update;
 	uint32_t new_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 }
 
 void
@@ -551,26 +553,28 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 {
 	uint32_t ctrl;
 	uint32_t update;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
+	nfp_net_write_mac(net_hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
-	ctrl = hw->super.ctrl;
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
+	ctrl = hw->ctrl;
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
 	/* Signal the NIC about the change */
-	if (nfp_net_reconfig(hw, ctrl, update) != 0) {
+	if (nfp_reconfig(hw, ctrl, update) != 0) {
 		PMD_DRV_LOG(ERR, "MAC address update failed");
 		return -EIO;
 	}
@@ -689,36 +693,38 @@ int
 nfp_net_promisc_enable(struct rte_eth_dev *dev)
 {
 	int ret;
+	uint32_t update;
 	uint32_t new_ctrl;
-	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
 		repr = dev->data->dev_private;
-		hw = repr->app_fw_flower->pf_hw;
+		net_hw = repr->app_fw_flower->pf_hw;
 	} else {
-		hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+		net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	hw = &net_hw->super;
+	if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(ERR, "Promiscuous mode not supported");
 		return -ENOTSUP;
 	}
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already enabled");
 		return 0;
 	}
 
-	new_ctrl = hw->super.ctrl | NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -727,25 +733,27 @@ int
 nfp_net_promisc_disable(struct rte_eth_dev *dev)
 {
 	int ret;
+	uint32_t update;
 	uint32_t new_ctrl;
-	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already disabled");
 		return 0;
 	}
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1554,17 +1562,20 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 	int ret;
 	uint32_t update;
 	uint32_t new_ctrl;
+	struct nfp_hw *hw;
 	uint64_t rx_offload;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint32_t rxvlan_ctrl = 0;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
 	rx_offload = dev->data->dev_conf.rxmode.offloads;
-	new_ctrl = hw->super.ctrl;
+	new_ctrl = hw->ctrl;
 
 	/* VLAN stripping setting */
 	if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) {
-		nfp_net_enable_rxvlan_cap(hw, &rxvlan_ctrl);
+		nfp_net_enable_rxvlan_cap(net_hw, &rxvlan_ctrl);
 		if ((rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) != 0)
 			new_ctrl |= rxvlan_ctrl;
 		else
@@ -1579,16 +1590,16 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 			new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
-	if (new_ctrl == hw->super.ctrl)
+	if (new_ctrl == hw->ctrl)
 		return 0;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1658,10 +1669,13 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 {
 	int ret;
 	uint32_t update;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size);
@@ -1670,7 +1684,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
+	if (nfp_reconfig(hw, hw->ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1789,14 +1803,16 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 {
 	uint32_t update;
 	uint64_t rss_hf;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	rss_hf = rss_conf->rss_hf;
 
 	/* Checking if RSS is enabled */
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		if (rss_hf != 0) {
 			PMD_DRV_LOG(ERR, "RSS unsupported");
 			return -EINVAL;
@@ -1814,7 +1830,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
+	if (nfp_reconfig(hw, hw->ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1969,31 +1985,32 @@ nfp_net_close_tx_queue(struct rte_eth_dev *dev)
 }
 
 int
-nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
+nfp_net_set_vxlan_port(struct nfp_net_hw *net_hw,
 		size_t idx,
 		uint16_t port)
 {
 	int ret;
 	uint32_t i;
+	struct nfp_hw *hw = &net_hw->super;
 
 	if (idx >= NFP_NET_N_VXLAN_PORTS) {
 		PMD_DRV_LOG(ERR, "The idx value is out of range.");
 		return -ERANGE;
 	}
 
-	hw->vxlan_ports[idx] = port;
+	net_hw->vxlan_ports[idx] = port;
 
 	for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) {
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
-				(hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]);
+		nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
+				(net_hw->vxlan_ports[i + 1] << 16) | net_hw->vxlan_ports[i]);
 	}
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN);
+	ret = nfp_reconfig_real(hw, NFP_NET_CFG_UPDATE_VXLAN);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 3fe3e96107..d418cd2b99 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -119,6 +119,7 @@ struct nfp_hw {
 	uint32_t cap_ext;
 	uint32_t ctrl;
 	uint32_t ctrl_ext;
+	rte_spinlock_t reconfig_lock;
 };
 
 struct nfp_net_hw {
@@ -150,8 +151,6 @@ struct nfp_net_hw {
 	uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
 	uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
 
-	rte_spinlock_t reconfig_lock;
-
 	uint32_t max_tx_queues;
 	uint32_t max_rx_queues;
 	uint16_t flbufsz;
@@ -368,8 +367,8 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 }
 
 /* Prototypes for common NFP functions */
-int nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update);
-int nfp_net_ext_reconfig(struct nfp_net_hw *hw, uint32_t ctrl_ext, uint32_t update);
+int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
+int nfp_ext_reconfig(struct nfp_hw *hw, uint32_t ctrl_ext, uint32_t update);
 int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
 int nfp_net_configure(struct rte_eth_dev *dev);
 int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 11/25] net/nfp: extract the MAC address data field
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (9 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 10/25] net/nfp: change the parameter of reconfig Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 12/25] net/nfp: rename parameter in related logic Chaoyong He
                       ` (16 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'mac_addr' 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/nfp_ethdev.c     | 14 +++++++-------
 drivers/net/nfp/nfp_ethdev_vf.c  | 18 +++++++++---------
 drivers/net/nfp/nfp_net_common.c |  8 ++++----
 drivers/net/nfp/nfp_net_common.h |  5 ++---
 4 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 1378545d22..a93742a205 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -33,7 +33,7 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic,
 
 	nfp_eth_table = nfp_eth_read_ports(app_fw_nic->pf_dev->cpp);
 
-	rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->mac_addr);
+	rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->super.mac_addr);
 
 	free(nfp_eth_table);
 
@@ -599,18 +599,18 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+	nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 
-	tmp_ether_addr = &hw->mac_addr;
+	tmp_ether_addr = &hw->super.mac_addr;
 	if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
 
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -621,7 +621,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			eth_dev->data->port_id, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
 
 	/* Registering LSC interrupt handler */
 	rte_intr_callback_register(pci_dev->intr_handle,
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 6ead7e02b8..dead6ca5ab 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -16,14 +16,14 @@
 #include "nfp_net_common.h"
 
 static void
-nfp_netvf_read_mac(struct nfp_net_hw *hw)
+nfp_netvf_read_mac(struct nfp_hw *hw)
 {
 	uint32_t tmp;
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
 	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR + 4));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
 	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
 }
 
@@ -332,16 +332,16 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(hw);
-	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
+	nfp_netvf_read_mac(&hw->super);
+	if (rte_is_valid_assigned_ether_addr(&hw->super.mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
 
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -352,7 +352,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			port, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		/* Registering LSC interrupt handler */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 9e6d2fa490..a760fcf0d2 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -532,19 +532,19 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 }
 
 void
-nfp_net_write_mac(struct nfp_net_hw *hw,
+nfp_net_write_mac(struct nfp_hw *hw,
 		uint8_t *mac)
 {
 	uint32_t mac0;
 	uint16_t mac1;
 
 	mac0 = *(uint32_t *)mac;
-	nn_writel(rte_cpu_to_be_32(mac0), hw->super.ctrl_bar + NFP_NET_CFG_MACADDR);
+	nn_writel(rte_cpu_to_be_32(mac0), hw->ctrl_bar + NFP_NET_CFG_MACADDR);
 
 	mac += 4;
 	mac1 = *(uint16_t *)mac;
 	nn_writew(rte_cpu_to_be_16(mac1),
-			hw->super.ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
 }
 
 int
@@ -565,7 +565,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(net_hw, (uint8_t *)mac_addr);
+	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index d418cd2b99..e997756091 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -120,6 +120,7 @@ struct nfp_hw {
 	uint32_t ctrl;
 	uint32_t ctrl_ext;
 	rte_spinlock_t reconfig_lock;
+	struct rte_ether_addr mac_addr;
 };
 
 struct nfp_net_hw {
@@ -159,8 +160,6 @@ struct nfp_net_hw {
 	uint16_t subsystem_device_id;
 	uint16_t subsystem_vendor_id;
 
-	struct rte_ether_addr mac_addr;
-
 	/** Records starting point for counters */
 	struct rte_eth_stats eth_stats_base;
 	struct rte_eth_xstat *eth_xstats_base;
@@ -376,7 +375,7 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac);
+void nfp_net_write_mac(struct nfp_hw *hw, uint8_t *mac);
 int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 		struct rte_intr_handle *intr_handle);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 12/25] net/nfp: rename parameter in related logic
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (10 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 11/25] net/nfp: extract the MAC address data field Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 13/25] drivers: add the common ctrl module Chaoyong He
                       ` (15 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename parameter 'hw' into 'net_hw' in the related logic, to make the
name more accurate.

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        |  86 +++++++++++------------
 drivers/net/nfp/nfp_ethdev_vf.c     |  62 +++++++++--------
 drivers/net/nfp/nfp_ipsec.c         |  82 +++++++++++-----------
 drivers/net/nfp/nfp_net_common.c    | 102 ++++++++++++++++------------
 drivers/net/nfp/nfp_net_ctrl.c      |  14 ++--
 drivers/net/nfp/nfp_rxtx.c          |  16 ++---
 7 files changed, 193 insertions(+), 177 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 831f4a7265..f3fedbf7e5 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -25,18 +25,18 @@ static void
 nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 {
 	uint16_t i;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
 	uint64_t enabled_queues = 0;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	hw = &repr->app_fw_flower->pf_hw->super;
 
 	/* Enabling the required TX queues in the device */
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	enabled_queues = 0;
 
@@ -44,7 +44,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 static void
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index a93742a205..3d4b78fbf1 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -479,11 +479,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	uint16_t port;
 	uint64_t rx_base;
 	uint64_t tx_base;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_pf_dev *pf_dev;
 	struct rte_pci_device *pci_dev;
 	struct nfp_app_fw_nic *app_fw_nic;
-	struct rte_ether_addr *tmp_ether_addr;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 
@@ -503,46 +503,47 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	 * Use PF array of physical ports to get pointer to
 	 * this specific port.
 	 */
-	hw = app_fw_nic->ports[port];
+	net_hw = app_fw_nic->ports[port];
+	hw = &net_hw->super;
 
 	PMD_INIT_LOG(DEBUG, "Working with physical port number: %hu, "
-			"NFP internal port number: %d", port, hw->nfp_idx);
+			"NFP internal port number: %d", port, net_hw->nfp_idx);
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-	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");
+	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;
 
-		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);
-		if (hw->mac_stats_bar == NULL) {
+		hw->ctrl_bar = pf_dev->ctrl_bar;
+		min_size = NFP_MAC_STATS_SIZE * net_hw->pf_dev->nfp_eth_table->max_index;
+		net_hw->mac_stats_bar = nfp_rtsym_map(net_hw->pf_dev->sym_tbl, "_mac_stats",
+				min_size, &net_hw->mac_stats_area);
+		if (net_hw->mac_stats_bar == NULL) {
 			PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for _mac_stats_bar");
 			return -EIO;
 		}
 
-		hw->mac_stats = hw->mac_stats_bar;
+		net_hw->mac_stats = net_hw->mac_stats_bar;
 	} else {
 		if (pf_dev->ctrl_bar == NULL)
 			return -ENODEV;
 
 		/* Use port offset in pf ctrl_bar for this ports control bar */
-		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);
+		hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ);
+		net_hw->mac_stats = app_fw_nic->ports[0]->mac_stats_bar +
+				(net_hw->nfp_idx * NFP_MAC_STATS_SIZE);
 	}
 
-	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->super.ctrl_bar);
-	PMD_INIT_LOG(DEBUG, "MAC stats: %p", hw->mac_stats);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "MAC stats: %p", net_hw->mac_stats);
 
-	err = nfp_net_common_init(pci_dev, hw);
+	err = nfp_net_common_init(pci_dev, net_hw);
 	if (err != 0)
 		return err;
 
@@ -558,38 +559,38 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 		return err;
 	}
 
-	nfp_net_ethdev_ops_mount(hw, eth_dev);
+	nfp_net_ethdev_ops_mount(net_hw, eth_dev);
 
-	hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *
+	net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *
 			nfp_net_xstats_size(eth_dev), 0);
-	if (hw->eth_xstats_base == NULL) {
+	if (net_hw->eth_xstats_base == NULL) {
 		PMD_INIT_LOG(ERR, "no memory for xstats base values on device %s!",
 				pci_dev->device.name);
 		return -ENOMEM;
 	}
 
 	/* Work out where in the BAR the queues start. */
-	tx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
-	rx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
+	tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	rx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
 
-	hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
-	hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
-	eth_dev->data->dev_private = hw;
+	net_hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
+	net_hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
+	eth_dev->data->dev_private = net_hw;
 
 	PMD_INIT_LOG(DEBUG, "ctrl_bar: %p, tx_bar: %p, rx_bar: %p",
-			hw->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->ctrl_bar, net_hw->tx_bar, net_hw->rx_bar);
 
-	nfp_net_cfg_queue_setup(hw);
-	hw->mtu = RTE_ETHER_MTU;
+	nfp_net_cfg_queue_setup(net_hw);
+	net_hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
-	nfp_net_log_device_information(hw);
+	nfp_net_log_device_information(net_hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->super.reconfig_lock);
+	rte_spinlock_init(&hw->reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
@@ -599,20 +600,19 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 
-	tmp_ether_addr = &hw->super.mac_addr;
-	if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) {
+	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
@@ -621,13 +621,13 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			eth_dev->data->port_id, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
 
 	/* Registering LSC interrupt handler */
 	rte_intr_callback_register(pci_dev->intr_handle,
 			nfp_net_dev_interrupt_handler, (void *)eth_dev);
 	/* Telling the firmware about the LSC interrupt entry */
-	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 	/* Recording current stats counters values */
 	nfp_net_stats_reset(eth_dev);
 
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index dead6ca5ab..049728d30c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -254,7 +254,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	int err;
 	uint16_t port;
 	uint32_t start_q;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint64_t tx_bar_off = 0;
 	uint64_t rx_bar_off = 0;
 	struct rte_pci_device *pci_dev;
@@ -269,22 +270,23 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		return -ENODEV;
 	}
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	hw->dev_info = dev_info;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw->dev_info = dev_info;
+	hw = &net_hw->super;
 
-	hw->super.ctrl_bar = pci_dev->mem_resource[0].addr;
-	if (hw->super.ctrl_bar == NULL) {
+	hw->ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->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->super.ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
 
-	err = nfp_net_common_init(pci_dev, hw);
+	err = nfp_net_common_init(pci_dev, net_hw);
 	if (err != 0)
 		return err;
 
-	nfp_netvf_ethdev_ops_mount(hw, eth_dev);
+	nfp_netvf_ethdev_ops_mount(net_hw, eth_dev);
 
 	/* For secondary processes, the primary has done all the work */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -292,37 +294,37 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-	hw->eth_xstats_base = rte_malloc("rte_eth_xstat",
+	net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat",
 			sizeof(struct rte_eth_xstat) * nfp_net_xstats_size(eth_dev), 0);
-	if (hw->eth_xstats_base == NULL) {
+	if (net_hw->eth_xstats_base == NULL) {
 		PMD_INIT_LOG(ERR, "No memory for xstats base values on device %s!",
 				pci_dev->device.name);
 		return -ENOMEM;
 	}
 
 	/* Work out where in the BAR the queues start. */
-	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
-	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
 
-	hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
-	hw->rx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + rx_bar_off;
+	net_hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
+	net_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->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->ctrl_bar, net_hw->tx_bar, net_hw->rx_bar);
 
-	nfp_net_cfg_queue_setup(hw);
-	hw->mtu = RTE_ETHER_MTU;
+	nfp_net_cfg_queue_setup(net_hw);
+	net_hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
-	nfp_net_log_device_information(hw);
+	nfp_net_log_device_information(net_hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->super.reconfig_lock);
+	rte_spinlock_init(&hw->reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
@@ -332,18 +334,18 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(&hw->super);
-	if (rte_is_valid_assigned_ether_addr(&hw->super.mac_addr) == 0) {
+	nfp_netvf_read_mac(hw);
+	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
@@ -352,14 +354,14 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			port, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		/* Registering LSC interrupt handler */
 		rte_intr_callback_register(pci_dev->intr_handle,
 				nfp_net_dev_interrupt_handler, (void *)eth_dev);
 		/* Telling the firmware about the LSC interrupt entry */
-		nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 		/* Recording current stats counters values */
 		nfp_net_stats_reset(eth_dev);
 	}
@@ -367,7 +369,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	return 0;
 
 dev_err_ctrl_map:
-		nfp_cpp_area_free(hw->ctrl_area);
+		nfp_cpp_area_free(net_hw->ctrl_area);
 
 	return err;
 }
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index 0da5c2a3d2..7e26977dc1 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -434,7 +434,7 @@ enum nfp_ipsec_df_type {
 };
 
 static int
-nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
+nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *net_hw,
 		struct nfp_ipsec_msg *msg)
 {
 	int ret;
@@ -445,9 +445,9 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	msg->rsp = NFP_IPSEC_CFG_MSG_OK;
 
 	for (i = 0; i < msg_size; i++)
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
+		nn_cfg_writel(&net_hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
 
-	ret = nfp_net_mbox_reconfig(hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
+	ret = nfp_net_mbox_reconfig(net_hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to IPsec reconfig mbox");
 		return ret;
@@ -459,7 +459,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	 * response. One example where the data is needed is for statistics.
 	 */
 	for (i = 0; i < msg_size; i++)
-		msg->raw[i] = nn_cfg_readl(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
+		msg->raw[i] = nn_cfg_readl(&net_hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
 
 	switch (msg->rsp) {
 	case NFP_IPSEC_CFG_MSG_OK:
@@ -577,10 +577,10 @@ nfp_aead_map(struct rte_eth_dev *eth_dev,
 	uint32_t device_id;
 	const char *iv_str;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 	offset = 0;
 
 	switch (aead->algo) {
@@ -665,10 +665,10 @@ nfp_cipher_map(struct rte_eth_dev *eth_dev,
 	uint32_t i;
 	uint32_t device_id;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 
 	switch (cipher->algo) {
 	case RTE_CRYPTO_CIPHER_NULL:
@@ -801,15 +801,15 @@ nfp_auth_map(struct rte_eth_dev *eth_dev,
 	uint8_t key_length;
 	uint32_t device_id;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
 	if (digest_length == 0) {
 		PMD_DRV_LOG(ERR, "Auth digest length is illegal!");
 		return -EINVAL;
 	}
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 	digest_length = digest_length << 3;
 
 	switch (auth->algo) {
@@ -1068,7 +1068,7 @@ nfp_crypto_create_session(void *device,
 {
 	int ret;
 	int sa_idx;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg msg;
 	struct rte_eth_dev *eth_dev;
 	struct nfp_ipsec_session *priv_session;
@@ -1082,14 +1082,14 @@ nfp_crypto_create_session(void *device,
 	sa_idx = -1;
 	eth_dev = device;
 	priv_session = SECURITY_GET_SESS_PRIV(session);
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-	if (hw->ipsec_data->sa_free_cnt == 0) {
+	if (net_hw->ipsec_data->sa_free_cnt == 0) {
 		PMD_DRV_LOG(ERR, "No space in SA table, spi: %d", conf->ipsec.spi);
 		return -EINVAL;
 	}
 
-	nfp_get_sa_entry(hw->ipsec_data, &sa_idx);
+	nfp_get_sa_entry(net_hw->ipsec_data, &sa_idx);
 
 	if (sa_idx < 0) {
 		PMD_DRV_LOG(ERR, "Failed to get SA entry!");
@@ -1105,7 +1105,7 @@ nfp_crypto_create_session(void *device,
 
 	msg.cmd = NFP_IPSEC_CFG_MSG_ADD_SA;
 	msg.sa_idx = sa_idx;
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &msg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to add SA to nic");
 		return -EINVAL;
@@ -1118,8 +1118,8 @@ nfp_crypto_create_session(void *device,
 	priv_session->dev = eth_dev;
 	priv_session->user_data = conf->userdata;
 
-	hw->ipsec_data->sa_free_cnt--;
-	hw->ipsec_data->sa_entries[sa_idx] = priv_session;
+	net_hw->ipsec_data->sa_free_cnt--;
+	net_hw->ipsec_data->sa_entries[sa_idx] = priv_session;
 
 	return 0;
 }
@@ -1156,19 +1156,19 @@ nfp_security_set_pkt_metadata(void *device,
 {
 	int offset;
 	uint64_t *sqn;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct rte_eth_dev *eth_dev;
 	struct nfp_ipsec_session *priv_session;
 
 	sqn = params;
 	eth_dev = device;
 	priv_session = SECURITY_GET_SESS_PRIV(session);
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
 	if (priv_session->ipsec.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
 		struct nfp_tx_ipsec_desc_msg *desc_md;
 
-		offset = hw->ipsec_data->pkt_dynfield_offset;
+		offset = net_hw->ipsec_data->pkt_dynfield_offset;
 		desc_md = RTE_MBUF_DYNFIELD(m, offset, struct nfp_tx_ipsec_desc_msg *);
 
 		if (priv_session->msg.ctrl_word.ext_seq != 0 && sqn != NULL) {
@@ -1223,7 +1223,7 @@ nfp_security_session_get_stats(void *device,
 		struct rte_security_stats *stats)
 {
 	int ret;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg msg;
 	struct rte_eth_dev *eth_dev;
 	struct ipsec_get_sa_stats *cfg_s;
@@ -1236,9 +1236,9 @@ nfp_security_session_get_stats(void *device,
 	memset(&msg, 0, sizeof(msg));
 	msg.cmd = NFP_IPSEC_CFG_MSG_GET_SA_STATS;
 	msg.sa_idx = priv_session->sa_index;
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &msg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to get SA stats");
 		return ret;
@@ -1284,22 +1284,22 @@ nfp_crypto_remove_sa(struct rte_eth_dev *eth_dev,
 {
 	int ret;
 	uint32_t sa_index;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg cfg;
 
 	sa_index = priv_session->sa_index;
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
 	cfg.cmd = NFP_IPSEC_CFG_MSG_INV_SA;
 	cfg.sa_idx = sa_index;
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &cfg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &cfg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to remove SA!");
 		return -EINVAL;
 	}
 
-	hw->ipsec_data->sa_free_cnt++;
-	hw->ipsec_data->sa_entries[sa_index] = NULL;
+	net_hw->ipsec_data->sa_free_cnt++;
+	net_hw->ipsec_data->sa_entries[sa_index] = NULL;
 
 	return 0;
 }
@@ -1377,12 +1377,12 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint32_t cap_extend;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_net_ipsec_data *data;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->super.cap_ext;
+	cap_extend = net_hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return 0;
@@ -1396,7 +1396,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 
 	data->pkt_dynfield_offset = -1;
 	data->sa_free_cnt = NFP_NET_IPSEC_MAX_SA_CNT;
-	hw->ipsec_data = data;
+	net_hw->ipsec_data = data;
 
 	ret = nfp_ipsec_ctx_create(dev, data);
 	if (ret != 0) {
@@ -1424,12 +1424,12 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 {
 	uint16_t i;
 	uint32_t cap_extend;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_session *priv_session;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->super.cap_ext;
+	cap_extend = net_hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return;
@@ -1437,17 +1437,17 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 
 	nfp_ipsec_ctx_destroy(dev);
 
-	if (hw->ipsec_data == NULL) {
+	if (net_hw->ipsec_data == NULL) {
 		PMD_INIT_LOG(INFO, "IPsec data is NULL!");
 		return;
 	}
 
 	for (i = 0; i < NFP_NET_IPSEC_MAX_SA_CNT; i++) {
-		priv_session = hw->ipsec_data->sa_entries[i];
+		priv_session = net_hw->ipsec_data->sa_entries[i];
 		if (priv_session != NULL)
 			memset(priv_session, 0, sizeof(struct nfp_ipsec_session));
 	}
 
-	rte_free(hw->ipsec_data);
+	rte_free(net_hw->ipsec_data);
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index a760fcf0d2..01574de963 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -336,7 +336,7 @@ nfp_ext_reconfig(struct nfp_hw *hw,
 /**
  * Reconfigure the firmware via the mailbox
  *
- * @param hw
+ * @param net_hw
  *   Device to reconfigure
  * @param mbox_cmd
  *   The value for the mailbox command
@@ -346,24 +346,24 @@ nfp_ext_reconfig(struct nfp_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure by the mailbox
  */
 int
-nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
+nfp_net_mbox_reconfig(struct nfp_net_hw *net_hw,
 		uint32_t mbox_cmd)
 {
 	int ret;
 	uint32_t mbox;
 
-	mbox = hw->tlv_caps.mbox_off;
+	mbox = net_hw->tlv_caps.mbox_off;
 
-	rte_spinlock_lock(&hw->super.reconfig_lock);
+	rte_spinlock_lock(&net_hw->super.reconfig_lock);
 
-	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
+	nn_cfg_writeq(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
+	nn_cfg_writel(&net_hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
-	ret = nfp_reconfig_real(&hw->super, NFP_NET_CFG_UPDATE_MBOX);
+	ret = nfp_reconfig_real(&net_hw->super, NFP_NET_CFG_UPDATE_MBOX);
 
-	rte_spinlock_unlock(&hw->super.reconfig_lock);
+	rte_spinlock_unlock(&net_hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net mailbox reconfig: mbox=%#08x update=%#08x",
@@ -371,7 +371,7 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 		return -EIO;
 	}
 
-	return nn_cfg_readl(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
+	return nn_cfg_readl(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
 }
 
 /*
@@ -625,6 +625,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 uint32_t
 nfp_check_offloads(struct rte_eth_dev *dev)
 {
+	uint32_t cap;
 	uint32_t ctrl = 0;
 	uint64_t rx_offload;
 	uint64_t tx_offload;
@@ -632,13 +633,14 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	struct rte_eth_conf *dev_conf;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	cap = hw->super.cap;
 
 	dev_conf = &dev->data->dev_conf;
 	rx_offload = dev_conf->rxmode.offloads;
 	tx_offload = dev_conf->txmode.offloads;
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXCSUM;
 	}
 
@@ -646,25 +648,25 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 		nfp_net_enable_rxvlan_cap(hw, &ctrl);
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
 	hw->mtu = dev->data->mtu;
 
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2;
-		else if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
+		else if ((cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
 	}
 
 	/* L2 broadcast */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2BC) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_L2BC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2BC;
 
 	/* L2 multicast */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2MC) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_L2MC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2MC;
 
 	/* TX checksum offload */
@@ -676,7 +678,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	/* LSO offload */
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 ||
 			(tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_LSO) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_LSO;
 		else
 			ctrl |= NFP_NET_CFG_CTRL_LSO2;
@@ -1194,6 +1196,7 @@ nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
 int
 nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
+	uint32_t cap;
 	uint32_t cap_extend;
 	uint16_t min_rx_desc;
 	uint16_t max_rx_desc;
@@ -1224,32 +1227,34 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
-	if ((hw->super.cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
+	cap = hw->super.cap;
+
+	if ((cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->super.cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
+	if ((cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
 		dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
+	if ((cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
 			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_GATHER) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_GATHER) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	cap_extend = hw->super.cap_ext;
@@ -1292,7 +1297,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG,
 	};
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+	if ((cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
 		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
@@ -1615,9 +1620,11 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 	uint8_t mask;
 	uint32_t reta;
 	uint16_t shift;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
 		PMD_DRV_LOG(ERR, "The size of hash lookup table configured (%hu)"
@@ -1642,7 +1649,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 
 		/* If all 4 entries were set, don't need read RETA register */
 		if (mask != 0xF)
-			reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + i);
+			reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + i);
 
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
@@ -1655,7 +1662,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 			reta |= reta_conf[idx].reta[shift + j] << (8 * j);
 		}
 
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
+		nn_cfg_writel(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
 	}
 
 	return 0;
@@ -1702,10 +1709,13 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 	uint8_t mask;
 	uint32_t reta;
 	uint16_t shift;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
@@ -1728,7 +1738,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 		if (mask == 0)
 			continue;
 
-		reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
+		reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
 				continue;
@@ -1748,15 +1758,17 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	uint8_t i;
 	uint8_t key;
 	uint64_t rss_hf;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint32_t cfg_rss_ctrl = 0;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	/* Writing the key byte by byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
 		memcpy(&key, &rss_conf->rss_key[i], 1);
-		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY + i, key);
+		nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY + i, key);
 	}
 
 	rss_hf = rss_conf->rss_hf;
@@ -1789,10 +1801,10 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
 
 	/* Writing the key size */
-	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
+	nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
 
 	return 0;
 }
@@ -1843,16 +1855,18 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	uint8_t i;
 	uint8_t key;
 	uint64_t rss_hf;
+	struct nfp_hw *hw;
 	uint32_t cfg_rss_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
-	cfg_rss_ctrl = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_CTRL);
+	cfg_rss_ctrl = nn_cfg_readl(hw, NFP_NET_CFG_RSS_CTRL);
 
 	if ((cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4) != 0)
 		rss_hf |= RTE_ETH_RSS_IPV4;
@@ -1882,11 +1896,11 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	rss_conf->rss_hf = rss_hf;
 
 	/* Reading the key size */
-	rss_conf->rss_key_len = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_KEY_SZ);
+	rss_conf->rss_key_len = nn_cfg_readl(hw, NFP_NET_CFG_RSS_KEY_SZ);
 
 	/* Reading the key byte a byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
-		key = nn_cfg_readb(&hw->super, NFP_NET_CFG_RSS_KEY + i);
+		key = nn_cfg_readb(hw, NFP_NET_CFG_RSS_KEY + i);
 		memcpy(&rss_conf->rss_key[i], &key, 1);
 	}
 
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index d469896a64..8848fa38fe 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -29,15 +29,15 @@ nfp_net_tlv_caps_parse(struct rte_eth_dev *dev)
 	uint32_t length;
 	uint32_t offset;
 	uint32_t tlv_type;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_net_tlv_caps *caps;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	caps = &hw->tlv_caps;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	caps = &net_hw->tlv_caps;
 	nfp_net_tlv_caps_reset(caps);
 
-	data = hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
-	end = hw->super.ctrl_bar + NFP_NET_CFG_BAR_SZ;
+	data = net_hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
+	end = net_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->super.ctrl_bar;
+		offset = data - net_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->super.ctrl_bar;
+				caps->mbox_off = data - net_hw->super.ctrl_bar;
 			else
 				caps->mbox_off = 0;
 			break;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index f17cc13cc1..fc94e5f0b9 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -336,10 +336,10 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 		struct nfp_net_rxq *rxq,
 		struct rte_mbuf *mb)
 {
-	struct nfp_net_hw *hw = rxq->hw;
+	uint32_t ctrl = rxq->hw->super.ctrl;
 
-	/* Skip if firmware don't support setting vlan. */
-	if ((hw->super.ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
+	/* Skip if hardware don't support setting vlan. */
+	if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
 	/*
@@ -347,12 +347,12 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	 * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
 	 * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
 	 */
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+	if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
 		if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
 		}
-	} else if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+	} else if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
 		if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
@@ -383,10 +383,10 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 		struct nfp_net_rxq *rxq,
 		struct rte_mbuf *mb)
 {
-	struct nfp_net_hw *hw = rxq->hw;
+	struct nfp_hw *hw = &rxq->hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
-			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
 	if (meta->vlan_layer < NFP_META_MAX_VLANS)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 13/25] drivers: add the common ctrl module
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (11 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 12/25] net/nfp: rename parameter in related logic Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 14/25] drivers: add the nfp common module Chaoyong He
                       ` (14 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the common ctrl module.

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/common/nfp/nfp_common_ctrl.h | 374 +++++++++++++++++++++++++++
 drivers/net/nfp/nfp_net_ctrl.h       | 365 +-------------------------
 2 files changed, 375 insertions(+), 364 deletions(-)
 create mode 100644 drivers/common/nfp/nfp_common_ctrl.h

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
new file mode 100644
index 0000000000..3c8cd916cf
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -0,0 +1,374 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_CTRL_H__
+#define __NFP_COMMON_CTRL_H__
+
+/*
+ * Configuration BAR size.
+ *
+ * On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
+ */
+#define NFP_NET_CFG_BAR_SZ              (32 * 1024)
+
+/* Offset in Freelist buffer where packet starts on RX */
+#define NFP_NET_RX_OFFSET               32
+
+/* Working with metadata api (NFD version > 3.0) */
+#define NFP_NET_META_FIELD_SIZE         4
+#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
+#define NFP_NET_META_HEADER_SIZE        4
+#define NFP_NET_META_NFDK_LENGTH        8
+
+/* Working with metadata vlan api (NFD version >= 2.0) */
+#define NFP_NET_META_VLAN_INFO          16
+#define NFP_NET_META_VLAN_OFFLOAD       31
+#define NFP_NET_META_VLAN_TPID          3
+#define NFP_NET_META_VLAN_MASK          ((1 << NFP_NET_META_VLAN_INFO) - 1)
+#define NFP_NET_META_VLAN_TPID_MASK     ((1 << NFP_NET_META_VLAN_TPID) - 1)
+#define NFP_NET_META_TPID(d)            (((d) >> NFP_NET_META_VLAN_INFO) & \
+						NFP_NET_META_VLAN_TPID_MASK)
+
+/* Prepend field types */
+#define NFP_NET_META_HASH               1 /* Next field carries hash type */
+#define NFP_NET_META_VLAN               4
+#define NFP_NET_META_PORTID             5
+#define NFP_NET_META_IPSEC              9
+
+#define NFP_META_PORT_ID_CTRL           ~0U
+
+/* Hash type prepended when a RSS hash was computed */
+#define NFP_NET_RSS_NONE                0
+#define NFP_NET_RSS_IPV4                1
+#define NFP_NET_RSS_IPV6                2
+#define NFP_NET_RSS_IPV6_EX             3
+#define NFP_NET_RSS_IPV4_TCP            4
+#define NFP_NET_RSS_IPV6_TCP            5
+#define NFP_NET_RSS_IPV6_EX_TCP         6
+#define NFP_NET_RSS_IPV4_UDP            7
+#define NFP_NET_RSS_IPV6_UDP            8
+#define NFP_NET_RSS_IPV6_EX_UDP         9
+#define NFP_NET_RSS_IPV4_SCTP           10
+#define NFP_NET_RSS_IPV6_SCTP           11
+
+/*
+ * @NFP_NET_TXR_MAX:         Maximum number of TX rings
+ * @NFP_NET_TXR_MASK:        Mask for TX rings
+ * @NFP_NET_RXR_MAX:         Maximum number of RX rings
+ * @NFP_NET_RXR_MASK:        Mask for RX rings
+ */
+#define NFP_NET_TXR_MAX                 64
+#define NFP_NET_TXR_MASK                (NFP_NET_TXR_MAX - 1)
+#define NFP_NET_RXR_MAX                 64
+#define NFP_NET_RXR_MASK                (NFP_NET_RXR_MAX - 1)
+
+/*
+ * Read/Write config words (0x0000 - 0x002c)
+ * @NFP_NET_CFG_CTRL:        Global control
+ * @NFP_NET_CFG_UPDATE:      Indicate which fields are updated
+ * @NFP_NET_CFG_TXRS_ENABLE: Bitmask of enabled TX rings
+ * @NFP_NET_CFG_RXRS_ENABLE: Bitmask of enabled RX rings
+ * @NFP_NET_CFG_MTU:         Set MTU size
+ * @NFP_NET_CFG_FLBUFSZ:     Set freelist buffer size (must be larger than MTU)
+ * @NFP_NET_CFG_EXN:         MSI-X table entry for exceptions
+ * @NFP_NET_CFG_LSC:         MSI-X table entry for link state changes
+ * @NFP_NET_CFG_MACADDR:     MAC address
+ *
+ * TODO:
+ * - define Error details in UPDATE
+ */
+#define NFP_NET_CFG_CTRL                0x0000
+#define   NFP_NET_CFG_CTRL_ENABLE         (0x1 <<  0) /* Global enable */
+#define   NFP_NET_CFG_CTRL_PROMISC        (0x1 <<  1) /* Enable Promisc mode */
+#define   NFP_NET_CFG_CTRL_L2BC           (0x1 <<  2) /* Allow L2 Broadcast */
+#define   NFP_NET_CFG_CTRL_L2MC           (0x1 <<  3) /* Allow L2 Multicast */
+#define   NFP_NET_CFG_CTRL_RXCSUM         (0x1 <<  4) /* Enable RX Checksum */
+#define   NFP_NET_CFG_CTRL_TXCSUM         (0x1 <<  5) /* Enable TX Checksum */
+#define   NFP_NET_CFG_CTRL_RXVLAN         (0x1 <<  6) /* Enable VLAN strip */
+#define   NFP_NET_CFG_CTRL_TXVLAN         (0x1 <<  7) /* Enable VLAN insert */
+#define   NFP_NET_CFG_CTRL_SCATTER        (0x1 <<  8) /* Scatter DMA */
+#define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
+#define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
+#define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
+#define   NFP_NET_CFG_CTRL_RXVLAN_V2      (0x1 << 15) /* Enable VLAN strip with metadata */
+#define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
+#define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
+#define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
+#define   NFP_NET_CFG_CTRL_RINGPRIO       (0x1 << 19) /* Ring priorities */
+#define   NFP_NET_CFG_CTRL_MSIXAUTO       (0x1 << 20) /* MSI-X auto-masking */
+#define   NFP_NET_CFG_CTRL_TXRWB          (0x1 << 21) /* Write-back of TX ring */
+#define   NFP_NET_CFG_CTRL_L2SWITCH       (0x1 << 22) /* L2 Switch */
+#define   NFP_NET_CFG_CTRL_TXVLAN_V2      (0x1 << 23) /* Enable VLAN insert with metadata */
+#define   NFP_NET_CFG_CTRL_VXLAN          (0x1 << 24) /* Enable VXLAN */
+#define   NFP_NET_CFG_CTRL_NVGRE          (0x1 << 25) /* Enable NVGRE */
+#define   NFP_NET_CFG_CTRL_MSIX_TX_OFF    (0x1 << 26) /* Disable MSIX for TX */
+#define   NFP_NET_CFG_CTRL_LSO2           (0x1 << 28) /* LSO/TSO (version 2) */
+#define   NFP_NET_CFG_CTRL_RSS2           (0x1 << 29) /* RSS (version 2) */
+#define   NFP_NET_CFG_CTRL_CSUM_COMPLETE  (0x1 << 30) /* Checksum complete */
+#define   NFP_NET_CFG_CTRL_LIVE_ADDR      (0x1U << 31) /* Live MAC addr change */
+#define NFP_NET_CFG_UPDATE              0x0004
+#define   NFP_NET_CFG_UPDATE_GEN          (0x1 <<  0) /* General update */
+#define   NFP_NET_CFG_UPDATE_RING         (0x1 <<  1) /* Ring config change */
+#define   NFP_NET_CFG_UPDATE_RSS          (0x1 <<  2) /* RSS config change */
+#define   NFP_NET_CFG_UPDATE_TXRPRIO      (0x1 <<  3) /* TX Ring prio change */
+#define   NFP_NET_CFG_UPDATE_RXRPRIO      (0x1 <<  4) /* RX Ring prio change */
+#define   NFP_NET_CFG_UPDATE_MSIX         (0x1 <<  5) /* MSI-X change */
+#define   NFP_NET_CFG_UPDATE_L2SWITCH     (0x1 <<  6) /* Switch changes */
+#define   NFP_NET_CFG_UPDATE_RESET        (0x1 <<  7) /* Update due to FLR */
+#define   NFP_NET_CFG_UPDATE_IRQMOD       (0x1 <<  8) /* IRQ mod change */
+#define   NFP_NET_CFG_UPDATE_VXLAN        (0x1 <<  9) /* VXLAN port change */
+#define   NFP_NET_CFG_UPDATE_MACADDR      (0x1 << 11) /* MAC address change */
+#define   NFP_NET_CFG_UPDATE_MBOX         (0x1 << 12) /* Mailbox update */
+#define   NFP_NET_CFG_UPDATE_ERR          (0x1U << 31) /* A error occurred */
+#define NFP_NET_CFG_TXRS_ENABLE         0x0008
+#define NFP_NET_CFG_RXRS_ENABLE         0x0010
+#define NFP_NET_CFG_MTU                 0x0018
+#define NFP_NET_CFG_FLBUFSZ             0x001c
+#define NFP_NET_CFG_EXN                 0x001f
+#define NFP_NET_CFG_LSC                 0x0020
+#define NFP_NET_CFG_MACADDR             0x0024
+
+#define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2)
+#define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2)
+
+#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \
+					NFP_NET_CFG_CTRL_CSUM_COMPLETE)
+
+/* Version number helper defines */
+struct nfp_net_fw_ver {
+	uint8_t minor;
+	uint8_t major;
+	uint8_t class;
+	/**
+	 * This byte can be extended for more use.
+	 * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx
+	 * BIT[7:1]: reserved
+	 */
+	uint8_t extend;
+};
+
+/*
+ * Read-only words (0x0030 - 0x0050):
+ * @NFP_NET_CFG_VERSION:     Firmware version number
+ * @NFP_NET_CFG_STS:         Status
+ * @NFP_NET_CFG_CAP:         Capabilities (same bits as @NFP_NET_CFG_CTRL)
+ * @NFP_NET_MAX_TXRINGS:     Maximum number of TX rings
+ * @NFP_NET_MAX_RXRINGS:     Maximum number of RX rings
+ * @NFP_NET_MAX_MTU:         Maximum support MTU
+ * @NFP_NET_CFG_START_TXQ:   Start Queue Control Queue to use for TX (PF only)
+ * @NFP_NET_CFG_START_RXQ:   Start Queue Control Queue to use for RX (PF only)
+ *
+ * TODO:
+ * - define more STS bits
+ */
+#define NFP_NET_CFG_VERSION             0x0030
+#define   NFP_NET_CFG_VERSION_DP_NFD3   0
+#define   NFP_NET_CFG_VERSION_DP_NFDK   1
+#define NFP_NET_CFG_STS                 0x0034
+#define   NFP_NET_CFG_STS_LINK            (0x1 << 0) /* Link up or down */
+/* Link rate */
+#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
+#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
+#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
+#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN       1
+#define   NFP_NET_CFG_STS_LINK_RATE_1G            2
+#define   NFP_NET_CFG_STS_LINK_RATE_10G           3
+#define   NFP_NET_CFG_STS_LINK_RATE_25G           4
+#define   NFP_NET_CFG_STS_LINK_RATE_40G           5
+#define   NFP_NET_CFG_STS_LINK_RATE_50G           6
+#define   NFP_NET_CFG_STS_LINK_RATE_100G          7
+
+/*
+ * NSP Link rate is a 16-bit word. It is no longer determined by
+ * firmware, instead it is read from the nfp_eth_table of the
+ * associated pf_dev and written to the NFP_NET_CFG_STS_NSP_LINK_RATE
+ * address by the PMD each time the port is reconfigured.
+ */
+#define NFP_NET_CFG_STS_NSP_LINK_RATE   0x0036
+
+#define NFP_NET_CFG_CAP                 0x0038
+#define NFP_NET_CFG_MAX_TXRINGS         0x003c
+#define NFP_NET_CFG_MAX_RXRINGS         0x0040
+#define NFP_NET_CFG_MAX_MTU             0x0044
+/* Next two words are being used by VFs for solving THB350 issue */
+#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
+ */
+#define NFP_NET_CFG_RX_OFFSET           0x0050
+#define NFP_NET_CFG_RX_OFFSET_DYNAMIC          0    /* Prepend mode */
+
+/* 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
+
+/* Offload definitions */
+#define NFP_NET_N_VXLAN_PORTS  (NFP_NET_CFG_VXLAN_SZ / sizeof(uint16_t))
+
+/*
+ * 3 words reserved for extended ctrl words (0x0098 - 0x00a4)
+ * 3 words reserved for extended cap words (0x00a4 - 0x00b0)
+ * Currently only one word is used, can be extended in future.
+ */
+#define NFP_NET_CFG_CTRL_WORD1          0x0098
+#define NFP_NET_CFG_CTRL_PKT_TYPE         (0x1 << 0)
+#define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
+#define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
+#define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
+
+#define NFP_NET_CFG_CAP_WORD1           0x00a4
+
+/* 16B reserved for future use (0x00b0 - 0x00c0). */
+#define NFP_NET_CFG_RESERVED            0x00b0
+#define NFP_NET_CFG_RESERVED_SZ         0x0010
+
+/*
+ * RSS configuration (0x0100 - 0x01ac):
+ * Used only when NFP_NET_CFG_CTRL_RSS_ANY is enabled
+ * @NFP_NET_CFG_RSS_CFG:     RSS configuration word
+ * @NFP_NET_CFG_RSS_KEY:     RSS "secret" key
+ * @NFP_NET_CFG_RSS_ITBL:    RSS indirection table
+ */
+#define NFP_NET_CFG_RSS_BASE            0x0100
+#define NFP_NET_CFG_RSS_CTRL            NFP_NET_CFG_RSS_BASE
+#define   NFP_NET_CFG_RSS_MASK            (0x7f)
+#define   NFP_NET_CFG_RSS_MASK_of(_x)     ((_x) & 0x7f)
+#define   NFP_NET_CFG_RSS_IPV4            (1 <<  8) /* RSS for IPv4 */
+#define   NFP_NET_CFG_RSS_IPV6            (1 <<  9) /* RSS for IPv6 */
+#define   NFP_NET_CFG_RSS_IPV4_TCP        (1 << 10) /* RSS for IPv4/TCP */
+#define   NFP_NET_CFG_RSS_IPV4_UDP        (1 << 11) /* RSS for IPv4/UDP */
+#define   NFP_NET_CFG_RSS_IPV6_TCP        (1 << 12) /* RSS for IPv6/TCP */
+#define   NFP_NET_CFG_RSS_IPV6_UDP        (1 << 13) /* RSS for IPv6/UDP */
+#define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
+#define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
+#define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
+#define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
+#define NFP_NET_CFG_RSS_KEY_SZ          0x28
+#define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
+					 NFP_NET_CFG_RSS_KEY_SZ)
+#define NFP_NET_CFG_RSS_ITBL_SZ         0x80
+
+/*
+ * TX ring configuration (0x200 - 0x800)
+ * @NFP_NET_CFG_TXR_BASE:    Base offset for TX ring configuration
+ * @NFP_NET_CFG_TXR_ADDR:    Per TX ring DMA address (8B entries)
+ * @NFP_NET_CFG_TXR_WB_ADDR: Per TX ring write back DMA address (8B entries)
+ * @NFP_NET_CFG_TXR_SZ:      Per TX ring size (1B entries)
+ * @NFP_NET_CFG_TXR_VEC:     Per TX ring MSI-X table entry (1B entries)
+ * @NFP_NET_CFG_TXR_PRIO:    Per TX ring priority (1B entries)
+ * @NFP_NET_CFG_TXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
+ */
+#define NFP_NET_CFG_TXR_BASE            0x0200
+#define NFP_NET_CFG_TXR_ADDR(_x)        (NFP_NET_CFG_TXR_BASE + ((_x) * 0x8))
+#define NFP_NET_CFG_TXR_WB_ADDR(_x)     (NFP_NET_CFG_TXR_BASE + 0x200 + \
+					 ((_x) * 0x8))
+#define NFP_NET_CFG_TXR_SZ(_x)          (NFP_NET_CFG_TXR_BASE + 0x400 + (_x))
+#define NFP_NET_CFG_TXR_VEC(_x)         (NFP_NET_CFG_TXR_BASE + 0x440 + (_x))
+#define NFP_NET_CFG_TXR_PRIO(_x)        (NFP_NET_CFG_TXR_BASE + 0x480 + (_x))
+#define NFP_NET_CFG_TXR_IRQ_MOD(_x)     (NFP_NET_CFG_TXR_BASE + 0x500 + \
+					 ((_x) * 0x4))
+
+/*
+ * RX ring configuration (0x0800 - 0x0c00)
+ * @NFP_NET_CFG_RXR_BASE:    Base offset for RX ring configuration
+ * @NFP_NET_CFG_RXR_ADDR:    Per TX ring DMA address (8B entries)
+ * @NFP_NET_CFG_RXR_SZ:      Per TX ring size (1B entries)
+ * @NFP_NET_CFG_RXR_VEC:     Per TX ring MSI-X table entry (1B entries)
+ * @NFP_NET_CFG_RXR_PRIO:    Per TX ring priority (1B entries)
+ * @NFP_NET_CFG_RXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
+ */
+#define NFP_NET_CFG_RXR_BASE            0x0800
+#define NFP_NET_CFG_RXR_ADDR(_x)        (NFP_NET_CFG_RXR_BASE + ((_x) * 0x8))
+#define NFP_NET_CFG_RXR_SZ(_x)          (NFP_NET_CFG_RXR_BASE + 0x200 + (_x))
+#define NFP_NET_CFG_RXR_VEC(_x)         (NFP_NET_CFG_RXR_BASE + 0x240 + (_x))
+#define NFP_NET_CFG_RXR_PRIO(_x)        (NFP_NET_CFG_RXR_BASE + 0x280 + (_x))
+#define NFP_NET_CFG_RXR_IRQ_MOD(_x)     (NFP_NET_CFG_RXR_BASE + 0x300 + \
+					 ((_x) * 0x4))
+
+/*
+ * Interrupt Control/Cause registers (0x0c00 - 0x0d00)
+ * These registers are only used when MSI-X auto-masking is not
+ * enabled (@NFP_NET_CFG_CTRL_MSIXAUTO not set).  The array is index
+ * by MSI-X entry and are 1B in size.  If an entry is zero, the
+ * corresponding entry is enabled.  If the FW generates an interrupt,
+ * it writes a cause into the corresponding field.  This also masks
+ * the MSI-X entry and the host driver must clear the register to
+ * re-enable the interrupt.
+ */
+#define NFP_NET_CFG_ICR_BASE            0x0c00
+#define NFP_NET_CFG_ICR(_x)             (NFP_NET_CFG_ICR_BASE + (_x))
+#define   NFP_NET_CFG_ICR_UNMASKED      0x0
+#define   NFP_NET_CFG_ICR_RXTX          0x1
+#define   NFP_NET_CFG_ICR_LSC           0x2
+
+/*
+ * General device stats (0x0d00 - 0x0d90)
+ * All counters are 64bit.
+ */
+#define NFP_NET_CFG_STATS_BASE          0x0d00
+#define NFP_NET_CFG_STATS_RX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x00)
+#define NFP_NET_CFG_STATS_RX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x08)
+#define NFP_NET_CFG_STATS_RX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x10)
+#define NFP_NET_CFG_STATS_RX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x18)
+#define NFP_NET_CFG_STATS_RX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x20)
+#define NFP_NET_CFG_STATS_RX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x28)
+#define NFP_NET_CFG_STATS_RX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x30)
+#define NFP_NET_CFG_STATS_RX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x38)
+#define NFP_NET_CFG_STATS_RX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x40)
+
+#define NFP_NET_CFG_STATS_TX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x48)
+#define NFP_NET_CFG_STATS_TX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x50)
+#define NFP_NET_CFG_STATS_TX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x58)
+#define NFP_NET_CFG_STATS_TX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x60)
+#define NFP_NET_CFG_STATS_TX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x68)
+#define NFP_NET_CFG_STATS_TX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x70)
+#define NFP_NET_CFG_STATS_TX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x78)
+#define NFP_NET_CFG_STATS_TX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x80)
+#define NFP_NET_CFG_STATS_TX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x88)
+
+#define NFP_NET_CFG_STATS_APP0_FRAMES   (NFP_NET_CFG_STATS_BASE + 0x90)
+#define NFP_NET_CFG_STATS_APP0_BYTES    (NFP_NET_CFG_STATS_BASE + 0x98)
+#define NFP_NET_CFG_STATS_APP1_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xa0)
+#define NFP_NET_CFG_STATS_APP1_BYTES    (NFP_NET_CFG_STATS_BASE + 0xa8)
+#define NFP_NET_CFG_STATS_APP2_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xb0)
+#define NFP_NET_CFG_STATS_APP2_BYTES    (NFP_NET_CFG_STATS_BASE + 0xb8)
+#define NFP_NET_CFG_STATS_APP3_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xc0)
+#define NFP_NET_CFG_STATS_APP3_BYTES    (NFP_NET_CFG_STATS_BASE + 0xc8)
+
+/*
+ * Per ring stats (0x1000 - 0x1800)
+ * Options, 64bit per entry
+ * @NFP_NET_CFG_TXR_STATS:   TX ring statistics (Packet and Byte count)
+ * @NFP_NET_CFG_RXR_STATS:   RX ring statistics (Packet and Byte count)
+ */
+#define NFP_NET_CFG_TXR_STATS_BASE      0x1000
+#define NFP_NET_CFG_TXR_STATS(_x)       (NFP_NET_CFG_TXR_STATS_BASE + \
+					 ((_x) * 0x10))
+#define NFP_NET_CFG_RXR_STATS_BASE      0x1400
+#define NFP_NET_CFG_RXR_STATS(_x)       (NFP_NET_CFG_RXR_STATS_BASE + \
+					 ((_x) * 0x10))
+
+#endif /* __NFP_COMMON_CTRL_H__ */
diff --git a/drivers/net/nfp/nfp_net_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
index 3772b28a66..ee1b784bb1 100644
--- a/drivers/net/nfp/nfp_net_ctrl.h
+++ b/drivers/net/nfp/nfp_net_ctrl.h
@@ -10,370 +10,7 @@
 
 #include <ethdev_driver.h>
 
-/*
- * Configuration BAR size.
- *
- * On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
- */
-#define NFP_NET_CFG_BAR_SZ              (32 * 1024)
-
-/* Offset in Freelist buffer where packet starts on RX */
-#define NFP_NET_RX_OFFSET               32
-
-/* Working with metadata api (NFD version > 3.0) */
-#define NFP_NET_META_FIELD_SIZE         4
-#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
-#define NFP_NET_META_HEADER_SIZE        4
-#define NFP_NET_META_NFDK_LENGTH        8
-
-/* Working with metadata vlan api (NFD version >= 2.0) */
-#define NFP_NET_META_VLAN_INFO          16
-#define NFP_NET_META_VLAN_OFFLOAD       31
-#define NFP_NET_META_VLAN_TPID          3
-#define NFP_NET_META_VLAN_MASK          ((1 << NFP_NET_META_VLAN_INFO) - 1)
-#define NFP_NET_META_VLAN_TPID_MASK     ((1 << NFP_NET_META_VLAN_TPID) - 1)
-#define NFP_NET_META_TPID(d)            (((d) >> NFP_NET_META_VLAN_INFO) & \
-						NFP_NET_META_VLAN_TPID_MASK)
-
-/* Prepend field types */
-#define NFP_NET_META_HASH               1 /* Next field carries hash type */
-#define NFP_NET_META_VLAN               4
-#define NFP_NET_META_PORTID             5
-#define NFP_NET_META_IPSEC              9
-
-#define NFP_META_PORT_ID_CTRL           ~0U
-
-/* Hash type prepended when a RSS hash was computed */
-#define NFP_NET_RSS_NONE                0
-#define NFP_NET_RSS_IPV4                1
-#define NFP_NET_RSS_IPV6                2
-#define NFP_NET_RSS_IPV6_EX             3
-#define NFP_NET_RSS_IPV4_TCP            4
-#define NFP_NET_RSS_IPV6_TCP            5
-#define NFP_NET_RSS_IPV6_EX_TCP         6
-#define NFP_NET_RSS_IPV4_UDP            7
-#define NFP_NET_RSS_IPV6_UDP            8
-#define NFP_NET_RSS_IPV6_EX_UDP         9
-#define NFP_NET_RSS_IPV4_SCTP           10
-#define NFP_NET_RSS_IPV6_SCTP           11
-
-/*
- * @NFP_NET_TXR_MAX:         Maximum number of TX rings
- * @NFP_NET_TXR_MASK:        Mask for TX rings
- * @NFP_NET_RXR_MAX:         Maximum number of RX rings
- * @NFP_NET_RXR_MASK:        Mask for RX rings
- */
-#define NFP_NET_TXR_MAX                 64
-#define NFP_NET_TXR_MASK                (NFP_NET_TXR_MAX - 1)
-#define NFP_NET_RXR_MAX                 64
-#define NFP_NET_RXR_MASK                (NFP_NET_RXR_MAX - 1)
-
-/*
- * Read/Write config words (0x0000 - 0x002c)
- * @NFP_NET_CFG_CTRL:        Global control
- * @NFP_NET_CFG_UPDATE:      Indicate which fields are updated
- * @NFP_NET_CFG_TXRS_ENABLE: Bitmask of enabled TX rings
- * @NFP_NET_CFG_RXRS_ENABLE: Bitmask of enabled RX rings
- * @NFP_NET_CFG_MTU:         Set MTU size
- * @NFP_NET_CFG_FLBUFSZ:     Set freelist buffer size (must be larger than MTU)
- * @NFP_NET_CFG_EXN:         MSI-X table entry for exceptions
- * @NFP_NET_CFG_LSC:         MSI-X table entry for link state changes
- * @NFP_NET_CFG_MACADDR:     MAC address
- *
- * TODO:
- * - define Error details in UPDATE
- */
-#define NFP_NET_CFG_CTRL                0x0000
-#define   NFP_NET_CFG_CTRL_ENABLE         (0x1 <<  0) /* Global enable */
-#define   NFP_NET_CFG_CTRL_PROMISC        (0x1 <<  1) /* Enable Promisc mode */
-#define   NFP_NET_CFG_CTRL_L2BC           (0x1 <<  2) /* Allow L2 Broadcast */
-#define   NFP_NET_CFG_CTRL_L2MC           (0x1 <<  3) /* Allow L2 Multicast */
-#define   NFP_NET_CFG_CTRL_RXCSUM         (0x1 <<  4) /* Enable RX Checksum */
-#define   NFP_NET_CFG_CTRL_TXCSUM         (0x1 <<  5) /* Enable TX Checksum */
-#define   NFP_NET_CFG_CTRL_RXVLAN         (0x1 <<  6) /* Enable VLAN strip */
-#define   NFP_NET_CFG_CTRL_TXVLAN         (0x1 <<  7) /* Enable VLAN insert */
-#define   NFP_NET_CFG_CTRL_SCATTER        (0x1 <<  8) /* Scatter DMA */
-#define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
-#define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
-#define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
-#define   NFP_NET_CFG_CTRL_RXVLAN_V2      (0x1 << 15) /* Enable VLAN strip with metadata */
-#define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
-#define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
-#define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
-#define   NFP_NET_CFG_CTRL_RINGPRIO       (0x1 << 19) /* Ring priorities */
-#define   NFP_NET_CFG_CTRL_MSIXAUTO       (0x1 << 20) /* MSI-X auto-masking */
-#define   NFP_NET_CFG_CTRL_TXRWB          (0x1 << 21) /* Write-back of TX ring */
-#define   NFP_NET_CFG_CTRL_L2SWITCH       (0x1 << 22) /* L2 Switch */
-#define   NFP_NET_CFG_CTRL_TXVLAN_V2      (0x1 << 23) /* Enable VLAN insert with metadata */
-#define   NFP_NET_CFG_CTRL_VXLAN          (0x1 << 24) /* Enable VXLAN */
-#define   NFP_NET_CFG_CTRL_NVGRE          (0x1 << 25) /* Enable NVGRE */
-#define   NFP_NET_CFG_CTRL_MSIX_TX_OFF    (0x1 << 26) /* Disable MSIX for TX */
-#define   NFP_NET_CFG_CTRL_LSO2           (0x1 << 28) /* LSO/TSO (version 2) */
-#define   NFP_NET_CFG_CTRL_RSS2           (0x1 << 29) /* RSS (version 2) */
-#define   NFP_NET_CFG_CTRL_CSUM_COMPLETE  (0x1 << 30) /* Checksum complete */
-#define   NFP_NET_CFG_CTRL_LIVE_ADDR      (0x1U << 31) /* Live MAC addr change */
-#define NFP_NET_CFG_UPDATE              0x0004
-#define   NFP_NET_CFG_UPDATE_GEN          (0x1 <<  0) /* General update */
-#define   NFP_NET_CFG_UPDATE_RING         (0x1 <<  1) /* Ring config change */
-#define   NFP_NET_CFG_UPDATE_RSS          (0x1 <<  2) /* RSS config change */
-#define   NFP_NET_CFG_UPDATE_TXRPRIO      (0x1 <<  3) /* TX Ring prio change */
-#define   NFP_NET_CFG_UPDATE_RXRPRIO      (0x1 <<  4) /* RX Ring prio change */
-#define   NFP_NET_CFG_UPDATE_MSIX         (0x1 <<  5) /* MSI-X change */
-#define   NFP_NET_CFG_UPDATE_L2SWITCH     (0x1 <<  6) /* Switch changes */
-#define   NFP_NET_CFG_UPDATE_RESET        (0x1 <<  7) /* Update due to FLR */
-#define   NFP_NET_CFG_UPDATE_IRQMOD       (0x1 <<  8) /* IRQ mod change */
-#define   NFP_NET_CFG_UPDATE_VXLAN        (0x1 <<  9) /* VXLAN port change */
-#define   NFP_NET_CFG_UPDATE_MACADDR      (0x1 << 11) /* MAC address change */
-#define   NFP_NET_CFG_UPDATE_MBOX         (0x1 << 12) /* Mailbox update */
-#define   NFP_NET_CFG_UPDATE_ERR          (0x1U << 31) /* A error occurred */
-#define NFP_NET_CFG_TXRS_ENABLE         0x0008
-#define NFP_NET_CFG_RXRS_ENABLE         0x0010
-#define NFP_NET_CFG_MTU                 0x0018
-#define NFP_NET_CFG_FLBUFSZ             0x001c
-#define NFP_NET_CFG_EXN                 0x001f
-#define NFP_NET_CFG_LSC                 0x0020
-#define NFP_NET_CFG_MACADDR             0x0024
-
-#define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2)
-#define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2)
-
-#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \
-					NFP_NET_CFG_CTRL_CSUM_COMPLETE)
-
-/* Version number helper defines */
-struct nfp_net_fw_ver {
-	uint8_t minor;
-	uint8_t major;
-	uint8_t class;
-	/**
-	 * This byte can be extended for more use.
-	 * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx
-	 * BIT[7:1]: reserved
-	 */
-	uint8_t extend;
-};
-
-/*
- * Read-only words (0x0030 - 0x0050):
- * @NFP_NET_CFG_VERSION:     Firmware version number
- * @NFP_NET_CFG_STS:         Status
- * @NFP_NET_CFG_CAP:         Capabilities (same bits as @NFP_NET_CFG_CTRL)
- * @NFP_NET_MAX_TXRINGS:     Maximum number of TX rings
- * @NFP_NET_MAX_RXRINGS:     Maximum number of RX rings
- * @NFP_NET_MAX_MTU:         Maximum support MTU
- * @NFP_NET_CFG_START_TXQ:   Start Queue Control Queue to use for TX (PF only)
- * @NFP_NET_CFG_START_RXQ:   Start Queue Control Queue to use for RX (PF only)
- *
- * TODO:
- * - define more STS bits
- */
-#define NFP_NET_CFG_VERSION             0x0030
-#define   NFP_NET_CFG_VERSION_DP_NFD3   0
-#define   NFP_NET_CFG_VERSION_DP_NFDK   1
-#define NFP_NET_CFG_STS                 0x0034
-#define   NFP_NET_CFG_STS_LINK            (0x1 << 0) /* Link up or down */
-/* Link rate */
-#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
-#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
-#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
-#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN       1
-#define   NFP_NET_CFG_STS_LINK_RATE_1G            2
-#define   NFP_NET_CFG_STS_LINK_RATE_10G           3
-#define   NFP_NET_CFG_STS_LINK_RATE_25G           4
-#define   NFP_NET_CFG_STS_LINK_RATE_40G           5
-#define   NFP_NET_CFG_STS_LINK_RATE_50G           6
-#define   NFP_NET_CFG_STS_LINK_RATE_100G          7
-
-/*
- * NSP Link rate is a 16-bit word. It is no longer determined by
- * firmware, instead it is read from the nfp_eth_table of the
- * associated pf_dev and written to the NFP_NET_CFG_STS_NSP_LINK_RATE
- * address by the PMD each time the port is reconfigured.
- */
-#define NFP_NET_CFG_STS_NSP_LINK_RATE   0x0036
-
-#define NFP_NET_CFG_CAP                 0x0038
-#define NFP_NET_CFG_MAX_TXRINGS         0x003c
-#define NFP_NET_CFG_MAX_RXRINGS         0x0040
-#define NFP_NET_CFG_MAX_MTU             0x0044
-/* Next two words are being used by VFs for solving THB350 issue */
-#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
- */
-#define NFP_NET_CFG_RX_OFFSET           0x0050
-#define NFP_NET_CFG_RX_OFFSET_DYNAMIC          0    /* Prepend mode */
-
-/* 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
-
-/* Offload definitions */
-#define NFP_NET_N_VXLAN_PORTS  (NFP_NET_CFG_VXLAN_SZ / sizeof(uint16_t))
-
-/*
- * 3 words reserved for extended ctrl words (0x0098 - 0x00a4)
- * 3 words reserved for extended cap words (0x00a4 - 0x00b0)
- * Currently only one word is used, can be extended in future.
- */
-#define NFP_NET_CFG_CTRL_WORD1          0x0098
-#define NFP_NET_CFG_CTRL_PKT_TYPE         (0x1 << 0)
-#define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
-#define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
-#define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
-
-#define NFP_NET_CFG_CAP_WORD1           0x00a4
-
-/* 16B reserved for future use (0x00b0 - 0x00c0). */
-#define NFP_NET_CFG_RESERVED            0x00b0
-#define NFP_NET_CFG_RESERVED_SZ         0x0010
-
-/*
- * RSS configuration (0x0100 - 0x01ac):
- * Used only when NFP_NET_CFG_CTRL_RSS_ANY is enabled
- * @NFP_NET_CFG_RSS_CFG:     RSS configuration word
- * @NFP_NET_CFG_RSS_KEY:     RSS "secret" key
- * @NFP_NET_CFG_RSS_ITBL:    RSS indirection table
- */
-#define NFP_NET_CFG_RSS_BASE            0x0100
-#define NFP_NET_CFG_RSS_CTRL            NFP_NET_CFG_RSS_BASE
-#define   NFP_NET_CFG_RSS_MASK            (0x7f)
-#define   NFP_NET_CFG_RSS_MASK_of(_x)     ((_x) & 0x7f)
-#define   NFP_NET_CFG_RSS_IPV4            (1 <<  8) /* RSS for IPv4 */
-#define   NFP_NET_CFG_RSS_IPV6            (1 <<  9) /* RSS for IPv6 */
-#define   NFP_NET_CFG_RSS_IPV4_TCP        (1 << 10) /* RSS for IPv4/TCP */
-#define   NFP_NET_CFG_RSS_IPV4_UDP        (1 << 11) /* RSS for IPv4/UDP */
-#define   NFP_NET_CFG_RSS_IPV6_TCP        (1 << 12) /* RSS for IPv6/TCP */
-#define   NFP_NET_CFG_RSS_IPV6_UDP        (1 << 13) /* RSS for IPv6/UDP */
-#define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
-#define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
-#define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
-#define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
-#define NFP_NET_CFG_RSS_KEY_SZ          0x28
-#define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
-					 NFP_NET_CFG_RSS_KEY_SZ)
-#define NFP_NET_CFG_RSS_ITBL_SZ         0x80
-
-/*
- * TX ring configuration (0x200 - 0x800)
- * @NFP_NET_CFG_TXR_BASE:    Base offset for TX ring configuration
- * @NFP_NET_CFG_TXR_ADDR:    Per TX ring DMA address (8B entries)
- * @NFP_NET_CFG_TXR_WB_ADDR: Per TX ring write back DMA address (8B entries)
- * @NFP_NET_CFG_TXR_SZ:      Per TX ring size (1B entries)
- * @NFP_NET_CFG_TXR_VEC:     Per TX ring MSI-X table entry (1B entries)
- * @NFP_NET_CFG_TXR_PRIO:    Per TX ring priority (1B entries)
- * @NFP_NET_CFG_TXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
- */
-#define NFP_NET_CFG_TXR_BASE            0x0200
-#define NFP_NET_CFG_TXR_ADDR(_x)        (NFP_NET_CFG_TXR_BASE + ((_x) * 0x8))
-#define NFP_NET_CFG_TXR_WB_ADDR(_x)     (NFP_NET_CFG_TXR_BASE + 0x200 + \
-					 ((_x) * 0x8))
-#define NFP_NET_CFG_TXR_SZ(_x)          (NFP_NET_CFG_TXR_BASE + 0x400 + (_x))
-#define NFP_NET_CFG_TXR_VEC(_x)         (NFP_NET_CFG_TXR_BASE + 0x440 + (_x))
-#define NFP_NET_CFG_TXR_PRIO(_x)        (NFP_NET_CFG_TXR_BASE + 0x480 + (_x))
-#define NFP_NET_CFG_TXR_IRQ_MOD(_x)     (NFP_NET_CFG_TXR_BASE + 0x500 + \
-					 ((_x) * 0x4))
-
-/*
- * RX ring configuration (0x0800 - 0x0c00)
- * @NFP_NET_CFG_RXR_BASE:    Base offset for RX ring configuration
- * @NFP_NET_CFG_RXR_ADDR:    Per TX ring DMA address (8B entries)
- * @NFP_NET_CFG_RXR_SZ:      Per TX ring size (1B entries)
- * @NFP_NET_CFG_RXR_VEC:     Per TX ring MSI-X table entry (1B entries)
- * @NFP_NET_CFG_RXR_PRIO:    Per TX ring priority (1B entries)
- * @NFP_NET_CFG_RXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
- */
-#define NFP_NET_CFG_RXR_BASE            0x0800
-#define NFP_NET_CFG_RXR_ADDR(_x)        (NFP_NET_CFG_RXR_BASE + ((_x) * 0x8))
-#define NFP_NET_CFG_RXR_SZ(_x)          (NFP_NET_CFG_RXR_BASE + 0x200 + (_x))
-#define NFP_NET_CFG_RXR_VEC(_x)         (NFP_NET_CFG_RXR_BASE + 0x240 + (_x))
-#define NFP_NET_CFG_RXR_PRIO(_x)        (NFP_NET_CFG_RXR_BASE + 0x280 + (_x))
-#define NFP_NET_CFG_RXR_IRQ_MOD(_x)     (NFP_NET_CFG_RXR_BASE + 0x300 + \
-					 ((_x) * 0x4))
-
-/*
- * Interrupt Control/Cause registers (0x0c00 - 0x0d00)
- * These registers are only used when MSI-X auto-masking is not
- * enabled (@NFP_NET_CFG_CTRL_MSIXAUTO not set).  The array is index
- * by MSI-X entry and are 1B in size.  If an entry is zero, the
- * corresponding entry is enabled.  If the FW generates an interrupt,
- * it writes a cause into the corresponding field.  This also masks
- * the MSI-X entry and the host driver must clear the register to
- * re-enable the interrupt.
- */
-#define NFP_NET_CFG_ICR_BASE            0x0c00
-#define NFP_NET_CFG_ICR(_x)             (NFP_NET_CFG_ICR_BASE + (_x))
-#define   NFP_NET_CFG_ICR_UNMASKED      0x0
-#define   NFP_NET_CFG_ICR_RXTX          0x1
-#define   NFP_NET_CFG_ICR_LSC           0x2
-
-/*
- * General device stats (0x0d00 - 0x0d90)
- * All counters are 64bit.
- */
-#define NFP_NET_CFG_STATS_BASE          0x0d00
-#define NFP_NET_CFG_STATS_RX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x00)
-#define NFP_NET_CFG_STATS_RX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x08)
-#define NFP_NET_CFG_STATS_RX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x10)
-#define NFP_NET_CFG_STATS_RX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x18)
-#define NFP_NET_CFG_STATS_RX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x20)
-#define NFP_NET_CFG_STATS_RX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x28)
-#define NFP_NET_CFG_STATS_RX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x30)
-#define NFP_NET_CFG_STATS_RX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x38)
-#define NFP_NET_CFG_STATS_RX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x40)
-
-#define NFP_NET_CFG_STATS_TX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x48)
-#define NFP_NET_CFG_STATS_TX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x50)
-#define NFP_NET_CFG_STATS_TX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x58)
-#define NFP_NET_CFG_STATS_TX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x60)
-#define NFP_NET_CFG_STATS_TX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x68)
-#define NFP_NET_CFG_STATS_TX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x70)
-#define NFP_NET_CFG_STATS_TX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x78)
-#define NFP_NET_CFG_STATS_TX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x80)
-#define NFP_NET_CFG_STATS_TX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x88)
-
-#define NFP_NET_CFG_STATS_APP0_FRAMES   (NFP_NET_CFG_STATS_BASE + 0x90)
-#define NFP_NET_CFG_STATS_APP0_BYTES    (NFP_NET_CFG_STATS_BASE + 0x98)
-#define NFP_NET_CFG_STATS_APP1_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xa0)
-#define NFP_NET_CFG_STATS_APP1_BYTES    (NFP_NET_CFG_STATS_BASE + 0xa8)
-#define NFP_NET_CFG_STATS_APP2_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xb0)
-#define NFP_NET_CFG_STATS_APP2_BYTES    (NFP_NET_CFG_STATS_BASE + 0xb8)
-#define NFP_NET_CFG_STATS_APP3_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xc0)
-#define NFP_NET_CFG_STATS_APP3_BYTES    (NFP_NET_CFG_STATS_BASE + 0xc8)
-
-/*
- * Per ring stats (0x1000 - 0x1800)
- * Options, 64bit per entry
- * @NFP_NET_CFG_TXR_STATS:   TX ring statistics (Packet and Byte count)
- * @NFP_NET_CFG_RXR_STATS:   RX ring statistics (Packet and Byte count)
- */
-#define NFP_NET_CFG_TXR_STATS_BASE      0x1000
-#define NFP_NET_CFG_TXR_STATS(_x)       (NFP_NET_CFG_TXR_STATS_BASE + \
-					 ((_x) * 0x10))
-#define NFP_NET_CFG_RXR_STATS_BASE      0x1400
-#define NFP_NET_CFG_RXR_STATS(_x)       (NFP_NET_CFG_RXR_STATS_BASE + \
-					 ((_x) * 0x10))
+#include <nfp_common_ctrl.h>
 
 /*
  * Mac stats (0x0000 - 0x0200)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 14/25] drivers: add the nfp common module
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (12 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 13/25] drivers: add the common ctrl module Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 15/25] drivers: move queue logic to " Chaoyong He
                       ` (13 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the nfp common module in the nfp 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/common/nfp/meson.build   |   3 +-
 drivers/common/nfp/nfp_common.c  | 177 +++++++++++++++++++++++
 drivers/common/nfp/nfp_common.h  | 232 +++++++++++++++++++++++++++++++
 drivers/common/nfp/version.map   |   6 +
 drivers/net/nfp/nfp_ethdev.c     |   4 +-
 drivers/net/nfp/nfp_ethdev_vf.c  |  16 +--
 drivers/net/nfp/nfp_net_common.c | 159 +--------------------
 drivers/net/nfp/nfp_net_common.h | 206 +--------------------------
 8 files changed, 423 insertions(+), 380 deletions(-)
 create mode 100644 drivers/common/nfp/nfp_common.c
 create mode 100644 drivers/common/nfp/nfp_common.h

diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
index cda5a930c7..cca7fb7796 100644
--- a/drivers/common/nfp/meson.build
+++ b/drivers/common/nfp/meson.build
@@ -7,8 +7,9 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
 endif
 
 sources = files(
+        'nfp_common.c',
         'nfp_common_log.c',
         'nfp_common_pci.c',
 )
 
-deps += ['bus_pci']
+deps += ['bus_pci', 'net']
diff --git a/drivers/common/nfp/nfp_common.c b/drivers/common/nfp/nfp_common.c
new file mode 100644
index 0000000000..1a98326980
--- /dev/null
+++ b/drivers/common/nfp/nfp_common.c
@@ -0,0 +1,177 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common.h"
+
+#include "nfp_common_log.h"
+
+/*
+ * This is used by the reconfig protocol. It sets the maximum time waiting in
+ * milliseconds before a reconfig timeout happens.
+ */
+#define NFP_NET_POLL_TIMEOUT    5000
+
+int
+nfp_reconfig_real(struct nfp_hw *hw,
+		uint32_t update)
+{
+	uint32_t cnt;
+	uint32_t new;
+	struct timespec wait;
+
+	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
+			hw->qcp_cfg);
+
+	if (hw->qcp_cfg == NULL) {
+		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
+		return -ENXIO;
+	}
+
+	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+
+	wait.tv_sec = 0;
+	wait.tv_nsec = 1000000; /* 1ms */
+
+	PMD_DRV_LOG(DEBUG, "Polling for update ack...");
+
+	/* Poll update field, waiting for NFP to ack the config */
+	for (cnt = 0; ; cnt++) {
+		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
+		if (new == 0)
+			break;
+
+		if ((new & NFP_NET_CFG_UPDATE_ERR) != 0) {
+			PMD_DRV_LOG(ERR, "Reconfig error: %#08x", new);
+			return -1;
+		}
+
+		if (cnt >= NFP_NET_POLL_TIMEOUT) {
+			PMD_DRV_LOG(ERR, "Reconfig timeout for %#08x after %u ms",
+					update, cnt);
+			return -EIO;
+		}
+
+		nanosleep(&wait, 0); /* waiting for a 1ms */
+	}
+
+	PMD_DRV_LOG(DEBUG, "Ack DONE");
+	return 0;
+}
+
+/**
+ * Reconfigure the NIC.
+ *
+ * Write the update word to the BAR and ping the reconfig queue. Then poll
+ * until the firmware has acknowledged the update by zeroing the update word.
+ *
+ * @param hw
+ *   Device to reconfigure.
+ * @param ctrl
+ *   The value for the ctrl field in the BAR config.
+ * @param update
+ *   The value for the update field in the BAR config.
+ *
+ * @return
+ *   - (0) if OK to reconfigure the device.
+ *   - (-EIO) if I/O err and fail to reconfigure the device.
+ */
+int
+nfp_reconfig(struct nfp_hw *hw,
+		uint32_t ctrl,
+		uint32_t update)
+{
+	int ret;
+
+	rte_spinlock_lock(&hw->reconfig_lock);
+
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+
+	rte_wmb();
+
+	ret = nfp_reconfig_real(hw, update);
+
+	rte_spinlock_unlock(&hw->reconfig_lock);
+
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Error nfp reconfig: ctrl=%#08x update=%#08x",
+				ctrl, update);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+/**
+ * Reconfigure the NIC for the extend ctrl BAR.
+ *
+ * Write the update word to the BAR and ping the reconfig queue. Then poll
+ * until the firmware has acknowledged the update by zeroing the update word.
+ *
+ * @param hw
+ *   Device to reconfigure.
+ * @param ctrl_ext
+ *   The value for the first word of extend ctrl field in the BAR config.
+ * @param update
+ *   The value for the update field in the BAR config.
+ *
+ * @return
+ *   - (0) if OK to reconfigure the device.
+ *   - (-EIO) if I/O err and fail to reconfigure the device.
+ */
+int
+nfp_ext_reconfig(struct nfp_hw *hw,
+		uint32_t ctrl_ext,
+		uint32_t update)
+{
+	int ret;
+
+	rte_spinlock_lock(&hw->reconfig_lock);
+
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+
+	rte_wmb();
+
+	ret = nfp_reconfig_real(hw, update);
+
+	rte_spinlock_unlock(&hw->reconfig_lock);
+
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Error nfp ext reconfig: ctrl_ext=%#08x update=%#08x",
+				ctrl_ext, update);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+void
+nfp_read_mac(struct nfp_hw *hw)
+{
+	uint32_t tmp;
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
+}
+
+void
+nfp_write_mac(struct nfp_hw *hw,
+		uint8_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;
+	mac1 = *(uint16_t *)mac;
+	nn_writew(rte_cpu_to_be_16(mac1),
+			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+}
diff --git a/drivers/common/nfp/nfp_common.h b/drivers/common/nfp/nfp_common.h
new file mode 100644
index 0000000000..5615cde6af
--- /dev/null
+++ b/drivers/common/nfp/nfp_common.h
@@ -0,0 +1,232 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_H__
+#define __NFP_COMMON_H__
+
+#include <rte_byteorder.h>
+#include <rte_ether.h>
+#include <rte_io.h>
+#include <rte_spinlock.h>
+
+#include "nfp_common_ctrl.h"
+
+#define NFP_QCP_QUEUE_ADDR_SZ   (0x800)
+
+/* Macros for accessing the Queue Controller Peripheral 'CSRs' */
+#define NFP_QCP_QUEUE_OFF(_x)                 ((_x) * 0x800)
+#define NFP_QCP_QUEUE_ADD_RPTR                  0x0000
+#define NFP_QCP_QUEUE_ADD_WPTR                  0x0004
+#define NFP_QCP_QUEUE_STS_LO                    0x0008
+#define NFP_QCP_QUEUE_STS_LO_READPTR_MASK     (0x3ffff)
+#define NFP_QCP_QUEUE_STS_HI                    0x000c
+#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK    (0x3ffff)
+
+/* Read or Write Pointer of a queue */
+enum nfp_qcp_ptr {
+	NFP_QCP_READ_PTR = 0,
+	NFP_QCP_WRITE_PTR
+};
+
+struct nfp_hw {
+	uint8_t *ctrl_bar;
+	uint8_t *qcp_cfg;
+	uint32_t cap;
+	uint32_t cap_ext;
+	uint32_t ctrl;
+	uint32_t ctrl_ext;
+	rte_spinlock_t reconfig_lock;
+	struct rte_ether_addr mac_addr;
+};
+
+static inline uint8_t
+nn_readb(volatile const void *addr)
+{
+	return rte_read8(addr);
+}
+
+static inline void
+nn_writeb(uint8_t val,
+		volatile void *addr)
+{
+	rte_write8(val, addr);
+}
+
+static inline uint32_t
+nn_readl(volatile const void *addr)
+{
+	return rte_read32(addr);
+}
+
+static inline void
+nn_writel(uint32_t val,
+		volatile void *addr)
+{
+	rte_write32(val, addr);
+}
+
+static inline uint16_t
+nn_readw(volatile const void *addr)
+{
+	return rte_read16(addr);
+}
+
+static inline void
+nn_writew(uint16_t val,
+		volatile void *addr)
+{
+	rte_write16(val, addr);
+}
+
+static inline uint64_t
+nn_readq(volatile void *addr)
+{
+	uint32_t low;
+	uint32_t high;
+	const volatile uint32_t *p = addr;
+
+	high = nn_readl((volatile const void *)(p + 1));
+	low = nn_readl((volatile const void *)p);
+
+	return low + ((uint64_t)high << 32);
+}
+
+static inline void
+nn_writeq(uint64_t val,
+		volatile void *addr)
+{
+	nn_writel(val >> 32, (volatile char *)addr + 4);
+	nn_writel(val, addr);
+}
+
+static inline uint8_t
+nn_cfg_readb(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return nn_readb(hw->ctrl_bar + off);
+}
+
+static inline void
+nn_cfg_writeb(struct nfp_hw *hw,
+		uint32_t off,
+		uint8_t val)
+{
+	nn_writeb(val, hw->ctrl_bar + off);
+}
+
+static inline uint16_t
+nn_cfg_readw(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writew(struct nfp_hw *hw,
+		uint32_t off,
+		uint16_t val)
+{
+	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
+}
+
+static inline uint32_t
+nn_cfg_readl(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writel(struct nfp_hw *hw,
+		uint32_t off,
+		uint32_t val)
+{
+	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
+}
+
+static inline uint64_t
+nn_cfg_readq(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writeq(struct nfp_hw *hw,
+		uint32_t off,
+		uint64_t val)
+{
+	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
+}
+
+/**
+ * Add the value to the selected pointer of a queue.
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Add to the read or write pointer
+ * @param val
+ *   Value to add to the queue pointer
+ */
+static inline void
+nfp_qcp_ptr_add(uint8_t *queue,
+		enum nfp_qcp_ptr ptr,
+		uint32_t val)
+{
+	uint32_t off;
+
+	if (ptr == NFP_QCP_READ_PTR)
+		off = NFP_QCP_QUEUE_ADD_RPTR;
+	else
+		off = NFP_QCP_QUEUE_ADD_WPTR;
+
+	nn_writel(rte_cpu_to_le_32(val), queue + off);
+}
+
+/**
+ * Read the current read/write pointer value for a queue.
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Read or Write pointer
+ */
+static inline uint32_t
+nfp_qcp_read(uint8_t *queue,
+		enum nfp_qcp_ptr ptr)
+{
+	uint32_t off;
+	uint32_t val;
+
+	if (ptr == NFP_QCP_READ_PTR)
+		off = NFP_QCP_QUEUE_STS_LO;
+	else
+		off = NFP_QCP_QUEUE_STS_HI;
+
+	val = rte_cpu_to_le_32(nn_readl(queue + off));
+
+	if (ptr == NFP_QCP_READ_PTR)
+		return val & NFP_QCP_QUEUE_STS_LO_READPTR_MASK;
+	else
+		return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK;
+}
+
+__rte_internal
+int nfp_reconfig_real(struct nfp_hw *hw, uint32_t update);
+
+__rte_internal
+int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
+
+__rte_internal
+int nfp_ext_reconfig(struct nfp_hw *hw, uint32_t ctrl_ext, uint32_t update);
+
+__rte_internal
+void nfp_read_mac(struct nfp_hw *hw);
+
+__rte_internal
+void nfp_write_mac(struct nfp_hw *hw, uint8_t *mac);
+
+#endif/* __NFP_COMMON_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index 25e48c39d6..f6a54a97cd 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -3,5 +3,11 @@ INTERNAL {
 
 	nfp_class_driver_register;
 
+	nfp_reconfig;
+	nfp_ext_reconfig;
+	nfp_reconfig_real;
+	nfp_read_mac;
+	nfp_write_mac;
+
 	local: *;
 };
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 3d4b78fbf1..76317925ec 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -600,13 +600,13 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+	nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 
 	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
 		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 049728d30c..b9cfb48021 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -15,18 +15,6 @@
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
 
-static void
-nfp_netvf_read_mac(struct nfp_hw *hw)
-{
-	uint32_t tmp;
-
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
-	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
-
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
-	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
-}
-
 static int
 nfp_netvf_start(struct rte_eth_dev *dev)
 {
@@ -334,12 +322,12 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(hw);
+	nfp_read_mac(hw);
 	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
 		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 01574de963..711532b466 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -19,12 +19,6 @@
 #define NFP_TX_MAX_SEG       UINT8_MAX
 #define NFP_TX_MAX_MTU_SEG   8
 
-/*
- * This is used by the reconfig protocol. It sets the maximum time waiting in
- * milliseconds before a reconfig timeout happens.
- */
-#define NFP_NET_POLL_TIMEOUT    5000
-
 #define NFP_NET_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
 #define NFP_NET_LINK_UP_CHECK_TIMEOUT   1000 /* ms */
 
@@ -198,141 +192,6 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 /* The length of firmware version string */
 #define FW_VER_LEN        32
 
-static int
-nfp_reconfig_real(struct nfp_hw *hw,
-		uint32_t update)
-{
-	uint32_t cnt;
-	uint32_t new;
-	struct timespec wait;
-
-	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->qcp_cfg);
-
-	if (hw->qcp_cfg == NULL) {
-		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
-		return -ENXIO;
-	}
-
-	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
-
-	wait.tv_sec = 0;
-	wait.tv_nsec = 1000000; /* 1ms */
-
-	PMD_DRV_LOG(DEBUG, "Polling for update ack...");
-
-	/* Poll update field, waiting for NFP to ack the config */
-	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
-		if (new == 0)
-			break;
-
-		if ((new & NFP_NET_CFG_UPDATE_ERR) != 0) {
-			PMD_DRV_LOG(ERR, "Reconfig error: %#08x", new);
-			return -1;
-		}
-
-		if (cnt >= NFP_NET_POLL_TIMEOUT) {
-			PMD_DRV_LOG(ERR, "Reconfig timeout for %#08x after %u ms",
-					update, cnt);
-			return -EIO;
-		}
-
-		nanosleep(&wait, 0); /* Waiting for a 1ms */
-	}
-
-	PMD_DRV_LOG(DEBUG, "Ack DONE");
-	return 0;
-}
-
-/**
- * Reconfigure the NIC.
- *
- * Write the update word to the BAR and ping the reconfig queue. Then poll
- * until the firmware has acknowledged the update by zeroing the update word.
- *
- * @param hw
- *   Device to reconfigure.
- * @param ctrl
- *   The value for the ctrl field in the BAR config.
- * @param update
- *   The value for the update field in the BAR config.
- *
- * @return
- *   - (0) if OK to reconfigure the device.
- *   - (-EIO) if I/O err and fail to reconfigure the device.
- */
-int
-nfp_reconfig(struct nfp_hw *hw,
-		uint32_t ctrl,
-		uint32_t update)
-{
-	int ret;
-
-	rte_spinlock_lock(&hw->reconfig_lock);
-
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
-
-	rte_wmb();
-
-	ret = nfp_reconfig_real(hw, update);
-
-	rte_spinlock_unlock(&hw->reconfig_lock);
-
-	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp reconfig: ctrl=%#08x update=%#08x",
-				ctrl, update);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-/**
- * Reconfigure the NIC for the extend ctrl BAR.
- *
- * Write the update word to the BAR and ping the reconfig queue. Then poll
- * until the firmware has acknowledged the update by zeroing the update word.
- *
- * @param hw
- *   Device to reconfigure.
- * @param ctrl_ext
- *   The value for the first word of extend ctrl field in the BAR config.
- * @param update
- *   The value for the update field in the BAR config.
- *
- * @return
- *   - (0) if OK to reconfigure the device.
- *   - (-EIO) if I/O err and fail to reconfigure the device.
- */
-int
-nfp_ext_reconfig(struct nfp_hw *hw,
-		uint32_t ctrl_ext,
-		uint32_t update)
-{
-	int ret;
-
-	rte_spinlock_lock(&hw->reconfig_lock);
-
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
-
-	rte_wmb();
-
-	ret = nfp_reconfig_real(hw, update);
-
-	rte_spinlock_unlock(&hw->reconfig_lock);
-
-	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp ext reconfig: ctrl_ext=%#08x update=%#08x",
-				ctrl_ext, update);
-		return -EIO;
-	}
-
-	return 0;
-}
-
 /**
  * Reconfigure the firmware via the mailbox
  *
@@ -531,22 +390,6 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 	hw->super.qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }
 
-void
-nfp_net_write_mac(struct nfp_hw *hw,
-		uint8_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;
-	mac1 = *(uint16_t *)mac;
-	nn_writew(rte_cpu_to_be_16(mac1),
-			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
-}
-
 int
 nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 		struct rte_ether_addr *mac_addr)
@@ -565,7 +408,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
+	nfp_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index e997756091..9461440d0b 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -8,21 +8,12 @@
 
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
-#include <rte_io.h>
+#include <nfp_common.h>
 #include <rte_spinlock.h>
 
 #include "nfp_net_ctrl.h"
 #include "nfpcore/nfp_dev.h"
 
-/* Macros for accessing the Queue Controller Peripheral 'CSRs' */
-#define NFP_QCP_QUEUE_OFF(_x)                 ((_x) * 0x800)
-#define NFP_QCP_QUEUE_ADD_RPTR                  0x0000
-#define NFP_QCP_QUEUE_ADD_WPTR                  0x0004
-#define NFP_QCP_QUEUE_STS_LO                    0x0008
-#define NFP_QCP_QUEUE_STS_LO_READPTR_MASK     (0x3ffff)
-#define NFP_QCP_QUEUE_STS_HI                    0x000c
-#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK    (0x3ffff)
-
 /* Interrupt definitions */
 #define NFP_NET_IRQ_LSC_IDX             0
 
@@ -42,8 +33,6 @@
 /* Alignment for dma zones */
 #define NFP_MEMZONE_ALIGN       128
 
-#define NFP_QCP_QUEUE_ADDR_SZ   (0x800)
-
 /* Number of supported physical ports */
 #define NFP_MAX_PHYPORTS        12
 
@@ -53,12 +42,6 @@ enum nfp_app_fw_id {
 	NFP_APP_FW_FLOWER_NIC             = 0x3,
 };
 
-/* Read or Write Pointer of a queue */
-enum nfp_qcp_ptr {
-	NFP_QCP_READ_PTR = 0,
-	NFP_QCP_WRITE_PTR
-};
-
 enum nfp_net_meta_format {
 	NFP_NET_METAFORMAT_SINGLE,
 	NFP_NET_METAFORMAT_CHAINED,
@@ -112,17 +95,6 @@ struct nfp_app_fw_nic {
 	uint8_t total_phyports;
 };
 
-struct nfp_hw {
-	uint8_t *ctrl_bar;
-	uint8_t *qcp_cfg;
-	uint32_t cap;
-	uint32_t cap_ext;
-	uint32_t ctrl;
-	uint32_t ctrl_ext;
-	rte_spinlock_t reconfig_lock;
-	struct rte_ether_addr mac_addr;
-};
-
 struct nfp_net_hw {
 	/** The parent class */
 	struct nfp_hw super;
@@ -184,179 +156,6 @@ struct nfp_net_adapter {
 	struct nfp_net_hw hw;
 };
 
-static inline uint8_t
-nn_readb(volatile const void *addr)
-{
-	return rte_read8(addr);
-}
-
-static inline void
-nn_writeb(uint8_t val,
-		volatile void *addr)
-{
-	rte_write8(val, addr);
-}
-
-static inline uint32_t
-nn_readl(volatile const void *addr)
-{
-	return rte_read32(addr);
-}
-
-static inline void
-nn_writel(uint32_t val,
-		volatile void *addr)
-{
-	rte_write32(val, addr);
-}
-
-static inline uint16_t
-nn_readw(volatile const void *addr)
-{
-	return rte_read16(addr);
-}
-
-static inline void
-nn_writew(uint16_t val,
-		volatile void *addr)
-{
-	rte_write16(val, addr);
-}
-
-static inline uint64_t
-nn_readq(volatile void *addr)
-{
-	uint32_t low;
-	uint32_t high;
-	const volatile uint32_t *p = addr;
-
-	high = nn_readl((volatile const void *)(p + 1));
-	low = nn_readl((volatile const void *)p);
-
-	return low + ((uint64_t)high << 32);
-}
-
-static inline void
-nn_writeq(uint64_t val,
-		volatile void *addr)
-{
-	nn_writel(val >> 32, (volatile char *)addr + 4);
-	nn_writel(val, addr);
-}
-
-static inline uint8_t
-nn_cfg_readb(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return nn_readb(hw->ctrl_bar + off);
-}
-
-static inline void
-nn_cfg_writeb(struct nfp_hw *hw,
-		uint32_t off,
-		uint8_t val)
-{
-	nn_writeb(val, hw->ctrl_bar + off);
-}
-
-static inline uint16_t
-nn_cfg_readw(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writew(struct nfp_hw *hw,
-		uint32_t off,
-		uint16_t val)
-{
-	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
-}
-
-static inline uint32_t
-nn_cfg_readl(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writel(struct nfp_hw *hw,
-		uint32_t off,
-		uint32_t val)
-{
-	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
-}
-
-static inline uint64_t
-nn_cfg_readq(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writeq(struct nfp_hw *hw,
-		uint32_t off,
-		uint64_t val)
-{
-	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
-}
-
-/**
- * Add the value to the selected pointer of a queue.
- *
- * @param queue
- *   Base address for queue structure
- * @param ptr
- *   Add to the read or write pointer
- * @param val
- *   Value to add to the queue pointer
- */
-static inline void
-nfp_qcp_ptr_add(uint8_t *queue,
-		enum nfp_qcp_ptr ptr,
-		uint32_t val)
-{
-	uint32_t off;
-
-	if (ptr == NFP_QCP_READ_PTR)
-		off = NFP_QCP_QUEUE_ADD_RPTR;
-	else
-		off = NFP_QCP_QUEUE_ADD_WPTR;
-
-	nn_writel(rte_cpu_to_le_32(val), queue + off);
-}
-
-/**
- * Read the current read/write pointer value for a queue.
- *
- * @param queue
- *   Base address for queue structure
- * @param ptr
- *   Read or Write pointer
- */
-static inline uint32_t
-nfp_qcp_read(uint8_t *queue,
-		enum nfp_qcp_ptr ptr)
-{
-	uint32_t off;
-	uint32_t val;
-
-	if (ptr == NFP_QCP_READ_PTR)
-		off = NFP_QCP_QUEUE_STS_LO;
-	else
-		off = NFP_QCP_QUEUE_STS_HI;
-
-	val = rte_cpu_to_le_32(nn_readl(queue + off));
-
-	if (ptr == NFP_QCP_READ_PTR)
-		return val & NFP_QCP_QUEUE_STS_LO_READPTR_MASK;
-	else
-		return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK;
-}
-
 static inline uint32_t
 nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 		uint16_t queue)
@@ -366,8 +165,6 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 }
 
 /* Prototypes for common NFP functions */
-int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
-int nfp_ext_reconfig(struct nfp_hw *hw, uint32_t ctrl_ext, uint32_t update);
 int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
 int nfp_net_configure(struct rte_eth_dev *dev);
 int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw);
@@ -375,7 +172,6 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_net_write_mac(struct nfp_hw *hw, uint8_t *mac);
 int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 		struct rte_intr_handle *intr_handle);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 15/25] drivers: move queue logic to common module
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (13 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 14/25] drivers: add the nfp common module Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 16/25] drivers: move platform module to common library Chaoyong He
                       ` (12 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the queue enable/disable logic to the 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/common/nfp/nfp_common.c  | 49 ++++++++++++++++++++++++++++++++
 drivers/common/nfp/nfp_common.h  |  7 +++++
 drivers/common/nfp/version.map   |  2 ++
 drivers/net/nfp/nfp_net_common.c | 38 ++-----------------------
 4 files changed, 61 insertions(+), 35 deletions(-)

diff --git a/drivers/common/nfp/nfp_common.c b/drivers/common/nfp/nfp_common.c
index 1a98326980..4c94c9d59a 100644
--- a/drivers/common/nfp/nfp_common.c
+++ b/drivers/common/nfp/nfp_common.c
@@ -175,3 +175,52 @@ nfp_write_mac(struct nfp_hw *hw,
 	nn_writew(rte_cpu_to_be_16(mac1),
 			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
 }
+
+void
+nfp_enable_queues(struct nfp_hw *hw,
+		uint16_t nb_rx_queues,
+		uint16_t nb_tx_queues)
+{
+	int i;
+	uint64_t enabled_queues;
+
+	/* Enabling the required TX queues in the device */
+	enabled_queues = 0;
+	for (i = 0; i < nb_tx_queues; i++)
+		enabled_queues |= (1 << i);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+
+	/* Enabling the required RX queues in the device */
+	enabled_queues = 0;
+	for (i = 0; i < nb_rx_queues; i++)
+		enabled_queues |= (1 << i);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+}
+
+void
+nfp_disable_queues(struct nfp_hw *hw)
+{
+	int ret;
+	uint32_t update;
+	uint32_t new_ctrl;
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	update = NFP_NET_CFG_UPDATE_GEN |
+			NFP_NET_CFG_UPDATE_RING |
+			NFP_NET_CFG_UPDATE_MSIX;
+
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
+
+	/* If an error when reconfig we avoid to change hw state */
+	ret = nfp_reconfig(hw, new_ctrl, update);
+	if (ret < 0)
+		return;
+
+	hw->ctrl = new_ctrl;
+}
diff --git a/drivers/common/nfp/nfp_common.h b/drivers/common/nfp/nfp_common.h
index 5615cde6af..7597d4090b 100644
--- a/drivers/common/nfp/nfp_common.h
+++ b/drivers/common/nfp/nfp_common.h
@@ -229,4 +229,11 @@ void nfp_read_mac(struct nfp_hw *hw);
 __rte_internal
 void nfp_write_mac(struct nfp_hw *hw, uint8_t *mac);
 
+__rte_internal
+void nfp_enable_queues(struct nfp_hw *hw, uint16_t nb_rx_queues,
+		uint16_t nb_tx_queues);
+
+__rte_internal
+void nfp_disable_queues(struct nfp_hw *hw);
+
 #endif/* __NFP_COMMON_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index f6a54a97cd..c1e03d8b8d 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -8,6 +8,8 @@ INTERNAL {
 	nfp_reconfig_real;
 	nfp_read_mac;
 	nfp_write_mac;
+	nfp_enable_queues;
+	nfp_disable_queues;
 
 	local: *;
 };
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 711532b466..090feb0e39 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -327,54 +327,22 @@ nfp_net_enable_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;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	/* Enabling the required TX queues in the device */
-	enabled_queues = 0;
-	for (i = 0; i < dev->data->nb_tx_queues; i++)
-		enabled_queues |= (1 << i);
-
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
-
-	/* Enabling the required RX queues in the device */
-	enabled_queues = 0;
-	for (i = 0; i < dev->data->nb_rx_queues; i++)
-		enabled_queues |= (1 << i);
-
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nfp_enable_queues(&hw->super, dev->data->nb_rx_queues,
+			dev->data->nb_tx_queues);
 }
 
 void
 nfp_net_disable_queues(struct rte_eth_dev *dev)
 {
-	uint32_t update;
-	uint32_t new_ctrl;
-	struct nfp_hw *hw;
 	struct nfp_net_hw *net_hw;
 
 	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	hw = &net_hw->super;
-
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
-
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
-	update = NFP_NET_CFG_UPDATE_GEN |
-			NFP_NET_CFG_UPDATE_RING |
-			NFP_NET_CFG_UPDATE_MSIX;
-
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
-		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
-	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_reconfig(hw, new_ctrl, update) != 0)
-		return;
-
-	hw->ctrl = new_ctrl;
+	nfp_disable_queues(&net_hw->super);
 }
 
 void
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 16/25] drivers: move platform module to common library
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (14 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 15/25] drivers: move queue logic to " Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 17/25] drivers: move device " Chaoyong He
                       ` (11 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the platform module to the 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/nfpcore => common/nfp}/nfp_platform.h | 0
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c                     | 2 +-
 drivers/net/nfp/nfp_net_ctrl.c                         | 3 +--
 drivers/net/nfp/nfpcore/nfp_cppcore.c                  | 3 ++-
 drivers/net/nfp/nfpcore/nfp_dev.c                      | 3 +--
 drivers/net/nfp/nfpcore/nfp_nsp.c                      | 2 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c                  | 3 ++-
 7 files changed, 8 insertions(+), 8 deletions(-)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_platform.h (100%)

diff --git a/drivers/net/nfp/nfpcore/nfp_platform.h b/drivers/common/nfp/nfp_platform.h
similarity index 100%
rename from drivers/net/nfp/nfpcore/nfp_platform.h
rename to drivers/common/nfp/nfp_platform.h
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 3f8d25aa29..10e6982c95 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -6,10 +6,10 @@
 #include "nfp_nfdk.h"
 
 #include <bus_pci_driver.h>
+#include <nfp_platform.h>
 #include <rte_malloc.h>
 
 #include "../flower/nfp_flower.h"
-#include "../nfpcore/nfp_platform.h"
 #include "../nfp_logs.h"
 
 #define NFDK_TX_DESC_GATHER_MAX         17
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index 8848fa38fe..5135a1ad27 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -6,8 +6,7 @@
 #include "nfp_net_ctrl.h"
 
 #include <ethdev_pci.h>
-
-#include "nfpcore/nfp_platform.h"
+#include <nfp_platform.h>
 
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index f9b08a12b6..0e6045f2f0 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -5,8 +5,9 @@
 
 #include "nfp_cpp.h"
 
+#include <nfp_platform.h>
+
 #include "nfp_logs.h"
-#include "nfp_platform.h"
 #include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
 #include "nfp6000/nfp_xpb.h"
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.c b/drivers/net/nfp/nfpcore/nfp_dev.c
index 7799fa699a..f29b7e0711 100644
--- a/drivers/net/nfp/nfpcore/nfp_dev.c
+++ b/drivers/net/nfp/nfpcore/nfp_dev.c
@@ -5,10 +5,9 @@
 
 #include "nfp_dev.h"
 
+#include <nfp_platform.h>
 #include <rte_bitops.h>
 
-#include "nfp_platform.h"
-
 /*
  * Note: The value of 'max_qc_size' is different from kernel driver,
  * because DPDK use 'uint16_t' as the data type.
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index 5b804f6174..a680b972b8 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -5,10 +5,10 @@
 
 #include "nfp_nsp.h"
 
+#include <nfp_platform.h>
 #include <rte_common.h>
 
 #include "nfp_logs.h"
-#include "nfp_platform.h"
 #include "nfp_resource.h"
 
 /* Offsets relative to the CSR base */
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
index cc472907ca..75f6d40fea 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
@@ -3,9 +3,10 @@
  * All rights reserved.
  */
 
+#include <nfp_platform.h>
+
 #include "nfp_logs.h"
 #include "nfp_nsp.h"
-#include "nfp_platform.h"
 
 #define NSP_ETH_NBI_PORT_COUNT          24
 #define NSP_ETH_MAX_COUNT               (2 * NSP_ETH_NBI_PORT_COUNT)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 17/25] drivers: move device module to common library
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (15 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 16/25] drivers: move platform module to common library Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
                       ` (10 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the device module to the 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/common/nfp/meson.build                    | 1 +
 drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c | 0
 drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h | 3 +++
 drivers/common/nfp/version.map                    | 1 +
 drivers/net/nfp/meson.build                       | 1 -
 drivers/net/nfp/nfp_net_common.h                  | 2 +-
 drivers/net/nfp/nfpcore/nfp6000_pcie.h            | 2 +-
 7 files changed, 7 insertions(+), 3 deletions(-)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c (100%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h (96%)

diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
index cca7fb7796..a09d1e25e2 100644
--- a/drivers/common/nfp/meson.build
+++ b/drivers/common/nfp/meson.build
@@ -10,6 +10,7 @@ sources = files(
         'nfp_common.c',
         'nfp_common_log.c',
         'nfp_common_pci.c',
+        'nfp_dev.c',
 )
 
 deps += ['bus_pci', 'net']
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.c b/drivers/common/nfp/nfp_dev.c
similarity index 100%
rename from drivers/net/nfp/nfpcore/nfp_dev.c
rename to drivers/common/nfp/nfp_dev.c
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.h b/drivers/common/nfp/nfp_dev.h
similarity index 96%
rename from drivers/net/nfp/nfpcore/nfp_dev.h
rename to drivers/common/nfp/nfp_dev.h
index b0fffff619..ffcdd17227 100644
--- a/drivers/net/nfp/nfpcore/nfp_dev.h
+++ b/drivers/common/nfp/nfp_dev.h
@@ -8,6 +8,8 @@
 
 #include <stdint.h>
 
+#include <rte_compat.h>
+
 #define PCI_VENDOR_ID_NETRONOME         0x19ee
 #define PCI_VENDOR_ID_CORIGINE          0x1da8
 
@@ -39,6 +41,7 @@ struct nfp_dev_info {
 	uint8_t pf_num_per_unit;
 };
 
+__rte_internal
 const struct nfp_dev_info *nfp_dev_info_get(uint16_t device_id);
 
 #endif /* __NFP_DEV_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index c1e03d8b8d..c8a04b1b95 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -10,6 +10,7 @@ INTERNAL {
 	nfp_write_mac;
 	nfp_enable_queues;
 	nfp_disable_queues;
+	nfp_dev_info_get;
 
 	local: *;
 };
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index fa99c3b6aa..cf9c16266d 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -16,7 +16,6 @@ sources = files(
         'nfdk/nfp_nfdk_dp.c',
         'nfpcore/nfp_cppcore.c',
         'nfpcore/nfp_crc.c',
-        'nfpcore/nfp_dev.c',
         'nfpcore/nfp_hwinfo.c',
         'nfpcore/nfp_mip.c',
         'nfpcore/nfp_mutex.c',
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 9461440d0b..6607175460 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -9,10 +9,10 @@
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
 #include <nfp_common.h>
+#include <nfp_dev.h>
 #include <rte_spinlock.h>
 
 #include "nfp_net_ctrl.h"
-#include "nfpcore/nfp_dev.h"
 
 /* Interrupt definitions */
 #define NFP_NET_IRQ_LSC_IDX             0
diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.h b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
index 8e2cfb69e6..59b58ddd04 100644
--- a/drivers/net/nfp/nfpcore/nfp6000_pcie.h
+++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
@@ -7,9 +7,9 @@
 #define __NFP6000_PCIE_H__
 
 #include <ethdev_pci.h>
+#include <nfp_dev.h>
 
 #include "nfp_cpp.h"
-#include "nfp_dev.h"
 
 const struct nfp_cpp_operations *nfp_cpp_transport_operations(void);
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 18/25] drivers/vdpa: introduce the NFP vDPA library
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (16 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 17/25] drivers: move device " Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
                       ` (9 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Introduce the very basic NFP vDPA library.

Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
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>
---
 MAINTAINERS                          |  6 ++++
 doc/guides/vdpadevs/features/nfp.ini |  8 +++++
 doc/guides/vdpadevs/index.rst        |  1 +
 doc/guides/vdpadevs/nfp.rst          | 54 ++++++++++++++++++++++++++++
 drivers/vdpa/meson.build             |  1 +
 drivers/vdpa/nfp/meson.build         | 13 +++++++
 drivers/vdpa/nfp/nfp_vdpa_log.c      |  9 +++++
 drivers/vdpa/nfp/nfp_vdpa_log.h      | 21 +++++++++++
 8 files changed, 113 insertions(+)
 create mode 100644 doc/guides/vdpadevs/features/nfp.ini
 create mode 100644 doc/guides/vdpadevs/nfp.rst
 create mode 100644 drivers/vdpa/nfp/meson.build
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5273ab9812..f463188f1d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1301,6 +1301,12 @@ vDPA Drivers
 T: git://dpdk.org/next/dpdk-next-virtio
 F: drivers/vdpa/meson.build
 
+Corigine nfp vDPA
+M: Chaoyong He <chaoyong.he@corigine.com>
+F: drivers/vdpa/nfp/
+F: doc/guides/vpdadevs/nfp.rst
+F: doc/guides/vdpadevs/features/nfp.ini
+
 Intel ifc
 M: Xiao Wang <xiao.w.wang@intel.com>
 F: drivers/vdpa/ifc/
diff --git a/doc/guides/vdpadevs/features/nfp.ini b/doc/guides/vdpadevs/features/nfp.ini
new file mode 100644
index 0000000000..d830feafe0
--- /dev/null
+++ b/doc/guides/vdpadevs/features/nfp.ini
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'nfp' vDPA driver.
+;
+; Refer to default.ini for the full list of available driver features.
+;
+[Features]
+Linux                   = Y
+x86-64                  = Y
diff --git a/doc/guides/vdpadevs/index.rst b/doc/guides/vdpadevs/index.rst
index cc2f858042..b0191a3a1d 100644
--- a/doc/guides/vdpadevs/index.rst
+++ b/doc/guides/vdpadevs/index.rst
@@ -14,4 +14,5 @@ which can be used from an application through vhost API.
     features_overview
     ifc
     mlx5
+    nfp
     sfc
diff --git a/doc/guides/vdpadevs/nfp.rst b/doc/guides/vdpadevs/nfp.rst
new file mode 100644
index 0000000000..63636b2882
--- /dev/null
+++ b/doc/guides/vdpadevs/nfp.rst
@@ -0,0 +1,54 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (c) 2023 Corigine, Inc.
+
+NFP vDPA driver
+===============
+
+The NFP vDPA (vhost data path acceleration) driver (**librte_nfp_vdpa**)
+provides support for the Netronome and Corigine's NFP-6xxx, NFP-4xxx
+and NFP-38xx product lines.
+
+NFP vDPA implementation
+-----------------------
+
+NFP VF device can be configured in the net device or vDPA mode.
+Adding "class=vdpa" parameter helps to specify that this device is to
+be used in vDPA mode. If this parameter is not specified, device
+will be probed by net/nfp driver and will used as a VF net device.
+
+This PMD uses (common/nfp) code to access the device firmware.
+
+Per-Device Parameters
+~~~~~~~~~~~~~~~~~~~~~
+
+The following per-device parameters can be passed via EAL PCI device
+allowlist option like "-a 02:00.0,arg1=value1,...".
+
+- ``class`` [net|vdpa] (default **net**)
+
+  Choose the mode of operation of nfp device.
+  **net** device will work as network device and will be probed by net/nfp driver.
+  **vdpa** device will work as vdpa device and will be probed by vdpa/nfp driver.
+  If this parameter is not specified then nfp device will operate as network device.
+
+Dynamic Logging Parameters
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+One may leverage EAL option "--log-level" to change default levels
+for the log types supported by the driver. The option is used with
+an argument typically consisting of two parts separated by a colon.
+
+Level value is the last part which takes a symbolic name (or integer).
+Log type is the former part which may shell match syntax.
+Depending on the choice of the expression, the given log level may
+be used either for some specific log type or for a subset of types.
+
+NFP vDPA PMD provides the following log types available for control:
+
+- ``pmd.vdpa.nfp.vdpa`` (default level is **notice**)
+
+  Affects driver-wide messages unrelated to any particular devices.
+
+- ``pmd.vdpa.nfp.core`` (default level is **notice**)
+
+  Affects the core logic of this PMD.
diff --git a/drivers/vdpa/meson.build b/drivers/vdpa/meson.build
index 77412c7d09..896e8e0304 100644
--- a/drivers/vdpa/meson.build
+++ b/drivers/vdpa/meson.build
@@ -8,6 +8,7 @@ endif
 drivers = [
         'ifc',
         'mlx5',
+        'nfp',
         'sfc',
 ]
 std_deps = ['bus_pci', 'kvargs']
diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
new file mode 100644
index 0000000000..5eff240055
--- /dev/null
+++ b/drivers/vdpa/nfp/meson.build
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64-bit Linux'
+endif
+
+sources = files(
+        'nfp_vdpa_log.c',
+)
+
+deps += ['vhost']
diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.c b/drivers/vdpa/nfp/nfp_vdpa_log.c
new file mode 100644
index 0000000000..f5ada20713
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_log.c
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_vdpa_log.h"
+
+RTE_LOG_REGISTER_SUFFIX(nfp_logtype_core, core, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(nfp_logtype_vdpa, vdpa, NOTICE);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.h b/drivers/vdpa/nfp/nfp_vdpa_log.h
new file mode 100644
index 0000000000..cf342329b1
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_log.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_VDPA_LOG_H__
+#define __NFP_VDPA_LOG_H__
+
+#include <rte_log.h>
+
+extern int nfp_logtype_vdpa;
+#define DRV_VDPA_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_logtype_vdpa, \
+		"NFP_VDPA: %s(): " fmt "\n", __func__, ## args)
+
+extern int nfp_logtype_core;
+#define DRV_CORE_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_logtype_core, \
+		"NFP_CORE: %s(): " fmt "\n", __func__, ## args)
+
+#endif /* __NFP_VDPA_LOG_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 19/25] drivers: add the basic framework of vDPA PMD
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (17 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
                       ` (8 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the basic framework of vDPA PMD.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_pci.c |   1 +
 drivers/common/nfp/nfp_common_pci.h |   1 +
 drivers/vdpa/nfp/meson.build        |   3 +-
 drivers/vdpa/nfp/nfp_vdpa.c         | 153 ++++++++++++++++++++++++++++
 4 files changed, 157 insertions(+), 1 deletion(-)
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa.c

diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
index 65f189b05e..723035d0f7 100644
--- a/drivers/common/nfp/nfp_common_pci.c
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -32,6 +32,7 @@ static const struct {
 	enum nfp_class drv_class;
 } nfp_classes[] = {
 	{ .name = "eth",      .drv_class = NFP_CLASS_ETH },
+	{ .name = "vdpa",     .drv_class = NFP_CLASS_VDPA },
 };
 
 static enum nfp_class
diff --git a/drivers/common/nfp/nfp_common_pci.h b/drivers/common/nfp/nfp_common_pci.h
index 21465fca68..80c027c3a5 100644
--- a/drivers/common/nfp/nfp_common_pci.h
+++ b/drivers/common/nfp/nfp_common_pci.h
@@ -16,6 +16,7 @@ typedef int (nfp_class_driver_remove_t)(struct rte_pci_device *dev);
 
 enum nfp_class {
 	NFP_CLASS_ETH,
+	NFP_CLASS_VDPA,
 	NFP_CLASS_INVALID,
 };
 
diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
index 5eff240055..79a0364917 100644
--- a/drivers/vdpa/nfp/meson.build
+++ b/drivers/vdpa/nfp/meson.build
@@ -7,7 +7,8 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
 endif
 
 sources = files(
+        'nfp_vdpa.c',
         'nfp_vdpa_log.c',
 )
 
-deps += ['vhost']
+deps += ['vhost', 'common_nfp']
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
new file mode 100644
index 0000000000..ef4ae4946a
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -0,0 +1,153 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include <pthread.h>
+
+#include <nfp_common_pci.h>
+#include <nfp_dev.h>
+#include <vdpa_driver.h>
+
+#include "nfp_vdpa_log.h"
+
+#define NFP_VDPA_DRIVER_NAME nfp_vdpa
+
+struct nfp_vdpa_dev {
+	struct rte_pci_device *pci_dev;
+	struct rte_vdpa_device *vdev;
+};
+
+struct nfp_vdpa_dev_node {
+	TAILQ_ENTRY(nfp_vdpa_dev_node) next;
+	struct nfp_vdpa_dev *device;
+};
+
+TAILQ_HEAD(vdpa_dev_list_head, nfp_vdpa_dev_node);
+
+static struct vdpa_dev_list_head vdpa_dev_list =
+	TAILQ_HEAD_INITIALIZER(vdpa_dev_list);
+
+static pthread_mutex_t vdpa_list_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static struct nfp_vdpa_dev_node *
+nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
+{
+	bool found = false;
+	struct nfp_vdpa_dev_node *node;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+
+	TAILQ_FOREACH(node, &vdpa_dev_list, next) {
+		if (pdev == node->device->pci_dev) {
+			found = true;
+			break;
+		}
+	}
+
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	if (found)
+		return node;
+
+	return NULL;
+}
+
+struct rte_vdpa_dev_ops nfp_vdpa_ops = {
+};
+
+static int
+nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
+{
+	struct nfp_vdpa_dev *device;
+	struct nfp_vdpa_dev_node *node;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	node = calloc(1, sizeof(*node));
+	if (node == NULL)
+		return -ENOMEM;
+
+	device = calloc(1, sizeof(*device));
+	if (device == NULL)
+		goto free_node;
+
+	device->pci_dev = pci_dev;
+
+	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
+	if (device->vdev == NULL) {
+		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
+		goto free_device;
+	}
+
+	node->device = device;
+	pthread_mutex_lock(&vdpa_list_lock);
+	TAILQ_INSERT_TAIL(&vdpa_dev_list, node, next);
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	return 0;
+
+free_device:
+	free(device);
+free_node:
+	free(node);
+
+	return -1;
+}
+
+static int
+nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
+{
+	struct nfp_vdpa_dev *device;
+	struct nfp_vdpa_dev_node *node;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	node = nfp_vdpa_find_node_by_pdev(pci_dev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid device: %s", pci_dev->name);
+		return -ENODEV;
+	}
+
+	device = node->device;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+	TAILQ_REMOVE(&vdpa_dev_list, node, next);
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	rte_vdpa_unregister_device(device->vdev);
+
+	free(device);
+	free(node);
+
+	return 0;
+}
+
+static const struct rte_pci_id pci_id_nfp_vdpa_map[] = {
+	{
+		RTE_PCI_DEVICE(PCI_VENDOR_ID_NETRONOME,
+				PCI_DEVICE_ID_NFP6000_VF_NIC)
+	},
+	{
+		.vendor_id = 0,
+	},
+};
+
+static struct nfp_class_driver nfp_vdpa = {
+	.drv_class = NFP_CLASS_VDPA,
+	.name = RTE_STR(NFP_VDPA_DRIVER_NAME),
+	.id_table = pci_id_nfp_vdpa_map,
+	.drv_flags =  RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+	.probe = nfp_vdpa_pci_probe,
+	.remove = nfp_vdpa_pci_remove,
+};
+
+RTE_INIT(nfp_vdpa_init)
+{
+	nfp_class_driver_register(&nfp_vdpa);
+}
+
+RTE_PMD_REGISTER_PCI_TABLE(NFP_VDPA_DRIVER_NAME, pci_id_nfp_vdpa_map);
+RTE_PMD_REGISTER_KMOD_DEP(NFP_VDPA_DRIVER_NAME, "* vfio-pci");
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 20/25] vdpa/nfp: add the logic of remap PCI memory
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (18 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
                       ` (7 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the logic of remap PCI memory.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c | 65 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index ef4ae4946a..824b0d681a 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -7,6 +7,7 @@
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
+#include <rte_vfio.h>
 #include <vdpa_driver.h>
 
 #include "nfp_vdpa_log.h"
@@ -16,6 +17,11 @@
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
+
+	int vfio_container_fd;
+	int vfio_group_fd;
+	int vfio_dev_fd;
+	int iommu_group;
 };
 
 struct nfp_vdpa_dev_node {
@@ -53,12 +59,62 @@ nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
 	return NULL;
 }
 
+static int
+nfp_vdpa_vfio_setup(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	char dev_name[RTE_DEV_NAME_MAX_LEN] = {0};
+	struct rte_pci_device *pci_dev = device->pci_dev;
+
+	rte_pci_unmap_device(pci_dev);
+
+	rte_pci_device_name(&pci_dev->addr, dev_name, RTE_DEV_NAME_MAX_LEN);
+	rte_vfio_get_group_num(rte_pci_get_sysfs_path(), dev_name,
+			&device->iommu_group);
+
+	device->vfio_container_fd = rte_vfio_container_create();
+	if (device->vfio_container_fd < 0)
+		return -1;
+
+	device->vfio_group_fd = rte_vfio_container_group_bind(
+			device->vfio_container_fd, device->iommu_group);
+	if (device->vfio_group_fd < 0)
+		goto container_destroy;
+
+	DRV_VDPA_LOG(DEBUG, "container_fd=%d, group_fd=%d,\n",
+			device->vfio_container_fd, device->vfio_group_fd);
+
+	ret = rte_pci_map_device(pci_dev);
+	if (ret != 0)
+		goto group_unbind;
+
+	device->vfio_dev_fd = rte_intr_dev_fd_get(pci_dev->intr_handle);
+
+	return 0;
+
+group_unbind:
+	rte_vfio_container_group_unbind(device->vfio_container_fd, device->iommu_group);
+container_destroy:
+	rte_vfio_container_destroy(device->vfio_container_fd);
+
+	return -1;
+}
+
+static void
+nfp_vdpa_vfio_teardown(struct nfp_vdpa_dev *device)
+{
+	rte_pci_unmap_device(device->pci_dev);
+	rte_vfio_container_group_unbind(device->vfio_container_fd, device->iommu_group);
+	rte_vfio_container_destroy(device->vfio_container_fd);
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
 };
 
 static int
 nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 {
+	int ret;
 	struct nfp_vdpa_dev *device;
 	struct nfp_vdpa_dev_node *node;
 
@@ -75,10 +131,14 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 
 	device->pci_dev = pci_dev;
 
+	ret = nfp_vdpa_vfio_setup(device);
+	if (ret != 0)
+		goto free_device;
+
 	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
 	if (device->vdev == NULL) {
 		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
-		goto free_device;
+		goto vfio_teardown;
 	}
 
 	node->device = device;
@@ -88,6 +148,8 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 
 	return 0;
 
+vfio_teardown:
+	nfp_vdpa_vfio_teardown(device);
 free_device:
 	free(device);
 free_node:
@@ -118,6 +180,7 @@ nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
 	pthread_mutex_unlock(&vdpa_list_lock);
 
 	rte_vdpa_unregister_device(device->vdev);
+	nfp_vdpa_vfio_teardown(device);
 
 	free(device);
 	free(node);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 21/25] vdpa/nfp: add the hardware init logic
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (19 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 22/25] drivers: add the datapath update logic Chaoyong He
                       ` (6 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the hardware initialize logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/meson.build     |  1 +
 drivers/vdpa/nfp/nfp_vdpa.c      | 10 ++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c | 54 ++++++++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h | 32 +++++++++++++++++++
 4 files changed, 97 insertions(+)
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.h

diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
index 79a0364917..258f3eaaa0 100644
--- a/drivers/vdpa/nfp/meson.build
+++ b/drivers/vdpa/nfp/meson.build
@@ -8,6 +8,7 @@ endif
 
 sources = files(
         'nfp_vdpa.c',
+        'nfp_vdpa_core.c',
         'nfp_vdpa_log.c',
 )
 
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 824b0d681a..00d8f7e007 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -10,6 +10,7 @@
 #include <rte_vfio.h>
 #include <vdpa_driver.h>
 
+#include "nfp_vdpa_core.h"
 #include "nfp_vdpa_log.h"
 
 #define NFP_VDPA_DRIVER_NAME nfp_vdpa
@@ -17,11 +18,14 @@
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_hw hw;
 
 	int vfio_container_fd;
 	int vfio_group_fd;
 	int vfio_dev_fd;
 	int iommu_group;
+
+	uint16_t max_queues;
 };
 
 struct nfp_vdpa_dev_node {
@@ -135,6 +139,12 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 	if (ret != 0)
 		goto free_device;
 
+	ret = nfp_vdpa_hw_init(&device->hw, pci_dev);
+	if (ret != 0)
+		goto vfio_teardown;
+
+	device->max_queues = NFP_VDPA_MAX_QUEUES;
+
 	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
 	if (device->vdev == NULL) {
 		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
new file mode 100644
index 0000000000..a7e15fa88a
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_vdpa_core.h"
+
+#include <rte_vhost.h>
+
+#include "nfp_vdpa_log.h"
+
+/* Available and used descs are in same order */
+#ifndef VIRTIO_F_IN_ORDER
+#define VIRTIO_F_IN_ORDER      35
+#endif
+
+int
+nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
+		struct rte_pci_device *pci_dev)
+{
+	uint32_t queue;
+	struct nfp_hw *hw;
+	uint8_t *notify_base;
+
+	hw = &vdpa_hw->super;
+	hw->ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->ctrl_bar == NULL) {
+		DRV_CORE_LOG(ERR, "hw->ctrl_bar is NULL. BAR0 not configured.");
+		return -ENODEV;
+	}
+
+	notify_base = hw->ctrl_bar + NFP_VDPA_NOTIFY_ADDR_BASE;
+	for (queue = 0; queue < NFP_VDPA_MAX_QUEUES; queue++) {
+		uint32_t idx = queue * 2;
+
+		/* RX */
+		vdpa_hw->notify_addr[idx] = notify_base;
+		notify_base += NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+		/* TX */
+		vdpa_hw->notify_addr[idx + 1] = notify_base;
+		notify_base += NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+
+		vdpa_hw->notify_region = queue;
+		DRV_CORE_LOG(DEBUG, "notify_addr[%d] at %p, notify_addr[%d] at %p",
+				idx, vdpa_hw->notify_addr[idx],
+				idx + 1, vdpa_hw->notify_addr[idx + 1]);
+	}
+
+	vdpa_hw->features = (1ULL << VIRTIO_F_VERSION_1) |
+			(1ULL << VIRTIO_F_IN_ORDER) |
+			(1ULL << VHOST_USER_F_PROTOCOL_FEATURES);
+
+	return 0;
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
new file mode 100644
index 0000000000..c9403e0ea4
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_VDPA_CORE_H__
+#define __NFP_VDPA_CORE_H__
+
+#include <bus_pci_driver.h>
+#include <nfp_common.h>
+#include <rte_ether.h>
+
+#define NFP_VDPA_MAX_QUEUES         1
+
+#define NFP_VDPA_NOTIFY_ADDR_BASE        0x4000
+#define NFP_VDPA_NOTIFY_ADDR_INTERVAL    0x1000
+
+struct nfp_vdpa_hw {
+	struct nfp_hw super;
+
+	uint64_t features;
+	uint64_t req_features;
+
+	uint8_t *notify_addr[NFP_VDPA_MAX_QUEUES * 2];
+
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+	uint8_t notify_region;
+};
+
+int nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, struct rte_pci_device *dev);
+
+#endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 22/25] drivers: add the datapath update logic
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (20 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 23/25] vdpa/nfp: add the notify related logic Chaoyong He
                       ` (5 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the vDPA datapath update logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h |   1 +
 drivers/vdpa/nfp/nfp_vdpa.c          | 318 +++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c     |  78 +++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h     |  15 ++
 4 files changed, 412 insertions(+)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 3c8cd916cf..f92ce50fc0 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -238,6 +238,7 @@ struct nfp_net_fw_ver {
 #define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
 #define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
 #define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
+#define NFP_NET_CFG_CTRL_IN_ORDER         (0x1 << 11) /**< Virtio in-order flag */
 
 #define NFP_NET_CFG_CAP_WORD1           0x00a4
 
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 00d8f7e007..d0d8050887 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -4,6 +4,7 @@
  */
 
 #include <pthread.h>
+#include <sys/ioctl.h>
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
@@ -15,6 +16,9 @@
 
 #define NFP_VDPA_DRIVER_NAME nfp_vdpa
 
+#define MSIX_IRQ_SET_BUF_LEN (sizeof(struct vfio_irq_set) + \
+		sizeof(int) * (NFP_VDPA_MAX_QUEUES * 2 + 1))
+
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
@@ -25,7 +29,15 @@ struct nfp_vdpa_dev {
 	int vfio_dev_fd;
 	int iommu_group;
 
+	int vid;
 	uint16_t max_queues;
+	uint32_t started;
+	uint32_t dev_attached;
+	uint32_t running;
+	rte_spinlock_t lock;
+
+	/** Eventfd for used ring interrupt */
+	int intr_fd[NFP_VDPA_MAX_QUEUES * 2];
 };
 
 struct nfp_vdpa_dev_node {
@@ -112,6 +124,305 @@ nfp_vdpa_vfio_teardown(struct nfp_vdpa_dev *device)
 	rte_vfio_container_destroy(device->vfio_container_fd);
 }
 
+static int
+nfp_vdpa_dma_do_unmap(struct rte_vhost_memory *mem,
+		uint32_t times,
+		int vfio_container_fd)
+{
+	uint32_t i;
+	int ret = 0;
+	struct rte_vhost_mem_region *region;
+
+	for (i = 0; i < times; i++) {
+		region = &mem->regions[i];
+
+		ret = rte_vfio_container_dma_unmap(vfio_container_fd,
+				region->host_user_addr, region->guest_phys_addr,
+				region->size);
+		if (ret < 0) {
+			/* Here should not return, even error happened. */
+			DRV_VDPA_LOG(ERR, "DMA unmap failed. Times: %u", i);
+		}
+	}
+
+	return ret;
+}
+
+static int
+nfp_vdpa_dma_do_map(struct rte_vhost_memory *mem,
+		uint32_t times,
+		int vfio_container_fd)
+{
+	int ret;
+	uint32_t i;
+	struct rte_vhost_mem_region *region;
+
+	for (i = 0; i < times; i++) {
+		region = &mem->regions[i];
+
+		ret = rte_vfio_container_dma_map(vfio_container_fd,
+				region->host_user_addr, region->guest_phys_addr,
+				region->size);
+		if (ret < 0) {
+			DRV_VDPA_LOG(ERR, "DMA map failed.");
+			nfp_vdpa_dma_do_unmap(mem, i, vfio_container_fd);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_dma_map(struct nfp_vdpa_dev *device,
+		bool do_map)
+{
+	int ret;
+	int vfio_container_fd;
+	struct rte_vhost_memory *mem = NULL;
+
+	ret = rte_vhost_get_mem_table(device->vid, &mem);
+	if (ret < 0) {
+		DRV_VDPA_LOG(ERR, "Failed to get memory layout.");
+		return ret;
+	}
+
+	vfio_container_fd = device->vfio_container_fd;
+	DRV_VDPA_LOG(DEBUG, "vfio_container_fd %d", vfio_container_fd);
+
+	if (do_map)
+		ret = nfp_vdpa_dma_do_map(mem, mem->nregions, vfio_container_fd);
+	else
+		ret = nfp_vdpa_dma_do_unmap(mem, mem->nregions, vfio_container_fd);
+
+	free(mem);
+
+	return ret;
+}
+
+static uint64_t
+nfp_vdpa_qva_to_gpa(int vid,
+		uint64_t qva)
+{
+	int ret;
+	uint32_t i;
+	uint64_t gpa = 0;
+	struct rte_vhost_memory *mem = NULL;
+	struct rte_vhost_mem_region *region;
+
+	ret = rte_vhost_get_mem_table(vid, &mem);
+	if (ret < 0) {
+		DRV_VDPA_LOG(ERR, "Failed to get memory layout.");
+		return gpa;
+	}
+
+	for (i = 0; i < mem->nregions; i++) {
+		region = &mem->regions[i];
+
+		if (qva >= region->host_user_addr &&
+				qva < region->host_user_addr + region->size) {
+			gpa = qva - region->host_user_addr + region->guest_phys_addr;
+			break;
+		}
+	}
+
+	free(mem);
+
+	return gpa;
+}
+
+static int
+nfp_vdpa_start(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	int vid;
+	uint16_t i;
+	uint64_t gpa;
+	struct rte_vhost_vring vring;
+	struct nfp_vdpa_hw *vdpa_hw = &device->hw;
+
+	vid = device->vid;
+	vdpa_hw->nr_vring = rte_vhost_get_vring_num(vid);
+
+	ret = rte_vhost_get_negotiated_features(vid, &vdpa_hw->req_features);
+	if (ret != 0)
+		return ret;
+
+	for (i = 0; i < vdpa_hw->nr_vring; i++) {
+		ret = rte_vhost_get_vhost_vring(vid, i, &vring);
+		if (ret != 0)
+			return ret;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.desc);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for descriptor ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].desc = gpa;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.avail);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for available ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].avail = gpa;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.used);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for used ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].used = gpa;
+
+		vdpa_hw->vring[i].size = vring.size;
+
+		ret = rte_vhost_get_vring_base(vid, i,
+				&vdpa_hw->vring[i].last_avail_idx,
+				&vdpa_hw->vring[i].last_used_idx);
+		if (ret != 0)
+			return ret;
+	}
+
+	return nfp_vdpa_hw_start(&device->hw, vid);
+}
+
+static void
+nfp_vdpa_stop(struct nfp_vdpa_dev *device)
+{
+	int vid;
+	uint32_t i;
+	struct nfp_vdpa_hw *vdpa_hw = &device->hw;
+
+	nfp_vdpa_hw_stop(vdpa_hw);
+
+	vid = device->vid;
+	for (i = 0; i < vdpa_hw->nr_vring; i++)
+		rte_vhost_set_vring_base(vid, i,
+				vdpa_hw->vring[i].last_avail_idx,
+				vdpa_hw->vring[i].last_used_idx);
+}
+
+static int
+nfp_vdpa_enable_vfio_intr(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	uint16_t i;
+	int *fd_ptr;
+	uint16_t nr_vring;
+	struct vfio_irq_set *irq_set;
+	struct rte_vhost_vring vring;
+	char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
+
+	nr_vring = rte_vhost_get_vring_num(device->vid);
+
+	irq_set = (struct vfio_irq_set *)irq_set_buf;
+	irq_set->argsz = sizeof(irq_set_buf);
+	irq_set->count = nr_vring + 1;
+	irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;
+	irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
+	irq_set->start = 0;
+
+	fd_ptr = (int *)&irq_set->data;
+	fd_ptr[RTE_INTR_VEC_ZERO_OFFSET] = rte_intr_fd_get(device->pci_dev->intr_handle);
+
+	for (i = 0; i < nr_vring; i++)
+		device->intr_fd[i] = -1;
+
+	for (i = 0; i < nr_vring; i++) {
+		rte_vhost_get_vhost_vring(device->vid, i, &vring);
+		fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = vring.callfd;
+	}
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Error enabling MSI-X interrupts.");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_disable_vfio_intr(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	struct vfio_irq_set *irq_set;
+	char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
+
+	irq_set = (struct vfio_irq_set *)irq_set_buf;
+	irq_set->argsz = sizeof(irq_set_buf);
+	irq_set->count = 0;
+	irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER;
+	irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
+	irq_set->start = 0;
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Error disabling MSI-X interrupts.");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int
+update_datapath(struct nfp_vdpa_dev *device)
+{
+	int ret;
+
+	rte_spinlock_lock(&device->lock);
+
+	if ((rte_atomic_load_explicit(&device->running, rte_memory_order_relaxed) == 0) &&
+			(rte_atomic_load_explicit(&device->started,
+					rte_memory_order_relaxed) != 0) &&
+			(rte_atomic_load_explicit(&device->dev_attached,
+					rte_memory_order_relaxed) != 0)) {
+		ret = nfp_vdpa_dma_map(device, true);
+		if (ret != 0)
+			goto unlock_exit;
+
+		ret = nfp_vdpa_enable_vfio_intr(device);
+		if (ret != 0)
+			goto dma_map_rollback;
+
+		ret = nfp_vdpa_start(device);
+		if (ret != 0)
+			goto disable_vfio_intr;
+
+		rte_atomic_store_explicit(&device->running, 1, rte_memory_order_relaxed);
+	} else if ((rte_atomic_load_explicit(&device->running, rte_memory_order_relaxed) != 0) &&
+			((rte_atomic_load_explicit(&device->started,
+					rte_memory_order_relaxed) != 0) ||
+			(rte_atomic_load_explicit(&device->dev_attached,
+					rte_memory_order_relaxed) != 0))) {
+		nfp_vdpa_stop(device);
+
+		ret = nfp_vdpa_disable_vfio_intr(device);
+		if (ret != 0)
+			goto unlock_exit;
+
+		ret = nfp_vdpa_dma_map(device, false);
+		if (ret != 0)
+			goto unlock_exit;
+
+		rte_atomic_store_explicit(&device->running, 0, rte_memory_order_relaxed);
+	}
+
+	rte_spinlock_unlock(&device->lock);
+	return 0;
+
+disable_vfio_intr:
+	nfp_vdpa_disable_vfio_intr(device);
+dma_map_rollback:
+	nfp_vdpa_dma_map(device, false);
+unlock_exit:
+	rte_spinlock_unlock(&device->lock);
+	return ret;
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
 };
 
@@ -156,6 +467,10 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 	TAILQ_INSERT_TAIL(&vdpa_dev_list, node, next);
 	pthread_mutex_unlock(&vdpa_list_lock);
 
+	rte_spinlock_init(&device->lock);
+	rte_atomic_store_explicit(&device->started, 1, rte_memory_order_relaxed);
+	update_datapath(device);
+
 	return 0;
 
 vfio_teardown:
@@ -185,6 +500,9 @@ nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
 
 	device = node->device;
 
+	rte_atomic_store_explicit(&device->started, 0, rte_memory_order_relaxed);
+	update_datapath(device);
+
 	pthread_mutex_lock(&vdpa_list_lock);
 	TAILQ_REMOVE(&vdpa_dev_list, node, next);
 	pthread_mutex_unlock(&vdpa_list_lock);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
index a7e15fa88a..db9b8462b4 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.c
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -5,6 +5,7 @@
 
 #include "nfp_vdpa_core.h"
 
+#include <nfp_common.h>
 #include <rte_vhost.h>
 
 #include "nfp_vdpa_log.h"
@@ -52,3 +53,80 @@ nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
 
 	return 0;
 }
+
+static uint32_t
+nfp_vdpa_check_offloads(void)
+{
+	return NFP_NET_CFG_CTRL_SCATTER |
+			NFP_NET_CFG_CTRL_IN_ORDER;
+}
+
+int
+nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw,
+		int vid)
+{
+	int ret;
+	uint32_t update;
+	uint32_t new_ctrl;
+	struct timespec wait_tst;
+	struct nfp_hw *hw = &vdpa_hw->super;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(0), vdpa_hw->vring[1].desc);
+	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(0), rte_log2_u32(vdpa_hw->vring[1].size));
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(1), vdpa_hw->vring[1].avail);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(2), vdpa_hw->vring[1].used);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(0), vdpa_hw->vring[0].desc);
+	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(0), rte_log2_u32(vdpa_hw->vring[0].size));
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(1), vdpa_hw->vring[0].avail);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(2), vdpa_hw->vring[0].used);
+
+	rte_wmb();
+
+	nfp_disable_queues(hw);
+	nfp_enable_queues(hw, NFP_VDPA_MAX_QUEUES, NFP_VDPA_MAX_QUEUES);
+
+	new_ctrl = nfp_vdpa_check_offloads();
+
+	nn_cfg_writel(hw, NFP_NET_CFG_MTU, 9216);
+	nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, 10240);
+
+	/* TODO: Temporary set MAC to fixed value fe:1b:ac:05:a5:22 */
+	mac_addr[0] = 0xfe;
+	mac_addr[1] = 0x1b;
+	mac_addr[2] = 0xac;
+	mac_addr[3] = 0x05;
+	mac_addr[4] = 0xa5;
+	mac_addr[5] = (0x22 + vid);
+
+	/* Writing new MAC to the specific port BAR address */
+	nfp_write_mac(hw, (uint8_t *)mac_addr);
+
+	/* Enable device */
+	new_ctrl |= NFP_NET_CFG_CTRL_ENABLE;
+
+	/* Signal the NIC about the change */
+	update = NFP_NET_CFG_UPDATE_MACADDR |
+			NFP_NET_CFG_UPDATE_GEN |
+			NFP_NET_CFG_UPDATE_RING;
+
+	ret = nfp_reconfig(hw, new_ctrl, update);
+	if (ret < 0)
+		return -EIO;
+
+	hw->ctrl = new_ctrl;
+
+	DRV_CORE_LOG(DEBUG, "Enabling the device, sleep 1 seconds...");
+	wait_tst.tv_sec = 1;
+	wait_tst.tv_nsec = 0;
+	nanosleep(&wait_tst, 0);
+
+	return 0;
+}
+
+void
+nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw)
+{
+	nfp_disable_queues(&vdpa_hw->super);
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
index c9403e0ea4..a88de768dd 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.h
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -15,6 +15,15 @@
 #define NFP_VDPA_NOTIFY_ADDR_BASE        0x4000
 #define NFP_VDPA_NOTIFY_ADDR_INTERVAL    0x1000
 
+struct nfp_vdpa_vring {
+	uint64_t desc;
+	uint64_t avail;
+	uint64_t used;
+	uint16_t size;
+	uint16_t last_avail_idx;
+	uint16_t last_used_idx;
+};
+
 struct nfp_vdpa_hw {
 	struct nfp_hw super;
 
@@ -22,11 +31,17 @@ struct nfp_vdpa_hw {
 	uint64_t req_features;
 
 	uint8_t *notify_addr[NFP_VDPA_MAX_QUEUES * 2];
+	struct nfp_vdpa_vring vring[NFP_VDPA_MAX_QUEUES * 2];
 
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t notify_region;
+	uint8_t nr_vring;
 };
 
 int nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, struct rte_pci_device *dev);
 
+int nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw, int vid);
+
+void nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw);
+
 #endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 23/25] vdpa/nfp: add the notify related logic
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (21 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 22/25] drivers: add the datapath update logic Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
                       ` (4 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the logic to process vDPA notify relay.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c      | 155 +++++++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c |  61 ++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h |   4 +
 3 files changed, 220 insertions(+)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index d0d8050887..f4d63b8ba9 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -4,7 +4,9 @@
  */
 
 #include <pthread.h>
+#include <sys/epoll.h>
 #include <sys/ioctl.h>
+#include <unistd.h>
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
@@ -29,6 +31,9 @@ struct nfp_vdpa_dev {
 	int vfio_dev_fd;
 	int iommu_group;
 
+	rte_thread_t tid;    /**< Thread for notify relay */
+	int epoll_fd;
+
 	int vid;
 	uint16_t max_queues;
 	uint32_t started;
@@ -368,6 +373,148 @@ nfp_vdpa_disable_vfio_intr(struct nfp_vdpa_dev *device)
 	return 0;
 }
 
+static void
+nfp_vdpa_read_kickfd(int kickfd)
+{
+	int bytes;
+	uint64_t buf;
+
+	for (;;) {
+		bytes = read(kickfd, &buf, 8);
+		if (bytes >= 0)
+			break;
+
+		if (errno != EINTR && errno != EWOULDBLOCK &&
+				errno != EAGAIN) {
+			DRV_VDPA_LOG(ERR, "Error reading kickfd");
+			break;
+		}
+	}
+}
+
+static int
+nfp_vdpa_notify_epoll_ctl(uint32_t queue_num,
+		struct nfp_vdpa_dev *device)
+{
+	int ret;
+	uint32_t qid;
+
+	for (qid = 0; qid < queue_num; qid++) {
+		struct epoll_event ev;
+		struct rte_vhost_vring vring;
+
+		ev.events = EPOLLIN | EPOLLPRI;
+		rte_vhost_get_vhost_vring(device->vid, qid, &vring);
+		ev.data.u64 = qid | (uint64_t)vring.kickfd << 32;
+		ret = epoll_ctl(device->epoll_fd, EPOLL_CTL_ADD, vring.kickfd, &ev);
+		if (ret < 0) {
+			DRV_VDPA_LOG(ERR, "Epoll add error for queue %d", qid);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_notify_epoll_wait(uint32_t queue_num,
+		struct nfp_vdpa_dev *device)
+{
+	int i;
+	int fds;
+	int kickfd;
+	uint32_t qid;
+	struct epoll_event events[NFP_VDPA_MAX_QUEUES * 2];
+
+	for (;;) {
+		fds = epoll_wait(device->epoll_fd, events, queue_num, -1);
+		if (fds < 0) {
+			if (errno == EINTR)
+				continue;
+
+			DRV_VDPA_LOG(ERR, "Epoll wait fail");
+			return -EACCES;
+		}
+
+		for (i = 0; i < fds; i++) {
+			qid = events[i].data.u32;
+			kickfd = (uint32_t)(events[i].data.u64 >> 32);
+
+			nfp_vdpa_read_kickfd(kickfd);
+			nfp_vdpa_notify_queue(&device->hw, qid);
+		}
+	}
+
+	return 0;
+}
+
+static uint32_t
+nfp_vdpa_notify_relay(void *arg)
+{
+	int ret;
+	int epoll_fd;
+	uint32_t queue_num;
+	struct nfp_vdpa_dev *device = arg;
+
+	epoll_fd = epoll_create(NFP_VDPA_MAX_QUEUES * 2);
+	if (epoll_fd < 0) {
+		DRV_VDPA_LOG(ERR, "failed to create epoll instance.");
+		return 1;
+	}
+
+	device->epoll_fd = epoll_fd;
+
+	queue_num = rte_vhost_get_vring_num(device->vid);
+
+	ret = nfp_vdpa_notify_epoll_ctl(queue_num, device);
+	if (ret != 0)
+		goto notify_exit;
+
+	ret = nfp_vdpa_notify_epoll_wait(queue_num, device);
+	if (ret != 0)
+		goto notify_exit;
+
+	return 0;
+
+notify_exit:
+	close(device->epoll_fd);
+	device->epoll_fd = -1;
+
+	return 1;
+}
+
+static int
+nfp_vdpa_setup_notify_relay(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	char name[RTE_THREAD_INTERNAL_NAME_SIZE];
+
+	snprintf(name, sizeof(name), "nfp-noti%d", device->vid);
+	ret = rte_thread_create_internal_control(&device->tid, name,
+			nfp_vdpa_notify_relay, (void *)device);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Failed to create notify relay pthread.");
+		return -1;
+	}
+
+	return 0;
+}
+
+static void
+nfp_vdpa_unset_notify_relay(struct nfp_vdpa_dev *device)
+{
+	if (device->tid.opaque_id != 0) {
+		pthread_cancel((pthread_t)device->tid.opaque_id);
+		rte_thread_join(device->tid, NULL);
+		device->tid.opaque_id = 0;
+	}
+
+	if (device->epoll_fd >= 0) {
+		close(device->epoll_fd);
+		device->epoll_fd = -1;
+	}
+}
+
 static int
 update_datapath(struct nfp_vdpa_dev *device)
 {
@@ -392,12 +539,18 @@ update_datapath(struct nfp_vdpa_dev *device)
 		if (ret != 0)
 			goto disable_vfio_intr;
 
+		ret = nfp_vdpa_setup_notify_relay(device);
+		if (ret != 0)
+			goto vdpa_stop;
+
 		rte_atomic_store_explicit(&device->running, 1, rte_memory_order_relaxed);
 	} else if ((rte_atomic_load_explicit(&device->running, rte_memory_order_relaxed) != 0) &&
 			((rte_atomic_load_explicit(&device->started,
 					rte_memory_order_relaxed) != 0) ||
 			(rte_atomic_load_explicit(&device->dev_attached,
 					rte_memory_order_relaxed) != 0))) {
+		nfp_vdpa_unset_notify_relay(device);
+
 		nfp_vdpa_stop(device);
 
 		ret = nfp_vdpa_disable_vfio_intr(device);
@@ -414,6 +567,8 @@ update_datapath(struct nfp_vdpa_dev *device)
 	rte_spinlock_unlock(&device->lock);
 	return 0;
 
+vdpa_stop:
+	nfp_vdpa_stop(device);
 disable_vfio_intr:
 	nfp_vdpa_disable_vfio_intr(device);
 dma_map_rollback:
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
index db9b8462b4..e2a6253ae5 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.c
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -15,6 +15,41 @@
 #define VIRTIO_F_IN_ORDER      35
 #endif
 
+#define NFP_QCP_NOTIFY_MAX_ADD    0x7f
+
+enum nfp_qcp_notify_ptr {
+	NFP_QCP_NOTIFY_WRITE_PTR = 0,
+	NFP_QCP_NOTIFY_READ_PTR
+};
+
+/**
+ * Add the value to the selected pointer of a queue
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Add to the Read or Write pointer
+ * @param val
+ *   Value to add to the queue pointer
+ */
+static inline void
+nfp_qcp_notify_ptr_add(uint8_t *q,
+		enum nfp_qcp_notify_ptr ptr,
+		uint32_t val)
+{
+	uint32_t off;
+
+	if (ptr == NFP_QCP_NOTIFY_WRITE_PTR)
+		off = NFP_QCP_QUEUE_ADD_RPTR;
+	else
+		off = NFP_QCP_QUEUE_ADD_WPTR;
+
+	for (; val > NFP_QCP_NOTIFY_MAX_ADD; val -= NFP_QCP_NOTIFY_MAX_ADD)
+		nn_writel(rte_cpu_to_le_32(NFP_QCP_NOTIFY_MAX_ADD), q + off);
+
+	nn_writel(rte_cpu_to_le_32(val), q + off);
+}
+
 int
 nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
 		struct rte_pci_device *pci_dev)
@@ -130,3 +165,29 @@ nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw)
 {
 	nfp_disable_queues(&vdpa_hw->super);
 }
+
+/*
+ * This offset is used for mmaping the notify area. It implies it needs
+ * to be a multiple of PAGE_SIZE.
+ * For debugging, using notify region 0 with an offset of 4K. This should
+ * point to the conf bar.
+ */
+uint64_t
+nfp_vdpa_get_queue_notify_offset(struct nfp_vdpa_hw *vdpa_hw __rte_unused,
+		int qid)
+{
+	return NFP_VDPA_NOTIFY_ADDR_BASE + (qid * NFP_VDPA_NOTIFY_ADDR_INTERVAL);
+}
+
+/*
+ * With just one queue the increment is 0, which does not
+ * incremente the counter but will raise a queue event due
+ * to queue configured for watermark events.
+ */
+void
+nfp_vdpa_notify_queue(struct nfp_vdpa_hw *vdpa_hw,
+		uint16_t qid)
+{
+	nfp_qcp_notify_ptr_add(vdpa_hw->notify_addr[qid],
+			NFP_QCP_NOTIFY_WRITE_PTR, qid);
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
index a88de768dd..a8e0d6dd70 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.h
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -44,4 +44,8 @@ int nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw, int vid);
 
 void nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw);
 
+void nfp_vdpa_notify_queue(struct nfp_vdpa_hw *vdpa_hw, uint16_t qid);
+
+uint64_t nfp_vdpa_get_queue_notify_offset(struct nfp_vdpa_hw *vdpa_hw, int qid);
+
 #endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 24/25] vdpa/nfp: add nfp vDPA device operations
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (22 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 23/25] vdpa/nfp: add the notify related logic Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26  6:43     ` [PATCH v3 25/25] doc: add a entry in the release notes Chaoyong He
                       ` (3 subsequent siblings)
  27 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Implement the corresponding nfp vDPA operation functions.

Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
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/vdpa/nfp/nfp_vdpa.c | 213 ++++++++++++++++++++++++++++++++++++
 1 file changed, 213 insertions(+)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index f4d63b8ba9..181fee58c2 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -57,6 +57,29 @@ static struct vdpa_dev_list_head vdpa_dev_list =
 
 static pthread_mutex_t vdpa_list_lock = PTHREAD_MUTEX_INITIALIZER;
 
+static struct nfp_vdpa_dev_node *
+nfp_vdpa_find_node_by_vdev(struct rte_vdpa_device *vdev)
+{
+	bool found = false;
+	struct nfp_vdpa_dev_node *node;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+
+	TAILQ_FOREACH(node, &vdpa_dev_list, next) {
+		if (vdev == node->device->vdev) {
+			found = true;
+			break;
+		}
+	}
+
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	if (found)
+		return node;
+
+	return NULL;
+}
+
 static struct nfp_vdpa_dev_node *
 nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
 {
@@ -578,7 +601,197 @@ update_datapath(struct nfp_vdpa_dev *device)
 	return ret;
 }
 
+static int
+nfp_vdpa_dev_config(int vid)
+{
+	int ret;
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	device->vid = vid;
+	rte_atomic_store_explicit(&device->dev_attached, 1, rte_memory_order_relaxed);
+	update_datapath(device);
+
+	ret = rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true);
+	if (ret != 0)
+		DRV_VDPA_LOG(INFO, "vDPA (%s): software relay is used.",
+				vdev->device->name);
+
+	return 0;
+}
+
+static int
+nfp_vdpa_dev_close(int vid)
+{
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	rte_atomic_store_explicit(&device->dev_attached, 0, rte_memory_order_relaxed);
+	update_datapath(device);
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_vfio_group_fd(int vid)
+{
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	return node->device->vfio_group_fd;
+}
+
+static int
+nfp_vdpa_get_vfio_device_fd(int vid)
+{
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	return node->device->vfio_dev_fd;
+}
+
+static int
+nfp_vdpa_get_notify_area(int vid,
+		int qid,
+		uint64_t *offset,
+		uint64_t *size)
+{
+	int ret;
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+	struct vfio_region_info region = {
+		.argsz = sizeof(region)
+	};
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR,  "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	region.index = device->hw.notify_region;
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, &region);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Get not get device region info.");
+		return -EIO;
+	}
+
+	*offset = nfp_vdpa_get_queue_notify_offset(&device->hw, qid) + region.offset;
+	*size = NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_queue_num(struct rte_vdpa_device *vdev,
+		uint32_t *queue_num)
+{
+	struct nfp_vdpa_dev_node *node;
+
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	*queue_num = node->device->max_queues;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_vdpa_features(struct rte_vdpa_device *vdev,
+		uint64_t *features)
+{
+	struct nfp_vdpa_dev_node *node;
+
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR,  "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	*features = node->device->hw.features;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_protocol_features(struct rte_vdpa_device *vdev __rte_unused,
+		uint64_t *features)
+{
+	*features = 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD |
+			1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK |
+			1ULL << VHOST_USER_PROTOCOL_F_BACKEND_REQ |
+			1ULL << VHOST_USER_PROTOCOL_F_BACKEND_SEND_FD |
+			1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_set_features(int32_t vid)
+{
+	DRV_VDPA_LOG(DEBUG, "Start vid=%d", vid);
+	return 0;
+}
+
+static int
+nfp_vdpa_set_vring_state(int vid,
+		int vring,
+		int state)
+{
+	DRV_VDPA_LOG(DEBUG, "Start vid=%d, vring=%d, state=%d", vid, vring, state);
+	return 0;
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
+	.get_queue_num = nfp_vdpa_get_queue_num,
+	.get_features = nfp_vdpa_get_vdpa_features,
+	.get_protocol_features = nfp_vdpa_get_protocol_features,
+	.dev_conf = nfp_vdpa_dev_config,
+	.dev_close = nfp_vdpa_dev_close,
+	.set_vring_state = nfp_vdpa_set_vring_state,
+	.set_features = nfp_vdpa_set_features,
+	.get_vfio_group_fd = nfp_vdpa_get_vfio_group_fd,
+	.get_vfio_device_fd = nfp_vdpa_get_vfio_device_fd,
+	.get_notify_area = nfp_vdpa_get_notify_area,
 };
 
 static int
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v3 25/25] doc: add a entry in the release notes
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (23 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
@ 2023-10-26  6:43     ` Chaoyong He
  2023-10-26 14:55       ` Ferruh Yigit
  2023-10-26 14:47     ` [PATCH v3 00/25] add the NFP vDPA PMD Ferruh Yigit
                       ` (2 subsequent siblings)
  27 siblings, 1 reply; 121+ messages in thread
From: Chaoyong He @ 2023-10-26  6:43 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add a entry for the NFP vDPA PMD in the release notes.

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>
---
 doc/guides/rel_notes/release_23_11.rst | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index 0a6fc76a9d..f6dde6fb9d 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -153,6 +153,11 @@ New Features
 
   * Added inline IPsec offload based on the security framework.
 
+* **Add new vDPA PMD based on Corigine NFP devices.**
+
+  Added a new Corigine NFP vDPA (``nfp_vdpa``) PMD.
+  See the :doc:`../vdpadevs/nfp` guide for more details on this driver.
+
 * **Updated Wangxun ngbe driver.**
 
   * Added 100M and auto-neg support in YT PHY fiber mode.
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v2 00/25] add the NFP vDPA PMD
  2023-10-26  2:50       ` Chaoyong He
@ 2023-10-26 11:30         ` Ferruh Yigit
  2023-10-26 11:33           ` Chaoyong He
  0 siblings, 1 reply; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-26 11:30 UTC (permalink / raw)
  To: Chaoyong He, dev, David Marchand
  Cc: oss-drivers, Honnappa Nagarahalli, Tyler Retzlaff

On 10/26/2023 3:50 AM, Chaoyong He wrote:
>>> On 10/24/2023 3:28 AM, Chaoyong He wrote:
>>>> This patch series aims to add the NFP vDPA PMD, we also grab the
>>>> common logic into the `drivers/common/nfp` directory.
>>>>
>>>> ---
>>>> v2:
>>>> * Grab more logic into the `drivers/common/nfp` directory.
>>>> * Delete some logic which should be when moving logic.
>>>> ---
>>>>
>>>> Chaoyong He (25):
>>>>   drivers: introduce the NFP common library
>>>>   net/nfp: make VF PMD using of NFP common module
>>>>   net/nfp: rename common module name
>>>>   net/nfp: rename ctrl module name
>>>>   net/nfp: extract the cap data field
>>>>   net/nfp: extract the qcp data field
>>>>   net/nfp: extract the ctrl BAR data field
>>>>   net/nfp: extract the ctrl data field
>>>>   net/nfp: change the parameter of APIs
>>>>   net/nfp: change the parameter of reconfig
>>>>   net/nfp: extract the MAC address data field
>>>>   net/nfp: rename parameter in related logic
>>>>   drivers: add the common ctrl module
>>>>   drivers: add the nfp common module
>>>>   drivers: move queue logic to common module
>>>>   drivers: move platform module to common library
>>>>   drivers: move device module to common library
>>>>   drivers/vdpa: introduce the NFP vDPA library
>>>>   drivers: add the basic framework of vDPA PMD
>>>>   vdpa/nfp: add the logic of remap PCI memory
>>>>   vdpa/nfp: add the hardware init logic
>>>>   drivers: add the datapath update logic
>>>>   vdpa/nfp: add the notify related logic
>>>>   vdpa/nfp: add nfp vDPA device operations
>>>>   doc: add the common and vDPA document
>>>>
>>>
>>> Overall pretty clean set, but there are a few minor issues, commented
>>> on patches.
>>>
>>>
>>> Also can you please address checkpatch warnings:
>>>
>>>   ### [PATCH] drivers: add the datapath update logic
>>>
>>>     Warning in drivers/vdpa/nfp/nfp_vdpa.c:
>>>     Using __atomic_xxx built-ins, prefer rte_atomic_xxx
>>>
>>
>> Oh, Sorry, we choose '__atomic_xxx' because we see the document in
>> https://doc.dpdk.org/guides/prog_guide/writing_efficient_code.html?highlig
>> ht=atomic%20operations%20use%20c11%20atomic%20builtins#atomic-
>> operations-use-c11-atomic-builtins.
>> Maybe we misunderstood it, we will change to the `rte_atomic_xxx` in next
>> version, thanks.
> 
> As the notes in the 'doc/guides/rel_notes/deprecation.rst':
> ---
>   rte_atomicNN_xxx: These APIs do not take memory order parameter. This does
>   not allow for writing optimized code for all the CPU architectures supported
>   in DPDK. DPDK has adopted the atomic operations from
>   https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html. These
>   operations must be used for patches that need to be merged in 20.08 onwards.
>   This change will not introduce any performance degradation.
> ---
> The '__atomic_xxx' is the preferred choice? So maybe it's the 'checkpatches.sh' should update?
> And seems there are many logics using the '__atomic_xxx'.
> 
> Spend some time and confused about this now.
> What is the right APIs I should use?
> Please make it clear, thanks.
> 

Atomics usage got a few updates by time, if I remember correct:
first there was DPDK rte_atomicNN_xxx APIs,
later guidance updated to prefer compiler builtins,
and recently guidance updated to use C11 defined functions.

And now there are 'rte_atomic_xxx()' APIs, underneath they use "compiler
builtins" or "C11 functions" based on 'enable_stdatomic' config option
and of course tool-chain support.

That is the reason of complexity in the checkpatch script.

@Tyler, @David, @Honnappa, what is the latest, up to date, guidance in
the atomic APIs usage?



@Honnappa, is the deprecation notice Chaoyong highlighted still valid?
Should we update it?



^ permalink raw reply	[flat|nested] 121+ messages in thread

* RE: [PATCH v2 00/25] add the NFP vDPA PMD
  2023-10-26 11:30         ` Ferruh Yigit
@ 2023-10-26 11:33           ` Chaoyong He
  0 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-26 11:33 UTC (permalink / raw)
  To: Ferruh Yigit, dev, David Marchand
  Cc: oss-drivers, Honnappa Nagarahalli, Tyler Retzlaff

> On 10/26/2023 3:50 AM, Chaoyong He wrote:
> >>> On 10/24/2023 3:28 AM, Chaoyong He wrote:
> >>>> This patch series aims to add the NFP vDPA PMD, we also grab the
> >>>> common logic into the `drivers/common/nfp` directory.
> >>>>
> >>>> ---
> >>>> v2:
> >>>> * Grab more logic into the `drivers/common/nfp` directory.
> >>>> * Delete some logic which should be when moving logic.
> >>>> ---
> >>>>
> >>>> Chaoyong He (25):
> >>>>   drivers: introduce the NFP common library
> >>>>   net/nfp: make VF PMD using of NFP common module
> >>>>   net/nfp: rename common module name
> >>>>   net/nfp: rename ctrl module name
> >>>>   net/nfp: extract the cap data field
> >>>>   net/nfp: extract the qcp data field
> >>>>   net/nfp: extract the ctrl BAR data field
> >>>>   net/nfp: extract the ctrl data field
> >>>>   net/nfp: change the parameter of APIs
> >>>>   net/nfp: change the parameter of reconfig
> >>>>   net/nfp: extract the MAC address data field
> >>>>   net/nfp: rename parameter in related logic
> >>>>   drivers: add the common ctrl module
> >>>>   drivers: add the nfp common module
> >>>>   drivers: move queue logic to common module
> >>>>   drivers: move platform module to common library
> >>>>   drivers: move device module to common library
> >>>>   drivers/vdpa: introduce the NFP vDPA library
> >>>>   drivers: add the basic framework of vDPA PMD
> >>>>   vdpa/nfp: add the logic of remap PCI memory
> >>>>   vdpa/nfp: add the hardware init logic
> >>>>   drivers: add the datapath update logic
> >>>>   vdpa/nfp: add the notify related logic
> >>>>   vdpa/nfp: add nfp vDPA device operations
> >>>>   doc: add the common and vDPA document
> >>>>
> >>>
> >>> Overall pretty clean set, but there are a few minor issues,
> >>> commented on patches.
> >>>
> >>>
> >>> Also can you please address checkpatch warnings:
> >>>
> >>>   ### [PATCH] drivers: add the datapath update logic
> >>>
> >>>     Warning in drivers/vdpa/nfp/nfp_vdpa.c:
> >>>     Using __atomic_xxx built-ins, prefer rte_atomic_xxx
> >>>
> >>
> >> Oh, Sorry, we choose '__atomic_xxx' because we see the document in
> >> https://doc.dpdk.org/guides/prog_guide/writing_efficient_code.html?hi
> >> ghlig
> >> ht=atomic%20operations%20use%20c11%20atomic%20builtins#atomic-
> >> operations-use-c11-atomic-builtins.
> >> Maybe we misunderstood it, we will change to the `rte_atomic_xxx` in
> >> next version, thanks.
> >
> > As the notes in the 'doc/guides/rel_notes/deprecation.rst':
> > ---
> >   rte_atomicNN_xxx: These APIs do not take memory order parameter. This
> does
> >   not allow for writing optimized code for all the CPU architectures supported
> >   in DPDK. DPDK has adopted the atomic operations from
> >   https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html.
> These
> >   operations must be used for patches that need to be merged in 20.08
> onwards.
> >   This change will not introduce any performance degradation.
> > ---
> > The '__atomic_xxx' is the preferred choice? So maybe it's the
> 'checkpatches.sh' should update?
> > And seems there are many logics using the '__atomic_xxx'.
> >
> > Spend some time and confused about this now.
> > What is the right APIs I should use?
> > Please make it clear, thanks.
> >
> 
> Atomics usage got a few updates by time, if I remember correct:
> first there was DPDK rte_atomicNN_xxx APIs, later guidance updated to prefer
> compiler builtins, and recently guidance updated to use C11 defined
> functions.
> 
> And now there are 'rte_atomic_xxx()' APIs, underneath they use "compiler
> builtins" or "C11 functions" based on 'enable_stdatomic' config option and of
> course tool-chain support.
> 
> That is the reason of complexity in the checkpatch script.
> 
> @Tyler, @David, @Honnappa, what is the latest, up to date, guidance in the
> atomic APIs usage?
> 
> 
> 
> @Honnappa, is the deprecation notice Chaoyong highlighted still valid?
> Should we update it?
> 

Oh, sorry, I have found that we should use the <rte_stdatomic.h> header file, and I have sent out the v3 patch series, and it passed the check script.
Thanks.

^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v3 00/25] add the NFP vDPA PMD
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (24 preceding siblings ...)
  2023-10-26  6:43     ` [PATCH v3 25/25] doc: add a entry in the release notes Chaoyong He
@ 2023-10-26 14:47     ` Ferruh Yigit
  2023-10-26 14:55     ` Ferruh Yigit
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
  27 siblings, 0 replies; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-26 14:47 UTC (permalink / raw)
  To: Chaoyong He, dev, Tyler Retzlaff, David Marchand; +Cc: oss-drivers

On 10/26/2023 7:42 AM, Chaoyong He wrote:
> This patch series aims to add the NFP vDPA PMD, we also grab the common
> logic into the `drivers/common/nfp` directory.
> 
> ---
> v3:
> * Replace 'pthread_xxx' API with 'rte_thread_xxx' API.
> * Replace '__atomic_xxx' built-ins with 'rte_atomic_xxx'.
> * Drop the check statement in meson.build file which prevent build of
>   PMD.
> * Fix a problem about the logtype prefix.
> * Move the document modification to the commit which should be.
> v2:
> * Grab more logic into the `drivers/common/nfp` directory.
> * Delete some logic which should be when moving logic.
> ---
> 
> Chaoyong He (25):
>   drivers: introduce the NFP common library
>   net/nfp: make VF PMD using of NFP common module
>   net/nfp: rename common module name
>   net/nfp: rename ctrl module name
>   net/nfp: extract the cap data field
>   net/nfp: extract the qcp data field
>   net/nfp: extract the ctrl BAR data field
>   net/nfp: extract the ctrl data field
>   net/nfp: change the parameter of APIs
>   net/nfp: change the parameter of reconfig
>   net/nfp: extract the MAC address data field
>   net/nfp: rename parameter in related logic
>   drivers: add the common ctrl module
>   drivers: add the nfp common module
>   drivers: move queue logic to common module
>   drivers: move platform module to common library
>   drivers: move device module to common library
>   drivers/vdpa: introduce the NFP vDPA library
>   drivers: add the basic framework of vDPA PMD
>   vdpa/nfp: add the logic of remap PCI memory
>   vdpa/nfp: add the hardware init logic
>   drivers: add the datapath update logic
>   vdpa/nfp: add the notify related logic
>   vdpa/nfp: add nfp vDPA device operations
>   doc: add a entry in the release notes
> 

There is a build error on atomics API [1] with clang [2], it is fine
with gcc, cc'ed Tyler and David for help.



[1]
../drivers/vdpa/nfp/nfp_vdpa.c:548:7:
error: address argument to atomic operation must be a pointer to _Atomic
type ('uint32_t *' (aka 'unsigned int *') invalid)
        if ((rte_atomic_load_explicit(&device->running, rte_memory...
             ^                        ~~~~~~~~~~~~~~~~

../lib/eal/include/rte_stdatomic.h:71:2:
note: expanded from macro 'rte_atomic_load_explicit'
        atomic_load_explicit(ptr, memorder)
        ^                    ~~~

/usr/lib/llvm-14/lib/clang/14.0.0/include/stdatomic.h:130:30:
note: expanded from macro 'atomic_load_explicit'
#define atomic_load_explicit __c11_atomic_load
                             ^

[2]
CC=clang meson -Denable_stdatomic=true build

$ clang --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin


^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v3 25/25] doc: add a entry in the release notes
  2023-10-26  6:43     ` [PATCH v3 25/25] doc: add a entry in the release notes Chaoyong He
@ 2023-10-26 14:55       ` Ferruh Yigit
  0 siblings, 0 replies; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-26 14:55 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Long Wu, Peng Zhang

On 10/26/2023 7:43 AM, Chaoyong He wrote:
> Add a entry for the NFP vDPA PMD in the release notes.
> 
> 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>
> 

Can you please squash this patch to relevant commit:
18/25] drivers/vdpa: introduce the NFP vDPA library



^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v3 00/25] add the NFP vDPA PMD
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (25 preceding siblings ...)
  2023-10-26 14:47     ` [PATCH v3 00/25] add the NFP vDPA PMD Ferruh Yigit
@ 2023-10-26 14:55     ` Ferruh Yigit
  2023-10-27  1:23       ` Chaoyong He
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
  27 siblings, 1 reply; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-26 14:55 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers

On 10/26/2023 7:42 AM, Chaoyong He wrote:
> This patch series aims to add the NFP vDPA PMD, we also grab the common
> logic into the `drivers/common/nfp` directory.
> 
> ---
> v3:
> * Replace 'pthread_xxx' API with 'rte_thread_xxx' API.
> * Replace '__atomic_xxx' built-ins with 'rte_atomic_xxx'.
> * Drop the check statement in meson.build file which prevent build of
>   PMD.
> * Fix a problem about the logtype prefix.
> * Move the document modification to the commit which should be.
> v2:
> * Grab more logic into the `drivers/common/nfp` directory.
> * Delete some logic which should be when moving logic.
> ---
> 
> Chaoyong He (25):
>   drivers: introduce the NFP common library
>   net/nfp: make VF PMD using of NFP common module
>   net/nfp: rename common module name
>   net/nfp: rename ctrl module name
>   net/nfp: extract the cap data field
>   net/nfp: extract the qcp data field
>   net/nfp: extract the ctrl BAR data field
>   net/nfp: extract the ctrl data field
>   net/nfp: change the parameter of APIs
>   net/nfp: change the parameter of reconfig
>   net/nfp: extract the MAC address data field
>   net/nfp: rename parameter in related logic
>   drivers: add the common ctrl module
>   drivers: add the nfp common module
>   drivers: move queue logic to common module
>   drivers: move platform module to common library
>   drivers: move device module to common library
>   drivers/vdpa: introduce the NFP vDPA library
>   drivers: add the basic framework of vDPA PMD
>   vdpa/nfp: add the logic of remap PCI memory
>   vdpa/nfp: add the hardware init logic
>   drivers: add the datapath update logic
>   vdpa/nfp: add the notify related logic
>   vdpa/nfp: add nfp vDPA device operations
>   doc: add a entry in the release notes
> 

I was about the merge this patch but recognized the build error, and I
assume there will be new version,
for new version can you please look following as patch subject suggestions:

 vdpa/nfp: add device operations
 vdpa/nfp: add notify related logic
 vdpa/nfp: add datapath update
 vdpa/nfp: add hardware init
 vdpa/nfp: add remap PCI memory
 vdpa/nfp: add basic framework
 vdpa/nfp: introduce driver
 common/nfp: move device module
 common/nfp: move platform module
 common/nfp: move queue logic
 common/nfp: add common module
 common/nfp: add common ctrl module
 net/nfp: rename parameter in related logic
 net/nfp: extract MAC address data field
 net/nfp: change parameter of reconfig
 net/nfp: change parameter of functions
 net/nfp: extract ctrl data field
 net/nfp: extract ctrl BAR data field
 net/nfp: extract qcp data field
 net/nfp: extract cap data field
 net/nfp: rename ctrl module
 net/nfp: rename net common module
 net/nfp: make VF PMD use NFP common driver
 common/nfp: introduce driver


I am aware some will generate checkpatch warning 'Wrong headline
prefix', that happens when patch has mixture of different modules, I
think better to have the warning than using 'driver: '.


^ permalink raw reply	[flat|nested] 121+ messages in thread

* RE: [PATCH v3 00/25] add the NFP vDPA PMD
  2023-10-26 14:55     ` Ferruh Yigit
@ 2023-10-27  1:23       ` Chaoyong He
  0 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  1:23 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: oss-drivers

> On 10/26/2023 7:42 AM, Chaoyong He wrote:
> > This patch series aims to add the NFP vDPA PMD, we also grab the
> > common logic into the `drivers/common/nfp` directory.
> >
> > ---
> > v3:
> > * Replace 'pthread_xxx' API with 'rte_thread_xxx' API.
> > * Replace '__atomic_xxx' built-ins with 'rte_atomic_xxx'.
> > * Drop the check statement in meson.build file which prevent build of
> >   PMD.
> > * Fix a problem about the logtype prefix.
> > * Move the document modification to the commit which should be.
> > v2:
> > * Grab more logic into the `drivers/common/nfp` directory.
> > * Delete some logic which should be when moving logic.
> > ---
> >
> > Chaoyong He (25):
> >   drivers: introduce the NFP common library
> >   net/nfp: make VF PMD using of NFP common module
> >   net/nfp: rename common module name
> >   net/nfp: rename ctrl module name
> >   net/nfp: extract the cap data field
> >   net/nfp: extract the qcp data field
> >   net/nfp: extract the ctrl BAR data field
> >   net/nfp: extract the ctrl data field
> >   net/nfp: change the parameter of APIs
> >   net/nfp: change the parameter of reconfig
> >   net/nfp: extract the MAC address data field
> >   net/nfp: rename parameter in related logic
> >   drivers: add the common ctrl module
> >   drivers: add the nfp common module
> >   drivers: move queue logic to common module
> >   drivers: move platform module to common library
> >   drivers: move device module to common library
> >   drivers/vdpa: introduce the NFP vDPA library
> >   drivers: add the basic framework of vDPA PMD
> >   vdpa/nfp: add the logic of remap PCI memory
> >   vdpa/nfp: add the hardware init logic
> >   drivers: add the datapath update logic
> >   vdpa/nfp: add the notify related logic
> >   vdpa/nfp: add nfp vDPA device operations
> >   doc: add a entry in the release notes
> >
> 
> I was about the merge this patch but recognized the build error, and I assume
> there will be new version, for new version can you please look following as
> patch subject suggestions:
> 
>  vdpa/nfp: add device operations
>  vdpa/nfp: add notify related logic
>  vdpa/nfp: add datapath update
>  vdpa/nfp: add hardware init
>  vdpa/nfp: add remap PCI memory
>  vdpa/nfp: add basic framework
>  vdpa/nfp: introduce driver
>  common/nfp: move device module
>  common/nfp: move platform module
>  common/nfp: move queue logic
>  common/nfp: add common module
>  common/nfp: add common ctrl module
>  net/nfp: rename parameter in related logic
>  net/nfp: extract MAC address data field
>  net/nfp: change parameter of reconfig
>  net/nfp: change parameter of functions
>  net/nfp: extract ctrl data field
>  net/nfp: extract ctrl BAR data field
>  net/nfp: extract qcp data field
>  net/nfp: extract cap data field
>  net/nfp: rename ctrl module
>  net/nfp: rename net common module
>  net/nfp: make VF PMD use NFP common driver
>  common/nfp: introduce driver
> 
> 
> I am aware some will generate checkpatch warning 'Wrong headline prefix',
> that happens when patch has mixture of different modules, I think better to
> have the warning than using 'driver: '.

Okay, got it. Thanks.

^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 00/24] add the NFP vDPA PMD
  2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
                       ` (26 preceding siblings ...)
  2023-10-26 14:55     ` Ferruh Yigit
@ 2023-10-27  2:59     ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 01/24] common/nfp: introduce driver Chaoyong He
                         ` (24 more replies)
  27 siblings, 25 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series aims to add the NFP vDPA PMD, we also grab the common
logic into the `drivers/common/nfp` directory.

---
v4:
* Try to fix compile error in clang environment.
* Merge the modify of release notes into suitable commit.
* Rewrite the commit headline as the advise of reviewer.
v3:
* Replace 'pthread_xxx' API with 'rte_thread_xxx' API.
* Replace '__atomic_xxx' built-ins with 'rte_atomic_xxx'.
* Drop the check statement in meson.build file which prevent build of
  PMD.
* Fix a problem about the logtype prefix.
* Move the document modification to the commit which should be.
v2:
* Grab more logic into the `drivers/common/nfp` directory.
* Delete some logic which should be when moving logic.
---

Chaoyong He (24):
  common/nfp: introduce driver
  net/nfp: make VF PMD use NFP common driver
  net/nfp: rename net common module
  net/nfp: rename ctrl module
  net/nfp: extract cap data field
  net/nfp: extract qcp data field
  net/nfp: extract ctrl BAR data field
  net/nfp: extract ctrl data field
  net/nfp: change parameter of functions
  net/nfp: change parameter of reconfig
  net/nfp: extract MAC address data field
  net/nfp: rename parameter in related logic
  common/nfp: add common ctrl module
  common/nfp: add common module
  common/nfp: move queue logic
  common/nfp: move platform module
  common/nfp: move device module
  vdpa/nfp: introduce driver
  vdpa/nfp: add basic framework
  vdpa/nfp: add remap PCI memory
  vdpa/nfp: add hardware init
  vdpa/nfp: add datapath update
  vdpa/nfp: add notify related logic
  vdpa/nfp: add device operations

 .mailmap                                      |   1 +
 MAINTAINERS                                   |   7 +
 doc/guides/rel_notes/release_23_11.rst        |   5 +
 doc/guides/vdpadevs/features/nfp.ini          |   8 +
 doc/guides/vdpadevs/index.rst                 |   1 +
 doc/guides/vdpadevs/nfp.rst                   |  54 ++
 drivers/common/nfp/meson.build                |  16 +
 drivers/common/nfp/nfp_common.c               | 226 +++++
 drivers/common/nfp/nfp_common.h               | 239 +++++
 .../nfp/nfp_common_ctrl.h}                    | 209 +---
 drivers/common/nfp/nfp_common_log.c           |   8 +
 drivers/common/nfp/nfp_common_log.h           |  16 +
 drivers/common/nfp/nfp_common_pci.c           | 275 ++++++
 drivers/common/nfp/nfp_common_pci.h           |  45 +
 .../{net/nfp/nfpcore => common/nfp}/nfp_dev.c |   3 +-
 .../{net/nfp/nfpcore => common/nfp}/nfp_dev.h |   3 +
 .../nfp/nfpcore => common/nfp}/nfp_platform.h |   0
 drivers/common/nfp/version.map                |  16 +
 drivers/meson.build                           |   1 +
 drivers/net/nfp/flower/nfp_flower.c           |  56 +-
 drivers/net/nfp/flower/nfp_flower.h           |   2 +-
 .../net/nfp/flower/nfp_flower_representor.c   |  10 +-
 drivers/net/nfp/meson.build                   |   7 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c            |  18 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c            |  22 +-
 drivers/net/nfp/nfp_cpp_bridge.h              |   2 +-
 drivers/net/nfp/nfp_ethdev.c                  |  80 +-
 drivers/net/nfp/nfp_ethdev_vf.c               |  74 +-
 drivers/net/nfp/nfp_flow.h                    |   2 +-
 drivers/net/nfp/nfp_ipsec.c                   |  86 +-
 .../nfp/{nfp_common.c => nfp_net_common.c}    | 493 ++++------
 .../nfp/{nfp_common.h => nfp_net_common.h}    | 219 +----
 .../net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c}    |  21 +-
 drivers/net/nfp/nfp_net_ctrl.h                | 211 ++++
 drivers/net/nfp/nfp_rxtx.c                    |  20 +-
 drivers/net/nfp/nfpcore/nfp6000_pcie.h        |   2 +-
 drivers/net/nfp/nfpcore/nfp_cppcore.c         |   3 +-
 drivers/net/nfp/nfpcore/nfp_nsp.c             |   2 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c         |   3 +-
 drivers/vdpa/meson.build                      |   1 +
 drivers/vdpa/nfp/meson.build                  |  15 +
 drivers/vdpa/nfp/nfp_vdpa.c                   | 912 ++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c              | 193 ++++
 drivers/vdpa/nfp/nfp_vdpa_core.h              |  51 +
 drivers/vdpa/nfp/nfp_vdpa_log.c               |   9 +
 drivers/vdpa/nfp/nfp_vdpa_log.h               |  21 +
 46 files changed, 2727 insertions(+), 941 deletions(-)
 create mode 100644 doc/guides/vdpadevs/features/nfp.ini
 create mode 100644 doc/guides/vdpadevs/nfp.rst
 create mode 100644 drivers/common/nfp/meson.build
 create mode 100644 drivers/common/nfp/nfp_common.c
 create mode 100644 drivers/common/nfp/nfp_common.h
 rename drivers/{net/nfp/nfp_ctrl.h => common/nfp/nfp_common_ctrl.h} (63%)
 create mode 100644 drivers/common/nfp/nfp_common_log.c
 create mode 100644 drivers/common/nfp/nfp_common_log.h
 create mode 100644 drivers/common/nfp/nfp_common_pci.c
 create mode 100644 drivers/common/nfp/nfp_common_pci.h
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c (98%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h (96%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_platform.h (100%)
 create mode 100644 drivers/common/nfp/version.map
 rename drivers/net/nfp/{nfp_common.c => nfp_net_common.c} (80%)
 rename drivers/net/nfp/{nfp_common.h => nfp_net_common.h} (64%)
 rename drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} (84%)
 create mode 100644 drivers/net/nfp/nfp_net_ctrl.h
 create mode 100644 drivers/vdpa/nfp/meson.build
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.h
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.h

-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 01/24] common/nfp: introduce driver
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 02/24] net/nfp: make VF PMD use NFP common driver Chaoyong He
                         ` (23 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

A new NFP vdpa PMD will be added to support vdpa operations by NFP
adapters.

This vdpa PMD share some logic with the net/nfp PMD. So create a new
common library in drivers/common for NFP PMDs.

We import a 'nfp_class_driver' layer and which can support various
device type in addition to the ethernet device.

The shared logic will move into this common library in the following
commits.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 .mailmap                            |   1 +
 MAINTAINERS                         |   1 +
 drivers/common/nfp/meson.build      |  14 ++
 drivers/common/nfp/nfp_common_log.c |   8 +
 drivers/common/nfp/nfp_common_log.h |  16 ++
 drivers/common/nfp/nfp_common_pci.c | 274 ++++++++++++++++++++++++++++
 drivers/common/nfp/nfp_common_pci.h |  44 +++++
 drivers/common/nfp/version.map      |   7 +
 drivers/meson.build                 |   1 +
 9 files changed, 366 insertions(+)
 create mode 100644 drivers/common/nfp/meson.build
 create mode 100644 drivers/common/nfp/nfp_common_log.c
 create mode 100644 drivers/common/nfp/nfp_common_log.h
 create mode 100644 drivers/common/nfp/nfp_common_pci.c
 create mode 100644 drivers/common/nfp/nfp_common_pci.h
 create mode 100644 drivers/common/nfp/version.map

diff --git a/.mailmap b/.mailmap
index 3f5bab26a8..9d9e015607 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1299,6 +1299,7 @@ Shuanglin Wang <shuanglin.wang@broadcom.com>
 Shuki Katzenelson <shuki@lightbitslabs.com>
 Shun Hao <shunh@nvidia.com>
 Shu Shen <shu.shen@radisys.com>
+Shujing Dong <shujing.dong@corigine.com>
 Shweta Choudaha <shweta.choudaha@att.com>
 Shyam Kumar Shrivastav <shrivastav.shyam@gmail.com>
 Shy Shyman <shys@nvidia.com> <shys@mellanox.com>
diff --git a/MAINTAINERS b/MAINTAINERS
index 4083658697..5273ab9812 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -900,6 +900,7 @@ F: doc/guides/nics/features/nfb.ini
 
 Netronome nfp
 M: Chaoyong He <chaoyong.he@corigine.com>
+F: drivers/common/nfp/
 F: drivers/net/nfp/
 F: doc/guides/nics/nfp.rst
 F: doc/guides/nics/features/nfp*.ini
diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
new file mode 100644
index 0000000000..cda5a930c7
--- /dev/null
+++ b/drivers/common/nfp/meson.build
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64-bit Linux'
+endif
+
+sources = files(
+        'nfp_common_log.c',
+        'nfp_common_pci.c',
+)
+
+deps += ['bus_pci']
diff --git a/drivers/common/nfp/nfp_common_log.c b/drivers/common/nfp/nfp_common_log.c
new file mode 100644
index 0000000000..e69e608eb9
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_log.c
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common_log.h"
+
+RTE_LOG_REGISTER_SUFFIX(nfp_logtype_common, common, NOTICE);
diff --git a/drivers/common/nfp/nfp_common_log.h b/drivers/common/nfp/nfp_common_log.h
new file mode 100644
index 0000000000..066e38e688
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_log.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_LOG_H__
+#define __NFP_COMMON_LOG_H__
+
+#include <rte_log.h>
+
+extern int nfp_logtype_common;
+#define PMD_DRV_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_logtype_common, \
+			"%s(): " fmt "\n", __func__, ## args)
+
+#endif/* __NFP_COMMON_LOG_H__ */
diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
new file mode 100644
index 0000000000..65f189b05e
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -0,0 +1,274 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common_pci.h"
+
+#include <string.h>
+
+#include <rte_class.h>
+#include <rte_devargs.h>
+#include <rte_kvargs.h>
+
+#include "nfp_common_log.h"
+
+/* Reported driver name. */
+#define NFP_PCI_DRIVER_NAME "nfp_common_pci"
+
+static struct rte_pci_driver nfp_common_pci_driver;
+
+/* PCI ID table is build dynamically based on registered nfp drivers. */
+static struct rte_pci_id *nfp_pci_id_table;
+
+/* Head of list of drivers. */
+static TAILQ_HEAD(nfp_drivers, nfp_class_driver) nfp_drivers_list =
+		TAILQ_HEAD_INITIALIZER(nfp_drivers_list);
+
+static bool nfp_common_initialized;
+
+static const struct {
+	const char *name;
+	enum nfp_class drv_class;
+} nfp_classes[] = {
+	{ .name = "eth",      .drv_class = NFP_CLASS_ETH },
+};
+
+static enum nfp_class
+nfp_class_name_to_value(const char *class_name)
+{
+	uint32_t i;
+
+	for (i = 0; i < RTE_DIM(nfp_classes); i++) {
+		if (strcmp(class_name, nfp_classes[i].name) == 0)
+			return nfp_classes[i].drv_class;
+	}
+
+	return NFP_CLASS_INVALID;
+}
+
+static uint32_t
+nfp_pci_id_table_size_get(const struct rte_pci_id *id_table)
+{
+	uint32_t table_size;
+
+	if (id_table == NULL)
+		return 0;
+
+	for (table_size = 0; id_table->vendor_id != 0; id_table++)
+		table_size++;
+
+	return table_size;
+}
+
+static bool
+nfp_pci_id_exists(const struct rte_pci_id *id,
+		const struct rte_pci_id *table,
+		uint32_t next_idx)
+{
+	uint32_t i;
+
+	if (next_idx == 0)
+		return false;
+
+	for (i = 0; i < next_idx; i++) {
+		if (id->device_id == table[i].device_id &&
+				id->vendor_id == table[i].vendor_id &&
+				id->subsystem_vendor_id == table[i].subsystem_vendor_id &&
+				id->subsystem_device_id == table[i].subsystem_device_id)
+			return true;
+	}
+
+	return false;
+}
+
+static void
+nfp_pci_id_insert(struct rte_pci_id *new_table,
+		uint32_t *next_idx,
+		const struct rte_pci_id *id_table)
+{
+	if (id_table == NULL)
+		return;
+
+	/* Add non duplicate entries to new table. */
+	for (; id_table->vendor_id != 0; id_table++) {
+		if (!nfp_pci_id_exists(id_table, new_table, *next_idx)) {
+			new_table[*next_idx] = *id_table;
+			(*next_idx)++;
+		}
+	}
+}
+
+static int
+nfp_pci_id_table_update(const struct rte_pci_id *driver_id_table)
+{
+	uint32_t i = 0;
+	uint32_t num_ids = 0;
+	struct rte_pci_id *old_table;
+	const struct rte_pci_id *id_iter;
+	struct rte_pci_id *updated_table;
+
+	old_table = nfp_pci_id_table;
+	if (old_table != NULL)
+		num_ids = nfp_pci_id_table_size_get(old_table);
+	num_ids += nfp_pci_id_table_size_get(driver_id_table);
+
+	/* Increase size by one for the termination entry of vendor_id = 0. */
+	num_ids += 1;
+	updated_table = calloc(num_ids, sizeof(struct rte_pci_id));
+	if (updated_table == NULL)
+		return -ENOMEM;
+
+	if (old_table == NULL) {
+		/* Copy the first driver's ID table. */
+		for (id_iter = driver_id_table; id_iter[i].vendor_id != 0; i++)
+			updated_table[i] = id_iter[i];
+	} else {
+		/* First copy existing table entries. */
+		for (id_iter = old_table; id_iter[i].vendor_id != 0; i++)
+			updated_table[i] = id_iter[i];
+		/* New id to be added at the end of current ID table. */
+		nfp_pci_id_insert(updated_table, &i, driver_id_table);
+
+		free(old_table);
+	}
+
+	/* Terminate table with empty entry. */
+	updated_table[i].vendor_id = 0;
+	nfp_pci_id_table = updated_table;
+	nfp_common_pci_driver.id_table = nfp_pci_id_table;
+
+	return 0;
+}
+
+static int
+nfp_kvarg_dev_class_handler(__rte_unused const char *key,
+		const char *class_str,
+		void *opaque)
+{
+	enum nfp_class *dev_class = opaque;
+
+	if (class_str == NULL)
+		return *dev_class;
+
+	*dev_class = nfp_class_name_to_value(class_str);
+
+	return 0;
+}
+
+static enum nfp_class
+nfp_parse_class_options(const struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvargs;
+	enum nfp_class dev_class = NFP_CLASS_ETH;
+
+	if (devargs == NULL)
+		return dev_class;
+
+	kvargs = rte_kvargs_parse(devargs->args, NULL);
+	if (kvargs == NULL)
+		return dev_class;
+
+	if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
+		rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
+				nfp_kvarg_dev_class_handler, &dev_class);
+	}
+
+	rte_kvargs_free(kvargs);
+
+	return dev_class;
+}
+
+static int
+nfp_drivers_probe(struct rte_pci_device *pci_dev,
+		enum nfp_class class)
+{
+	int32_t ret = 0;
+	struct nfp_class_driver *driver;
+
+	TAILQ_FOREACH(driver, &nfp_drivers_list, next) {
+		if (driver->drv_class != class)
+			continue;
+
+		ret = driver->probe(pci_dev);
+		if (ret < 0) {
+			PMD_DRV_LOG(ERR, "Failed to load driver %s", driver->name);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_common_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+		struct rte_pci_device *pci_dev)
+{
+	enum nfp_class class;
+	struct rte_device *eal_dev = &pci_dev->device;
+
+	PMD_DRV_LOG(INFO, "probe device %s.", eal_dev->name);
+
+	class = nfp_parse_class_options(eal_dev->devargs);
+	if (class == NFP_CLASS_INVALID) {
+		PMD_DRV_LOG(ERR, "Unsupported nfp class type: %s",
+				eal_dev->devargs->args);
+		return -ENOTSUP;
+	}
+
+	return nfp_drivers_probe(pci_dev, class);
+}
+
+static int
+nfp_common_pci_remove(__rte_unused struct rte_pci_device *pci_dev)
+{
+	return 0;
+}
+
+static struct rte_pci_driver nfp_common_pci_driver = {
+	.driver = {
+		.name = NFP_PCI_DRIVER_NAME,
+	},
+	.probe = nfp_common_pci_probe,
+	.remove = nfp_common_pci_remove,
+};
+
+static void
+nfp_common_init(void)
+{
+	const struct rte_pci_id empty_table[] = {
+		{
+			.vendor_id = 0
+		},
+	};
+
+	if (nfp_common_initialized)
+		return;
+
+	/*
+	 * All the constructor of NFP PMDs run at same priority. So any of the PMD
+	 * including this one can register the PCI table first. If any other
+	 * PMD(s) have registered the PCI ID table, no need to register an empty
+	 * default one.
+	 */
+	if (nfp_pci_id_table == NULL && nfp_pci_id_table_update(empty_table) != 0)
+		return;
+
+	rte_pci_register(&nfp_common_pci_driver);
+	nfp_common_initialized = true;
+}
+
+void
+nfp_class_driver_register(struct nfp_class_driver *driver)
+{
+	nfp_common_init();
+
+	if (driver->id_table != NULL) {
+		if (nfp_pci_id_table_update(driver->id_table) != 0)
+			return;
+	}
+
+	nfp_common_pci_driver.drv_flags |= driver->drv_flags;
+
+	TAILQ_INSERT_TAIL(&nfp_drivers_list, driver, next);
+}
diff --git a/drivers/common/nfp/nfp_common_pci.h b/drivers/common/nfp/nfp_common_pci.h
new file mode 100644
index 0000000000..21465fca68
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_pci.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_PCI_H__
+#define __NFP_COMMON_PCI_H__
+
+#include <bus_pci_driver.h>
+
+/* Initialization function for the driver called during device probing. */
+typedef int (nfp_class_driver_probe_t)(struct rte_pci_device *dev);
+
+/* Uninitialization function for the driver called during hot-unplugging. */
+typedef int (nfp_class_driver_remove_t)(struct rte_pci_device *dev);
+
+enum nfp_class {
+	NFP_CLASS_ETH,
+	NFP_CLASS_INVALID,
+};
+
+/* Describing a nfp common class driver. */
+struct nfp_class_driver {
+	TAILQ_ENTRY(nfp_class_driver) next;
+	enum nfp_class drv_class;            /**< Class of this driver. */
+	const char *name;                    /**< Driver name. */
+	const struct rte_pci_id *id_table;   /**< ID table, NULL terminated. */
+	uint32_t drv_flags;                  /**< Flags RTE_PCI_DRV_*. */
+	nfp_class_driver_probe_t *probe;     /**< Device probe function. */
+	nfp_class_driver_remove_t *remove;   /**< Device remove function. */
+};
+
+/**
+ * Register a nfp device driver.
+ *
+ * @param driver
+ *   A pointer to a nfp_driver structure describing the driver
+ *   to be registered.
+ */
+__rte_internal
+void
+nfp_class_driver_register(struct nfp_class_driver *driver);
+
+#endif /* __NFP_COMMON_PCI_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
new file mode 100644
index 0000000000..25e48c39d6
--- /dev/null
+++ b/drivers/common/nfp/version.map
@@ -0,0 +1,7 @@
+INTERNAL {
+	global:
+
+	nfp_class_driver_register;
+
+	local: *;
+};
diff --git a/drivers/meson.build b/drivers/meson.build
index 8c775bbe62..af70ed322c 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -15,6 +15,7 @@ subdirs = [
         'common/mlx5',    # depends on bus.
         'common/qat',     # depends on bus.
         'common/sfc_efx', # depends on bus.
+        'common/nfp',     # depends on bus.
         'mempool',        # depends on common and bus.
         'dma',            # depends on common and bus.
         'net',            # depends on common, bus, mempool
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 02/24] net/nfp: make VF PMD use NFP common driver
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 01/24] common/nfp: introduce driver Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 03/24] net/nfp: rename net common module Chaoyong He
                         ` (22 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Modify the logic of NFP VF PMD, make it using of the NFP common module
and link into the 'nfp_drivers_list'.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/meson.build     |  2 +-
 drivers/net/nfp/nfp_ethdev_vf.c | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 40e9ef8524..4702f1cdf4 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -40,4 +40,4 @@ sources = files(
         'nfp_rxtx.c',
 )
 
-deps += ['hash', 'security']
+deps += ['hash', 'security', 'common_nfp']
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 3db35b90e8..b9d7a7c5c0 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -6,6 +6,7 @@
  */
 
 #include <rte_alarm.h>
+#include <nfp_common_pci.h>
 
 #include "nfd3/nfp_nfd3.h"
 #include "nfdk/nfp_nfdk.h"
@@ -399,8 +400,7 @@ nfp_vf_pci_uninit(struct rte_eth_dev *eth_dev)
 }
 
 static int
-nfp_vf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
-		struct rte_pci_device *pci_dev)
+nfp_vf_pci_probe(struct rte_pci_device *pci_dev)
 {
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 			sizeof(struct nfp_net_adapter), nfp_netvf_init);
@@ -412,13 +412,19 @@ nfp_vf_pci_remove(struct rte_pci_device *pci_dev)
 	return rte_eth_dev_pci_generic_remove(pci_dev, nfp_vf_pci_uninit);
 }
 
-static struct rte_pci_driver rte_nfp_net_vf_pmd = {
+static struct nfp_class_driver rte_nfp_net_vf_pmd = {
+	.drv_class = NFP_CLASS_ETH,
+	.name = RTE_STR(net_nfp_vf),
 	.id_table = pci_id_nfp_vf_net_map,
 	.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
 	.probe = nfp_vf_pci_probe,
 	.remove = nfp_vf_pci_remove,
 };
 
-RTE_PMD_REGISTER_PCI(net_nfp_vf, rte_nfp_net_vf_pmd);
+RTE_INIT(rte_nfp_vf_pmd_init)
+{
+	nfp_class_driver_register(&rte_nfp_net_vf_pmd);
+}
+
 RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 03/24] net/nfp: rename net common module
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 01/24] common/nfp: introduce driver Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 02/24] net/nfp: make VF PMD use NFP common driver Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 04/24] net/nfp: rename ctrl module Chaoyong He
                         ` (21 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename the 'nfp_common' module into 'nfp_net_common' module, because
which is more suitable and we will add 'nfp_common' module in the
'drivers/common/nfp' directory.

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.h                | 2 +-
 drivers/net/nfp/meson.build                        | 2 +-
 drivers/net/nfp/nfp_cpp_bridge.h                   | 2 +-
 drivers/net/nfp/nfp_ctrl.c                         | 2 +-
 drivers/net/nfp/nfp_ethdev_vf.c                    | 2 +-
 drivers/net/nfp/nfp_flow.h                         | 2 +-
 drivers/net/nfp/nfp_ipsec.c                        | 2 +-
 drivers/net/nfp/{nfp_common.c => nfp_net_common.c} | 2 +-
 drivers/net/nfp/{nfp_common.h => nfp_net_common.h} | 6 +++---
 9 files changed, 11 insertions(+), 11 deletions(-)
 rename drivers/net/nfp/{nfp_common.c => nfp_net_common.c} (99%)
 rename drivers/net/nfp/{nfp_common.h => nfp_net_common.h} (99%)

diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h
index b7ea830209..7d442e3cb2 100644
--- a/drivers/net/nfp/flower/nfp_flower.h
+++ b/drivers/net/nfp/flower/nfp_flower.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_FLOWER_H__
 #define __NFP_FLOWER_H__
 
-#include "../nfp_common.h"
+#include "../nfp_net_common.h"
 
 /* Extra features bitmap. */
 #define NFP_FL_FEATS_GENEVE             RTE_BIT64(0)
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 4702f1cdf4..4b4c587d5d 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -28,7 +28,6 @@ sources = files(
         'nfpcore/nfp_rtsym.c',
         'nfpcore/nfp_target.c',
         'nfpcore/nfp6000_pcie.c',
-        'nfp_common.c',
         'nfp_cpp_bridge.c',
         'nfp_ctrl.c',
         'nfp_ethdev.c',
@@ -37,6 +36,7 @@ sources = files(
         'nfp_ipsec.c',
         'nfp_logs.c',
         'nfp_mtr.c',
+        'nfp_net_common.c',
         'nfp_rxtx.c',
 )
 
diff --git a/drivers/net/nfp/nfp_cpp_bridge.h b/drivers/net/nfp/nfp_cpp_bridge.h
index a1103e85e4..bf975ce7ba 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.h
+++ b/drivers/net/nfp/nfp_cpp_bridge.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_CPP_BRIDGE_H__
 #define __NFP_CPP_BRIDGE_H__
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 int nfp_enable_cpp_service(struct nfp_pf_dev *pf_dev);
 int nfp_map_service(uint32_t service_id);
diff --git a/drivers/net/nfp/nfp_ctrl.c b/drivers/net/nfp/nfp_ctrl.c
index 6fc8cffd2e..a95e35c9a5 100644
--- a/drivers/net/nfp/nfp_ctrl.c
+++ b/drivers/net/nfp/nfp_ctrl.c
@@ -9,8 +9,8 @@
 
 #include "nfpcore/nfp_platform.h"
 
-#include "nfp_common.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 
 static void
 nfp_net_tlv_caps_reset(struct nfp_net_tlv_caps *caps)
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index b9d7a7c5c0..51c474275e 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -12,8 +12,8 @@
 #include "nfdk/nfp_nfdk.h"
 #include "nfpcore/nfp_cpp.h"
 
-#include "nfp_common.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 
 static void
 nfp_netvf_read_mac(struct nfp_net_hw *hw)
diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h
index aeb24458f3..09e5b30dd8 100644
--- a/drivers/net/nfp/nfp_flow.h
+++ b/drivers/net/nfp/nfp_flow.h
@@ -6,7 +6,7 @@
 #ifndef __NFP_FLOW_H__
 #define __NFP_FLOW_H__
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 /* The firmware expects lengths in units of long words */
 #define NFP_FL_LW_SIZ                   2
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index a76ba2a91d..f137e4b50c 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -12,9 +12,9 @@
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
 
-#include "nfp_common.h"
 #include "nfp_ctrl.h"
 #include "nfp_logs.h"
+#include "nfp_net_common.h"
 #include "nfp_rxtx.h"
 
 #define NFP_UDP_ESP_PORT            4500
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_net_common.c
similarity index 99%
rename from drivers/net/nfp/nfp_common.c
rename to drivers/net/nfp/nfp_net_common.c
index 2d4a7635ab..189f81bbb6 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -5,7 +5,7 @@
  * Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
  */
 
-#include "nfp_common.h"
+#include "nfp_net_common.h"
 
 #include <rte_alarm.h>
 
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_net_common.h
similarity index 99%
rename from drivers/net/nfp/nfp_common.h
rename to drivers/net/nfp/nfp_net_common.h
index c7f467e33c..cf08df4618 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -3,8 +3,8 @@
  * All rights reserved.
  */
 
-#ifndef __NFP_COMMON_H__
-#define __NFP_COMMON_H__
+#ifndef __NFP_NET_COMMON_H__
+#define __NFP_NET_COMMON_H__
 
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
@@ -451,4 +451,4 @@ bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
 #define NFP_PRIV_TO_APP_FW_FLOWER(app_fw_priv)\
 	((struct nfp_app_fw_flower *)app_fw_priv)
 
-#endif /* __NFP_COMMON_H__ */
+#endif /* __NFP_NET_COMMON_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 04/24] net/nfp: rename ctrl module
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (2 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 03/24] net/nfp: rename net common module Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 05/24] net/nfp: extract cap data field Chaoyong He
                         ` (20 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename the 'nfp_ctrl' module into 'nfp_net_ctrl' module, because which
is more suitable and we will add 'nfp_common_ctrl' module in the
'drivers/common/nfp' directory.

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/meson.build                    | 2 +-
 drivers/net/nfp/nfp_ipsec.c                    | 2 +-
 drivers/net/nfp/nfp_net_common.h               | 2 +-
 drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} | 2 +-
 drivers/net/nfp/{nfp_ctrl.h => nfp_net_ctrl.h} | 6 +++---
 5 files changed, 7 insertions(+), 7 deletions(-)
 rename drivers/net/nfp/{nfp_ctrl.c => nfp_net_ctrl.c} (98%)
 rename drivers/net/nfp/{nfp_ctrl.h => nfp_net_ctrl.h} (99%)

diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 4b4c587d5d..fa99c3b6aa 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -29,7 +29,6 @@ sources = files(
         'nfpcore/nfp_target.c',
         'nfpcore/nfp6000_pcie.c',
         'nfp_cpp_bridge.c',
-        'nfp_ctrl.c',
         'nfp_ethdev.c',
         'nfp_ethdev_vf.c',
         'nfp_flow.c',
@@ -37,6 +36,7 @@ sources = files(
         'nfp_logs.c',
         'nfp_mtr.c',
         'nfp_net_common.c',
+        'nfp_net_ctrl.c',
         'nfp_rxtx.c',
 )
 
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index f137e4b50c..af85e8575c 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -12,9 +12,9 @@
 #include <ethdev_driver.h>
 #include <ethdev_pci.h>
 
-#include "nfp_ctrl.h"
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
+#include "nfp_net_ctrl.h"
 #include "nfp_rxtx.h"
 
 #define NFP_UDP_ESP_PORT            4500
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index cf08df4618..8a02911c45 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -11,7 +11,7 @@
 #include <rte_io.h>
 #include <rte_spinlock.h>
 
-#include "nfp_ctrl.h"
+#include "nfp_net_ctrl.h"
 #include "nfpcore/nfp_dev.h"
 
 /* Macros for accessing the Queue Controller Peripheral 'CSRs' */
diff --git a/drivers/net/nfp/nfp_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
similarity index 98%
rename from drivers/net/nfp/nfp_ctrl.c
rename to drivers/net/nfp/nfp_net_ctrl.c
index a95e35c9a5..b0a427c98e 100644
--- a/drivers/net/nfp/nfp_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -3,7 +3,7 @@
  * All rights reserved.
  */
 
-#include "nfp_ctrl.h"
+#include "nfp_net_ctrl.h"
 
 #include <ethdev_pci.h>
 
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
similarity index 99%
rename from drivers/net/nfp/nfp_ctrl.h
rename to drivers/net/nfp/nfp_net_ctrl.h
index 9ec51e0a25..3772b28a66 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_net_ctrl.h
@@ -3,8 +3,8 @@
  * All rights reserved.
  */
 
-#ifndef __NFP_CTRL_H__
-#define __NFP_CTRL_H__
+#ifndef __NFP_NET_CTRL_H__
+#define __NFP_NET_CTRL_H__
 
 #include <stdint.h>
 
@@ -571,4 +571,4 @@ nfp_net_cfg_ctrl_rss(uint32_t hw_cap)
 	return NFP_NET_CFG_CTRL_RSS;
 }
 
-#endif /* __NFP_CTRL_H__ */
+#endif /* __NFP_NET_CTRL_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 05/24] net/nfp: extract cap data field
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (3 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 04/24] net/nfp: rename ctrl module Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 06/24] net/nfp: extract qcp " Chaoyong He
                         ` (19 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'cap' and 'cap_ext' data field into the super class, ready
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 |  6 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c  | 12 ++--
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  | 14 ++---
 drivers/net/nfp/nfp_ethdev.c        | 14 ++---
 drivers/net/nfp/nfp_ethdev_vf.c     | 10 +--
 drivers/net/nfp/nfp_ipsec.c         |  4 +-
 drivers/net/nfp/nfp_net_common.c    | 98 +++++++++++++++--------------
 drivers/net/nfp/nfp_net_common.h    | 10 ++-
 drivers/net/nfp/nfp_rxtx.c          |  2 +-
 9 files changed, 89 insertions(+), 81 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 60d843451e..453080f521 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -65,7 +65,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
+	if (hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
@@ -101,7 +101,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_RSS;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS2) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS2;
 	else
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS;
@@ -111,7 +111,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index b64dbaca0d..bbf4530ae9 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -30,7 +30,7 @@ nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
 		goto clean_txd;
 
 	ol_flags = mb->ol_flags;
@@ -69,7 +69,7 @@ nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
 		return;
 
 	ol_flags = mb->ol_flags;
@@ -127,8 +127,8 @@ nfp_net_nfd3_tx_vlan(struct nfp_net_txq *txq,
 {
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0 ||
-			(hw->cap & NFP_NET_CFG_CTRL_TXVLAN) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0 ||
+			(hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) == 0)
 		return;
 
 	if ((mb->ol_flags & RTE_MBUF_F_TX_VLAN) != 0) {
@@ -151,7 +151,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
 	uint8_t ipsec_layer = 0;
 
 	hw = txq->hw;
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
 			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
@@ -278,7 +278,7 @@ nfp_net_nfd3_xmit_pkts_common(void *tx_queue,
 		}
 
 		if (unlikely(pkt->nb_segs > 1 &&
-				(hw->cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
+				(hw->super.cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
 			PMD_TX_LOG(ERR, "Multisegment packet not supported");
 			goto xmit_end;
 		}
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 259039964a..807666686f 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -23,7 +23,7 @@ nfp_net_nfdk_tx_cksum(struct nfp_net_txq *txq,
 	uint64_t ol_flags;
 	struct nfp_net_hw *hw = txq->hw;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) == 0)
 		return flags;
 
 	ol_flags = mb->ol_flags;
@@ -57,7 +57,7 @@ nfp_net_nfdk_tx_tso(struct nfp_net_txq *txq,
 
 	txd.raw = 0;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) == 0)
 		return txd.raw;
 
 	ol_flags = mb->ol_flags;
@@ -146,7 +146,7 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq,
 		return -EINVAL;
 
 	/* Count TSO descriptor */
-	if ((txq->hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+	if ((txq->hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 			(pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0)
 		n_descs++;
 
@@ -184,7 +184,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 
 	memset(&meta_data, 0, sizeof(meta_data));
 	hw = txq->hw;
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
 			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
@@ -322,7 +322,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 			nfp_net_nfdk_set_meta_data(pkt, txq, &metadata);
 
 		if (unlikely(pkt->nb_segs > 1 &&
-				(hw->cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
+				(hw->super.cap & NFP_NET_CFG_CTRL_GATHER) == 0)) {
 			PMD_TX_LOG(ERR, "Multisegment packet not supported");
 			goto xmit_end;
 		}
@@ -332,7 +332,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 		 * multisegment packet, but TSO info needs to be in all of them.
 		 */
 		dma_len = pkt->data_len;
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 				(pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) {
 			type = NFDK_DESC_TX_TYPE_TSO;
 		} else if (pkt->next == NULL && dma_len <= NFDK_TX_MAX_DATA_PER_HEAD) {
@@ -405,7 +405,7 @@ nfp_net_nfdk_xmit_pkts_common(void *tx_queue,
 		ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_cksum(txq, temp_pkt, metadata));
 		ktxds++;
 
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0 &&
 				(temp_pkt->ol_flags & RTE_MBUF_F_TX_TCP_SEG) != 0) {
 			ktxds->raw = rte_cpu_to_le_64(nfp_net_nfdk_tx_tso(txq, temp_pkt));
 			ktxds++;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index d32a82210c..8ac2acea7b 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -119,7 +119,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
 	}
 
 	/* Enable device */
@@ -128,19 +128,19 @@ nfp_net_start(struct rte_eth_dev *dev)
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
 	/* Enable vxlan */
-	if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
 		new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
 		update |= NFP_NET_CFG_UPDATE_VXLAN;
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/* Enable packet type offload by extend ctrl word1. */
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
 		ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
 
@@ -579,8 +579,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
 	nfp_net_log_device_information(hw);
 
@@ -608,7 +608,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	/* Copying mac address to DPDK eth_dev struct */
 	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 51c474275e..293d1ed53c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -86,7 +86,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
 	}
 
 	/* Enable device */
@@ -94,7 +94,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
 	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
@@ -314,8 +314,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
 	nfp_net_log_device_information(hw);
 
@@ -341,7 +341,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	/* Copying mac address to DPDK eth_dev struct */
 	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index af85e8575c..e080e71db2 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -1382,7 +1382,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return 0;
@@ -1429,7 +1429,7 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 189f81bbb6..77c0652642 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -408,7 +408,7 @@ nfp_net_configure(struct rte_eth_dev *dev)
 
 	/* Checking RX mode */
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+			(hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		PMD_DRV_LOG(ERR, "RSS not supported");
 		return -EINVAL;
 	}
@@ -426,27 +426,29 @@ nfp_net_configure(struct rte_eth_dev *dev)
 void
 nfp_net_log_device_information(const struct nfp_net_hw *hw)
 {
+	uint32_t cap = hw->super.cap;
+
 	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
 			hw->ver.major, hw->ver.minor, hw->max_mtu);
 
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
-			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
-			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2 ? "TXVLANv2 "  : "",
-			hw->cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
-			hw->cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
-			hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
-			hw->cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
-			hw->cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
-			hw->cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
-			hw->cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
+	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", cap,
+			cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
+			cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
+			cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
+			cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
+			cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
+			cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
+			cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
+			cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
+			cap & NFP_NET_CFG_CTRL_TXVLAN_V2 ? "TXVLANv2 "  : "",
+			cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
+			cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
+			cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
+			cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
+			cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
+			cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
+			cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
+			cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
 
 	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
 			hw->max_rx_queues, hw->max_tx_queues);
@@ -456,9 +458,9 @@ static inline void
 nfp_net_enable_rxvlan_cap(struct nfp_net_hw *hw,
 		uint32_t *ctrl)
 {
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0)
 		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN_V2;
-	else if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN) != 0)
+	else if ((hw->super.cap & NFP_NET_CFG_CTRL_RXVLAN) != 0)
 		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN;
 }
 
@@ -503,7 +505,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
@@ -552,7 +554,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
+			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
 	}
@@ -563,7 +565,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
+			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
 	/* Signal the NIC about the change */
@@ -631,7 +633,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	tx_offload = dev_conf->txmode.offloads;
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXCSUM;
 	}
 
@@ -639,25 +641,25 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 		nfp_net_enable_rxvlan_cap(hw, &ctrl);
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
 	hw->mtu = dev->data->mtu;
 
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2;
-		else if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
+		else if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
 	}
 
 	/* L2 broadcast */
-	if ((hw->cap & NFP_NET_CFG_CTRL_L2BC) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2BC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2BC;
 
 	/* L2 multicast */
-	if ((hw->cap & NFP_NET_CFG_CTRL_L2MC) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2MC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2MC;
 
 	/* TX checksum offload */
@@ -669,7 +671,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	/* LSO offload */
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 ||
 			(tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) {
-		if ((hw->cap & NFP_NET_CFG_CTRL_LSO) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_LSO;
 		else
 			ctrl |= NFP_NET_CFG_CTRL_LSO2;
@@ -698,7 +700,7 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev)
 		hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(ERR, "Promiscuous mode not supported");
 		return -ENOTSUP;
 	}
@@ -1213,35 +1215,35 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
-	if ((hw->cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
+	if ((hw->super.cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
+	if ((hw->super.cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
 		dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
-		if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
+		if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
 			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
 	}
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_GATHER) != 0)
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_GATHER) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
-	cap_extend = hw->cap_ext;
+	cap_extend = hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SECURITY;
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SECURITY;
@@ -1281,7 +1283,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG,
 	};
 
-	if ((hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
 		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
@@ -1334,8 +1336,8 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 		return -ENODEV;
 
 	/* Get some of the read-only fields from the config BAR */
-	hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
-	hw->cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	hw->super.cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
+	hw->super.cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
 	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
 	hw->flbufsz = DEFAULT_FLBUF_SIZE;
 
@@ -2025,14 +2027,14 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw)
 	 */
 	if (hw->ver.major == 4) {
 		hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
-	} else if ((hw->cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
+	} else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
 		hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
 		/*
-		 * RSS is incompatible with chained metadata. hw->cap just represents
+		 * RSS is incompatible with chained metadata. hw->super.cap just represents
 		 * firmware's ability rather than the firmware's configuration. We decide
-		 * to reduce the confusion to allow us can use hw->cap to identify RSS later.
+		 * to reduce the confusion to allow us can use hw->super.cap to identify RSS later.
 		 */
-		hw->cap &= ~NFP_NET_CFG_CTRL_RSS;
+		hw->super.cap &= ~NFP_NET_CFG_CTRL_RSS;
 	} else {
 		hw->meta_format = NFP_NET_METAFORMAT_SINGLE;
 	}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 8a02911c45..7bcdd9295f 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -112,7 +112,15 @@ struct nfp_app_fw_nic {
 	uint8_t total_phyports;
 };
 
+struct nfp_hw {
+	uint32_t cap;
+	uint32_t cap_ext;
+};
+
 struct nfp_net_hw {
+	/** The parent class */
+	struct nfp_hw super;
+
 	/** Backpointer to the PF this port belongs to */
 	struct nfp_pf_dev *pf_dev;
 
@@ -120,9 +128,7 @@ struct nfp_net_hw {
 	struct rte_eth_dev *eth_dev;
 
 	/** Info from the firmware */
-	uint32_t cap_ext;
 	struct nfp_net_fw_ver ver;
-	uint32_t cap;
 	uint32_t max_mtu;
 	uint32_t mtu;
 	uint32_t rx_offset;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index efdca7fccf..a0c7e0e9b5 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -386,7 +386,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 	struct nfp_net_hw *hw = rxq->hw;
 
 	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
-			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
+			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
 	if (meta->vlan_layer < NFP_META_MAX_VLANS)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 06/24] net/nfp: extract qcp data field
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (4 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 05/24] net/nfp: extract cap data field Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 07/24] net/nfp: extract ctrl BAR " Chaoyong He
                         ` (18 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'qcp_cfg' data field 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/nfp_net_common.c | 8 ++++----
 drivers/net/nfp/nfp_net_common.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 77c0652642..cb64fa13c5 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -206,14 +206,14 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 	struct timespec wait;
 
 	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->qcp_cfg);
+			hw->super.qcp_cfg);
 
-	if (hw->qcp_cfg == NULL) {
+	if (hw->super.qcp_cfg == NULL) {
 		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
 		return -ENXIO;
 	}
 
-	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+	nfp_qcp_ptr_add(hw->super.qcp_cfg, NFP_QCP_WRITE_PTR, 1);
 
 	wait.tv_sec = 0;
 	wait.tv_nsec = 1000000; /* 1ms */
@@ -525,7 +525,7 @@ nfp_net_params_setup(struct nfp_net_hw *hw)
 void
 nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 {
-	hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
+	hw->super.qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }
 
 void
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 7bcdd9295f..4bfb3174b0 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 *qcp_cfg;
 	uint32_t cap;
 	uint32_t cap_ext;
 };
@@ -150,7 +151,6 @@ struct nfp_net_hw {
 	uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
 	uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
 
-	uint8_t *qcp_cfg;
 	rte_spinlock_t reconfig_lock;
 
 	uint32_t max_tx_queues;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 07/24] net/nfp: extract ctrl BAR data field
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (5 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 06/24] net/nfp: extract qcp " Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 08/24] net/nfp: extract ctrl " Chaoyong He
                         ` (17 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

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(-)

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;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 08/24] net/nfp: extract ctrl data field
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (6 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 07/24] net/nfp: extract ctrl BAR " Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 09/24] net/nfp: change parameter of functions Chaoyong He
                         ` (16 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'ctrl' 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/nfd3/nfp_nfd3_dp.c  |  2 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c  |  2 +-
 drivers/net/nfp/nfp_ethdev.c        |  4 ++-
 drivers/net/nfp/nfp_ethdev_vf.c     |  2 +-
 drivers/net/nfp/nfp_net_common.c    | 46 ++++++++++++++---------------
 drivers/net/nfp/nfp_net_common.h    |  5 ++--
 drivers/net/nfp/nfp_rxtx.c          | 12 ++++----
 8 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index c8455e0241..8bb5914888 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -61,7 +61,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
 	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
@@ -72,7 +72,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 }
 
 int
@@ -123,7 +123,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 		return -EIO;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
@@ -721,7 +721,7 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 		return -EIO;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index bbf4530ae9..3045533857 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -154,7 +154,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
 	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+			(hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
 		if (meta_data->length == 0)
 			meta_data->length = NFP_NET_META_HEADER_SIZE;
 		meta_data->length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 807666686f..63421ba796 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -187,7 +187,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 	cap_extend = hw->super.cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+			(hw->super.ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
 		if (meta_data.length == 0)
 			meta_data.length = NFP_NET_META_HEADER_SIZE;
 		meta_data.length += NFP_NET_META_FIELD_SIZE;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index b7c60b642f..0f6f97be8e 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -152,6 +152,8 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if (nfp_net_ext_reconfig(hw, ctrl_extend, update) != 0)
 		return -EIO;
 
+	hw->super.ctrl_ext = ctrl_extend;
+
 	/*
 	 * Allocating rte mbufs for configured rx queues.
 	 * This requires queues being enabled before.
@@ -167,7 +169,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	else
 		nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 1);
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 641fed6fcf..684968903c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -110,7 +110,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 29f836c31e..058260bda3 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -500,7 +500,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
 	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
@@ -512,7 +512,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 }
 
 void
@@ -553,7 +553,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	struct nfp_net_hw *hw;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
 			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
@@ -563,8 +563,8 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
-	ctrl = hw->ctrl;
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+	ctrl = hw->super.ctrl;
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
 			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
@@ -613,7 +613,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 	}
 
 	/* Avoiding TX interrupts */
-	hw->ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
+	hw->super.ctrl |= NFP_NET_CFG_CTRL_MSIX_TX_OFF;
 	return 0;
 }
 
@@ -705,19 +705,19 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already enabled");
 		return 0;
 	}
 
-	new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->super.ctrl | NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -732,19 +732,19 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already disabled");
 		return 0;
 	}
 
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1349,7 +1349,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 	else
 		hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
 
-	hw->ctrl = 0;
+	hw->super.ctrl = 0;
 	hw->stride_rx = stride;
 	hw->stride_tx = stride;
 
@@ -1453,7 +1453,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
 	/* Make sure all updates are written before un-masking */
 	rte_wmb();
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_MSIXAUTO) != 0) {
 		/* If MSI-X auto-masking is used, clear the entry */
 		rte_intr_ack(pci_dev->intr_handle);
 	} else {
@@ -1559,7 +1559,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	rx_offload = dev->data->dev_conf.rxmode.offloads;
-	new_ctrl = hw->ctrl;
+	new_ctrl = hw->super.ctrl;
 
 	/* VLAN stripping setting */
 	if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) {
@@ -1578,7 +1578,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 			new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
-	if (new_ctrl == hw->ctrl)
+	if (new_ctrl == hw->super.ctrl)
 		return 0;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
@@ -1587,7 +1587,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 	if (ret != 0)
 		return ret;
 
-	hw->ctrl = new_ctrl;
+	hw->super.ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1660,7 +1660,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 	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)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size);
@@ -1669,7 +1669,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1690,7 +1690,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 	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)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
@@ -1795,7 +1795,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 	rss_hf = rss_conf->rss_hf;
 
 	/* Checking if RSS is enabled */
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		if (rss_hf != 0) {
 			PMD_DRV_LOG(ERR, "RSS unsupported");
 			return -EINVAL;
@@ -1813,7 +1813,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->ctrl, update) != 0)
+	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1831,7 +1831,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index dd62ec6d83..3fb3b34613 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -117,6 +117,8 @@ struct nfp_hw {
 	uint8_t *qcp_cfg;
 	uint32_t cap;
 	uint32_t cap_ext;
+	uint32_t ctrl;
+	uint32_t ctrl_ext;
 };
 
 struct nfp_net_hw {
@@ -139,9 +141,6 @@ struct nfp_net_hw {
 	/** NFP ASIC params */
 	const struct nfp_dev_info *dev_info;
 
-	/** Current values for control */
-	uint32_t ctrl;
-
 	uint8_t *tx_bar;
 	uint8_t *rx_bar;
 
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index a0c7e0e9b5..a9dd464a6a 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -143,7 +143,7 @@ nfp_net_rx_cksum(struct nfp_net_rxq *rxq,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXCSUM) == 0)
 		return;
 
 	/* If IPv4 and IP checksum error, fail */
@@ -307,7 +307,7 @@ nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return;
 
 	mbuf->hash.rss = meta->hash;
@@ -339,7 +339,7 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	struct nfp_net_hw *hw = rxq->hw;
 
 	/* Skip if firmware don't support setting vlan. */
-	if ((hw->ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
+	if ((hw->super.ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
 	/*
@@ -347,12 +347,12 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	 * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
 	 * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
 	 */
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
 		if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
 		}
-	} else if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+	} else if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
 		if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
@@ -385,7 +385,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
 			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 09/24] net/nfp: change parameter of functions
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (7 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 08/24] net/nfp: extract ctrl " Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 10/24] net/nfp: change parameter of reconfig Chaoyong He
                         ` (15 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Change the parameter of some functions from 'struct nfp_net_hw' into the
super class 'struct nfp_hw', 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           |  24 ++--
 .../net/nfp/flower/nfp_flower_representor.c   |  10 +-
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c            |   4 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c            |   4 +-
 drivers/net/nfp/nfp_ethdev.c                  |   8 +-
 drivers/net/nfp/nfp_ethdev_vf.c               |  12 +-
 drivers/net/nfp/nfp_ipsec.c                   |   4 +-
 drivers/net/nfp/nfp_net_common.c              | 129 +++++++++---------
 drivers/net/nfp/nfp_net_common.h              |  32 ++---
 drivers/net/nfp/nfp_rxtx.c                    |   4 +-
 10 files changed, 116 insertions(+), 115 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 8bb5914888..ccb579541b 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -36,7 +36,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	enabled_queues = 0;
 
@@ -44,7 +44,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 static void
@@ -58,8 +58,8 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 	repr = dev->data->dev_private;
 	hw = repr->app_fw_flower->pf_hw;
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
 
 	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
@@ -114,7 +114,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
 
 	/* If an error when reconfig we avoid to change hw state */
 	ret = nfp_net_reconfig(hw, new_ctrl, update);
@@ -219,7 +219,7 @@ nfp_flower_pf_close(struct rte_eth_dev *dev)
 	/* Cancel possible impending LSC work here before releasing the port */
 	rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler, (void *)dev);
 
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
 
 	/* Now it is safe to free all PF resources */
 	PMD_DRV_LOG(INFO, "Freeing PF resources");
@@ -356,9 +356,9 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw,
 		return err;
 
 	/* Work out where in the BAR the queues start */
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = (uint64_t)start_q * NFP_QCP_QUEUE_ADDR_SZ;
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = (uint64_t)start_q * NFP_QCP_QUEUE_ADDR_SZ;
 
 	hw->tx_bar = pf_dev->qc_bar + tx_bar_off;
@@ -543,8 +543,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 		 * Telling the HW about the physical address of the RX ring and number
 		 * of descriptors in log2 format.
 		 */
-		nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(i), rxq->dma);
-		nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
+		nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(i), rxq->dma);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
 	}
 
 	snprintf(ctrl_txring_name, sizeof(ctrl_txring_name), "%s_cttx_ring", pci_name);
@@ -608,8 +608,8 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 		 * Telling the HW about the physical address of the TX ring and number
 		 * of descriptors in log2 format.
 		 */
-		nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(i), txq->dma);
-		nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
+		nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(i), txq->dma);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(i), rte_log2_u32(CTRL_VNIC_NB_DESC));
 	}
 
 	return 0;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 650f09a475..b52c6f514a 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -97,8 +97,8 @@ nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the RX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
@@ -181,8 +181,8 @@ nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
@@ -228,7 +228,7 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,
 				}
 			}
 		} else {
-			nn_link_status = nn_cfg_readw(pf_hw, NFP_NET_CFG_STS);
+			nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS);
 			nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) &
 					NFP_NET_CFG_STS_LINK_RATE_MASK;
 
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 3045533857..c85fadc80d 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -465,8 +465,8 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
 
 	return 0;
 }
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 63421ba796..3f8d25aa29 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -542,8 +542,8 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the TX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(txq->tx_count));
 
 	return 0;
 }
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 0f6f97be8e..a773a81e55 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -286,7 +286,7 @@ nfp_net_close(struct rte_eth_dev *dev)
 
 	/* Only free PF resources after all physical ports have been closed */
 	/* Mark this port as unused and free device priv resources */
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, 0xff);
 	app_fw_nic->ports[hw->idx] = NULL;
 
 	for (i = 0; i < app_fw_nic->total_phyports; i++) {
@@ -567,8 +567,8 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* Work out where in the BAR the queues start. */
-	tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
-	rx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	tx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
+	rx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 
 	hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
 	hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
@@ -625,7 +625,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	rte_intr_callback_register(pci_dev->intr_handle,
 			nfp_net_dev_interrupt_handler, (void *)eth_dev);
 	/* Telling the firmware about the LSC interrupt entry */
-	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 	/* Recording current stats counters values */
 	nfp_net_stats_reset(eth_dev);
 
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 684968903c..7fb2a3d378 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -20,10 +20,10 @@ nfp_netvf_read_mac(struct nfp_net_hw *hw)
 {
 	uint32_t tmp;
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR));
 	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR + 4));
 	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
 }
 
@@ -97,7 +97,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
 	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
@@ -299,9 +299,9 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* Work out where in the BAR the queues start. */
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
-	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
 
 	hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
@@ -357,7 +357,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		rte_intr_callback_register(pci_dev->intr_handle,
 				nfp_net_dev_interrupt_handler, (void *)eth_dev);
 		/* Telling the firmware about the LSC interrupt entry */
-		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 		/* Recording current stats counters values */
 		nfp_net_stats_reset(eth_dev);
 	}
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index e080e71db2..0da5c2a3d2 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -445,7 +445,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	msg->rsp = NFP_IPSEC_CFG_MSG_OK;
 
 	for (i = 0; i < msg_size; i++)
-		nn_cfg_writel(hw, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
 
 	ret = nfp_net_mbox_reconfig(hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
 	if (ret < 0) {
@@ -459,7 +459,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	 * response. One example where the data is needed is for statistics.
 	 */
 	for (i = 0; i < msg_size; i++)
-		msg->raw[i] = nn_cfg_readl(hw, NFP_NET_CFG_MBOX_VAL + 4 * i);
+		msg->raw[i] = nn_cfg_readl(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
 
 	switch (msg->rsp) {
 	case NFP_IPSEC_CFG_MSG_OK:
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 058260bda3..2ab8d8fadd 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -182,7 +182,8 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 	 * NFP_NET_CFG_STS_NSP_LINK_RATE.
 	 */
 	if (link->link_status == RTE_ETH_LINK_DOWN) {
-		nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE, NFP_NET_CFG_STS_LINK_RATE_UNKNOWN);
+		nn_cfg_writew(&hw->super, NFP_NET_CFG_STS_NSP_LINK_RATE,
+				NFP_NET_CFG_STS_LINK_RATE_UNKNOWN);
 		return;
 	}
 
@@ -190,7 +191,7 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 	 * Link is up so write the link speed from the eth_table to
 	 * NFP_NET_CFG_STS_NSP_LINK_RATE.
 	 */
-	nn_cfg_writew(hw, NFP_NET_CFG_STS_NSP_LINK_RATE,
+	nn_cfg_writew(&hw->super, NFP_NET_CFG_STS_NSP_LINK_RATE,
 			nfp_net_link_speed_rte2nfp(link->link_speed));
 }
 
@@ -222,7 +223,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	/* Poll update field, waiting for NFP to ack the config */
 	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
+		new = nn_cfg_readl(&hw->super, NFP_NET_CFG_UPDATE);
 		if (new == 0)
 			break;
 
@@ -270,8 +271,8 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
@@ -314,8 +315,8 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
@@ -355,8 +356,8 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writeq(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
+	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
@@ -370,7 +371,7 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 		return -EIO;
 	}
 
-	return nn_cfg_readl(hw, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
+	return nn_cfg_readl(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
 }
 
 /*
@@ -478,14 +479,14 @@ nfp_net_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	/* Enabling the required RX queues in the device */
 	enabled_queues = 0;
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 void
@@ -497,8 +498,8 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
 
 	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
@@ -518,8 +519,8 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 void
 nfp_net_params_setup(struct nfp_net_hw *hw)
 {
-	nn_cfg_writel(hw, NFP_NET_CFG_MTU, hw->mtu);
-	nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_MTU, hw->mtu);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_FLBUFSZ, hw->flbufsz);
 }
 
 void
@@ -596,7 +597,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 	if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) {
 		PMD_DRV_LOG(INFO, "VF: enabling RX interrupt with UIO");
 		/* UIO just supports one queue and no LSC */
-		nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(0), 0);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_VEC(0), 0);
 		if (rte_intr_vec_list_index_set(intr_handle, 0, 0) != 0)
 			return -1;
 	} else {
@@ -606,7 +607,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 			 * The first msix vector is reserved for non
 			 * efd interrupts.
 			 */
-			nn_cfg_writeb(hw, NFP_NET_CFG_RXR_VEC(i), i + 1);
+			nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_VEC(i), i + 1);
 			if (rte_intr_vec_list_index_set(intr_handle, i, i + 1) != 0)
 				return -1;
 		}
@@ -771,7 +772,7 @@ nfp_net_link_update(struct rte_eth_dev *dev,
 	memset(&link, 0, sizeof(struct rte_eth_link));
 
 	/* Read link status */
-	nn_link_status = nn_cfg_readw(hw, NFP_NET_CFG_STS);
+	nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS);
 	if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0)
 		link.link_status = RTE_ETH_LINK_UP;
 
@@ -842,12 +843,12 @@ nfp_net_stats_get(struct rte_eth_dev *dev,
 			break;
 
 		nfp_dev_stats.q_ipackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i));
 		nfp_dev_stats.q_ipackets[i] -=
 				hw->eth_stats_base.q_ipackets[i];
 
 		nfp_dev_stats.q_ibytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i) + 0x8);
 		nfp_dev_stats.q_ibytes[i] -=
 				hw->eth_stats_base.q_ibytes[i];
 	}
@@ -858,42 +859,42 @@ nfp_net_stats_get(struct rte_eth_dev *dev,
 			break;
 
 		nfp_dev_stats.q_opackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i));
 		nfp_dev_stats.q_opackets[i] -= hw->eth_stats_base.q_opackets[i];
 
 		nfp_dev_stats.q_obytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i) + 0x8);
 		nfp_dev_stats.q_obytes[i] -= hw->eth_stats_base.q_obytes[i];
 	}
 
-	nfp_dev_stats.ipackets = nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES);
+	nfp_dev_stats.ipackets = nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_FRAMES);
 	nfp_dev_stats.ipackets -= hw->eth_stats_base.ipackets;
 
-	nfp_dev_stats.ibytes = nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS);
+	nfp_dev_stats.ibytes = nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_OCTETS);
 	nfp_dev_stats.ibytes -= hw->eth_stats_base.ibytes;
 
 	nfp_dev_stats.opackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_FRAMES);
 	nfp_dev_stats.opackets -= hw->eth_stats_base.opackets;
 
 	nfp_dev_stats.obytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_OCTETS);
 	nfp_dev_stats.obytes -= hw->eth_stats_base.obytes;
 
 	/* Reading general device stats */
 	nfp_dev_stats.ierrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_ERRORS);
 	nfp_dev_stats.ierrors -= hw->eth_stats_base.ierrors;
 
 	nfp_dev_stats.oerrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_ERRORS);
 	nfp_dev_stats.oerrors -= hw->eth_stats_base.oerrors;
 
 	/* RX ring mbuf allocation failures */
 	nfp_dev_stats.rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 
 	nfp_dev_stats.imissed =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_DISCARDS);
 	nfp_dev_stats.imissed -= hw->eth_stats_base.imissed;
 
 	memcpy(stats, &nfp_dev_stats, sizeof(*stats));
@@ -918,10 +919,10 @@ nfp_net_stats_reset(struct rte_eth_dev *dev)
 			break;
 
 		hw->eth_stats_base.q_ipackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i));
 
 		hw->eth_stats_base.q_ibytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_RXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_RXR_STATS(i) + 0x8);
 	}
 
 	/* Reading per TX ring stats */
@@ -930,36 +931,36 @@ nfp_net_stats_reset(struct rte_eth_dev *dev)
 			break;
 
 		hw->eth_stats_base.q_opackets[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i));
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i));
 
 		hw->eth_stats_base.q_obytes[i] =
-				nn_cfg_readq(hw, NFP_NET_CFG_TXR_STATS(i) + 0x8);
+				nn_cfg_readq(&hw->super, NFP_NET_CFG_TXR_STATS(i) + 0x8);
 	}
 
 	hw->eth_stats_base.ipackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_FRAMES);
 
 	hw->eth_stats_base.ibytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_OCTETS);
 
 	hw->eth_stats_base.opackets =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_FRAMES);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_FRAMES);
 
 	hw->eth_stats_base.obytes =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_OCTETS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_OCTETS);
 
 	/* Reading general device stats */
 	hw->eth_stats_base.ierrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_ERRORS);
 
 	hw->eth_stats_base.oerrors =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_TX_ERRORS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_TX_ERRORS);
 
 	/* RX ring mbuf allocation failures */
 	dev->data->rx_mbuf_alloc_failed = 0;
 
 	hw->eth_stats_base.imissed =
-			nn_cfg_readq(hw, NFP_NET_CFG_STATS_RX_DISCARDS);
+			nn_cfg_readq(&hw->super, NFP_NET_CFG_STATS_RX_DISCARDS);
 
 	return 0;
 }
@@ -1012,7 +1013,7 @@ nfp_net_xstats_value(const struct rte_eth_dev *dev,
 	if (xstat.group == NFP_XSTAT_GROUP_MAC)
 		value = nn_readq(hw->mac_stats + xstat.offset);
 	else
-		value = nn_cfg_readq(hw, xstat.offset);
+		value = nn_cfg_readq(&hw->super, xstat.offset);
 
 	if (raw)
 		return value;
@@ -1320,8 +1321,8 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 	hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
 	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
 
-	hw->max_rx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_RXRINGS);
-	hw->max_tx_queues = nn_cfg_readl(hw, NFP_NET_CFG_MAX_TXRINGS);
+	hw->max_rx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_RXRINGS);
+	hw->max_tx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_TXRINGS);
 	if (hw->max_rx_queues == 0 || hw->max_tx_queues == 0) {
 		PMD_INIT_LOG(ERR, "Device %s can not be used, there are no valid queue "
 				"pairs for use", pci_dev->name);
@@ -1336,9 +1337,9 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 		return -ENODEV;
 
 	/* Get some of the read-only fields from the config BAR */
-	hw->super.cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
-	hw->super.cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
-	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
+	hw->super.cap = nn_cfg_readl(&hw->super, NFP_NET_CFG_CAP);
+	hw->super.cap_ext = nn_cfg_readl(&hw->super, NFP_NET_CFG_CAP_WORD1);
+	hw->max_mtu = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_MTU);
 	hw->flbufsz = DEFAULT_FLBUF_SIZE;
 
 	nfp_net_init_metadata_format(hw);
@@ -1347,7 +1348,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, NFP_NET_CFG_RX_OFFSET_ADDR);
+		hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET_ADDR);
 
 	hw->super.ctrl = 0;
 	hw->stride_rx = stride;
@@ -1389,7 +1390,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev,
 	rte_wmb();
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id),
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id),
 			NFP_NET_CFG_ICR_UNMASKED);
 	return 0;
 }
@@ -1410,7 +1411,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev,
 	rte_wmb();
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nn_cfg_writeb(hw, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX);
 
 	return 0;
 }
@@ -1457,7 +1458,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
 		/* If MSI-X auto-masking is used, clear the entry */
 		rte_intr_ack(pci_dev->intr_handle);
 	} else {
-		nn_cfg_writeb(hw, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX),
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(NFP_NET_IRQ_LSC_IDX),
 				NFP_NET_CFG_ICR_UNMASKED);
 	}
 }
@@ -1539,7 +1540,7 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev,
 	}
 
 	/* Writing to configuration space */
-	nn_cfg_writel(hw, NFP_NET_CFG_MTU, mtu);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_MTU, mtu);
 
 	hw->mtu = mtu;
 
@@ -1630,7 +1631,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 
 		/* If all 4 entries were set, don't need read RETA register */
 		if (mask != 0xF)
-			reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + i);
+			reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + i);
 
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
@@ -1643,7 +1644,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 			reta |= reta_conf[idx].reta[shift + j] << (8 * j);
 		}
 
-		nn_cfg_writel(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
 	}
 
 	return 0;
@@ -1713,7 +1714,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 		if (mask == 0)
 			continue;
 
-		reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
+		reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
 				continue;
@@ -1741,7 +1742,7 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	/* Writing the key byte by byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
 		memcpy(&key, &rss_conf->rss_key[i], 1);
-		nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY + i, key);
+		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY + i, key);
 	}
 
 	rss_hf = rss_conf->rss_hf;
@@ -1774,10 +1775,10 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
-	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
 
 	/* Writing the key size */
-	nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
 
 	return 0;
 }
@@ -1835,7 +1836,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
-	cfg_rss_ctrl = nn_cfg_readl(hw, NFP_NET_CFG_RSS_CTRL);
+	cfg_rss_ctrl = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_CTRL);
 
 	if ((cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4) != 0)
 		rss_hf |= RTE_ETH_RSS_IPV4;
@@ -1865,11 +1866,11 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	rss_conf->rss_hf = rss_hf;
 
 	/* Reading the key size */
-	rss_conf->rss_key_len = nn_cfg_readl(hw, NFP_NET_CFG_RSS_KEY_SZ);
+	rss_conf->rss_key_len = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_KEY_SZ);
 
 	/* Reading the key byte a byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
-		key = nn_cfg_readb(hw, NFP_NET_CFG_RSS_KEY + i);
+		key = nn_cfg_readb(&hw->super, NFP_NET_CFG_RSS_KEY + i);
 		memcpy(&rss_conf->rss_key[i], &key, 1);
 	}
 
@@ -1983,13 +1984,13 @@ nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
 	hw->vxlan_ports[idx] = port;
 
 	for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) {
-		nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
+		nn_cfg_writel(&hw->super, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
 				(hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]);
 	}
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
+	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
 	rte_wmb();
 
 	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN);
@@ -2048,7 +2049,7 @@ nfp_net_cfg_read_version(struct nfp_net_hw *hw)
 		struct nfp_net_fw_ver split;
 	} version;
 
-	version.whole = nn_cfg_readl(hw, NFP_NET_CFG_VERSION);
+	version.whole = nn_cfg_readl(&hw->super, NFP_NET_CFG_VERSION);
 	hw->ver = version.split;
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 3fb3b34613..3fe3e96107 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -247,63 +247,63 @@ nn_writeq(uint64_t val,
 }
 
 static inline uint8_t
-nn_cfg_readb(struct nfp_net_hw *hw,
+nn_cfg_readb(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return nn_readb(hw->super.ctrl_bar + off);
+	return nn_readb(hw->ctrl_bar + off);
 }
 
 static inline void
-nn_cfg_writeb(struct nfp_net_hw *hw,
+nn_cfg_writeb(struct nfp_hw *hw,
 		uint32_t off,
 		uint8_t val)
 {
-	nn_writeb(val, hw->super.ctrl_bar + off);
+	nn_writeb(val, hw->ctrl_bar + off);
 }
 
 static inline uint16_t
-nn_cfg_readw(struct nfp_net_hw *hw,
+nn_cfg_readw(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_16(nn_readw(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writew(struct nfp_net_hw *hw,
+nn_cfg_writew(struct nfp_hw *hw,
 		uint32_t off,
 		uint16_t val)
 {
-	nn_writew(rte_cpu_to_le_16(val), hw->super.ctrl_bar + off);
+	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
 }
 
 static inline uint32_t
-nn_cfg_readl(struct nfp_net_hw *hw,
+nn_cfg_readl(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_32(nn_readl(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writel(struct nfp_net_hw *hw,
+nn_cfg_writel(struct nfp_hw *hw,
 		uint32_t off,
 		uint32_t val)
 {
-	nn_writel(rte_cpu_to_le_32(val), hw->super.ctrl_bar + off);
+	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
 }
 
 static inline uint64_t
-nn_cfg_readq(struct nfp_net_hw *hw,
+nn_cfg_readq(struct nfp_hw *hw,
 		uint32_t off)
 {
-	return rte_le_to_cpu_64(nn_readq(hw->super.ctrl_bar + off));
+	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
 }
 
 static inline void
-nn_cfg_writeq(struct nfp_net_hw *hw,
+nn_cfg_writeq(struct nfp_hw *hw,
 		uint32_t off,
 		uint64_t val)
 {
-	nn_writeq(rte_cpu_to_le_64(val), hw->super.ctrl_bar + off);
+	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
 }
 
 /**
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index a9dd464a6a..f17cc13cc1 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -925,8 +925,8 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
 	 * Telling the HW about the physical address of the RX ring and number
 	 * of descriptors in log2 format.
 	 */
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
-	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
+	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma);
+	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc));
 
 	return 0;
 }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 10/24] net/nfp: change parameter of reconfig
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (8 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 09/24] net/nfp: change parameter of functions Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 11/24] net/nfp: extract MAC address data field Chaoyong He
                         ` (14 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'reconfig_lock' data field into the super class, also change
the parameter of the related APIs, 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 |  50 +++++----
 drivers/net/nfp/nfp_ethdev.c        |  34 +++---
 drivers/net/nfp/nfp_ethdev_vf.c     |  20 ++--
 drivers/net/nfp/nfp_net_common.c    | 161 +++++++++++++++-------------
 drivers/net/nfp/nfp_net_common.h    |   7 +-
 5 files changed, 149 insertions(+), 123 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index ccb579541b..831f4a7265 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -52,27 +52,29 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
 {
 	uint32_t update;
 	uint32_t new_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	net_hw = repr->app_fw_flower->pf_hw;
+	hw = &net_hw->super;
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if (hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG)
+	if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) < 0)
 		return;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 }
 
 int
@@ -80,13 +82,15 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	net_hw = repr->app_fw_flower->pf_hw;
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_pf_repr_disable_queues(dev);
@@ -97,11 +101,11 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	update |= NFP_NET_CFG_UPDATE_RSS;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS2) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS2;
 	else
 		new_ctrl |= NFP_NET_CFG_CTRL_RSS;
@@ -111,19 +115,19 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
 
 	/* If an error when reconfig we avoid to change hw state */
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to reconfig PF vnic");
 		return -EIO;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
@@ -374,7 +378,7 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw,
 			vnic_type, hw->max_rx_queues, hw->max_tx_queues);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	return 0;
 }
@@ -690,14 +694,16 @@ nfp_flower_cleanup_ctrl_vnic(struct nfp_net_hw *hw)
 }
 
 static int
-nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
+nfp_flower_start_ctrl_vnic(struct nfp_net_hw *net_hw)
 {
 	int ret;
 	uint32_t update;
 	uint32_t new_ctrl;
+	struct nfp_hw *hw;
 	struct rte_eth_dev *dev;
 
-	dev = hw->eth_dev;
+	dev = net_hw->eth_dev;
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_net_disable_queues(dev);
@@ -706,7 +712,7 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 	nfp_net_enable_queues(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	new_ctrl = NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING |
@@ -715,13 +721,13 @@ nfp_flower_start_ctrl_vnic(struct nfp_net_hw *hw)
 	rte_wmb();
 
 	/* If an error when reconfig we avoid to change hw state */
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Failed to reconfig ctrl vnic");
 		return -EIO;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	/* Setup the freelist ring */
 	ret = nfp_net_rx_freelist_setup(dev);
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index a773a81e55..1378545d22 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -45,12 +45,13 @@ nfp_net_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	uint32_t cap_extend;
 	uint32_t intr_vector;
-	struct nfp_net_hw *hw;
 	uint32_t ctrl_extend = 0;
+	struct nfp_net_hw *net_hw;
 	struct nfp_pf_dev *pf_dev;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
@@ -58,9 +59,10 @@ 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;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv);
+	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
 	nfp_net_disable_queues(dev);
@@ -100,9 +102,9 @@ nfp_net_start(struct rte_eth_dev *dev)
 	}
 
 	/* Checking MTU set */
-	if (dev->data->mtu > hw->flbufsz) {
+	if (dev->data->mtu > net_hw->flbufsz) {
 		PMD_INIT_LOG(ERR, "MTU (%u) can't be larger than the current NFP_FRAME_SIZE (%u)",
-				dev->data->mtu, hw->flbufsz);
+				dev->data->mtu, net_hw->flbufsz);
 		return -ERANGE;
 	}
 
@@ -111,7 +113,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	nfp_net_params_setup(hw);
+	nfp_net_params_setup(net_hw);
 
 	dev_conf = &dev->data->dev_conf;
 	rxmode = &dev_conf->rxmode;
@@ -119,7 +121,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
 	}
 
 	/* Enable device */
@@ -128,19 +130,19 @@ nfp_net_start(struct rte_eth_dev *dev)
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
 	/* Enable vxlan */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
+	if ((hw->cap & NFP_NET_CFG_CTRL_VXLAN) != 0) {
 		new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
 		update |= NFP_NET_CFG_UPDATE_VXLAN;
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/* Enable packet type offload by extend ctrl word1. */
-	cap_extend = hw->super.cap_ext;
+	cap_extend = hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
 		ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
 
@@ -149,10 +151,10 @@ nfp_net_start(struct rte_eth_dev *dev)
 				| NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
-	if (nfp_net_ext_reconfig(hw, ctrl_extend, update) != 0)
+	if (nfp_ext_reconfig(hw, ctrl_extend, update) != 0)
 		return -EIO;
 
-	hw->super.ctrl_ext = ctrl_extend;
+	hw->ctrl_ext = ctrl_extend;
 
 	/*
 	 * Allocating rte mbufs for configured rx queues.
@@ -165,11 +167,11 @@ nfp_net_start(struct rte_eth_dev *dev)
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		/* Configure the physical port up */
-		nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 1);
+		nfp_eth_set_configured(net_hw->cpp, net_hw->nfp_idx, 1);
 	else
-		nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 1);
+		nfp_eth_set_configured(dev->process_private, net_hw->nfp_idx, 1);
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
@@ -587,7 +589,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 7fb2a3d378..6ead7e02b8 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -32,10 +32,11 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint16_t i;
+	struct nfp_hw *hw;
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	uint32_t intr_vector;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct rte_eth_conf *dev_conf;
 	struct rte_eth_rxmode *rxmode;
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
@@ -77,8 +78,9 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	new_ctrl = nfp_check_offloads(dev);
 
 	/* Writing configuration parameters in the device */
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	nfp_net_params_setup(hw);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+	nfp_net_params_setup(net_hw);
 
 	dev_conf = &dev->data->dev_conf;
 	rxmode = &dev_conf->rxmode;
@@ -86,7 +88,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) {
 		nfp_net_rss_config_default(dev);
 		update |= NFP_NET_CFG_UPDATE_RSS;
-		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->super.cap);
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
 	}
 
 	/* Enable device */
@@ -94,11 +96,11 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, new_ctrl);
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl);
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return -EIO;
 
 	/*
@@ -110,7 +112,7 @@ nfp_netvf_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
@@ -320,7 +322,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->reconfig_lock);
+	rte_spinlock_init(&hw->super.reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 2ab8d8fadd..9e6d2fa490 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -199,7 +199,7 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 #define FW_VER_LEN        32
 
 static int
-__nfp_net_reconfig(struct nfp_net_hw *hw,
+nfp_reconfig_real(struct nfp_hw *hw,
 		uint32_t update)
 {
 	uint32_t cnt;
@@ -207,14 +207,14 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 	struct timespec wait;
 
 	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->super.qcp_cfg);
+			hw->qcp_cfg);
 
-	if (hw->super.qcp_cfg == NULL) {
+	if (hw->qcp_cfg == NULL) {
 		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
 		return -ENXIO;
 	}
 
-	nfp_qcp_ptr_add(hw->super.qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
 
 	wait.tv_sec = 0;
 	wait.tv_nsec = 1000000; /* 1ms */
@@ -223,7 +223,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	/* Poll update field, waiting for NFP to ack the config */
 	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(&hw->super, NFP_NET_CFG_UPDATE);
+		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
 		if (new == 0)
 			break;
 
@@ -263,7 +263,7 @@ __nfp_net_reconfig(struct nfp_net_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure the device.
  */
 int
-nfp_net_reconfig(struct nfp_net_hw *hw,
+nfp_reconfig(struct nfp_hw *hw,
 		uint32_t ctrl,
 		uint32_t update)
 {
@@ -271,17 +271,17 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, update);
+	ret = nfp_reconfig_real(hw, update);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
 	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp net reconfig: ctrl=%#08x update=%#08x",
+		PMD_DRV_LOG(ERR, "Error nfp reconfig: ctrl=%#08x update=%#08x",
 				ctrl, update);
 		return -EIO;
 	}
@@ -307,7 +307,7 @@ nfp_net_reconfig(struct nfp_net_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure the device.
  */
 int
-nfp_net_ext_reconfig(struct nfp_net_hw *hw,
+nfp_ext_reconfig(struct nfp_hw *hw,
 		uint32_t ctrl_ext,
 		uint32_t update)
 {
@@ -315,17 +315,17 @@ nfp_net_ext_reconfig(struct nfp_net_hw *hw,
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, update);
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, update);
+	ret = nfp_reconfig_real(hw, update);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
 	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nft net ext reconfig: ctrl_ext=%#08x update=%#08x",
+		PMD_DRV_LOG(ERR, "Error nfp ext reconfig: ctrl_ext=%#08x update=%#08x",
 				ctrl_ext, update);
 		return -EIO;
 	}
@@ -354,16 +354,16 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 
 	mbox = hw->tlv_caps.mbox_off;
 
-	rte_spinlock_lock(&hw->reconfig_lock);
+	rte_spinlock_lock(&hw->super.reconfig_lock);
 
 	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
 	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_MBOX);
+	ret = nfp_reconfig_real(&hw->super, NFP_NET_CFG_UPDATE_MBOX);
 
-	rte_spinlock_unlock(&hw->reconfig_lock);
+	rte_spinlock_unlock(&hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net mailbox reconfig: mbox=%#08x update=%#08x",
@@ -494,26 +494,28 @@ nfp_net_disable_queues(struct rte_eth_dev *dev)
 {
 	uint32_t update;
 	uint32_t new_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
 	update = NFP_NET_CFG_UPDATE_GEN |
 			NFP_NET_CFG_UPDATE_RING |
 			NFP_NET_CFG_UPDATE_MSIX;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
 		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
 	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_net_reconfig(hw, new_ctrl, update) != 0)
+	if (nfp_reconfig(hw, new_ctrl, update) != 0)
 		return;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 }
 
 void
@@ -551,26 +553,28 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 {
 	uint32_t ctrl;
 	uint32_t update;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) {
 		PMD_DRV_LOG(ERR, "MAC address unable to change when port enabled");
 		return -EBUSY;
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
+	nfp_net_write_mac(net_hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
-	ctrl = hw->super.ctrl;
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
-			(hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
+	ctrl = hw->ctrl;
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 &&
+			(hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_LIVE_ADDR;
 
 	/* Signal the NIC about the change */
-	if (nfp_net_reconfig(hw, ctrl, update) != 0) {
+	if (nfp_reconfig(hw, ctrl, update) != 0) {
 		PMD_DRV_LOG(ERR, "MAC address update failed");
 		return -EIO;
 	}
@@ -689,36 +693,38 @@ int
 nfp_net_promisc_enable(struct rte_eth_dev *dev)
 {
 	int ret;
+	uint32_t update;
 	uint32_t new_ctrl;
-	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_flower_representor *repr;
 
 	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
 		repr = dev->data->dev_private;
-		hw = repr->app_fw_flower->pf_hw;
+		net_hw = repr->app_fw_flower->pf_hw;
 	} else {
-		hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+		net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	hw = &net_hw->super;
+	if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(ERR, "Promiscuous mode not supported");
 		return -ENOTSUP;
 	}
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) != 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already enabled");
 		return 0;
 	}
 
-	new_ctrl = hw->super.ctrl | NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->ctrl | NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -727,25 +733,27 @@ int
 nfp_net_promisc_disable(struct rte_eth_dev *dev)
 {
 	int ret;
+	uint32_t update;
 	uint32_t new_ctrl;
-	uint32_t update = 0;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) {
 		PMD_DRV_LOG(INFO, "Promiscuous mode already disabled");
 		return 0;
 	}
 
-	new_ctrl = hw->super.ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_PROMISC;
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1554,17 +1562,20 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 	int ret;
 	uint32_t update;
 	uint32_t new_ctrl;
+	struct nfp_hw *hw;
 	uint64_t rx_offload;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint32_t rxvlan_ctrl = 0;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
 	rx_offload = dev->data->dev_conf.rxmode.offloads;
-	new_ctrl = hw->super.ctrl;
+	new_ctrl = hw->ctrl;
 
 	/* VLAN stripping setting */
 	if ((mask & RTE_ETH_VLAN_STRIP_MASK) != 0) {
-		nfp_net_enable_rxvlan_cap(hw, &rxvlan_ctrl);
+		nfp_net_enable_rxvlan_cap(net_hw, &rxvlan_ctrl);
 		if ((rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) != 0)
 			new_ctrl |= rxvlan_ctrl;
 		else
@@ -1579,16 +1590,16 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev,
 			new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
-	if (new_ctrl == hw->super.ctrl)
+	if (new_ctrl == hw->ctrl)
 		return 0;
 
 	update = NFP_NET_CFG_UPDATE_GEN;
 
-	ret = nfp_net_reconfig(hw, new_ctrl, update);
+	ret = nfp_reconfig(hw, new_ctrl, update);
 	if (ret != 0)
 		return ret;
 
-	hw->super.ctrl = new_ctrl;
+	hw->ctrl = new_ctrl;
 
 	return 0;
 }
@@ -1658,10 +1669,13 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 {
 	int ret;
 	uint32_t update;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	ret = nfp_net_rss_reta_write(dev, reta_conf, reta_size);
@@ -1670,7 +1684,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
+	if (nfp_reconfig(hw, hw->ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1789,14 +1803,16 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 {
 	uint32_t update;
 	uint64_t rss_hf;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	rss_hf = rss_conf->rss_hf;
 
 	/* Checking if RSS is enabled */
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) {
 		if (rss_hf != 0) {
 			PMD_DRV_LOG(ERR, "RSS unsupported");
 			return -EINVAL;
@@ -1814,7 +1830,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev,
 
 	update = NFP_NET_CFG_UPDATE_RSS;
 
-	if (nfp_net_reconfig(hw, hw->super.ctrl, update) != 0)
+	if (nfp_reconfig(hw, hw->ctrl, update) != 0)
 		return -EIO;
 
 	return 0;
@@ -1969,31 +1985,32 @@ nfp_net_close_tx_queue(struct rte_eth_dev *dev)
 }
 
 int
-nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
+nfp_net_set_vxlan_port(struct nfp_net_hw *net_hw,
 		size_t idx,
 		uint16_t port)
 {
 	int ret;
 	uint32_t i;
+	struct nfp_hw *hw = &net_hw->super;
 
 	if (idx >= NFP_NET_N_VXLAN_PORTS) {
 		PMD_DRV_LOG(ERR, "The idx value is out of range.");
 		return -ERANGE;
 	}
 
-	hw->vxlan_ports[idx] = port;
+	net_hw->vxlan_ports[idx] = port;
 
 	for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) {
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
-				(hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]);
+		nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
+				(net_hw->vxlan_ports[i + 1] << 16) | net_hw->vxlan_ports[i]);
 	}
 
 	rte_spinlock_lock(&hw->reconfig_lock);
 
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
 	rte_wmb();
 
-	ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN);
+	ret = nfp_reconfig_real(hw, NFP_NET_CFG_UPDATE_VXLAN);
 
 	rte_spinlock_unlock(&hw->reconfig_lock);
 
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 3fe3e96107..d418cd2b99 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -119,6 +119,7 @@ struct nfp_hw {
 	uint32_t cap_ext;
 	uint32_t ctrl;
 	uint32_t ctrl_ext;
+	rte_spinlock_t reconfig_lock;
 };
 
 struct nfp_net_hw {
@@ -150,8 +151,6 @@ struct nfp_net_hw {
 	uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
 	uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
 
-	rte_spinlock_t reconfig_lock;
-
 	uint32_t max_tx_queues;
 	uint32_t max_rx_queues;
 	uint16_t flbufsz;
@@ -368,8 +367,8 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 }
 
 /* Prototypes for common NFP functions */
-int nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update);
-int nfp_net_ext_reconfig(struct nfp_net_hw *hw, uint32_t ctrl_ext, uint32_t update);
+int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
+int nfp_ext_reconfig(struct nfp_hw *hw, uint32_t ctrl_ext, uint32_t update);
 int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
 int nfp_net_configure(struct rte_eth_dev *dev);
 int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 11/24] net/nfp: extract MAC address data field
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (9 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 10/24] net/nfp: change parameter of reconfig Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 12/24] net/nfp: rename parameter in related logic Chaoyong He
                         ` (13 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Extract the 'mac_addr' 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/nfp_ethdev.c     | 14 +++++++-------
 drivers/net/nfp/nfp_ethdev_vf.c  | 18 +++++++++---------
 drivers/net/nfp/nfp_net_common.c |  8 ++++----
 drivers/net/nfp/nfp_net_common.h |  5 ++---
 4 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 1378545d22..a93742a205 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -33,7 +33,7 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic,
 
 	nfp_eth_table = nfp_eth_read_ports(app_fw_nic->pf_dev->cpp);
 
-	rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->mac_addr);
+	rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->super.mac_addr);
 
 	free(nfp_eth_table);
 
@@ -599,18 +599,18 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+	nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 
-	tmp_ether_addr = &hw->mac_addr;
+	tmp_ether_addr = &hw->super.mac_addr;
 	if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
 
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -621,7 +621,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			eth_dev->data->port_id, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
 
 	/* Registering LSC interrupt handler */
 	rte_intr_callback_register(pci_dev->intr_handle,
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 6ead7e02b8..dead6ca5ab 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -16,14 +16,14 @@
 #include "nfp_net_common.h"
 
 static void
-nfp_netvf_read_mac(struct nfp_net_hw *hw)
+nfp_netvf_read_mac(struct nfp_hw *hw)
 {
 	uint32_t tmp;
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
 	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
 
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR + 4));
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
 	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
 }
 
@@ -332,16 +332,16 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(hw);
-	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
+	nfp_netvf_read_mac(&hw->super);
+	if (rte_is_valid_assigned_ether_addr(&hw->super.mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
 
 	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -352,7 +352,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			port, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		/* Registering LSC interrupt handler */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 9e6d2fa490..a760fcf0d2 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -532,19 +532,19 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 }
 
 void
-nfp_net_write_mac(struct nfp_net_hw *hw,
+nfp_net_write_mac(struct nfp_hw *hw,
 		uint8_t *mac)
 {
 	uint32_t mac0;
 	uint16_t mac1;
 
 	mac0 = *(uint32_t *)mac;
-	nn_writel(rte_cpu_to_be_32(mac0), hw->super.ctrl_bar + NFP_NET_CFG_MACADDR);
+	nn_writel(rte_cpu_to_be_32(mac0), hw->ctrl_bar + NFP_NET_CFG_MACADDR);
 
 	mac += 4;
 	mac1 = *(uint16_t *)mac;
 	nn_writew(rte_cpu_to_be_16(mac1),
-			hw->super.ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
 }
 
 int
@@ -565,7 +565,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(net_hw, (uint8_t *)mac_addr);
+	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index d418cd2b99..e997756091 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -120,6 +120,7 @@ struct nfp_hw {
 	uint32_t ctrl;
 	uint32_t ctrl_ext;
 	rte_spinlock_t reconfig_lock;
+	struct rte_ether_addr mac_addr;
 };
 
 struct nfp_net_hw {
@@ -159,8 +160,6 @@ struct nfp_net_hw {
 	uint16_t subsystem_device_id;
 	uint16_t subsystem_vendor_id;
 
-	struct rte_ether_addr mac_addr;
-
 	/** Records starting point for counters */
 	struct rte_eth_stats eth_stats_base;
 	struct rte_eth_xstat *eth_xstats_base;
@@ -376,7 +375,7 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac);
+void nfp_net_write_mac(struct nfp_hw *hw, uint8_t *mac);
 int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 		struct rte_intr_handle *intr_handle);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 12/24] net/nfp: rename parameter in related logic
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (10 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 11/24] net/nfp: extract MAC address data field Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 13/24] common/nfp: add common ctrl module Chaoyong He
                         ` (12 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Rename parameter 'hw' into 'net_hw' in the related logic, to make the
name more accurate.

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        |  86 +++++++++++------------
 drivers/net/nfp/nfp_ethdev_vf.c     |  62 +++++++++--------
 drivers/net/nfp/nfp_ipsec.c         |  82 +++++++++++-----------
 drivers/net/nfp/nfp_net_common.c    | 102 ++++++++++++++++------------
 drivers/net/nfp/nfp_net_ctrl.c      |  14 ++--
 drivers/net/nfp/nfp_rxtx.c          |  16 ++---
 7 files changed, 193 insertions(+), 177 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 831f4a7265..f3fedbf7e5 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -25,18 +25,18 @@ static void
 nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 {
 	uint16_t i;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
 	uint64_t enabled_queues = 0;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
-	hw = repr->app_fw_flower->pf_hw;
+	hw = &repr->app_fw_flower->pf_hw->super;
 
 	/* Enabling the required TX queues in the device */
 	for (i = 0; i < dev->data->nb_tx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
 
 	enabled_queues = 0;
 
@@ -44,7 +44,7 @@ nfp_pf_repr_enable_queues(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_rx_queues; i++)
 		enabled_queues |= (1 << i);
 
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
 }
 
 static void
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index a93742a205..3d4b78fbf1 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -479,11 +479,11 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	uint16_t port;
 	uint64_t rx_base;
 	uint64_t tx_base;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_pf_dev *pf_dev;
 	struct rte_pci_device *pci_dev;
 	struct nfp_app_fw_nic *app_fw_nic;
-	struct rte_ether_addr *tmp_ether_addr;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 
@@ -503,46 +503,47 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	 * Use PF array of physical ports to get pointer to
 	 * this specific port.
 	 */
-	hw = app_fw_nic->ports[port];
+	net_hw = app_fw_nic->ports[port];
+	hw = &net_hw->super;
 
 	PMD_INIT_LOG(DEBUG, "Working with physical port number: %hu, "
-			"NFP internal port number: %d", port, hw->nfp_idx);
+			"NFP internal port number: %d", port, net_hw->nfp_idx);
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-	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");
+	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;
 
-		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);
-		if (hw->mac_stats_bar == NULL) {
+		hw->ctrl_bar = pf_dev->ctrl_bar;
+		min_size = NFP_MAC_STATS_SIZE * net_hw->pf_dev->nfp_eth_table->max_index;
+		net_hw->mac_stats_bar = nfp_rtsym_map(net_hw->pf_dev->sym_tbl, "_mac_stats",
+				min_size, &net_hw->mac_stats_area);
+		if (net_hw->mac_stats_bar == NULL) {
 			PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for _mac_stats_bar");
 			return -EIO;
 		}
 
-		hw->mac_stats = hw->mac_stats_bar;
+		net_hw->mac_stats = net_hw->mac_stats_bar;
 	} else {
 		if (pf_dev->ctrl_bar == NULL)
 			return -ENODEV;
 
 		/* Use port offset in pf ctrl_bar for this ports control bar */
-		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);
+		hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ);
+		net_hw->mac_stats = app_fw_nic->ports[0]->mac_stats_bar +
+				(net_hw->nfp_idx * NFP_MAC_STATS_SIZE);
 	}
 
-	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->super.ctrl_bar);
-	PMD_INIT_LOG(DEBUG, "MAC stats: %p", hw->mac_stats);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "MAC stats: %p", net_hw->mac_stats);
 
-	err = nfp_net_common_init(pci_dev, hw);
+	err = nfp_net_common_init(pci_dev, net_hw);
 	if (err != 0)
 		return err;
 
@@ -558,38 +559,38 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 		return err;
 	}
 
-	nfp_net_ethdev_ops_mount(hw, eth_dev);
+	nfp_net_ethdev_ops_mount(net_hw, eth_dev);
 
-	hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *
+	net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat", sizeof(struct rte_eth_xstat) *
 			nfp_net_xstats_size(eth_dev), 0);
-	if (hw->eth_xstats_base == NULL) {
+	if (net_hw->eth_xstats_base == NULL) {
 		PMD_INIT_LOG(ERR, "no memory for xstats base values on device %s!",
 				pci_dev->device.name);
 		return -ENOMEM;
 	}
 
 	/* Work out where in the BAR the queues start. */
-	tx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
-	rx_base = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
+	tx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
+	rx_base = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
 
-	hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
-	hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
-	eth_dev->data->dev_private = hw;
+	net_hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
+	net_hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
+	eth_dev->data->dev_private = net_hw;
 
 	PMD_INIT_LOG(DEBUG, "ctrl_bar: %p, tx_bar: %p, rx_bar: %p",
-			hw->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->ctrl_bar, net_hw->tx_bar, net_hw->rx_bar);
 
-	nfp_net_cfg_queue_setup(hw);
-	hw->mtu = RTE_ETHER_MTU;
+	nfp_net_cfg_queue_setup(net_hw);
+	net_hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
-	nfp_net_log_device_information(hw);
+	nfp_net_log_device_information(net_hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->super.reconfig_lock);
+	rte_spinlock_init(&hw->reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
@@ -599,20 +600,19 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 
-	tmp_ether_addr = &hw->super.mac_addr;
-	if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) {
+	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
@@ -621,13 +621,13 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			eth_dev->data->port_id, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
 
 	/* Registering LSC interrupt handler */
 	rte_intr_callback_register(pci_dev->intr_handle,
 			nfp_net_dev_interrupt_handler, (void *)eth_dev);
 	/* Telling the firmware about the LSC interrupt entry */
-	nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 	/* Recording current stats counters values */
 	nfp_net_stats_reset(eth_dev);
 
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index dead6ca5ab..049728d30c 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -254,7 +254,8 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	int err;
 	uint16_t port;
 	uint32_t start_q;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint64_t tx_bar_off = 0;
 	uint64_t rx_bar_off = 0;
 	struct rte_pci_device *pci_dev;
@@ -269,22 +270,23 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		return -ENODEV;
 	}
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	hw->dev_info = dev_info;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw->dev_info = dev_info;
+	hw = &net_hw->super;
 
-	hw->super.ctrl_bar = pci_dev->mem_resource[0].addr;
-	if (hw->super.ctrl_bar == NULL) {
+	hw->ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->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->super.ctrl_bar);
+	PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
 
-	err = nfp_net_common_init(pci_dev, hw);
+	err = nfp_net_common_init(pci_dev, net_hw);
 	if (err != 0)
 		return err;
 
-	nfp_netvf_ethdev_ops_mount(hw, eth_dev);
+	nfp_netvf_ethdev_ops_mount(net_hw, eth_dev);
 
 	/* For secondary processes, the primary has done all the work */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -292,37 +294,37 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
-	hw->eth_xstats_base = rte_malloc("rte_eth_xstat",
+	net_hw->eth_xstats_base = rte_malloc("rte_eth_xstat",
 			sizeof(struct rte_eth_xstat) * nfp_net_xstats_size(eth_dev), 0);
-	if (hw->eth_xstats_base == NULL) {
+	if (net_hw->eth_xstats_base == NULL) {
 		PMD_INIT_LOG(ERR, "No memory for xstats base values on device %s!",
 				pci_dev->device.name);
 		return -ENOMEM;
 	}
 
 	/* Work out where in the BAR the queues start. */
-	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_TXQ);
+	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_TXQ);
 	tx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
-	start_q = nn_cfg_readl(&hw->super, NFP_NET_CFG_START_RXQ);
+	start_q = nn_cfg_readl(hw, NFP_NET_CFG_START_RXQ);
 	rx_bar_off = nfp_qcp_queue_offset(dev_info, start_q);
 
-	hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
-	hw->rx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + rx_bar_off;
+	net_hw->tx_bar = (uint8_t *)pci_dev->mem_resource[2].addr + tx_bar_off;
+	net_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->super.ctrl_bar, hw->tx_bar, hw->rx_bar);
+			hw->ctrl_bar, net_hw->tx_bar, net_hw->rx_bar);
 
-	nfp_net_cfg_queue_setup(hw);
-	hw->mtu = RTE_ETHER_MTU;
+	nfp_net_cfg_queue_setup(net_hw);
+	net_hw->mtu = RTE_ETHER_MTU;
 
 	/* VLAN insertion is incompatible with LSOv2 */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO2) != 0)
-		hw->super.cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
+	if ((hw->cap & NFP_NET_CFG_CTRL_LSO2) != 0)
+		hw->cap &= ~NFP_NET_CFG_CTRL_TXVLAN;
 
-	nfp_net_log_device_information(hw);
+	nfp_net_log_device_information(net_hw);
 
 	/* Initializing spinlock for reconfigs */
-	rte_spinlock_init(&hw->super.reconfig_lock);
+	rte_spinlock_init(&hw->reconfig_lock);
 
 	/* Allocating memory for mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc("mac_addr", RTE_ETHER_ADDR_LEN, 0);
@@ -332,18 +334,18 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(&hw->super);
-	if (rte_is_valid_assigned_ether_addr(&hw->super.mac_addr) == 0) {
+	nfp_netvf_read_mac(hw);
+	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
-		rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
+		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
-	rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
+	rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
+	if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
@@ -352,14 +354,14 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 			"mac=" RTE_ETHER_ADDR_PRT_FMT,
 			port, pci_dev->id.vendor_id,
 			pci_dev->id.device_id,
-			RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
+			RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		/* Registering LSC interrupt handler */
 		rte_intr_callback_register(pci_dev->intr_handle,
 				nfp_net_dev_interrupt_handler, (void *)eth_dev);
 		/* Telling the firmware about the LSC interrupt entry */
-		nn_cfg_writeb(&hw->super, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
+		nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 		/* Recording current stats counters values */
 		nfp_net_stats_reset(eth_dev);
 	}
@@ -367,7 +369,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	return 0;
 
 dev_err_ctrl_map:
-		nfp_cpp_area_free(hw->ctrl_area);
+		nfp_cpp_area_free(net_hw->ctrl_area);
 
 	return err;
 }
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index 0da5c2a3d2..7e26977dc1 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -434,7 +434,7 @@ enum nfp_ipsec_df_type {
 };
 
 static int
-nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
+nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *net_hw,
 		struct nfp_ipsec_msg *msg)
 {
 	int ret;
@@ -445,9 +445,9 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	msg->rsp = NFP_IPSEC_CFG_MSG_OK;
 
 	for (i = 0; i < msg_size; i++)
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
+		nn_cfg_writel(&net_hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i, msg->raw[i]);
 
-	ret = nfp_net_mbox_reconfig(hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
+	ret = nfp_net_mbox_reconfig(net_hw, NFP_NET_CFG_MBOX_CMD_IPSEC);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to IPsec reconfig mbox");
 		return ret;
@@ -459,7 +459,7 @@ nfp_ipsec_cfg_cmd_issue(struct nfp_net_hw *hw,
 	 * response. One example where the data is needed is for statistics.
 	 */
 	for (i = 0; i < msg_size; i++)
-		msg->raw[i] = nn_cfg_readl(&hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
+		msg->raw[i] = nn_cfg_readl(&net_hw->super, NFP_NET_CFG_MBOX_VAL + 4 * i);
 
 	switch (msg->rsp) {
 	case NFP_IPSEC_CFG_MSG_OK:
@@ -577,10 +577,10 @@ nfp_aead_map(struct rte_eth_dev *eth_dev,
 	uint32_t device_id;
 	const char *iv_str;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 	offset = 0;
 
 	switch (aead->algo) {
@@ -665,10 +665,10 @@ nfp_cipher_map(struct rte_eth_dev *eth_dev,
 	uint32_t i;
 	uint32_t device_id;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 
 	switch (cipher->algo) {
 	case RTE_CRYPTO_CIPHER_NULL:
@@ -801,15 +801,15 @@ nfp_auth_map(struct rte_eth_dev *eth_dev,
 	uint8_t key_length;
 	uint32_t device_id;
 	const uint32_t *key;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
 	if (digest_length == 0) {
 		PMD_DRV_LOG(ERR, "Auth digest length is illegal!");
 		return -EINVAL;
 	}
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
-	device_id = hw->device_id;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	device_id = net_hw->device_id;
 	digest_length = digest_length << 3;
 
 	switch (auth->algo) {
@@ -1068,7 +1068,7 @@ nfp_crypto_create_session(void *device,
 {
 	int ret;
 	int sa_idx;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg msg;
 	struct rte_eth_dev *eth_dev;
 	struct nfp_ipsec_session *priv_session;
@@ -1082,14 +1082,14 @@ nfp_crypto_create_session(void *device,
 	sa_idx = -1;
 	eth_dev = device;
 	priv_session = SECURITY_GET_SESS_PRIV(session);
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-	if (hw->ipsec_data->sa_free_cnt == 0) {
+	if (net_hw->ipsec_data->sa_free_cnt == 0) {
 		PMD_DRV_LOG(ERR, "No space in SA table, spi: %d", conf->ipsec.spi);
 		return -EINVAL;
 	}
 
-	nfp_get_sa_entry(hw->ipsec_data, &sa_idx);
+	nfp_get_sa_entry(net_hw->ipsec_data, &sa_idx);
 
 	if (sa_idx < 0) {
 		PMD_DRV_LOG(ERR, "Failed to get SA entry!");
@@ -1105,7 +1105,7 @@ nfp_crypto_create_session(void *device,
 
 	msg.cmd = NFP_IPSEC_CFG_MSG_ADD_SA;
 	msg.sa_idx = sa_idx;
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &msg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to add SA to nic");
 		return -EINVAL;
@@ -1118,8 +1118,8 @@ nfp_crypto_create_session(void *device,
 	priv_session->dev = eth_dev;
 	priv_session->user_data = conf->userdata;
 
-	hw->ipsec_data->sa_free_cnt--;
-	hw->ipsec_data->sa_entries[sa_idx] = priv_session;
+	net_hw->ipsec_data->sa_free_cnt--;
+	net_hw->ipsec_data->sa_entries[sa_idx] = priv_session;
 
 	return 0;
 }
@@ -1156,19 +1156,19 @@ nfp_security_set_pkt_metadata(void *device,
 {
 	int offset;
 	uint64_t *sqn;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct rte_eth_dev *eth_dev;
 	struct nfp_ipsec_session *priv_session;
 
 	sqn = params;
 	eth_dev = device;
 	priv_session = SECURITY_GET_SESS_PRIV(session);
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
 	if (priv_session->ipsec.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
 		struct nfp_tx_ipsec_desc_msg *desc_md;
 
-		offset = hw->ipsec_data->pkt_dynfield_offset;
+		offset = net_hw->ipsec_data->pkt_dynfield_offset;
 		desc_md = RTE_MBUF_DYNFIELD(m, offset, struct nfp_tx_ipsec_desc_msg *);
 
 		if (priv_session->msg.ctrl_word.ext_seq != 0 && sqn != NULL) {
@@ -1223,7 +1223,7 @@ nfp_security_session_get_stats(void *device,
 		struct rte_security_stats *stats)
 {
 	int ret;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg msg;
 	struct rte_eth_dev *eth_dev;
 	struct ipsec_get_sa_stats *cfg_s;
@@ -1236,9 +1236,9 @@ nfp_security_session_get_stats(void *device,
 	memset(&msg, 0, sizeof(msg));
 	msg.cmd = NFP_IPSEC_CFG_MSG_GET_SA_STATS;
 	msg.sa_idx = priv_session->sa_index;
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &msg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to get SA stats");
 		return ret;
@@ -1284,22 +1284,22 @@ nfp_crypto_remove_sa(struct rte_eth_dev *eth_dev,
 {
 	int ret;
 	uint32_t sa_index;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_msg cfg;
 
 	sa_index = priv_session->sa_index;
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 
 	cfg.cmd = NFP_IPSEC_CFG_MSG_INV_SA;
 	cfg.sa_idx = sa_index;
-	ret = nfp_ipsec_cfg_cmd_issue(hw, &cfg);
+	ret = nfp_ipsec_cfg_cmd_issue(net_hw, &cfg);
 	if (ret < 0) {
 		PMD_DRV_LOG(ERR, "Failed to remove SA!");
 		return -EINVAL;
 	}
 
-	hw->ipsec_data->sa_free_cnt++;
-	hw->ipsec_data->sa_entries[sa_index] = NULL;
+	net_hw->ipsec_data->sa_free_cnt++;
+	net_hw->ipsec_data->sa_entries[sa_index] = NULL;
 
 	return 0;
 }
@@ -1377,12 +1377,12 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 {
 	int ret;
 	uint32_t cap_extend;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_net_ipsec_data *data;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->super.cap_ext;
+	cap_extend = net_hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return 0;
@@ -1396,7 +1396,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 
 	data->pkt_dynfield_offset = -1;
 	data->sa_free_cnt = NFP_NET_IPSEC_MAX_SA_CNT;
-	hw->ipsec_data = data;
+	net_hw->ipsec_data = data;
 
 	ret = nfp_ipsec_ctx_create(dev, data);
 	if (ret != 0) {
@@ -1424,12 +1424,12 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 {
 	uint16_t i;
 	uint32_t cap_extend;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_ipsec_session *priv_session;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = hw->super.cap_ext;
+	cap_extend = net_hw->super.cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return;
@@ -1437,17 +1437,17 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 
 	nfp_ipsec_ctx_destroy(dev);
 
-	if (hw->ipsec_data == NULL) {
+	if (net_hw->ipsec_data == NULL) {
 		PMD_INIT_LOG(INFO, "IPsec data is NULL!");
 		return;
 	}
 
 	for (i = 0; i < NFP_NET_IPSEC_MAX_SA_CNT; i++) {
-		priv_session = hw->ipsec_data->sa_entries[i];
+		priv_session = net_hw->ipsec_data->sa_entries[i];
 		if (priv_session != NULL)
 			memset(priv_session, 0, sizeof(struct nfp_ipsec_session));
 	}
 
-	rte_free(hw->ipsec_data);
+	rte_free(net_hw->ipsec_data);
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index a760fcf0d2..01574de963 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -336,7 +336,7 @@ nfp_ext_reconfig(struct nfp_hw *hw,
 /**
  * Reconfigure the firmware via the mailbox
  *
- * @param hw
+ * @param net_hw
  *   Device to reconfigure
  * @param mbox_cmd
  *   The value for the mailbox command
@@ -346,24 +346,24 @@ nfp_ext_reconfig(struct nfp_hw *hw,
  *   - (-EIO) if I/O err and fail to reconfigure by the mailbox
  */
 int
-nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
+nfp_net_mbox_reconfig(struct nfp_net_hw *net_hw,
 		uint32_t mbox_cmd)
 {
 	int ret;
 	uint32_t mbox;
 
-	mbox = hw->tlv_caps.mbox_off;
+	mbox = net_hw->tlv_caps.mbox_off;
 
-	rte_spinlock_lock(&hw->super.reconfig_lock);
+	rte_spinlock_lock(&net_hw->super.reconfig_lock);
 
-	nn_cfg_writeq(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
+	nn_cfg_writeq(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
+	nn_cfg_writel(&net_hw->super, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_MBOX);
 
 	rte_wmb();
 
-	ret = nfp_reconfig_real(&hw->super, NFP_NET_CFG_UPDATE_MBOX);
+	ret = nfp_reconfig_real(&net_hw->super, NFP_NET_CFG_UPDATE_MBOX);
 
-	rte_spinlock_unlock(&hw->super.reconfig_lock);
+	rte_spinlock_unlock(&net_hw->super.reconfig_lock);
 
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Error nft net mailbox reconfig: mbox=%#08x update=%#08x",
@@ -371,7 +371,7 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *hw,
 		return -EIO;
 	}
 
-	return nn_cfg_readl(&hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
+	return nn_cfg_readl(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET);
 }
 
 /*
@@ -625,6 +625,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 uint32_t
 nfp_check_offloads(struct rte_eth_dev *dev)
 {
+	uint32_t cap;
 	uint32_t ctrl = 0;
 	uint64_t rx_offload;
 	uint64_t tx_offload;
@@ -632,13 +633,14 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	struct rte_eth_conf *dev_conf;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	cap = hw->super.cap;
 
 	dev_conf = &dev->data->dev_conf;
 	rx_offload = dev_conf->rxmode.offloads;
 	tx_offload = dev_conf->txmode.offloads;
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXCSUM;
 	}
 
@@ -646,25 +648,25 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 		nfp_net_enable_rxvlan_cap(hw, &ctrl);
 
 	if ((rx_offload & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
 	}
 
 	hw->mtu = dev->data->mtu;
 
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2;
-		else if ((hw->super.cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
+		else if ((cap & NFP_NET_CFG_CTRL_TXVLAN) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
 	}
 
 	/* L2 broadcast */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2BC) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_L2BC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2BC;
 
 	/* L2 multicast */
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_L2MC) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_L2MC) != 0)
 		ctrl |= NFP_NET_CFG_CTRL_L2MC;
 
 	/* TX checksum offload */
@@ -676,7 +678,7 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	/* LSO offload */
 	if ((tx_offload & RTE_ETH_TX_OFFLOAD_TCP_TSO) != 0 ||
 			(tx_offload & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) != 0) {
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_LSO) != 0)
 			ctrl |= NFP_NET_CFG_CTRL_LSO;
 		else
 			ctrl |= NFP_NET_CFG_CTRL_LSO2;
@@ -1194,6 +1196,7 @@ nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
 int
 nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
+	uint32_t cap;
 	uint32_t cap_extend;
 	uint16_t min_rx_desc;
 	uint16_t max_rx_desc;
@@ -1224,32 +1227,34 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
-	if ((hw->super.cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
+	cap = hw->super.cap;
+
+	if ((cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) != 0)
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_RXQINQ) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_RXCSUM) != 0)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->super.cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
+	if ((cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2)) != 0)
 		dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_TXCSUM) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
 				RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
 				RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
+	if ((cap & NFP_NET_CFG_CTRL_LSO_ANY) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
-		if ((hw->super.cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
+		if ((cap & NFP_NET_CFG_CTRL_VXLAN) != 0)
 			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
 	}
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_GATHER) != 0)
+	if ((cap & NFP_NET_CFG_CTRL_GATHER) != 0)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
 	cap_extend = hw->super.cap_ext;
@@ -1292,7 +1297,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		.nb_mtu_seg_max = NFP_TX_MAX_MTU_SEG,
 	};
 
-	if ((hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+	if ((cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 
 		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
@@ -1615,9 +1620,11 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 	uint8_t mask;
 	uint32_t reta;
 	uint16_t shift;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
 		PMD_DRV_LOG(ERR, "The size of hash lookup table configured (%hu)"
@@ -1642,7 +1649,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 
 		/* If all 4 entries were set, don't need read RETA register */
 		if (mask != 0xF)
-			reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + i);
+			reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + i);
 
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
@@ -1655,7 +1662,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev,
 			reta |= reta_conf[idx].reta[shift + j] << (8 * j);
 		}
 
-		nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
+		nn_cfg_writel(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift, reta);
 	}
 
 	return 0;
@@ -1702,10 +1709,13 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 	uint8_t mask;
 	uint32_t reta;
 	uint16_t shift;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) {
@@ -1728,7 +1738,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev,
 		if (mask == 0)
 			continue;
 
-		reta = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
+		reta = nn_cfg_readl(hw, NFP_NET_CFG_RSS_ITBL + (idx * 64) + shift);
 		for (j = 0; j < 4; j++) {
 			if ((mask & (0x1 << j)) == 0)
 				continue;
@@ -1748,15 +1758,17 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	uint8_t i;
 	uint8_t key;
 	uint64_t rss_hf;
-	struct nfp_net_hw *hw;
+	struct nfp_hw *hw;
+	struct nfp_net_hw *net_hw;
 	uint32_t cfg_rss_ctrl = 0;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
 	/* Writing the key byte by byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
 		memcpy(&key, &rss_conf->rss_key[i], 1);
-		nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY + i, key);
+		nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY + i, key);
 	}
 
 	rss_hf = rss_conf->rss_hf;
@@ -1789,10 +1801,10 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
-	nn_cfg_writel(&hw->super, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
 
 	/* Writing the key size */
-	nn_cfg_writeb(&hw->super, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
+	nn_cfg_writeb(hw, NFP_NET_CFG_RSS_KEY_SZ, rss_conf->rss_key_len);
 
 	return 0;
 }
@@ -1843,16 +1855,18 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	uint8_t i;
 	uint8_t key;
 	uint64_t rss_hf;
+	struct nfp_hw *hw;
 	uint32_t cfg_rss_ctrl;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	hw = &net_hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
 		return -EINVAL;
 
 	rss_hf = rss_conf->rss_hf;
-	cfg_rss_ctrl = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_CTRL);
+	cfg_rss_ctrl = nn_cfg_readl(hw, NFP_NET_CFG_RSS_CTRL);
 
 	if ((cfg_rss_ctrl & NFP_NET_CFG_RSS_IPV4) != 0)
 		rss_hf |= RTE_ETH_RSS_IPV4;
@@ -1882,11 +1896,11 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
 	rss_conf->rss_hf = rss_hf;
 
 	/* Reading the key size */
-	rss_conf->rss_key_len = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_KEY_SZ);
+	rss_conf->rss_key_len = nn_cfg_readl(hw, NFP_NET_CFG_RSS_KEY_SZ);
 
 	/* Reading the key byte a byte */
 	for (i = 0; i < rss_conf->rss_key_len; i++) {
-		key = nn_cfg_readb(&hw->super, NFP_NET_CFG_RSS_KEY + i);
+		key = nn_cfg_readb(hw, NFP_NET_CFG_RSS_KEY + i);
 		memcpy(&rss_conf->rss_key[i], &key, 1);
 	}
 
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index d469896a64..8848fa38fe 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -29,15 +29,15 @@ nfp_net_tlv_caps_parse(struct rte_eth_dev *dev)
 	uint32_t length;
 	uint32_t offset;
 	uint32_t tlv_type;
-	struct nfp_net_hw *hw;
+	struct nfp_net_hw *net_hw;
 	struct nfp_net_tlv_caps *caps;
 
-	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	caps = &hw->tlv_caps;
+	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	caps = &net_hw->tlv_caps;
 	nfp_net_tlv_caps_reset(caps);
 
-	data = hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
-	end = hw->super.ctrl_bar + NFP_NET_CFG_BAR_SZ;
+	data = net_hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
+	end = net_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->super.ctrl_bar;
+		offset = data - net_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->super.ctrl_bar;
+				caps->mbox_off = data - net_hw->super.ctrl_bar;
 			else
 				caps->mbox_off = 0;
 			break;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index f17cc13cc1..fc94e5f0b9 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -336,10 +336,10 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 		struct nfp_net_rxq *rxq,
 		struct rte_mbuf *mb)
 {
-	struct nfp_net_hw *hw = rxq->hw;
+	uint32_t ctrl = rxq->hw->super.ctrl;
 
-	/* Skip if firmware don't support setting vlan. */
-	if ((hw->super.ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
+	/* Skip if hardware don't support setting vlan. */
+	if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
 	/*
@@ -347,12 +347,12 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	 * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
 	 * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
 	 */
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+	if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
 		if (meta->vlan_layer > 0 && meta->vlan[0].offload != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
 		}
-	} else if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+	} else if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
 		if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
 			mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.offload_info);
 			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
@@ -383,10 +383,10 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
 		struct nfp_net_rxq *rxq,
 		struct rte_mbuf *mb)
 {
-	struct nfp_net_hw *hw = rxq->hw;
+	struct nfp_hw *hw = &rxq->hw->super;
 
-	if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
-			(hw->super.cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
 		return;
 
 	if (meta->vlan_layer < NFP_META_MAX_VLANS)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 13/24] common/nfp: add common ctrl module
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (11 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 12/24] net/nfp: rename parameter in related logic Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 14/24] common/nfp: add common module Chaoyong He
                         ` (11 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the common ctrl module.

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/common/nfp/nfp_common_ctrl.h | 374 +++++++++++++++++++++++++++
 drivers/net/nfp/nfp_net_ctrl.h       | 365 +-------------------------
 2 files changed, 375 insertions(+), 364 deletions(-)
 create mode 100644 drivers/common/nfp/nfp_common_ctrl.h

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
new file mode 100644
index 0000000000..3c8cd916cf
--- /dev/null
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -0,0 +1,374 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_CTRL_H__
+#define __NFP_COMMON_CTRL_H__
+
+/*
+ * Configuration BAR size.
+ *
+ * On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
+ */
+#define NFP_NET_CFG_BAR_SZ              (32 * 1024)
+
+/* Offset in Freelist buffer where packet starts on RX */
+#define NFP_NET_RX_OFFSET               32
+
+/* Working with metadata api (NFD version > 3.0) */
+#define NFP_NET_META_FIELD_SIZE         4
+#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
+#define NFP_NET_META_HEADER_SIZE        4
+#define NFP_NET_META_NFDK_LENGTH        8
+
+/* Working with metadata vlan api (NFD version >= 2.0) */
+#define NFP_NET_META_VLAN_INFO          16
+#define NFP_NET_META_VLAN_OFFLOAD       31
+#define NFP_NET_META_VLAN_TPID          3
+#define NFP_NET_META_VLAN_MASK          ((1 << NFP_NET_META_VLAN_INFO) - 1)
+#define NFP_NET_META_VLAN_TPID_MASK     ((1 << NFP_NET_META_VLAN_TPID) - 1)
+#define NFP_NET_META_TPID(d)            (((d) >> NFP_NET_META_VLAN_INFO) & \
+						NFP_NET_META_VLAN_TPID_MASK)
+
+/* Prepend field types */
+#define NFP_NET_META_HASH               1 /* Next field carries hash type */
+#define NFP_NET_META_VLAN               4
+#define NFP_NET_META_PORTID             5
+#define NFP_NET_META_IPSEC              9
+
+#define NFP_META_PORT_ID_CTRL           ~0U
+
+/* Hash type prepended when a RSS hash was computed */
+#define NFP_NET_RSS_NONE                0
+#define NFP_NET_RSS_IPV4                1
+#define NFP_NET_RSS_IPV6                2
+#define NFP_NET_RSS_IPV6_EX             3
+#define NFP_NET_RSS_IPV4_TCP            4
+#define NFP_NET_RSS_IPV6_TCP            5
+#define NFP_NET_RSS_IPV6_EX_TCP         6
+#define NFP_NET_RSS_IPV4_UDP            7
+#define NFP_NET_RSS_IPV6_UDP            8
+#define NFP_NET_RSS_IPV6_EX_UDP         9
+#define NFP_NET_RSS_IPV4_SCTP           10
+#define NFP_NET_RSS_IPV6_SCTP           11
+
+/*
+ * @NFP_NET_TXR_MAX:         Maximum number of TX rings
+ * @NFP_NET_TXR_MASK:        Mask for TX rings
+ * @NFP_NET_RXR_MAX:         Maximum number of RX rings
+ * @NFP_NET_RXR_MASK:        Mask for RX rings
+ */
+#define NFP_NET_TXR_MAX                 64
+#define NFP_NET_TXR_MASK                (NFP_NET_TXR_MAX - 1)
+#define NFP_NET_RXR_MAX                 64
+#define NFP_NET_RXR_MASK                (NFP_NET_RXR_MAX - 1)
+
+/*
+ * Read/Write config words (0x0000 - 0x002c)
+ * @NFP_NET_CFG_CTRL:        Global control
+ * @NFP_NET_CFG_UPDATE:      Indicate which fields are updated
+ * @NFP_NET_CFG_TXRS_ENABLE: Bitmask of enabled TX rings
+ * @NFP_NET_CFG_RXRS_ENABLE: Bitmask of enabled RX rings
+ * @NFP_NET_CFG_MTU:         Set MTU size
+ * @NFP_NET_CFG_FLBUFSZ:     Set freelist buffer size (must be larger than MTU)
+ * @NFP_NET_CFG_EXN:         MSI-X table entry for exceptions
+ * @NFP_NET_CFG_LSC:         MSI-X table entry for link state changes
+ * @NFP_NET_CFG_MACADDR:     MAC address
+ *
+ * TODO:
+ * - define Error details in UPDATE
+ */
+#define NFP_NET_CFG_CTRL                0x0000
+#define   NFP_NET_CFG_CTRL_ENABLE         (0x1 <<  0) /* Global enable */
+#define   NFP_NET_CFG_CTRL_PROMISC        (0x1 <<  1) /* Enable Promisc mode */
+#define   NFP_NET_CFG_CTRL_L2BC           (0x1 <<  2) /* Allow L2 Broadcast */
+#define   NFP_NET_CFG_CTRL_L2MC           (0x1 <<  3) /* Allow L2 Multicast */
+#define   NFP_NET_CFG_CTRL_RXCSUM         (0x1 <<  4) /* Enable RX Checksum */
+#define   NFP_NET_CFG_CTRL_TXCSUM         (0x1 <<  5) /* Enable TX Checksum */
+#define   NFP_NET_CFG_CTRL_RXVLAN         (0x1 <<  6) /* Enable VLAN strip */
+#define   NFP_NET_CFG_CTRL_TXVLAN         (0x1 <<  7) /* Enable VLAN insert */
+#define   NFP_NET_CFG_CTRL_SCATTER        (0x1 <<  8) /* Scatter DMA */
+#define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
+#define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
+#define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
+#define   NFP_NET_CFG_CTRL_RXVLAN_V2      (0x1 << 15) /* Enable VLAN strip with metadata */
+#define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
+#define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
+#define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
+#define   NFP_NET_CFG_CTRL_RINGPRIO       (0x1 << 19) /* Ring priorities */
+#define   NFP_NET_CFG_CTRL_MSIXAUTO       (0x1 << 20) /* MSI-X auto-masking */
+#define   NFP_NET_CFG_CTRL_TXRWB          (0x1 << 21) /* Write-back of TX ring */
+#define   NFP_NET_CFG_CTRL_L2SWITCH       (0x1 << 22) /* L2 Switch */
+#define   NFP_NET_CFG_CTRL_TXVLAN_V2      (0x1 << 23) /* Enable VLAN insert with metadata */
+#define   NFP_NET_CFG_CTRL_VXLAN          (0x1 << 24) /* Enable VXLAN */
+#define   NFP_NET_CFG_CTRL_NVGRE          (0x1 << 25) /* Enable NVGRE */
+#define   NFP_NET_CFG_CTRL_MSIX_TX_OFF    (0x1 << 26) /* Disable MSIX for TX */
+#define   NFP_NET_CFG_CTRL_LSO2           (0x1 << 28) /* LSO/TSO (version 2) */
+#define   NFP_NET_CFG_CTRL_RSS2           (0x1 << 29) /* RSS (version 2) */
+#define   NFP_NET_CFG_CTRL_CSUM_COMPLETE  (0x1 << 30) /* Checksum complete */
+#define   NFP_NET_CFG_CTRL_LIVE_ADDR      (0x1U << 31) /* Live MAC addr change */
+#define NFP_NET_CFG_UPDATE              0x0004
+#define   NFP_NET_CFG_UPDATE_GEN          (0x1 <<  0) /* General update */
+#define   NFP_NET_CFG_UPDATE_RING         (0x1 <<  1) /* Ring config change */
+#define   NFP_NET_CFG_UPDATE_RSS          (0x1 <<  2) /* RSS config change */
+#define   NFP_NET_CFG_UPDATE_TXRPRIO      (0x1 <<  3) /* TX Ring prio change */
+#define   NFP_NET_CFG_UPDATE_RXRPRIO      (0x1 <<  4) /* RX Ring prio change */
+#define   NFP_NET_CFG_UPDATE_MSIX         (0x1 <<  5) /* MSI-X change */
+#define   NFP_NET_CFG_UPDATE_L2SWITCH     (0x1 <<  6) /* Switch changes */
+#define   NFP_NET_CFG_UPDATE_RESET        (0x1 <<  7) /* Update due to FLR */
+#define   NFP_NET_CFG_UPDATE_IRQMOD       (0x1 <<  8) /* IRQ mod change */
+#define   NFP_NET_CFG_UPDATE_VXLAN        (0x1 <<  9) /* VXLAN port change */
+#define   NFP_NET_CFG_UPDATE_MACADDR      (0x1 << 11) /* MAC address change */
+#define   NFP_NET_CFG_UPDATE_MBOX         (0x1 << 12) /* Mailbox update */
+#define   NFP_NET_CFG_UPDATE_ERR          (0x1U << 31) /* A error occurred */
+#define NFP_NET_CFG_TXRS_ENABLE         0x0008
+#define NFP_NET_CFG_RXRS_ENABLE         0x0010
+#define NFP_NET_CFG_MTU                 0x0018
+#define NFP_NET_CFG_FLBUFSZ             0x001c
+#define NFP_NET_CFG_EXN                 0x001f
+#define NFP_NET_CFG_LSC                 0x0020
+#define NFP_NET_CFG_MACADDR             0x0024
+
+#define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2)
+#define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2)
+
+#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \
+					NFP_NET_CFG_CTRL_CSUM_COMPLETE)
+
+/* Version number helper defines */
+struct nfp_net_fw_ver {
+	uint8_t minor;
+	uint8_t major;
+	uint8_t class;
+	/**
+	 * This byte can be extended for more use.
+	 * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx
+	 * BIT[7:1]: reserved
+	 */
+	uint8_t extend;
+};
+
+/*
+ * Read-only words (0x0030 - 0x0050):
+ * @NFP_NET_CFG_VERSION:     Firmware version number
+ * @NFP_NET_CFG_STS:         Status
+ * @NFP_NET_CFG_CAP:         Capabilities (same bits as @NFP_NET_CFG_CTRL)
+ * @NFP_NET_MAX_TXRINGS:     Maximum number of TX rings
+ * @NFP_NET_MAX_RXRINGS:     Maximum number of RX rings
+ * @NFP_NET_MAX_MTU:         Maximum support MTU
+ * @NFP_NET_CFG_START_TXQ:   Start Queue Control Queue to use for TX (PF only)
+ * @NFP_NET_CFG_START_RXQ:   Start Queue Control Queue to use for RX (PF only)
+ *
+ * TODO:
+ * - define more STS bits
+ */
+#define NFP_NET_CFG_VERSION             0x0030
+#define   NFP_NET_CFG_VERSION_DP_NFD3   0
+#define   NFP_NET_CFG_VERSION_DP_NFDK   1
+#define NFP_NET_CFG_STS                 0x0034
+#define   NFP_NET_CFG_STS_LINK            (0x1 << 0) /* Link up or down */
+/* Link rate */
+#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
+#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
+#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
+#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN       1
+#define   NFP_NET_CFG_STS_LINK_RATE_1G            2
+#define   NFP_NET_CFG_STS_LINK_RATE_10G           3
+#define   NFP_NET_CFG_STS_LINK_RATE_25G           4
+#define   NFP_NET_CFG_STS_LINK_RATE_40G           5
+#define   NFP_NET_CFG_STS_LINK_RATE_50G           6
+#define   NFP_NET_CFG_STS_LINK_RATE_100G          7
+
+/*
+ * NSP Link rate is a 16-bit word. It is no longer determined by
+ * firmware, instead it is read from the nfp_eth_table of the
+ * associated pf_dev and written to the NFP_NET_CFG_STS_NSP_LINK_RATE
+ * address by the PMD each time the port is reconfigured.
+ */
+#define NFP_NET_CFG_STS_NSP_LINK_RATE   0x0036
+
+#define NFP_NET_CFG_CAP                 0x0038
+#define NFP_NET_CFG_MAX_TXRINGS         0x003c
+#define NFP_NET_CFG_MAX_RXRINGS         0x0040
+#define NFP_NET_CFG_MAX_MTU             0x0044
+/* Next two words are being used by VFs for solving THB350 issue */
+#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
+ */
+#define NFP_NET_CFG_RX_OFFSET           0x0050
+#define NFP_NET_CFG_RX_OFFSET_DYNAMIC          0    /* Prepend mode */
+
+/* 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
+
+/* Offload definitions */
+#define NFP_NET_N_VXLAN_PORTS  (NFP_NET_CFG_VXLAN_SZ / sizeof(uint16_t))
+
+/*
+ * 3 words reserved for extended ctrl words (0x0098 - 0x00a4)
+ * 3 words reserved for extended cap words (0x00a4 - 0x00b0)
+ * Currently only one word is used, can be extended in future.
+ */
+#define NFP_NET_CFG_CTRL_WORD1          0x0098
+#define NFP_NET_CFG_CTRL_PKT_TYPE         (0x1 << 0)
+#define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
+#define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
+#define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
+
+#define NFP_NET_CFG_CAP_WORD1           0x00a4
+
+/* 16B reserved for future use (0x00b0 - 0x00c0). */
+#define NFP_NET_CFG_RESERVED            0x00b0
+#define NFP_NET_CFG_RESERVED_SZ         0x0010
+
+/*
+ * RSS configuration (0x0100 - 0x01ac):
+ * Used only when NFP_NET_CFG_CTRL_RSS_ANY is enabled
+ * @NFP_NET_CFG_RSS_CFG:     RSS configuration word
+ * @NFP_NET_CFG_RSS_KEY:     RSS "secret" key
+ * @NFP_NET_CFG_RSS_ITBL:    RSS indirection table
+ */
+#define NFP_NET_CFG_RSS_BASE            0x0100
+#define NFP_NET_CFG_RSS_CTRL            NFP_NET_CFG_RSS_BASE
+#define   NFP_NET_CFG_RSS_MASK            (0x7f)
+#define   NFP_NET_CFG_RSS_MASK_of(_x)     ((_x) & 0x7f)
+#define   NFP_NET_CFG_RSS_IPV4            (1 <<  8) /* RSS for IPv4 */
+#define   NFP_NET_CFG_RSS_IPV6            (1 <<  9) /* RSS for IPv6 */
+#define   NFP_NET_CFG_RSS_IPV4_TCP        (1 << 10) /* RSS for IPv4/TCP */
+#define   NFP_NET_CFG_RSS_IPV4_UDP        (1 << 11) /* RSS for IPv4/UDP */
+#define   NFP_NET_CFG_RSS_IPV6_TCP        (1 << 12) /* RSS for IPv6/TCP */
+#define   NFP_NET_CFG_RSS_IPV6_UDP        (1 << 13) /* RSS for IPv6/UDP */
+#define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
+#define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
+#define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
+#define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
+#define NFP_NET_CFG_RSS_KEY_SZ          0x28
+#define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
+					 NFP_NET_CFG_RSS_KEY_SZ)
+#define NFP_NET_CFG_RSS_ITBL_SZ         0x80
+
+/*
+ * TX ring configuration (0x200 - 0x800)
+ * @NFP_NET_CFG_TXR_BASE:    Base offset for TX ring configuration
+ * @NFP_NET_CFG_TXR_ADDR:    Per TX ring DMA address (8B entries)
+ * @NFP_NET_CFG_TXR_WB_ADDR: Per TX ring write back DMA address (8B entries)
+ * @NFP_NET_CFG_TXR_SZ:      Per TX ring size (1B entries)
+ * @NFP_NET_CFG_TXR_VEC:     Per TX ring MSI-X table entry (1B entries)
+ * @NFP_NET_CFG_TXR_PRIO:    Per TX ring priority (1B entries)
+ * @NFP_NET_CFG_TXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
+ */
+#define NFP_NET_CFG_TXR_BASE            0x0200
+#define NFP_NET_CFG_TXR_ADDR(_x)        (NFP_NET_CFG_TXR_BASE + ((_x) * 0x8))
+#define NFP_NET_CFG_TXR_WB_ADDR(_x)     (NFP_NET_CFG_TXR_BASE + 0x200 + \
+					 ((_x) * 0x8))
+#define NFP_NET_CFG_TXR_SZ(_x)          (NFP_NET_CFG_TXR_BASE + 0x400 + (_x))
+#define NFP_NET_CFG_TXR_VEC(_x)         (NFP_NET_CFG_TXR_BASE + 0x440 + (_x))
+#define NFP_NET_CFG_TXR_PRIO(_x)        (NFP_NET_CFG_TXR_BASE + 0x480 + (_x))
+#define NFP_NET_CFG_TXR_IRQ_MOD(_x)     (NFP_NET_CFG_TXR_BASE + 0x500 + \
+					 ((_x) * 0x4))
+
+/*
+ * RX ring configuration (0x0800 - 0x0c00)
+ * @NFP_NET_CFG_RXR_BASE:    Base offset for RX ring configuration
+ * @NFP_NET_CFG_RXR_ADDR:    Per TX ring DMA address (8B entries)
+ * @NFP_NET_CFG_RXR_SZ:      Per TX ring size (1B entries)
+ * @NFP_NET_CFG_RXR_VEC:     Per TX ring MSI-X table entry (1B entries)
+ * @NFP_NET_CFG_RXR_PRIO:    Per TX ring priority (1B entries)
+ * @NFP_NET_CFG_RXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
+ */
+#define NFP_NET_CFG_RXR_BASE            0x0800
+#define NFP_NET_CFG_RXR_ADDR(_x)        (NFP_NET_CFG_RXR_BASE + ((_x) * 0x8))
+#define NFP_NET_CFG_RXR_SZ(_x)          (NFP_NET_CFG_RXR_BASE + 0x200 + (_x))
+#define NFP_NET_CFG_RXR_VEC(_x)         (NFP_NET_CFG_RXR_BASE + 0x240 + (_x))
+#define NFP_NET_CFG_RXR_PRIO(_x)        (NFP_NET_CFG_RXR_BASE + 0x280 + (_x))
+#define NFP_NET_CFG_RXR_IRQ_MOD(_x)     (NFP_NET_CFG_RXR_BASE + 0x300 + \
+					 ((_x) * 0x4))
+
+/*
+ * Interrupt Control/Cause registers (0x0c00 - 0x0d00)
+ * These registers are only used when MSI-X auto-masking is not
+ * enabled (@NFP_NET_CFG_CTRL_MSIXAUTO not set).  The array is index
+ * by MSI-X entry and are 1B in size.  If an entry is zero, the
+ * corresponding entry is enabled.  If the FW generates an interrupt,
+ * it writes a cause into the corresponding field.  This also masks
+ * the MSI-X entry and the host driver must clear the register to
+ * re-enable the interrupt.
+ */
+#define NFP_NET_CFG_ICR_BASE            0x0c00
+#define NFP_NET_CFG_ICR(_x)             (NFP_NET_CFG_ICR_BASE + (_x))
+#define   NFP_NET_CFG_ICR_UNMASKED      0x0
+#define   NFP_NET_CFG_ICR_RXTX          0x1
+#define   NFP_NET_CFG_ICR_LSC           0x2
+
+/*
+ * General device stats (0x0d00 - 0x0d90)
+ * All counters are 64bit.
+ */
+#define NFP_NET_CFG_STATS_BASE          0x0d00
+#define NFP_NET_CFG_STATS_RX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x00)
+#define NFP_NET_CFG_STATS_RX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x08)
+#define NFP_NET_CFG_STATS_RX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x10)
+#define NFP_NET_CFG_STATS_RX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x18)
+#define NFP_NET_CFG_STATS_RX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x20)
+#define NFP_NET_CFG_STATS_RX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x28)
+#define NFP_NET_CFG_STATS_RX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x30)
+#define NFP_NET_CFG_STATS_RX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x38)
+#define NFP_NET_CFG_STATS_RX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x40)
+
+#define NFP_NET_CFG_STATS_TX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x48)
+#define NFP_NET_CFG_STATS_TX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x50)
+#define NFP_NET_CFG_STATS_TX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x58)
+#define NFP_NET_CFG_STATS_TX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x60)
+#define NFP_NET_CFG_STATS_TX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x68)
+#define NFP_NET_CFG_STATS_TX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x70)
+#define NFP_NET_CFG_STATS_TX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x78)
+#define NFP_NET_CFG_STATS_TX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x80)
+#define NFP_NET_CFG_STATS_TX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x88)
+
+#define NFP_NET_CFG_STATS_APP0_FRAMES   (NFP_NET_CFG_STATS_BASE + 0x90)
+#define NFP_NET_CFG_STATS_APP0_BYTES    (NFP_NET_CFG_STATS_BASE + 0x98)
+#define NFP_NET_CFG_STATS_APP1_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xa0)
+#define NFP_NET_CFG_STATS_APP1_BYTES    (NFP_NET_CFG_STATS_BASE + 0xa8)
+#define NFP_NET_CFG_STATS_APP2_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xb0)
+#define NFP_NET_CFG_STATS_APP2_BYTES    (NFP_NET_CFG_STATS_BASE + 0xb8)
+#define NFP_NET_CFG_STATS_APP3_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xc0)
+#define NFP_NET_CFG_STATS_APP3_BYTES    (NFP_NET_CFG_STATS_BASE + 0xc8)
+
+/*
+ * Per ring stats (0x1000 - 0x1800)
+ * Options, 64bit per entry
+ * @NFP_NET_CFG_TXR_STATS:   TX ring statistics (Packet and Byte count)
+ * @NFP_NET_CFG_RXR_STATS:   RX ring statistics (Packet and Byte count)
+ */
+#define NFP_NET_CFG_TXR_STATS_BASE      0x1000
+#define NFP_NET_CFG_TXR_STATS(_x)       (NFP_NET_CFG_TXR_STATS_BASE + \
+					 ((_x) * 0x10))
+#define NFP_NET_CFG_RXR_STATS_BASE      0x1400
+#define NFP_NET_CFG_RXR_STATS(_x)       (NFP_NET_CFG_RXR_STATS_BASE + \
+					 ((_x) * 0x10))
+
+#endif /* __NFP_COMMON_CTRL_H__ */
diff --git a/drivers/net/nfp/nfp_net_ctrl.h b/drivers/net/nfp/nfp_net_ctrl.h
index 3772b28a66..ee1b784bb1 100644
--- a/drivers/net/nfp/nfp_net_ctrl.h
+++ b/drivers/net/nfp/nfp_net_ctrl.h
@@ -10,370 +10,7 @@
 
 #include <ethdev_driver.h>
 
-/*
- * Configuration BAR size.
- *
- * On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
- */
-#define NFP_NET_CFG_BAR_SZ              (32 * 1024)
-
-/* Offset in Freelist buffer where packet starts on RX */
-#define NFP_NET_RX_OFFSET               32
-
-/* Working with metadata api (NFD version > 3.0) */
-#define NFP_NET_META_FIELD_SIZE         4
-#define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
-#define NFP_NET_META_HEADER_SIZE        4
-#define NFP_NET_META_NFDK_LENGTH        8
-
-/* Working with metadata vlan api (NFD version >= 2.0) */
-#define NFP_NET_META_VLAN_INFO          16
-#define NFP_NET_META_VLAN_OFFLOAD       31
-#define NFP_NET_META_VLAN_TPID          3
-#define NFP_NET_META_VLAN_MASK          ((1 << NFP_NET_META_VLAN_INFO) - 1)
-#define NFP_NET_META_VLAN_TPID_MASK     ((1 << NFP_NET_META_VLAN_TPID) - 1)
-#define NFP_NET_META_TPID(d)            (((d) >> NFP_NET_META_VLAN_INFO) & \
-						NFP_NET_META_VLAN_TPID_MASK)
-
-/* Prepend field types */
-#define NFP_NET_META_HASH               1 /* Next field carries hash type */
-#define NFP_NET_META_VLAN               4
-#define NFP_NET_META_PORTID             5
-#define NFP_NET_META_IPSEC              9
-
-#define NFP_META_PORT_ID_CTRL           ~0U
-
-/* Hash type prepended when a RSS hash was computed */
-#define NFP_NET_RSS_NONE                0
-#define NFP_NET_RSS_IPV4                1
-#define NFP_NET_RSS_IPV6                2
-#define NFP_NET_RSS_IPV6_EX             3
-#define NFP_NET_RSS_IPV4_TCP            4
-#define NFP_NET_RSS_IPV6_TCP            5
-#define NFP_NET_RSS_IPV6_EX_TCP         6
-#define NFP_NET_RSS_IPV4_UDP            7
-#define NFP_NET_RSS_IPV6_UDP            8
-#define NFP_NET_RSS_IPV6_EX_UDP         9
-#define NFP_NET_RSS_IPV4_SCTP           10
-#define NFP_NET_RSS_IPV6_SCTP           11
-
-/*
- * @NFP_NET_TXR_MAX:         Maximum number of TX rings
- * @NFP_NET_TXR_MASK:        Mask for TX rings
- * @NFP_NET_RXR_MAX:         Maximum number of RX rings
- * @NFP_NET_RXR_MASK:        Mask for RX rings
- */
-#define NFP_NET_TXR_MAX                 64
-#define NFP_NET_TXR_MASK                (NFP_NET_TXR_MAX - 1)
-#define NFP_NET_RXR_MAX                 64
-#define NFP_NET_RXR_MASK                (NFP_NET_RXR_MAX - 1)
-
-/*
- * Read/Write config words (0x0000 - 0x002c)
- * @NFP_NET_CFG_CTRL:        Global control
- * @NFP_NET_CFG_UPDATE:      Indicate which fields are updated
- * @NFP_NET_CFG_TXRS_ENABLE: Bitmask of enabled TX rings
- * @NFP_NET_CFG_RXRS_ENABLE: Bitmask of enabled RX rings
- * @NFP_NET_CFG_MTU:         Set MTU size
- * @NFP_NET_CFG_FLBUFSZ:     Set freelist buffer size (must be larger than MTU)
- * @NFP_NET_CFG_EXN:         MSI-X table entry for exceptions
- * @NFP_NET_CFG_LSC:         MSI-X table entry for link state changes
- * @NFP_NET_CFG_MACADDR:     MAC address
- *
- * TODO:
- * - define Error details in UPDATE
- */
-#define NFP_NET_CFG_CTRL                0x0000
-#define   NFP_NET_CFG_CTRL_ENABLE         (0x1 <<  0) /* Global enable */
-#define   NFP_NET_CFG_CTRL_PROMISC        (0x1 <<  1) /* Enable Promisc mode */
-#define   NFP_NET_CFG_CTRL_L2BC           (0x1 <<  2) /* Allow L2 Broadcast */
-#define   NFP_NET_CFG_CTRL_L2MC           (0x1 <<  3) /* Allow L2 Multicast */
-#define   NFP_NET_CFG_CTRL_RXCSUM         (0x1 <<  4) /* Enable RX Checksum */
-#define   NFP_NET_CFG_CTRL_TXCSUM         (0x1 <<  5) /* Enable TX Checksum */
-#define   NFP_NET_CFG_CTRL_RXVLAN         (0x1 <<  6) /* Enable VLAN strip */
-#define   NFP_NET_CFG_CTRL_TXVLAN         (0x1 <<  7) /* Enable VLAN insert */
-#define   NFP_NET_CFG_CTRL_SCATTER        (0x1 <<  8) /* Scatter DMA */
-#define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
-#define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
-#define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
-#define   NFP_NET_CFG_CTRL_RXVLAN_V2      (0x1 << 15) /* Enable VLAN strip with metadata */
-#define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
-#define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
-#define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
-#define   NFP_NET_CFG_CTRL_RINGPRIO       (0x1 << 19) /* Ring priorities */
-#define   NFP_NET_CFG_CTRL_MSIXAUTO       (0x1 << 20) /* MSI-X auto-masking */
-#define   NFP_NET_CFG_CTRL_TXRWB          (0x1 << 21) /* Write-back of TX ring */
-#define   NFP_NET_CFG_CTRL_L2SWITCH       (0x1 << 22) /* L2 Switch */
-#define   NFP_NET_CFG_CTRL_TXVLAN_V2      (0x1 << 23) /* Enable VLAN insert with metadata */
-#define   NFP_NET_CFG_CTRL_VXLAN          (0x1 << 24) /* Enable VXLAN */
-#define   NFP_NET_CFG_CTRL_NVGRE          (0x1 << 25) /* Enable NVGRE */
-#define   NFP_NET_CFG_CTRL_MSIX_TX_OFF    (0x1 << 26) /* Disable MSIX for TX */
-#define   NFP_NET_CFG_CTRL_LSO2           (0x1 << 28) /* LSO/TSO (version 2) */
-#define   NFP_NET_CFG_CTRL_RSS2           (0x1 << 29) /* RSS (version 2) */
-#define   NFP_NET_CFG_CTRL_CSUM_COMPLETE  (0x1 << 30) /* Checksum complete */
-#define   NFP_NET_CFG_CTRL_LIVE_ADDR      (0x1U << 31) /* Live MAC addr change */
-#define NFP_NET_CFG_UPDATE              0x0004
-#define   NFP_NET_CFG_UPDATE_GEN          (0x1 <<  0) /* General update */
-#define   NFP_NET_CFG_UPDATE_RING         (0x1 <<  1) /* Ring config change */
-#define   NFP_NET_CFG_UPDATE_RSS          (0x1 <<  2) /* RSS config change */
-#define   NFP_NET_CFG_UPDATE_TXRPRIO      (0x1 <<  3) /* TX Ring prio change */
-#define   NFP_NET_CFG_UPDATE_RXRPRIO      (0x1 <<  4) /* RX Ring prio change */
-#define   NFP_NET_CFG_UPDATE_MSIX         (0x1 <<  5) /* MSI-X change */
-#define   NFP_NET_CFG_UPDATE_L2SWITCH     (0x1 <<  6) /* Switch changes */
-#define   NFP_NET_CFG_UPDATE_RESET        (0x1 <<  7) /* Update due to FLR */
-#define   NFP_NET_CFG_UPDATE_IRQMOD       (0x1 <<  8) /* IRQ mod change */
-#define   NFP_NET_CFG_UPDATE_VXLAN        (0x1 <<  9) /* VXLAN port change */
-#define   NFP_NET_CFG_UPDATE_MACADDR      (0x1 << 11) /* MAC address change */
-#define   NFP_NET_CFG_UPDATE_MBOX         (0x1 << 12) /* Mailbox update */
-#define   NFP_NET_CFG_UPDATE_ERR          (0x1U << 31) /* A error occurred */
-#define NFP_NET_CFG_TXRS_ENABLE         0x0008
-#define NFP_NET_CFG_RXRS_ENABLE         0x0010
-#define NFP_NET_CFG_MTU                 0x0018
-#define NFP_NET_CFG_FLBUFSZ             0x001c
-#define NFP_NET_CFG_EXN                 0x001f
-#define NFP_NET_CFG_LSC                 0x0020
-#define NFP_NET_CFG_MACADDR             0x0024
-
-#define NFP_NET_CFG_CTRL_LSO_ANY (NFP_NET_CFG_CTRL_LSO | NFP_NET_CFG_CTRL_LSO2)
-#define NFP_NET_CFG_CTRL_RSS_ANY (NFP_NET_CFG_CTRL_RSS | NFP_NET_CFG_CTRL_RSS2)
-
-#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \
-					NFP_NET_CFG_CTRL_CSUM_COMPLETE)
-
-/* Version number helper defines */
-struct nfp_net_fw_ver {
-	uint8_t minor;
-	uint8_t major;
-	uint8_t class;
-	/**
-	 * This byte can be extended for more use.
-	 * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx
-	 * BIT[7:1]: reserved
-	 */
-	uint8_t extend;
-};
-
-/*
- * Read-only words (0x0030 - 0x0050):
- * @NFP_NET_CFG_VERSION:     Firmware version number
- * @NFP_NET_CFG_STS:         Status
- * @NFP_NET_CFG_CAP:         Capabilities (same bits as @NFP_NET_CFG_CTRL)
- * @NFP_NET_MAX_TXRINGS:     Maximum number of TX rings
- * @NFP_NET_MAX_RXRINGS:     Maximum number of RX rings
- * @NFP_NET_MAX_MTU:         Maximum support MTU
- * @NFP_NET_CFG_START_TXQ:   Start Queue Control Queue to use for TX (PF only)
- * @NFP_NET_CFG_START_RXQ:   Start Queue Control Queue to use for RX (PF only)
- *
- * TODO:
- * - define more STS bits
- */
-#define NFP_NET_CFG_VERSION             0x0030
-#define   NFP_NET_CFG_VERSION_DP_NFD3   0
-#define   NFP_NET_CFG_VERSION_DP_NFDK   1
-#define NFP_NET_CFG_STS                 0x0034
-#define   NFP_NET_CFG_STS_LINK            (0x1 << 0) /* Link up or down */
-/* Link rate */
-#define   NFP_NET_CFG_STS_LINK_RATE_SHIFT 1
-#define   NFP_NET_CFG_STS_LINK_RATE_MASK  0xF
-#define   NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED   0
-#define   NFP_NET_CFG_STS_LINK_RATE_UNKNOWN       1
-#define   NFP_NET_CFG_STS_LINK_RATE_1G            2
-#define   NFP_NET_CFG_STS_LINK_RATE_10G           3
-#define   NFP_NET_CFG_STS_LINK_RATE_25G           4
-#define   NFP_NET_CFG_STS_LINK_RATE_40G           5
-#define   NFP_NET_CFG_STS_LINK_RATE_50G           6
-#define   NFP_NET_CFG_STS_LINK_RATE_100G          7
-
-/*
- * NSP Link rate is a 16-bit word. It is no longer determined by
- * firmware, instead it is read from the nfp_eth_table of the
- * associated pf_dev and written to the NFP_NET_CFG_STS_NSP_LINK_RATE
- * address by the PMD each time the port is reconfigured.
- */
-#define NFP_NET_CFG_STS_NSP_LINK_RATE   0x0036
-
-#define NFP_NET_CFG_CAP                 0x0038
-#define NFP_NET_CFG_MAX_TXRINGS         0x003c
-#define NFP_NET_CFG_MAX_RXRINGS         0x0040
-#define NFP_NET_CFG_MAX_MTU             0x0044
-/* Next two words are being used by VFs for solving THB350 issue */
-#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
- */
-#define NFP_NET_CFG_RX_OFFSET           0x0050
-#define NFP_NET_CFG_RX_OFFSET_DYNAMIC          0    /* Prepend mode */
-
-/* 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
-
-/* Offload definitions */
-#define NFP_NET_N_VXLAN_PORTS  (NFP_NET_CFG_VXLAN_SZ / sizeof(uint16_t))
-
-/*
- * 3 words reserved for extended ctrl words (0x0098 - 0x00a4)
- * 3 words reserved for extended cap words (0x00a4 - 0x00b0)
- * Currently only one word is used, can be extended in future.
- */
-#define NFP_NET_CFG_CTRL_WORD1          0x0098
-#define NFP_NET_CFG_CTRL_PKT_TYPE         (0x1 << 0)
-#define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
-#define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
-#define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
-
-#define NFP_NET_CFG_CAP_WORD1           0x00a4
-
-/* 16B reserved for future use (0x00b0 - 0x00c0). */
-#define NFP_NET_CFG_RESERVED            0x00b0
-#define NFP_NET_CFG_RESERVED_SZ         0x0010
-
-/*
- * RSS configuration (0x0100 - 0x01ac):
- * Used only when NFP_NET_CFG_CTRL_RSS_ANY is enabled
- * @NFP_NET_CFG_RSS_CFG:     RSS configuration word
- * @NFP_NET_CFG_RSS_KEY:     RSS "secret" key
- * @NFP_NET_CFG_RSS_ITBL:    RSS indirection table
- */
-#define NFP_NET_CFG_RSS_BASE            0x0100
-#define NFP_NET_CFG_RSS_CTRL            NFP_NET_CFG_RSS_BASE
-#define   NFP_NET_CFG_RSS_MASK            (0x7f)
-#define   NFP_NET_CFG_RSS_MASK_of(_x)     ((_x) & 0x7f)
-#define   NFP_NET_CFG_RSS_IPV4            (1 <<  8) /* RSS for IPv4 */
-#define   NFP_NET_CFG_RSS_IPV6            (1 <<  9) /* RSS for IPv6 */
-#define   NFP_NET_CFG_RSS_IPV4_TCP        (1 << 10) /* RSS for IPv4/TCP */
-#define   NFP_NET_CFG_RSS_IPV4_UDP        (1 << 11) /* RSS for IPv4/UDP */
-#define   NFP_NET_CFG_RSS_IPV6_TCP        (1 << 12) /* RSS for IPv6/TCP */
-#define   NFP_NET_CFG_RSS_IPV6_UDP        (1 << 13) /* RSS for IPv6/UDP */
-#define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
-#define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
-#define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
-#define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
-#define NFP_NET_CFG_RSS_KEY_SZ          0x28
-#define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
-					 NFP_NET_CFG_RSS_KEY_SZ)
-#define NFP_NET_CFG_RSS_ITBL_SZ         0x80
-
-/*
- * TX ring configuration (0x200 - 0x800)
- * @NFP_NET_CFG_TXR_BASE:    Base offset for TX ring configuration
- * @NFP_NET_CFG_TXR_ADDR:    Per TX ring DMA address (8B entries)
- * @NFP_NET_CFG_TXR_WB_ADDR: Per TX ring write back DMA address (8B entries)
- * @NFP_NET_CFG_TXR_SZ:      Per TX ring size (1B entries)
- * @NFP_NET_CFG_TXR_VEC:     Per TX ring MSI-X table entry (1B entries)
- * @NFP_NET_CFG_TXR_PRIO:    Per TX ring priority (1B entries)
- * @NFP_NET_CFG_TXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
- */
-#define NFP_NET_CFG_TXR_BASE            0x0200
-#define NFP_NET_CFG_TXR_ADDR(_x)        (NFP_NET_CFG_TXR_BASE + ((_x) * 0x8))
-#define NFP_NET_CFG_TXR_WB_ADDR(_x)     (NFP_NET_CFG_TXR_BASE + 0x200 + \
-					 ((_x) * 0x8))
-#define NFP_NET_CFG_TXR_SZ(_x)          (NFP_NET_CFG_TXR_BASE + 0x400 + (_x))
-#define NFP_NET_CFG_TXR_VEC(_x)         (NFP_NET_CFG_TXR_BASE + 0x440 + (_x))
-#define NFP_NET_CFG_TXR_PRIO(_x)        (NFP_NET_CFG_TXR_BASE + 0x480 + (_x))
-#define NFP_NET_CFG_TXR_IRQ_MOD(_x)     (NFP_NET_CFG_TXR_BASE + 0x500 + \
-					 ((_x) * 0x4))
-
-/*
- * RX ring configuration (0x0800 - 0x0c00)
- * @NFP_NET_CFG_RXR_BASE:    Base offset for RX ring configuration
- * @NFP_NET_CFG_RXR_ADDR:    Per TX ring DMA address (8B entries)
- * @NFP_NET_CFG_RXR_SZ:      Per TX ring size (1B entries)
- * @NFP_NET_CFG_RXR_VEC:     Per TX ring MSI-X table entry (1B entries)
- * @NFP_NET_CFG_RXR_PRIO:    Per TX ring priority (1B entries)
- * @NFP_NET_CFG_RXR_IRQ_MOD: Per TX ring interrupt moderation (4B entries)
- */
-#define NFP_NET_CFG_RXR_BASE            0x0800
-#define NFP_NET_CFG_RXR_ADDR(_x)        (NFP_NET_CFG_RXR_BASE + ((_x) * 0x8))
-#define NFP_NET_CFG_RXR_SZ(_x)          (NFP_NET_CFG_RXR_BASE + 0x200 + (_x))
-#define NFP_NET_CFG_RXR_VEC(_x)         (NFP_NET_CFG_RXR_BASE + 0x240 + (_x))
-#define NFP_NET_CFG_RXR_PRIO(_x)        (NFP_NET_CFG_RXR_BASE + 0x280 + (_x))
-#define NFP_NET_CFG_RXR_IRQ_MOD(_x)     (NFP_NET_CFG_RXR_BASE + 0x300 + \
-					 ((_x) * 0x4))
-
-/*
- * Interrupt Control/Cause registers (0x0c00 - 0x0d00)
- * These registers are only used when MSI-X auto-masking is not
- * enabled (@NFP_NET_CFG_CTRL_MSIXAUTO not set).  The array is index
- * by MSI-X entry and are 1B in size.  If an entry is zero, the
- * corresponding entry is enabled.  If the FW generates an interrupt,
- * it writes a cause into the corresponding field.  This also masks
- * the MSI-X entry and the host driver must clear the register to
- * re-enable the interrupt.
- */
-#define NFP_NET_CFG_ICR_BASE            0x0c00
-#define NFP_NET_CFG_ICR(_x)             (NFP_NET_CFG_ICR_BASE + (_x))
-#define   NFP_NET_CFG_ICR_UNMASKED      0x0
-#define   NFP_NET_CFG_ICR_RXTX          0x1
-#define   NFP_NET_CFG_ICR_LSC           0x2
-
-/*
- * General device stats (0x0d00 - 0x0d90)
- * All counters are 64bit.
- */
-#define NFP_NET_CFG_STATS_BASE          0x0d00
-#define NFP_NET_CFG_STATS_RX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x00)
-#define NFP_NET_CFG_STATS_RX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x08)
-#define NFP_NET_CFG_STATS_RX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x10)
-#define NFP_NET_CFG_STATS_RX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x18)
-#define NFP_NET_CFG_STATS_RX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x20)
-#define NFP_NET_CFG_STATS_RX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x28)
-#define NFP_NET_CFG_STATS_RX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x30)
-#define NFP_NET_CFG_STATS_RX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x38)
-#define NFP_NET_CFG_STATS_RX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x40)
-
-#define NFP_NET_CFG_STATS_TX_DISCARDS   (NFP_NET_CFG_STATS_BASE + 0x48)
-#define NFP_NET_CFG_STATS_TX_ERRORS     (NFP_NET_CFG_STATS_BASE + 0x50)
-#define NFP_NET_CFG_STATS_TX_OCTETS     (NFP_NET_CFG_STATS_BASE + 0x58)
-#define NFP_NET_CFG_STATS_TX_UC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x60)
-#define NFP_NET_CFG_STATS_TX_MC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x68)
-#define NFP_NET_CFG_STATS_TX_BC_OCTETS  (NFP_NET_CFG_STATS_BASE + 0x70)
-#define NFP_NET_CFG_STATS_TX_FRAMES     (NFP_NET_CFG_STATS_BASE + 0x78)
-#define NFP_NET_CFG_STATS_TX_MC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x80)
-#define NFP_NET_CFG_STATS_TX_BC_FRAMES  (NFP_NET_CFG_STATS_BASE + 0x88)
-
-#define NFP_NET_CFG_STATS_APP0_FRAMES   (NFP_NET_CFG_STATS_BASE + 0x90)
-#define NFP_NET_CFG_STATS_APP0_BYTES    (NFP_NET_CFG_STATS_BASE + 0x98)
-#define NFP_NET_CFG_STATS_APP1_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xa0)
-#define NFP_NET_CFG_STATS_APP1_BYTES    (NFP_NET_CFG_STATS_BASE + 0xa8)
-#define NFP_NET_CFG_STATS_APP2_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xb0)
-#define NFP_NET_CFG_STATS_APP2_BYTES    (NFP_NET_CFG_STATS_BASE + 0xb8)
-#define NFP_NET_CFG_STATS_APP3_FRAMES   (NFP_NET_CFG_STATS_BASE + 0xc0)
-#define NFP_NET_CFG_STATS_APP3_BYTES    (NFP_NET_CFG_STATS_BASE + 0xc8)
-
-/*
- * Per ring stats (0x1000 - 0x1800)
- * Options, 64bit per entry
- * @NFP_NET_CFG_TXR_STATS:   TX ring statistics (Packet and Byte count)
- * @NFP_NET_CFG_RXR_STATS:   RX ring statistics (Packet and Byte count)
- */
-#define NFP_NET_CFG_TXR_STATS_BASE      0x1000
-#define NFP_NET_CFG_TXR_STATS(_x)       (NFP_NET_CFG_TXR_STATS_BASE + \
-					 ((_x) * 0x10))
-#define NFP_NET_CFG_RXR_STATS_BASE      0x1400
-#define NFP_NET_CFG_RXR_STATS(_x)       (NFP_NET_CFG_RXR_STATS_BASE + \
-					 ((_x) * 0x10))
+#include <nfp_common_ctrl.h>
 
 /*
  * Mac stats (0x0000 - 0x0200)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 14/24] common/nfp: add common module
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (12 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 13/24] common/nfp: add common ctrl module Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 15/24] common/nfp: move queue logic Chaoyong He
                         ` (10 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Add the nfp common module in the nfp 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/common/nfp/meson.build   |   3 +-
 drivers/common/nfp/nfp_common.c  | 177 +++++++++++++++++++++++
 drivers/common/nfp/nfp_common.h  | 232 +++++++++++++++++++++++++++++++
 drivers/common/nfp/version.map   |   6 +
 drivers/net/nfp/nfp_ethdev.c     |   4 +-
 drivers/net/nfp/nfp_ethdev_vf.c  |  16 +--
 drivers/net/nfp/nfp_net_common.c | 159 +--------------------
 drivers/net/nfp/nfp_net_common.h | 206 +--------------------------
 8 files changed, 423 insertions(+), 380 deletions(-)
 create mode 100644 drivers/common/nfp/nfp_common.c
 create mode 100644 drivers/common/nfp/nfp_common.h

diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
index cda5a930c7..cca7fb7796 100644
--- a/drivers/common/nfp/meson.build
+++ b/drivers/common/nfp/meson.build
@@ -7,8 +7,9 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
 endif
 
 sources = files(
+        'nfp_common.c',
         'nfp_common_log.c',
         'nfp_common_pci.c',
 )
 
-deps += ['bus_pci']
+deps += ['bus_pci', 'net']
diff --git a/drivers/common/nfp/nfp_common.c b/drivers/common/nfp/nfp_common.c
new file mode 100644
index 0000000000..1a98326980
--- /dev/null
+++ b/drivers/common/nfp/nfp_common.c
@@ -0,0 +1,177 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_common.h"
+
+#include "nfp_common_log.h"
+
+/*
+ * This is used by the reconfig protocol. It sets the maximum time waiting in
+ * milliseconds before a reconfig timeout happens.
+ */
+#define NFP_NET_POLL_TIMEOUT    5000
+
+int
+nfp_reconfig_real(struct nfp_hw *hw,
+		uint32_t update)
+{
+	uint32_t cnt;
+	uint32_t new;
+	struct timespec wait;
+
+	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
+			hw->qcp_cfg);
+
+	if (hw->qcp_cfg == NULL) {
+		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
+		return -ENXIO;
+	}
+
+	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
+
+	wait.tv_sec = 0;
+	wait.tv_nsec = 1000000; /* 1ms */
+
+	PMD_DRV_LOG(DEBUG, "Polling for update ack...");
+
+	/* Poll update field, waiting for NFP to ack the config */
+	for (cnt = 0; ; cnt++) {
+		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
+		if (new == 0)
+			break;
+
+		if ((new & NFP_NET_CFG_UPDATE_ERR) != 0) {
+			PMD_DRV_LOG(ERR, "Reconfig error: %#08x", new);
+			return -1;
+		}
+
+		if (cnt >= NFP_NET_POLL_TIMEOUT) {
+			PMD_DRV_LOG(ERR, "Reconfig timeout for %#08x after %u ms",
+					update, cnt);
+			return -EIO;
+		}
+
+		nanosleep(&wait, 0); /* waiting for a 1ms */
+	}
+
+	PMD_DRV_LOG(DEBUG, "Ack DONE");
+	return 0;
+}
+
+/**
+ * Reconfigure the NIC.
+ *
+ * Write the update word to the BAR and ping the reconfig queue. Then poll
+ * until the firmware has acknowledged the update by zeroing the update word.
+ *
+ * @param hw
+ *   Device to reconfigure.
+ * @param ctrl
+ *   The value for the ctrl field in the BAR config.
+ * @param update
+ *   The value for the update field in the BAR config.
+ *
+ * @return
+ *   - (0) if OK to reconfigure the device.
+ *   - (-EIO) if I/O err and fail to reconfigure the device.
+ */
+int
+nfp_reconfig(struct nfp_hw *hw,
+		uint32_t ctrl,
+		uint32_t update)
+{
+	int ret;
+
+	rte_spinlock_lock(&hw->reconfig_lock);
+
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+
+	rte_wmb();
+
+	ret = nfp_reconfig_real(hw, update);
+
+	rte_spinlock_unlock(&hw->reconfig_lock);
+
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Error nfp reconfig: ctrl=%#08x update=%#08x",
+				ctrl, update);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+/**
+ * Reconfigure the NIC for the extend ctrl BAR.
+ *
+ * Write the update word to the BAR and ping the reconfig queue. Then poll
+ * until the firmware has acknowledged the update by zeroing the update word.
+ *
+ * @param hw
+ *   Device to reconfigure.
+ * @param ctrl_ext
+ *   The value for the first word of extend ctrl field in the BAR config.
+ * @param update
+ *   The value for the update field in the BAR config.
+ *
+ * @return
+ *   - (0) if OK to reconfigure the device.
+ *   - (-EIO) if I/O err and fail to reconfigure the device.
+ */
+int
+nfp_ext_reconfig(struct nfp_hw *hw,
+		uint32_t ctrl_ext,
+		uint32_t update)
+{
+	int ret;
+
+	rte_spinlock_lock(&hw->reconfig_lock);
+
+	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
+	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
+
+	rte_wmb();
+
+	ret = nfp_reconfig_real(hw, update);
+
+	rte_spinlock_unlock(&hw->reconfig_lock);
+
+	if (ret != 0) {
+		PMD_DRV_LOG(ERR, "Error nfp ext reconfig: ctrl_ext=%#08x update=%#08x",
+				ctrl_ext, update);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+void
+nfp_read_mac(struct nfp_hw *hw)
+{
+	uint32_t tmp;
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
+	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
+
+	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
+	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
+}
+
+void
+nfp_write_mac(struct nfp_hw *hw,
+		uint8_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;
+	mac1 = *(uint16_t *)mac;
+	nn_writew(rte_cpu_to_be_16(mac1),
+			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+}
diff --git a/drivers/common/nfp/nfp_common.h b/drivers/common/nfp/nfp_common.h
new file mode 100644
index 0000000000..5615cde6af
--- /dev/null
+++ b/drivers/common/nfp/nfp_common.h
@@ -0,0 +1,232 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_COMMON_H__
+#define __NFP_COMMON_H__
+
+#include <rte_byteorder.h>
+#include <rte_ether.h>
+#include <rte_io.h>
+#include <rte_spinlock.h>
+
+#include "nfp_common_ctrl.h"
+
+#define NFP_QCP_QUEUE_ADDR_SZ   (0x800)
+
+/* Macros for accessing the Queue Controller Peripheral 'CSRs' */
+#define NFP_QCP_QUEUE_OFF(_x)                 ((_x) * 0x800)
+#define NFP_QCP_QUEUE_ADD_RPTR                  0x0000
+#define NFP_QCP_QUEUE_ADD_WPTR                  0x0004
+#define NFP_QCP_QUEUE_STS_LO                    0x0008
+#define NFP_QCP_QUEUE_STS_LO_READPTR_MASK     (0x3ffff)
+#define NFP_QCP_QUEUE_STS_HI                    0x000c
+#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK    (0x3ffff)
+
+/* Read or Write Pointer of a queue */
+enum nfp_qcp_ptr {
+	NFP_QCP_READ_PTR = 0,
+	NFP_QCP_WRITE_PTR
+};
+
+struct nfp_hw {
+	uint8_t *ctrl_bar;
+	uint8_t *qcp_cfg;
+	uint32_t cap;
+	uint32_t cap_ext;
+	uint32_t ctrl;
+	uint32_t ctrl_ext;
+	rte_spinlock_t reconfig_lock;
+	struct rte_ether_addr mac_addr;
+};
+
+static inline uint8_t
+nn_readb(volatile const void *addr)
+{
+	return rte_read8(addr);
+}
+
+static inline void
+nn_writeb(uint8_t val,
+		volatile void *addr)
+{
+	rte_write8(val, addr);
+}
+
+static inline uint32_t
+nn_readl(volatile const void *addr)
+{
+	return rte_read32(addr);
+}
+
+static inline void
+nn_writel(uint32_t val,
+		volatile void *addr)
+{
+	rte_write32(val, addr);
+}
+
+static inline uint16_t
+nn_readw(volatile const void *addr)
+{
+	return rte_read16(addr);
+}
+
+static inline void
+nn_writew(uint16_t val,
+		volatile void *addr)
+{
+	rte_write16(val, addr);
+}
+
+static inline uint64_t
+nn_readq(volatile void *addr)
+{
+	uint32_t low;
+	uint32_t high;
+	const volatile uint32_t *p = addr;
+
+	high = nn_readl((volatile const void *)(p + 1));
+	low = nn_readl((volatile const void *)p);
+
+	return low + ((uint64_t)high << 32);
+}
+
+static inline void
+nn_writeq(uint64_t val,
+		volatile void *addr)
+{
+	nn_writel(val >> 32, (volatile char *)addr + 4);
+	nn_writel(val, addr);
+}
+
+static inline uint8_t
+nn_cfg_readb(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return nn_readb(hw->ctrl_bar + off);
+}
+
+static inline void
+nn_cfg_writeb(struct nfp_hw *hw,
+		uint32_t off,
+		uint8_t val)
+{
+	nn_writeb(val, hw->ctrl_bar + off);
+}
+
+static inline uint16_t
+nn_cfg_readw(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writew(struct nfp_hw *hw,
+		uint32_t off,
+		uint16_t val)
+{
+	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
+}
+
+static inline uint32_t
+nn_cfg_readl(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writel(struct nfp_hw *hw,
+		uint32_t off,
+		uint32_t val)
+{
+	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
+}
+
+static inline uint64_t
+nn_cfg_readq(struct nfp_hw *hw,
+		uint32_t off)
+{
+	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
+}
+
+static inline void
+nn_cfg_writeq(struct nfp_hw *hw,
+		uint32_t off,
+		uint64_t val)
+{
+	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
+}
+
+/**
+ * Add the value to the selected pointer of a queue.
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Add to the read or write pointer
+ * @param val
+ *   Value to add to the queue pointer
+ */
+static inline void
+nfp_qcp_ptr_add(uint8_t *queue,
+		enum nfp_qcp_ptr ptr,
+		uint32_t val)
+{
+	uint32_t off;
+
+	if (ptr == NFP_QCP_READ_PTR)
+		off = NFP_QCP_QUEUE_ADD_RPTR;
+	else
+		off = NFP_QCP_QUEUE_ADD_WPTR;
+
+	nn_writel(rte_cpu_to_le_32(val), queue + off);
+}
+
+/**
+ * Read the current read/write pointer value for a queue.
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Read or Write pointer
+ */
+static inline uint32_t
+nfp_qcp_read(uint8_t *queue,
+		enum nfp_qcp_ptr ptr)
+{
+	uint32_t off;
+	uint32_t val;
+
+	if (ptr == NFP_QCP_READ_PTR)
+		off = NFP_QCP_QUEUE_STS_LO;
+	else
+		off = NFP_QCP_QUEUE_STS_HI;
+
+	val = rte_cpu_to_le_32(nn_readl(queue + off));
+
+	if (ptr == NFP_QCP_READ_PTR)
+		return val & NFP_QCP_QUEUE_STS_LO_READPTR_MASK;
+	else
+		return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK;
+}
+
+__rte_internal
+int nfp_reconfig_real(struct nfp_hw *hw, uint32_t update);
+
+__rte_internal
+int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
+
+__rte_internal
+int nfp_ext_reconfig(struct nfp_hw *hw, uint32_t ctrl_ext, uint32_t update);
+
+__rte_internal
+void nfp_read_mac(struct nfp_hw *hw);
+
+__rte_internal
+void nfp_write_mac(struct nfp_hw *hw, uint8_t *mac);
+
+#endif/* __NFP_COMMON_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index 25e48c39d6..f6a54a97cd 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -3,5 +3,11 @@ INTERNAL {
 
 	nfp_class_driver_register;
 
+	nfp_reconfig;
+	nfp_ext_reconfig;
+	nfp_reconfig_real;
+	nfp_read_mac;
+	nfp_write_mac;
+
 	local: *;
 };
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 3d4b78fbf1..76317925ec 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -600,13 +600,13 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	}
 
 	nfp_net_pf_read_mac(app_fw_nic, port);
-	nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+	nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 
 	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
 		/* Using random mac addresses for VFs */
 		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 049728d30c..b9cfb48021 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -15,18 +15,6 @@
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
 
-static void
-nfp_netvf_read_mac(struct nfp_hw *hw)
-{
-	uint32_t tmp;
-
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
-	memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
-
-	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
-	memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
-}
-
 static int
 nfp_netvf_start(struct rte_eth_dev *dev)
 {
@@ -334,12 +322,12 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 		goto dev_err_ctrl_map;
 	}
 
-	nfp_netvf_read_mac(hw);
+	nfp_read_mac(hw);
 	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
 		PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
 		/* Using random mac addresses for VFs */
 		rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
-		nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+		nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 	}
 
 	/* Copying mac address to DPDK eth_dev struct */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 01574de963..711532b466 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -19,12 +19,6 @@
 #define NFP_TX_MAX_SEG       UINT8_MAX
 #define NFP_TX_MAX_MTU_SEG   8
 
-/*
- * This is used by the reconfig protocol. It sets the maximum time waiting in
- * milliseconds before a reconfig timeout happens.
- */
-#define NFP_NET_POLL_TIMEOUT    5000
-
 #define NFP_NET_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
 #define NFP_NET_LINK_UP_CHECK_TIMEOUT   1000 /* ms */
 
@@ -198,141 +192,6 @@ nfp_net_notify_port_speed(struct nfp_net_hw *hw,
 /* The length of firmware version string */
 #define FW_VER_LEN        32
 
-static int
-nfp_reconfig_real(struct nfp_hw *hw,
-		uint32_t update)
-{
-	uint32_t cnt;
-	uint32_t new;
-	struct timespec wait;
-
-	PMD_DRV_LOG(DEBUG, "Writing to the configuration queue (%p)...",
-			hw->qcp_cfg);
-
-	if (hw->qcp_cfg == NULL) {
-		PMD_DRV_LOG(ERR, "Bad configuration queue pointer");
-		return -ENXIO;
-	}
-
-	nfp_qcp_ptr_add(hw->qcp_cfg, NFP_QCP_WRITE_PTR, 1);
-
-	wait.tv_sec = 0;
-	wait.tv_nsec = 1000000; /* 1ms */
-
-	PMD_DRV_LOG(DEBUG, "Polling for update ack...");
-
-	/* Poll update field, waiting for NFP to ack the config */
-	for (cnt = 0; ; cnt++) {
-		new = nn_cfg_readl(hw, NFP_NET_CFG_UPDATE);
-		if (new == 0)
-			break;
-
-		if ((new & NFP_NET_CFG_UPDATE_ERR) != 0) {
-			PMD_DRV_LOG(ERR, "Reconfig error: %#08x", new);
-			return -1;
-		}
-
-		if (cnt >= NFP_NET_POLL_TIMEOUT) {
-			PMD_DRV_LOG(ERR, "Reconfig timeout for %#08x after %u ms",
-					update, cnt);
-			return -EIO;
-		}
-
-		nanosleep(&wait, 0); /* Waiting for a 1ms */
-	}
-
-	PMD_DRV_LOG(DEBUG, "Ack DONE");
-	return 0;
-}
-
-/**
- * Reconfigure the NIC.
- *
- * Write the update word to the BAR and ping the reconfig queue. Then poll
- * until the firmware has acknowledged the update by zeroing the update word.
- *
- * @param hw
- *   Device to reconfigure.
- * @param ctrl
- *   The value for the ctrl field in the BAR config.
- * @param update
- *   The value for the update field in the BAR config.
- *
- * @return
- *   - (0) if OK to reconfigure the device.
- *   - (-EIO) if I/O err and fail to reconfigure the device.
- */
-int
-nfp_reconfig(struct nfp_hw *hw,
-		uint32_t ctrl,
-		uint32_t update)
-{
-	int ret;
-
-	rte_spinlock_lock(&hw->reconfig_lock);
-
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL, ctrl);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
-
-	rte_wmb();
-
-	ret = nfp_reconfig_real(hw, update);
-
-	rte_spinlock_unlock(&hw->reconfig_lock);
-
-	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp reconfig: ctrl=%#08x update=%#08x",
-				ctrl, update);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-/**
- * Reconfigure the NIC for the extend ctrl BAR.
- *
- * Write the update word to the BAR and ping the reconfig queue. Then poll
- * until the firmware has acknowledged the update by zeroing the update word.
- *
- * @param hw
- *   Device to reconfigure.
- * @param ctrl_ext
- *   The value for the first word of extend ctrl field in the BAR config.
- * @param update
- *   The value for the update field in the BAR config.
- *
- * @return
- *   - (0) if OK to reconfigure the device.
- *   - (-EIO) if I/O err and fail to reconfigure the device.
- */
-int
-nfp_ext_reconfig(struct nfp_hw *hw,
-		uint32_t ctrl_ext,
-		uint32_t update)
-{
-	int ret;
-
-	rte_spinlock_lock(&hw->reconfig_lock);
-
-	nn_cfg_writel(hw, NFP_NET_CFG_CTRL_WORD1, ctrl_ext);
-	nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, update);
-
-	rte_wmb();
-
-	ret = nfp_reconfig_real(hw, update);
-
-	rte_spinlock_unlock(&hw->reconfig_lock);
-
-	if (ret != 0) {
-		PMD_DRV_LOG(ERR, "Error nfp ext reconfig: ctrl_ext=%#08x update=%#08x",
-				ctrl_ext, update);
-		return -EIO;
-	}
-
-	return 0;
-}
-
 /**
  * Reconfigure the firmware via the mailbox
  *
@@ -531,22 +390,6 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
 	hw->super.qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
 }
 
-void
-nfp_net_write_mac(struct nfp_hw *hw,
-		uint8_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;
-	mac1 = *(uint16_t *)mac;
-	nn_writew(rte_cpu_to_be_16(mac1),
-			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
-}
-
 int
 nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 		struct rte_ether_addr *mac_addr)
@@ -565,7 +408,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
 	}
 
 	/* Writing new MAC to the specific port BAR address */
-	nfp_net_write_mac(hw, (uint8_t *)mac_addr);
+	nfp_write_mac(hw, (uint8_t *)mac_addr);
 
 	update = NFP_NET_CFG_UPDATE_MACADDR;
 	ctrl = hw->ctrl;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index e997756091..9461440d0b 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -8,21 +8,12 @@
 
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
-#include <rte_io.h>
+#include <nfp_common.h>
 #include <rte_spinlock.h>
 
 #include "nfp_net_ctrl.h"
 #include "nfpcore/nfp_dev.h"
 
-/* Macros for accessing the Queue Controller Peripheral 'CSRs' */
-#define NFP_QCP_QUEUE_OFF(_x)                 ((_x) * 0x800)
-#define NFP_QCP_QUEUE_ADD_RPTR                  0x0000
-#define NFP_QCP_QUEUE_ADD_WPTR                  0x0004
-#define NFP_QCP_QUEUE_STS_LO                    0x0008
-#define NFP_QCP_QUEUE_STS_LO_READPTR_MASK     (0x3ffff)
-#define NFP_QCP_QUEUE_STS_HI                    0x000c
-#define NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK    (0x3ffff)
-
 /* Interrupt definitions */
 #define NFP_NET_IRQ_LSC_IDX             0
 
@@ -42,8 +33,6 @@
 /* Alignment for dma zones */
 #define NFP_MEMZONE_ALIGN       128
 
-#define NFP_QCP_QUEUE_ADDR_SZ   (0x800)
-
 /* Number of supported physical ports */
 #define NFP_MAX_PHYPORTS        12
 
@@ -53,12 +42,6 @@ enum nfp_app_fw_id {
 	NFP_APP_FW_FLOWER_NIC             = 0x3,
 };
 
-/* Read or Write Pointer of a queue */
-enum nfp_qcp_ptr {
-	NFP_QCP_READ_PTR = 0,
-	NFP_QCP_WRITE_PTR
-};
-
 enum nfp_net_meta_format {
 	NFP_NET_METAFORMAT_SINGLE,
 	NFP_NET_METAFORMAT_CHAINED,
@@ -112,17 +95,6 @@ struct nfp_app_fw_nic {
 	uint8_t total_phyports;
 };
 
-struct nfp_hw {
-	uint8_t *ctrl_bar;
-	uint8_t *qcp_cfg;
-	uint32_t cap;
-	uint32_t cap_ext;
-	uint32_t ctrl;
-	uint32_t ctrl_ext;
-	rte_spinlock_t reconfig_lock;
-	struct rte_ether_addr mac_addr;
-};
-
 struct nfp_net_hw {
 	/** The parent class */
 	struct nfp_hw super;
@@ -184,179 +156,6 @@ struct nfp_net_adapter {
 	struct nfp_net_hw hw;
 };
 
-static inline uint8_t
-nn_readb(volatile const void *addr)
-{
-	return rte_read8(addr);
-}
-
-static inline void
-nn_writeb(uint8_t val,
-		volatile void *addr)
-{
-	rte_write8(val, addr);
-}
-
-static inline uint32_t
-nn_readl(volatile const void *addr)
-{
-	return rte_read32(addr);
-}
-
-static inline void
-nn_writel(uint32_t val,
-		volatile void *addr)
-{
-	rte_write32(val, addr);
-}
-
-static inline uint16_t
-nn_readw(volatile const void *addr)
-{
-	return rte_read16(addr);
-}
-
-static inline void
-nn_writew(uint16_t val,
-		volatile void *addr)
-{
-	rte_write16(val, addr);
-}
-
-static inline uint64_t
-nn_readq(volatile void *addr)
-{
-	uint32_t low;
-	uint32_t high;
-	const volatile uint32_t *p = addr;
-
-	high = nn_readl((volatile const void *)(p + 1));
-	low = nn_readl((volatile const void *)p);
-
-	return low + ((uint64_t)high << 32);
-}
-
-static inline void
-nn_writeq(uint64_t val,
-		volatile void *addr)
-{
-	nn_writel(val >> 32, (volatile char *)addr + 4);
-	nn_writel(val, addr);
-}
-
-static inline uint8_t
-nn_cfg_readb(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return nn_readb(hw->ctrl_bar + off);
-}
-
-static inline void
-nn_cfg_writeb(struct nfp_hw *hw,
-		uint32_t off,
-		uint8_t val)
-{
-	nn_writeb(val, hw->ctrl_bar + off);
-}
-
-static inline uint16_t
-nn_cfg_readw(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_16(nn_readw(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writew(struct nfp_hw *hw,
-		uint32_t off,
-		uint16_t val)
-{
-	nn_writew(rte_cpu_to_le_16(val), hw->ctrl_bar + off);
-}
-
-static inline uint32_t
-nn_cfg_readl(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_32(nn_readl(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writel(struct nfp_hw *hw,
-		uint32_t off,
-		uint32_t val)
-{
-	nn_writel(rte_cpu_to_le_32(val), hw->ctrl_bar + off);
-}
-
-static inline uint64_t
-nn_cfg_readq(struct nfp_hw *hw,
-		uint32_t off)
-{
-	return rte_le_to_cpu_64(nn_readq(hw->ctrl_bar + off));
-}
-
-static inline void
-nn_cfg_writeq(struct nfp_hw *hw,
-		uint32_t off,
-		uint64_t val)
-{
-	nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off);
-}
-
-/**
- * Add the value to the selected pointer of a queue.
- *
- * @param queue
- *   Base address for queue structure
- * @param ptr
- *   Add to the read or write pointer
- * @param val
- *   Value to add to the queue pointer
- */
-static inline void
-nfp_qcp_ptr_add(uint8_t *queue,
-		enum nfp_qcp_ptr ptr,
-		uint32_t val)
-{
-	uint32_t off;
-
-	if (ptr == NFP_QCP_READ_PTR)
-		off = NFP_QCP_QUEUE_ADD_RPTR;
-	else
-		off = NFP_QCP_QUEUE_ADD_WPTR;
-
-	nn_writel(rte_cpu_to_le_32(val), queue + off);
-}
-
-/**
- * Read the current read/write pointer value for a queue.
- *
- * @param queue
- *   Base address for queue structure
- * @param ptr
- *   Read or Write pointer
- */
-static inline uint32_t
-nfp_qcp_read(uint8_t *queue,
-		enum nfp_qcp_ptr ptr)
-{
-	uint32_t off;
-	uint32_t val;
-
-	if (ptr == NFP_QCP_READ_PTR)
-		off = NFP_QCP_QUEUE_STS_LO;
-	else
-		off = NFP_QCP_QUEUE_STS_HI;
-
-	val = rte_cpu_to_le_32(nn_readl(queue + off));
-
-	if (ptr == NFP_QCP_READ_PTR)
-		return val & NFP_QCP_QUEUE_STS_LO_READPTR_MASK;
-	else
-		return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_MASK;
-}
-
 static inline uint32_t
 nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 		uint16_t queue)
@@ -366,8 +165,6 @@ nfp_qcp_queue_offset(const struct nfp_dev_info *dev_info,
 }
 
 /* Prototypes for common NFP functions */
-int nfp_reconfig(struct nfp_hw *hw, uint32_t ctrl, uint32_t update);
-int nfp_ext_reconfig(struct nfp_hw *hw, uint32_t ctrl_ext, uint32_t update);
 int nfp_net_mbox_reconfig(struct nfp_net_hw *hw, uint32_t mbox_cmd);
 int nfp_net_configure(struct rte_eth_dev *dev);
 int nfp_net_common_init(struct rte_pci_device *pci_dev, struct nfp_net_hw *hw);
@@ -375,7 +172,6 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_net_write_mac(struct nfp_hw *hw, uint8_t *mac);
 int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
 int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
 		struct rte_intr_handle *intr_handle);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 15/24] common/nfp: move queue logic
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (13 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 14/24] common/nfp: add common module Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 16/24] common/nfp: move platform module Chaoyong He
                         ` (9 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the queue enable/disable logic to the 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/common/nfp/nfp_common.c  | 49 ++++++++++++++++++++++++++++++++
 drivers/common/nfp/nfp_common.h  |  7 +++++
 drivers/common/nfp/version.map   |  2 ++
 drivers/net/nfp/nfp_net_common.c | 38 ++-----------------------
 4 files changed, 61 insertions(+), 35 deletions(-)

diff --git a/drivers/common/nfp/nfp_common.c b/drivers/common/nfp/nfp_common.c
index 1a98326980..4c94c9d59a 100644
--- a/drivers/common/nfp/nfp_common.c
+++ b/drivers/common/nfp/nfp_common.c
@@ -175,3 +175,52 @@ nfp_write_mac(struct nfp_hw *hw,
 	nn_writew(rte_cpu_to_be_16(mac1),
 			hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
 }
+
+void
+nfp_enable_queues(struct nfp_hw *hw,
+		uint16_t nb_rx_queues,
+		uint16_t nb_tx_queues)
+{
+	int i;
+	uint64_t enabled_queues;
+
+	/* Enabling the required TX queues in the device */
+	enabled_queues = 0;
+	for (i = 0; i < nb_tx_queues; i++)
+		enabled_queues |= (1 << i);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
+
+	/* Enabling the required RX queues in the device */
+	enabled_queues = 0;
+	for (i = 0; i < nb_rx_queues; i++)
+		enabled_queues |= (1 << i);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+}
+
+void
+nfp_disable_queues(struct nfp_hw *hw)
+{
+	int ret;
+	uint32_t update;
+	uint32_t new_ctrl;
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
+
+	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
+	update = NFP_NET_CFG_UPDATE_GEN |
+			NFP_NET_CFG_UPDATE_RING |
+			NFP_NET_CFG_UPDATE_MSIX;
+
+	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
+		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
+
+	/* If an error when reconfig we avoid to change hw state */
+	ret = nfp_reconfig(hw, new_ctrl, update);
+	if (ret < 0)
+		return;
+
+	hw->ctrl = new_ctrl;
+}
diff --git a/drivers/common/nfp/nfp_common.h b/drivers/common/nfp/nfp_common.h
index 5615cde6af..7597d4090b 100644
--- a/drivers/common/nfp/nfp_common.h
+++ b/drivers/common/nfp/nfp_common.h
@@ -229,4 +229,11 @@ void nfp_read_mac(struct nfp_hw *hw);
 __rte_internal
 void nfp_write_mac(struct nfp_hw *hw, uint8_t *mac);
 
+__rte_internal
+void nfp_enable_queues(struct nfp_hw *hw, uint16_t nb_rx_queues,
+		uint16_t nb_tx_queues);
+
+__rte_internal
+void nfp_disable_queues(struct nfp_hw *hw);
+
 #endif/* __NFP_COMMON_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index f6a54a97cd..c1e03d8b8d 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -8,6 +8,8 @@ INTERNAL {
 	nfp_reconfig_real;
 	nfp_read_mac;
 	nfp_write_mac;
+	nfp_enable_queues;
+	nfp_disable_queues;
 
 	local: *;
 };
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 711532b466..090feb0e39 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -327,54 +327,22 @@ nfp_net_enable_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;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	/* Enabling the required TX queues in the device */
-	enabled_queues = 0;
-	for (i = 0; i < dev->data->nb_tx_queues; i++)
-		enabled_queues |= (1 << i);
-
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXRS_ENABLE, enabled_queues);
-
-	/* Enabling the required RX queues in the device */
-	enabled_queues = 0;
-	for (i = 0; i < dev->data->nb_rx_queues; i++)
-		enabled_queues |= (1 << i);
-
-	nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXRS_ENABLE, enabled_queues);
+	nfp_enable_queues(&hw->super, dev->data->nb_rx_queues,
+			dev->data->nb_tx_queues);
 }
 
 void
 nfp_net_disable_queues(struct rte_eth_dev *dev)
 {
-	uint32_t update;
-	uint32_t new_ctrl;
-	struct nfp_hw *hw;
 	struct nfp_net_hw *net_hw;
 
 	net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	hw = &net_hw->super;
-
-	nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
-	nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0);
-
-	new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE;
-	update = NFP_NET_CFG_UPDATE_GEN |
-			NFP_NET_CFG_UPDATE_RING |
-			NFP_NET_CFG_UPDATE_MSIX;
-
-	if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0)
-		new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG;
 
-	/* If an error when reconfig we avoid to change hw state */
-	if (nfp_reconfig(hw, new_ctrl, update) != 0)
-		return;
-
-	hw->ctrl = new_ctrl;
+	nfp_disable_queues(&net_hw->super);
 }
 
 void
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 16/24] common/nfp: move platform module
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (14 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 15/24] common/nfp: move queue logic Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 17/24] common/nfp: move device module Chaoyong He
                         ` (8 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the platform module to the 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/nfpcore => common/nfp}/nfp_platform.h | 0
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c                     | 2 +-
 drivers/net/nfp/nfp_net_ctrl.c                         | 3 +--
 drivers/net/nfp/nfpcore/nfp_cppcore.c                  | 3 ++-
 drivers/net/nfp/nfpcore/nfp_dev.c                      | 3 +--
 drivers/net/nfp/nfpcore/nfp_nsp.c                      | 2 +-
 drivers/net/nfp/nfpcore/nfp_nsp_eth.c                  | 3 ++-
 7 files changed, 8 insertions(+), 8 deletions(-)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_platform.h (100%)

diff --git a/drivers/net/nfp/nfpcore/nfp_platform.h b/drivers/common/nfp/nfp_platform.h
similarity index 100%
rename from drivers/net/nfp/nfpcore/nfp_platform.h
rename to drivers/common/nfp/nfp_platform.h
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 3f8d25aa29..10e6982c95 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -6,10 +6,10 @@
 #include "nfp_nfdk.h"
 
 #include <bus_pci_driver.h>
+#include <nfp_platform.h>
 #include <rte_malloc.h>
 
 #include "../flower/nfp_flower.h"
-#include "../nfpcore/nfp_platform.h"
 #include "../nfp_logs.h"
 
 #define NFDK_TX_DESC_GATHER_MAX         17
diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c
index 8848fa38fe..5135a1ad27 100644
--- a/drivers/net/nfp/nfp_net_ctrl.c
+++ b/drivers/net/nfp/nfp_net_ctrl.c
@@ -6,8 +6,7 @@
 #include "nfp_net_ctrl.h"
 
 #include <ethdev_pci.h>
-
-#include "nfpcore/nfp_platform.h"
+#include <nfp_platform.h>
 
 #include "nfp_logs.h"
 #include "nfp_net_common.h"
diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c
index f9b08a12b6..0e6045f2f0 100644
--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c
@@ -5,8 +5,9 @@
 
 #include "nfp_cpp.h"
 
+#include <nfp_platform.h>
+
 #include "nfp_logs.h"
-#include "nfp_platform.h"
 #include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
 #include "nfp6000/nfp_xpb.h"
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.c b/drivers/net/nfp/nfpcore/nfp_dev.c
index 7799fa699a..f29b7e0711 100644
--- a/drivers/net/nfp/nfpcore/nfp_dev.c
+++ b/drivers/net/nfp/nfpcore/nfp_dev.c
@@ -5,10 +5,9 @@
 
 #include "nfp_dev.h"
 
+#include <nfp_platform.h>
 #include <rte_bitops.h>
 
-#include "nfp_platform.h"
-
 /*
  * Note: The value of 'max_qc_size' is different from kernel driver,
  * because DPDK use 'uint16_t' as the data type.
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index 5b804f6174..a680b972b8 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -5,10 +5,10 @@
 
 #include "nfp_nsp.h"
 
+#include <nfp_platform.h>
 #include <rte_common.h>
 
 #include "nfp_logs.h"
-#include "nfp_platform.h"
 #include "nfp_resource.h"
 
 /* Offsets relative to the CSR base */
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
index cc472907ca..75f6d40fea 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
@@ -3,9 +3,10 @@
  * All rights reserved.
  */
 
+#include <nfp_platform.h>
+
 #include "nfp_logs.h"
 #include "nfp_nsp.h"
-#include "nfp_platform.h"
 
 #define NSP_ETH_NBI_PORT_COUNT          24
 #define NSP_ETH_MAX_COUNT               (2 * NSP_ETH_NBI_PORT_COUNT)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 17/24] common/nfp: move device module
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (15 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 16/24] common/nfp: move platform module Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 18/24] vdpa/nfp: introduce driver Chaoyong He
                         ` (7 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

Move the device module to the 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/common/nfp/meson.build                    | 1 +
 drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c | 0
 drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h | 3 +++
 drivers/common/nfp/version.map                    | 1 +
 drivers/net/nfp/meson.build                       | 1 -
 drivers/net/nfp/nfp_net_common.h                  | 2 +-
 drivers/net/nfp/nfpcore/nfp6000_pcie.h            | 2 +-
 7 files changed, 7 insertions(+), 3 deletions(-)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.c (100%)
 rename drivers/{net/nfp/nfpcore => common/nfp}/nfp_dev.h (96%)

diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
index cca7fb7796..a09d1e25e2 100644
--- a/drivers/common/nfp/meson.build
+++ b/drivers/common/nfp/meson.build
@@ -10,6 +10,7 @@ sources = files(
         'nfp_common.c',
         'nfp_common_log.c',
         'nfp_common_pci.c',
+        'nfp_dev.c',
 )
 
 deps += ['bus_pci', 'net']
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.c b/drivers/common/nfp/nfp_dev.c
similarity index 100%
rename from drivers/net/nfp/nfpcore/nfp_dev.c
rename to drivers/common/nfp/nfp_dev.c
diff --git a/drivers/net/nfp/nfpcore/nfp_dev.h b/drivers/common/nfp/nfp_dev.h
similarity index 96%
rename from drivers/net/nfp/nfpcore/nfp_dev.h
rename to drivers/common/nfp/nfp_dev.h
index b0fffff619..ffcdd17227 100644
--- a/drivers/net/nfp/nfpcore/nfp_dev.h
+++ b/drivers/common/nfp/nfp_dev.h
@@ -8,6 +8,8 @@
 
 #include <stdint.h>
 
+#include <rte_compat.h>
+
 #define PCI_VENDOR_ID_NETRONOME         0x19ee
 #define PCI_VENDOR_ID_CORIGINE          0x1da8
 
@@ -39,6 +41,7 @@ struct nfp_dev_info {
 	uint8_t pf_num_per_unit;
 };
 
+__rte_internal
 const struct nfp_dev_info *nfp_dev_info_get(uint16_t device_id);
 
 #endif /* __NFP_DEV_H__ */
diff --git a/drivers/common/nfp/version.map b/drivers/common/nfp/version.map
index c1e03d8b8d..c8a04b1b95 100644
--- a/drivers/common/nfp/version.map
+++ b/drivers/common/nfp/version.map
@@ -10,6 +10,7 @@ INTERNAL {
 	nfp_write_mac;
 	nfp_enable_queues;
 	nfp_disable_queues;
+	nfp_dev_info_get;
 
 	local: *;
 };
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index fa99c3b6aa..cf9c16266d 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -16,7 +16,6 @@ sources = files(
         'nfdk/nfp_nfdk_dp.c',
         'nfpcore/nfp_cppcore.c',
         'nfpcore/nfp_crc.c',
-        'nfpcore/nfp_dev.c',
         'nfpcore/nfp_hwinfo.c',
         'nfpcore/nfp_mip.c',
         'nfpcore/nfp_mutex.c',
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 9461440d0b..6607175460 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -9,10 +9,10 @@
 #include <bus_pci_driver.h>
 #include <ethdev_driver.h>
 #include <nfp_common.h>
+#include <nfp_dev.h>
 #include <rte_spinlock.h>
 
 #include "nfp_net_ctrl.h"
-#include "nfpcore/nfp_dev.h"
 
 /* Interrupt definitions */
 #define NFP_NET_IRQ_LSC_IDX             0
diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.h b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
index 8e2cfb69e6..59b58ddd04 100644
--- a/drivers/net/nfp/nfpcore/nfp6000_pcie.h
+++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.h
@@ -7,9 +7,9 @@
 #define __NFP6000_PCIE_H__
 
 #include <ethdev_pci.h>
+#include <nfp_dev.h>
 
 #include "nfp_cpp.h"
-#include "nfp_dev.h"
 
 const struct nfp_cpp_operations *nfp_cpp_transport_operations(void);
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 18/24] vdpa/nfp: introduce driver
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (16 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 17/24] common/nfp: move device module Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 19/24] vdpa/nfp: add basic framework Chaoyong He
                         ` (6 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Introduce the very basic NFP vDPA library, and add entry for the NFP
vDPA PMD in the release notes.

Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
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>
---
 MAINTAINERS                            |  6 +++
 doc/guides/rel_notes/release_23_11.rst |  5 +++
 doc/guides/vdpadevs/features/nfp.ini   |  8 ++++
 doc/guides/vdpadevs/index.rst          |  1 +
 doc/guides/vdpadevs/nfp.rst            | 54 ++++++++++++++++++++++++++
 drivers/vdpa/meson.build               |  1 +
 drivers/vdpa/nfp/meson.build           | 13 +++++++
 drivers/vdpa/nfp/nfp_vdpa_log.c        |  9 +++++
 drivers/vdpa/nfp/nfp_vdpa_log.h        | 21 ++++++++++
 9 files changed, 118 insertions(+)
 create mode 100644 doc/guides/vdpadevs/features/nfp.ini
 create mode 100644 doc/guides/vdpadevs/nfp.rst
 create mode 100644 drivers/vdpa/nfp/meson.build
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_log.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5273ab9812..f463188f1d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1301,6 +1301,12 @@ vDPA Drivers
 T: git://dpdk.org/next/dpdk-next-virtio
 F: drivers/vdpa/meson.build
 
+Corigine nfp vDPA
+M: Chaoyong He <chaoyong.he@corigine.com>
+F: drivers/vdpa/nfp/
+F: doc/guides/vpdadevs/nfp.rst
+F: doc/guides/vdpadevs/features/nfp.ini
+
 Intel ifc
 M: Xiao Wang <xiao.w.wang@intel.com>
 F: drivers/vdpa/ifc/
diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst
index 0a6fc76a9d..f6dde6fb9d 100644
--- a/doc/guides/rel_notes/release_23_11.rst
+++ b/doc/guides/rel_notes/release_23_11.rst
@@ -153,6 +153,11 @@ New Features
 
   * Added inline IPsec offload based on the security framework.
 
+* **Add new vDPA PMD based on Corigine NFP devices.**
+
+  Added a new Corigine NFP vDPA (``nfp_vdpa``) PMD.
+  See the :doc:`../vdpadevs/nfp` guide for more details on this driver.
+
 * **Updated Wangxun ngbe driver.**
 
   * Added 100M and auto-neg support in YT PHY fiber mode.
diff --git a/doc/guides/vdpadevs/features/nfp.ini b/doc/guides/vdpadevs/features/nfp.ini
new file mode 100644
index 0000000000..d830feafe0
--- /dev/null
+++ b/doc/guides/vdpadevs/features/nfp.ini
@@ -0,0 +1,8 @@
+;
+; Supported features of the 'nfp' vDPA driver.
+;
+; Refer to default.ini for the full list of available driver features.
+;
+[Features]
+Linux                   = Y
+x86-64                  = Y
diff --git a/doc/guides/vdpadevs/index.rst b/doc/guides/vdpadevs/index.rst
index cc2f858042..b0191a3a1d 100644
--- a/doc/guides/vdpadevs/index.rst
+++ b/doc/guides/vdpadevs/index.rst
@@ -14,4 +14,5 @@ which can be used from an application through vhost API.
     features_overview
     ifc
     mlx5
+    nfp
     sfc
diff --git a/doc/guides/vdpadevs/nfp.rst b/doc/guides/vdpadevs/nfp.rst
new file mode 100644
index 0000000000..63636b2882
--- /dev/null
+++ b/doc/guides/vdpadevs/nfp.rst
@@ -0,0 +1,54 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright (c) 2023 Corigine, Inc.
+
+NFP vDPA driver
+===============
+
+The NFP vDPA (vhost data path acceleration) driver (**librte_nfp_vdpa**)
+provides support for the Netronome and Corigine's NFP-6xxx, NFP-4xxx
+and NFP-38xx product lines.
+
+NFP vDPA implementation
+-----------------------
+
+NFP VF device can be configured in the net device or vDPA mode.
+Adding "class=vdpa" parameter helps to specify that this device is to
+be used in vDPA mode. If this parameter is not specified, device
+will be probed by net/nfp driver and will used as a VF net device.
+
+This PMD uses (common/nfp) code to access the device firmware.
+
+Per-Device Parameters
+~~~~~~~~~~~~~~~~~~~~~
+
+The following per-device parameters can be passed via EAL PCI device
+allowlist option like "-a 02:00.0,arg1=value1,...".
+
+- ``class`` [net|vdpa] (default **net**)
+
+  Choose the mode of operation of nfp device.
+  **net** device will work as network device and will be probed by net/nfp driver.
+  **vdpa** device will work as vdpa device and will be probed by vdpa/nfp driver.
+  If this parameter is not specified then nfp device will operate as network device.
+
+Dynamic Logging Parameters
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+One may leverage EAL option "--log-level" to change default levels
+for the log types supported by the driver. The option is used with
+an argument typically consisting of two parts separated by a colon.
+
+Level value is the last part which takes a symbolic name (or integer).
+Log type is the former part which may shell match syntax.
+Depending on the choice of the expression, the given log level may
+be used either for some specific log type or for a subset of types.
+
+NFP vDPA PMD provides the following log types available for control:
+
+- ``pmd.vdpa.nfp.vdpa`` (default level is **notice**)
+
+  Affects driver-wide messages unrelated to any particular devices.
+
+- ``pmd.vdpa.nfp.core`` (default level is **notice**)
+
+  Affects the core logic of this PMD.
diff --git a/drivers/vdpa/meson.build b/drivers/vdpa/meson.build
index 77412c7d09..896e8e0304 100644
--- a/drivers/vdpa/meson.build
+++ b/drivers/vdpa/meson.build
@@ -8,6 +8,7 @@ endif
 drivers = [
         'ifc',
         'mlx5',
+        'nfp',
         'sfc',
 ]
 std_deps = ['bus_pci', 'kvargs']
diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
new file mode 100644
index 0000000000..5eff240055
--- /dev/null
+++ b/drivers/vdpa/nfp/meson.build
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2023 Corigine, Inc.
+
+if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
+    build = false
+    reason = 'only supported on 64-bit Linux'
+endif
+
+sources = files(
+        'nfp_vdpa_log.c',
+)
+
+deps += ['vhost']
diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.c b/drivers/vdpa/nfp/nfp_vdpa_log.c
new file mode 100644
index 0000000000..f5ada20713
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_log.c
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_vdpa_log.h"
+
+RTE_LOG_REGISTER_SUFFIX(nfp_logtype_core, core, NOTICE);
+RTE_LOG_REGISTER_SUFFIX(nfp_logtype_vdpa, vdpa, NOTICE);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_log.h b/drivers/vdpa/nfp/nfp_vdpa_log.h
new file mode 100644
index 0000000000..cf342329b1
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_log.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_VDPA_LOG_H__
+#define __NFP_VDPA_LOG_H__
+
+#include <rte_log.h>
+
+extern int nfp_logtype_vdpa;
+#define DRV_VDPA_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_logtype_vdpa, \
+		"NFP_VDPA: %s(): " fmt "\n", __func__, ## args)
+
+extern int nfp_logtype_core;
+#define DRV_CORE_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, nfp_logtype_core, \
+		"NFP_CORE: %s(): " fmt "\n", __func__, ## args)
+
+#endif /* __NFP_VDPA_LOG_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 19/24] vdpa/nfp: add basic framework
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (17 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 18/24] vdpa/nfp: introduce driver Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 20/24] vdpa/nfp: add remap PCI memory Chaoyong He
                         ` (5 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the basic framework of vDPA PMD.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_pci.c |   1 +
 drivers/common/nfp/nfp_common_pci.h |   1 +
 drivers/vdpa/nfp/meson.build        |   3 +-
 drivers/vdpa/nfp/nfp_vdpa.c         | 153 ++++++++++++++++++++++++++++
 4 files changed, 157 insertions(+), 1 deletion(-)
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa.c

diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
index 65f189b05e..723035d0f7 100644
--- a/drivers/common/nfp/nfp_common_pci.c
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -32,6 +32,7 @@ static const struct {
 	enum nfp_class drv_class;
 } nfp_classes[] = {
 	{ .name = "eth",      .drv_class = NFP_CLASS_ETH },
+	{ .name = "vdpa",     .drv_class = NFP_CLASS_VDPA },
 };
 
 static enum nfp_class
diff --git a/drivers/common/nfp/nfp_common_pci.h b/drivers/common/nfp/nfp_common_pci.h
index 21465fca68..80c027c3a5 100644
--- a/drivers/common/nfp/nfp_common_pci.h
+++ b/drivers/common/nfp/nfp_common_pci.h
@@ -16,6 +16,7 @@ typedef int (nfp_class_driver_remove_t)(struct rte_pci_device *dev);
 
 enum nfp_class {
 	NFP_CLASS_ETH,
+	NFP_CLASS_VDPA,
 	NFP_CLASS_INVALID,
 };
 
diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
index 5eff240055..79a0364917 100644
--- a/drivers/vdpa/nfp/meson.build
+++ b/drivers/vdpa/nfp/meson.build
@@ -7,7 +7,8 @@ if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
 endif
 
 sources = files(
+        'nfp_vdpa.c',
         'nfp_vdpa_log.c',
 )
 
-deps += ['vhost']
+deps += ['vhost', 'common_nfp']
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
new file mode 100644
index 0000000000..ef4ae4946a
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -0,0 +1,153 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include <pthread.h>
+
+#include <nfp_common_pci.h>
+#include <nfp_dev.h>
+#include <vdpa_driver.h>
+
+#include "nfp_vdpa_log.h"
+
+#define NFP_VDPA_DRIVER_NAME nfp_vdpa
+
+struct nfp_vdpa_dev {
+	struct rte_pci_device *pci_dev;
+	struct rte_vdpa_device *vdev;
+};
+
+struct nfp_vdpa_dev_node {
+	TAILQ_ENTRY(nfp_vdpa_dev_node) next;
+	struct nfp_vdpa_dev *device;
+};
+
+TAILQ_HEAD(vdpa_dev_list_head, nfp_vdpa_dev_node);
+
+static struct vdpa_dev_list_head vdpa_dev_list =
+	TAILQ_HEAD_INITIALIZER(vdpa_dev_list);
+
+static pthread_mutex_t vdpa_list_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static struct nfp_vdpa_dev_node *
+nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
+{
+	bool found = false;
+	struct nfp_vdpa_dev_node *node;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+
+	TAILQ_FOREACH(node, &vdpa_dev_list, next) {
+		if (pdev == node->device->pci_dev) {
+			found = true;
+			break;
+		}
+	}
+
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	if (found)
+		return node;
+
+	return NULL;
+}
+
+struct rte_vdpa_dev_ops nfp_vdpa_ops = {
+};
+
+static int
+nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
+{
+	struct nfp_vdpa_dev *device;
+	struct nfp_vdpa_dev_node *node;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	node = calloc(1, sizeof(*node));
+	if (node == NULL)
+		return -ENOMEM;
+
+	device = calloc(1, sizeof(*device));
+	if (device == NULL)
+		goto free_node;
+
+	device->pci_dev = pci_dev;
+
+	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
+	if (device->vdev == NULL) {
+		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
+		goto free_device;
+	}
+
+	node->device = device;
+	pthread_mutex_lock(&vdpa_list_lock);
+	TAILQ_INSERT_TAIL(&vdpa_dev_list, node, next);
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	return 0;
+
+free_device:
+	free(device);
+free_node:
+	free(node);
+
+	return -1;
+}
+
+static int
+nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
+{
+	struct nfp_vdpa_dev *device;
+	struct nfp_vdpa_dev_node *node;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	node = nfp_vdpa_find_node_by_pdev(pci_dev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid device: %s", pci_dev->name);
+		return -ENODEV;
+	}
+
+	device = node->device;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+	TAILQ_REMOVE(&vdpa_dev_list, node, next);
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	rte_vdpa_unregister_device(device->vdev);
+
+	free(device);
+	free(node);
+
+	return 0;
+}
+
+static const struct rte_pci_id pci_id_nfp_vdpa_map[] = {
+	{
+		RTE_PCI_DEVICE(PCI_VENDOR_ID_NETRONOME,
+				PCI_DEVICE_ID_NFP6000_VF_NIC)
+	},
+	{
+		.vendor_id = 0,
+	},
+};
+
+static struct nfp_class_driver nfp_vdpa = {
+	.drv_class = NFP_CLASS_VDPA,
+	.name = RTE_STR(NFP_VDPA_DRIVER_NAME),
+	.id_table = pci_id_nfp_vdpa_map,
+	.drv_flags =  RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+	.probe = nfp_vdpa_pci_probe,
+	.remove = nfp_vdpa_pci_remove,
+};
+
+RTE_INIT(nfp_vdpa_init)
+{
+	nfp_class_driver_register(&nfp_vdpa);
+}
+
+RTE_PMD_REGISTER_PCI_TABLE(NFP_VDPA_DRIVER_NAME, pci_id_nfp_vdpa_map);
+RTE_PMD_REGISTER_KMOD_DEP(NFP_VDPA_DRIVER_NAME, "* vfio-pci");
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 20/24] vdpa/nfp: add remap PCI memory
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (18 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 19/24] vdpa/nfp: add basic framework Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 21/24] vdpa/nfp: add hardware init Chaoyong He
                         ` (4 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the logic of remap PCI memory.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c | 65 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index ef4ae4946a..824b0d681a 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -7,6 +7,7 @@
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
+#include <rte_vfio.h>
 #include <vdpa_driver.h>
 
 #include "nfp_vdpa_log.h"
@@ -16,6 +17,11 @@
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
+
+	int vfio_container_fd;
+	int vfio_group_fd;
+	int vfio_dev_fd;
+	int iommu_group;
 };
 
 struct nfp_vdpa_dev_node {
@@ -53,12 +59,62 @@ nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
 	return NULL;
 }
 
+static int
+nfp_vdpa_vfio_setup(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	char dev_name[RTE_DEV_NAME_MAX_LEN] = {0};
+	struct rte_pci_device *pci_dev = device->pci_dev;
+
+	rte_pci_unmap_device(pci_dev);
+
+	rte_pci_device_name(&pci_dev->addr, dev_name, RTE_DEV_NAME_MAX_LEN);
+	rte_vfio_get_group_num(rte_pci_get_sysfs_path(), dev_name,
+			&device->iommu_group);
+
+	device->vfio_container_fd = rte_vfio_container_create();
+	if (device->vfio_container_fd < 0)
+		return -1;
+
+	device->vfio_group_fd = rte_vfio_container_group_bind(
+			device->vfio_container_fd, device->iommu_group);
+	if (device->vfio_group_fd < 0)
+		goto container_destroy;
+
+	DRV_VDPA_LOG(DEBUG, "container_fd=%d, group_fd=%d,\n",
+			device->vfio_container_fd, device->vfio_group_fd);
+
+	ret = rte_pci_map_device(pci_dev);
+	if (ret != 0)
+		goto group_unbind;
+
+	device->vfio_dev_fd = rte_intr_dev_fd_get(pci_dev->intr_handle);
+
+	return 0;
+
+group_unbind:
+	rte_vfio_container_group_unbind(device->vfio_container_fd, device->iommu_group);
+container_destroy:
+	rte_vfio_container_destroy(device->vfio_container_fd);
+
+	return -1;
+}
+
+static void
+nfp_vdpa_vfio_teardown(struct nfp_vdpa_dev *device)
+{
+	rte_pci_unmap_device(device->pci_dev);
+	rte_vfio_container_group_unbind(device->vfio_container_fd, device->iommu_group);
+	rte_vfio_container_destroy(device->vfio_container_fd);
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
 };
 
 static int
 nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 {
+	int ret;
 	struct nfp_vdpa_dev *device;
 	struct nfp_vdpa_dev_node *node;
 
@@ -75,10 +131,14 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 
 	device->pci_dev = pci_dev;
 
+	ret = nfp_vdpa_vfio_setup(device);
+	if (ret != 0)
+		goto free_device;
+
 	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
 	if (device->vdev == NULL) {
 		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
-		goto free_device;
+		goto vfio_teardown;
 	}
 
 	node->device = device;
@@ -88,6 +148,8 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 
 	return 0;
 
+vfio_teardown:
+	nfp_vdpa_vfio_teardown(device);
 free_device:
 	free(device);
 free_node:
@@ -118,6 +180,7 @@ nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
 	pthread_mutex_unlock(&vdpa_list_lock);
 
 	rte_vdpa_unregister_device(device->vdev);
+	nfp_vdpa_vfio_teardown(device);
 
 	free(device);
 	free(node);
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 21/24] vdpa/nfp: add hardware init
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (19 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 20/24] vdpa/nfp: add remap PCI memory Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  2:59       ` [PATCH v4 22/24] vdpa/nfp: add datapath update Chaoyong He
                         ` (3 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the hardware initialize logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/meson.build     |  1 +
 drivers/vdpa/nfp/nfp_vdpa.c      | 10 ++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c | 54 ++++++++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h | 32 +++++++++++++++++++
 4 files changed, 97 insertions(+)
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.c
 create mode 100644 drivers/vdpa/nfp/nfp_vdpa_core.h

diff --git a/drivers/vdpa/nfp/meson.build b/drivers/vdpa/nfp/meson.build
index 79a0364917..258f3eaaa0 100644
--- a/drivers/vdpa/nfp/meson.build
+++ b/drivers/vdpa/nfp/meson.build
@@ -8,6 +8,7 @@ endif
 
 sources = files(
         'nfp_vdpa.c',
+        'nfp_vdpa_core.c',
         'nfp_vdpa_log.c',
 )
 
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 824b0d681a..00d8f7e007 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -10,6 +10,7 @@
 #include <rte_vfio.h>
 #include <vdpa_driver.h>
 
+#include "nfp_vdpa_core.h"
 #include "nfp_vdpa_log.h"
 
 #define NFP_VDPA_DRIVER_NAME nfp_vdpa
@@ -17,11 +18,14 @@
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_hw hw;
 
 	int vfio_container_fd;
 	int vfio_group_fd;
 	int vfio_dev_fd;
 	int iommu_group;
+
+	uint16_t max_queues;
 };
 
 struct nfp_vdpa_dev_node {
@@ -135,6 +139,12 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 	if (ret != 0)
 		goto free_device;
 
+	ret = nfp_vdpa_hw_init(&device->hw, pci_dev);
+	if (ret != 0)
+		goto vfio_teardown;
+
+	device->max_queues = NFP_VDPA_MAX_QUEUES;
+
 	device->vdev = rte_vdpa_register_device(&pci_dev->device, &nfp_vdpa_ops);
 	if (device->vdev == NULL) {
 		DRV_VDPA_LOG(ERR, "Failed to register device %s", pci_dev->name);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
new file mode 100644
index 0000000000..a7e15fa88a
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_vdpa_core.h"
+
+#include <rte_vhost.h>
+
+#include "nfp_vdpa_log.h"
+
+/* Available and used descs are in same order */
+#ifndef VIRTIO_F_IN_ORDER
+#define VIRTIO_F_IN_ORDER      35
+#endif
+
+int
+nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
+		struct rte_pci_device *pci_dev)
+{
+	uint32_t queue;
+	struct nfp_hw *hw;
+	uint8_t *notify_base;
+
+	hw = &vdpa_hw->super;
+	hw->ctrl_bar = pci_dev->mem_resource[0].addr;
+	if (hw->ctrl_bar == NULL) {
+		DRV_CORE_LOG(ERR, "hw->ctrl_bar is NULL. BAR0 not configured.");
+		return -ENODEV;
+	}
+
+	notify_base = hw->ctrl_bar + NFP_VDPA_NOTIFY_ADDR_BASE;
+	for (queue = 0; queue < NFP_VDPA_MAX_QUEUES; queue++) {
+		uint32_t idx = queue * 2;
+
+		/* RX */
+		vdpa_hw->notify_addr[idx] = notify_base;
+		notify_base += NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+		/* TX */
+		vdpa_hw->notify_addr[idx + 1] = notify_base;
+		notify_base += NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+
+		vdpa_hw->notify_region = queue;
+		DRV_CORE_LOG(DEBUG, "notify_addr[%d] at %p, notify_addr[%d] at %p",
+				idx, vdpa_hw->notify_addr[idx],
+				idx + 1, vdpa_hw->notify_addr[idx + 1]);
+	}
+
+	vdpa_hw->features = (1ULL << VIRTIO_F_VERSION_1) |
+			(1ULL << VIRTIO_F_IN_ORDER) |
+			(1ULL << VHOST_USER_F_PROTOCOL_FEATURES);
+
+	return 0;
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
new file mode 100644
index 0000000000..c9403e0ea4
--- /dev/null
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_VDPA_CORE_H__
+#define __NFP_VDPA_CORE_H__
+
+#include <bus_pci_driver.h>
+#include <nfp_common.h>
+#include <rte_ether.h>
+
+#define NFP_VDPA_MAX_QUEUES         1
+
+#define NFP_VDPA_NOTIFY_ADDR_BASE        0x4000
+#define NFP_VDPA_NOTIFY_ADDR_INTERVAL    0x1000
+
+struct nfp_vdpa_hw {
+	struct nfp_hw super;
+
+	uint64_t features;
+	uint64_t req_features;
+
+	uint8_t *notify_addr[NFP_VDPA_MAX_QUEUES * 2];
+
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+	uint8_t notify_region;
+};
+
+int nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, struct rte_pci_device *dev);
+
+#endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 22/24] vdpa/nfp: add datapath update
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (20 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 21/24] vdpa/nfp: add hardware init Chaoyong He
@ 2023-10-27  2:59       ` Chaoyong He
  2023-10-27  3:00       ` [PATCH v4 23/24] vdpa/nfp: add notify related logic Chaoyong He
                         ` (2 subsequent siblings)
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  2:59 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the vDPA datapath update logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h |   1 +
 drivers/vdpa/nfp/nfp_vdpa.c          | 318 +++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c     |  78 +++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h     |  15 ++
 4 files changed, 412 insertions(+)

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 3c8cd916cf..f92ce50fc0 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -238,6 +238,7 @@ struct nfp_net_fw_ver {
 #define NFP_NET_CFG_CTRL_IPSEC            (0x1 << 1) /**< IPsec offload */
 #define NFP_NET_CFG_CTRL_IPSEC_SM_LOOKUP  (0x1 << 3) /**< SA short match lookup */
 #define NFP_NET_CFG_CTRL_IPSEC_LM_LOOKUP  (0x1 << 4) /**< SA long match lookup */
+#define NFP_NET_CFG_CTRL_IN_ORDER         (0x1 << 11) /**< Virtio in-order flag */
 
 #define NFP_NET_CFG_CAP_WORD1           0x00a4
 
diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 00d8f7e007..04dd29092b 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -4,6 +4,7 @@
  */
 
 #include <pthread.h>
+#include <sys/ioctl.h>
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
@@ -15,6 +16,9 @@
 
 #define NFP_VDPA_DRIVER_NAME nfp_vdpa
 
+#define MSIX_IRQ_SET_BUF_LEN (sizeof(struct vfio_irq_set) + \
+		sizeof(int) * (NFP_VDPA_MAX_QUEUES * 2 + 1))
+
 struct nfp_vdpa_dev {
 	struct rte_pci_device *pci_dev;
 	struct rte_vdpa_device *vdev;
@@ -25,7 +29,15 @@ struct nfp_vdpa_dev {
 	int vfio_dev_fd;
 	int iommu_group;
 
+	int vid;
 	uint16_t max_queues;
+	RTE_ATOMIC(uint32_t) started;
+	RTE_ATOMIC(uint32_t) dev_attached;
+	RTE_ATOMIC(uint32_t) running;
+	rte_spinlock_t lock;
+
+	/** Eventfd for used ring interrupt */
+	int intr_fd[NFP_VDPA_MAX_QUEUES * 2];
 };
 
 struct nfp_vdpa_dev_node {
@@ -112,6 +124,305 @@ nfp_vdpa_vfio_teardown(struct nfp_vdpa_dev *device)
 	rte_vfio_container_destroy(device->vfio_container_fd);
 }
 
+static int
+nfp_vdpa_dma_do_unmap(struct rte_vhost_memory *mem,
+		uint32_t times,
+		int vfio_container_fd)
+{
+	uint32_t i;
+	int ret = 0;
+	struct rte_vhost_mem_region *region;
+
+	for (i = 0; i < times; i++) {
+		region = &mem->regions[i];
+
+		ret = rte_vfio_container_dma_unmap(vfio_container_fd,
+				region->host_user_addr, region->guest_phys_addr,
+				region->size);
+		if (ret < 0) {
+			/* Here should not return, even error happened. */
+			DRV_VDPA_LOG(ERR, "DMA unmap failed. Times: %u", i);
+		}
+	}
+
+	return ret;
+}
+
+static int
+nfp_vdpa_dma_do_map(struct rte_vhost_memory *mem,
+		uint32_t times,
+		int vfio_container_fd)
+{
+	int ret;
+	uint32_t i;
+	struct rte_vhost_mem_region *region;
+
+	for (i = 0; i < times; i++) {
+		region = &mem->regions[i];
+
+		ret = rte_vfio_container_dma_map(vfio_container_fd,
+				region->host_user_addr, region->guest_phys_addr,
+				region->size);
+		if (ret < 0) {
+			DRV_VDPA_LOG(ERR, "DMA map failed.");
+			nfp_vdpa_dma_do_unmap(mem, i, vfio_container_fd);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_dma_map(struct nfp_vdpa_dev *device,
+		bool do_map)
+{
+	int ret;
+	int vfio_container_fd;
+	struct rte_vhost_memory *mem = NULL;
+
+	ret = rte_vhost_get_mem_table(device->vid, &mem);
+	if (ret < 0) {
+		DRV_VDPA_LOG(ERR, "Failed to get memory layout.");
+		return ret;
+	}
+
+	vfio_container_fd = device->vfio_container_fd;
+	DRV_VDPA_LOG(DEBUG, "vfio_container_fd %d", vfio_container_fd);
+
+	if (do_map)
+		ret = nfp_vdpa_dma_do_map(mem, mem->nregions, vfio_container_fd);
+	else
+		ret = nfp_vdpa_dma_do_unmap(mem, mem->nregions, vfio_container_fd);
+
+	free(mem);
+
+	return ret;
+}
+
+static uint64_t
+nfp_vdpa_qva_to_gpa(int vid,
+		uint64_t qva)
+{
+	int ret;
+	uint32_t i;
+	uint64_t gpa = 0;
+	struct rte_vhost_memory *mem = NULL;
+	struct rte_vhost_mem_region *region;
+
+	ret = rte_vhost_get_mem_table(vid, &mem);
+	if (ret < 0) {
+		DRV_VDPA_LOG(ERR, "Failed to get memory layout.");
+		return gpa;
+	}
+
+	for (i = 0; i < mem->nregions; i++) {
+		region = &mem->regions[i];
+
+		if (qva >= region->host_user_addr &&
+				qva < region->host_user_addr + region->size) {
+			gpa = qva - region->host_user_addr + region->guest_phys_addr;
+			break;
+		}
+	}
+
+	free(mem);
+
+	return gpa;
+}
+
+static int
+nfp_vdpa_start(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	int vid;
+	uint16_t i;
+	uint64_t gpa;
+	struct rte_vhost_vring vring;
+	struct nfp_vdpa_hw *vdpa_hw = &device->hw;
+
+	vid = device->vid;
+	vdpa_hw->nr_vring = rte_vhost_get_vring_num(vid);
+
+	ret = rte_vhost_get_negotiated_features(vid, &vdpa_hw->req_features);
+	if (ret != 0)
+		return ret;
+
+	for (i = 0; i < vdpa_hw->nr_vring; i++) {
+		ret = rte_vhost_get_vhost_vring(vid, i, &vring);
+		if (ret != 0)
+			return ret;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.desc);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for descriptor ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].desc = gpa;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.avail);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for available ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].avail = gpa;
+
+		gpa = nfp_vdpa_qva_to_gpa(vid, (uint64_t)(uintptr_t)vring.used);
+		if (gpa == 0) {
+			DRV_VDPA_LOG(ERR, "Fail to get GPA for used ring.");
+			return -1;
+		}
+
+		vdpa_hw->vring[i].used = gpa;
+
+		vdpa_hw->vring[i].size = vring.size;
+
+		ret = rte_vhost_get_vring_base(vid, i,
+				&vdpa_hw->vring[i].last_avail_idx,
+				&vdpa_hw->vring[i].last_used_idx);
+		if (ret != 0)
+			return ret;
+	}
+
+	return nfp_vdpa_hw_start(&device->hw, vid);
+}
+
+static void
+nfp_vdpa_stop(struct nfp_vdpa_dev *device)
+{
+	int vid;
+	uint32_t i;
+	struct nfp_vdpa_hw *vdpa_hw = &device->hw;
+
+	nfp_vdpa_hw_stop(vdpa_hw);
+
+	vid = device->vid;
+	for (i = 0; i < vdpa_hw->nr_vring; i++)
+		rte_vhost_set_vring_base(vid, i,
+				vdpa_hw->vring[i].last_avail_idx,
+				vdpa_hw->vring[i].last_used_idx);
+}
+
+static int
+nfp_vdpa_enable_vfio_intr(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	uint16_t i;
+	int *fd_ptr;
+	uint16_t nr_vring;
+	struct vfio_irq_set *irq_set;
+	struct rte_vhost_vring vring;
+	char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
+
+	nr_vring = rte_vhost_get_vring_num(device->vid);
+
+	irq_set = (struct vfio_irq_set *)irq_set_buf;
+	irq_set->argsz = sizeof(irq_set_buf);
+	irq_set->count = nr_vring + 1;
+	irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;
+	irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
+	irq_set->start = 0;
+
+	fd_ptr = (int *)&irq_set->data;
+	fd_ptr[RTE_INTR_VEC_ZERO_OFFSET] = rte_intr_fd_get(device->pci_dev->intr_handle);
+
+	for (i = 0; i < nr_vring; i++)
+		device->intr_fd[i] = -1;
+
+	for (i = 0; i < nr_vring; i++) {
+		rte_vhost_get_vhost_vring(device->vid, i, &vring);
+		fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = vring.callfd;
+	}
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Error enabling MSI-X interrupts.");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_disable_vfio_intr(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	struct vfio_irq_set *irq_set;
+	char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
+
+	irq_set = (struct vfio_irq_set *)irq_set_buf;
+	irq_set->argsz = sizeof(irq_set_buf);
+	irq_set->count = 0;
+	irq_set->flags = VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_TRIGGER;
+	irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
+	irq_set->start = 0;
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Error disabling MSI-X interrupts.");
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int
+update_datapath(struct nfp_vdpa_dev *device)
+{
+	int ret;
+
+	rte_spinlock_lock(&device->lock);
+
+	if ((rte_atomic_load_explicit(&device->running, rte_memory_order_relaxed) == 0) &&
+			(rte_atomic_load_explicit(&device->started,
+					rte_memory_order_relaxed) != 0) &&
+			(rte_atomic_load_explicit(&device->dev_attached,
+					rte_memory_order_relaxed) != 0)) {
+		ret = nfp_vdpa_dma_map(device, true);
+		if (ret != 0)
+			goto unlock_exit;
+
+		ret = nfp_vdpa_enable_vfio_intr(device);
+		if (ret != 0)
+			goto dma_map_rollback;
+
+		ret = nfp_vdpa_start(device);
+		if (ret != 0)
+			goto disable_vfio_intr;
+
+		rte_atomic_store_explicit(&device->running, 1, rte_memory_order_relaxed);
+	} else if ((rte_atomic_load_explicit(&device->running, rte_memory_order_relaxed) != 0) &&
+			((rte_atomic_load_explicit(&device->started,
+					rte_memory_order_relaxed) != 0) ||
+			(rte_atomic_load_explicit(&device->dev_attached,
+					rte_memory_order_relaxed) != 0))) {
+		nfp_vdpa_stop(device);
+
+		ret = nfp_vdpa_disable_vfio_intr(device);
+		if (ret != 0)
+			goto unlock_exit;
+
+		ret = nfp_vdpa_dma_map(device, false);
+		if (ret != 0)
+			goto unlock_exit;
+
+		rte_atomic_store_explicit(&device->running, 0, rte_memory_order_relaxed);
+	}
+
+	rte_spinlock_unlock(&device->lock);
+	return 0;
+
+disable_vfio_intr:
+	nfp_vdpa_disable_vfio_intr(device);
+dma_map_rollback:
+	nfp_vdpa_dma_map(device, false);
+unlock_exit:
+	rte_spinlock_unlock(&device->lock);
+	return ret;
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
 };
 
@@ -156,6 +467,10 @@ nfp_vdpa_pci_probe(struct rte_pci_device *pci_dev)
 	TAILQ_INSERT_TAIL(&vdpa_dev_list, node, next);
 	pthread_mutex_unlock(&vdpa_list_lock);
 
+	rte_spinlock_init(&device->lock);
+	rte_atomic_store_explicit(&device->started, 1, rte_memory_order_relaxed);
+	update_datapath(device);
+
 	return 0;
 
 vfio_teardown:
@@ -185,6 +500,9 @@ nfp_vdpa_pci_remove(struct rte_pci_device *pci_dev)
 
 	device = node->device;
 
+	rte_atomic_store_explicit(&device->started, 0, rte_memory_order_relaxed);
+	update_datapath(device);
+
 	pthread_mutex_lock(&vdpa_list_lock);
 	TAILQ_REMOVE(&vdpa_dev_list, node, next);
 	pthread_mutex_unlock(&vdpa_list_lock);
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
index a7e15fa88a..db9b8462b4 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.c
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -5,6 +5,7 @@
 
 #include "nfp_vdpa_core.h"
 
+#include <nfp_common.h>
 #include <rte_vhost.h>
 
 #include "nfp_vdpa_log.h"
@@ -52,3 +53,80 @@ nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
 
 	return 0;
 }
+
+static uint32_t
+nfp_vdpa_check_offloads(void)
+{
+	return NFP_NET_CFG_CTRL_SCATTER |
+			NFP_NET_CFG_CTRL_IN_ORDER;
+}
+
+int
+nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw,
+		int vid)
+{
+	int ret;
+	uint32_t update;
+	uint32_t new_ctrl;
+	struct timespec wait_tst;
+	struct nfp_hw *hw = &vdpa_hw->super;
+	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(0), vdpa_hw->vring[1].desc);
+	nn_cfg_writeb(hw, NFP_NET_CFG_TXR_SZ(0), rte_log2_u32(vdpa_hw->vring[1].size));
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(1), vdpa_hw->vring[1].avail);
+	nn_cfg_writeq(hw, NFP_NET_CFG_TXR_ADDR(2), vdpa_hw->vring[1].used);
+
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(0), vdpa_hw->vring[0].desc);
+	nn_cfg_writeb(hw, NFP_NET_CFG_RXR_SZ(0), rte_log2_u32(vdpa_hw->vring[0].size));
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(1), vdpa_hw->vring[0].avail);
+	nn_cfg_writeq(hw, NFP_NET_CFG_RXR_ADDR(2), vdpa_hw->vring[0].used);
+
+	rte_wmb();
+
+	nfp_disable_queues(hw);
+	nfp_enable_queues(hw, NFP_VDPA_MAX_QUEUES, NFP_VDPA_MAX_QUEUES);
+
+	new_ctrl = nfp_vdpa_check_offloads();
+
+	nn_cfg_writel(hw, NFP_NET_CFG_MTU, 9216);
+	nn_cfg_writel(hw, NFP_NET_CFG_FLBUFSZ, 10240);
+
+	/* TODO: Temporary set MAC to fixed value fe:1b:ac:05:a5:22 */
+	mac_addr[0] = 0xfe;
+	mac_addr[1] = 0x1b;
+	mac_addr[2] = 0xac;
+	mac_addr[3] = 0x05;
+	mac_addr[4] = 0xa5;
+	mac_addr[5] = (0x22 + vid);
+
+	/* Writing new MAC to the specific port BAR address */
+	nfp_write_mac(hw, (uint8_t *)mac_addr);
+
+	/* Enable device */
+	new_ctrl |= NFP_NET_CFG_CTRL_ENABLE;
+
+	/* Signal the NIC about the change */
+	update = NFP_NET_CFG_UPDATE_MACADDR |
+			NFP_NET_CFG_UPDATE_GEN |
+			NFP_NET_CFG_UPDATE_RING;
+
+	ret = nfp_reconfig(hw, new_ctrl, update);
+	if (ret < 0)
+		return -EIO;
+
+	hw->ctrl = new_ctrl;
+
+	DRV_CORE_LOG(DEBUG, "Enabling the device, sleep 1 seconds...");
+	wait_tst.tv_sec = 1;
+	wait_tst.tv_nsec = 0;
+	nanosleep(&wait_tst, 0);
+
+	return 0;
+}
+
+void
+nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw)
+{
+	nfp_disable_queues(&vdpa_hw->super);
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
index c9403e0ea4..a88de768dd 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.h
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -15,6 +15,15 @@
 #define NFP_VDPA_NOTIFY_ADDR_BASE        0x4000
 #define NFP_VDPA_NOTIFY_ADDR_INTERVAL    0x1000
 
+struct nfp_vdpa_vring {
+	uint64_t desc;
+	uint64_t avail;
+	uint64_t used;
+	uint16_t size;
+	uint16_t last_avail_idx;
+	uint16_t last_used_idx;
+};
+
 struct nfp_vdpa_hw {
 	struct nfp_hw super;
 
@@ -22,11 +31,17 @@ struct nfp_vdpa_hw {
 	uint64_t req_features;
 
 	uint8_t *notify_addr[NFP_VDPA_MAX_QUEUES * 2];
+	struct nfp_vdpa_vring vring[NFP_VDPA_MAX_QUEUES * 2];
 
 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
 	uint8_t notify_region;
+	uint8_t nr_vring;
 };
 
 int nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw, struct rte_pci_device *dev);
 
+int nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw, int vid);
+
+void nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw);
+
 #endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 23/24] vdpa/nfp: add notify related logic
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (21 preceding siblings ...)
  2023-10-27  2:59       ` [PATCH v4 22/24] vdpa/nfp: add datapath update Chaoyong He
@ 2023-10-27  3:00       ` Chaoyong He
  2023-10-27  3:00       ` [PATCH v4 24/24] vdpa/nfp: add device operations Chaoyong He
  2023-10-27 13:38       ` [PATCH v4 00/24] add the NFP vDPA PMD Ferruh Yigit
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  3:00 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Add the logic to process vDPA notify relay.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c      | 155 +++++++++++++++++++++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.c |  61 ++++++++++++
 drivers/vdpa/nfp/nfp_vdpa_core.h |   4 +
 3 files changed, 220 insertions(+)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 04dd29092b..c104588663 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -4,7 +4,9 @@
  */
 
 #include <pthread.h>
+#include <sys/epoll.h>
 #include <sys/ioctl.h>
+#include <unistd.h>
 
 #include <nfp_common_pci.h>
 #include <nfp_dev.h>
@@ -29,6 +31,9 @@ struct nfp_vdpa_dev {
 	int vfio_dev_fd;
 	int iommu_group;
 
+	rte_thread_t tid;    /**< Thread for notify relay */
+	int epoll_fd;
+
 	int vid;
 	uint16_t max_queues;
 	RTE_ATOMIC(uint32_t) started;
@@ -368,6 +373,148 @@ nfp_vdpa_disable_vfio_intr(struct nfp_vdpa_dev *device)
 	return 0;
 }
 
+static void
+nfp_vdpa_read_kickfd(int kickfd)
+{
+	int bytes;
+	uint64_t buf;
+
+	for (;;) {
+		bytes = read(kickfd, &buf, 8);
+		if (bytes >= 0)
+			break;
+
+		if (errno != EINTR && errno != EWOULDBLOCK &&
+				errno != EAGAIN) {
+			DRV_VDPA_LOG(ERR, "Error reading kickfd");
+			break;
+		}
+	}
+}
+
+static int
+nfp_vdpa_notify_epoll_ctl(uint32_t queue_num,
+		struct nfp_vdpa_dev *device)
+{
+	int ret;
+	uint32_t qid;
+
+	for (qid = 0; qid < queue_num; qid++) {
+		struct epoll_event ev;
+		struct rte_vhost_vring vring;
+
+		ev.events = EPOLLIN | EPOLLPRI;
+		rte_vhost_get_vhost_vring(device->vid, qid, &vring);
+		ev.data.u64 = qid | (uint64_t)vring.kickfd << 32;
+		ret = epoll_ctl(device->epoll_fd, EPOLL_CTL_ADD, vring.kickfd, &ev);
+		if (ret < 0) {
+			DRV_VDPA_LOG(ERR, "Epoll add error for queue %d", qid);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int
+nfp_vdpa_notify_epoll_wait(uint32_t queue_num,
+		struct nfp_vdpa_dev *device)
+{
+	int i;
+	int fds;
+	int kickfd;
+	uint32_t qid;
+	struct epoll_event events[NFP_VDPA_MAX_QUEUES * 2];
+
+	for (;;) {
+		fds = epoll_wait(device->epoll_fd, events, queue_num, -1);
+		if (fds < 0) {
+			if (errno == EINTR)
+				continue;
+
+			DRV_VDPA_LOG(ERR, "Epoll wait fail");
+			return -EACCES;
+		}
+
+		for (i = 0; i < fds; i++) {
+			qid = events[i].data.u32;
+			kickfd = (uint32_t)(events[i].data.u64 >> 32);
+
+			nfp_vdpa_read_kickfd(kickfd);
+			nfp_vdpa_notify_queue(&device->hw, qid);
+		}
+	}
+
+	return 0;
+}
+
+static uint32_t
+nfp_vdpa_notify_relay(void *arg)
+{
+	int ret;
+	int epoll_fd;
+	uint32_t queue_num;
+	struct nfp_vdpa_dev *device = arg;
+
+	epoll_fd = epoll_create(NFP_VDPA_MAX_QUEUES * 2);
+	if (epoll_fd < 0) {
+		DRV_VDPA_LOG(ERR, "failed to create epoll instance.");
+		return 1;
+	}
+
+	device->epoll_fd = epoll_fd;
+
+	queue_num = rte_vhost_get_vring_num(device->vid);
+
+	ret = nfp_vdpa_notify_epoll_ctl(queue_num, device);
+	if (ret != 0)
+		goto notify_exit;
+
+	ret = nfp_vdpa_notify_epoll_wait(queue_num, device);
+	if (ret != 0)
+		goto notify_exit;
+
+	return 0;
+
+notify_exit:
+	close(device->epoll_fd);
+	device->epoll_fd = -1;
+
+	return 1;
+}
+
+static int
+nfp_vdpa_setup_notify_relay(struct nfp_vdpa_dev *device)
+{
+	int ret;
+	char name[RTE_THREAD_INTERNAL_NAME_SIZE];
+
+	snprintf(name, sizeof(name), "nfp-noti%d", device->vid);
+	ret = rte_thread_create_internal_control(&device->tid, name,
+			nfp_vdpa_notify_relay, (void *)device);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Failed to create notify relay pthread.");
+		return -1;
+	}
+
+	return 0;
+}
+
+static void
+nfp_vdpa_unset_notify_relay(struct nfp_vdpa_dev *device)
+{
+	if (device->tid.opaque_id != 0) {
+		pthread_cancel((pthread_t)device->tid.opaque_id);
+		rte_thread_join(device->tid, NULL);
+		device->tid.opaque_id = 0;
+	}
+
+	if (device->epoll_fd >= 0) {
+		close(device->epoll_fd);
+		device->epoll_fd = -1;
+	}
+}
+
 static int
 update_datapath(struct nfp_vdpa_dev *device)
 {
@@ -392,12 +539,18 @@ update_datapath(struct nfp_vdpa_dev *device)
 		if (ret != 0)
 			goto disable_vfio_intr;
 
+		ret = nfp_vdpa_setup_notify_relay(device);
+		if (ret != 0)
+			goto vdpa_stop;
+
 		rte_atomic_store_explicit(&device->running, 1, rte_memory_order_relaxed);
 	} else if ((rte_atomic_load_explicit(&device->running, rte_memory_order_relaxed) != 0) &&
 			((rte_atomic_load_explicit(&device->started,
 					rte_memory_order_relaxed) != 0) ||
 			(rte_atomic_load_explicit(&device->dev_attached,
 					rte_memory_order_relaxed) != 0))) {
+		nfp_vdpa_unset_notify_relay(device);
+
 		nfp_vdpa_stop(device);
 
 		ret = nfp_vdpa_disable_vfio_intr(device);
@@ -414,6 +567,8 @@ update_datapath(struct nfp_vdpa_dev *device)
 	rte_spinlock_unlock(&device->lock);
 	return 0;
 
+vdpa_stop:
+	nfp_vdpa_stop(device);
 disable_vfio_intr:
 	nfp_vdpa_disable_vfio_intr(device);
 dma_map_rollback:
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.c b/drivers/vdpa/nfp/nfp_vdpa_core.c
index db9b8462b4..e2a6253ae5 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.c
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.c
@@ -15,6 +15,41 @@
 #define VIRTIO_F_IN_ORDER      35
 #endif
 
+#define NFP_QCP_NOTIFY_MAX_ADD    0x7f
+
+enum nfp_qcp_notify_ptr {
+	NFP_QCP_NOTIFY_WRITE_PTR = 0,
+	NFP_QCP_NOTIFY_READ_PTR
+};
+
+/**
+ * Add the value to the selected pointer of a queue
+ *
+ * @param queue
+ *   Base address for queue structure
+ * @param ptr
+ *   Add to the Read or Write pointer
+ * @param val
+ *   Value to add to the queue pointer
+ */
+static inline void
+nfp_qcp_notify_ptr_add(uint8_t *q,
+		enum nfp_qcp_notify_ptr ptr,
+		uint32_t val)
+{
+	uint32_t off;
+
+	if (ptr == NFP_QCP_NOTIFY_WRITE_PTR)
+		off = NFP_QCP_QUEUE_ADD_RPTR;
+	else
+		off = NFP_QCP_QUEUE_ADD_WPTR;
+
+	for (; val > NFP_QCP_NOTIFY_MAX_ADD; val -= NFP_QCP_NOTIFY_MAX_ADD)
+		nn_writel(rte_cpu_to_le_32(NFP_QCP_NOTIFY_MAX_ADD), q + off);
+
+	nn_writel(rte_cpu_to_le_32(val), q + off);
+}
+
 int
 nfp_vdpa_hw_init(struct nfp_vdpa_hw *vdpa_hw,
 		struct rte_pci_device *pci_dev)
@@ -130,3 +165,29 @@ nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw)
 {
 	nfp_disable_queues(&vdpa_hw->super);
 }
+
+/*
+ * This offset is used for mmaping the notify area. It implies it needs
+ * to be a multiple of PAGE_SIZE.
+ * For debugging, using notify region 0 with an offset of 4K. This should
+ * point to the conf bar.
+ */
+uint64_t
+nfp_vdpa_get_queue_notify_offset(struct nfp_vdpa_hw *vdpa_hw __rte_unused,
+		int qid)
+{
+	return NFP_VDPA_NOTIFY_ADDR_BASE + (qid * NFP_VDPA_NOTIFY_ADDR_INTERVAL);
+}
+
+/*
+ * With just one queue the increment is 0, which does not
+ * incremente the counter but will raise a queue event due
+ * to queue configured for watermark events.
+ */
+void
+nfp_vdpa_notify_queue(struct nfp_vdpa_hw *vdpa_hw,
+		uint16_t qid)
+{
+	nfp_qcp_notify_ptr_add(vdpa_hw->notify_addr[qid],
+			NFP_QCP_NOTIFY_WRITE_PTR, qid);
+}
diff --git a/drivers/vdpa/nfp/nfp_vdpa_core.h b/drivers/vdpa/nfp/nfp_vdpa_core.h
index a88de768dd..a8e0d6dd70 100644
--- a/drivers/vdpa/nfp/nfp_vdpa_core.h
+++ b/drivers/vdpa/nfp/nfp_vdpa_core.h
@@ -44,4 +44,8 @@ int nfp_vdpa_hw_start(struct nfp_vdpa_hw *vdpa_hw, int vid);
 
 void nfp_vdpa_hw_stop(struct nfp_vdpa_hw *vdpa_hw);
 
+void nfp_vdpa_notify_queue(struct nfp_vdpa_hw *vdpa_hw, uint16_t qid);
+
+uint64_t nfp_vdpa_get_queue_notify_offset(struct nfp_vdpa_hw *vdpa_hw, int qid);
+
 #endif /* __NFP_VDPA_CORE_H__ */
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* [PATCH v4 24/24] vdpa/nfp: add device operations
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (22 preceding siblings ...)
  2023-10-27  3:00       ` [PATCH v4 23/24] vdpa/nfp: add notify related logic Chaoyong He
@ 2023-10-27  3:00       ` Chaoyong He
  2023-10-27 13:38       ` [PATCH v4 00/24] add the NFP vDPA PMD Ferruh Yigit
  24 siblings, 0 replies; 121+ messages in thread
From: Chaoyong He @ 2023-10-27  3:00 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Shujing Dong, Long Wu, Peng Zhang

Implement the corresponding nfp vDPA operation functions.

Signed-off-by: Shujing Dong <shujing.dong@corigine.com>
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/vdpa/nfp/nfp_vdpa.c | 213 ++++++++++++++++++++++++++++++++++++
 1 file changed, 213 insertions(+)

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index c104588663..a1d1dc4f73 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -57,6 +57,29 @@ static struct vdpa_dev_list_head vdpa_dev_list =
 
 static pthread_mutex_t vdpa_list_lock = PTHREAD_MUTEX_INITIALIZER;
 
+static struct nfp_vdpa_dev_node *
+nfp_vdpa_find_node_by_vdev(struct rte_vdpa_device *vdev)
+{
+	bool found = false;
+	struct nfp_vdpa_dev_node *node;
+
+	pthread_mutex_lock(&vdpa_list_lock);
+
+	TAILQ_FOREACH(node, &vdpa_dev_list, next) {
+		if (vdev == node->device->vdev) {
+			found = true;
+			break;
+		}
+	}
+
+	pthread_mutex_unlock(&vdpa_list_lock);
+
+	if (found)
+		return node;
+
+	return NULL;
+}
+
 static struct nfp_vdpa_dev_node *
 nfp_vdpa_find_node_by_pdev(struct rte_pci_device *pdev)
 {
@@ -578,7 +601,197 @@ update_datapath(struct nfp_vdpa_dev *device)
 	return ret;
 }
 
+static int
+nfp_vdpa_dev_config(int vid)
+{
+	int ret;
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	device->vid = vid;
+	rte_atomic_store_explicit(&device->dev_attached, 1, rte_memory_order_relaxed);
+	update_datapath(device);
+
+	ret = rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true);
+	if (ret != 0)
+		DRV_VDPA_LOG(INFO, "vDPA (%s): software relay is used.",
+				vdev->device->name);
+
+	return 0;
+}
+
+static int
+nfp_vdpa_dev_close(int vid)
+{
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	rte_atomic_store_explicit(&device->dev_attached, 0, rte_memory_order_relaxed);
+	update_datapath(device);
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_vfio_group_fd(int vid)
+{
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	return node->device->vfio_group_fd;
+}
+
+static int
+nfp_vdpa_get_vfio_device_fd(int vid)
+{
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	return node->device->vfio_dev_fd;
+}
+
+static int
+nfp_vdpa_get_notify_area(int vid,
+		int qid,
+		uint64_t *offset,
+		uint64_t *size)
+{
+	int ret;
+	struct nfp_vdpa_dev *device;
+	struct rte_vdpa_device *vdev;
+	struct nfp_vdpa_dev_node *node;
+	struct vfio_region_info region = {
+		.argsz = sizeof(region)
+	};
+
+	vdev = rte_vhost_get_vdpa_device(vid);
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR,  "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	device = node->device;
+	region.index = device->hw.notify_region;
+
+	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, &region);
+	if (ret != 0) {
+		DRV_VDPA_LOG(ERR, "Get not get device region info.");
+		return -EIO;
+	}
+
+	*offset = nfp_vdpa_get_queue_notify_offset(&device->hw, qid) + region.offset;
+	*size = NFP_VDPA_NOTIFY_ADDR_INTERVAL;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_queue_num(struct rte_vdpa_device *vdev,
+		uint32_t *queue_num)
+{
+	struct nfp_vdpa_dev_node *node;
+
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	*queue_num = node->device->max_queues;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_vdpa_features(struct rte_vdpa_device *vdev,
+		uint64_t *features)
+{
+	struct nfp_vdpa_dev_node *node;
+
+	node = nfp_vdpa_find_node_by_vdev(vdev);
+	if (node == NULL) {
+		DRV_VDPA_LOG(ERR,  "Invalid vDPA device: %p", vdev);
+		return -ENODEV;
+	}
+
+	*features = node->device->hw.features;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_get_protocol_features(struct rte_vdpa_device *vdev __rte_unused,
+		uint64_t *features)
+{
+	*features = 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD |
+			1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK |
+			1ULL << VHOST_USER_PROTOCOL_F_BACKEND_REQ |
+			1ULL << VHOST_USER_PROTOCOL_F_BACKEND_SEND_FD |
+			1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER;
+
+	return 0;
+}
+
+static int
+nfp_vdpa_set_features(int32_t vid)
+{
+	DRV_VDPA_LOG(DEBUG, "Start vid=%d", vid);
+	return 0;
+}
+
+static int
+nfp_vdpa_set_vring_state(int vid,
+		int vring,
+		int state)
+{
+	DRV_VDPA_LOG(DEBUG, "Start vid=%d, vring=%d, state=%d", vid, vring, state);
+	return 0;
+}
+
 struct rte_vdpa_dev_ops nfp_vdpa_ops = {
+	.get_queue_num = nfp_vdpa_get_queue_num,
+	.get_features = nfp_vdpa_get_vdpa_features,
+	.get_protocol_features = nfp_vdpa_get_protocol_features,
+	.dev_conf = nfp_vdpa_dev_config,
+	.dev_close = nfp_vdpa_dev_close,
+	.set_vring_state = nfp_vdpa_set_vring_state,
+	.set_features = nfp_vdpa_set_features,
+	.get_vfio_group_fd = nfp_vdpa_get_vfio_group_fd,
+	.get_vfio_device_fd = nfp_vdpa_get_vfio_device_fd,
+	.get_notify_area = nfp_vdpa_get_notify_area,
 };
 
 static int
-- 
2.39.1


^ permalink raw reply	[flat|nested] 121+ messages in thread

* Re: [PATCH v4 00/24] add the NFP vDPA PMD
  2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
                         ` (23 preceding siblings ...)
  2023-10-27  3:00       ` [PATCH v4 24/24] vdpa/nfp: add device operations Chaoyong He
@ 2023-10-27 13:38       ` Ferruh Yigit
  24 siblings, 0 replies; 121+ messages in thread
From: Ferruh Yigit @ 2023-10-27 13:38 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers

On 10/27/2023 3:59 AM, Chaoyong He wrote:
> This patch series aims to add the NFP vDPA PMD, we also grab the common
> logic into the `drivers/common/nfp` directory.
> 
> ---
> v4:
> * Try to fix compile error in clang environment.
> * Merge the modify of release notes into suitable commit.
> * Rewrite the commit headline as the advise of reviewer.
> v3:
> * Replace 'pthread_xxx' API with 'rte_thread_xxx' API.
> * Replace '__atomic_xxx' built-ins with 'rte_atomic_xxx'.
> * Drop the check statement in meson.build file which prevent build of
>   PMD.
> * Fix a problem about the logtype prefix.
> * Move the document modification to the commit which should be.
> v2:
> * Grab more logic into the `drivers/common/nfp` directory.
> * Delete some logic which should be when moving logic.
> ---
> 
> Chaoyong He (24):
>   common/nfp: introduce driver
>   net/nfp: make VF PMD use NFP common driver
>   net/nfp: rename net common module
>   net/nfp: rename ctrl module
>   net/nfp: extract cap data field
>   net/nfp: extract qcp data field
>   net/nfp: extract ctrl BAR data field
>   net/nfp: extract ctrl data field
>   net/nfp: change parameter of functions
>   net/nfp: change parameter of reconfig
>   net/nfp: extract MAC address data field
>   net/nfp: rename parameter in related logic
>   common/nfp: add common ctrl module
>   common/nfp: add common module
>   common/nfp: move queue logic
>   common/nfp: move platform module
>   common/nfp: move device module
>   vdpa/nfp: introduce driver
>   vdpa/nfp: add basic framework
>   vdpa/nfp: add remap PCI memory
>   vdpa/nfp: add hardware init
>   vdpa/nfp: add datapath update
>   vdpa/nfp: add notify related logic
>   vdpa/nfp: add device operations
> 

Series applied to dpdk-next-net/main, thanks.


Need to resolve conflict on 'nfp_net_supported_ptypes_get()' because of
previous patch merged, can you please double check if the final output
is good.


^ permalink raw reply	[flat|nested] 121+ messages in thread

end of thread, other threads:[~2023-10-27 13:38 UTC | newest]

Thread overview: 121+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-17  5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
2023-10-17  5:45 ` [PATCH 01/25] drivers: introduce the NFP common library Chaoyong He
2023-10-17  5:45 ` [PATCH 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
2023-10-17  5:45 ` [PATCH 03/25] net/nfp: rename common module name Chaoyong He
2023-10-17  5:45 ` [PATCH 04/25] net/nfp: rename ctrl " Chaoyong He
2023-10-17  5:45 ` [PATCH 05/25] net/nfp: extract the cap data field Chaoyong He
2023-10-17  5:45 ` [PATCH 06/25] net/nfp: extract the qcp " Chaoyong He
2023-10-17  5:45 ` [PATCH 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
2023-10-17  5:45 ` [PATCH 08/25] net/nfp: extract the ctrl " Chaoyong He
2023-10-17  5:45 ` [PATCH 09/25] net/nfp: change the parameter of APIs Chaoyong He
2023-10-17  5:45 ` [PATCH 10/25] net/nfp: change the parameter of reconfig Chaoyong He
2023-10-17  5:45 ` [PATCH 11/25] net/nfp: extract the MAC address data field Chaoyong He
2023-10-17  5:45 ` [PATCH 12/25] net/nfp: rename parameter in related logic Chaoyong He
2023-10-17  5:45 ` [PATCH 13/25] drivers: add the common ctrl module Chaoyong He
2023-10-17  5:45 ` [PATCH 14/25] drivers: add the nfp common module Chaoyong He
2023-10-17  5:45 ` [PATCH 15/25] drivers: move queue logic to " Chaoyong He
2023-10-17  5:45 ` [PATCH 16/25] drivers: move platform module to common library Chaoyong He
2023-10-17  5:45 ` [PATCH 17/25] drivers: move device " Chaoyong He
2023-10-17  5:45 ` [PATCH 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
2023-10-17  5:45 ` [PATCH 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
2023-10-17  5:45 ` [PATCH 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
2023-10-17  5:45 ` [PATCH 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
2023-10-17  5:45 ` [PATCH 22/25] drivers: add the datapath update logic Chaoyong He
2023-10-17  5:45 ` [PATCH 23/25] vdpa/nfp: add the notify related logic Chaoyong He
2023-10-17  5:45 ` [PATCH 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
2023-10-17  5:45 ` [PATCH 25/25] doc: add the common and vDPA document Chaoyong He
2023-10-24  2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
2023-10-24  2:28   ` [PATCH v2 01/25] drivers: introduce the NFP common library Chaoyong He
2023-10-24  2:28   ` [PATCH v2 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
2023-10-25 16:09     ` Ferruh Yigit
2023-10-26  1:34       ` Chaoyong He
2023-10-24  2:28   ` [PATCH v2 03/25] net/nfp: rename common module name Chaoyong He
2023-10-24  2:28   ` [PATCH v2 04/25] net/nfp: rename ctrl " Chaoyong He
2023-10-24  2:28   ` [PATCH v2 05/25] net/nfp: extract the cap data field Chaoyong He
2023-10-24  2:28   ` [PATCH v2 06/25] net/nfp: extract the qcp " Chaoyong He
2023-10-24  2:28   ` [PATCH v2 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
2023-10-24  2:28   ` [PATCH v2 08/25] net/nfp: extract the ctrl " Chaoyong He
2023-10-24  2:28   ` [PATCH v2 09/25] net/nfp: change the parameter of APIs Chaoyong He
2023-10-24  2:28   ` [PATCH v2 10/25] net/nfp: change the parameter of reconfig Chaoyong He
2023-10-24  2:28   ` [PATCH v2 11/25] net/nfp: extract the MAC address data field Chaoyong He
2023-10-24  2:28   ` [PATCH v2 12/25] net/nfp: rename parameter in related logic Chaoyong He
2023-10-24  2:28   ` [PATCH v2 13/25] drivers: add the common ctrl module Chaoyong He
2023-10-24  2:28   ` [PATCH v2 14/25] drivers: add the nfp common module Chaoyong He
2023-10-24  2:28   ` [PATCH v2 15/25] drivers: move queue logic to " Chaoyong He
2023-10-24  2:28   ` [PATCH v2 16/25] drivers: move platform module to common library Chaoyong He
2023-10-24  2:28   ` [PATCH v2 17/25] drivers: move device " Chaoyong He
2023-10-24  2:28   ` [PATCH v2 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
2023-10-25 16:09     ` Ferruh Yigit
2023-10-26  1:39       ` Chaoyong He
2023-10-24  2:28   ` [PATCH v2 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
2023-10-25 16:10     ` Ferruh Yigit
2023-10-26  1:39       ` Chaoyong He
2023-10-24  2:28   ` [PATCH v2 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
2023-10-24  2:28   ` [PATCH v2 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
2023-10-24  2:28   ` [PATCH v2 22/25] drivers: add the datapath update logic Chaoyong He
2023-10-24  2:28   ` [PATCH v2 23/25] vdpa/nfp: add the notify related logic Chaoyong He
2023-10-24  2:28   ` [PATCH v2 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
2023-10-24  2:28   ` [PATCH v2 25/25] doc: add the common and vDPA document Chaoyong He
2023-10-25 16:11     ` Ferruh Yigit
2023-10-26  1:41       ` Chaoyong He
2023-10-25 16:09   ` [PATCH v2 00/25] add the NFP vDPA PMD Ferruh Yigit
2023-10-26  1:33     ` Chaoyong He
2023-10-26  2:50       ` Chaoyong He
2023-10-26 11:30         ` Ferruh Yigit
2023-10-26 11:33           ` Chaoyong He
2023-10-26  6:42   ` [PATCH v3 " Chaoyong He
2023-10-26  6:43     ` [PATCH v3 01/25] drivers: introduce the NFP common library Chaoyong He
2023-10-26  6:43     ` [PATCH v3 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
2023-10-26  6:43     ` [PATCH v3 03/25] net/nfp: rename common module name Chaoyong He
2023-10-26  6:43     ` [PATCH v3 04/25] net/nfp: rename ctrl " Chaoyong He
2023-10-26  6:43     ` [PATCH v3 05/25] net/nfp: extract the cap data field Chaoyong He
2023-10-26  6:43     ` [PATCH v3 06/25] net/nfp: extract the qcp " Chaoyong He
2023-10-26  6:43     ` [PATCH v3 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
2023-10-26  6:43     ` [PATCH v3 08/25] net/nfp: extract the ctrl " Chaoyong He
2023-10-26  6:43     ` [PATCH v3 09/25] net/nfp: change the parameter of APIs Chaoyong He
2023-10-26  6:43     ` [PATCH v3 10/25] net/nfp: change the parameter of reconfig Chaoyong He
2023-10-26  6:43     ` [PATCH v3 11/25] net/nfp: extract the MAC address data field Chaoyong He
2023-10-26  6:43     ` [PATCH v3 12/25] net/nfp: rename parameter in related logic Chaoyong He
2023-10-26  6:43     ` [PATCH v3 13/25] drivers: add the common ctrl module Chaoyong He
2023-10-26  6:43     ` [PATCH v3 14/25] drivers: add the nfp common module Chaoyong He
2023-10-26  6:43     ` [PATCH v3 15/25] drivers: move queue logic to " Chaoyong He
2023-10-26  6:43     ` [PATCH v3 16/25] drivers: move platform module to common library Chaoyong He
2023-10-26  6:43     ` [PATCH v3 17/25] drivers: move device " Chaoyong He
2023-10-26  6:43     ` [PATCH v3 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
2023-10-26  6:43     ` [PATCH v3 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
2023-10-26  6:43     ` [PATCH v3 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
2023-10-26  6:43     ` [PATCH v3 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
2023-10-26  6:43     ` [PATCH v3 22/25] drivers: add the datapath update logic Chaoyong He
2023-10-26  6:43     ` [PATCH v3 23/25] vdpa/nfp: add the notify related logic Chaoyong He
2023-10-26  6:43     ` [PATCH v3 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
2023-10-26  6:43     ` [PATCH v3 25/25] doc: add a entry in the release notes Chaoyong He
2023-10-26 14:55       ` Ferruh Yigit
2023-10-26 14:47     ` [PATCH v3 00/25] add the NFP vDPA PMD Ferruh Yigit
2023-10-26 14:55     ` Ferruh Yigit
2023-10-27  1:23       ` Chaoyong He
2023-10-27  2:59     ` [PATCH v4 00/24] " Chaoyong He
2023-10-27  2:59       ` [PATCH v4 01/24] common/nfp: introduce driver Chaoyong He
2023-10-27  2:59       ` [PATCH v4 02/24] net/nfp: make VF PMD use NFP common driver Chaoyong He
2023-10-27  2:59       ` [PATCH v4 03/24] net/nfp: rename net common module Chaoyong He
2023-10-27  2:59       ` [PATCH v4 04/24] net/nfp: rename ctrl module Chaoyong He
2023-10-27  2:59       ` [PATCH v4 05/24] net/nfp: extract cap data field Chaoyong He
2023-10-27  2:59       ` [PATCH v4 06/24] net/nfp: extract qcp " Chaoyong He
2023-10-27  2:59       ` [PATCH v4 07/24] net/nfp: extract ctrl BAR " Chaoyong He
2023-10-27  2:59       ` [PATCH v4 08/24] net/nfp: extract ctrl " Chaoyong He
2023-10-27  2:59       ` [PATCH v4 09/24] net/nfp: change parameter of functions Chaoyong He
2023-10-27  2:59       ` [PATCH v4 10/24] net/nfp: change parameter of reconfig Chaoyong He
2023-10-27  2:59       ` [PATCH v4 11/24] net/nfp: extract MAC address data field Chaoyong He
2023-10-27  2:59       ` [PATCH v4 12/24] net/nfp: rename parameter in related logic Chaoyong He
2023-10-27  2:59       ` [PATCH v4 13/24] common/nfp: add common ctrl module Chaoyong He
2023-10-27  2:59       ` [PATCH v4 14/24] common/nfp: add common module Chaoyong He
2023-10-27  2:59       ` [PATCH v4 15/24] common/nfp: move queue logic Chaoyong He
2023-10-27  2:59       ` [PATCH v4 16/24] common/nfp: move platform module Chaoyong He
2023-10-27  2:59       ` [PATCH v4 17/24] common/nfp: move device module Chaoyong He
2023-10-27  2:59       ` [PATCH v4 18/24] vdpa/nfp: introduce driver Chaoyong He
2023-10-27  2:59       ` [PATCH v4 19/24] vdpa/nfp: add basic framework Chaoyong He
2023-10-27  2:59       ` [PATCH v4 20/24] vdpa/nfp: add remap PCI memory Chaoyong He
2023-10-27  2:59       ` [PATCH v4 21/24] vdpa/nfp: add hardware init Chaoyong He
2023-10-27  2:59       ` [PATCH v4 22/24] vdpa/nfp: add datapath update Chaoyong He
2023-10-27  3:00       ` [PATCH v4 23/24] vdpa/nfp: add notify related logic Chaoyong He
2023-10-27  3:00       ` [PATCH v4 24/24] vdpa/nfp: add device operations Chaoyong He
2023-10-27 13:38       ` [PATCH v4 00/24] add the NFP vDPA PMD Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).