DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/14] Step towards PCI independency
@ 2016-01-04 20:08 Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 01/14] eal/common: introduce RTE_PCI_DRV_MAGIC Jan Viktorin
                   ` (14 more replies)
  0 siblings, 15 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Hello DPDK community,

A few days ago, I've proposed an RFC of a new infrastructure that allows to
detect non-PCI devices present on SoC systems. It is, however, the easier part
of the story. To bring support of non-PCI devices, it is necessary to do much
deeper changes in DPDK. In this patch series, I am proposing changes that shows
a possible way how to do it.

I extended the rte_pci_{device,driver} with a member .magic. This member holds
a magic number unique to the PCI-infra. Another one (SoC-infra) would get a
different set of magics. This allows to define unions of bus-specific devices
and drivers while not loosing information about the original data type. It can
also add some type-safety into the system. It solves the problem of a missing
'type' member in the eth_driver structure.

Those extensions are then used to generalize the librte_ether library that
seems (to me) to be independent on the PCI now. What is important, the API
stays backwards compatible at the moment. From the point of ABI, I am afraid
that the .magic member breaks it anyway...

The code builds successfully for both x86_64 and ARMv7. I didn't test it in
runtime as the tests are not very suitable for this.

This patch set is independent on the previous one (which was adding the SoC
infra), however, if it is approved I expect them to be joined or to make them
dependent on each other in some way.

Regards
Jan
---
Jan Viktorin (14):
  eal/common: introduce RTE_PCI_DRV_MAGIC
  eal/common: introduce RTE_PCI_DEVICE_MAGIC
  eal/common: introduce union rte_device and related
  eal/common: introduce function to_pci_driver
  eal/common: introduce function to_pci_device
  Include rte_dev.h instead of rte_pci.h
  lib/ether: generalize rte_eth_dev_init/uninit
  eal/common: introduce rte_bus_addr
  lib/ether: generalize attach/detach of devices
  lib/ether: copy the rte_device union instead of rte_pci_device
  lib/ether: extract function rte_device_get_intr_handle
  lib/ether: check magic before naming a zone
  lib/ether: check magic in rte_eth_copy_pci_info
  lib/ether: introduce rte_eth_copy_dev_info

 app/test-pipeline/config.c                         |   2 +-
 app/test-pipeline/init.c                           |   2 +-
 app/test-pipeline/main.c                           |   2 +-
 app/test-pipeline/runtime.c                        |   2 +-
 app/test-pmd/cmdline.c                             |   2 +-
 app/test-pmd/config.c                              |   2 +-
 app/test-pmd/csumonly.c                            |   2 +-
 app/test-pmd/flowgen.c                             |   2 +-
 app/test-pmd/iofwd.c                               |   2 +-
 app/test-pmd/macfwd-retry.c                        |   2 +-
 app/test-pmd/macfwd.c                              |   2 +-
 app/test-pmd/macswap.c                             |   2 +-
 app/test-pmd/parameters.c                          |   2 +-
 app/test-pmd/rxonly.c                              |   2 +-
 app/test-pmd/testpmd.c                             |   2 +-
 app/test-pmd/txonly.c                              |   2 +-
 app/test/test_pci.c                                |   2 +-
 drivers/net/bnx2x/bnx2x_ethdev.c                   |   2 +
 drivers/net/bnx2x/bnx2x_ethdev.h                   |   2 +-
 drivers/net/cxgbe/base/t4_hw.c                     |   2 +-
 drivers/net/cxgbe/cxgbe_ethdev.c                   |   3 +-
 drivers/net/cxgbe/cxgbe_main.c                     |   2 +-
 drivers/net/cxgbe/sge.c                            |   2 +-
 drivers/net/e1000/em_ethdev.c                      |   3 +-
 drivers/net/e1000/em_rxtx.c                        |   2 +-
 drivers/net/e1000/igb_ethdev.c                     |   4 +-
 drivers/net/e1000/igb_rxtx.c                       |   2 +-
 drivers/net/enic/base/vnic_dev.h                   |   2 +-
 drivers/net/enic/enic_ethdev.c                     |   2 +-
 drivers/net/enic/enic_main.c                       |   2 +-
 drivers/net/fm10k/fm10k_ethdev.c                   |   1 +
 drivers/net/i40e/i40e_ethdev.c                     |   3 +-
 drivers/net/i40e/i40e_ethdev_vf.c                  |   3 +-
 drivers/net/i40e/i40e_pf.c                         |   2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c                   |   4 +-
 drivers/net/ixgbe/ixgbe_fdir.c                     |   2 +-
 drivers/net/ixgbe/ixgbe_rxtx.c                     |   2 +-
 drivers/net/mlx4/mlx4.c                            |   1 +
 drivers/net/mlx5/mlx5.c                            |   3 +-
 drivers/net/virtio/virtio_ethdev.c                 |   3 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c               |   3 +-
 drivers/net/vmxnet3/vmxnet3_rxtx.c                 |   2 +-
 examples/bond/main.c                               |   2 +-
 examples/dpdk_qat/main.c                           |   2 +-
 examples/exception_path/main.c                     |   2 +-
 examples/ip_fragmentation/main.c                   |   2 +-
 examples/ip_reassembly/main.c                      |   2 +-
 examples/ipv4_multicast/main.c                     |   2 +-
 examples/kni/main.c                                |   2 +-
 examples/l2fwd-crypto/main.c                       |   2 +-
 examples/l2fwd-ivshmem/guest/guest.c               |   2 +-
 examples/l2fwd-jobstats/main.c                     |   2 +-
 examples/l2fwd-keepalive/main.c                    |   2 +-
 examples/l2fwd/main.c                              |   2 +-
 examples/l3fwd-acl/main.c                          |   2 +-
 examples/l3fwd-power/main.c                        |   2 +-
 examples/l3fwd-vf/main.c                           |   2 +-
 examples/l3fwd/main.c                              |   2 +-
 examples/link_status_interrupt/main.c              |   2 +-
 examples/load_balancer/config.c                    |   2 +-
 examples/load_balancer/init.c                      |   2 +-
 examples/load_balancer/main.c                      |   2 +-
 examples/load_balancer/runtime.c                   |   2 +-
 .../client_server_mp/mp_client/client.c            |   2 +-
 .../client_server_mp/mp_server/init.c              |   2 +-
 .../client_server_mp/mp_server/main.c              |   2 +-
 examples/multi_process/l2fwd_fork/flib.c           |   2 +-
 examples/multi_process/l2fwd_fork/main.c           |   2 +-
 examples/multi_process/symmetric_mp/main.c         |   2 +-
 examples/performance-thread/l3fwd-thread/main.c    |   2 +-
 examples/vmdq/main.c                               |   2 +-
 examples/vmdq_dcb/main.c                           |   2 +-
 lib/librte_cryptodev/rte_cryptodev.c               |   4 +-
 lib/librte_cryptodev/rte_cryptodev_pmd.h           |   1 -
 lib/librte_eal/bsdapp/eal/eal.c                    |   1 -
 lib/librte_eal/bsdapp/eal/eal_pci.c                |   2 +-
 lib/librte_eal/common/eal_common_devargs.c         |   2 +-
 lib/librte_eal/common/eal_common_pci.c             |   2 +-
 lib/librte_eal/common/eal_private.h                |   2 +-
 lib/librte_eal/common/include/rte_dev.h            |  44 ++++
 lib/librte_eal/common/include/rte_devargs.h        |   2 +-
 lib/librte_eal/common/include/rte_pci.h            |  27 +++
 lib/librte_eal/linuxapp/eal/eal.c                  |   2 +-
 lib/librte_eal/linuxapp/eal/eal_interrupts.c       |   2 +-
 lib/librte_eal/linuxapp/eal/eal_ivshmem.c          |   2 +-
 lib/librte_ether/rte_ethdev.c                      | 224 +++++++++++++++------
 lib/librte_ether/rte_ethdev.h                      |  25 ++-
 87 files changed, 351 insertions(+), 144 deletions(-)

-- 
2.6.3

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

* [dpdk-dev] [PATCH 01/14] eal/common: introduce RTE_PCI_DRV_MAGIC
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 02/14] eal/common: introduce RTE_PCI_DEVICE_MAGIC Jan Viktorin
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

To distinguish between different types of drivers, include a member .magic
at the beginning of the rte_pci_driver structure.

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 drivers/net/bnx2x/bnx2x_ethdev.c        | 2 ++
 drivers/net/cxgbe/cxgbe_ethdev.c        | 1 +
 drivers/net/e1000/em_ethdev.c           | 1 +
 drivers/net/e1000/igb_ethdev.c          | 2 ++
 drivers/net/enic/enic_ethdev.c          | 1 +
 drivers/net/fm10k/fm10k_ethdev.c        | 1 +
 drivers/net/i40e/i40e_ethdev.c          | 1 +
 drivers/net/i40e/i40e_ethdev_vf.c       | 1 +
 drivers/net/ixgbe/ixgbe_ethdev.c        | 2 ++
 drivers/net/mlx4/mlx4.c                 | 1 +
 drivers/net/mlx5/mlx5.c                 | 1 +
 drivers/net/virtio/virtio_ethdev.c      | 1 +
 drivers/net/vmxnet3/vmxnet3_ethdev.c    | 1 +
 lib/librte_eal/common/include/rte_pci.h | 2 ++
 14 files changed, 18 insertions(+)

diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 69df02e..e23dae2 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -498,6 +498,7 @@ eth_bnx2xvf_dev_init(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_bnx2x_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_bnx2x_pmd",
 		.id_table = pci_id_bnx2x_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
@@ -511,6 +512,7 @@ static struct eth_driver rte_bnx2x_pmd = {
  */
 static struct eth_driver rte_bnx2xvf_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_bnx2xvf_pmd",
 		.id_table = pci_id_bnx2xvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 97ef152..6807e50 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -848,6 +848,7 @@ out_free_adapter:
 
 static struct eth_driver rte_cxgbe_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_cxgbe_pmd",
 		.id_table = cxgb4_pci_tbl,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 66e8993..ffd0363 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -336,6 +336,7 @@ eth_em_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_em_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_em_pmd",
 		.id_table = pci_id_em_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index d1bbcda..413072d 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -957,6 +957,7 @@ eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_igb_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_igb_pmd",
 		.id_table = pci_id_igb_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
@@ -972,6 +973,7 @@ static struct eth_driver rte_igb_pmd = {
  */
 static struct eth_driver rte_igbvf_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_igbvf_pmd",
 		.id_table = pci_id_igbvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 2a88043..44ea5f9 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -622,6 +622,7 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_enic_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_enic_pmd",
 		.id_table = pci_id_enic_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index e4aed94..e372225 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2749,6 +2749,7 @@ static const struct rte_pci_id pci_id_fm10k_map[] = {
 
 static struct eth_driver rte_pmd_fm10k = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_pmd_fm10k",
 		.id_table = pci_id_fm10k_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bf6220d..f642bce 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -599,6 +599,7 @@ static const struct rte_i40e_xstats_name_off rte_i40e_txq_prio_strings[] = {
 
 static struct eth_driver rte_i40e_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_i40e_pmd",
 		.id_table = pci_id_i40e_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 14d2a50..e1b3e8f 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -1363,6 +1363,7 @@ i40evf_dev_uninit(struct rte_eth_dev *eth_dev)
  */
 static struct eth_driver rte_i40evf_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_i40evf_pmd",
 		.id_table = pci_id_i40evf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 4c4c6df..637731c 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1429,6 +1429,7 @@ eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_ixgbe_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_ixgbe_pmd",
 		.id_table = pci_id_ixgbe_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
@@ -1444,6 +1445,7 @@ static struct eth_driver rte_ixgbe_pmd = {
  */
 static struct eth_driver rte_ixgbevf_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_ixgbevf_pmd",
 		.id_table = pci_id_ixgbevf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 207bfe2..6d1d214 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5669,6 +5669,7 @@ static const struct rte_pci_id mlx4_pci_id_map[] = {
 
 static struct eth_driver mlx4_driver = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = MLX4_DRIVER_NAME,
 		.id_table = mlx4_pci_id_map,
 		.devinit = mlx4_pci_devinit,
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 821ee0f..da33ecf 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -534,6 +534,7 @@ static const struct rte_pci_id mlx5_pci_id_map[] = {
 
 static struct eth_driver mlx5_driver = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = MLX5_DRIVER_NAME,
 		.id_table = mlx5_pci_id_map,
 		.devinit = mlx5_pci_devinit,
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index d928339..9816a98 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1436,6 +1436,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_virtio_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_virtio_pmd",
 		.id_table = pci_id_virtio_map,
 		.drv_flags = RTE_PCI_DRV_DETACHABLE,
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index c363bf6..d84acd8 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -322,6 +322,7 @@ eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev)
 
 static struct eth_driver rte_vmxnet3_pmd = {
 	.pci_drv = {
+		.magic = RTE_PCI_DRV_MAGIC,
 		.name = "rte_vmxnet3_pmd",
 		.id_table = pci_id_vmxnet3_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 334c12e..db8382f 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -203,6 +203,8 @@ typedef int (pci_devuninit_t)(struct rte_pci_device *);
  * A structure describing a PCI driver.
  */
 struct rte_pci_driver {
+#define RTE_PCI_DRV_MAGIC 0x00000001
+	unsigned int magic;                     /**< PCI driver magic */
 	TAILQ_ENTRY(rte_pci_driver) next;       /**< Next in list. */
 	const char *name;                       /**< Driver name. */
 	pci_devinit_t *devinit;                 /**< Device init. function. */
-- 
2.6.3

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

* [dpdk-dev] [PATCH 02/14] eal/common: introduce RTE_PCI_DEVICE_MAGIC
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 01/14] eal/common: introduce RTE_PCI_DRV_MAGIC Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related Jan Viktorin
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

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

diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index db8382f..54d0fe2 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -156,6 +156,8 @@ enum rte_kernel_driver {
  * A structure describing a PCI device.
  */
 struct rte_pci_device {
+#define RTE_PCI_DEVICE_MAGIC 0x00000001
+	unsigned int magic;                     /**< PCI device magic */
 	TAILQ_ENTRY(rte_pci_device) next;       /**< Next probed PCI device. */
 	struct rte_pci_addr addr;               /**< PCI location. */
 	struct rte_pci_id id;                   /**< PCI ID. */
-- 
2.6.3

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

* [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 01/14] eal/common: introduce RTE_PCI_DRV_MAGIC Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 02/14] eal/common: introduce RTE_PCI_DEVICE_MAGIC Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-13 14:01   ` Bruce Richardson
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 04/14] eal/common: introduce function to_pci_driver Jan Viktorin
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

