DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC 0/6] Preview of a big eal/ethdev cleanup
@ 2016-01-18 16:03 Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 1/6] eal: introduce rte_bus_device and rte_bus_driver Jan Viktorin
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jan Viktorin @ 2016-01-18 16:03 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Hello,

based on the recent discussions [1], I have prepared a little preview of
patches reflecting the basic ideas. That is:

* generalization of device and driver structures
* embedding a generic device and driver structure in the bus-specific ones
* moving some members from PCI-specific structures to the generic ones
* introduction of the container_of macro

The code compiles for x86_64/linux/gcc, however, I didn't try any runtime yet.

[1] http://dpdk.org/ml/archives/dev/2016-January/031390.html

Regards
Jan

---

Jan Viktorin (6):
  eal: introduce rte_bus_device and rte_bus_driver
  eal: define macro container_of
  eal: move devargs from rte_pci_device to rte_device
  eal: move numa_node from rte_pci_device to rte_device
  eal: move intr_handle from rte_pci_device to rte_device
  eal: move driver pointer from rte_pci_device to rte_bus_device

 app/test/virtual_pmd.c                     |  4 +--
 drivers/net/e1000/em_ethdev.c              | 14 +++++-----
 drivers/net/e1000/igb_ethdev.c             | 24 ++++++++---------
 drivers/net/enic/enic_main.c               |  4 +--
 drivers/net/fm10k/fm10k_ethdev.c           | 16 ++++++------
 drivers/net/i40e/i40e_ethdev.c             | 32 +++++++++++------------
 drivers/net/i40e/i40e_ethdev_vf.c          | 16 ++++++------
 drivers/net/ixgbe/ixgbe_ethdev.c           | 28 ++++++++++----------
 drivers/net/virtio/virtio_ethdev.c         | 41 ++++++++++++++++++------------
 lib/librte_cryptodev/rte_cryptodev.c       |  3 ++-
 lib/librte_eal/bsdapp/eal/eal_pci.c        | 16 ++++++------
 lib/librte_eal/common/eal_common_pci.c     | 14 +++++-----
 lib/librte_eal/common/eal_common_pci_uio.c | 18 ++++++-------
 lib/librte_eal/common/include/rte_common.h | 16 ++++++++++++
 lib/librte_eal/common/include/rte_dev.h    | 15 +++++++++++
 lib/librte_eal/common/include/rte_pci.h    | 10 +++++---
 lib/librte_eal/linuxapp/eal/eal_pci.c      |  8 +++---
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c  | 28 ++++++++++----------
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 14 +++++-----
 lib/librte_ether/rte_ethdev.c              | 16 +++++++-----
 20 files changed, 191 insertions(+), 146 deletions(-)

-- 
2.7.0

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

* [dpdk-dev] [RFC 1/6] eal: introduce rte_bus_device and rte_bus_driver
  2016-01-18 16:03 [dpdk-dev] [RFC 0/6] Preview of a big eal/ethdev cleanup Jan Viktorin
@ 2016-01-18 16:03 ` Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 2/6] eal: define macro container_of Jan Viktorin
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jan Viktorin @ 2016-01-18 16:03 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Define a general represenation of a device and driver in DPDK. The goal is to
get rid of the deep dependency on the PCI. Higher level code should not
reference the bus-specific structures as it does not need to.

PCI infrastructure embeds those structures. Other infrastructures will do the
same.

Suggested-by: David Marchand <david.marchand@6wind.com>
Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_eal/common/include/rte_dev.h | 9 +++++++++
 lib/librte_eal/common/include/rte_pci.h | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index f1b5507..b779705 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -50,6 +50,7 @@ extern "C" {
 #include <sys/queue.h>
 
 #include <rte_log.h>
+#include <rte_interrupts.h>
 
 __attribute__((format(printf, 2, 0)))
 static inline void
@@ -151,6 +152,14 @@ void rte_eal_driver_register(struct rte_driver *driver);
  */
 void rte_eal_driver_unregister(struct rte_driver *driver);
 
+struct rte_bus_driver {
+	const char *name;
+};
+
+struct rte_bus_device {
+	const char *name;
+};
+
 /**
  * Initalize all the registered drivers in this process
  */
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 334c12e..10a2306 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -83,6 +83,7 @@ extern "C" {
 #include <inttypes.h>
 
 #include <rte_interrupts.h>
+#include <rte_dev.h>
 
 TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */
 TAILQ_HEAD(pci_driver_list, rte_pci_driver); /**< PCI drivers in D-linked Q. */
@@ -166,6 +167,7 @@ struct rte_pci_device {
 	int numa_node;                          /**< NUMA node connection */
 	struct rte_devargs *devargs;            /**< Device user arguments */
 	enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
+	struct rte_bus_device dev;              /**< Generic device */
 };
 
 /** Any PCI device identifier (vendor, device, ...) */
@@ -209,6 +211,7 @@ struct rte_pci_driver {
 	pci_devuninit_t *devuninit;             /**< Device uninit function. */
 	const struct rte_pci_id *id_table;	/**< ID table, NULL terminated. */
 	uint32_t drv_flags;                     /**< Flags contolling handling of device. */
+	struct rte_bus_driver drv;              /**< Generic driver */
 };
 
 /** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
-- 
2.7.0

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

* [dpdk-dev] [RFC 2/6] eal: define macro container_of
  2016-01-18 16:03 [dpdk-dev] [RFC 0/6] Preview of a big eal/ethdev cleanup Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 1/6] eal: introduce rte_bus_device and rte_bus_driver Jan Viktorin
@ 2016-01-18 16:03 ` Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 3/6] eal: move devargs from rte_pci_device to rte_device Jan Viktorin
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jan Viktorin @ 2016-01-18 16:03 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_eal/common/include/rte_common.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index b58a384..bf6560d 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -322,6 +322,22 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif
 
+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *      ...
+ *      struct child c;
+ *      ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#define container_of(p, type, member) \
+	((type *) (((char *) (p)) - offsetof(type, member)))
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)
-- 
2.7.0

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

* [dpdk-dev] [RFC 3/6] eal: move devargs from rte_pci_device to rte_device
  2016-01-18 16:03 [dpdk-dev] [RFC 0/6] Preview of a big eal/ethdev cleanup Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 1/6] eal: introduce rte_bus_device and rte_bus_driver Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 2/6] eal: define macro container_of Jan Viktorin