The union rte_device can be used in situations where we want to work with all
devices without distinguishing among bus-specific features (PCI, ...).
The target device type can be detected by reading the magic.

Also, the macros RTE_DEVICE_DECL and RTE_DEVICE_PTR_DECL are introduced to
provide a generic way to declare a device or a pointer to a device. The macros
aim to preserve API backwards-compatibility. Eg.

struct old_super_struct {             =>   struct old_super_struct {
    struct rte_pci_device *pci_dev;   =>        RTE_DEVICE_PTR_DECL(pci_dev);
    ...                               =>       ...
};                                    =>   };

struct old_super_struct inst;

The new code should reference inst.dev.pci, the old code can still use the
inst.pci_dev. The previously introduced magic is included so one can ask the
instance about its type:

if (inst.dev.magic == RTE_PCI_DEVICE_MAGIC) {
    ...
}

I don't like to include the rte_pci.h header here, however, I didn't find
a better way at the moment.

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

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index f1b5507..c99d038 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -49,6 +49,7 @@ extern "C" {
 #include <stdio.h>
 #include <sys/queue.h>
 
+#include <rte_pci.h>
 #include <rte_log.h>
 
 __attribute__((format(printf, 2, 0)))
@@ -134,6 +135,32 @@ struct rte_driver {
 };
 
 /**
+ * Generic representation of a device.
+ */
+union rte_device {
+	unsigned int magic;
+	struct rte_pci_device pci;
+};
+
+/**
+ * The macro preserves API backwards compatibility.
+ */
+#define RTE_DEVICE_DECL(_pci)               \
+	union {                             \
+		union rte_device dev;       \
+		struct rte_pci_device _pci; \
+	}
+
+/**
+ * The macro preserves API backwards compatibility.
+ */
+#define RTE_DEVICE_PTR_DECL(_pci)            \
+	union {                              \
+		union rte_device *dev;       \
+		struct rte_pci_device *_pci; \
+	}
+
+/**
  * Register a device driver.
  *
  * @param driver
-- 
2.6.3

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

* [dpdk-dev] [PATCH 04/14] eal/common: introduce function to_pci_driver
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (2 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 05/14] eal/common: introduce function to_pci_device Jan Viktorin
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_cryptodev/rte_cryptodev.c    |  3 +--
 lib/librte_eal/common/include/rte_pci.h | 12 ++++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index f09f67e..682c1aa 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -424,8 +424,7 @@ rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv,
 {
 	/* Call crypto device initialization directly if device is virtual */
 	if (type == PMD_VDEV)
-		return rte_cryptodev_init((struct rte_pci_driver *)cryptodrv,
-				NULL);
+		return rte_cryptodev_init(to_pci_driver(cryptodrv), NULL);
 
 	/*
 	 * Register PCI driver for physical device intialisation during
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 54d0fe2..1321654 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -82,6 +82,7 @@ extern "C" {
 #include <stdint.h>
 #include <inttypes.h>
 
+#include <rte_debug.h>
 #include <rte_interrupts.h>
 
 TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */
@@ -215,6 +216,17 @@ struct rte_pci_driver {
 	uint32_t drv_flags;                     /**< Flags contolling handling of device. */
 };
 
+static inline struct rte_pci_driver *
+to_pci_driver(void *p)
+{
+	unsigned int *magic = (unsigned int *) p;
+	if (*magic == RTE_PCI_DRV_MAGIC)
+		return (struct rte_pci_driver *) p;
+
+	rte_panic("%s: bad cast (%p: %08x)\n", __func__, p, *magic);
+	return NULL;
+}
+
 /** 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 */
-- 
2.6.3

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

* [dpdk-dev] [PATCH 05/14] eal/common: introduce function to_pci_device
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (3 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 04/14] eal/common: introduce function to_pci_driver Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 06/14] Include rte_dev.h instead of rte_pci.h Jan Viktorin
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

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

diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 1321654..204ee82 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -171,6 +171,17 @@ struct rte_pci_device {
 	enum rte_kernel_driver kdrv;            /**< Kernel driver passthrough */
 };
 
+static inline struct rte_pci_device *
+to_pci_device(void *p)
+{
+	unsigned int *magic = (unsigned int *) p;
+	if (*magic == RTE_PCI_DEVICE_MAGIC)
+		return (struct rte_pci_device *) p;
+
+	rte_panic("%s: bad cast (%p: %08x)\n", __func__, p, *magic);
+	return NULL;
+}
+
 /** Any PCI device identifier (vendor, device, ...) */
 #define PCI_ANY_ID (0xffff)
 
-- 
2.6.3

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

* [dpdk-dev] [PATCH 06/14] Include rte_dev.h instead of rte_pci.h
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (4 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 05/14] eal/common: introduce function to_pci_device Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 07/14] lib/ether: generalize rte_eth_dev_init/uninit Jan Viktorin
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

As rte_dev.h now include rte_pci.h, we can remove the rte_pci.h inclusion
among all DPDK code base or replace it by a more general rte_dev.h inclusion.

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 app/test-pipeline/config.c                                 | 2 +-
 app/test-pipeline/init.c                                   | 2 +-
 app/test-pipeline/main.c                                   | 2 +-
 app/test-pipeline/runtime.c                                | 2 +-
 app/test-pmd/cmdline.c                                     | 2 +-
 app/test-pmd/config.c                                      | 2 +-
 app/test-pmd/csumonly.c                                    | 2 +-
 app/test-pmd/flowgen.c                                     | 2 +-
 app/test-pmd/iofwd.c                                       | 2 +-
 app/test-pmd/macfwd-retry.c                                | 2 +-
 app/test-pmd/macfwd.c                                      | 2 +-
 app/test-pmd/macswap.c                                     | 2 +-
 app/test-pmd/parameters.c                                  | 2 +-
 app/test-pmd/rxonly.c                                      | 2 +-
 app/test-pmd/testpmd.c                                     | 2 +-
 app/test-pmd/txonly.c                                      | 2 +-
 app/test/test_pci.c                                        | 2 +-
 drivers/net/bnx2x/bnx2x_ethdev.h                           | 2 +-
 drivers/net/cxgbe/base/t4_hw.c                             | 2 +-
 drivers/net/cxgbe/cxgbe_ethdev.c                           | 2 +-
 drivers/net/cxgbe/cxgbe_main.c                             | 2 +-
 drivers/net/cxgbe/sge.c                                    | 2 +-
 drivers/net/e1000/em_ethdev.c                              | 2 +-
 drivers/net/e1000/em_rxtx.c                                | 2 +-
 drivers/net/e1000/igb_ethdev.c                             | 2 +-
 drivers/net/e1000/igb_rxtx.c                               | 2 +-
 drivers/net/enic/base/vnic_dev.h                           | 2 +-
 drivers/net/enic/enic_ethdev.c                             | 1 -
 drivers/net/enic/enic_main.c                               | 2 +-
 drivers/net/i40e/i40e_ethdev.c                             | 2 +-
 drivers/net/i40e/i40e_ethdev_vf.c                          | 2 +-
 drivers/net/i40e/i40e_pf.c                                 | 2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c                           | 2 +-
 drivers/net/ixgbe/ixgbe_fdir.c                             | 2 +-
 drivers/net/ixgbe/ixgbe_rxtx.c                             | 2 +-
 drivers/net/mlx5/mlx5.c                                    | 2 +-
 drivers/net/virtio/virtio_ethdev.c                         | 2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c                       | 2 +-
 drivers/net/vmxnet3/vmxnet3_rxtx.c                         | 2 +-
 examples/bond/main.c                                       | 2 +-
 examples/dpdk_qat/main.c                                   | 2 +-
 examples/exception_path/main.c                             | 2 +-
 examples/ip_fragmentation/main.c                           | 2 +-
 examples/ip_reassembly/main.c                              | 2 +-
 examples/ipv4_multicast/main.c                             | 2 +-
 examples/kni/main.c                                        | 2 +-
 examples/l2fwd-crypto/main.c                               | 2 +-
 examples/l2fwd-ivshmem/guest/guest.c                       | 2 +-
 examples/l2fwd-jobstats/main.c                             | 2 +-
 examples/l2fwd-keepalive/main.c                            | 2 +-
 examples/l2fwd/main.c                                      | 2 +-
 examples/l3fwd-acl/main.c                                  | 2 +-
 examples/l3fwd-power/main.c                                | 2 +-
 examples/l3fwd-vf/main.c                                   | 2 +-
 examples/l3fwd/main.c                                      | 2 +-
 examples/link_status_interrupt/main.c                      | 2 +-
 examples/load_balancer/config.c                            | 2 +-
 examples/load_balancer/init.c                              | 2 +-
 examples/load_balancer/main.c                              | 2 +-
 examples/load_balancer/runtime.c                           | 2 +-
 examples/multi_process/client_server_mp/mp_client/client.c | 2 +-
 examples/multi_process/client_server_mp/mp_server/init.c   | 2 +-
 examples/multi_process/client_server_mp/mp_server/main.c   | 2 +-
 examples/multi_process/l2fwd_fork/flib.c                   | 2 +-
 examples/multi_process/l2fwd_fork/main.c                   | 2 +-
 examples/multi_process/symmetric_mp/main.c                 | 2 +-
 examples/performance-thread/l3fwd-thread/main.c            | 2 +-
 examples/vmdq/main.c                                       | 2 +-
 examples/vmdq_dcb/main.c                                   | 2 +-
 lib/librte_cryptodev/rte_cryptodev.c                       | 1 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h                   | 1 -
 lib/librte_eal/bsdapp/eal/eal.c                            | 1 -
 lib/librte_eal/bsdapp/eal/eal_pci.c                        | 2 +-
 lib/librte_eal/common/eal_common_devargs.c                 | 2 +-
 lib/librte_eal/common/eal_common_pci.c                     | 2 +-
 lib/librte_eal/common/eal_private.h                        | 2 +-
 lib/librte_eal/common/include/rte_devargs.h                | 2 +-
 lib/librte_eal/linuxapp/eal/eal.c                          | 2 +-
 lib/librte_eal/linuxapp/eal/eal_interrupts.c               | 2 +-
 lib/librte_eal/linuxapp/eal/eal_ivshmem.c                  | 2 +-
 lib/librte_ether/rte_ethdev.c                              | 2 +-
 lib/librte_ether/rte_ethdev.h                              | 1 -
 82 files changed, 77 insertions(+), 82 deletions(-)

diff --git a/app/test-pipeline/config.c b/app/test-pipeline/config.c
index 72e018c..0bb1b26 100644
--- a/app/test-pipeline/config.c
+++ b/app/test-pipeline/config.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/app/test-pipeline/init.c b/app/test-pipeline/init.c
index db2196b..2b27e07 100644
--- a/app/test-pipeline/init.c
+++ b/app/test-pipeline/init.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/app/test-pipeline/main.c b/app/test-pipeline/main.c
index 685ebd4..10ed8e9 100644
--- a/app/test-pipeline/main.c
+++ b/app/test-pipeline/main.c
@@ -59,7 +59,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/app/test-pipeline/runtime.c b/app/test-pipeline/runtime.c
index 42a6142..d9e7762 100644
--- a/app/test-pipeline/runtime.c
+++ b/app/test-pipeline/runtime.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 73298c9..5ec885f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -69,7 +69,7 @@
 #include <rte_ring.h>
 #include <rte_mempool.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 7088f6f..fee6724 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -88,7 +88,7 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 7e4f662..3d1fc86 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -62,7 +62,7 @@
 #include <rte_mbuf.h>
 #include <rte_memcpy.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ip.h>
diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c
index e3620f5..97f878d 100644
--- a/app/test-pmd/flowgen.c
+++ b/app/test-pmd/flowgen.c
@@ -62,7 +62,7 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ip.h>
diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c
index 8840d86..653d061 100644
--- a/app/test-pmd/iofwd.c
+++ b/app/test-pmd/iofwd.c
@@ -61,7 +61,7 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
diff --git a/app/test-pmd/macfwd-retry.c b/app/test-pmd/macfwd-retry.c
index 3a96b3d..5ea2567 100644
--- a/app/test-pmd/macfwd-retry.c
+++ b/app/test-pmd/macfwd-retry.c
@@ -61,7 +61,7 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ip.h>
diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c
index 3b7fffb..ff01733 100644
--- a/app/test-pmd/macfwd.c
+++ b/app/test-pmd/macfwd.c
@@ -61,7 +61,7 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ip.h>
diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c
index 154889d..85124c8 100644
--- a/app/test-pmd/macswap.c
+++ b/app/test-pmd/macswap.c
@@ -61,7 +61,7 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ip.h>
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 4b421c8..e53ec5b 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -66,7 +66,7 @@
 #include <rte_ring.h>
 #include <rte_mempool.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 14555ab..9c01d3e 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -61,7 +61,7 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 98ae46d..118f857 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -67,7 +67,7 @@
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_dev.h>
diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
index a903d4f..69db1cf 100644
--- a/app/test-pmd/txonly.c
+++ b/app/test-pmd/txonly.c
@@ -62,7 +62,7 @@
 #include <rte_mbuf.h>
 #include <rte_memcpy.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_ip.h>
diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index 5530d99..9d8ec8e 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -38,7 +38,7 @@
 #include <sys/queue.h>
 
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ethdev.h>
 #include <rte_devargs.h>
 
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.h b/drivers/net/bnx2x/bnx2x_ethdev.h
index a9da9de..3edf465 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.h
+++ b/drivers/net/bnx2x/bnx2x_ethdev.h
@@ -31,7 +31,7 @@
 #include <rte_cycles.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_malloc.h>
 #include <rte_ethdev.h>
 #include <rte_spinlock.h>
diff --git a/drivers/net/cxgbe/base/t4_hw.c b/drivers/net/cxgbe/base/t4_hw.c
index 884d2cf..cf48ee4 100644
--- a/drivers/net/cxgbe/base/t4_hw.c
+++ b/drivers/net/cxgbe/base/t4_hw.c
@@ -36,7 +36,7 @@
 #include <rte_interrupts.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index 6807e50..22b843c 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -47,7 +47,7 @@
 #include <rte_interrupts.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c
index aff23d0..ce6f6c8 100644
--- a/drivers/net/cxgbe/cxgbe_main.c
+++ b/drivers/net/cxgbe/cxgbe_main.c
@@ -47,7 +47,7 @@
 #include <rte_interrupts.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c
index 3c62d03..e3b9507 100644
--- a/drivers/net/cxgbe/sge.c
+++ b/drivers/net/cxgbe/sge.c
@@ -47,7 +47,7 @@
 #include <rte_interrupts.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index ffd0363..efde4ce 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -42,7 +42,7 @@
 #include <rte_byteorder.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_memory.h>
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index d8fb252..6486c61 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -46,7 +46,7 @@
 #include <rte_common.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_memory.h>
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 413072d..04edcc0 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -42,7 +42,7 @@
 #include <rte_byteorder.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_memory.h>
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 996e7da..0d3ebea 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -46,7 +46,7 @@
 #include <rte_common.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_memory.h>
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
diff --git a/drivers/net/enic/base/vnic_dev.h b/drivers/net/enic/base/vnic_dev.h
index 113d6ac..11652fc 100644
--- a/drivers/net/enic/base/vnic_dev.h
+++ b/drivers/net/enic/base/vnic_dev.h
@@ -36,7 +36,7 @@
 #define _VNIC_DEV_H_
 
 #include "enic_compat.h"
-#include "rte_pci.h"
+#include "rte_dev.h"
 #include "vnic_resource.h"
 #include "vnic_devcmd.h"
 
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 44ea5f9..3991553 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -36,7 +36,6 @@
 #include <stdint.h>
 
 #include <rte_dev.h>
-#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
 
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index 07a9810..2ecfbe5 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -39,7 +39,7 @@
 #include <fcntl.h>
 #include <libgen.h>
 
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_memzone.h>
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index f642bce..2f7ad5b 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -42,7 +42,7 @@
 #include <assert.h>
 
 #include <rte_string_fns.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_memzone.h>
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index e1b3e8f..63ea77d 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -46,7 +46,7 @@
 #include <rte_interrupts.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index cbf4e5b..ac1d887 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -41,7 +41,7 @@
 #include <inttypes.h>
 
 #include <rte_string_fns.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_memzone.h>
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 637731c..7158386 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -47,7 +47,7 @@
 #include <rte_interrupts.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
diff --git a/drivers/net/ixgbe/ixgbe_fdir.c b/drivers/net/ixgbe/ixgbe_fdir.c
index e03219b..5a9fd3f 100644
--- a/drivers/net/ixgbe/ixgbe_fdir.c
+++ b/drivers/net/ixgbe/ixgbe_fdir.c
@@ -40,7 +40,7 @@
 #include <rte_interrupts.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 52a263c..67bcd08 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -49,7 +49,7 @@
 #include <rte_log.h>
 #include <rte_debug.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
 #include <rte_launch.h>
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index da33ecf..b829f8f 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -55,7 +55,7 @@
 #endif
 #include <rte_malloc.h>
 #include <rte_ethdev.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_common.h>
 #ifdef PEDANTIC
 #pragma GCC diagnostic error "-pedantic"
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 9816a98..957f8a2 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -48,7 +48,7 @@
 #include <rte_malloc.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_common.h>
 #include <rte_errno.h>
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index d84acd8..db274cc 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -47,7 +47,7 @@
 #include <rte_interrupts.h>
 #include <rte_log.h>
 #include <rte_debug.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
 #include <rte_memory.h>
diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index 4de5d89..4d8731d 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
@@ -48,7 +48,7 @@
 #include <rte_log.h>
 #include <rte_debug.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
 #include <rte_launch.h>
diff --git a/examples/bond/main.c b/examples/bond/main.c
index 53bd044..b1051fa 100644
--- a/examples/bond/main.c
+++ b/examples/bond/main.c
@@ -62,7 +62,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/dpdk_qat/main.c b/examples/dpdk_qat/main.c
index dc68989..00ba37e 100644
--- a/examples/dpdk_qat/main.c
+++ b/examples/dpdk_qat/main.c
@@ -57,7 +57,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c
index b3fe170..d6a050c 100644
--- a/examples/exception_path/main.c
+++ b/examples/exception_path/main.c
@@ -61,7 +61,7 @@
 #include <rte_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index fbc0b8d..24da657 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -59,7 +59,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index 741c398..cecb791 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -60,7 +60,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c
index d4253c0..b0167ee 100644
--- a/examples/ipv4_multicast/main.c
+++ b/examples/ipv4_multicast/main.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/kni/main.c b/examples/kni/main.c
index 6d434ad..1457169 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -61,7 +61,7 @@
 #include <rte_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index d70fc9a..01d1dff 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -67,7 +67,7 @@
 #include <rte_memory.h>
 #include <rte_mempool.h>
 #include <rte_memzone.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_per_lcore.h>
 #include <rte_prefetch.h>
 #include <rte_random.h>
diff --git a/examples/l2fwd-ivshmem/guest/guest.c b/examples/l2fwd-ivshmem/guest/guest.c
index 7c49521..38287d7 100644
--- a/examples/l2fwd-ivshmem/guest/guest.c
+++ b/examples/l2fwd-ivshmem/guest/guest.c
@@ -65,7 +65,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index 7b59f4e..15ceadd 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -54,7 +54,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index f4d52f2..1c17791 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -60,7 +60,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 720fd5a..0215eab 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -60,7 +60,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index f676d14..4202347 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 828c18a..b4803ce 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -60,7 +60,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c
index 01f610e..5e4aa26 100644
--- a/examples/l3fwd-vf/main.c
+++ b/examples/l3fwd-vf/main.c
@@ -60,7 +60,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 5b0c2dd..5146235 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -59,7 +59,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c
index c57a08a..c8e4f39 100644
--- a/examples/link_status_interrupt/main.c
+++ b/examples/link_status_interrupt/main.c
@@ -61,7 +61,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/load_balancer/config.c b/examples/load_balancer/config.c
index 3f6ddee..161d621 100644
--- a/examples/load_balancer/config.c
+++ b/examples/load_balancer/config.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/load_balancer/init.c b/examples/load_balancer/init.c
index 5a56078..30f77d4 100644
--- a/examples/load_balancer/init.c
+++ b/examples/load_balancer/init.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/load_balancer/main.c b/examples/load_balancer/main.c
index 7ede358..d474bc3 100644
--- a/examples/load_balancer/main.c
+++ b/examples/load_balancer/main.c
@@ -59,7 +59,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/load_balancer/runtime.c b/examples/load_balancer/runtime.c
index 2b265c2..7c96ab4 100644
--- a/examples/load_balancer/runtime.c
+++ b/examples/load_balancer/runtime.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/multi_process/client_server_mp/mp_client/client.c b/examples/multi_process/client_server_mp/mp_client/client.c
index bf049a4..6d204a0 100644
--- a/examples/multi_process/client_server_mp/mp_client/client.c
+++ b/examples/multi_process/client_server_mp/mp_client/client.c
@@ -58,7 +58,7 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c
index 7afd51a..ba60a89 100644
--- a/examples/multi_process/client_server_mp/mp_server/init.c
+++ b/examples/multi_process/client_server_mp/mp_server/init.c
@@ -56,7 +56,7 @@
 #include <rte_memcpy.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_malloc.h>
diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c
index de54c67..f42f2a7 100644
--- a/examples/multi_process/client_server_mp/mp_server/main.c
+++ b/examples/multi_process/client_server_mp/mp_server/main.c
@@ -61,7 +61,7 @@
 #include <rte_mbuf.h>
 #include <rte_ether.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ethdev.h>
 #include <rte_byteorder.h>
 #include <rte_malloc.h>
diff --git a/examples/multi_process/l2fwd_fork/flib.c b/examples/multi_process/l2fwd_fork/flib.c
index 343f09f..5a00c28 100644
--- a/examples/multi_process/l2fwd_fork/flib.c
+++ b/examples/multi_process/l2fwd_fork/flib.c
@@ -65,7 +65,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/multi_process/l2fwd_fork/main.c b/examples/multi_process/l2fwd_fork/main.c
index f2d7eab..500c354 100644
--- a/examples/multi_process/l2fwd_fork/main.c
+++ b/examples/multi_process/l2fwd_fork/main.c
@@ -63,7 +63,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c
index 931c94f..2c37126 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -67,7 +67,7 @@
 #include <rte_ring.h>
 #include <rte_debug.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_mempool.h>
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index db6cb64..4727766 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -61,7 +61,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c
index 178af2f..d2cc5cb 100644
--- a/examples/vmdq/main.c
+++ b/examples/vmdq/main.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index b90ac28..be7e4ca 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -58,7 +58,7 @@
 #include <rte_per_lcore.h>
 #include <rte_branch_prediction.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_random.h>
 #include <rte_debug.h>
 #include <rte_ether.h>
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 682c1aa..484980e 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -47,7 +47,6 @@
 #include <rte_debug.h>
 #include <rte_dev.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
 #include <rte_memory.h>
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 8270afa..8e2a385 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -47,7 +47,6 @@ extern "C" {
 #include <string.h>
 
 #include <rte_dev.h>
-#include <rte_pci.h>
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
 #include <rte_mempool.h>
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index a34e61d..a7065a6 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -64,7 +64,6 @@
 #include <rte_string_fns.h>
 #include <rte_cpuflags.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
 #include <rte_dev.h>
 #include <rte_devargs.h>
 #include <rte_common.h>
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 6c21fbd..efc99ae 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -53,7 +53,7 @@
 
 #include <rte_interrupts.h>
 #include <rte_log.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_common.h>
 #include <rte_launch.h>
 #include <rte_memory.h>
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 5d075d0..e0fa427 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -40,7 +40,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_devargs.h>
 #include "eal_private.h"
 
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index dcfe947..5927c2b 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -71,7 +71,7 @@
 
 #include <rte_interrupts.h>
 #include <rte_log.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_per_lcore.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 072e672..21d3413 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -35,7 +35,7 @@
 #define _EAL_PRIVATE_H_
 
 #include <stdio.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 
 /**
  * Initialize the memzone subsystem (private to eal).
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 53c59f5..0031f81 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -50,7 +50,7 @@ extern "C" {
 
 #include <stdio.h>
 #include <sys/queue.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 
 /**
  * Type of generic device
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 635ec36..1b15133 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -68,7 +68,7 @@
 #include <rte_string_fns.h>
 #include <rte_cpuflags.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_devargs.h>
 #include <rte_common.h>
 #include <rte_version.h>
diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
index 06b26a9..4de6684 100644
--- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
+++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
@@ -61,7 +61,7 @@
 #include <rte_debug.h>
 #include <rte_log.h>
 #include <rte_mempool.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_malloc.h>
 #include <rte_errno.h>
 #include <rte_spinlock.h>
diff --git a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
index 589019b..d064106 100644
--- a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
+++ b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
@@ -42,7 +42,7 @@
 #include <sys/queue.h>
 
 #include <rte_log.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_memory.h>
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ed971b4..21fc0d7 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -47,7 +47,7 @@
 #include <rte_log.h>
 #include <rte_debug.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
+#include <rte_dev.h>
 #include <rte_memory.h>
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index bada8ad..5a267e4 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -179,7 +179,6 @@ extern "C" {
 
 #include <rte_log.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
 #include <rte_dev.h>
 #include <rte_devargs.h>
 #include "rte_ether.h"
-- 
2.6.3

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

* [dpdk-dev] [PATCH 07/14] lib/ether: generalize rte_eth_dev_init/uninit
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (5 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 06/14] Include rte_dev.h instead of rte_pci.h Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 08/14] eal/common: introduce rte_bus_addr Jan Viktorin
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Generalize strict PCI-specific initialization and uninitialization steps and
prepare the code to be easily reused for other infrastructures. API of the
eth_driver stays backwards compatible. The previously introduced magic is
utilized to test whether we are working with a PCI device or not.

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_ether/rte_ethdev.c | 118 ++++++++++++++++++++++++++++--------------
 lib/librte_ether/rte_ethdev.h |   9 ++--
 2 files changed, 85 insertions(+), 42 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 21fc0d7..826d4b9 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -216,16 +216,23 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 
 static int
 rte_eth_dev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
+		union rte_device *dev)
 {
 	int ret;
 
-	if ((name == NULL) || (pci_dev == NULL))
+	if ((name == NULL) || (dev == NULL))
 		return -EINVAL;
 
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
+	switch (dev->magic) {
+	case RTE_PCI_DEVICE_MAGIC:
+		ret = snprintf(name, size, "%d:%d.%d",
+			dev->pci.addr.bus, dev->pci.addr.devid,
+			dev->pci.addr.function);
+		break;
+	default:
+		ret = -ENODEV;
+	}
+
 	if (ret < 0)
 		return ret;
 	return 0;
@@ -243,33 +250,41 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 }
 
 static int
-rte_eth_dev_init(struct rte_pci_driver *pci_drv,
-		 struct rte_pci_device *pci_dev)
+rte_device_get_dev_type(union rte_device *dev)
+{
+	switch (dev->magic) {
+	case RTE_PCI_DEVICE_MAGIC:
+		return RTE_ETH_DEV_PCI;
+	default:
+		return RTE_ETH_DEV_UNKNOWN;
+	}
+}
+
+static int
+rte_eth_dev_init(struct eth_driver *eth_drv, union rte_device *dev)
 {
-	struct eth_driver    *eth_drv;
 	struct rte_eth_dev *eth_dev;
 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
-
 	int diag;
 
-	eth_drv = (struct eth_driver *)pci_drv;
-
-	/* Create unique Ethernet device name using PCI address */
+	/* Create unique Ethernet device name */
 	rte_eth_dev_create_unique_device_name(ethdev_name,
-			sizeof(ethdev_name), pci_dev);
+			sizeof(ethdev_name), dev);
 
-	eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
+	eth_dev = rte_eth_dev_allocate(ethdev_name,
+			rte_device_get_dev_type(dev));
 	if (eth_dev == NULL)
 		return -ENOMEM;
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		eth_dev->data->dev_private = rte_zmalloc("ethdev private structure",
-				  eth_drv->dev_private_size,
-				  RTE_CACHE_LINE_SIZE);
+				eth_drv->dev_private_size,
+				RTE_CACHE_LINE_SIZE);
 		if (eth_dev->data->dev_private == NULL)
 			rte_panic("Cannot allocate memzone for private port data\n");
 	}
-	eth_dev->pci_dev = pci_dev;
+
+	eth_dev->dev = dev;
 	eth_dev->driver = eth_drv;
 	eth_dev->data->rx_mbuf_alloc_failed = 0;
 
@@ -286,10 +301,6 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 	if (diag == 0)
 		return 0;
 
-	RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x) failed\n",
-			pci_drv->name,
-			(unsigned) pci_dev->id.vendor_id,
-			(unsigned) pci_dev->id.device_id);
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		rte_free(eth_dev->data->dev_private);
 	rte_eth_dev_release_port(eth_dev);