@ 2016-01-18 16:03 ` Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 4/6] eal: move numa_node " Jan Viktorin
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jan Viktorin @ 2016-01-18 16:03 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Suggested-by: David Marchand <david.marchand@6wind.com>
Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_eal/common/eal_common_pci.c  | 6 +++---
 lib/librte_eal/common/include/rte_dev.h | 3 +++
 lib/librte_eal/common/include/rte_pci.h | 1 -
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index dcfe947..60501a5 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -173,8 +173,8 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 				dev->id.device_id, dr->name);
 
 		/* no initialization when blacklisted, return without error */
-		if (dev->devargs != NULL &&
-			dev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (dev->dev.devargs != NULL &&
+			dev->dev.devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
 			RTE_LOG(DEBUG, EAL, "  Device is blacklisted, not initializing\n");
 			return 1;
 		}
@@ -401,7 +401,7 @@ rte_eal_pci_probe(void)
 		/* set devargs in PCI structure */
 		devargs = pci_devargs_lookup(dev);
 		if (devargs != NULL)
-			dev->devargs = devargs;
+			dev->dev.devargs = devargs;
 
 		/* probe all or only whitelisted devices */
 		if (probe_all)
diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index b779705..1ab47f9 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -156,8 +156,11 @@ struct rte_bus_driver {
 	const char *name;
 };
 
+struct rte_devargs;
+
 struct rte_bus_device {
 	const char *name;
+	struct rte_devargs *devargs;
 };
 
 /**
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 10a2306..b894913 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -165,7 +165,6 @@ struct rte_pci_device {
 	struct rte_pci_driver *driver;          /**< Associated driver */
 	uint16_t max_vfs;                       /**< sriov enable if not zero */
 	int numa_node;                          /**< NUMA node connection */
-	struct rte_devargs *devargs;            /**< Device user arguments */
 	enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
 	struct rte_bus_device dev;              /**< Generic device */
 };
-- 
2.7.0

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

* [dpdk-dev] [RFC 4/6] eal: move numa_node from rte_pci_device to rte_device
  2016-01-18 16:03 [dpdk-dev] [RFC 0/6] Preview of a big eal/ethdev cleanup Jan Viktorin
                   ` (2 preceding siblings ...)
  2016-01-18 16:03 ` [dpdk-dev] [RFC 3/6] eal: move devargs from rte_pci_device to rte_device Jan Viktorin
@ 2016-01-18 16:03 ` Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 5/6] eal: move intr_handle " Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 6/6] eal: move driver pointer from rte_pci_device to rte_bus_device Jan Viktorin
  5 siblings, 0 replies; 7+ messages in thread
From: Jan Viktorin @ 2016-01-18 16:03 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 app/test/virtual_pmd.c                  | 2 +-
 lib/librte_eal/bsdapp/eal/eal_pci.c     | 2 +-
 lib/librte_eal/common/eal_common_pci.c  | 4 ++--
 lib/librte_eal/common/include/rte_dev.h | 1 +
 lib/librte_eal/common/include/rte_pci.h | 1 -
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 4 ++--
 lib/librte_ether/rte_ethdev.c           | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index a538c8a..0fe957f 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -585,7 +585,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 	if (eth_dev == NULL)
 		goto err;
 
-	pci_dev->numa_node = socket_id;
+	pci_dev->dev.numa_node = socket_id;
 	pci_drv->name = virtual_ethdev_driver_name;
 	pci_drv->id_table = id_table;
 
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 6c21fbd..07fd6c8 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -277,7 +277,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 	dev->max_vfs = 0;
 
 	/* FreeBSD has no NUMA support (yet) */
-	dev->numa_node = 0;
+	dev->dev.numa_node = 0;
 
 	/* FreeBSD has only one pass through driver */
 	dev->kdrv = RTE_KDRV_NIC_UIO;
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 60501a5..4ac180d 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -167,7 +167,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 
 		RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
 				loc->domain, loc->bus, loc->devid, loc->function,
-				dev->numa_node);
+				dev->dev.numa_node);
 
 		RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
 				dev->id.device_id, dr->name);
@@ -241,7 +241,7 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
 
 		RTE_LOG(DEBUG, EAL, "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",
 				loc->domain, loc->bus, loc->devid,
-				loc->function, dev->numa_node);
+				loc->function, dev->dev.numa_node);
 
 		RTE_LOG(DEBUG, EAL, "  remove driver: %x:%x %s\n", dev->id.vendor_id,
 				dev->id.device_id, dr->name);
diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 1ab47f9..593ceb3 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -161,6 +161,7 @@ struct rte_devargs;
 struct rte_bus_device {
 	const char *name;
 	struct rte_devargs *devargs;
+	int numa_node;
 };
 
 /**
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index b894913..5566e3d 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -164,7 +164,6 @@ struct rte_pci_device {
 	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
 	struct rte_pci_driver *driver;          /**< Associated driver */
 	uint16_t max_vfs;                       /**< sriov enable if not zero */
-	int numa_node;                          /**< NUMA node connection */
 	enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
 	struct rte_bus_device dev;              /**< Generic device */
 };
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index bc5b5be..c87dd37 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -326,13 +326,13 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 		 dirname);
 	if (access(filename, R_OK) != 0) {
 		/* if no NUMA support, set default to 0 */
-		dev->numa_node = 0;
+		dev->dev.numa_node = 0;
 	} else {
 		if (eal_parse_sysfs_value(filename, &tmp) < 0) {
 			free(dev);
 			return -1;
 		}
-		dev->numa_node = tmp;
+		dev->dev.numa_node = tmp;
 	}
 
 	/* parse resources */
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ed971b4..908997a 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3236,6 +3236,6 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
-	eth_dev->data->numa_node = pci_dev->numa_node;
+	eth_dev->data->numa_node = pci_dev->dev.numa_node;
 	eth_dev->data->drv_name = pci_dev->driver->name;
 }
-- 
2.7.0

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

* [dpdk-dev] [RFC 5/6] eal: move intr_handle from rte_pci_device to rte_device
  2016-01-18 16:03 [dpdk-dev] [RFC 0/6] Preview of a big eal/ethdev cleanup Jan Viktorin
                   ` (3 preceding siblings ...)
  2016-01-18 16:03 ` [dpdk-dev] [RFC 4/6] eal: move numa_node " Jan Viktorin
@ 2016-01-18 16:03 ` Jan Viktorin
  2016-01-18 16:03 ` [dpdk-dev] [RFC 6/6] eal: move driver pointer from rte_pci_device to rte_bus_device Jan Viktorin
  5 siblings, 0 replies; 7+ messages in thread
From: Jan Viktorin @ 2016-01-18 16:03 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Suggested-by: David Marchand <david.marchand@6wind.com>
Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 drivers/net/e1000/em_ethdev.c              | 14 ++++++-------
 drivers/net/e1000/igb_ethdev.c             | 24 +++++++++++-----------
 drivers/net/enic/enic_main.c               |  4 ++--
 drivers/net/fm10k/fm10k_ethdev.c           | 16 +++++++--------
 drivers/net/i40e/i40e_ethdev.c             | 32 +++++++++++++++---------------
 drivers/net/i40e/i40e_ethdev_vf.c          | 16 +++++++--------
 drivers/net/ixgbe/ixgbe_ethdev.c           | 28 +++++++++++++-------------
 drivers/net/virtio/virtio_ethdev.c         | 16 +++++++--------
 lib/librte_eal/bsdapp/eal/eal_pci.c        | 14 ++++++-------
 lib/librte_eal/common/eal_common_pci_uio.c | 18 ++++++++---------
 lib/librte_eal/common/include/rte_dev.h    |  1 +
 lib/librte_eal/common/include/rte_pci.h    |  1 -
 lib/librte_eal/linuxapp/eal/eal_pci.c      |  4 ++--
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c  | 28 +++++++++++++-------------
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 14 ++++++-------
 lib/librte_ether/rte_ethdev.c              |  4 ++--
 16 files changed, 117 insertions(+), 117 deletions(-)

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 66e8993..87ed780 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -296,7 +296,7 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev)
 		     eth_dev->data->port_id, pci_dev->id.vendor_id,
 		     pci_dev->id.device_id);
 