@@ -297,29 +308,41 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 }
 
 static int
-rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
+rte_eth_dev_pci_init(struct rte_pci_driver *pci_drv,
+		 struct rte_pci_device *pci_dev)
+{
+	struct eth_driver *eth_drv = (struct eth_driver *)pci_drv;
+	union rte_device *dev = (union rte_device *) pci_dev;
+	int rc;
+
+	if ((rc = rte_eth_dev_init(eth_drv, dev))) {
+		RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x) failed\n",
+				pci_drv->name,
+				(unsigned) pci_dev->id.vendor_id,
+				(unsigned) pci_dev->id.device_id);
+		return rc;
+	}
+
+	return 0;
+}
+
+static int
+rte_eth_dev_uninit(struct eth_driver *eth_drv)
 {
-	const struct eth_driver *eth_drv;
+	union rte_device *dev = (union rte_device *) eth_drv;
 	struct rte_eth_dev *eth_dev;
 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
-	int ret;
 
-	if (pci_dev == NULL)
-		return -EINVAL;
-
-	/* Create unique Ethernet device name using PCI address */
+	/* Create unique Ethernet device name */
 	rte_eth_dev_create_unique_device_name(ethdev_name,
-			sizeof(ethdev_name), pci_dev);
+			sizeof(ethdev_name), dev);
 
 	eth_dev = rte_eth_dev_allocated(ethdev_name);
 	if (eth_dev == NULL)
 		return -ENODEV;
 
-	eth_drv = (const struct eth_driver *)pci_dev->driver;
-
-	/* Invoke PMD device uninit function */
 	if (*eth_drv->eth_dev_uninit) {
-		ret = (*eth_drv->eth_dev_uninit)(eth_dev);
+		int ret = (*eth_drv->eth_dev_uninit)(eth_dev);
 		if (ret)
 			return ret;
 	}
@@ -330,13 +353,26 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		rte_free(eth_dev->data->dev_private);
 
-	eth_dev->pci_dev = NULL;
+	eth_dev->dev = NULL;
 	eth_dev->driver = NULL;
 	eth_dev->data = NULL;
 
 	return 0;
 }
 
+static int
+rte_eth_dev_pci_uninit(struct rte_pci_device *pci_dev)
+{
+	struct eth_driver *eth_drv;
+
+	if (pci_dev == NULL || pci_dev->driver == NULL)
+		return -EINVAL;
+
+	eth_drv = (struct eth_driver *) pci_dev->driver;
+
+	return rte_eth_dev_uninit(eth_drv);
+}
+
 /**
  * Register an Ethernet [Poll Mode] driver.
  *
@@ -345,18 +381,22 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
  * Poll Mode Driver.
  * Invokes the rte_eal_pci_register() function to register the *pci_drv*
  * structure embedded in the *eth_drv* structure, after having stored the
- * address of the rte_eth_dev_init() function in the *devinit* field of
+ * address of the rte_eth_dev_pci_init() function in the *devinit* field of
  * the *pci_drv* structure.
- * During the PCI probing phase, the rte_eth_dev_init() function is
+ * During the PCI probing phase, the rte_eth_dev_pci_init() function is
  * invoked for each PCI [Ethernet device] matching the embedded PCI
  * identifiers provided by the driver.
  */
 void
 rte_eth_driver_register(struct eth_driver *eth_drv)
 {
-	eth_drv->pci_drv.devinit = rte_eth_dev_init;
-	eth_drv->pci_drv.devuninit = rte_eth_dev_uninit;
-	rte_eal_pci_register(&eth_drv->pci_drv);
+	if (eth_drv->magic == RTE_PCI_DRV_MAGIC) {
+		eth_drv->pci_drv.devinit = rte_eth_dev_pci_init;
+		eth_drv->pci_drv.devuninit = rte_eth_dev_pci_uninit;
+		rte_eal_pci_register(&eth_drv->pci_drv);
+	} else {
+		rte_panic("%s(): bad magic: %08x\n", __func__, eth_drv->magic);
+	}
 }
 
 int
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 5a267e4..5dd2e1a 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -824,7 +824,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_QINQ_INSERT 0x00000100
 
 struct rte_eth_dev_info {
-	struct rte_pci_device *pci_dev; /**< Device PCI information. */
+	RTE_DEVICE_PTR_DECL(pci_dev); /**< Device information. */
 	const char *driver_name; /**< Device Driver name. */
 	unsigned int if_index; /**< Index to bound host interface, or 0 if none.
 		Use if_indextoname() to translate into an interface name. */
@@ -1534,7 +1534,7 @@ struct rte_eth_dev {
 	struct rte_eth_dev_data *data;  /**< Pointer to device data */
 	const struct eth_driver *driver;/**< Driver for this device */
 	const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
-	struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
+	RTE_DEVICE_PTR_DECL(pci_dev); /**< Device information. */
 	/** User application callbacks for NIC interrupts */
 	struct rte_eth_dev_cb_list link_intr_cbs;
 	/**
@@ -1767,7 +1767,10 @@ typedef int (*eth_dev_uninit_t)(struct rte_eth_dev *eth_dev);
  * - The size of the private data to allocate for each matching device.
  */
 struct eth_driver {
-	struct rte_pci_driver pci_drv;    /**< The PMD is also a PCI driver. */
+	union {
+		unsigned int magic;
+		struct rte_pci_driver pci_drv; /**< The PMD is a PCI driver. */
+	};
 	eth_dev_init_t eth_dev_init;      /**< Device init function. */
 	eth_dev_uninit_t eth_dev_uninit;  /**< Device uninit function. */
 	unsigned int dev_private_size;    /**< Size of device private data. */
-- 
2.6.3

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

* [dpdk-dev] [PATCH 08/14] eal/common: introduce rte_bus_addr
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (6 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 07/14] lib/ether: generalize rte_eth_dev_init/uninit Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 09/14] lib/ether: generalize attach/detach of devices Jan Viktorin
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

To support a generic manipulation with devices we need to have a general
representation of the rte_*_addr which replaces the rte_pci_addr in the code.
Here we introduce the rte_bus_addr consisting of a union of various rte_*_addr
fields and the device magic to discriminate among them.

A wrapper around rte_eal_compare_pci_addr is introduced and it will be extended
while adding a new non-PCI infra.

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

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index c99d038..48c46fd 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -161,6 +161,23 @@ union rte_device {
 	}
 
 /**
+ * Generic bus address of a device.
+ */
+struct rte_bus_addr {
+	union {
+		struct rte_pci_addr pci;
+	};
+	unsigned int dev_magic;
+};
+
+static inline int
+rte_eal_compare_bus_addr(const struct rte_bus_addr *a,
+		const struct rte_bus_addr *b)
+{
+	return rte_eal_compare_pci_addr(&a->pci, &b->pci);
+}
+
+/**
  * Register a device driver.
  *
  * @param driver
-- 
2.6.3

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

* [dpdk-dev] [PATCH 09/14] lib/ether: generalize attach/detach of devices
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (7 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 08/14] eal/common: introduce rte_bus_addr Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 10/14] lib/ether: copy the rte_device union instead of rte_pci_device Jan Viktorin
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Make the attach and detach functions independent on the PCI infra. Mostly, this
means to utilize the rte_bus_addr instead of rte_pci_addr.

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_ether/rte_ethdev.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 826d4b9..db12515 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -432,7 +432,7 @@ rte_eth_dev_get_device_type(uint8_t port_id)
 }
 
 static int
-rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
+rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_bus_addr *addr)
 {
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
@@ -441,8 +441,15 @@ rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
 		return -EINVAL;
 	}
 
-	*addr = rte_eth_devices[port_id].pci_dev->addr;
-	return 0;
+	if (rte_eth_devices[port_id].dev_type == RTE_ETH_DEV_PCI) {
+		addr->pci = rte_eth_devices[port_id].pci_dev->addr;
+		addr->dev_magic = RTE_PCI_DEVICE_MAGIC;
+		return 0;
+	} else {
+		rte_panic("%s(): unexpected dev_type: %u\n", __func__,
+				rte_eth_devices[port_id].dev_type);
+		return -ENODEV;
+	}
 }
 
 static int
@@ -566,10 +573,10 @@ err:
 
 /* detach the new physical device, then store pci_addr of the device */
 static int
-rte_eth_dev_detach_pdev(uint8_t port_id, struct rte_pci_addr *addr)
+rte_eth_dev_detach_pdev(uint8_t port_id, struct rte_bus_addr *addr)
 {
-	struct rte_pci_addr freed_addr;
-	struct rte_pci_addr vp;
+	struct rte_bus_addr freed_addr;
+	struct rte_bus_addr vp;
 
 	if (addr == NULL)
 		goto err;
@@ -583,13 +590,16 @@ rte_eth_dev_detach_pdev(uint8_t port_id, struct rte_pci_addr *addr)
 		goto err;
 
 	/* Zeroed pci addr means the port comes from virtual device */
-	vp.domain = vp.bus = vp.devid = vp.function = 0;
-	if (rte_eal_compare_pci_addr(&vp, &freed_addr) == 0)
+	memset(&vp, 0, sizeof(vp));
+	if (rte_eal_compare_bus_addr(&vp, &freed_addr) == 0)
 		goto err;
 
 	/* invoke devuninit func of the pci driver,
 	 * also remove the device from pci_device_list */
-	if (rte_eal_pci_detach(&freed_addr))
+	if (freed_addr.dev_magic == RTE_PCI_DEVICE_MAGIC) {
+		if (rte_eal_pci_detach(&freed_addr.pci))
+			goto err;
+	} else
 		goto err;
 
 	*addr = freed_addr;
@@ -683,7 +693,7 @@ rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 int
 rte_eth_dev_detach(uint8_t port_id, char *name)
 {
-	struct rte_pci_addr addr;
+	struct rte_bus_addr addr;
 	int ret;
 
 	if (name == NULL)
@@ -698,8 +708,8 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
 		if (ret == 0)
 			snprintf(name, RTE_ETH_NAME_MAX_LEN,
 				"%04x:%02x:%02x.%d",
-				addr.domain, addr.bus,
-				addr.devid, addr.function);
+				addr.pci.domain, addr.pci.bus,
+				addr.pci.devid, addr.pci.function);
 
 		return ret;
 	} else
-- 
2.6.3

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

* [dpdk-dev] [PATCH 10/14] lib/ether: copy the rte_device union instead of rte_pci_device
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (8 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 09/14] lib/ether: generalize attach/detach of devices Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 11/14] lib/ether: extract function rte_device_get_intr_handle Jan Viktorin
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_ether/rte_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index db12515..a9007e7 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1660,7 +1660,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 
 	RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
-	dev_info->pci_dev = dev->pci_dev;
+	dev_info->dev = dev->dev;
 	dev_info->driver_name = dev->data->drv_name;
 }
 
-- 
2.6.3

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

* [dpdk-dev] [PATCH 11/14] lib/ether: extract function rte_device_get_intr_handle
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (9 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 10/14] lib/ether: copy the rte_device union instead of rte_pci_device Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 12/14] lib/ether: check magic before naming a zone Jan Viktorin
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_ether/rte_ethdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index a9007e7..b17aa11 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2606,6 +2606,17 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
 	rte_spinlock_unlock(&rte_eth_dev_cb_lock);
 }
 
+static struct rte_intr_handle *
+rte_device_get_intr_handle(union rte_device *dev)
+{
+	switch (dev->magic) {
+	case RTE_PCI_DEVICE_MAGIC:
+		return &dev->pci.intr_handle;
+	default:
+		return NULL;
+	}
+}
+
 int
 rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 {
@@ -2621,7 +2632,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 = rte_device_get_intr_handle(dev->dev);
 	if (!intr_handle->intr_vec) {
 		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
@@ -2684,7 +2695,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 = rte_device_get_intr_handle(dev->dev);
 	if (!intr_handle->intr_vec) {
 		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
-- 
2.6.3

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

* [dpdk-dev] [PATCH 12/14] lib/ether: check magic before naming a zone
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (10 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 11/14] lib/ether: extract function rte_device_get_intr_handle Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 13/14] lib/ether: check magic in rte_eth_copy_pci_info Jan Viktorin
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_ether/rte_ethdev.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b17aa11..6fb3423 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2659,9 +2659,12 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name,
 	char z_name[RTE_MEMZONE_NAMESIZE];
 	const struct rte_memzone *mz;
 
-	snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
-		 dev->driver->pci_drv.name, ring_name,
-		 dev->data->port_id, queue_id);
+	if (dev->dev->magic == RTE_PCI_DEVICE_MAGIC) {
+		snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d",
+			 dev->driver->pci_drv.name, ring_name,
+			 dev->data->port_id, queue_id);
+	} else
+		return NULL;
 
 	mz = rte_memzone_lookup(z_name);
 	if (mz)
-- 
2.6.3

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

* [dpdk-dev] [PATCH 13/14] lib/ether: check magic in rte_eth_copy_pci_info
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (11 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 12/14] lib/ether: check magic before naming a zone Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 14/14] lib/ether: introduce rte_eth_copy_dev_info Jan Viktorin
       [not found] ` <CALwxeUtxE5Gd+UvZOHz+fyHSjLi9Tjkc=99QHpag62KV+UP+NA@mail.gmail.com>
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_ether/rte_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 6fb3423..75121bc 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3293,6 +3293,12 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de
 		return;
 	}
 
+	if (eth_dev->dev->magic != RTE_PCI_DEVICE_MAGIC) {
+		rte_panic("%s() unexpected device magic: %08x\n",
+				__func__, eth_dev->dev->magic);
+		return;
+	}
+
 	eth_dev->data->dev_flags = 0;
 	if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
-- 
2.6.3

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

* [dpdk-dev] [PATCH 14/14] lib/ether: introduce rte_eth_copy_dev_info
  2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
                   ` (12 preceding siblings ...)
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 13/14] lib/ether: check magic in rte_eth_copy_pci_info Jan Viktorin
@ 2016-01-04 20:08 ` Jan Viktorin
       [not found] ` <CALwxeUtxE5Gd+UvZOHz+fyHSjLi9Tjkc=99QHpag62KV+UP+NA@mail.gmail.com>
  14 siblings, 0 replies; 20+ messages in thread
From: Jan Viktorin @ 2016-01-04 20:08 UTC (permalink / raw)
  To: dev; +Cc: Jan Viktorin

This function should be preferred over the rte_eth_copy_pci_info as it is not
PCI-specific.

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
---
 lib/librte_ether/rte_ethdev.c | 38 ++++++++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h | 15 +++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 75121bc..6d58544 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3309,3 +3309,41 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de
 	eth_dev->data->numa_node = pci_dev->numa_node;
 	eth_dev->data->drv_name = pci_dev->driver->name;
 }