-	rte_intr_callback_register(&(pci_dev->intr_handle),
+	rte_intr_callback_register(&(pci_dev->dev.intr_handle),
 		eth_em_interrupt_handler, (void *)eth_dev);
 
 	return (0);
@@ -327,8 +327,8 @@ eth_em_dev_uninit(struct rte_eth_dev *eth_dev)
 	eth_dev->data->mac_addrs = NULL;
 
 	/* disable uio intr before callback unregister */
-	rte_intr_disable(&(pci_dev->intr_handle));
-	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+	rte_intr_disable(&(pci_dev->dev.intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->dev.intr_handle),
 		eth_em_interrupt_handler, (void *)eth_dev);
 
 	return 0;
@@ -506,7 +506,7 @@ eth_em_start(struct rte_eth_dev *dev)
 		E1000_DEV_PRIVATE(dev->data->dev_private);
 	struct e1000_hw *hw =
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	int ret, mask;
 	uint32_t intr_vector = 0;
 
@@ -683,7 +683,7 @@ eth_em_stop(struct rte_eth_dev *dev)
 {
 	struct rte_eth_link link;
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 
 	em_rxq_intr_disable(hw);
 	em_lsc_intr_disable(hw);
@@ -945,7 +945,7 @@ eth_em_rx_queue_intr_enable(struct rte_eth_dev *dev, __rte_unused uint16_t queue
 	struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
 	em_rxq_intr_enable(hw);
-	rte_intr_enable(&dev->pci_dev->intr_handle);
+	rte_intr_enable(&dev->pci_dev->dev.intr_handle);
 
 	return 0;
 }
@@ -1482,7 +1482,7 @@ eth_em_interrupt_action(struct rte_eth_dev *dev)
 		return -1;
 
 	intr->flags &= ~E1000_FLAG_NEED_LINK_UPDATE;
-	rte_intr_enable(&(dev->pci_dev->intr_handle));
+	rte_intr_enable(&(dev->pci_dev->dev.intr_handle));
 
 	/* set get_link_status to check register later */
 	hw->mac.get_link_status = 1;
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index d1bbcda..860bd5c 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -769,12 +769,12 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev)
 		     eth_dev->data->port_id, pci_dev->id.vendor_id,
 		     pci_dev->id.device_id);
 
-	rte_intr_callback_register(&pci_dev->intr_handle,
+	rte_intr_callback_register(&pci_dev->dev.intr_handle,
 				   eth_igb_interrupt_handler,
 				   (void *)eth_dev);
 
 	/* enable uio/vfio intr/eventfd mapping */
-	rte_intr_enable(&pci_dev->intr_handle);
+	rte_intr_enable(&pci_dev->dev.intr_handle);
 
 	/* enable support intr */
 	igb_intr_enable(eth_dev);
@@ -827,8 +827,8 @@ eth_igb_dev_uninit(struct rte_eth_dev *eth_dev)
 	igb_pf_host_uninit(eth_dev);
 
 	/* disable uio intr before callback unregister */
-	rte_intr_disable(&(pci_dev->intr_handle));
-	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+	rte_intr_disable(&(pci_dev->dev.intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->dev.intr_handle),
 		eth_igb_interrupt_handler, (void *)eth_dev);
 
 	return 0;
@@ -1115,7 +1115,7 @@ eth_igb_start(struct rte_eth_dev *dev)
 		E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct e1000_adapter *adapter =
 		E1000_DEV_PRIVATE(dev->data->dev_private);
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	int ret, mask;
 	uint32_t intr_vector = 0;
 	uint32_t ctrl_ext;
@@ -1315,7 +1315,7 @@ eth_igb_stop(struct rte_eth_dev *dev)
 	struct e1000_flex_filter *p_flex;
 	struct e1000_5tuple_filter *p_5tuple, *p_5tuple_next;
 	struct e1000_2tuple_filter *p_2tuple, *p_2tuple_next;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 
 	igb_intr_disable(hw);
 
@@ -1413,9 +1413,9 @@ eth_igb_close(struct rte_eth_dev *dev)
 	igb_dev_free_queues(dev);
 
 	pci_dev = dev->pci_dev;
-	if (pci_dev->intr_handle.intr_vec) {
-		rte_free(pci_dev->intr_handle.intr_vec);
-		pci_dev->intr_handle.intr_vec = NULL;
+	if (pci_dev->dev.intr_handle.intr_vec) {
+		rte_free(pci_dev->dev.intr_handle.intr_vec);
+		pci_dev->dev.intr_handle.intr_vec = NULL;
 	}
 
 	memset(&link, 0, sizeof(link));
@@ -2431,7 +2431,7 @@ eth_igb_interrupt_action(struct rte_eth_dev *dev)
 	}
 
 	igb_intr_enable(dev);
-	rte_intr_enable(&(dev->pci_dev->intr_handle));
+	rte_intr_enable(&(dev->pci_dev->dev.intr_handle));
 
 	if (intr->flags & E1000_FLAG_NEED_LINK_UPDATE) {
 		intr->flags &= ~E1000_FLAG_NEED_LINK_UPDATE;
@@ -4727,7 +4727,7 @@ eth_igb_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 	E1000_WRITE_REG(hw, E1000_EIMS, regval | mask);
 	E1000_WRITE_FLUSH(hw);
 
-	rte_intr_enable(&dev->pci_dev->intr_handle);
+	rte_intr_enable(&dev->pci_dev->dev.intr_handle);
 
 	return 0;
 }
@@ -4792,7 +4792,7 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev)
 	uint32_t base = E1000_MISC_VEC_ID;
 	uint32_t misc_shift = 0;
 
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 
 	/* won't configure msix register if no mapping is done
 	 * between intr vector and event fd
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index 07a9810..5a1c2ce 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -606,10 +606,10 @@ int enic_enable(struct enic *enic)
 	vnic_dev_enable_wait(enic->vdev);
 
 	/* Register and enable error interrupt */
-	rte_intr_callback_register(&(enic->pdev->intr_handle),
+	rte_intr_callback_register(&(enic->pdev->dev.intr_handle),
 		enic_intr_handler, (void *)enic->rte_dev);
 
-	rte_intr_enable(&(enic->pdev->intr_handle));
+	rte_intr_enable(&(enic->pdev->dev.intr_handle));
 	vnic_intr_unmask(&enic->intr);
 
 	return 0;
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index e4aed94..7f88d25 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2322,7 +2322,7 @@ fm10k_dev_interrupt_handler_pf(
 	FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_AUTOMASK |
 					FM10K_ITR_MASK_CLEAR);
 	/* Re-enable interrupt from host side */
-	rte_intr_enable(&(dev->pci_dev->intr_handle));
+	rte_intr_enable(&(dev->pci_dev->dev.intr_handle));
 }
 
 /**
@@ -2356,7 +2356,7 @@ fm10k_dev_interrupt_handler_vf(
 	FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_AUTOMASK |
 					FM10K_ITR_MASK_CLEAR);
 	/* Re-enable interrupt from host side */
-	rte_intr_enable(&(dev->pci_dev->intr_handle));
+	rte_intr_enable(&(dev->pci_dev->dev.intr_handle));
 }
 
 /* Mailbox message handler in VF */