+
+void
+rte_eth_copy_dev_info(struct rte_eth_dev *eth_dev, const union rte_device *dev)
+{
+	unsigned int drv_flags;
+
+	if (eth_dev == NULL || dev == NULL) {
+		RTE_PMD_DEBUG_TRACE("NULL pointer eth_dev=%p dev=%p\n",
+				eth_dev, dev);
+		return;
+	}
+
+	if (eth_dev->dev->magic != dev->magic) {
+		rte_panic("%s() incompatible magic set: %08x != %08x\n",
+				__func__, eth_dev->dev->magic, dev->magic);
+		return;
+	}
+
+	eth_dev->data->dev_flags = 0;
+
+	switch (eth_dev->dev->magic) {
+	case RTE_PCI_DEVICE_MAGIC:
+		drv_flags = dev->pci.driver->drv_flags;
+		if (drv_flags & RTE_PCI_DRV_INTR_LSC)
+			eth_dev->data->dev_flags |= RTE_PCI_DRV_INTR_LSC;
+		if (drv_flags & RTE_PCI_DRV_DETACHABLE)
+			eth_dev->data->dev_flags |= RTE_PCI_DRV_DETACHABLE;
+
+		eth_dev->data->kdrv = dev->pci.kdrv;
+		eth_dev->data->numa_node = dev->pci.numa_node;
+		eth_dev->data->drv_name = dev->pci.driver->name;
+		break;
+	default:
+		rte_panic("%s() unrecognized dev magic: %08x\n",
+				__func__, dev->magic);
+		break;
+	}
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 5dd2e1a..020c0f7 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3864,6 +3864,21 @@ extern int rte_eth_timesync_write_time(uint8_t port_id,
  */
 extern void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev);
 
+/**
+ * Copy device info to the Ethernet device data. The target eth_dev must be
+ * compatible with the given device (from the same infrastructure - eg. PCI).
+ *
+ * @param eth_dev
+ * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
+ * @param pci_dev
+ * The *dev* pointer is the address of the *rte_device* union.
+ *
+ * @return
+ *   - 0 on success, negative on error
+ */
+extern void rte_eth_copy_dev_info(struct rte_eth_dev *eth_dev,
+		const union rte_device *dev);
+
 
 /**
  * Create memzone for HW rings.
-- 
2.6.3

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

* Re: [dpdk-dev] [PATCH 00/14] Step towards PCI independency
       [not found] ` <CALwxeUtxE5Gd+UvZOHz+fyHSjLi9Tjkc=99QHpag62KV+UP+NA@mail.gmail.com>
@ 2016-01-11 17:29   ` Jan Viktorin
  2016-01-13 14:07     ` David Marchand
  0 siblings, 1 reply; 20+ messages in thread
From: Jan Viktorin @ 2016-01-11 17:29 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

Hello David,

did you find time to see the patchset? I am working on a PMD on top of
these so I'd be glad to base on the code close to the (potentially)
upstreamed one.

Regards
Jan

On Tue, 5 Jan 2016 10:45:11 +0100
David Marchand <david.marchand@6wind.com> wrote:

> Hello Jan,
> 
> I agree that ethdev / cryptodev should really have no idea of what device
> type is underneath.
> I was thinking of a slightly difference approach, but yours looks fine.
> 
> I must find time to have a closer look at your patchset, asap.
> 
> 

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

* Re: [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related
  2016-01-04 20:08 ` [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related Jan Viktorin
@ 2016-01-13 14:01   ` Bruce Richardson
  2016-01-13 14:12     ` Jan Viktorin
  0 siblings, 1 reply; 20+ messages in thread
From: Bruce Richardson @ 2016-01-13 14:01 UTC (permalink / raw)
  To: Jan Viktorin; +Cc: dev

On Mon, Jan 04, 2016 at 09:08:15PM +0100, Jan Viktorin wrote:
> The union rte_device can be used in situations where we want to work with all
> devices without distinguishing among bus-specific features (PCI, ...).
> The target device type can be detected by reading the magic.
> 
> Also, the macros RTE_DEVICE_DECL and RTE_DEVICE_PTR_DECL are introduced to
> provide a generic way to declare a device or a pointer to a device. The macros
> aim to preserve API backwards-compatibility. Eg.
> 
> struct old_super_struct {             =>   struct old_super_struct {
>     struct rte_pci_device *pci_dev;   =>        RTE_DEVICE_PTR_DECL(pci_dev);
>     ...                               =>       ...
> };                                    =>   };
> 
> struct old_super_struct inst;
> 
> The new code should reference inst.dev.pci, the old code can still use the
> inst.pci_dev. The previously introduced magic is included so one can ask the
> instance about its type:
> 
> if (inst.dev.magic == RTE_PCI_DEVICE_MAGIC) {
>     ...
> }

Rather than magic numbers i.e. #defines, an enum might be better.

/Bruce

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

* Re: [dpdk-dev] [PATCH 00/14] Step towards PCI independency
  2016-01-11 17:29   ` [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
@ 2016-01-13 14:07     ` David Marchand
  0 siblings, 0 replies; 20+ messages in thread
From: David Marchand @ 2016-01-13 14:07 UTC (permalink / raw)
  To: Jan Viktorin; +Cc: dev

Hello Jan,

On Mon, Jan 11, 2016 at 6:29 PM, Jan Viktorin <viktorin@rehivetech.com> wrote:
> Hello David,
>
> did you find time to see the patchset? I am working on a PMD on top of
> these so I'd be glad to base on the code close to the (potentially)
> upstreamed one.

I took a quick look but since we still have an abi breakage, I am
trying to put my ideas on paper and will share to you asap.


Regards,
-- 
David Marchand

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

* Re: [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related
  2016-01-13 14:01   ` Bruce Richardson
@ 2016-01-13 14:12     ` Jan Viktorin
  2016-01-13 14:24       ` Bruce Richardson
  0 siblings, 1 reply; 20+ messages in thread
From: Jan Viktorin @ 2016-01-13 14:12 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Wed, 13 Jan 2016 14:01:19 +0000
Bruce Richardson <bruce.richardson@intel.com> wrote:

> On Mon, Jan 04, 2016 at 09:08:15PM +0100, Jan Viktorin wrote:
> > The union rte_device can be used in situations where we want to work with all
> > devices without distinguishing among bus-specific features (PCI, ...).
> > The target device type can be detected by reading the magic.
> > 
> > Also, the macros RTE_DEVICE_DECL and RTE_DEVICE_PTR_DECL are introduced to
> > provide a generic way to declare a device or a pointer to a device. The macros
> > aim to preserve API backwards-compatibility. Eg.
> > 
> > struct old_super_struct {             =>   struct old_super_struct {
> >     struct rte_pci_device *pci_dev;   =>        RTE_DEVICE_PTR_DECL(pci_dev);
> >     ...                               =>       ...
> > };                                    =>   };
> > 
> > struct old_super_struct inst;
> > 
> > The new code should reference inst.dev.pci, the old code can still use the
> > inst.pci_dev. The previously introduced magic is included so one can ask the
> > instance about its type:
> > 
> > if (inst.dev.magic == RTE_PCI_DEVICE_MAGIC) {
> >     ...
> > }  
> 
> Rather than magic numbers i.e. #defines, an enum might be better.

True. However, would it be helpful to put really some _magic_ numbers
there for debugging purposes (to clearly recognize the data type)? Or,
is it sufficient to just say 1 for PCI, 2 for SoC, 3 for xxx...?

> 
> /Bruce
> 



-- 
   Jan Viktorin                  E-mail: Viktorin@RehiveTech.com
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic

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

* Re: [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related
  2016-01-13 14:12     ` Jan Viktorin
@ 2016-01-13 14:24       ` Bruce Richardson
  0 siblings, 0 replies; 20+ messages in thread
From: Bruce Richardson @ 2016-01-13 14:24 UTC (permalink / raw)
  To: Jan Viktorin; +Cc: dev

On Wed, Jan 13, 2016 at 03:12:27PM +0100, Jan Viktorin wrote:
> On Wed, 13 Jan 2016 14:01:19 +0000
> Bruce Richardson <bruce.richardson@intel.com> wrote:
> 
> > On Mon, Jan 04, 2016 at 09:08:15PM +0100, Jan Viktorin wrote:
> > > The union rte_device can be used in situations where we want to work with all
> > > devices without distinguishing among bus-specific features (PCI, ...).
> > > The target device type can be detected by reading the magic.
> > > 
> > > Also, the macros RTE_DEVICE_DECL and RTE_DEVICE_PTR_DECL are introduced to
> > > provide a generic way to declare a device or a pointer to a device. The macros
> > > aim to preserve API backwards-compatibility. Eg.
> > > 
> > > struct old_super_struct {             =>   struct old_super_struct {
> > >     struct rte_pci_device *pci_dev;   =>        RTE_DEVICE_PTR_DECL(pci_dev);
> > >     ...                               =>       ...
> > > };                                    =>   };
> > > 
> > > struct old_super_struct inst;
> > > 
> > > The new code should reference inst.dev.pci, the old code can still use the
> > > inst.pci_dev. The previously introduced magic is included so one can ask the
> > > instance about its type:
> > > 
> > > if (inst.dev.magic == RTE_PCI_DEVICE_MAGIC) {
> > >     ...
> > > }  
> > 
> > Rather than magic numbers i.e. #defines, an enum might be better.
> 
> True. However, would it be helpful to put really some _magic_ numbers
> there for debugging purposes (to clearly recognize the data type)? Or,
> is it sufficient to just say 1 for PCI, 2 for SoC, 3 for xxx...?
> 
I'd find it hard to see the need for actual magic numbers. I think the magic field
should be renamed to "type" and the values taken from a device_type enum. Should
make the code more readable e.g.

if (inst.dev.type == RTE_DEVTYPE_PCI) { ... }

/Bruce

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

end of thread, other threads:[~2016-01-13 14:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-04 20:08 [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 01/14] eal/common: introduce RTE_PCI_DRV_MAGIC Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 02/14] eal/common: introduce RTE_PCI_DEVICE_MAGIC Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 03/14] eal/common: introduce union rte_device and related Jan Viktorin
2016-01-13 14:01   ` Bruce Richardson
2016-01-13 14:12     ` Jan Viktorin
2016-01-13 14:24       ` Bruce Richardson
2016-01-04 20:08 ` [dpdk-dev] [PATCH 04/14] eal/common: introduce function to_pci_driver Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 05/14] eal/common: introduce function to_pci_device Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 06/14] Include rte_dev.h instead of rte_pci.h Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 07/14] lib/ether: generalize rte_eth_dev_init/uninit Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 08/14] eal/common: introduce rte_bus_addr Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 09/14] lib/ether: generalize attach/detach of devices Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 10/14] lib/ether: copy the rte_device union instead of rte_pci_device Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 11/14] lib/ether: extract function rte_device_get_intr_handle Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 12/14] lib/ether: check magic before naming a zone Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 13/14] lib/ether: check magic in rte_eth_copy_pci_info Jan Viktorin
2016-01-04 20:08 ` [dpdk-dev] [PATCH 14/14] lib/ether: introduce rte_eth_copy_dev_info Jan Viktorin
     [not found] ` <CALwxeUtxE5Gd+UvZOHz+fyHSjLi9Tjkc=99QHpag62KV+UP+NA@mail.gmail.com>
2016-01-11 17:29   ` [dpdk-dev] [PATCH 00/14] Step towards PCI independency Jan Viktorin
2016-01-13 14:07     ` David Marchand

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