@@ -2624,20 +2624,20 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
 	/*PF/VF has different interrupt handling mechanism */
 	if (hw->mac.type == fm10k_mac_pf) {
 		/* register callback func to eal lib */
-		rte_intr_callback_register(&(dev->pci_dev->intr_handle),
+		rte_intr_callback_register(&(dev->pci_dev->dev.intr_handle),
 			fm10k_dev_interrupt_handler_pf, (void *)dev);
 
 		/* enable MISC interrupt */
 		fm10k_dev_enable_intr_pf(dev);
 	} else { /* VF */
-		rte_intr_callback_register(&(dev->pci_dev->intr_handle),
+		rte_intr_callback_register(&(dev->pci_dev->dev.intr_handle),
 			fm10k_dev_interrupt_handler_vf, (void *)dev);
 
 		fm10k_dev_enable_intr_vf(dev);
 	}
 
 	/* Enable uio intr after callback registered */
-	rte_intr_enable(&(dev->pci_dev->intr_handle));
+	rte_intr_enable(&(dev->pci_dev->dev.intr_handle));
 
 	hw->mac.ops.update_int_moderator(hw);
 
@@ -2707,7 +2707,7 @@ eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
 	dev->tx_pkt_burst = NULL;
 
 	/* disable uio/vfio intr */
-	rte_intr_disable(&(dev->pci_dev->intr_handle));
+	rte_intr_disable(&(dev->pci_dev->dev.intr_handle));
 
 	/*PF/VF has different interrupt handling mechanism */
 	if (hw->mac.type == fm10k_mac_pf) {
@@ -2715,13 +2715,13 @@ eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
 		fm10k_dev_disable_intr_pf(dev);
 
 		/* unregister callback func to eal lib */
-		rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+		rte_intr_callback_unregister(&(dev->pci_dev->dev.intr_handle),
 			fm10k_dev_interrupt_handler_pf, (void *)dev);
 	} else {
 		/* disable interrupt */
 		fm10k_dev_disable_intr_vf(dev);
 
-		rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),
+		rte_intr_callback_unregister(&(dev->pci_dev->dev.intr_handle),
 			fm10k_dev_interrupt_handler_vf, (void *)dev);
 	}
 
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bf6220d..2d6a7d5 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -903,7 +903,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 	i40e_pf_host_init(dev);
 
 	/* register callback func to eal lib */
-	rte_intr_callback_register(&(pci_dev->intr_handle),
+	rte_intr_callback_register(&(pci_dev->dev.intr_handle),
 		i40e_dev_interrupt_handler, (void *)dev);
 
 	/* configure and enable device interrupt */
@@ -911,7 +911,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 	i40e_pf_enable_irq0(hw);
 
 	/* enable uio intr after callback register */
-	rte_intr_enable(&(pci_dev->intr_handle));
+	rte_intr_enable(&(pci_dev->dev.intr_handle));
 	/*
 	 * Add an ethertype filter to drop all flow control frames transmitted
 	 * from VSIs. By doing so, we stop VF from sending out PAUSE or PFC
@@ -1004,10 +1004,10 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev)
 	dev->data->mac_addrs = NULL;
 
 	/* disable uio intr before callback unregister */
-	rte_intr_disable(&(pci_dev->intr_handle));
+	rte_intr_disable(&(pci_dev->dev.intr_handle));
 
 	/* register callback func to eal lib */
-	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+	rte_intr_callback_unregister(&(pci_dev->dev.intr_handle),
 		i40e_dev_interrupt_handler, (void *)dev);
 
 	return 0;
@@ -1094,7 +1094,7 @@ void
 i40e_vsi_queues_unbind_intr(struct i40e_vsi *vsi)
 {
 	struct rte_eth_dev *dev = vsi->adapter->eth_dev;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
 	uint16_t msix_vect = vsi->msix_intr;
 	uint16_t i;
@@ -1207,7 +1207,7 @@ void
 i40e_vsi_queues_bind_intr(struct i40e_vsi *vsi)
 {
 	struct rte_eth_dev *dev = vsi->adapter->eth_dev;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
 	uint16_t msix_vect = vsi->msix_intr;
 	uint16_t nb_msix = RTE_MIN(vsi->nb_msix, intr_handle->nb_efd);
@@ -1278,7 +1278,7 @@ static void
 i40e_vsi_enable_queues_intr(struct i40e_vsi *vsi)
 {
 	struct rte_eth_dev *dev = vsi->adapter->eth_dev;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
 	uint16_t interval = i40e_calc_itr_interval(\
 		RTE_LIBRTE_I40E_ITR_INTERVAL);
@@ -1309,7 +1309,7 @@ static void
 i40e_vsi_disable_queues_intr(struct i40e_vsi *vsi)
 {
 	struct rte_eth_dev *dev = vsi->adapter->eth_dev;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
 	uint16_t msix_intr, i;
 
@@ -1389,7 +1389,7 @@ i40e_dev_start(struct rte_eth_dev *dev)
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct i40e_vsi *main_vsi = pf->main_vsi;
 	int ret, i;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	uint32_t intr_vector = 0;
 
 	hw->adapter_stopped = 0;
@@ -1507,7 +1507,7 @@ i40e_dev_stop(struct rte_eth_dev *dev)
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct i40e_vsi *main_vsi = pf->main_vsi;
 	struct i40e_mirror_rule *p_mirror;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	int i;
 
 	/* Disable all queues */
@@ -1569,7 +1569,7 @@ i40e_dev_close(struct rte_eth_dev *dev)
 
 	/* Disable interrupt */
 	i40e_pf_disable_irq0(hw);
-	rte_intr_disable(&(dev->pci_dev->intr_handle));
+	rte_intr_disable(&(dev->pci_dev->dev.intr_handle));
 
 	/* shutdown and destroy the HMC */
 	i40e_shutdown_lan_hmc(hw);
@@ -4920,7 +4920,7 @@ i40e_dev_interrupt_delayed_handler(void *param)
 	_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
 
 	i40e_pf_enable_irq0(hw);
-	rte_intr_enable(&(dev->pci_dev->intr_handle));
+	rte_intr_enable(&(dev->pci_dev->dev.intr_handle));
 }
 
 /**
@@ -5007,7 +5007,7 @@ i40e_dev_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
 done:
 	/* Enable interrupt */
 	i40e_pf_enable_irq0(hw);
-	rte_intr_enable(&(dev->pci_dev->intr_handle));
+	rte_intr_enable(&(dev->pci_dev->dev.intr_handle));
 }
 
 static int
@@ -8483,7 +8483,7 @@ i40e_dev_get_dcb_info(struct rte_eth_dev *dev,
 static int
 i40e_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint16_t interval =
 		i40e_calc_itr_interval(RTE_LIBRTE_I40E_ITR_INTERVAL);
@@ -8508,7 +8508,7 @@ i40e_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 				I40E_PFINT_DYN_CTLN_INTERVAL_SHIFT));
 
 	I40E_WRITE_FLUSH(hw);
-	rte_intr_enable(&dev->pci_dev->intr_handle);
+	rte_intr_enable(&dev->pci_dev->dev.intr_handle);
 
 	return 0;
 }
@@ -8516,7 +8516,7 @@ i40e_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 static int
 i40e_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint16_t msix_intr;
 
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 14d2a50..f9ed908 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -748,7 +748,7 @@ i40evf_config_irq_map(struct rte_eth_dev *dev)
 	uint8_t cmd_buffer[sizeof(struct i40e_virtchnl_irq_map_info) + \
 		sizeof(struct i40e_virtchnl_vector_map)];
 	struct i40e_virtchnl_irq_map_info *map_info;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	uint32_t vector_id;
 	int i, err;
 
@@ -1693,7 +1693,7 @@ i40evf_enable_queues_intr(struct rte_eth_dev *dev)
 {
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 
 	if (!rte_intr_allow_others(intr_handle)) {
 		I40E_WRITE_REG(hw,
@@ -1724,7 +1724,7 @@ i40evf_disable_queues_intr(struct rte_eth_dev *dev)
 {
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 
 	if (!rte_intr_allow_others(intr_handle)) {
 		I40E_WRITE_REG(hw, I40E_VFINT_DYN_CTL01, 0);
@@ -1746,7 +1746,7 @@ i40evf_disable_queues_intr(struct rte_eth_dev *dev)
 static int
 i40evf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint16_t interval =
 		i40e_calc_itr_interval(RTE_LIBRTE_I40E_ITR_INTERVAL);
@@ -1772,7 +1772,7 @@ i40evf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 
 	I40EVF_WRITE_FLUSH(hw);
 
-	rte_intr_enable(&dev->pci_dev->intr_handle);
+	rte_intr_enable(&dev->pci_dev->dev.intr_handle);
 
 	return 0;
 }
@@ -1780,7 +1780,7 @@ i40evf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 static int
 i40evf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint16_t msix_intr;
 
@@ -1803,7 +1803,7 @@ i40evf_dev_start(struct rte_eth_dev *dev)
 {
 	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct ether_addr mac_addr;
 	uint32_t intr_vector = 0;
 
@@ -1879,7 +1879,7 @@ static void
 i40evf_dev_stop(struct rte_eth_dev *dev)
 {
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct ether_addr mac_addr;
 
 	PMD_INIT_FUNC_TRACE();
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 4c4c6df..cc760f3 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1151,12 +1151,12 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
 			eth_dev->data->port_id, pci_dev->id.vendor_id,
 			pci_dev->id.device_id);
 
-	rte_intr_callback_register(&pci_dev->intr_handle,
+	rte_intr_callback_register(&pci_dev->dev.intr_handle,
 				   ixgbe_dev_interrupt_handler,
 				   (void *)eth_dev);
 
 	/* enable uio/vfio intr/eventfd mapping */
-	rte_intr_enable(&pci_dev->intr_handle);
+	rte_intr_enable(&pci_dev->dev.intr_handle);
 
 	/* enable support intr */
 	ixgbe_enable_intr(eth_dev);
@@ -1194,8 +1194,8 @@ eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
 	ixgbe_swfw_lock_reset(hw);
 
 	/* disable uio intr before callback unregister */
-	rte_intr_disable(&(pci_dev->intr_handle));
-	rte_intr_callback_unregister(&(pci_dev->intr_handle),
+	rte_intr_disable(&(pci_dev->dev.intr_handle));
+	rte_intr_callback_unregister(&(pci_dev->dev.intr_handle),
 		ixgbe_dev_interrupt_handler, (void *)eth_dev);
 
 	/* uninitialize PF if max_vfs not zero */
@@ -1972,7 +1972,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ixgbe_vf_info *vfinfo =
 		*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	uint32_t intr_vector = 0;
 	int err, link_up = 0, negotiate = 0;
 	uint32_t speed = 0;
@@ -2184,7 +2184,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)
 	struct ixgbe_filter_info *filter_info =
 		IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
 	struct ixgbe_5tuple_filter *p_5tuple, *p_5tuple_next;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	int vf;
 
 	PMD_INIT_FUNC_TRACE();
@@ -3173,7 +3173,7 @@ ixgbe_dev_interrupt_action(struct rte_eth_dev *dev)
 	} else {
 		PMD_DRV_LOG(DEBUG, "enable intr immediately");
 		ixgbe_enable_intr(dev);
-		rte_intr_enable(&(dev->pci_dev->intr_handle));
+		rte_intr_enable(&(dev->pci_dev->dev.intr_handle));
 	}
 
 
@@ -3217,7 +3217,7 @@ ixgbe_dev_interrupt_delayed_handler(void *param)
 
 	PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
 	ixgbe_enable_intr(dev);
-	rte_intr_enable(&(dev->pci_dev->intr_handle));
+	rte_intr_enable(&(dev->pci_dev->dev.intr_handle));
 }
 
 /**
@@ -3817,7 +3817,7 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)
 	struct ixgbe_hw *hw =
 		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint32_t intr_vector = 0;
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 
 	int err, mask = 0;
 
@@ -3880,7 +3880,7 @@ static void
 ixgbevf_dev_stop(struct rte_eth_dev *dev)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -4453,7 +4453,7 @@ ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 	RTE_SET_USED(queue_id);
 	IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
 
-	rte_intr_enable(&dev->pci_dev->intr_handle);
+	rte_intr_enable(&dev->pci_dev->dev.intr_handle);
 
 	return 0;
 }
@@ -4495,7 +4495,7 @@ ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 		mask &= (1 << (queue_id - 32));
 		IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
 	}
-	rte_intr_enable(&dev->pci_dev->intr_handle);
+	rte_intr_enable(&dev->pci_dev->dev.intr_handle);
 
 	return 0;
 }
@@ -4599,7 +4599,7 @@ ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
 static void
 ixgbevf_configure_msix(struct rte_eth_dev *dev)
 {
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct ixgbe_hw *hw =
 		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint32_t q_idx;
@@ -4632,7 +4632,7 @@ ixgbevf_configure_msix(struct rte_eth_dev *dev)
 static void
 ixgbe_configure_msix(struct rte_eth_dev *dev)
 {
-	struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = &dev->pci_dev->dev.intr_handle;
 	struct ixgbe_hw *hw =
 		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index d928339..1ee9f85 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1114,14 +1114,14 @@ static int virtio_resource_init_by_uio(struct rte_pci_device *pci_dev)
 	/* save fd */
 	memset(dirname, 0, sizeof(dirname));
 	snprintf(dirname, sizeof(dirname), "/dev/uio%u", uio_num);
-	pci_dev->intr_handle.fd = open(dirname, O_RDWR);
-	if (pci_dev->intr_handle.fd < 0) {
+	pci_dev->dev.intr_handle.fd = open(dirname, O_RDWR);
+	if (pci_dev->dev.intr_handle.fd < 0) {
 		PMD_INIT_LOG(ERR, "Cannot open %s: %s\n",
 			dirname, strerror(errno));
 		return -1;
 	}
 
-	pci_dev->intr_handle.type = RTE_INTR_HANDLE_UIO;
+	pci_dev->dev.intr_handle.type = RTE_INTR_HANDLE_UIO;
 	pci_dev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC;
 
 	return 0;
@@ -1233,7 +1233,7 @@ virtio_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
 	isr = vtpci_isr(hw);
 	PMD_DRV_LOG(INFO, "interrupt status = %#x", isr);
 
-	if (rte_intr_enable(&dev->pci_dev->intr_handle) < 0)
+	if (rte_intr_enable(&dev->pci_dev->dev.intr_handle) < 0)
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
 
 	if (isr & VIRTIO_PCI_ISR_CONFIG) {
@@ -1389,7 +1389,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 
 	/* Setup interrupt callback  */
 	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
-		rte_intr_callback_register(&pci_dev->intr_handle,
+		rte_intr_callback_register(&pci_dev->dev.intr_handle,
 				   virtio_interrupt_handler, eth_dev);
 
 	virtio_dev_cq_start(eth_dev);
@@ -1425,7 +1425,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 
 	/* reset interrupt callback  */
 	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
-		rte_intr_callback_unregister(&pci_dev->intr_handle,
+		rte_intr_callback_unregister(&pci_dev->dev.intr_handle,
 						virtio_interrupt_handler,
 						eth_dev);
 
@@ -1515,7 +1515,7 @@ virtio_dev_start(struct rte_eth_dev *dev)
 			return -ENOTSUP;
 		}
 
-		if (rte_intr_enable(&dev->pci_dev->intr_handle) < 0) {
+		if (rte_intr_enable(&dev->pci_dev->dev.intr_handle) < 0) {
 			PMD_DRV_LOG(ERR, "interrupt enable failed");
 			return -EIO;
 		}
@@ -1616,7 +1616,7 @@ virtio_dev_stop(struct rte_eth_dev *dev)
 	PMD_INIT_LOG(DEBUG, "stop");
 
 	if (dev->data->dev_conf.intr_conf.lsc)
-		rte_intr_disable(&dev->pci_dev->intr_handle);
+		rte_intr_disable(&dev->pci_dev->dev.intr_handle);
 
 	memset(&link, 0, sizeof(link));
 	virtio_dev_atomic_write_link_status(dev, &link);
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 07fd6c8..762ddfd 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -136,10 +136,10 @@ pci_uio_free_resource(struct rte_pci_device *dev,
 {
 	rte_free(uio_res);
 
-	if (dev->intr_handle.fd) {
-		close(dev->intr_handle.fd);
-		dev->intr_handle.fd = -1;
-		dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
+	if (dev->dev.intr_handle.fd) {
+		close(dev->dev.intr_handle.fd);
+		dev->dev.intr_handle.fd = -1;
+		dev->dev.intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
 	}
 }
 
@@ -162,13 +162,13 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
 	}
 
 	/* save fd if in primary process */
-	dev->intr_handle.fd = open(devname, O_RDWR);
-	if (dev->intr_handle.fd < 0) {
+	dev->dev.intr_handle.fd = open(devname, O_RDWR);
+	if (dev->dev.intr_handle.fd < 0) {
 		RTE_LOG(ERR, EAL, "Cannot open %s: %s\n",
 			devname, strerror(errno));
 		goto error;
 	}
-	dev->intr_handle.type = RTE_INTR_HANDLE_UIO;
+	dev->dev.intr_handle.type = RTE_INTR_HANDLE_UIO;
 
 	/* allocate the mapping details for secondary processes*/
 	*uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0);
diff --git a/lib/librte_eal/common/eal_common_pci_uio.c b/lib/librte_eal/common/eal_common_pci_uio.c
index f062e81..5adc396 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -105,9 +105,9 @@ pci_uio_map_resource(struct rte_pci_device *dev)
 	struct mapped_pci_res_list *uio_res_list =
 		RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
 
-	dev->intr_handle.fd = -1;
-	dev->intr_handle.uio_cfg_fd = -1;
-	dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
+	dev->dev.intr_handle.fd = -1;
+	dev->dev.intr_handle.uio_cfg_fd = -1;
+	dev->dev.intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
 
 	/* secondary processes - use already recorded details */
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -211,12 +211,12 @@ pci_uio_unmap_resource(struct rte_pci_device *dev)
 	rte_free(uio_res);
 
 	/* close fd if in primary process */
-	close(dev->intr_handle.fd);
-	if (dev->intr_handle.uio_cfg_fd >= 0) {
-		close(dev->intr_handle.uio_cfg_fd);
-		dev->intr_handle.uio_cfg_fd = -1;
+	close(dev->dev.intr_handle.fd);
+	if (dev->dev.intr_handle.uio_cfg_fd >= 0) {
+		close(dev->dev.intr_handle.uio_cfg_fd);
+		dev->dev.intr_handle.uio_cfg_fd = -1;
 	}
 
-	dev->intr_handle.fd = -1;
-	dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
+	dev->dev.intr_handle.fd = -1;
+	dev->dev.intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
 }
diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 593ceb3..a481988 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -161,6 +161,7 @@ struct rte_devargs;
 struct rte_bus_device {
 	const char *name;
 	struct rte_devargs *devargs;
+	struct rte_intr_handle intr_handle;
 	int numa_node;
 };
 
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 5566e3d..e2c3073 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -161,7 +161,6 @@ struct rte_pci_device {
 	struct rte_pci_addr addr;               /**< PCI location. */
 	struct rte_pci_id id;                   /**< PCI ID. */
 	struct rte_pci_resource mem_resource[PCI_MAX_RESOURCE];   /**< PCI Memory Resource */
-	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
 	struct rte_pci_driver *driver;          /**< Associated driver */
 	uint16_t max_vfs;                       /**< sriov enable if not zero */
 	enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index c87dd37..11e175e 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -575,7 +575,7 @@ pci_config_space_set(struct rte_pci_device *dev)
 int rte_eal_pci_read_config(const struct rte_pci_device *device,
 			    void *buf, size_t len, off_t offset)
 {
-	const struct rte_intr_handle *intr_handle = &device->intr_handle;
+	const struct rte_intr_handle *intr_handle = &device->dev.intr_handle;
 
 	switch (intr_handle->type) {
 	case RTE_INTR_HANDLE_UIO:
@@ -600,7 +600,7 @@ int rte_eal_pci_read_config(const struct rte_pci_device *device,
 int rte_eal_pci_write_config(const struct rte_pci_device *device,
 			     const void *buf, size_t len, off_t offset)
 {
-	const struct rte_intr_handle *intr_handle = &device->intr_handle;
+	const struct rte_intr_handle *intr_handle = &device->dev.intr_handle;
 
 	switch (intr_handle->type) {
 	case RTE_INTR_HANDLE_UIO:
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index ac50e13..840b5ba 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -221,14 +221,14 @@ pci_uio_free_resource(struct rte_pci_device *dev,
 {
 	rte_free(uio_res);
 
-	if (dev->intr_handle.uio_cfg_fd >= 0) {
-		close(dev->intr_handle.uio_cfg_fd);
-		dev->intr_handle.uio_cfg_fd = -1;
+	if (dev->dev.intr_handle.uio_cfg_fd >= 0) {
+		close(dev->dev.intr_handle.uio_cfg_fd);
+		dev->dev.intr_handle.uio_cfg_fd = -1;
 	}
-	if (dev->intr_handle.fd) {
-		close(dev->intr_handle.fd);
-		dev->intr_handle.fd = -1;
-		dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
+	if (dev->dev.intr_handle.fd) {
+		close(dev->dev.intr_handle.fd);
+		dev->dev.intr_handle.fd = -1;
+		dev->dev.intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
 	}
 }
 
@@ -254,8 +254,8 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
 	snprintf(devname, sizeof(devname), "/dev/uio%u", uio_num);
 
 	/* save fd if in primary process */
-	dev->intr_handle.fd = open(devname, O_RDWR);
-	if (dev->intr_handle.fd < 0) {
+	dev->dev.intr_handle.fd = open(devname, O_RDWR);
+	if (dev->dev.intr_handle.fd < 0) {
 		RTE_LOG(ERR, EAL, "Cannot open %s: %s\n",
 			devname, strerror(errno));
 		goto error;
@@ -263,20 +263,20 @@ pci_uio_alloc_resource(struct rte_pci_device *dev,
 
 	snprintf(cfgname, sizeof(cfgname),
 			"/sys/class/uio/uio%u/device/config", uio_num);
-	dev->intr_handle.uio_cfg_fd = open(cfgname, O_RDWR);
-	if (dev->intr_handle.uio_cfg_fd < 0) {
+	dev->dev.intr_handle.uio_cfg_fd = open(cfgname, O_RDWR);
+	if (dev->dev.intr_handle.uio_cfg_fd < 0) {
 		RTE_LOG(ERR, EAL, "Cannot open %s: %s\n",
 			cfgname, strerror(errno));
 		goto error;
 	}
 
 	if (dev->kdrv == RTE_KDRV_IGB_UIO)
-		dev->intr_handle.type = RTE_INTR_HANDLE_UIO;
+		dev->dev.intr_handle.type = RTE_INTR_HANDLE_UIO;
 	else {
-		dev->intr_handle.type = RTE_INTR_HANDLE_UIO_INTX;
+		dev->dev.intr_handle.type = RTE_INTR_HANDLE_UIO_INTX;
 
 		/* set bus master that is not done by uio_pci_generic */
-		if (pci_uio_set_bus_master(dev->intr_handle.uio_cfg_fd)) {
+		if (pci_uio_set_bus_master(dev->dev.intr_handle.uio_cfg_fd)) {
 			RTE_LOG(ERR, EAL, "Cannot set up bus mastering!\n");
 			goto error;
 		}
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 74f91ba..30addc6 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -317,21 +317,21 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd)
 			return -1;
 		}
 
-		dev->intr_handle.fd = fd;
-		dev->intr_handle.vfio_dev_fd = vfio_dev_fd;
+		dev->dev.intr_handle.fd = fd;
+		dev->dev.intr_handle.vfio_dev_fd = vfio_dev_fd;
 
 		switch (i) {
 		case VFIO_PCI_MSIX_IRQ_INDEX:
 			internal_config.vfio_intr_mode = RTE_INTR_MODE_MSIX;
-			dev->intr_handle.type = RTE_INTR_HANDLE_VFIO_MSIX;
+			dev->dev.intr_handle.type = RTE_INTR_HANDLE_VFIO_MSIX;
 			break;
 		case VFIO_PCI_MSI_IRQ_INDEX:
 			internal_config.vfio_intr_mode = RTE_INTR_MODE_MSI;
-			dev->intr_handle.type = RTE_INTR_HANDLE_VFIO_MSI;
+			dev->dev.intr_handle.type = RTE_INTR_HANDLE_VFIO_MSI;
 			break;
 		case VFIO_PCI_INTX_IRQ_INDEX:
 			internal_config.vfio_intr_mode = RTE_INTR_MODE_LEGACY;
-			dev->intr_handle.type = RTE_INTR_HANDLE_VFIO_LEGACY;
+			dev->dev.intr_handle.type = RTE_INTR_HANDLE_VFIO_LEGACY;
 			break;
 		default:
 			RTE_LOG(ERR, EAL, "  unknown interrupt type!\n");
@@ -574,8 +574,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 	uint32_t msix_table_offset = 0;
 	uint32_t msix_table_size = 0;
 
-	dev->intr_handle.fd = -1;
-	dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
+	dev->dev.intr_handle.fd = -1;
+	dev->dev.intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
 
 	/* store PCI address string */
 	snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 908997a..b93fba8 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2571,7 +2571,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 	}
 
 	dev = &rte_eth_devices[port_id];
-	intr_handle = &dev->pci_dev->intr_handle;
+	intr_handle = &dev->pci_dev->dev.intr_handle;
 	if (!intr_handle->intr_vec) {
 		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
@@ -2634,7 +2634,7 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,
 		return -EINVAL;
 	}
 
-	intr_handle = &dev->pci_dev->intr_handle;
+	intr_handle = &dev->pci_dev->dev.intr_handle;
 	if (!intr_handle->intr_vec) {
 		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
-- 
2.7.0

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

* [dpdk-dev] [RFC 6/6] eal: move driver pointer from rte_pci_device to rte_bus_device
  2016-01-18 16:03 [dpdk-dev] [RFC 0/6] Preview of a big eal/ethdev cleanup Jan Viktorin
                   ` (4 preceding siblings ...)
  2016-01-18 16:03 ` [dpdk-dev] [RFC 5/6] eal: move intr_handle " Jan Viktorin
@ 2016-01-18 16:03 ` Jan Viktorin
  5 siblings, 0 replies; 7+ messages in thread
From: Jan Viktorin @ 2016-01-18 16:03 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

We define to_pci_driver helper macro here.

Suggested-by: David Marchand <david.marchand@6wind.com>
Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 app/test/virtual_pmd.c                  |  2 +-
 drivers/net/virtio/virtio_ethdev.c      | 25 +++++++++++++++++--------
 lib/librte_cryptodev/rte_cryptodev.c    |  3 ++-
 lib/librte_eal/common/eal_common_pci.c  |  4 ++--
 lib/librte_eal/common/include/rte_dev.h |  1 +
 lib/librte_eal/common/include/rte_pci.h |  4 +++-
 lib/librte_ether/rte_ethdev.c           | 10 ++++++----
 7 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 0fe957f..c88972d 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -626,7 +626,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 	eth_dev->dev_ops = &dev_private->dev_ops;
 
 	eth_dev->pci_dev = pci_dev;
-	eth_dev->pci_dev->driver = &eth_drv->pci_drv;
+	eth_dev->pci_dev->dev.driver = &eth_drv->pci_drv.drv;
 
 	eth_dev->rx_pkt_burst = virtual_ethdev_rx_burst_success;
 	eth_dev->tx_pkt_burst = virtual_ethdev_tx_burst_success;
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 1ee9f85..22a7849 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -487,11 +487,12 @@ virtio_dev_close(struct rte_eth_dev *dev)
 {
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct rte_pci_device *pci_dev = dev->pci_dev;
+	struct rte_pci_driver *pci_drv = to_pci_driver(pci_dev->dev.driver);
 
 	PMD_INIT_LOG(DEBUG, "virtio_dev_close");
 
 	/* reset the NIC */
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)
 		vtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR);
 	vtpci_reset(hw);
 	hw->started = 0;
@@ -1080,6 +1081,7 @@ virtio_has_msix(const struct rte_pci_addr *loc)
 /* Extract I/O port numbers from sysfs */
 static int virtio_resource_init_by_uio(struct rte_pci_device *pci_dev)
 {
+	struct rte_pci_driver *pci_drv = to_pci_driver(pci_dev->dev.driver);
 	char dirname[PATH_MAX];
 	char filename[PATH_MAX];
 	unsigned long start, size;
@@ -1122,7 +1124,7 @@ static int virtio_resource_init_by_uio(struct rte_pci_device *pci_dev)
 	}
 
 	pci_dev->dev.intr_handle.type = RTE_INTR_HANDLE_UIO;
-	pci_dev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC;
+	pci_drv->drv_flags |= RTE_PCI_DRV_INTR_LSC;
 
 	return 0;
 }
@@ -1130,6 +1132,7 @@ static int virtio_resource_init_by_uio(struct rte_pci_device *pci_dev)
 /* Extract port I/O numbers from proc/ioports */
 static int virtio_resource_init_by_ioports(struct rte_pci_device *pci_dev)
 {
+	struct rte_pci_driver *pci_drv = to_pci_driver(pci_dev->dev.driver);
 	uint16_t start, end;
 	int size;
 	FILE *fp;
@@ -1188,7 +1191,7 @@ static int virtio_resource_init_by_ioports(struct rte_pci_device *pci_dev)
 		start, size);
 
 	/* can't support lsc interrupt without uio */
-	pci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;
+	pci_drv->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;
 
 	return 0;
 }
@@ -1265,6 +1268,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	struct virtio_net_config *config;
 	struct virtio_net_config local_config;
 	struct rte_pci_device *pci_dev;
+	struct rte_pci_driver *pci_drv;
 
 	RTE_BUILD_BUG_ON(RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr));
 
@@ -1286,6 +1290,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	pci_dev = eth_dev->pci_dev;
+	pci_drv = to_pci_driver(pci_dev->dev.driver);
 
 	if (virtio_resource_init(pci_dev) < 0)
 		return -1;
@@ -1305,7 +1310,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 
 	/* If host does not support status then disable LSC */
 	if (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS))
-		pci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;
+		pci_drv->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;
 
 	rte_eth_copy_pci_info(eth_dev, pci_dev);
 
@@ -1388,7 +1393,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 			pci_dev->id.device_id);
 
 	/* Setup interrupt callback  */
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)
 		rte_intr_callback_register(&pci_dev->dev.intr_handle,
 				   virtio_interrupt_handler, eth_dev);
 
@@ -1401,6 +1406,7 @@ static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
+	struct rte_pci_driver *pci_drv;
 	struct virtio_hw *hw = eth_dev->data->dev_private;
 
 	PMD_INIT_FUNC_TRACE();
@@ -1413,6 +1419,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 		virtio_dev_close(eth_dev);
 	}
 	pci_dev = eth_dev->pci_dev;
+	pci_drv = to_pci_driver(pci_dev->dev.driver);
 
 	eth_dev->dev_ops = NULL;
 	eth_dev->tx_pkt_burst = NULL;
@@ -1424,7 +1431,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 	eth_dev->data->mac_addrs = NULL;
 
 	/* reset interrupt callback  */
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)
 		rte_intr_callback_unregister(&pci_dev->dev.intr_handle,
 						virtio_interrupt_handler,
 						eth_dev);
@@ -1474,6 +1481,7 @@ virtio_dev_configure(struct rte_eth_dev *dev)
 	const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct rte_pci_device *pci_dev = dev->pci_dev;
+	struct rte_pci_driver *pci_drv = to_pci_driver(pci_dev->dev.driver);
 
 	PMD_INIT_LOG(DEBUG, "configure");
 
@@ -1491,7 +1499,7 @@ virtio_dev_configure(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)
 		if (vtpci_irq_config(hw, 0) == VIRTIO_MSI_NO_VECTOR) {
 			PMD_DRV_LOG(ERR, "failed to set config vector");
 			return -EBUSY;
@@ -1507,10 +1515,11 @@ virtio_dev_start(struct rte_eth_dev *dev)
 	uint16_t nb_queues, i;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct rte_pci_device *pci_dev = dev->pci_dev;
+	struct rte_pci_driver *pci_drv = to_pci_driver(pci_dev->dev.driver);
 
 	/* check if lsc interrupt feature is enabled */
 	if (dev->data->dev_conf.intr_conf.lsc) {
-		if (!(pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
+		if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
 			PMD_DRV_LOG(ERR, "link status not supported by host");
 			return -ENOTSUP;
 		}
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index f09f67e..f1c9a4e 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -394,7 +394,8 @@ rte_cryptodev_uninit(struct rte_pci_device *pci_dev)
 	if (cryptodev == NULL)
 		return -ENODEV;
 
-	cryptodrv = (const struct rte_cryptodev_driver *)pci_dev->driver;
+	cryptodrv = (const struct rte_cryptodev_driver *)
+		to_pci_driver(pci_dev->dev.driver);
 	if (cryptodrv == NULL)
 		return -ENODEV;
 
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 4ac180d..8341a92 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -199,7 +199,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 		}
 
 		/* reference driver structure */
-		dev->driver = dr;
+		dev->dev.driver = &dr->drv;
 
 		/* call the driver devinit() function */
 		return dr->devinit(dr, dev);
@@ -250,7 +250,7 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
 			return -1;	/* negative value is an error */
 
 		/* clear driver structure */
-		dev->driver = NULL;
+		dev->dev.driver = NULL;
 
 		if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)
 			/* unmap resources for devices that use igb_uio */
diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index a481988..29655da 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -160,6 +160,7 @@ struct rte_devargs;
 
 struct rte_bus_device {
 	const char *name;
+	struct rte_bus_driver *driver;
 	struct rte_devargs *devargs;
 	struct rte_intr_handle intr_handle;
 	int numa_node;
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index e2c3073..f2360a7 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -161,7 +161,6 @@ struct rte_pci_device {
 	struct rte_pci_addr addr;               /**< PCI location. */
 	struct rte_pci_id id;                   /**< PCI ID. */
 	struct rte_pci_resource mem_resource[PCI_MAX_RESOURCE];   /**< PCI Memory Resource */
-	struct rte_pci_driver *driver;          /**< Associated driver */
 	uint16_t max_vfs;                       /**< sriov enable if not zero */
 	enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
 	struct rte_bus_device dev;              /**< Generic device */
@@ -211,6 +210,9 @@ struct rte_pci_driver {
 	struct rte_bus_driver drv;              /**< Generic driver */
 };
 
+#define to_pci_driver(busdrv) \
+	container_of((busdrv), struct rte_pci_driver, drv)
+
 /** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
 #define RTE_PCI_DRV_NEED_MAPPING 0x0001
 /** Device driver must be registered several times until failure - deprecated */
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b93fba8..17db470 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -315,7 +315,8 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
 	if (eth_dev == NULL)
 		return -ENODEV;
 
-	eth_drv = (const struct eth_driver *)pci_dev->driver;
+	eth_drv = (const struct eth_driver *)
+		to_pci_driver(pci_dev->dev.driver);
 
 	/* Invoke PMD device uninit function */
 	if (*eth_drv->eth_dev_uninit) {
@@ -3223,6 +3224,7 @@ rte_eth_dev_get_dcb_info(uint8_t port_id,
 void
 rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev)
 {
+	struct rte_pci_driver *drv = to_pci_driver(pci_dev->dev.driver);
 	if ((eth_dev == NULL) || (pci_dev == NULL)) {
 		RTE_PMD_DEBUG_TRACE("NULL pointer eth_dev=%p pci_dev=%p\n",
 				eth_dev, pci_dev);
@@ -3230,12 +3232,12 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de
 	}
 
 	eth_dev->data->dev_flags = 0;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
+	if (drv->drv_flags & RTE_PCI_DRV_INTR_LSC)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
-	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_DETACHABLE)
+	if (drv->drv_flags & RTE_PCI_DRV_DETACHABLE)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
 
 	eth_dev->data->kdrv = pci_dev->kdrv;
 	eth_dev->data->numa_node = pci_dev->dev.numa_node;
-	eth_dev->data->drv_name = pci_dev->driver->name;
+	eth_dev->data->drv_name = pci_dev->dev.driver->name;
 }
-- 
2.7.0

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

end of thread, other threads:[~2016-01-18 16:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18 16:03 [dpdk-dev] [RFC 0/6] Preview of a big eal/ethdev cleanup Jan Viktorin
2016-01-18 16:03 ` [dpdk-dev] [RFC 1/6] eal: introduce rte_bus_device and rte_bus_driver Jan Viktorin
2016-01-18 16:03 ` [dpdk-dev] [RFC 2/6] eal: define macro container_of Jan Viktorin
2016-01-18 16:03 ` [dpdk-dev] [RFC 3/6] eal: move devargs from rte_pci_device to rte_device Jan Viktorin
2016-01-18 16:03 ` [dpdk-dev] [RFC 4/6] eal: move numa_node " Jan Viktorin
2016-01-18 16:03 ` [dpdk-dev] [RFC 5/6] eal: move intr_handle " Jan Viktorin
2016-01-18 16:03 ` [dpdk-dev] [RFC 6/6] eal: move driver pointer from rte_pci_device to rte_bus_device Jan Viktorin

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