Skip to contentSkip to conversation

prepare for rte_device / rte_driver

PATCH Superseded David Marchand 15 participants 375 messages Jan 29, 2016 – Oct 26, 2016 1 message not in the archive Page 2 of 5

Subsystems (4)
lore
Share & tools
lore
#102 lore raw

PATCH v4 17/17 ethdev: get rid of device type

In reply to Shreyansh Jain

Now that hotplug has been moved to eal, there is no reason to keep the device type in this layer.

---
 app/test/virtual_pmd.c                    |  2 +-
 drivers/net/af_packet/rte_eth_af_packet.c |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c    |  2 +-
 drivers/net/cxgbe/cxgbe_main.c            |  2 +-
 drivers/net/mlx4/mlx4.c                   |  2 +-
 drivers/net/mlx5/mlx5.c                   |  2 +-
 drivers/net/mpipe/mpipe_tilegx.c          |  2 +-
 drivers/net/null/rte_eth_null.c           |  2 +-
 drivers/net/pcap/rte_eth_pcap.c           |  2 +-
 drivers/net/ring/rte_eth_ring.c           |  2 +-
 drivers/net/vhost/rte_eth_vhost.c         |  2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |  2 +-
 examples/ip_pipeline/init.c               | 22 ----------------------
 lib/librte_ether/rte_ethdev.c             |  5 ++---
 lib/librte_ether/rte_ethdev.h             | 15 +--------------
 15 files changed, 15 insertions(+), 51 deletions(-)
app/test/virtual_pmd.c +1 -1
index b4bd2f2..8a1f0d0 100644
@@ -581,7 +581,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 		goto err;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto err;
 
drivers/net/af_packet/rte_eth_af_packet.c +1 -1
index f17bd7e..36ac102 100644
@@ -648,7 +648,7 @@ rte_pmd_init_internals(const char *name,
 	}
 
 	/* reserve an ethdev entry */
-	*eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	*eth_dev = rte_eth_dev_allocate(name);
 	if (*eth_dev == NULL)
 		goto error;
 
drivers/net/bonding/rte_eth_bond_api.c +1 -1
index 53df9fe..b858ee1 100644
@@ -189,7 +189,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	}
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
 		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
drivers/net/cxgbe/cxgbe_main.c +1 -1
index ceaf5ab..922155b 100644
@@ -1150,7 +1150,7 @@ int cxgbe_probe(struct adapter *adapter)
 		 */
 
 		/* reserve an ethdev entry */
-		pi->eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+		pi->eth_dev = rte_eth_dev_allocate(name);
 		if (!pi->eth_dev)
 			goto out_free;
 
drivers/net/mlx4/mlx4.c +1 -1
index b594433..ba42c33 100644
@@ -5715,7 +5715,7 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
 			snprintf(name, sizeof(name), "%s port %u",
 				 ibv_get_device_name(ibv_dev), port);
-			eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+			eth_dev = rte_eth_dev_allocate(name);
 		}
 		if (eth_dev == NULL) {
 			ERROR("can not allocate rte ethdev");
drivers/net/mlx5/mlx5.c +1 -1
index 1989a37..f6399fc 100644
@@ -519,7 +519,7 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
 			snprintf(name, sizeof(name), "%s port %u",
 				 ibv_get_device_name(ibv_dev), port);
-			eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+			eth_dev = rte_eth_dev_allocate(name);
 		}
 		if (eth_dev == NULL) {
 			ERROR("can not allocate rte ethdev");
drivers/net/mpipe/mpipe_tilegx.c +1 -1
index 26e1424..9de556e 100644
@@ -1587,7 +1587,7 @@ rte_pmd_mpipe_devinit(const char *ifname,
 		return -ENODEV;
 	}
 
-	eth_dev = rte_eth_dev_allocate(ifname, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(ifname);
 	if (!eth_dev) {
 		RTE_LOG(ERR, PMD, "%s: Failed to allocate device.\n", ifname);
 		rte_free(priv);
drivers/net/null/rte_eth_null.c +1 -1
index 5e8e203..e6c74a6 100644
@@ -514,7 +514,7 @@ eth_dev_null_create(const char *name,
 		goto error;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto error;
 
drivers/net/pcap/rte_eth_pcap.c +1 -1
index c98e234..2d00d04 100644
@@ -822,7 +822,7 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 		goto error;
 
 	/* reserve an ethdev entry */
-	*eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	*eth_dev = rte_eth_dev_allocate(name);
 	if (*eth_dev == NULL)
 		goto error;
 
drivers/net/ring/rte_eth_ring.c +1 -1
index b1783c3..b78d1cf 100644
@@ -303,7 +303,7 @@ do_eth_dev_ring_create(const char *name,
 	}
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
 		rte_errno = ENOSPC;
 		goto error;
drivers/net/vhost/rte_eth_vhost.c +1 -1
index 310cbef..4e99360 100644
@@ -717,7 +717,7 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
 		goto error;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto error;
 
drivers/net/xenvirt/rte_eth_xenvirt.c +1 -1
index 1adeb5b..72861d8 100644
@@ -651,7 +651,7 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 		goto err;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto err;
 
examples/ip_pipeline/init.c +0 -22
index 7120bab..0933a5f 100644
@@ -606,29 +606,12 @@ app_link_set_tcp_syn_filter(struct app_params *app, struct app_link_params *cp)
 	}
 }
 
-static int
-app_link_is_virtual(struct app_link_params *p)
-{
-	uint32_t pmd_id = p->pmd_id;
-	struct rte_eth_dev *dev = &rte_eth_devices[pmd_id];
-
-	if (dev->dev_type == RTE_ETH_DEV_VIRTUAL)
-		return 1;
-
-	return 0;
-}
-
 void
 app_link_up_internal(struct app_params *app, struct app_link_params *cp)
 {
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 1;
-		return;
-	}
-
 	/* For each link, add filters for IP of current link */
 	if (cp->ip != 0) {
 		for (i = 0; i < app->n_links; i++) {
@@ -736,11 +719,6 @@ app_link_down_internal(struct app_params *app, struct app_link_params *cp)
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 0;
-		return;
-	}
-
 	/* PMD link down */
 	status = rte_eth_dev_set_link_down(cp->pmd_id);
 	if (status < 0)
lib/librte_ether/rte_ethdev.c +2 -3
index 28604ca..f8c3d71 100644
@@ -191,7 +191,7 @@ rte_eth_dev_find_free_port(void)
 }
 
 struct rte_eth_dev *
-rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
+rte_eth_dev_allocate(const char *name)
 {
 	uint8_t port_id;
 	struct rte_eth_dev *eth_dev;
@@ -216,7 +216,6 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
 	eth_dev->data->port_id = port_id;
 	eth_dev->attached = DEV_ATTACHED;
-	eth_dev->dev_type = type;
 	eth_dev_last_created_port = port_id;
 	nb_ports++;
 	return eth_dev;
@@ -248,7 +247,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
 	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
 			sizeof(ethdev_name));
 
-	eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
+	eth_dev = rte_eth_dev_allocate(ethdev_name);
 	if (eth_dev == NULL)
 		return -ENOMEM;
 
lib/librte_ether/rte_ethdev.h +1 -14
index ffd24e4..921dfa0 100644
@@ -1594,17 +1594,6 @@ struct rte_eth_rxtx_callback {
 };
 
 /**
- * The eth device type.
- */
-enum rte_eth_dev_type {
-	RTE_ETH_DEV_UNKNOWN,	/**< unknown device type */
-	RTE_ETH_DEV_PCI,
-		/**< Physical function and Virtual function of PCI devices */
-	RTE_ETH_DEV_VIRTUAL,	/**< non hardware device */
-	RTE_ETH_DEV_MAX		/**< max value of this enum */
-};
-
-/**
  * @internal
  * The generic data structure associated with each ethernet device.
  *
@@ -1634,7 +1623,6 @@ struct rte_eth_dev {
 	 */
 	struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
 	uint8_t attached; /**< Flag indicating the port is attached */
-	enum rte_eth_dev_type dev_type; /**< Flag indicating the device type */
 };
 
 struct rte_eth_dev_sriov {
@@ -1747,8 +1735,7 @@ struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(const char *name,
-		enum rte_eth_dev_type type);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
 
 /**
  * @internal
Signature · 1 line
2.7.4
#103 lore raw
In reply to Shreyansh Jain

Self NACK.

Rebase over master before posting series broke compilation. Apologies.

Quoted 105 lines · Shreyansh Jain

* Original patch series is from David Marchand [1], [2].
* Cover letter text has been modified to make it author agnostic

David created the original patchset based on the discussions on list [3]. Being a large piece of work, this patchset introduces first level of changes for generalizing the driver-device relationship for supporting hotplug.

Pending work, as per discussions in thread [3]:
- Heirarchical relationship between rte_driver/device, pci_*, crypto_*
- Cleaner device init/deinit methods (probably from rte_driver onwards)
- Moving generic flags/fields from pci_* structure to rte_* structure
- Removing dependency on devargs for pdev/vdev distinction
- Device/Driver lists: discussion and decision on separate or unified lists

Changes since v3:
- rebase over HEAD (913154e)
- Update arguments to RTE_EAL_PCI_REGISTER macro as per Jan's suggestion
- modify qede driver to use RTE_EAL_PCI_REGISTER
- Argument check in hotplug functions

Changes since v2:
- rebase over HEAD (d76c193)
- Move SYSFS_PCI_DRIVERS macro to rte_pci.h to avoid compilation issue

Changes since v1:
- rebased on HEAD, new drivers should be okay
- patches have been split into smaller pieces
- RTE_INIT macro has been added, but in the end, I am not sure it is useful
- device type has been removed from ethdev, as it was used only by hotplug
- getting rid of pmd type in eal patch (patch 5 of initial series) has been dropped for now, we can do this once vdev drivers have been converted

[1] http://dpdk.org/ml/archives/dev/2016-January/032387.html
[2] http://dpdk.org/ml/archives/dev/2016-April/037686.html
[3] http://dpdk.org/ml/archives/dev/2016-January/031390.html

David Marchand (17):
pci: no need for dynamic tailq init
crypto: no need for a crypto pmd type
drivers: align pci driver definitions
eal: remove duplicate function declaration
eal: introduce init macros
crypto: export init/uninit common wrappers for pci drivers
ethdev: export init/uninit common wrappers for pci drivers
drivers: convert all pdev drivers as pci drivers
crypto: get rid of crypto driver register callback
ethdev: get rid of eth driver register callback eal/linux: move back interrupt thread init before setting affinity
pci: add a helper for device name
pci: add a helper to update a device
ethdev: do not scan all pci devices on attach
eal: add hotplug operations for pci and vdev
ethdev: convert to eal hotplug
ethdev: get rid of device type

 app/test/virtual_pmd.c                          |   2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c          |  18 +-
 drivers/net/af_packet/rte_eth_af_packet.c       |   2 +-
 drivers/net/bnx2x/bnx2x_ethdev.c                |  35 +---
 drivers/net/bonding/rte_eth_bond_api.c          |   2 +-
 drivers/net/cxgbe/cxgbe_ethdev.c                |  24 +--
 drivers/net/cxgbe/cxgbe_main.c                  |   2 +-
 drivers/net/e1000/em_ethdev.c                   |  16 +-
 drivers/net/e1000/igb_ethdev.c                  |  40 +----
 drivers/net/ena/ena_ethdev.c                    |  20 +--
 drivers/net/enic/enic_ethdev.c                  |  23 +--
 drivers/net/fm10k/fm10k_ethdev.c                |  23 +--
 drivers/net/i40e/i40e_ethdev.c                  |  26 +--
 drivers/net/i40e/i40e_ethdev_vf.c               |  25 +--
 drivers/net/ixgbe/ixgbe_ethdev.c                |  47 +----
 drivers/net/mlx4/mlx4.c                         |  22 +--
 drivers/net/mlx5/mlx5.c                         |  21 +--
 drivers/net/mpipe/mpipe_tilegx.c                |   2 +-
 drivers/net/nfp/nfp_net.c                       |  23 +--
 drivers/net/null/rte_eth_null.c                 |   2 +-
 drivers/net/pcap/rte_eth_pcap.c                 |   2 +-
 drivers/net/qede/qede_ethdev.c                  |  40 +----
 drivers/net/ring/rte_eth_ring.c                 |   2 +-
 drivers/net/szedata2/rte_eth_szedata2.c         |  25 +--
 drivers/net/vhost/rte_eth_vhost.c               |   2 +-
 drivers/net/virtio/virtio_ethdev.c              |  26 +--
 drivers/net/vmxnet3/vmxnet3_ethdev.c            |  23 +--
 drivers/net/xenvirt/rte_eth_xenvirt.c           |   2 +-
 examples/ip_pipeline/init.c                     |  22 ---
 lib/librte_cryptodev/rte_cryptodev.c            |  67 ++-----
 lib/librte_cryptodev/rte_cryptodev.h            |   2 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h        |  45 ++---
 lib/librte_cryptodev/rte_cryptodev_version.map  |   9 +-
 lib/librte_eal/bsdapp/eal/eal_pci.c             |  52 +++++-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   2 +
 lib/librte_eal/common/eal_common_dev.c          |  47 +++++
 lib/librte_eal/common/eal_common_pci.c          |  19 +-
 lib/librte_eal/common/eal_private.h             |  20 ++-
 lib/librte_eal/common/include/rte_dev.h         |  29 +++-
 lib/librte_eal/common/include/rte_eal.h         |   3 +
 lib/librte_eal/common/include/rte_pci.h         |  36 ++++
 lib/librte_eal/common/include/rte_tailq.h       |   4 +-
 lib/librte_eal/linuxapp/eal/eal.c               |   7 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c           |  16 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   2 +
 lib/librte_ether/rte_ethdev.c                   | 222 +++++-------------------
 lib/librte_ether/rte_ethdev.h                   |  40 ++---
 lib/librte_ether/rte_ether_version.map          |   4 +-
 48 files changed, 395 insertions(+), 750 deletions(-)
#104 lore raw

v5 cover Prepare for rte_device / rte_driver

In reply to Shreyansh Jain

* Original patch series is from David Marchand [1], [2].
* Cover letter text has been modified to make it author agnostic

David created the original patchset based on the discussions on list [3]. Being a large piece of work, this patchset introduces first level of changes for generalizing the driver-device relationship for supporting hotplug.

Pending work, as per discussions in thread [3]:
- Heirarchical relationship between rte_driver/device, pci_*, crypto_*
- Cleaner device init/deinit methods (probably from rte_driver onwards)
- Moving generic flags/fields from pci_* structure to rte_* structure
- Removing dependency on devargs for pdev/vdev distinction
- Device/Driver lists: discussion and decision on separate or unified lists

This patchset is based on master (34d279)

Changes since v4:
- Fix compilation issue after rebase on HEAD (913154e) in previous series
- Retain rte_eth_dev_get_port_by_name and rte_eth_dev_get_name_by_port which were removed by previous patchset. These are being used by pdump library

Changes since v3:
- rebase over HEAD (913154e)
- Update arguments to RTE_EAL_PCI_REGISTER macro as per Jan's suggestion
- modify qede driver to use RTE_EAL_PCI_REGISTER
- Argument check in hotplug functions

Changes since v2:
- rebase over HEAD (d76c193)
- Move SYSFS_PCI_DRIVERS macro to rte_pci.h to avoid compilation issue

Changes since v1:
- rebased on HEAD, new drivers should be okay
- patches have been split into smaller pieces
- RTE_INIT macro has been added, but in the end, I am not sure it is useful
- device type has been removed from ethdev, as it was used only by hotplug
- getting rid of pmd type in eal patch (patch 5 of initial series) has been dropped for now, we can do this once vdev drivers have been converted

[1] http://dpdk.org/ml/archives/dev/2016-January/032387.html
[2] http://dpdk.org/ml/archives/dev/2016-April/037686.html
[3] http://dpdk.org/ml/archives/dev/2016-January/031390.html

David Marchand, Shreyansh Jain (17):
pci: no need for dynamic tailq init
crypto: no need for a crypto pmd type
drivers: align pci driver definitions
eal: remove duplicate function declaration
eal: introduce init macros
crypto: export init/uninit common wrappers for pci drivers
ethdev: export init/uninit common wrappers for pci drivers
drivers: convert all pdev drivers as pci drivers
crypto: get rid of crypto driver register callback
ethdev: get rid of eth driver register callback eal/linux: move back interrupt thread init before setting affinity
pci: add a helper for device name
pci: add a helper to update a device
ethdev: do not scan all pci devices on attach
eal: add hotplug operations for pci and vdev
ethdev: convert to eal hotplug
ethdev: get rid of device type

 app/test/virtual_pmd.c                          |   2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c          |  18 +-
 drivers/net/af_packet/rte_eth_af_packet.c       |   2 +-
 drivers/net/bnx2x/bnx2x_ethdev.c                |  35 +--
 drivers/net/bonding/rte_eth_bond_api.c          |   2 +-
 drivers/net/cxgbe/cxgbe_ethdev.c                |  24 +--
 drivers/net/cxgbe/cxgbe_main.c                  |   2 +-
 drivers/net/e1000/em_ethdev.c                   |  16 +-
 drivers/net/e1000/igb_ethdev.c                  |  40 +---
 drivers/net/ena/ena_ethdev.c                    |  20 +-
 drivers/net/enic/enic_ethdev.c                  |  23 +-
 drivers/net/fm10k/fm10k_ethdev.c                |  23 +-
 drivers/net/i40e/i40e_ethdev.c                  |  26 +--
 drivers/net/i40e/i40e_ethdev_vf.c               |  25 +--
 drivers/net/ixgbe/ixgbe_ethdev.c                |  47 +---
 drivers/net/mlx4/mlx4.c                         |  22 +-
 drivers/net/mlx5/mlx5.c                         |  21 +-
 drivers/net/mpipe/mpipe_tilegx.c                |   2 +-
 drivers/net/nfp/nfp_net.c                       |  23 +-
 drivers/net/null/rte_eth_null.c                 |   2 +-
 drivers/net/pcap/rte_eth_pcap.c                 |   2 +-
 drivers/net/qede/qede_ethdev.c                  |  40 +---
 drivers/net/ring/rte_eth_ring.c                 |   2 +-
 drivers/net/szedata2/rte_eth_szedata2.c         |  25 +--
 drivers/net/vhost/rte_eth_vhost.c               |   2 +-
 drivers/net/virtio/virtio_ethdev.c              |  26 +--
 drivers/net/vmxnet3/vmxnet3_ethdev.c            |  23 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c           |   2 +-
 examples/ip_pipeline/init.c                     |  22 --
 lib/librte_cryptodev/rte_cryptodev.c            |  67 ++----
 lib/librte_cryptodev/rte_cryptodev.h            |   2 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h        |  45 ++--
 lib/librte_cryptodev/rte_cryptodev_version.map  |   9 +-
 lib/librte_eal/bsdapp/eal/eal_pci.c             |  52 ++++-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   2 +
 lib/librte_eal/common/eal_common_dev.c          |  47 ++++
 lib/librte_eal/common/eal_common_pci.c          |  19 +-
 lib/librte_eal/common/eal_private.h             |  20 +-
 lib/librte_eal/common/include/rte_dev.h         |  29 ++-
 lib/librte_eal/common/include/rte_eal.h         |   3 +
 lib/librte_eal/common/include/rte_pci.h         |  36 ++++
 lib/librte_eal/common/include/rte_tailq.h       |   4 +-
 lib/librte_eal/linuxapp/eal/eal.c               |   7 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c           |  16 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   2 +
 lib/librte_ether/rte_ethdev.c                   | 271 ++++--------------------
 lib/librte_ether/rte_ethdev.h                   |  40 ++--
 lib/librte_ether/rte_ether_version.map          |   4 +-
 48 files changed, 395 insertions(+), 799 deletions(-)
Signature · 1 line
2.7.4
#105 lore raw

PATCH v5 1/17 pci: no need for dynamic tailq init

These lists can be initialized once and for all at build time. With this, those lists are only manipulated in a common place (and we could even make them private).

A nice side effect is that pci drivers can now register in constructors.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c    | 3 ---
 lib/librte_eal/common/eal_common_pci.c | 6 ++++--
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 3 ---
 3 files changed, 4 insertions(+), 8 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +0 -3
index 7fdd6f1..880483d 100644
@@ -623,9 +623,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 int
 rte_eal_pci_init(void)
 {
-	TAILQ_INIT(&pci_driver_list);
-	TAILQ_INIT(&pci_device_list);
-
 	/* for debug purposes, PCI can be disabled */
 	if (internal_config.no_pci)
 		return 0;
lib/librte_eal/common/eal_common_pci.c +4 -2
index ba5283d..fee4aa5 100644
@@ -82,8 +82,10 @@
 
 #include "eal_private.h"
 
-struct pci_driver_list pci_driver_list;
-struct pci_device_list pci_device_list;
+struct pci_driver_list pci_driver_list =
+	TAILQ_HEAD_INITIALIZER(pci_driver_list);
+struct pci_device_list pci_device_list =
+	TAILQ_HEAD_INITIALIZER(pci_device_list);
 
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 
lib/librte_eal/linuxapp/eal/eal_pci.c +0 -3
index f9c3efd..bfc410f 100644
@@ -743,9 +743,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 int
 rte_eal_pci_init(void)
 {
-	TAILQ_INIT(&pci_driver_list);
-	TAILQ_INIT(&pci_device_list);
-
 	/* for debug purposes, PCI can be disabled */
 	if (internal_config.no_pci)
 		return 0;
Signature · 1 line
2.7.4
#106 lore raw

PATCH v5 2/17 crypto: no need for a crypto pmd type

In reply to Shreyansh Jain

This information is not used and just adds noise.

---
 lib/librte_cryptodev/rte_cryptodev.c     | 8 +++-----
 lib/librte_cryptodev/rte_cryptodev.h     | 2 --
 lib/librte_cryptodev/rte_cryptodev_pmd.h | 3 +--
 3 files changed, 4 insertions(+), 9 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +3 -5
index 960e2d5..b0d806c 100644
@@ -230,7 +230,7 @@ rte_cryptodev_find_free_device_index(void)
 }
 
 struct rte_cryptodev *
-rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id)
+rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 {
 	struct rte_cryptodev *cryptodev;
 	uint8_t dev_id;
@@ -269,7 +269,6 @@ rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id)
 		cryptodev->data->dev_started = 0;
 
 		cryptodev->attached = RTE_CRYPTODEV_ATTACHED;
-		cryptodev->pmd_type = type;
 
 		cryptodev_globals.nb_devs++;
 	}
@@ -318,7 +317,7 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 	struct rte_cryptodev *cryptodev;
 
 	/* allocate device structure */
-	cryptodev = rte_cryptodev_pmd_allocate(name, PMD_VDEV, socket_id);
+	cryptodev = rte_cryptodev_pmd_allocate(name, socket_id);
 	if (cryptodev == NULL)
 		return NULL;
 
@@ -360,8 +359,7 @@ rte_cryptodev_init(struct rte_pci_driver *pci_drv,
 	rte_cryptodev_create_unique_device_name(cryptodev_name,
 			sizeof(cryptodev_name), pci_dev);
 
-	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, PMD_PDEV,
-			rte_socket_id());
+	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 	if (cryptodev == NULL)
 		return -ENOMEM;
 
lib/librte_cryptodev/rte_cryptodev.h +0 -2
index 27cf8ef..f22eb43 100644
@@ -700,8 +700,6 @@ struct rte_cryptodev {
 
 	enum rte_cryptodev_type dev_type;
 	/**< Crypto device type */
-	enum pmd_type pmd_type;
-	/**< PMD type - PDEV / VDEV */
 
 	struct rte_cryptodev_cb_list link_intr_cbs;
 	/**< User application callback for interrupts if present */
lib/librte_cryptodev/rte_cryptodev_pmd.h +1 -2
index 7d049ea..c977c61 100644
@@ -454,13 +454,12 @@ struct rte_cryptodev_ops {
  * to that slot for the driver to use.
  *
  * @param	name		Unique identifier name for each device
- * @param	type		Device type of this Crypto device
  * @param	socket_id	Socket to allocate resources on.
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
 struct rte_cryptodev *
-rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id);
+rte_cryptodev_pmd_allocate(const char *name, int socket_id);
 
 /**
  * Creates a new virtual crypto device and returns the pointer
Signature · 1 line
2.7.4
#107 lore raw

PATCH v5 3/17 drivers: align pci driver definitions

In reply to Shreyansh Jain

Pure coding style, but it might make it easier later if we want to move fields in rte_cryptodev_driver and eth_driver structures.

---
 drivers/crypto/qat/rte_qat_cryptodev.c | 2 +-
 drivers/net/ena/ena_ethdev.c           | 2 +-
 drivers/net/nfp/nfp_net.c              | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/qat/rte_qat_cryptodev.c +1 -1
index f46ec85..0ff3944 100644
@@ -113,7 +113,7 @@ crypto_qat_dev_init(__attribute__((unused)) struct rte_cryptodev_driver *crypto_
 }
 
 static struct rte_cryptodev_driver rte_qat_pmd = {
-	{
+	.pci_drv = {
 		.name = "rte_qat_pmd",
 		.id_table = pci_id_qat_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
drivers/net/ena/ena_ethdev.c +1 -1
index e157587..8d01e9a 100644
@@ -1427,7 +1427,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 }
 
 static struct eth_driver rte_ena_pmd = {
-	{
+	.pci_drv = {
 		.name = "rte_ena_pmd",
 		.id_table = pci_id_ena_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
drivers/net/nfp/nfp_net.c +1 -1
index 5c9f350..ef7011e 100644
@@ -2463,7 +2463,7 @@ static struct rte_pci_id pci_id_nfp_net_map[] = {
 };
 
 static struct eth_driver rte_nfp_net_pmd = {
-	{
+	.pci_drv = {
 		.name = "rte_nfp_net_pmd",
 		.id_table = pci_id_nfp_net_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
Signature · 1 line
2.7.4
#108 lore raw

PATCH v5 4/17 eal: remove duplicate function declaration

In reply to Shreyansh Jain

rte_eal_dev_init is declared in both eal_private.h and rte_dev.h since its introduction.
This function has been exported in ABI, so remove it from eal_private.h

Fixes e57f20e05177 ("eal: make vdev init path generic for both virtual and pci devices")
---
 lib/librte_eal/common/eal_private.h | 7 -------
 lib/librte_eal/linuxapp/eal/eal.c   | 1 +
 2 files changed, 1 insertion(+), 7 deletions(-)
lib/librte_eal/common/eal_private.h +0 -7
index 857dc3e..06a68f6 100644
@@ -259,13 +259,6 @@ int rte_eal_intr_init(void);
 int rte_eal_alarm_init(void);
 
 /**
- * This function initialises any virtual devices
- *
- * This function is private to the EAL.
- */
-int rte_eal_dev_init(void);
-
-/**
  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
  * etc.) loaded.
  *
lib/librte_eal/linuxapp/eal/eal.c +1 -0
index 4f22c18..29fba52 100644
@@ -70,6 +70,7 @@
 #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>
Signature · 1 line
2.7.4
#109 lore raw

PATCH v5 5/17 eal: introduce init macros

In reply to Shreyansh Jain

Introduce a RTE_INIT macro used to mark an init function as a constructor. Current eal macros have been converted to use this (no functional impact). RTE_EAL_PCI_REGISTER is added as a helper for pci drivers.

---
 lib/librte_eal/common/include/rte_dev.h   | 4 ++--
 lib/librte_eal/common/include/rte_eal.h   | 3 +++
 lib/librte_eal/common/include/rte_pci.h   | 8 ++++++++
 lib/librte_eal/common/include/rte_tailq.h | 4 ++--
 4 files changed, 15 insertions(+), 4 deletions(-)
lib/librte_eal/common/include/rte_dev.h +2 -2
index f1b5507..85e48f2 100644
@@ -179,8 +179,8 @@ int rte_eal_vdev_init(const char *name, const char *args);
 int rte_eal_vdev_uninit(const char *name);
 
 #define PMD_REGISTER_DRIVER(d)\
-void devinitfn_ ##d(void);\
-void __attribute__((constructor, used)) devinitfn_ ##d(void)\
+RTE_INIT(devinitfn_ ##d);\
+static void devinitfn_ ##d(void)\
 {\
 	rte_eal_driver_register(&d);\
 }
lib/librte_eal/common/include/rte_eal.h +3 -0
index a71d6f5..186f3c6 100644
@@ -252,6 +252,9 @@ static inline int rte_gettid(void)
 	return RTE_PER_LCORE(_thread_id);
 }
 
+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_pci.h +8 -0
index fa74962..ac890fc 100644
@@ -470,6 +470,14 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registeration from driver (eth, crypto) instance */
+#define RTE_EAL_PCI_REGISTER(name) \
+RTE_INIT(pciinitfn_ ##name); \
+static void pciinitfn_ ##name(void) \
+{ \
+	rte_eal_pci_register(&(name).pci_drv); \
+}
+
 /**
  * Unregister a PCI driver.
  *
lib/librte_eal/common/include/rte_tailq.h +2 -2
index 4a686e6..71ed3bb 100644
@@ -148,8 +148,8 @@ struct rte_tailq_head *rte_eal_tailq_lookup(const char *name);
 int rte_eal_tailq_register(struct rte_tailq_elem *t);
 
 #define EAL_REGISTER_TAILQ(t) \
-void tailqinitfn_ ##t(void); \
-void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \
+RTE_INIT(tailqinitfn_ ##t); \
+static void tailqinitfn_ ##t(void) \
 { \
 	if (rte_eal_tailq_register(&t) < 0) \
 		rte_panic("Cannot initialize tailq: %s\n", t.name); \
Signature · 1 line
2.7.4
#110 lore raw

PATCH v5 6/17 crypto: export init/uninit common wrappers for pci drivers

In reply to Shreyansh Jain

Preparing for getting rid of rte_cryptodev_driver, here are two wrappers that can be used by pci drivers that assume a 1 to 1 association between pci resource and upper interface.

---
 lib/librte_cryptodev/rte_cryptodev.c           | 16 ++++++++--------
 lib/librte_cryptodev/rte_cryptodev_pmd.h       | 12 ++++++++++++
 lib/librte_cryptodev/rte_cryptodev_version.map |  8 ++++++++
 3 files changed, 28 insertions(+), 8 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +8 -8
index b0d806c..65a2e29 100644
@@ -340,9 +340,9 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 	return cryptodev;
 }
 
-static int
-rte_cryptodev_init(struct rte_pci_driver *pci_drv,
-		struct rte_pci_device *pci_dev)
+int
+rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
+			struct rte_pci_device *pci_dev)
 {
 	struct rte_cryptodev_driver *cryptodrv;
 	struct rte_cryptodev *cryptodev;
@@ -401,8 +401,8 @@ rte_cryptodev_init(struct rte_pci_driver *pci_drv,
 	return -ENXIO;
 }
 
-static int
-rte_cryptodev_uninit(struct rte_pci_device *pci_dev)
+int
+rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 {
 	const struct rte_cryptodev_driver *cryptodrv;
 	struct rte_cryptodev *cryptodev;
@@ -450,15 +450,15 @@ 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,
+		return rte_cryptodev_pci_probe((struct rte_pci_driver *)cryptodrv,
 				NULL);
 
 	/*
 	 * Register PCI driver for physical device intialisation during
 	 * PCI probing
 	 */
-	cryptodrv->pci_drv.devinit = rte_cryptodev_init;
-	cryptodrv->pci_drv.devuninit = rte_cryptodev_uninit;
+	cryptodrv->pci_drv.devinit = rte_cryptodev_pci_probe;
+	cryptodrv->pci_drv.devuninit = rte_cryptodev_pci_remove;
 
 	rte_eal_pci_register(&cryptodrv->pci_drv);
 
lib/librte_cryptodev/rte_cryptodev_pmd.h +12 -0
index c977c61..3fb7c7c 100644
@@ -534,6 +534,18 @@ rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
 void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 				enum rte_cryptodev_event_type event);
 
+/**
+ * Wrapper for use by pci drivers as a .devinit function to attach to a crypto
+ * interface.
+ */
+int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
+			    struct rte_pci_device *pci_dev);
+
+/**
+ * Wrapper for use by pci drivers as a .devuninit function to detach a crypto
+ * interface.
+ */
+int rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev);
 
 #ifdef __cplusplus
 }
lib/librte_cryptodev/rte_cryptodev_version.map +8 -0
index 41004e1..8d0edfb 100644
@@ -32,3 +32,11 @@ DPDK_16.04 {
 
 	local: *;
 };
+
+DPDK_16.07 {
+	global:
+
+	rte_cryptodev_pci_probe;
+	rte_cryptodev_pci_remove;
+
+} DPDK_16.04;
Signature · 1 line
2.7.4
#111 lore raw

PATCH v5 7/17 ethdev: export init/uninit common wrappers for pci drivers

In reply to Shreyansh Jain

Preparing for getting rid of eth_drv, here are two wrappers that can be used by pci drivers that assume a 1 to 1 association between pci resource and upper interface.

---
 lib/librte_ether/rte_ethdev.c          | 14 +++++++-------
 lib/librte_ether/rte_ethdev.h          | 13 +++++++++++++
 lib/librte_ether/rte_ether_version.map |  3 +++
 3 files changed, 23 insertions(+), 7 deletions(-)
lib/librte_ether/rte_ethdev.c +7 -7
index 42aaef7..312c42c 100644
@@ -245,9 +245,9 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
-static int
-rte_eth_dev_init(struct rte_pci_driver *pci_drv,
-		 struct rte_pci_device *pci_dev)
+int
+rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
+		      struct rte_pci_device *pci_dev)
 {
 	struct eth_driver    *eth_drv;
 	struct rte_eth_dev *eth_dev;
@@ -299,8 +299,8 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 	return diag;
 }
 
-static int
-rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
+int
+rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 {
 	const struct eth_driver *eth_drv;
 	struct rte_eth_dev *eth_dev;
@@ -357,8 +357,8 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
 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;
+	eth_drv->pci_drv.devinit = rte_eth_dev_pci_probe;
+	eth_drv->pci_drv.devuninit = rte_eth_dev_pci_remove;
 	rte_eal_pci_register(&eth_drv->pci_drv);
 }
 
lib/librte_ether/rte_ethdev.h +13 -0
index bd93bf6..2249466 100644
@@ -4354,6 +4354,19 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id);
 int
 rte_eth_dev_get_name_by_port(uint8_t port_id, char *name);
 
+/**
+ * Wrapper for use by pci drivers as a .devinit function to attach to a ethdev
+ * interface.
+ */
+int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
+			  struct rte_pci_device *pci_dev);
+
+/**
+ * Wrapper for use by pci drivers as a .devuninit function to detach a ethdev
+ * interface.
+ */
+int rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev);
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_ether/rte_ether_version.map +3 -0
index 97ed0b0..cf4581c 100644
@@ -140,4 +140,7 @@ DPDK_16.07 {
 	rte_eth_dev_get_name_by_port;
 	rte_eth_dev_get_port_by_name;
 	rte_eth_xstats_get_names;
+	rte_eth_dev_pci_probe;
+	rte_eth_dev_pci_remove;
+
 } DPDK_16.04;
Signature · 1 line
2.7.4
#112 lore raw

PATCH v5 8/17 drivers: convert all pdev drivers as pci drivers

In reply to Shreyansh Jain

Simplify crypto and ethdev pci drivers init by using newly introduced init macros and helpers.
Those drivers then don't need to register as "rte_driver"s anymore.

virtio and mlx* drivers use the general purpose RTE_INIT macro, as they both need some special stuff to be done before registering a pci driver.

---
 drivers/crypto/qat/rte_qat_cryptodev.c  | 16 +++--------
 drivers/net/bnx2x/bnx2x_ethdev.c        | 35 +++++-------------------
 drivers/net/cxgbe/cxgbe_ethdev.c        | 24 +++--------------
 drivers/net/e1000/em_ethdev.c           | 16 +++--------
 drivers/net/e1000/igb_ethdev.c          | 40 +++++-----------------------
 drivers/net/ena/ena_ethdev.c            | 18 +++----------
 drivers/net/enic/enic_ethdev.c          | 23 +++-------------
 drivers/net/fm10k/fm10k_ethdev.c        | 23 +++-------------
 drivers/net/i40e/i40e_ethdev.c          | 26 +++---------------
 drivers/net/i40e/i40e_ethdev_vf.c       | 25 +++---------------
 drivers/net/ixgbe/ixgbe_ethdev.c        | 47 +++++----------------------------
 drivers/net/mlx4/mlx4.c                 | 20 +++-----------
 drivers/net/mlx5/mlx5.c                 | 19 +++----------
 drivers/net/nfp/nfp_net.c               | 21 +++------------
 drivers/net/qede/qede_ethdev.c          | 40 ++++++----------------------
 drivers/net/szedata2/rte_eth_szedata2.c | 25 +++---------------
 drivers/net/virtio/virtio_ethdev.c      | 26 +++++-------------
 drivers/net/vmxnet3/vmxnet3_ethdev.c    | 23 +++-------------
 18 files changed, 76 insertions(+), 391 deletions(-)
drivers/crypto/qat/rte_qat_cryptodev.c +3 -13
index 0ff3944..970970a 100644
@@ -117,21 +117,11 @@ static struct rte_cryptodev_driver rte_qat_pmd = {
 		.name = "rte_qat_pmd",
 		.id_table = pci_id_qat_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_cryptodev_pci_probe,
+		.devuninit = rte_cryptodev_pci_remove,
 	},
 	.cryptodev_init = crypto_qat_dev_init,
 	.dev_private_size = sizeof(struct qat_pmd_private),
 };
 
-static int
-rte_qat_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return rte_cryptodev_pmd_driver_register(&rte_qat_pmd, PMD_PDEV);
-}
-
-static struct rte_driver pmd_qat_drv = {
-	.type = PMD_PDEV,
-	.init = rte_qat_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(pmd_qat_drv);
+RTE_EAL_PCI_REGISTER(rte_qat_pmd);
drivers/net/bnx2x/bnx2x_ethdev.c +7 -28
index 071b44f..5ab3c75 100644
@@ -506,11 +506,15 @@ static struct eth_driver rte_bnx2x_pmd = {
 		.name = "rte_bnx2x_pmd",
 		.id_table = pci_id_bnx2x_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_bnx2x_dev_init,
 	.dev_private_size = sizeof(struct bnx2x_softc),
 };
 
+RTE_EAL_PCI_REGISTER(rte_bnx2x_pmd);
+
 /*
  * virtual function driver struct
  */
@@ -519,36 +523,11 @@ static struct eth_driver rte_bnx2xvf_pmd = {
 		.name = "rte_bnx2xvf_pmd",
 		.id_table = pci_id_bnx2xvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_bnx2xvf_dev_init,
 	.dev_private_size = sizeof(struct bnx2x_softc),
 };
 
-static int rte_bnx2x_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_bnx2x_pmd);
-
-	return 0;
-}
-
-static int rte_bnx2xvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_bnx2xvf_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_bnx2x_driver = {
-	.type = PMD_PDEV,
-	.init = rte_bnx2x_pmd_init,
-};
-
-static struct rte_driver rte_bnx2xvf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_bnx2xvf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_bnx2x_driver);
-PMD_REGISTER_DRIVER(rte_bnx2xvf_driver);
+RTE_EAL_PCI_REGISTER(rte_bnx2xvf_pmd);
drivers/net/cxgbe/cxgbe_ethdev.c +3 -21
index 04eddaf..1389371 100644
@@ -869,29 +869,11 @@ static struct eth_driver rte_cxgbe_pmd = {
 		.name = "rte_cxgbe_pmd",
 		.id_table = cxgb4_pci_tbl,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_cxgbe_dev_init,
 	.dev_private_size = sizeof(struct port_info),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI CXGBE devices.
- */
-static int rte_cxgbe_pmd_init(const char *name __rte_unused,
-			      const char *params __rte_unused)
-{
-	CXGBE_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_cxgbe_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_cxgbe_driver = {
-	.name = "cxgbe_driver",
-	.type = PMD_PDEV,
-	.init = rte_cxgbe_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_cxgbe_driver);
+RTE_EAL_PCI_REGISTER(rte_cxgbe_pmd);
drivers/net/e1000/em_ethdev.c +3 -13
index 653be09..c67e67f 100644
@@ -368,18 +368,15 @@ static struct eth_driver rte_em_pmd = {
 		.id_table = pci_id_em_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_em_dev_init,
 	.eth_dev_uninit = eth_em_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
-static int
-rte_em_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_em_pmd);
-	return 0;
-}
+RTE_EAL_PCI_REGISTER(rte_em_pmd);
 
 static int
 em_hw_init(struct e1000_hw *hw)
@@ -1771,10 +1768,3 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
 	e1000_update_mc_addr_list(hw, (u8 *)mc_addr_set, nb_mc_addr);
 	return 0;
 }
-
-struct rte_driver em_pmd_drv = {
-	.type = PMD_PDEV,
-	.init = rte_em_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(em_pmd_drv);
drivers/net/e1000/igb_ethdev.c +7 -33
index b822992..a523944 100644
@@ -983,12 +983,16 @@ static struct eth_driver rte_igb_pmd = {
 		.id_table = pci_id_igb_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_igb_dev_init,
 	.eth_dev_uninit = eth_igb_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
+RTE_EAL_PCI_REGISTER(rte_igb_pmd);
+
 /*
  * virtual function driver struct
  */
@@ -997,18 +1001,15 @@ static struct eth_driver rte_igbvf_pmd = {
 		.name = "rte_igbvf_pmd",
 		.id_table = pci_id_igbvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_igbvf_dev_init,
 	.eth_dev_uninit = eth_igbvf_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
-static int
-rte_igb_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_igb_pmd);
-	return 0;
-}
+RTE_EAL_PCI_REGISTER(rte_igbvf_pmd);
 
 static void
 igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
@@ -1021,20 +1022,6 @@ igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
 	E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 }
 
-/*
- * VF Driver initialization routine.
- * Invoked one at EAL init time.
- * Register itself as the [Virtual Poll Mode] Driver of PCI IGB devices.
- */
-static int
-rte_igbvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_igbvf_pmd);
-	return 0;
-}
-
 static int
 igb_check_mq_mode(struct rte_eth_dev *dev)
 {
@@ -4844,16 +4831,6 @@ eth_igb_set_eeprom(struct rte_eth_dev *dev,
 	return nvm->ops.write(hw,  first, length, data);
 }
 
-static struct rte_driver pmd_igb_drv = {
-	.type = PMD_PDEV,
-	.init = rte_igb_pmd_init,
-};
-
-static struct rte_driver pmd_igbvf_drv = {
-	.type = PMD_PDEV,
-	.init = rte_igbvf_pmd_init,
-};
-
 static int
 eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
@@ -5014,6 +4991,3 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev)
 
 	E1000_WRITE_FLUSH(hw);
 }
-
-PMD_REGISTER_DRIVER(pmd_igb_drv);
-PMD_REGISTER_DRIVER(pmd_igbvf_drv);
drivers/net/ena/ena_ethdev.c +3 -15
index 8d01e9a..dc32435 100644
@@ -1431,23 +1431,11 @@ static struct eth_driver rte_ena_pmd = {
 		.name = "rte_ena_pmd",
 		.id_table = pci_id_ena_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_ena_dev_init,
 	.dev_private_size = sizeof(struct ena_adapter),
 };
 
-static int
-rte_ena_pmd_init(const char *name __rte_unused,
-		 const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_ena_pmd);
-	return 0;
-};
-
-struct rte_driver ena_pmd_drv = {
-	.name = "ena_driver",
-	.type = PMD_PDEV,
-	.init = rte_ena_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(ena_pmd_drv);
+RTE_EAL_PCI_REGISTER(rte_ena_pmd);
drivers/net/enic/enic_ethdev.c +3 -20
index 6bea940..d5e395d 100644
@@ -660,28 +660,11 @@ static struct eth_driver rte_enic_pmd = {
 		.name = "rte_enic_pmd",
 		.id_table = pci_id_enic_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_enicpmd_dev_init,
 	.dev_private_size = sizeof(struct enic),
 };
 
-/* Driver initialization routine.
- * Invoked once at EAL init time.
- * Register as the [Poll Mode] Driver of Cisco ENIC device.
- */
-static int
-rte_enic_pmd_init(__rte_unused const char *name,
-	 __rte_unused const char *params)
-{
-	ENICPMD_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_enic_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_enic_driver = {
-	.type = PMD_PDEV,
-	.init = rte_enic_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_enic_driver);
+RTE_EAL_PCI_REGISTER(rte_enic_pmd);
drivers/net/fm10k/fm10k_ethdev.c +3 -20
index ce053b0..8ec8f5e 100644
@@ -3064,29 +3064,12 @@ static struct eth_driver rte_pmd_fm10k = {
 		.id_table = pci_id_fm10k_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_fm10k_dev_init,
 	.eth_dev_uninit = eth_fm10k_dev_uninit,
 	.dev_private_size = sizeof(struct fm10k_adapter),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI FM10K devices.
- */
-static int
-rte_pmd_fm10k_init(__rte_unused const char *name,
-	__rte_unused const char *params)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_pmd_fm10k);
-	return 0;
-}
-
-static struct rte_driver rte_fm10k_driver = {
-	.type = PMD_PDEV,
-	.init = rte_pmd_fm10k_init,
-};
-
-PMD_REGISTER_DRIVER(rte_fm10k_driver);
+RTE_EAL_PCI_REGISTER(rte_pmd_fm10k);
drivers/net/i40e/i40e_ethdev.c +4 -22
index f94ad87..f2712ab 100644
@@ -645,12 +645,16 @@ static struct eth_driver rte_i40e_pmd = {
 		.id_table = pci_id_i40e_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_i40e_dev_init,
 	.eth_dev_uninit = eth_i40e_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_adapter),
 };
 
+RTE_EAL_PCI_REGISTER(rte_i40e_pmd);
+
 static inline int
 rte_i40e_dev_atomic_read_link_status(struct rte_eth_dev *dev,
 				     struct rte_eth_link *link)
@@ -680,28 +684,6 @@ rte_i40e_dev_atomic_write_link_status(struct rte_eth_dev *dev,
 }
 
 /*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI IXGBE devices.
- */
-static int
-rte_i40e_pmd_init(const char *name __rte_unused,
-		  const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_i40e_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_i40e_driver = {
-	.type = PMD_PDEV,
-	.init = rte_i40e_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_i40e_driver);
-
-/*
  * Initialize registers for flexible payload, which should be set by NVM.
  * This should be removed from code once it is fixed in NVM.
  */
drivers/net/i40e/i40e_ethdev_vf.c +3 -22
index 37af399..3411831 100644
@@ -1555,34 +1555,15 @@ static struct eth_driver rte_i40evf_pmd = {
 		.name = "rte_i40evf_pmd",
 		.id_table = pci_id_i40evf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = i40evf_dev_init,
 	.eth_dev_uninit = i40evf_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_adapter),
 };
 
-/*
- * VF Driver initialization routine.
- * Invoked one at EAL init time.
- * Register itself as the [Virtual Poll Mode] Driver of PCI Fortville devices.
- */
-static int
-rte_i40evf_pmd_init(const char *name __rte_unused,
-		    const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_i40evf_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_i40evf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_i40evf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_i40evf_driver);
+RTE_EAL_PCI_REGISTER(rte_i40evf_pmd);
 
 static int
 i40evf_dev_configure(struct rte_eth_dev *dev)
drivers/net/ixgbe/ixgbe_ethdev.c +7 -40

74 lines not on this page · raw message

drivers/net/mlx4/mlx4.c +3 -17
index 9ed1491..b594433 100644
@@ -5837,15 +5837,10 @@ static struct eth_driver mlx4_driver = {
 	.dev_private_size = sizeof(struct priv)
 };
 
-/**
- * Driver initialization routine.
- */
-static int
-rte_mlx4_pmd_init(const char *name, const char *args)
+RTE_INIT(rte_mlx4_pmd_init);
+static void
+rte_mlx4_pmd_init(void)
 {
-	(void)name;
-	(void)args;
-
 	RTE_BUILD_BUG_ON(sizeof(wr_id_t) != sizeof(uint64_t));
 	/*
 	 * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
@@ -5856,13 +5851,4 @@ rte_mlx4_pmd_init(const char *name, const char *args)
 	setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
 	ibv_fork_init();
 	rte_eal_pci_register(&mlx4_driver.pci_drv);
-	return 0;
 }
-
-static struct rte_driver rte_mlx4_driver = {
-	.type = PMD_PDEV,
-	.name = MLX4_DRIVER_NAME,
-	.init = rte_mlx4_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_mlx4_driver)
drivers/net/mlx5/mlx5.c +3 -16
index 041cfc3..1989a37 100644
@@ -646,14 +646,10 @@ static struct eth_driver mlx5_driver = {
 	.dev_private_size = sizeof(struct priv)
 };
 
-/**
- * Driver initialization routine.
- */
-static int
-rte_mlx5_pmd_init(const char *name, const char *args)
+RTE_INIT(rte_mlx5_pmd_init);
+static void
+rte_mlx5_pmd_init(void)
 {
-	(void)name;
-	(void)args;
 	/*
 	 * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
 	 * huge pages. Calling ibv_fork_init() during init allows
@@ -663,13 +659,4 @@ rte_mlx5_pmd_init(const char *name, const char *args)
 	setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
 	ibv_fork_init();
 	rte_eal_pci_register(&mlx5_driver.pci_drv);
-	return 0;
 }
-
-static struct rte_driver rte_mlx5_driver = {
-	.type = PMD_PDEV,
-	.name = MLX5_DRIVER_NAME,
-	.init = rte_mlx5_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_mlx5_driver)
drivers/net/nfp/nfp_net.c +3 -18
index ef7011e..951c8b4 100644
@@ -2468,29 +2468,14 @@ static struct eth_driver rte_nfp_net_pmd = {
 		.id_table = pci_id_nfp_net_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			     RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = nfp_net_init,
 	.dev_private_size = sizeof(struct nfp_net_adapter),
 };
 
-static int
-nfp_net_pmd_init(const char *name __rte_unused,
-		 const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	PMD_INIT_LOG(INFO, "librte_pmd_nfp_net version %s\n",
-		     NFP_NET_PMD_VERSION);
-
-	rte_eth_driver_register(&rte_nfp_net_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_nfp_net_driver = {
-	.type = PMD_PDEV,
-	.init = nfp_net_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_nfp_net_driver);
+RTE_EAL_PCI_REGISTER(rte_nfp_net_pmd);
 
 /*
  * Local variables:
drivers/net/qede/qede_ethdev.c +8 -32
index 1273fd3..4fcb54c 100644
@@ -1056,7 +1056,9 @@ static struct eth_driver rte_qedevf_pmd = {
 		    .id_table = pci_id_qedevf_map,
 		    .drv_flags =
 		    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-		    },
+		    .devinit = rte_eth_dev_pci_probe,
+		    .devuninit = rte_eth_dev_pci_remove,
+		   },
 	.eth_dev_init = qedevf_eth_dev_init,
 	.eth_dev_uninit = qedevf_eth_dev_uninit,
 	.dev_private_size = sizeof(struct qede_dev),
@@ -1068,39 +1070,13 @@ static struct eth_driver rte_qede_pmd = {
 		    .id_table = pci_id_qede_map,
 		    .drv_flags =
 		    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-		    },
+		    .devinit = rte_eth_dev_pci_probe,
+		    .devuninit = rte_eth_dev_pci_remove,
+		   },
 	.eth_dev_init = qede_eth_dev_init,
 	.eth_dev_uninit = qede_eth_dev_uninit,
 	.dev_private_size = sizeof(struct qede_dev),
 };
 
-static int
-rte_qedevf_pmd_init(const char *name __rte_unused,
-		    const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_qedevf_pmd);
-
-	return 0;
-}
-
-static int
-rte_qede_pmd_init(const char *name __rte_unused,
-		  const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_qede_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_qedevf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_qede_pmd_init
-};
-
-static struct rte_driver rte_qede_driver = {
-	.type = PMD_PDEV,
-	.init = rte_qedevf_pmd_init
-};
-
-PMD_REGISTER_DRIVER(rte_qede_driver);
-PMD_REGISTER_DRIVER(rte_qedevf_driver);
+RTE_EAL_PCI_REGISTER(rte_qede_pmd);
+RTE_EAL_PCI_REGISTER(rte_qedevf_pmd);
drivers/net/szedata2/rte_eth_szedata2.c +3 -22
index 985a8d6..6815dbb 100644
@@ -1574,31 +1574,12 @@ static struct eth_driver szedata2_eth_driver = {
 	.pci_drv = {
 		.name     = RTE_SZEDATA2_PCI_DRIVER_NAME,
 		.id_table = rte_szedata2_pci_id_table,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init     = rte_szedata2_eth_dev_init,
 	.eth_dev_uninit   = rte_szedata2_eth_dev_uninit,
 	.dev_private_size = sizeof(struct pmd_internals),
 };
 
-static int
-rte_szedata2_init(const char *name __rte_unused,
-		const char *args __rte_unused)
-{
-	rte_eth_driver_register(&szedata2_eth_driver);
-	return 0;
-}
-
-static int
-rte_szedata2_uninit(const char *name __rte_unused)
-{
-	return 0;
-}
-
-static struct rte_driver rte_szedata2_driver = {
-	.type = PMD_PDEV,
-	.name = RTE_SZEDATA2_DRIVER_NAME,
-	.init = rte_szedata2_init,
-	.uninit = rte_szedata2_uninit,
-};
-
-PMD_REGISTER_DRIVER(rte_szedata2_driver);
+RTE_EAL_PCI_REGISTER(szedata2_eth_driver);
drivers/net/virtio/virtio_ethdev.c +7 -19
index a833740..9f5faf1 100644
@@ -1255,29 +1255,24 @@ static struct eth_driver rte_virtio_pmd = {
 		.name = "rte_virtio_pmd",
 		.id_table = pci_id_virtio_map,
 		.drv_flags = RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_virtio_dev_init,
 	.eth_dev_uninit = eth_virtio_dev_uninit,
 	.dev_private_size = sizeof(struct virtio_hw),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI virtio devices.
- * Returns 0 on success.
- */
-static int
-rte_virtio_pmd_init(const char *name __rte_unused,
-		    const char *param __rte_unused)
+RTE_INIT(rte_virtio_pmd_init);
+static void
+rte_virtio_pmd_init(void)
 {
 	if (rte_eal_iopl_init() != 0) {
 		PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
-		return -1;
+		return;
 	}
 
-	rte_eth_driver_register(&rte_virtio_pmd);
-	return 0;
+	rte_eal_pci_register(&rte_virtio_pmd.pci_drv);
 }
 
 /*
@@ -1499,10 +1494,3 @@ __rte_unused uint8_t is_rx)
 {
 	return 0;
 }
-
-static struct rte_driver rte_virtio_driver = {
-	.type = PMD_PDEV,
-	.init = rte_virtio_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_virtio_driver);
drivers/net/vmxnet3/vmxnet3_ethdev.c +3 -20
index 29b469c..79c5f6d 100644
@@ -332,25 +332,15 @@ static struct eth_driver rte_vmxnet3_pmd = {
 		.name = "rte_vmxnet3_pmd",
 		.id_table = pci_id_vmxnet3_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_vmxnet3_dev_init,
 	.eth_dev_uninit = eth_vmxnet3_dev_uninit,
 	.dev_private_size = sizeof(struct vmxnet3_hw),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of Virtual PCI VMXNET3 devices.
- */
-static int
-rte_vmxnet3_pmd_init(const char *name __rte_unused, const char *param __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_vmxnet3_pmd);
-	return 0;
-}
+RTE_EAL_PCI_REGISTER(rte_vmxnet3_pmd);
 
 static int
 vmxnet3_dev_configure(struct rte_eth_dev *dev)
@@ -948,10 +938,3 @@ vmxnet3_process_events(struct vmxnet3_hw *hw)
 
 }
 #endif
-
-static struct rte_driver rte_vmxnet3_driver = {
-	.type = PMD_PDEV,
-	.init = rte_vmxnet3_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_vmxnet3_driver);
Signature · 1 line
2.7.4
#113 lore raw

PATCH v5 9/17 crypto: get rid of crypto driver register callback

In reply to Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register crypto drivers through a dedicated channel.

---
 lib/librte_cryptodev/rte_cryptodev.c           | 22 -------------------
 lib/librte_cryptodev/rte_cryptodev_pmd.h       | 30 --------------------------
 lib/librte_cryptodev/rte_cryptodev_version.map |  1 -
 3 files changed, 53 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +0 -22
index 65a2e29..a7cb33a 100644
@@ -444,28 +444,6 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv,
-		enum pmd_type type)
-{
-	/* Call crypto device initialization directly if device is virtual */
-	if (type == PMD_VDEV)
-		return rte_cryptodev_pci_probe((struct rte_pci_driver *)cryptodrv,
-				NULL);
-
-	/*
-	 * Register PCI driver for physical device intialisation during
-	 * PCI probing
-	 */
-	cryptodrv->pci_drv.devinit = rte_cryptodev_pci_probe;
-	cryptodrv->pci_drv.devuninit = rte_cryptodev_pci_remove;
-
-	rte_eal_pci_register(&cryptodrv->pci_drv);
-
-	return 0;
-}
-
-
 uint16_t
 rte_cryptodev_queue_pair_count(uint8_t dev_id)
 {
lib/librte_cryptodev/rte_cryptodev_pmd.h +0 -30
index 3fb7c7c..99fd69e 100644
@@ -491,36 +491,6 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 extern int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);
 
-
-/**
- * Register a Crypto [Poll Mode] driver.
- *
- * Function invoked by the initialization function of a Crypto driver
- * to simultaneously register itself as Crypto Poll Mode Driver and to either:
- *
- *	a - register itself as PCI driver if the crypto device is a physical
- *		device, by invoking the rte_eal_pci_register() function to
- *		register the *pci_drv* structure embedded in the *crypto_drv*
- *		structure, after having stored the address of the
- *		rte_cryptodev_init() function in the *devinit* field of the
- *		*pci_drv* structure.
- *
- *		During the PCI probing phase, the rte_cryptodev_init()
- *		function is invoked for each PCI [device] matching the
- *		embedded PCI identifiers provided by the driver.
- *
- *	b, complete the initialization sequence if the device is a virtual
- *		device by calling the rte_cryptodev_init() directly passing a
- *		NULL parameter for the rte_pci_device structure.
- *
- *   @param crypto_drv	crypto_driver structure associated with the crypto
- *					driver.
- *   @param type		pmd type
- */
-extern int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
-		enum pmd_type type);
-
 /**
  * Executes all the user application registered callbacks for the specific
  * device.
lib/librte_cryptodev/rte_cryptodev_version.map +0 -1
index 8d0edfb..e0a9620 100644
@@ -14,7 +14,6 @@ DPDK_16.04 {
 	rte_cryptodev_info_get;
 	rte_cryptodev_pmd_allocate;
 	rte_cryptodev_pmd_callback_process;
-	rte_cryptodev_pmd_driver_register;
 	rte_cryptodev_pmd_release_device;
 	rte_cryptodev_pmd_virtual_dev_init;
 	rte_cryptodev_sym_session_create;
Signature · 1 line
2.7.4
#114 lore raw

Re: [PATCH v5 09/17] crypto: get rid of crypto driver register callback

Quoted 90 lines · Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register crypto drivers through a dedicated channel.

---
 lib/librte_cryptodev/rte_cryptodev.c           | 22 -------------------
 lib/librte_cryptodev/rte_cryptodev_pmd.h       | 30 --------------------------
 lib/librte_cryptodev/rte_cryptodev_version.map |  1 -
 3 files changed, 53 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +0 -22
index 65a2e29..a7cb33a 100644
@@ -444,28 +444,6 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv,
-		enum pmd_type type)
-{
-	/* Call crypto device initialization directly if device is virtual */
-	if (type == PMD_VDEV)
-		return rte_cryptodev_pci_probe((struct rte_pci_driver *)cryptodrv,
-				NULL);
-
-	/*
-	 * Register PCI driver for physical device intialisation during
-	 * PCI probing
-	 */
-	cryptodrv->pci_drv.devinit = rte_cryptodev_pci_probe;
-	cryptodrv->pci_drv.devuninit = rte_cryptodev_pci_remove;
-
-	rte_eal_pci_register(&cryptodrv->pci_drv);
-
-	return 0;
-}
-
-
 uint16_t
 rte_cryptodev_queue_pair_count(uint8_t dev_id)
 {
lib/librte_cryptodev/rte_cryptodev_pmd.h +0 -30
index 3fb7c7c..99fd69e 100644
@@ -491,36 +491,6 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 extern int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);
 
-
-/**
- * Register a Crypto [Poll Mode] driver.
- *
- * Function invoked by the initialization function of a Crypto driver
- * to simultaneously register itself as Crypto Poll Mode Driver and to either:
- *
- *	a - register itself as PCI driver if the crypto device is a physical
- *		device, by invoking the rte_eal_pci_register() function to
- *		register the *pci_drv* structure embedded in the *crypto_drv*
- *		structure, after having stored the address of the
- *		rte_cryptodev_init() function in the *devinit* field of the
- *		*pci_drv* structure.
- *
- *		During the PCI probing phase, the rte_cryptodev_init()
- *		function is invoked for each PCI [device] matching the
- *		embedded PCI identifiers provided by the driver.
- *
- *	b, complete the initialization sequence if the device is a virtual
- *		device by calling the rte_cryptodev_init() directly passing a
- *		NULL parameter for the rte_pci_device structure.
- *
- *   @param crypto_drv	crypto_driver structure associated with the crypto
- *					driver.
- *   @param type		pmd type
- */
-extern int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
-		enum pmd_type type);
-
 /**
  * Executes all the user application registered callbacks for the specific
  * device.
lib/librte_cryptodev/rte_cryptodev_version.map +0 -0
index 8d0edfb..e0a9620 100644

lib/librte_cryptodev/rte_cryptodev_version.map DPDK_16.04 { · line 19

Quoted 7 lines
lib/librte_cryptodev/rte_cryptodev_version.map +0 -1
@@ -14,7 +14,6 @@ DPDK_16.04 {
 	rte_cryptodev_info_get;
 	rte_cryptodev_pmd_allocate;
 	rte_cryptodev_pmd_callback_process;
-	rte_cryptodev_pmd_driver_register;
 	rte_cryptodev_pmd_release_device;
 	rte_cryptodev_pmd_virtual_dev_init;
 	rte_cryptodev_sym_session_create;

NAK, you can't just remove exported symbols without going through the deprecation process. Better still would be to only expose it for DPDK_16.04 and hide it in the next release

Neil

Quoted 4 lines
Signature · 1 line
2.7.4
#115 lore raw

Re: [PATCH v5 09/17] crypto: get rid of crypto driver register callback

Quoted 93 lines · Neil Horman
Quoted 92 lines · Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register crypto drivers through a dedicated channel.

---
 lib/librte_cryptodev/rte_cryptodev.c           | 22 -------------------
 lib/librte_cryptodev/rte_cryptodev_pmd.h       | 30 --------------------------
 lib/librte_cryptodev/rte_cryptodev_version.map |  1 -
 3 files changed, 53 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +0 -22
index 65a2e29..a7cb33a 100644
@@ -444,28 +444,6 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv,
-		enum pmd_type type)
-{
-	/* Call crypto device initialization directly if device is virtual */
-	if (type == PMD_VDEV)
-		return rte_cryptodev_pci_probe((struct rte_pci_driver *)cryptodrv,
-				NULL);
-
-	/*
-	 * Register PCI driver for physical device intialisation during
-	 * PCI probing
-	 */
-	cryptodrv->pci_drv.devinit = rte_cryptodev_pci_probe;
-	cryptodrv->pci_drv.devuninit = rte_cryptodev_pci_remove;
-
-	rte_eal_pci_register(&cryptodrv->pci_drv);
-
-	return 0;
-}
-
-
 uint16_t
 rte_cryptodev_queue_pair_count(uint8_t dev_id)
 {
lib/librte_cryptodev/rte_cryptodev_pmd.h +0 -30
index 3fb7c7c..99fd69e 100644
@@ -491,36 +491,6 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 extern int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);
 
-
-/**
- * Register a Crypto [Poll Mode] driver.
- *
- * Function invoked by the initialization function of a Crypto driver
- * to simultaneously register itself as Crypto Poll Mode Driver and to either:
- *
- *	a - register itself as PCI driver if the crypto device is a physical
- *		device, by invoking the rte_eal_pci_register() function to
- *		register the *pci_drv* structure embedded in the *crypto_drv*
- *		structure, after having stored the address of the
- *		rte_cryptodev_init() function in the *devinit* field of the
- *		*pci_drv* structure.
- *
- *		During the PCI probing phase, the rte_cryptodev_init()
- *		function is invoked for each PCI [device] matching the
- *		embedded PCI identifiers provided by the driver.
- *
- *	b, complete the initialization sequence if the device is a virtual
- *		device by calling the rte_cryptodev_init() directly passing a
- *		NULL parameter for the rte_pci_device structure.
- *
- *   @param crypto_drv	crypto_driver structure associated with the crypto
- *					driver.
- *   @param type		pmd type
- */
-extern int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
-		enum pmd_type type);
-
 /**
  * Executes all the user application registered callbacks for the specific
  * device.
lib/librte_cryptodev/rte_cryptodev_version.map +0 -0
index 8d0edfb..e0a9620 100644
@@ -14,7 +14,6 @@ DPDK_16.04 {
 	rte_cryptodev_info_get;
 	rte_cryptodev_pmd_allocate;
Quoted 8 lines

lib/librte_cryptodev/rte_cryptodev_version.map DPDK_16.04 { · line 19

Quoted 5 lines
lib/librte_cryptodev/rte_cryptodev_version.map +0 -1
 	rte_cryptodev_pmd_callback_process;
-	rte_cryptodev_pmd_driver_register;
 	rte_cryptodev_pmd_release_device;
 	rte_cryptodev_pmd_virtual_dev_init;
 	rte_cryptodev_sym_session_create;

NAK, you can't just remove exported symbols without going through the deprecation process. Better still would be to only expose it for DPDK_16.04 and hide it in the next release

Agree. I will fix it.

Quoted 8 lines

Neil

Quoted 4 lines
Signature · 1 line
2.7.4
#116 lore raw

Re: [PATCH v5 09/17] crypto: get rid of crypto driver register callback

In reply to Neil Horman

2016-06-22 09:27, Neil Horman:

Quoted 5 lines

lib/librte_cryptodev/rte_cryptodev_version.map DPDK_16.04 { · line 17

Quoted 2 lines

+++ b/lib/librte_cryptodev/rte_cryptodev_version.map

lib/librte_cryptodev/rte_cryptodev_version.map +0 -1
-	rte_cryptodev_pmd_driver_register;

NAK, you can't just remove exported symbols without going through the deprecation process. Better still would be to only expose it for DPDK_16.04 and hide it in the next release

This function is not called by the application.
Thus there is no ABI break.

#117 lore raw

PATCH v5 10/17 ethdev: get rid of eth driver register callback

In reply to Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register ethdev drivers through a dedicated channel.

---
 lib/librte_ether/rte_ethdev.c          | 22 ----------------------
 lib/librte_ether/rte_ethdev.h          | 12 ------------
 lib/librte_ether/rte_ether_version.map |  1 -
 3 files changed, 35 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -22
index 312c42c..06065fe 100644
@@ -340,28 +340,6 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-/**
- * Register an Ethernet [Poll Mode] driver.
- *
- * Function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * 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
- * the *pci_drv* structure.
- * During the PCI probing phase, the rte_eth_dev_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_pci_probe;
-	eth_drv->pci_drv.devuninit = rte_eth_dev_pci_remove;
-	rte_eal_pci_register(&eth_drv->pci_drv);
-}
-
 int
 rte_eth_dev_is_valid_port(uint8_t port_id)
 {
lib/librte_ether/rte_ethdev.h +0 -12
index 2249466..ffd24e4 100644
@@ -1862,18 +1862,6 @@ struct eth_driver {
 };
 
 /**
- * @internal
- * A function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * Poll Mode Driver (PMD).
- *
- * @param eth_drv
- *   The pointer to the *eth_driver* structure associated with
- *   the Ethernet driver.
- */
-void rte_eth_driver_register(struct eth_driver *eth_drv);
-
-/**
  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
  * the bitmap link_speeds of the struct rte_eth_conf
  *
lib/librte_ether/rte_ether_version.map +0 -1
index cf4581c..8151007 100644
@@ -80,7 +80,6 @@ DPDK_2.2 {
 	rte_eth_dev_vlan_filter;
 	rte_eth_dev_wd_timeout_store;
 	rte_eth_dma_zone_reserve;
-	rte_eth_driver_register;
 	rte_eth_led_off;
 	rte_eth_led_on;
 	rte_eth_link;
Signature · 1 line
2.7.4
#118 lore raw

Re: [PATCH v5 10/17] ethdev: get rid of eth driver register callback

Quoted 72 lines · Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register ethdev drivers through a dedicated channel.

---
 lib/librte_ether/rte_ethdev.c          | 22 ----------------------
 lib/librte_ether/rte_ethdev.h          | 12 ------------
 lib/librte_ether/rte_ether_version.map |  1 -
 3 files changed, 35 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -22
index 312c42c..06065fe 100644
@@ -340,28 +340,6 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-/**
- * Register an Ethernet [Poll Mode] driver.
- *
- * Function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * 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
- * the *pci_drv* structure.
- * During the PCI probing phase, the rte_eth_dev_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_pci_probe;
-	eth_drv->pci_drv.devuninit = rte_eth_dev_pci_remove;
-	rte_eal_pci_register(&eth_drv->pci_drv);
-}
-
 int
 rte_eth_dev_is_valid_port(uint8_t port_id)
 {
lib/librte_ether/rte_ethdev.h +0 -12
index 2249466..ffd24e4 100644
@@ -1862,18 +1862,6 @@ struct eth_driver {
 };
 
 /**
- * @internal
- * A function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * Poll Mode Driver (PMD).
- *
- * @param eth_drv
- *   The pointer to the *eth_driver* structure associated with
- *   the Ethernet driver.
- */
-void rte_eth_driver_register(struct eth_driver *eth_drv);
-
-/**
  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
  * the bitmap link_speeds of the struct rte_eth_conf
  *
lib/librte_ether/rte_ether_version.map +0 -0
index cf4581c..8151007 100644

lib/librte_ether/rte_ether_version.map DPDK_2.2 { · line 85

Quoted 7 lines
lib/librte_ether/rte_ether_version.map +0 -1
@@ -80,7 +80,6 @@ DPDK_2.2 {
 	rte_eth_dev_vlan_filter;
 	rte_eth_dev_wd_timeout_store;
 	rte_eth_dma_zone_reserve;
-	rte_eth_driver_register;
 	rte_eth_led_off;
 	rte_eth_led_on;
 	rte_eth_link;

Nak, Same issue as the crypto registration

Quoted 4 lines
Signature · 1 line
2.7.4
#119 lore raw

Re: [PATCH v5 10/17] ethdev: get rid of eth driver register callback

Quoted 73 lines · Neil Horman
Quoted 72 lines · Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register ethdev drivers through a dedicated channel.

---
 lib/librte_ether/rte_ethdev.c          | 22 ----------------------
 lib/librte_ether/rte_ethdev.h          | 12 ------------
 lib/librte_ether/rte_ether_version.map |  1 -
 3 files changed, 35 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -22
index 312c42c..06065fe 100644
@@ -340,28 +340,6 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-/**
- * Register an Ethernet [Poll Mode] driver.
- *
- * Function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * 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
- * the *pci_drv* structure.
- * During the PCI probing phase, the rte_eth_dev_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_pci_probe;
-	eth_drv->pci_drv.devuninit = rte_eth_dev_pci_remove;
-	rte_eal_pci_register(&eth_drv->pci_drv);
-}
-
 int
 rte_eth_dev_is_valid_port(uint8_t port_id)
 {
lib/librte_ether/rte_ethdev.h +0 -12
index 2249466..ffd24e4 100644
@@ -1862,18 +1862,6 @@ struct eth_driver {
 };
 
 /**
- * @internal
- * A function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * Poll Mode Driver (PMD).
- *
- * @param eth_drv
- *   The pointer to the *eth_driver* structure associated with
- *   the Ethernet driver.
- */
-void rte_eth_driver_register(struct eth_driver *eth_drv);
-
-/**
  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
  * the bitmap link_speeds of the struct rte_eth_conf
  *
lib/librte_ether/rte_ether_version.map +0 -0
index cf4581c..8151007 100644
@@ -80,7 +80,6 @@ DPDK_2.2 {
Quoted 8 lines

lib/librte_ether/rte_ether_version.map DPDK_2.2 { · line 85

Quoted 7 lines
lib/librte_ether/rte_ether_version.map +0 -1
 	rte_eth_dev_vlan_filter;
 	rte_eth_dev_wd_timeout_store;
 	rte_eth_dma_zone_reserve;
-	rte_eth_driver_register;
 	rte_eth_led_off;
 	rte_eth_led_on;
 	rte_eth_link;

Nak, Same issue as the crypto registration

Yes, I agree. I will fix this in next version.

Quoted 6 lines
Quoted 5 lines
Signature · 2 lines
-- 
2.7.4
#120 lore raw

PATCH v5 11/17 eal/linux: move back interrupt thread init before setting affinity

In reply to Shreyansh Jain

Now that virtio pci driver is initialized in a constructor, iopl() stuff happens early enough so that interrupt thread can be created right after plugin loading.
This way, chelsio driver should be happy again [1].

[1] http://dpdk.org/ml/archives/dev/2015-November/028289.html

---
 lib/librte_eal/linuxapp/eal/eal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +3 -3
index 29fba52..748daca 100644
@@ -821,6 +821,9 @@ rte_eal_init(int argc, char **argv)
 	if (eal_plugins_init() < 0)
 		rte_panic("Cannot init plugins\n");
 
+	if (rte_eal_intr_init() < 0)
+		rte_panic("Cannot init interrupt-handling thread\n");
+
 	eal_thread_init_master(rte_config.master_lcore);
 
 	ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
@@ -832,9 +835,6 @@ rte_eal_init(int argc, char **argv)
 	if (rte_eal_dev_init() < 0)
 		rte_panic("Cannot init pmd devices\n");
 
-	if (rte_eal_intr_init() < 0)
-		rte_panic("Cannot init interrupt-handling thread\n");
-
 	RTE_LCORE_FOREACH_SLAVE(i) {
 
 		/*
Signature · 1 line
2.7.4
#121 lore raw

PATCH v5 12/17 pci: add a helper for device name

In reply to Shreyansh Jain

eal is a better place than crypto / ethdev for naming resources. Add a helper in eal and make use of it in crypto / ethdev.

---
 lib/librte_cryptodev/rte_cryptodev.c    | 27 ++++-----------------------
 lib/librte_eal/common/include/rte_pci.h | 25 +++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.c           | 24 ++++--------------------
 3 files changed, 33 insertions(+), 43 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +4 -23
index a7cb33a..3b587e4 100644
@@ -276,23 +276,6 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 	return cryptodev;
 }
 
-static inline int
-rte_cryptodev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
-{
-	int ret;
-
-	if ((name == NULL) || (pci_dev == NULL))
-		return -EINVAL;
-
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
 int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
 {
@@ -355,9 +338,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
 	if (cryptodrv == NULL)
 		return -ENODEV;
 
-	/* Create unique Crypto device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 	if (cryptodev == NULL)
@@ -412,9 +394,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -EINVAL;
 
-	/* Create unique device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
 	if (cryptodev == NULL)
lib/librte_eal/common/include/rte_pci.h +25 -0
index ac890fc..1666a55 100644
@@ -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. */
@@ -95,6 +96,7 @@ const char *pci_get_sysfs_path(void);
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
+#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
@@ -308,6 +310,29 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
 }
 #undef GET_PCIADDR_FIELD
 
+/**
+ * Utility function to write a pci device name, this device name can later be
+ * used to retrieve the corresponding rte_pci_addr using above functions.
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address
+ * @param output
+ *	The output buffer string
+ * @param size
+ *	The output buffer size
+ * @return
+ *  0 on success, negative on error.
+ */
+static inline void
+rte_eal_pci_device_name(const struct rte_pci_addr *addr,
+		    char *output, size_t size)
+{
+	RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
+	RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
+			    addr->domain, addr->bus,
+			    addr->devid, addr->function) >= 0);
+}
+
 /* Compare two PCI device addresses. */
 /**
  * Utility function to compare two PCI device addresses.
lib/librte_ether/rte_ethdev.c +4 -20
index 06065fe..ace8353 100644
@@ -220,20 +220,6 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	return eth_dev;
 }
 
-static int
-rte_eth_dev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
-{
-	int ret;
-
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
 int
 rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 {
@@ -257,9 +243,8 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
 
 	eth_drv = (struct eth_driver *)pci_drv;
 
-	/* Create unique Ethernet device name using PCI address */
-	rte_eth_dev_create_unique_device_name(ethdev_name,
-			sizeof(ethdev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
+			sizeof(ethdev_name));
 
 	eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
 	if (eth_dev == NULL)
@@ -310,9 +295,8 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -EINVAL;
 
-	/* Create unique Ethernet device name using PCI address */
-	rte_eth_dev_create_unique_device_name(ethdev_name,
-			sizeof(ethdev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
+			sizeof(ethdev_name));
 
 	eth_dev = rte_eth_dev_allocated(ethdev_name);
 	if (eth_dev == NULL)
Signature · 1 line
2.7.4
#122 lore raw

PATCH v5 13/17 pci: add a helper to update a device

In reply to Shreyansh Jain

This helper updates a pci device object with latest information it can find.
It will be used mainly for hotplug code.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c     | 49 +++++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_common_pci.c  |  2 --
 lib/librte_eal/common/eal_private.h     | 13 +++++++++
 lib/librte_eal/common/include/rte_pci.h |  3 ++
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 13 +++++++++
 5 files changed, 78 insertions(+), 2 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +49 -0
index 880483d..013c953 100644
@@ -406,6 +406,55 @@ error:
 	return -1;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	int fd;
+	struct pci_conf matches[2];
+	struct pci_match_conf match = {
+		.pc_sel = {
+			.pc_domain = addr->domain,
+			.pc_bus = addr->bus,
+			.pc_dev = addr->devid,
+			.pc_func = addr->function,
+		},
+	};
+	struct pci_conf_io conf_io = {
+		.pat_buf_len = 0,
+		.num_patterns = 1,
+		.patterns = &match,
+		.match_buf_len = sizeof(matches),
+		.matches = &matches[0],
+	};
+
+	fd = open("/dev/pci", O_RDONLY);
+	if (fd < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
+		goto error;
+	}
+
+	if (ioctl(fd, PCIOCGETCONF, &conf_io) < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error with ioctl on /dev/pci: %s\n",
+				__func__, strerror(errno));
+		goto error;
+	}
+
+	if (conf_io.num_matches != 1)
+		goto error;
+
+	if (pci_scan_one(fd, &matches[0]) < 0)
+		goto error;
+
+	close(fd);
+
+	return 0;
+
+error:
+	if (fd >= 0)
+		close(fd);
+	return -1;
+}
+
 /* Read PCI config space. */
 int rte_eal_pci_read_config(const struct rte_pci_device *dev,
 			    void *buf, size_t len, off_t offset)
lib/librte_eal/common/eal_common_pci.c +0 -2
index fee4aa5..dfd0a8c 100644
@@ -87,8 +87,6 @@ struct pci_driver_list pci_driver_list =
 struct pci_device_list pci_device_list =
 	TAILQ_HEAD_INITIALIZER(pci_device_list);
 
-#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
-
 const char *pci_get_sysfs_path(void)
 {
 	const char *path = NULL;
lib/librte_eal/common/eal_private.h +13 -0
index 06a68f6..b8ff9c5 100644
@@ -152,6 +152,19 @@ struct rte_pci_driver;
 struct rte_pci_device;
 
 /**
+ * Update a pci device object by asking the kernel for the latest information.
+ *
+ * This function is private to EAL.
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address to look for
+ * @return
+ *   - 0 on success.
+ *   - negative on error.
+ */
+int pci_update_device(const struct rte_pci_addr *addr);
+
+/**
  * Unbind kernel driver for this device
  *
  * This function is private to EAL.
lib/librte_eal/common/include/rte_pci.h +3 -0
index 1666a55..eed6b56 100644
@@ -107,6 +107,9 @@ const char *pci_get_sysfs_path(void);
 /** Nb. of values in PCI resource format. */
 #define PCI_RESOURCE_FMT_NVAL 3
 
+/** Default sysfs path for PCI device search. */
+#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
+
 /**
  * A structure describing a PCI resource.
  */
lib/librte_eal/linuxapp/eal/eal_pci.c +13 -0
index bfc410f..0a368c5 100644
@@ -417,6 +417,19 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 	return 0;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	char filename[PATH_MAX];
+
+	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
+		 SYSFS_PCI_DEVICES, addr->domain, addr->bus, addr->devid,
+		 addr->function);
+
+	return pci_scan_one(filename, addr->domain, addr->bus, addr->devid,
+			    addr->function);
+}
+
 /*
  * split up a pci address into its constituent parts.
  */
Signature · 1 line
2.7.4
#123 lore raw

PATCH v5 14/17 ethdev: do not scan all pci devices on attach

In reply to Shreyansh Jain

No need to scan all devices, we only need to update the device being attached.

---
 lib/librte_eal/common/eal_common_pci.c | 11 ++++++++---
 lib/librte_ether/rte_ethdev.c          |  3 ---
 2 files changed, 8 insertions(+), 6 deletions(-)
lib/librte_eal/common/eal_common_pci.c +8 -3
index dfd0a8c..d05dda4 100644
@@ -339,6 +339,11 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 	if (addr == NULL)
 		return -1;
 
+	/* update current pci device in global list, kernel bindings might have
+	 * changed since last time we looked at it */
+	if (pci_update_device(addr) < 0)
+		goto err_return;
+
 	TAILQ_FOREACH(dev, &pci_device_list, next) {
 		if (rte_eal_compare_pci_addr(&dev->addr, addr))
 			continue;
@@ -351,9 +356,9 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 	return -1;
 
 err_return:
-	RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT
-			" cannot be used\n", dev->addr.domain, dev->addr.bus,
-			dev->addr.devid, dev->addr.function);
+	RTE_LOG(WARNING, EAL,
+		"Requested device " PCI_PRI_FMT " cannot be used\n",
+		addr->domain, addr->bus, addr->devid, addr->function);
 	return -1;
 }
 
lib/librte_ether/rte_ethdev.c +0 -3
index ace8353..6f2b169 100644
@@ -469,9 +469,6 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 static int
 rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
 {
-	/* re-construct pci_device_list */
-	if (rte_eal_pci_scan())
-		goto err;
 	/* Invoke probe func of the driver can handle the new device. */
 	if (rte_eal_pci_probe_one(addr))
 		goto err;
Signature · 1 line
2.7.4
#124 lore raw

PATCH v5 15/17 eal: add hotplug operations for pci and vdev

In reply to Shreyansh Jain

hotplug which deals with resources should come from the layer that already handles them, i.e. eal.

For both attach and detach operations, 'name' is used to select the bus that will handle the request.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  2 ++
 lib/librte_eal/common/eal_common_dev.c          | 47 +++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_dev.h         | 25 +++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 ++
 4 files changed, 76 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
index 1852c4a..6f9324f 100644
@@ -159,5 +159,7 @@ DPDK_16.07 {
 	rte_keepalive_mark_sleep;
 	rte_keepalive_register_relay_callback;
 	rte_thread_setname;
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
 
 } DPDK_16.04;
lib/librte_eal/common/eal_common_dev.c +47 -0

50 lines not on this page · raw message

lib/librte_eal/common/include/rte_dev.h +25 -0
index 85e48f2..b1c0520 100644
@@ -178,6 +178,31 @@ int rte_eal_vdev_init(const char *name, const char *args);
  */
 int rte_eal_vdev_uninit(const char *name);
 
+/**
+ * Attach a resource to a registered driver.
+ *
+ * @param name
+ *   The resource name, that refers to a pci resource or some private
+ *   way of designating a resource for vdev drivers. Based on this
+ *   resource name, eal will identify a driver capable of handling
+ *   this resource and pass this resource to the driver probing
+ *   function.
+ * @param devargs
+ *   Device arguments to be passed to the driver.
+ * @return
+ *   0 on success, negative on error.
+ */
+int rte_eal_dev_attach(const char *name, const char *devargs);
+
+/**
+ * Detach a resource from its driver.
+ *
+ * @param name
+ *   Same description as for rte_eal_dev_attach().
+ *   Here, eal will call the driver detaching function.
+ */
+int rte_eal_dev_detach(const char *name);
+
 #define PMD_REGISTER_DRIVER(d)\
 RTE_INIT(devinitfn_ ##d);\
 static void devinitfn_ ##d(void)\
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
index 0513467..6c6163e 100644
@@ -162,5 +162,7 @@ DPDK_16.07 {
 	rte_keepalive_mark_sleep;
 	rte_keepalive_register_relay_callback;
 	rte_thread_setname;
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
 
 } DPDK_16.04;
Signature · 1 line
2.7.4
#125 lore raw

PATCH v5 16/17 ethdev: convert to eal hotplug

In reply to Shreyansh Jain

Remove bus logic from ethdev hotplug by using eal for this.

Current api is preserved:
- the last port that has been created is tracked to return it to the application when attaching,
- the internal device name is reused when detaching.

We can not get rid of ethdev hotplug yet since we still need some mechanism to inform applications of port creation/removal to substitute for ethdev hotplug api.

dev_type field in struct rte_eth_dev and rte_eth_dev_allocate are kept as is, but this information is not needed anymore and is removed in the following commit.

---
 lib/librte_ether/rte_ethdev.c | 207 +++++++-----------------------------------
 1 file changed, 33 insertions(+), 174 deletions(-)
lib/librte_ether/rte_ethdev.c +33 -174
index 6f2b169..10e81e1 100644
@@ -72,6 +72,7 @@
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 static struct rte_eth_dev_data *rte_eth_dev_data;
+static uint8_t eth_dev_last_created_port;
 static uint8_t nb_ports;
 
 /* spinlock for eth device callbacks */
@@ -216,6 +217,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	eth_dev->data->port_id = port_id;
 	eth_dev->attached = DEV_ATTACHED;
 	eth_dev->dev_type = type;
+	eth_dev_last_created_port = port_id;
 	nb_ports++;
 	return eth_dev;
 }
@@ -347,27 +349,6 @@ rte_eth_dev_count(void)
 	return nb_ports;
 }
 
-static enum rte_eth_dev_type
-rte_eth_dev_get_device_type(uint8_t port_id)
-{
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, RTE_ETH_DEV_UNKNOWN);
-	return rte_eth_devices[port_id].dev_type;
-}
-
-static int
-rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
-{
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
-
-	if (addr == NULL) {
-		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
-		return -EINVAL;
-	}
-
-	*addr = rte_eth_devices[port_id].pci_dev->addr;
-	return 0;
-}
-
 int
 rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 {
@@ -413,34 +394,6 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id)
 }
 
 static int
-rte_eth_dev_get_port_by_addr(const struct rte_pci_addr *addr, uint8_t *port_id)
-{
-	int i;
-	struct rte_pci_device *pci_dev = NULL;
-
-	if (addr == NULL) {
-		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
-		return -EINVAL;
-	}
-
-	*port_id = RTE_MAX_ETHPORTS;
-
-	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-
-		pci_dev = rte_eth_devices[i].pci_dev;
-
-		if (pci_dev &&
-			!rte_eal_compare_pci_addr(&pci_dev->addr, addr)) {
-
-			*port_id = i;
-
-			return 0;
-		}
-	}
-	return -ENODEV;
-}
-
-static int
 rte_eth_dev_is_detachable(uint8_t port_id)
 {
 	uint32_t dev_flags;
@@ -465,124 +418,45 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 		return 1;
 }
 
-/* attach the new physical device, then store port_id of the device */
-static int
-rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
-{
-	/* Invoke probe func of the driver can handle the new device. */
-	if (rte_eal_pci_probe_one(addr))
-		goto err;
-
-	if (rte_eth_dev_get_port_by_addr(addr, port_id))
-		goto err;
-
-	return 0;
-err:
-	return -1;
-}
-
-/* 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)
-{
-	struct rte_pci_addr freed_addr;
-	struct rte_pci_addr vp;
-
-	/* get pci address by port id */
-	if (rte_eth_dev_get_addr_by_port(port_id, &freed_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)
-		goto err;
-
-	/* invoke devuninit func of the pci driver,
-	 * also remove the device from pci_device_list */
-	if (rte_eal_pci_detach(&freed_addr))
-		goto err;
-
-	*addr = freed_addr;
-	return 0;
-err:
-	return -1;
-}
-
-/* attach the new virtual device, then store port_id of the device */
-static int
-rte_eth_dev_attach_vdev(const char *vdevargs, uint8_t *port_id)
-{
-	char *name = NULL, *args = NULL;
-	int ret = -1;
-
-	/* parse vdevargs, then retrieve device name and args */
-	if (rte_eal_parse_devargs_str(vdevargs, &name, &args))
-		goto end;
-
-	/* walk around dev_driver_list to find the driver of the device,
-	 * then invoke probe function of the driver.
-	 * rte_eal_vdev_init() updates port_id allocated after
-	 * initialization.
-	 */
-	if (rte_eal_vdev_init(name, args))
-		goto end;
-
-	if (rte_eth_dev_get_port_by_name(name, port_id))
-		goto end;
-
-	ret = 0;
-end:
-	free(name);
-	free(args);
-
-	return ret;
-}
-
-/* detach the new virtual device, then store the name of the device */
-static int
-rte_eth_dev_detach_vdev(uint8_t port_id, char *vdevname)
-{
-	char name[RTE_ETH_NAME_MAX_LEN];
-
-	/* get device name by port id */
-	if (rte_eth_dev_get_name_by_port(port_id, name))
-		goto err;
-	/* walk around dev_driver_list to find the driver of the device,
-	 * then invoke uninit function of the driver */
-	if (rte_eal_vdev_uninit(name))
-		goto err;
-
-	strncpy(vdevname, name, sizeof(name));
-	return 0;
-err:
-	return -1;
-}
-
 /* attach the new device, then store port_id of the device */
 int
 rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
+	int current = eth_dev_last_created_port;
+	char *name = NULL;
+	char *args = NULL;
 
 	if ((devargs == NULL) || (port_id == NULL)) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	if (eal_parse_pci_DomBDF(devargs, &addr) == 0) {
-		ret = rte_eth_dev_attach_pdev(&addr, port_id);
-		if (ret < 0)
-			goto err;
-	} else {
-		ret = rte_eth_dev_attach_vdev(devargs, port_id);
-		if (ret < 0)
-			goto err;
+	/* parse devargs, then retrieve device name and args */
+	if (rte_eal_parse_devargs_str(devargs, &name, &args))
+		goto err;
+
+	ret = rte_eal_dev_attach(name, args);
+	if (ret < 0)
+		goto err;
+
+	/* no point looking at eth_dev_last_created_port if no port exists */
+	if (!nb_ports) {
+		ret = -1;
+		goto err;
+	}
+	/* if nothing happened, there is a bug here, since some driver told us
+	 * it did attach a device, but did not create a port */
+	if (current == eth_dev_last_created_port) {
+		ret = -1;
+		goto err;
 	}
+	*port_id = eth_dev_last_created_port;
+	ret = 0;
 
-	return 0;
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n");
+	free(name);
+	free(args);
 	return ret;
 }
 
@@ -590,7 +464,6 @@ err:
 int
 rte_eth_dev_detach(uint8_t port_id, char *name)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
 
 	if (name == NULL) {
@@ -598,33 +471,19 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
 		goto err;
 	}
 
-	/* check whether the driver supports detach feature, or not */
+	/* FIXME: move this to eal, once device flags are relocated there */
 	if (rte_eth_dev_is_detachable(port_id))
 		goto err;
 
-	if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {
-		ret = rte_eth_dev_get_addr_by_port(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		ret = rte_eth_dev_detach_pdev(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		snprintf(name, RTE_ETH_NAME_MAX_LEN,
-			"%04x:%02x:%02x.%d",
-			addr.domain, addr.bus,
-			addr.devid, addr.function);
-	} else {
-		ret = rte_eth_dev_detach_vdev(port_id, name);
-		if (ret < 0)
-			goto err;
-	}
+	snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
+		 "%s", rte_eth_devices[port_id].data->name);
+	ret = rte_eal_dev_detach(name);
+	if (ret < 0)
+		goto err;
 
 	return 0;
 
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n");
 	return ret;
 }
 
Signature · 1 line
2.7.4
#126 lore raw

PATCH v5 17/17 ethdev: get rid of device type

In reply to Shreyansh Jain

Now that hotplug has been moved to eal, there is no reason to keep the device type in this layer.

---
 app/test/virtual_pmd.c                    |  2 +-
 drivers/net/af_packet/rte_eth_af_packet.c |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c    |  2 +-
 drivers/net/cxgbe/cxgbe_main.c            |  2 +-
 drivers/net/mlx4/mlx4.c                   |  2 +-
 drivers/net/mlx5/mlx5.c                   |  2 +-
 drivers/net/mpipe/mpipe_tilegx.c          |  2 +-
 drivers/net/null/rte_eth_null.c           |  2 +-
 drivers/net/pcap/rte_eth_pcap.c           |  2 +-
 drivers/net/ring/rte_eth_ring.c           |  2 +-
 drivers/net/vhost/rte_eth_vhost.c         |  2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |  2 +-
 examples/ip_pipeline/init.c               | 22 ----------------------
 lib/librte_ether/rte_ethdev.c             |  5 ++---
 lib/librte_ether/rte_ethdev.h             | 15 +--------------
 15 files changed, 15 insertions(+), 51 deletions(-)
app/test/virtual_pmd.c +1 -1
index b4bd2f2..8a1f0d0 100644
@@ -581,7 +581,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 		goto err;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto err;
 
drivers/net/af_packet/rte_eth_af_packet.c +1 -1
index f17bd7e..36ac102 100644
@@ -648,7 +648,7 @@ rte_pmd_init_internals(const char *name,
 	}
 
 	/* reserve an ethdev entry */
-	*eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	*eth_dev = rte_eth_dev_allocate(name);
 	if (*eth_dev == NULL)
 		goto error;
 
drivers/net/bonding/rte_eth_bond_api.c +1 -1
index 53df9fe..b858ee1 100644
@@ -189,7 +189,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	}
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
 		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
drivers/net/cxgbe/cxgbe_main.c +1 -1
index ceaf5ab..922155b 100644
@@ -1150,7 +1150,7 @@ int cxgbe_probe(struct adapter *adapter)
 		 */
 
 		/* reserve an ethdev entry */
-		pi->eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+		pi->eth_dev = rte_eth_dev_allocate(name);
 		if (!pi->eth_dev)
 			goto out_free;
 
drivers/net/mlx4/mlx4.c +1 -1
index b594433..ba42c33 100644
@@ -5715,7 +5715,7 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
 			snprintf(name, sizeof(name), "%s port %u",
 				 ibv_get_device_name(ibv_dev), port);
-			eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+			eth_dev = rte_eth_dev_allocate(name);
 		}
 		if (eth_dev == NULL) {
 			ERROR("can not allocate rte ethdev");
drivers/net/mlx5/mlx5.c +1 -1
index 1989a37..f6399fc 100644
@@ -519,7 +519,7 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
 			snprintf(name, sizeof(name), "%s port %u",
 				 ibv_get_device_name(ibv_dev), port);
-			eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+			eth_dev = rte_eth_dev_allocate(name);
 		}
 		if (eth_dev == NULL) {
 			ERROR("can not allocate rte ethdev");
drivers/net/mpipe/mpipe_tilegx.c +1 -1
index 26e1424..9de556e 100644
@@ -1587,7 +1587,7 @@ rte_pmd_mpipe_devinit(const char *ifname,
 		return -ENODEV;
 	}
 
-	eth_dev = rte_eth_dev_allocate(ifname, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(ifname);
 	if (!eth_dev) {
 		RTE_LOG(ERR, PMD, "%s: Failed to allocate device.\n", ifname);
 		rte_free(priv);
drivers/net/null/rte_eth_null.c +1 -1
index 5e8e203..e6c74a6 100644
@@ -514,7 +514,7 @@ eth_dev_null_create(const char *name,
 		goto error;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto error;
 
drivers/net/pcap/rte_eth_pcap.c +1 -1
index c98e234..2d00d04 100644
@@ -822,7 +822,7 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 		goto error;
 
 	/* reserve an ethdev entry */
-	*eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	*eth_dev = rte_eth_dev_allocate(name);
 	if (*eth_dev == NULL)
 		goto error;
 
drivers/net/ring/rte_eth_ring.c +1 -1
index b1783c3..b78d1cf 100644
@@ -303,7 +303,7 @@ do_eth_dev_ring_create(const char *name,
 	}
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
 		rte_errno = ENOSPC;
 		goto error;
drivers/net/vhost/rte_eth_vhost.c +1 -1
index 310cbef..4e99360 100644
@@ -717,7 +717,7 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
 		goto error;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto error;
 
drivers/net/xenvirt/rte_eth_xenvirt.c +1 -1
index 1adeb5b..72861d8 100644
@@ -651,7 +651,7 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 		goto err;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto err;
 
examples/ip_pipeline/init.c +0 -22
index cd167f6..0dbc332 100644
@@ -606,29 +606,12 @@ app_link_set_tcp_syn_filter(struct app_params *app, struct app_link_params *cp)
 	}
 }
 
-static int
-app_link_is_virtual(struct app_link_params *p)
-{
-	uint32_t pmd_id = p->pmd_id;
-	struct rte_eth_dev *dev = &rte_eth_devices[pmd_id];
-
-	if (dev->dev_type == RTE_ETH_DEV_VIRTUAL)
-		return 1;
-
-	return 0;
-}
-
 void
 app_link_up_internal(struct app_params *app, struct app_link_params *cp)
 {
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 1;
-		return;
-	}
-
 	/* For each link, add filters for IP of current link */
 	if (cp->ip != 0) {
 		for (i = 0; i < app->n_links; i++) {
@@ -736,11 +719,6 @@ app_link_down_internal(struct app_params *app, struct app_link_params *cp)
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 0;
-		return;
-	}
-
 	/* PMD link down */
 	status = rte_eth_dev_set_link_down(cp->pmd_id);
 	if (status < 0)
lib/librte_ether/rte_ethdev.c +2 -3
index 10e81e1..48c7254 100644
@@ -191,7 +191,7 @@ rte_eth_dev_find_free_port(void)
 }
 
 struct rte_eth_dev *
-rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
+rte_eth_dev_allocate(const char *name)
 {
 	uint8_t port_id;
 	struct rte_eth_dev *eth_dev;
@@ -216,7 +216,6 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
 	eth_dev->data->port_id = port_id;
 	eth_dev->attached = DEV_ATTACHED;
-	eth_dev->dev_type = type;
 	eth_dev_last_created_port = port_id;
 	nb_ports++;
 	return eth_dev;
@@ -248,7 +247,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
 	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
 			sizeof(ethdev_name));
 
-	eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
+	eth_dev = rte_eth_dev_allocate(ethdev_name);
 	if (eth_dev == NULL)
 		return -ENOMEM;
 
lib/librte_ether/rte_ethdev.h +1 -14
index ffd24e4..921dfa0 100644
@@ -1594,17 +1594,6 @@ struct rte_eth_rxtx_callback {
 };
 
 /**
- * The eth device type.
- */
-enum rte_eth_dev_type {
-	RTE_ETH_DEV_UNKNOWN,	/**< unknown device type */
-	RTE_ETH_DEV_PCI,
-		/**< Physical function and Virtual function of PCI devices */
-	RTE_ETH_DEV_VIRTUAL,	/**< non hardware device */
-	RTE_ETH_DEV_MAX		/**< max value of this enum */
-};
-
-/**
  * @internal
  * The generic data structure associated with each ethernet device.
  *
@@ -1634,7 +1623,6 @@ struct rte_eth_dev {
 	 */
 	struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
 	uint8_t attached; /**< Flag indicating the port is attached */
-	enum rte_eth_dev_type dev_type; /**< Flag indicating the device type */
 };
 
 struct rte_eth_dev_sriov {
@@ -1747,8 +1735,7 @@ struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(const char *name,
-		enum rte_eth_dev_type type);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
 
 /**
  * @internal
Signature · 1 line
2.7.4
#127 lore raw

v6 cover Prepare for rte_device / rte_driver

In reply to Shreyansh Jain

* Original patch series is from David Marchand [1], [2].
* Link with patch series [4] from Jan Viktorin for a more complete picture of proposed EAL device heirarchy changes.
* This might not be in-sync with pmdinfogen as PMD_REGISTER_DRIVER is removed [7].

David created the original patchset based on the discussions on list [3]. Being a large piece of work, this patchset introduces first level of changes for generalizing the driver-device relationship for supporting hotplug.

This patchset is based on master (11c5e45d8)

Overview of this work as per David [3], as well as notes from Thomas, Jan:
- pdev -> PCI registeration using helpers (introduced in this series)
- removal of eth/crypto driver registeration callbacks. These are now handled by PCI registeration helpers (this patch)
- rte_device=>pci/vdev device heirarchy (by this [4] series)
- removal of PMD_PDEV type (this patch) and PMD_VDEV (by this [4] series)
- Support for hotplugging

In [5], Neil had NACK'd previous series due to removal of symbol from map file without proper process. I continue with the same patch in this series as I was not clear after Thomas's reponse [6] whether it is OK to remove these (rte_cryptodev_pmd_driver_register, rte_eth_driver_register) or not - probably some procedure of deprecation that I am skipping.

Changes since v5:
- Rebase over master (11c5e45d8)
- Rename RTE_EAL_PCI_REGISTER helper macro to DRIVER_REGISTER_PCI to be in sync with DRIVER_REGISTER_PCI_TABLE. [Probably, in future, both can be merged]
- Modifications to bnxt and thunderx driver PMD registeration files for using the simplified PCI device registeration helper macro

Changes since v4:
- Fix compilation issue after rebase on HEAD (913154e) in previous series
- Retain rte_eth_dev_get_port_by_name and rte_eth_dev_get_name_by_port which were removed by previous patchset. These are being used by pdump library

Changes since v3:
- rebase over HEAD (913154e)
- Update arguments to RTE_EAL_PCI_REGISTER macro as per Jan's suggestion
- modify qede driver to use RTE_EAL_PCI_REGISTER
- Argument check in hotplug functions

Changes since v2:
- rebase over HEAD (d76c193)
- Move SYSFS_PCI_DRIVERS macro to rte_pci.h to avoid compilation issue

Changes since v1:
- rebased on HEAD, new drivers should be okay
- patches have been split into smaller pieces
- RTE_INIT macro has been added, but in the end, I am not sure it is useful
- device type has been removed from ethdev, as it was used only by hotplug
- getting rid of pmd type in eal patch (patch 5 of initial series) has been dropped for now, we can do this once vdev drivers have been converted

[1] http://dpdk.org/ml/archives/dev/2016-January/032387.html
[2] http://dpdk.org/ml/archives/dev/2016-April/037686.html
[3] http://dpdk.org/ml/archives/dev/2016-January/031390.html
[4] http://dpdk.org/ml/archives/dev/2016-July/043645.html
[5] http://dpdk.org/ml/archives/dev/2016-June/042439.html
[6] http://dpdk.org/ml/archives/dev/2016-June/042444.html
[7] http://dpdk.org/ml/archives/dev/2016-July/043172.html

David Marchand, Shreyansh Jain (17):
pci: no need for dynamic tailq init
crypto: no need for a crypto pmd type
drivers: align pci driver definitions
eal: remove duplicate function declaration
eal: introduce init macros
crypto: export init/uninit common wrappers for pci drivers
ethdev: export init/uninit common wrappers for pci drivers
drivers: convert all pdev drivers as pci drivers
crypto: get rid of crypto driver register callback
ethdev: get rid of eth driver register callback eal/linux: move back interrupt thread init before setting affinity
pci: add a helper for device name
pci: add a helper to update a device
ethdev: do not scan all pci devices on attach
eal: add hotplug operations for pci and vdev
ethdev: convert to eal hotplug
ethdev: get rid of device type

 app/test/virtual_pmd.c                          |   2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c          |  18 +-
 drivers/net/af_packet/rte_eth_af_packet.c       |   2 +-
 drivers/net/bnx2x/bnx2x_ethdev.c                |  34 +--
 drivers/net/bnxt/bnxt_ethdev.c                  |  16 +-
 drivers/net/bonding/rte_eth_bond_api.c          |   2 +-
 drivers/net/cxgbe/cxgbe_ethdev.c                |  24 +--
 drivers/net/cxgbe/cxgbe_main.c                  |   2 +-
 drivers/net/e1000/em_ethdev.c                   |  16 +-
 drivers/net/e1000/igb_ethdev.c                  |  39 +---
 drivers/net/ena/ena_ethdev.c                    |  19 +-
 drivers/net/enic/enic_ethdev.c                  |  23 +-
 drivers/net/fm10k/fm10k_ethdev.c                |  23 +-
 drivers/net/i40e/i40e_ethdev.c                  |  24 +--
 drivers/net/i40e/i40e_ethdev_vf.c               |  25 +--
 drivers/net/ixgbe/ixgbe_ethdev.c                |  46 +---
 drivers/net/mlx4/mlx4.c                         |  17 +-
 drivers/net/mlx5/mlx5.c                         |  16 +-
 drivers/net/mpipe/mpipe_tilegx.c                |   2 +-
 drivers/net/nfp/nfp_net.c                       |  23 +-
 drivers/net/null/rte_eth_null.c                 |   2 +-
 drivers/net/pcap/rte_eth_pcap.c                 |   2 +-
 drivers/net/qede/qede_ethdev.c                  |  40 +---
 drivers/net/ring/rte_eth_ring.c                 |   2 +-
 drivers/net/szedata2/rte_eth_szedata2.c         |  24 +--
 drivers/net/thunderx/nicvf_ethdev.c             |  20 +-
 drivers/net/vhost/rte_eth_vhost.c               |   2 +-
 drivers/net/virtio/virtio_ethdev.c              |  25 +--
 drivers/net/virtio/virtio_user_ethdev.c         |   2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c            |  23 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c           |   2 +-
 examples/ip_pipeline/init.c                     |  22 --
 lib/librte_cryptodev/rte_cryptodev.c            |  67 ++----
 lib/librte_cryptodev/rte_cryptodev.h            |   2 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h        |  45 ++--
 lib/librte_cryptodev/rte_cryptodev_version.map  |   3 +-
 lib/librte_eal/bsdapp/eal/eal_pci.c             |  52 ++++-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   2 +
 lib/librte_eal/common/eal_common_dev.c          |  47 ++++
 lib/librte_eal/common/eal_common_pci.c          |  19 +-
 lib/librte_eal/common/eal_private.h             |  20 +-
 lib/librte_eal/common/include/rte_dev.h         |  29 ++-
 lib/librte_eal/common/include/rte_eal.h         |   3 +
 lib/librte_eal/common/include/rte_pci.h         |  36 ++++
 lib/librte_eal/common/include/rte_tailq.h       |   4 +-
 lib/librte_eal/linuxapp/eal/eal.c               |   7 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c           |  16 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   2 +
 lib/librte_ether/rte_ethdev.c                   | 271 ++++--------------------
 lib/librte_ether/rte_ethdev.h                   |  40 ++--
 lib/librte_ether/rte_ether_version.map          |   4 +-
 51 files changed, 392 insertions(+), 816 deletions(-)
Signature · 1 line
2.7.4
#128 lore raw

PATCH v6 1/17 pci: no need for dynamic tailq init

These lists can be initialized once and for all at build time. With this, those lists are only manipulated in a common place (and we could even make them private).

A nice side effect is that pci drivers can now register in constructors.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c    | 3 ---
 lib/librte_eal/common/eal_common_pci.c | 6 ++++--
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 3 ---
 3 files changed, 4 insertions(+), 8 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +0 -3
index 374b68f..a73cbb0 100644
@@ -623,9 +623,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 int
 rte_eal_pci_init(void)
 {
-	TAILQ_INIT(&pci_driver_list);
-	TAILQ_INIT(&pci_device_list);
-
 	/* for debug purposes, PCI can be disabled */
 	if (internal_config.no_pci)
 		return 0;
lib/librte_eal/common/eal_common_pci.c +4 -2
index 7248c38..6a0f6ac 100644
@@ -82,8 +82,10 @@
 
 #include "eal_private.h"
 
-struct pci_driver_list pci_driver_list;
-struct pci_device_list pci_device_list;
+struct pci_driver_list pci_driver_list =
+	TAILQ_HEAD_INITIALIZER(pci_driver_list);
+struct pci_device_list pci_device_list =
+	TAILQ_HEAD_INITIALIZER(pci_device_list);
 
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 
lib/librte_eal/linuxapp/eal/eal_pci.c +0 -3
index cd9de7c..f0215ee 100644
@@ -743,9 +743,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 int
 rte_eal_pci_init(void)
 {
-	TAILQ_INIT(&pci_driver_list);
-	TAILQ_INIT(&pci_device_list);
-
 	/* for debug purposes, PCI can be disabled */
 	if (internal_config.no_pci)
 		return 0;
Signature · 1 line
2.7.4
Tested-by on v6 1/17
#129 lore raw

Re: [PATCH v6 01/17] pci: no need for dynamic tailq init

Quoted 10 lines · On Tue, 12 Jul 2016 11:31:06 +0530 Shreyansh Jain <[email protected]>…

These lists can be initialized once and for all at build time. With this, those lists are only manipulated in a common place (and we could even make them private).

A nice side effect is that pci drivers can now register in constructors.

---

#130 lore raw

PATCH v6 2/17 crypto: no need for a crypto pmd type

In reply to Shreyansh Jain

This information is not used and just adds noise.

---
 lib/librte_cryptodev/rte_cryptodev.c     | 8 +++-----
 lib/librte_cryptodev/rte_cryptodev.h     | 2 --
 lib/librte_cryptodev/rte_cryptodev_pmd.h | 3 +--
 3 files changed, 4 insertions(+), 9 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +3 -5
index 20e5beb..c3cc3e9 100644
@@ -321,7 +321,7 @@ rte_cryptodev_find_free_device_index(void)
 }
 
 struct rte_cryptodev *
-rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id)
+rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 {
 	struct rte_cryptodev *cryptodev;
 	uint8_t dev_id;
@@ -360,7 +360,6 @@ rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id)
 		cryptodev->data->dev_started = 0;
 
 		cryptodev->attached = RTE_CRYPTODEV_ATTACHED;
-		cryptodev->pmd_type = type;
 
 		cryptodev_globals.nb_devs++;
 	}
@@ -409,7 +408,7 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 	struct rte_cryptodev *cryptodev;
 
 	/* allocate device structure */
-	cryptodev = rte_cryptodev_pmd_allocate(name, PMD_VDEV, socket_id);
+	cryptodev = rte_cryptodev_pmd_allocate(name, socket_id);
 	if (cryptodev == NULL)
 		return NULL;
 
@@ -451,8 +450,7 @@ rte_cryptodev_init(struct rte_pci_driver *pci_drv,
 	rte_cryptodev_create_unique_device_name(cryptodev_name,
 			sizeof(cryptodev_name), pci_dev);
 
-	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, PMD_PDEV,
-			rte_socket_id());
+	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 	if (cryptodev == NULL)
 		return -ENOMEM;
 
lib/librte_cryptodev/rte_cryptodev.h +0 -2
index affbdec..13f46e4 100644
@@ -613,8 +613,6 @@ struct rte_cryptodev {
 
 	enum rte_cryptodev_type dev_type;
 	/**< Crypto device type */
-	enum pmd_type pmd_type;
-	/**< PMD type - PDEV / VDEV */
 
 	struct rte_cryptodev_cb_list link_intr_cbs;
 	/**< User application callback for interrupts if present */
lib/librte_cryptodev/rte_cryptodev_pmd.h +1 -2
index 7d049ea..c977c61 100644
@@ -454,13 +454,12 @@ struct rte_cryptodev_ops {
  * to that slot for the driver to use.
  *
  * @param	name		Unique identifier name for each device
- * @param	type		Device type of this Crypto device
  * @param	socket_id	Socket to allocate resources on.
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
 struct rte_cryptodev *
-rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id);
+rte_cryptodev_pmd_allocate(const char *name, int socket_id);
 
 /**
  * Creates a new virtual crypto device and returns the pointer
Signature · 1 line
2.7.4
#132 lore raw

PATCH v6 3/17 drivers: align pci driver definitions

In reply to Shreyansh Jain

Pure coding style, but it might make it easier later if we want to move fields in rte_cryptodev_driver and eth_driver structures.

---
 drivers/crypto/qat/rte_qat_cryptodev.c | 2 +-
 drivers/net/ena/ena_ethdev.c           | 2 +-
 drivers/net/nfp/nfp_net.c              | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/qat/rte_qat_cryptodev.c +1 -1
index 82ab047..1e9e0ba 100644
@@ -113,7 +113,7 @@ crypto_qat_dev_init(__attribute__((unused)) struct rte_cryptodev_driver *crypto_
 }
 
 static struct rte_cryptodev_driver rte_qat_pmd = {
-	{
+	.pci_drv = {
 		.id_table = pci_id_qat_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 	},
drivers/net/ena/ena_ethdev.c +1 -1
index ac0803d..9418d50 100644
@@ -1685,7 +1685,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 }
 
 static struct eth_driver rte_ena_pmd = {
-	{
+	.pci_drv = {
 		.name = "rte_ena_pmd",
 		.id_table = pci_id_ena_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
drivers/net/nfp/nfp_net.c +1 -1
index 82e3e4e..99a258a 100644
@@ -2459,7 +2459,7 @@ static struct rte_pci_id pci_id_nfp_net_map[] = {
 };
 
 static struct eth_driver rte_nfp_net_pmd = {
-	{
+	.pci_drv = {
 		.name = "rte_nfp_net_pmd",
 		.id_table = pci_id_nfp_net_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
Signature · 1 line
2.7.4
Reviewed-by on v6 3/17
#133 lore raw

Re: [PATCH v6 03/17] drivers: align pci driver definitions

Quoted 6 lines · On Tue, 12 Jul 2016 11:31:08 +0530 Shreyansh Jain <[email protected]>…

Pure coding style, but it might make it easier later if we want to move fields in rte_cryptodev_driver and eth_driver structures.

---

#134 lore raw

PATCH v6 4/17 eal: remove duplicate function declaration

In reply to Shreyansh Jain

rte_eal_dev_init is declared in both eal_private.h and rte_dev.h since its introduction.
This function has been exported in ABI, so remove it from eal_private.h

Fixes e57f20e05177 ("eal: make vdev init path generic for both virtual and pci devices")
---
 lib/librte_eal/common/eal_private.h | 7 -------
 lib/librte_eal/linuxapp/eal/eal.c   | 1 +
 2 files changed, 1 insertion(+), 7 deletions(-)
lib/librte_eal/common/eal_private.h +0 -7
index 857dc3e..06a68f6 100644
@@ -259,13 +259,6 @@ int rte_eal_intr_init(void);
 int rte_eal_alarm_init(void);
 
 /**
- * This function initialises any virtual devices
- *
- * This function is private to the EAL.
- */
-int rte_eal_dev_init(void);
-
-/**
  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
  * etc.) loaded.
  *
lib/librte_eal/linuxapp/eal/eal.c +1 -0
index 3fb2188..fe9c704 100644
@@ -70,6 +70,7 @@
 #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>
Signature · 1 line
2.7.4
Reviewed-by on v6 4/17
#135 lore raw

Re: [PATCH v6 04/17] eal: remove duplicate function declaration

Quoted 8 lines · On Tue, 12 Jul 2016 11:31:09 +0530 Shreyansh Jain <[email protected]>…

rte_eal_dev_init is declared in both eal_private.h and rte_dev.h since its introduction.
This function has been exported in ABI, so remove it from eal_private.h

Fixes e57f20e05177 ("eal: make vdev init path generic for both virtual and pci devices")

---

#136 lore raw

PATCH v6 5/17 eal: introduce init macros

In reply to Shreyansh Jain

Introduce a RTE_INIT macro used to mark an init function as a constructor. Current eal macros have been converted to use this (no functional impact). DRIVER_REGISTER_PCI is added as a helper for pci drivers.

---
 lib/librte_eal/common/include/rte_dev.h   | 4 ++--
 lib/librte_eal/common/include/rte_eal.h   | 3 +++
 lib/librte_eal/common/include/rte_pci.h   | 8 ++++++++
 lib/librte_eal/common/include/rte_tailq.h | 4 ++--
 4 files changed, 15 insertions(+), 4 deletions(-)
lib/librte_eal/common/include/rte_dev.h +2 -2
index 95789f9..994650b 100644
@@ -185,8 +185,8 @@ static const char DRIVER_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
 __attribute__((used)) = RTE_STR(name)
 
 #define PMD_REGISTER_DRIVER(drv, nm)\
-void devinitfn_ ##drv(void);\
-void __attribute__((constructor, used)) devinitfn_ ##drv(void)\
+RTE_INIT(devinitfn_ ##drv);\
+static void devinitfn_ ##drv(void)\
 {\
 	(drv).name = RTE_STR(nm);\
 	rte_eal_driver_register(&drv);\
lib/librte_eal/common/include/rte_eal.h +3 -0
index a71d6f5..186f3c6 100644
@@ -252,6 +252,9 @@ static inline int rte_gettid(void)
 	return RTE_PER_LCORE(_thread_id);
 }
 
+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_pci.h +8 -0
index fa74962..3027adf 100644
@@ -470,6 +470,14 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registeration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{ \
+	rte_eal_pci_register(&drv.pci_drv); \
+}
+
 /**
  * Unregister a PCI driver.
  *
lib/librte_eal/common/include/rte_tailq.h +2 -2
index 4a686e6..71ed3bb 100644
@@ -148,8 +148,8 @@ struct rte_tailq_head *rte_eal_tailq_lookup(const char *name);
 int rte_eal_tailq_register(struct rte_tailq_elem *t);
 
 #define EAL_REGISTER_TAILQ(t) \
-void tailqinitfn_ ##t(void); \
-void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \
+RTE_INIT(tailqinitfn_ ##t); \
+static void tailqinitfn_ ##t(void) \
 { \
 	if (rte_eal_tailq_register(&t) < 0) \
 		rte_panic("Cannot initialize tailq: %s\n", t.name); \
Signature · 1 line
2.7.4
#137 lore raw

Re: [PATCH v6 05/17] eal: introduce init macros

Hello Shreyansh,

Quoted 8 lines · On Tue, 12 Jul 2016 11:31:10 +0530 Shreyansh Jain <[email protected]>…

Introduce a RTE_INIT macro used to mark an init function as a constructor. Current eal macros have been converted to use this (no functional impact). DRIVER_REGISTER_PCI is added as a helper for pci drivers.

---

[...]

Quoted 11 lines
lib/librte_eal/common/include/rte_eal.h +3 -0
+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_pci.h +0 -0
index fa74962..3027adf 100644

lib/librte_eal/common/include/rte_pci.h void rte_eal_pci_dump(FILE *f); · line 477

Quoted 8 lines
lib/librte_eal/common/include/rte_pci.h +5 -0
@@ -470,6 +470,14 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registeration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{ \

You are missing setting the name here like PMD_REGISTER_DRIVER does now. Or should I include it in my patch set?

	(drv).name = RTE_STR(nm);
Quoted 21 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
+	rte_eal_pci_register(&drv.pci_drv); \
+}
+
 /**
  * Unregister a PCI driver.
  *
lib/librte_eal/common/include/rte_tailq.h +2 -2
index 4a686e6..71ed3bb 100644
@@ -148,8 +148,8 @@ struct rte_tailq_head *rte_eal_tailq_lookup(const char *name);
 int rte_eal_tailq_register(struct rte_tailq_elem *t);
 
 #define EAL_REGISTER_TAILQ(t) \
-void tailqinitfn_ ##t(void); \
-void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \
+RTE_INIT(tailqinitfn_ ##t); \
+static void tailqinitfn_ ##t(void) \
 { \
 	if (rte_eal_tailq_register(&t) < 0) \
 		rte_panic("Cannot initialize tailq: %s\n", t.name); \
Signature · 4 lines
  Jan Viktorin                E-mail: [email protected]
  System Architect            Web:    www.RehiveTech.com
  RehiveTech
  Brno, Czech Republic
#138 lore raw

Re: [PATCH v6 05/17] eal: introduce init macros

Quoted 39 lines · On Wed, 13 Jul 2016 11:20:43 +0200 Jan Viktorin <[email protected]> wrote:

Hello Shreyansh,

Quoted 8 lines · On Tue, 12 Jul 2016 11:31:10 +0530 Shreyansh Jain <[email protected]>…

Introduce a RTE_INIT macro used to mark an init function as a constructor. Current eal macros have been converted to use this (no functional impact). DRIVER_REGISTER_PCI is added as a helper for pci drivers.

---

[...]

Quoted 11 lines
lib/librte_eal/common/include/rte_eal.h +3 -0
+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_pci.h +0 -0
index fa74962..3027adf 100644

lib/librte_eal/common/include/rte_pci.h void rte_eal_pci_dump(FILE *f); · line 477

Quoted 8 lines
lib/librte_eal/common/include/rte_pci.h +5 -0
@@ -470,6 +470,14 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registeration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{ \  

You are missing setting the name here like PMD_REGISTER_DRIVER does now. Or should I include it in my patch set?

Quoted 1 line
	(drv).name = RTE_STR(nm);

Moreover, it should accept the rte_pci_driver *, shouldn't it? Here, it expects a wrapper around it (eth_driver)... I now, my SoC patches were supposing the some... but I think it is wrong.

The original David's patch set contains calls like this:

  RTE_EAL_PCI_REGISTER(bnx2xvf, rte_bnx2xvf_pmd.pci_drv);

So, I think, we should go the original way.

Jan

Quoted 25 lines
Quoted 22 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
+	rte_eal_pci_register(&drv.pci_drv); \
+}
+
 /**
  * Unregister a PCI driver.
  *
lib/librte_eal/common/include/rte_tailq.h +2 -2
index 4a686e6..71ed3bb 100644
@@ -148,8 +148,8 @@ struct rte_tailq_head *rte_eal_tailq_lookup(const char *name);
 int rte_eal_tailq_register(struct rte_tailq_elem *t);
 
 #define EAL_REGISTER_TAILQ(t) \
-void tailqinitfn_ ##t(void); \
-void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \
+RTE_INIT(tailqinitfn_ ##t); \
+static void tailqinitfn_ ##t(void) \
 { \
 	if (rte_eal_tailq_register(&t) < 0) \
 		rte_panic("Cannot initialize tailq: %s\n", t.name); \  
Signature · 4 lines
  Jan Viktorin                E-mail: [email protected]
  System Architect            Web:    www.RehiveTech.com
  RehiveTech
  Brno, Czech Republic
#139 lore raw

Re: [PATCH v6 05/17] eal: introduce init macros

Hi Jan,

Quoted 42 lines · Jan Viktorin
Quoted 39 lines · On Wed, 13 Jul 2016 11:20:43 +0200 Jan Viktorin <[email protected]> wrote:

Hello Shreyansh,

Quoted 8 lines · On Tue, 12 Jul 2016 11:31:10 +0530 Shreyansh Jain <[email protected]>…

Introduce a RTE_INIT macro used to mark an init function as a constructor. Current eal macros have been converted to use this (no functional impact). DRIVER_REGISTER_PCI is added as a helper for pci drivers.

---

[...]

Quoted 11 lines
lib/librte_eal/common/include/rte_eal.h +3 -0
+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_pci.h +0 -0
index fa74962..3027adf 100644

lib/librte_eal/common/include/rte_pci.h void rte_eal_pci_dump(FILE *f); · line 477

Quoted 8 lines
lib/librte_eal/common/include/rte_pci.h +5 -0
@@ -470,6 +470,14 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registeration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{ \  

You are missing setting the name here like PMD_REGISTER_DRIVER does now. Or should I include it in my patch set?

Quoted 1 line
Quoted 1 line
	(drv).name = RTE_STR(nm);

That is a miss from my side.
I will publish v7 with this. You want this right away or should I wait a little while (more reviews, or any pending additions as per Thomas's notes) before publishing?

Quoted 10 lines

Moreover, it should accept the rte_pci_driver *, shouldn't it? Here, it expects a wrapper around it (eth_driver)... I now, my SoC patches were supposing the some... but I think it is wrong.

The original David's patch set contains calls like this:

  RTE_EAL_PCI_REGISTER(bnx2xvf, rte_bnx2xvf_pmd.pci_drv);

So, I think, we should go the original way.

I have a slightly different opinion of the above.
IMO, aim of the helpers is to hide the PCI details and continue to make driver consider itself as a generic ETH driver. In that case, dereferencing pci_drv would be done by macro.

Also, considering that in future pci_drv would also have soc_drv, the helpers can effectively hide the intra-structure naming of these. It would help when more such device types (would there be?) are introduced - in which case, driver framework has a consistent coding convention.

But, I am ok switching back to David's way as well - I don't have any strong argument against that.

Quoted 10 lines

Jan

Quoted 7 lines

lib/librte_eal/common/include/rte_pci.h void rte_eal_pci_dump(FILE *f); · line 483

Quoted 7 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
+	rte_eal_pci_register(&drv.pci_drv); \
+}
+
 /**
  * Unregister a PCI driver.
  *

[...]

-
Shreyansh

#140 lore raw

Re: [PATCH v6 05/17] eal: introduce init macros

Quoted 45 lines · On Thu, 14 Jul 2016 10:57:55 +0530 Shreyansh jain <[email protected]>…

Hi Jan,

Quoted 42 lines · Jan Viktorin
Quoted 39 lines · On Wed, 13 Jul 2016 11:20:43 +0200 Jan Viktorin <[email protected]> wrote:

Hello Shreyansh,

Quoted 8 lines · On Tue, 12 Jul 2016 11:31:10 +0530 Shreyansh Jain <[email protected]>…

Introduce a RTE_INIT macro used to mark an init function as a constructor. Current eal macros have been converted to use this (no functional impact). DRIVER_REGISTER_PCI is added as a helper for pci drivers.

---

[...]

Quoted 11 lines
lib/librte_eal/common/include/rte_eal.h +3 -0
+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_pci.h +0 -0
index fa74962..3027adf 100644

lib/librte_eal/common/include/rte_pci.h void rte_eal_pci_dump(FILE *f); · line 477

Quoted 8 lines
lib/librte_eal/common/include/rte_pci.h +5 -0
@@ -470,6 +470,14 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registeration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{ \    

You are missing setting the name here like PMD_REGISTER_DRIVER does now. Or should I include it in my patch set?

Quoted 4 lines
Quoted 1 line
Quoted 1 line
	(drv).name = RTE_STR(nm);  

That is a miss from my side.
I will publish v7 with this. You want this right away or should I wait a little while (more reviews, or any pending additions as per Thomas's notes) before publishing?

Please. The time is almost gone. 18/7/2016 is the release (according to the roadmap)... I have to fix it in my patchset, otherwise it does not build (after moving the .name from rte_pci_driver to rte_driver).

Quoted 6 lines
Quoted 6 lines

Moreover, it should accept the rte_pci_driver *, shouldn't it? Here, it expects a wrapper around it (eth_driver)... I now, my SoC patches were supposing the some... but I think it is wrong.

Quoted 8 lines
Quoted 5 lines

The original David's patch set contains calls like this:

  RTE_EAL_PCI_REGISTER(bnx2xvf, rte_bnx2xvf_pmd.pci_drv);

So, I think, we should go the original way.

I have a slightly different opinion of the above.
IMO, aim of the helpers is to hide the PCI details and continue to make driver consider itself as a generic ETH driver. In that case, dereferencing pci_drv would be done by macro.

In this case, I'd prefer to see DRIVER_REGISTER_PCI_ETH.

At first, this was also my way of thinking. But I've changed my mind. I find it to be a bit overdesigned.

Quoted 2 lines

Also, considering that in future pci_drv would also have soc_drv, the helpers can effectively hide the intra-structure naming of these. It would help when more such device types (would there be?) are introduced - in which case, driver framework has a consistent coding convention.

Hide? I am afraid, I don't understand clearly what you mean.

Quoted 2 lines

But, I am ok switching back to David's way as well - I don't have any strong argument against that.

I'd like to preserve the clear semantics. That is DRIVER_REGISTER_PCI -> give a pci device.

Has anybody a different opinion? David? Thomas?

Quoted 16 lines
Quoted 11 lines

Jan

Quoted 7 lines

lib/librte_eal/common/include/rte_pci.h void rte_eal_pci_dump(FILE *f); · line 483

Quoted 7 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
+	rte_eal_pci_register(&drv.pci_drv); \
+}
+
 /**
  * Unregister a PCI driver.
  *  

[...]

-
Shreyansh

Signature · 4 lines
  Jan Viktorin                E-mail: [email protected]
  System Architect            Web:    www.RehiveTech.com
  RehiveTech
  Brno, Czech Republic
#141 lore raw

Re: [PATCH v6 05/17] eal: introduce init macros

Quoted 50 lines · Jan Viktorin
Quoted 47 lines · On Thu, 14 Jul 2016 10:57:55 +0530 Shreyansh jain <[email protected]>…

Hi Jan,

Quoted 43 lines · Jan Viktorin
Quoted 40 lines · On Wed, 13 Jul 2016 11:20:43 +0200 Jan Viktorin <[email protected]> wrote:

Hello Shreyansh,

Quoted 8 lines · On Tue, 12 Jul 2016 11:31:10 +0530 Shreyansh Jain <[email protected]>…

Introduce a RTE_INIT macro used to mark an init function as a constructor. Current eal macros have been converted to use this (no functional impact). DRIVER_REGISTER_PCI is added as a helper for pci drivers.

---

[...]

Quoted 11 lines
lib/librte_eal/common/include/rte_eal.h +3 -0
+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_pci.h +0 -0
index fa74962..3027adf 100644

lib/librte_eal/common/include/rte_pci.h void rte_eal_pci_dump(FILE *f); · line 477

Quoted 8 lines
lib/librte_eal/common/include/rte_pci.h +5 -0
@@ -470,6 +470,14 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registeration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{ \    

You are missing setting the name here like PMD_REGISTER_DRIVER does now. Or should I include it in my patch set?

	(drv).name = RTE_STR(nm);  
Quoted 8 lines
Quoted 2 lines

That is a miss from my side.
I will publish v7 with this. You want this right away or should I wait a little while (more reviews, or any pending additions as per Thomas's notes) before publishing?

Please. The time is almost gone. 18/7/2016 is the release (according to the roadmap)... I have to fix it in my patchset, otherwise it does not build (after moving the .name from rte_pci_driver to rte_driver).

I didn't consider 18/Jul.
Please go ahead. I will continue to send v7 _without_ the above change so that your patchset doesn't break. This way you will not get blocked because of me.

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines

Moreover, it should accept the rte_pci_driver *, shouldn't it? Here, it expects a wrapper around it (eth_driver)... I now, my SoC patches were supposing the some... but I think it is wrong.

The original David's patch set contains calls like this:

  RTE_EAL_PCI_REGISTER(bnx2xvf, rte_bnx2xvf_pmd.pci_drv);

So, I think, we should go the original way.

Quoted 7 lines
Quoted 2 lines

I have a slightly different opinion of the above.
IMO, aim of the helpers is to hide the PCI details and continue to make driver consider itself as a generic ETH driver. In that case, dereferencing pci_drv would be done by macro.

In this case, I'd prefer to see DRIVER_REGISTER_PCI_ETH.

At first, this was also my way of thinking. But I've changed my mind. I find it to be a bit overdesigned.

There is:

DRIVER_REGISTER_PCI(...)
DRIVER_REGISTER_PCI_TABLE(...)

Wouldn't DRIVER_REGISTER_PCI_ETH look out-of-place?

Quoted 5 lines
Quoted 3 lines

Also, considering that in future pci_drv would also have soc_drv, the helpers can effectively hide the intra-structure naming of these. It would help when more such device types (would there be?) are introduced - in which case, driver framework has a consistent coding convention.

Hide? I am afraid, I don't understand clearly what you mean.

DRIVER_REGISTER_PCI(eth_driver)
DRIVER_REGISTER_SOC(eth_driver)
DRIVER_REGISTER_XXX(eth_driver)
...

In either case, the caller always creates the eth_driver and populates internal specific driver structure (pci_drv) as a sub-part of eth_driver specification. Macro 'hides' the internal structure name (pci_drv, soc_drv...). But again, nothing critical. Just a way of usage. We might not even have a 'XXX' in near future.

Quoted 8 lines
Quoted 3 lines

But, I am ok switching back to David's way as well - I don't have any strong argument against that.

I'd like to preserve the clear semantics. That is DRIVER_REGISTER_PCI -> give a pci device.

Has anybody a different opinion? David? Thomas?

Yes please.
Or else, if nothing comes up soon, I will simply go ahead and change to DRIVER_REGISTER_PCI(eth_driver.pci_drv) as this trivial issue shouldn't hold back this series.

Quoted 20 lines
Quoted 17 lines
Quoted 6 lines

Jan

Quoted 1 line
Quoted 6 lines
Quoted 6 lines

lib/librte_eal/common/include/rte_pci.h void rte_eal_pci_dump(FILE *f); · line 483

Quoted 6 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
+	rte_eal_pci_register(&drv.pci_drv); \
+}
+
 /**
  * Unregister a PCI driver.
  *  

[...]

-
Shreyansh

#142 lore raw

Re: [PATCH v6 05/17] eal: introduce init macros

Hi guys,

2016-07-15 16:18, Shreyansh jain:

Quoted 10 lines · Jan Viktorin
Quoted 4 lines

Please. The time is almost gone. 18/7/2016 is the release (according to the roadmap)... I have to fix it in my patchset, otherwise it does not build (after moving the .name from rte_pci_driver to rte_driver).

I didn't consider 18/Jul.
Please go ahead. I will continue to send v7 _without_ the above change so that your patchset doesn't break. This way you will not get blocked because of me.

[...]

Quoted 9 lines
Quoted 4 lines

I'd like to preserve the clear semantics. That is DRIVER_REGISTER_PCI -> give a pci device.

Has anybody a different opinion? David? Thomas?

Yes please.
Or else, if nothing comes up soon, I will simply go ahead and change to DRIVER_REGISTER_PCI(eth_driver.pci_drv) as this trivial issue shouldn't hold back this series.

I'm sorry I have no time to review these series shortly.

I think it is too late to consider an integration in 16.07 unfortunately. I feel you are doing a great job and we can target to have these changes in the early days of 16.11 (in August).
As this is a big refactoring, it is probably a good idea to integrate it in the beginning of the next release integration cycle.

#143 lore raw

Re: [PATCH v6 05/17] eal: introduce init macros

In reply to Shreyansh jain

Hi Jan,

Quoted 54 lines · Shreyansh jain
Quoted 53 lines · Jan Viktorin
Quoted 49 lines · On Thu, 14 Jul 2016 10:57:55 +0530 Shreyansh jain <[email protected]>…

Hi Jan,

Quoted 42 lines · Jan Viktorin
Quoted 39 lines · On Wed, 13 Jul 2016 11:20:43 +0200 Jan Viktorin <[email protected]> wrote:

Hello Shreyansh,

Quoted 8 lines · On Tue, 12 Jul 2016 11:31:10 +0530 Shreyansh Jain <[email protected]>…

Introduce a RTE_INIT macro used to mark an init function as a constructor. Current eal macros have been converted to use this (no functional impact). DRIVER_REGISTER_PCI is added as a helper for pci drivers.

---

[...]

Quoted 11 lines
lib/librte_eal/common/include/rte_eal.h +3 -0
+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_pci.h +0 -0
index fa74962..3027adf 100644

lib/librte_eal/common/include/rte_pci.h void rte_eal_pci_dump(FILE *f); · line 477

Quoted 8 lines
lib/librte_eal/common/include/rte_pci.h +5 -0
@@ -470,6 +470,14 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registeration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{ \    

You are missing setting the name here like PMD_REGISTER_DRIVER does now. Or should I include it in my patch set?

Quoted 1 line
Quoted 1 line
	(drv).name = RTE_STR(nm);  

That is a miss from my side.
I will publish v7 with this. You want this right away or should I wait a little while (more reviews, or any pending additions as per Thomas's notes) before publishing?

Quoted 9 lines
Quoted 5 lines

Please. The time is almost gone. 18/7/2016 is the release (according to the roadmap)... I have to fix it in my patchset, otherwise it does not build (after moving the .name from rte_pci_driver to rte_driver).

I didn't consider 18/Jul.
Please go ahead. I will continue to send v7 _without_ the above change so that your patchset doesn't break. This way you will not get blocked because of me.

Now that we have already skipped the 16.07, I will fix this in my code and release an updated version as soon as 16.07 is officially available. Is that OK?

Also, I have fixed most review comments except [1]. I am still not sure of the impact of this change. So, I will publish the v7 without this and then probably a v8 in case this change has any impact. That way we can have your patchset not blocked because of this series.

[1] http://dpdk.org/ml/archives/dev/2016-July/044004.html

[...]

-
Shreyansh

#144 lore raw

Re: [PATCH v6 05/17] eal: introduce init macros

Quoted 4 lines · On Thu, 28 Jul 2016 15:06:10 +0530 Shreyansh Jain <[email protected]>…

Hi Jan,

Quoted 1 line · Shreyansh jain

On Thursday 14 July 2016 09:27 PM, Jan Viktorin wrote:

[...]

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
	(drv).name = RTE_STR(nm);    

That is a miss from my side.
I will publish v7 with this. You want this right away or should I wait a little while (more reviews, or any pending additions as per Thomas's notes) before publishing?

Please. The time is almost gone. 18/7/2016 is the release (according to the roadmap)... I have to fix it in my patchset, otherwise it does not build (after moving the .name from rte_pci_driver to rte_driver).

Quoted 5 lines
Quoted 3 lines

I didn't consider 18/Jul.
Please go ahead. I will continue to send v7 _without_ the above change so that your patchset doesn't break. This way you will not get blocked because of me.

Now that we have already skipped the 16.07, I will fix this in my code and release an updated version as soon as 16.07 is officially available. Is that OK?

Sure :). The thing is that during August-September, I've got significantly less time for this then in June-July :/. That's why I was trying to fit in the 16.07.

Quoted 2 lines

Also, I have fixed most review comments except [1]. I am still not sure of the impact of this change. So, I will publish the v7 without this and then probably a v8 in case this change has any impact.

I have no idea about this. Hopefully, it's not a very serious thing.

Quoted 1 line

That way we can have your patchset not blocked because of this series.

Thank you!

Quoted 9 lines

[1] http://dpdk.org/ml/archives/dev/2016-July/044004.html

[...]

-
Shreyansh

Signature · 4 lines
  Jan Viktorin                E-mail: [email protected]
  System Architect            Web:    www.RehiveTech.com
  RehiveTech
  Brno, Czech Republic
#145 lore raw

Re: [PATCH v6 05/17] eal: introduce init macros

Hi Jan,

Quoted 25 lines · Jan Viktorin
Quoted 4 lines · On Thu, 28 Jul 2016 15:06:10 +0530 Shreyansh Jain <[email protected]>…

Hi Jan,

Quoted 1 line · Shreyansh jain

On Thursday 14 July 2016 09:27 PM, Jan Viktorin wrote:

[...]

Quoted 15 lines
Quoted 14 lines
Quoted 10 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
	(drv).name = RTE_STR(nm);    

That is a miss from my side.
I will publish v7 with this. You want this right away or should I wait a little while (more reviews, or any pending additions as per Thomas's notes) before publishing?

Please. The time is almost gone. 18/7/2016 is the release (according to the roadmap)... I have to fix it in my patchset, otherwise it does not build (after moving the .name from rte_pci_driver to rte_driver).

I didn't consider 18/Jul.
Please go ahead. I will continue to send v7 _without_ the above change so that your patchset doesn't break. This way you will not get blocked because of me.

Quoted 5 lines
Quoted 1 line

Now that we have already skipped the 16.07, I will fix this in my code and release an updated version as soon as 16.07 is officially available. Is that OK?

Sure :). The thing is that during August-September, I've got significantly less time for this then in June-July :/. That's why I was trying to fit in the 16.07.

Well, then lets try and get things out for review as soon as we can.
I have sent across v7 of rte_driver set.
Unfortunately, I forgot to add your sign-off. If the set works for you, can you bulk ack?

Quoted 22 lines
Quoted 3 lines

Also, I have fixed most review comments except [1]. I am still not sure of the impact of this change. So, I will publish the v7 without this and then probably a v8 in case this change has any impact.

I have no idea about this. Hopefully, it's not a very serious thing.

Quoted 1 line

That way we can have your patchset not blocked because of this series.

Thank you!

Quoted 9 lines

[1] http://dpdk.org/ml/archives/dev/2016-July/044004.html

[...]

-
Shreyansh

#146 lore raw

PATCH v6 6/17 crypto: export init/uninit common wrappers for pci drivers

In reply to Shreyansh Jain

Preparing for getting rid of rte_cryptodev_driver, here are two wrappers that can be used by pci drivers that assume a 1 to 1 association between pci resource and upper interface.

---
 lib/librte_cryptodev/rte_cryptodev.c           | 16 ++++++++--------
 lib/librte_cryptodev/rte_cryptodev_pmd.h       | 12 ++++++++++++
 lib/librte_cryptodev/rte_cryptodev_version.map |  2 ++
 3 files changed, 22 insertions(+), 8 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +8 -8
index c3cc3e9..3a75f2c 100644
@@ -431,9 +431,9 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 	return cryptodev;
 }
 
-static int
-rte_cryptodev_init(struct rte_pci_driver *pci_drv,
-		struct rte_pci_device *pci_dev)
+int
+rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
+			struct rte_pci_device *pci_dev)
 {
 	struct rte_cryptodev_driver *cryptodrv;
 	struct rte_cryptodev *cryptodev;
@@ -492,8 +492,8 @@ rte_cryptodev_init(struct rte_pci_driver *pci_drv,
 	return -ENXIO;
 }
 
-static int
-rte_cryptodev_uninit(struct rte_pci_device *pci_dev)
+int
+rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 {
 	const struct rte_cryptodev_driver *cryptodrv;
 	struct rte_cryptodev *cryptodev;
@@ -541,15 +541,15 @@ 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,
+		return rte_cryptodev_pci_probe((struct rte_pci_driver *)cryptodrv,
 				NULL);
 
 	/*
 	 * Register PCI driver for physical device intialisation during
 	 * PCI probing
 	 */
-	cryptodrv->pci_drv.devinit = rte_cryptodev_init;
-	cryptodrv->pci_drv.devuninit = rte_cryptodev_uninit;
+	cryptodrv->pci_drv.devinit = rte_cryptodev_pci_probe;
+	cryptodrv->pci_drv.devuninit = rte_cryptodev_pci_remove;
 
 	rte_eal_pci_register(&cryptodrv->pci_drv);
 
lib/librte_cryptodev/rte_cryptodev_pmd.h +12 -0
index c977c61..3fb7c7c 100644
@@ -534,6 +534,18 @@ rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
 void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 				enum rte_cryptodev_event_type event);
 
+/**
+ * Wrapper for use by pci drivers as a .devinit function to attach to a crypto
+ * interface.
+ */
+int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
+			    struct rte_pci_device *pci_dev);
+
+/**
+ * Wrapper for use by pci drivers as a .devuninit function to detach a crypto
+ * interface.
+ */
+int rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev);
 
 #ifdef __cplusplus
 }
lib/librte_cryptodev/rte_cryptodev_version.map +2 -0
index a08fd20..7aa7f4e 100644
@@ -37,5 +37,7 @@ DPDK_16.07 {
 	global:
 
 	rte_cryptodev_parse_vdev_init_params;
+	rte_cryptodev_pci_probe;
+	rte_cryptodev_pci_remove;
 
 } DPDK_16.04;
Signature · 1 line
2.7.4
Reviewed-by on v6 6/17
#147 lore raw

Re: [PATCH v6 06/17] crypto: export init/uninit common wrappers for pci drivers

Quoted 7 lines · On Tue, 12 Jul 2016 11:31:11 +0530 Shreyansh Jain <[email protected]>…

Preparing for getting rid of rte_cryptodev_driver, here are two wrappers that can be used by pci drivers that assume a 1 to 1 association between pci resource and upper interface.

---

#148 lore raw

PATCH v6 7/17 ethdev: export init/uninit common wrappers for pci drivers

In reply to Shreyansh Jain

Preparing for getting rid of eth_drv, here are two wrappers that can be used by pci drivers that assume a 1 to 1 association between pci resource and upper interface.

---
 lib/librte_ether/rte_ethdev.c          | 14 +++++++-------
 lib/librte_ether/rte_ethdev.h          | 13 +++++++++++++
 lib/librte_ether/rte_ether_version.map |  3 +++
 3 files changed, 23 insertions(+), 7 deletions(-)
lib/librte_ether/rte_ethdev.c +7 -7
index 0a6e3f1..25eb032 100644
@@ -245,9 +245,9 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
-static int
-rte_eth_dev_init(struct rte_pci_driver *pci_drv,
-		 struct rte_pci_device *pci_dev)
+int
+rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
+		      struct rte_pci_device *pci_dev)
 {
 	struct eth_driver    *eth_drv;
 	struct rte_eth_dev *eth_dev;
@@ -299,8 +299,8 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 	return diag;
 }
 
-static int
-rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
+int
+rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 {
 	const struct eth_driver *eth_drv;
 	struct rte_eth_dev *eth_dev;
@@ -357,8 +357,8 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
 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;
+	eth_drv->pci_drv.devinit = rte_eth_dev_pci_probe;
+	eth_drv->pci_drv.devuninit = rte_eth_dev_pci_remove;
 	rte_eal_pci_register(&eth_drv->pci_drv);
 }
 
lib/librte_ether/rte_ethdev.h +13 -0
index 4dac364..a2ec9d1 100644
@@ -4369,6 +4369,19 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id);
 int
 rte_eth_dev_get_name_by_port(uint8_t port_id, char *name);
 
+/**
+ * Wrapper for use by pci drivers as a .devinit function to attach to a ethdev
+ * interface.
+ */
+int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
+			  struct rte_pci_device *pci_dev);
+
+/**
+ * Wrapper for use by pci drivers as a .devuninit function to detach a ethdev
+ * interface.
+ */
+int rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev);
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_ether/rte_ether_version.map +3 -0
index 45ddf44..c5ef869 100644
@@ -138,4 +138,7 @@ DPDK_16.07 {
 	rte_eth_dev_get_name_by_port;
 	rte_eth_dev_get_port_by_name;
 	rte_eth_xstats_get_names;
+	rte_eth_dev_pci_probe;
+	rte_eth_dev_pci_remove;
+
 } DPDK_16.04;
Signature · 1 line
2.7.4
Reviewed-by on v6 7/17
#149 lore raw

Re: [PATCH v6 07/17] ethdev: export init/uninit common wrappers for pci drivers

Quoted 7 lines · On Tue, 12 Jul 2016 11:31:12 +0530 Shreyansh Jain <[email protected]>…

Preparing for getting rid of eth_drv, here are two wrappers that can be used by pci drivers that assume a 1 to 1 association between pci resource and upper interface.

---

#150 lore raw

PATCH v6 8/17 drivers: convert all pdev drivers as pci drivers

In reply to Shreyansh Jain

Simplify crypto and ethdev pci drivers init by using newly introduced init macros and helpers.
Those drivers then don't need to register as "rte_driver"s anymore.

Exceptions:
- virtio and mlx* use RTE_INIT directly as they have custom initialization steps.
- VDEV devices are not modified - they continue to use PMD_REGISTER_DRIVER.

---
 drivers/crypto/qat/rte_qat_cryptodev.c  | 16 +++---------
 drivers/net/bnx2x/bnx2x_ethdev.c        | 34 +++++-------------------
 drivers/net/bnxt/bnxt_ethdev.c          | 16 +++---------
 drivers/net/cxgbe/cxgbe_ethdev.c        | 24 +++--------------
 drivers/net/e1000/em_ethdev.c           | 16 +++---------
 drivers/net/e1000/igb_ethdev.c          | 39 +++++-----------------------
 drivers/net/ena/ena_ethdev.c            | 17 +++---------
 drivers/net/enic/enic_ethdev.c          | 23 +++--------------
 drivers/net/fm10k/fm10k_ethdev.c        | 23 +++--------------
 drivers/net/i40e/i40e_ethdev.c          | 24 +++--------------
 drivers/net/i40e/i40e_ethdev_vf.c       | 25 +++---------------
 drivers/net/ixgbe/ixgbe_ethdev.c        | 46 +++++----------------------------
 drivers/net/mlx4/mlx4.c                 | 15 +++--------
 drivers/net/mlx5/mlx5.c                 | 14 +++-------
 drivers/net/nfp/nfp_net.c               | 21 +++------------
 drivers/net/qede/qede_ethdev.c          | 40 ++++++----------------------
 drivers/net/szedata2/rte_eth_szedata2.c | 24 +++--------------
 drivers/net/thunderx/nicvf_ethdev.c     | 20 +++-----------
 drivers/net/virtio/virtio_ethdev.c      | 25 +++++-------------
 drivers/net/vmxnet3/vmxnet3_ethdev.c    | 23 +++--------------
 20 files changed, 78 insertions(+), 407 deletions(-)
drivers/crypto/qat/rte_qat_cryptodev.c +3 -13
index 1e9e0ba..4c215a6 100644
@@ -116,23 +116,13 @@ static struct rte_cryptodev_driver rte_qat_pmd = {
 	.pci_drv = {
 		.id_table = pci_id_qat_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_cryptodev_pci_probe,
+		.devuninit = rte_cryptodev_pci_remove,
 	},
 	.cryptodev_init = crypto_qat_dev_init,
 	.dev_private_size = sizeof(struct qat_pmd_private),
 };
 
-static int
-rte_qat_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return rte_cryptodev_pmd_driver_register(&rte_qat_pmd, PMD_PDEV);
-}
-
-static struct rte_driver pmd_qat_drv = {
-	.type = PMD_PDEV,
-	.init = rte_qat_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(pmd_qat_drv, CRYPTODEV_NAME_QAT_SYM_PMD);
+DRIVER_REGISTER_PCI(CRYPTODEV_NAME_QAT_SYM_PMD, rte_qat_pmd);
 DRIVER_REGISTER_PCI_TABLE(CRYPTODEV_NAME_QAT_SYM_PMD, pci_id_qat_map);
 
drivers/net/bnx2x/bnx2x_ethdev.c +6 -28
index c8d2bf2..dc7c893 100644
@@ -621,6 +621,8 @@ static struct eth_driver rte_bnx2x_pmd = {
 		.name = "rte_bnx2x_pmd",
 		.id_table = pci_id_bnx2x_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_bnx2x_dev_init,
 	.dev_private_size = sizeof(struct bnx2x_softc),
@@ -634,38 +636,14 @@ static struct eth_driver rte_bnx2xvf_pmd = {
 		.name = "rte_bnx2xvf_pmd",
 		.id_table = pci_id_bnx2xvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_bnx2xvf_dev_init,
 	.dev_private_size = sizeof(struct bnx2x_softc),
 };
 
-static int rte_bnx2x_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_bnx2x_pmd);
-
-	return 0;
-}
-
-static int rte_bnx2xvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_bnx2xvf_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_bnx2x_driver = {
-	.type = PMD_PDEV,
-	.init = rte_bnx2x_pmd_init,
-};
-
-static struct rte_driver rte_bnx2xvf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_bnx2xvf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_bnx2x_driver, bnx2x);
+DRIVER_REGISTER_PCI(bnx2x, rte_bnx2x_pmd);
 DRIVER_REGISTER_PCI_TABLE(bnx2x, pci_id_bnx2x_map);
-PMD_REGISTER_DRIVER(rte_bnx2xvf_driver, bnx2xvf);
+DRIVER_REGISTER_PCI(bnx2xvf, rte_bnx2xvf_pmd);
 DRIVER_REGISTER_PCI_TABLE(bnx2xvf, pci_id_bnx2xvf_map);
drivers/net/bnxt/bnxt_ethdev.c +3 -13
index 3795fac..607f88c 100644
@@ -1048,23 +1048,13 @@ static struct eth_driver bnxt_rte_pmd = {
 		    .name = "rte_" DRV_MODULE_NAME "_pmd",
 		    .id_table = bnxt_pci_id_map,
 		    .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		    .devinit = rte_eth_dev_pci_probe,
+		    .devuninit = rte_eth_dev_pci_remove,
 		    },
 	.eth_dev_init = bnxt_dev_init,
 	.eth_dev_uninit = bnxt_dev_uninit,
 	.dev_private_size = sizeof(struct bnxt),
 };
 
-static int bnxt_rte_pmd_init(const char *name, const char *params __rte_unused)
-{
-	RTE_LOG(INFO, PMD, "bnxt_rte_pmd_init() called for %s\n", name);
-	rte_eth_driver_register(&bnxt_rte_pmd);
-	return 0;
-}
-
-static struct rte_driver bnxt_pmd_drv = {
-	.type = PMD_PDEV,
-	.init = bnxt_rte_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(bnxt_pmd_drv, bnxt);
+DRIVER_REGISTER_PCI(bnxt, bnxt_rte_pmd);
 DRIVER_REGISTER_PCI_TABLE(bnxt, bnxt_pci_id_map);
drivers/net/cxgbe/cxgbe_ethdev.c +3 -21
index 9208a61..70cc1f6 100644
@@ -1042,30 +1042,12 @@ static struct eth_driver rte_cxgbe_pmd = {
 		.name = "rte_cxgbe_pmd",
 		.id_table = cxgb4_pci_tbl,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_cxgbe_dev_init,
 	.dev_private_size = sizeof(struct port_info),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI CXGBE devices.
- */
-static int rte_cxgbe_pmd_init(const char *name __rte_unused,
-			      const char *params __rte_unused)
-{
-	CXGBE_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_cxgbe_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_cxgbe_driver = {
-	.type = PMD_PDEV,
-	.init = rte_cxgbe_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_cxgbe_driver, cxgb4);
+DRIVER_REGISTER_PCI(cxgb4, rte_cxgbe_pmd);
 DRIVER_REGISTER_PCI_TABLE(cxgb4, cxgb4_pci_tbl);
-
drivers/net/e1000/em_ethdev.c +3 -13
index ad104ed..dc7a3c7 100644
@@ -395,6 +395,8 @@ static struct eth_driver rte_em_pmd = {
 		.id_table = pci_id_em_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_em_dev_init,
 	.eth_dev_uninit = eth_em_dev_uninit,
@@ -402,13 +404,6 @@ static struct eth_driver rte_em_pmd = {
 };
 
 static int
-rte_em_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_em_pmd);
-	return 0;
-}
-
-static int
 em_hw_init(struct e1000_hw *hw)
 {
 	int diag;
@@ -1799,10 +1794,5 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
 	return 0;
 }
 
-struct rte_driver em_pmd_drv = {
-	.type = PMD_PDEV,
-	.init = rte_em_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(em_pmd_drv, em);
+DRIVER_REGISTER_PCI(em, rte_em_pmd);
 DRIVER_REGISTER_PCI_TABLE(em, pci_id_em_map);
drivers/net/e1000/igb_ethdev.c +6 -33
index fbf4d09..c24a933 100644
@@ -1047,6 +1047,8 @@ static struct eth_driver rte_igb_pmd = {
 		.id_table = pci_id_igb_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_igb_dev_init,
 	.eth_dev_uninit = eth_igb_dev_uninit,
@@ -1061,19 +1063,14 @@ static struct eth_driver rte_igbvf_pmd = {
 		.name = "rte_igbvf_pmd",
 		.id_table = pci_id_igbvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_igbvf_dev_init,
 	.eth_dev_uninit = eth_igbvf_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
-static int
-rte_igb_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_igb_pmd);
-	return 0;
-}
-
 static void
 igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
 {
@@ -1085,20 +1082,6 @@ igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
 	E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 }
 
-/*
- * VF Driver initialization routine.
- * Invoked one at EAL init time.
- * Register itself as the [Virtual Poll Mode] Driver of PCI IGB devices.
- */
-static int
-rte_igbvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_igbvf_pmd);
-	return 0;
-}
-
 static int
 igb_check_mq_mode(struct rte_eth_dev *dev)
 {
@@ -5049,16 +5032,6 @@ eth_igb_set_eeprom(struct rte_eth_dev *dev,
 	return nvm->ops.write(hw,  first, length, data);
 }
 
-static struct rte_driver pmd_igb_drv = {
-	.type = PMD_PDEV,
-	.init = rte_igb_pmd_init,
-};
-
-static struct rte_driver pmd_igbvf_drv = {
-	.type = PMD_PDEV,
-	.init = rte_igbvf_pmd_init,
-};
-
 static int
 eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
@@ -5220,7 +5193,7 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev)
 	E1000_WRITE_FLUSH(hw);
 }
 
-PMD_REGISTER_DRIVER(pmd_igb_drv, igb);
+DRIVER_REGISTER_PCI(igb, rte_igb_pmd);
 DRIVER_REGISTER_PCI_TABLE(igb, pci_id_igb_map);
-PMD_REGISTER_DRIVER(pmd_igbvf_drv, igbvf);
+DRIVER_REGISTER_PCI(igbvf, rte_igbvf_pmd);
 DRIVER_REGISTER_PCI_TABLE(igbvf, pci_id_igbvf_map);
drivers/net/ena/ena_ethdev.c +3 -14
index 9418d50..9f46d57 100644
@@ -1689,23 +1689,12 @@ static struct eth_driver rte_ena_pmd = {
 		.name = "rte_ena_pmd",
 		.id_table = pci_id_ena_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_ena_dev_init,
 	.dev_private_size = sizeof(struct ena_adapter),
 };
 
-static int
-rte_ena_pmd_init(const char *name __rte_unused,
-		 const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_ena_pmd);
-	return 0;
-};
-
-struct rte_driver ena_pmd_drv = {
-	.type = PMD_PDEV,
-	.init = rte_ena_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(ena_pmd_drv, ena);
+DRIVER_REGISTER_PCI(ena, rte_ena_pmd);
 DRIVER_REGISTER_PCI_TABLE(ena, pci_id_ena_map);
drivers/net/enic/enic_ethdev.c +3 -20
index 3c87b49..7e7bae8 100644
@@ -609,29 +609,12 @@ static struct eth_driver rte_enic_pmd = {
 		.name = "rte_enic_pmd",
 		.id_table = pci_id_enic_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_enicpmd_dev_init,
 	.dev_private_size = sizeof(struct enic),
 };
 
-/* Driver initialization routine.
- * Invoked once at EAL init time.
- * Register as the [Poll Mode] Driver of Cisco ENIC device.
- */
-static int
-rte_enic_pmd_init(__rte_unused const char *name,
-	 __rte_unused const char *params)
-{
-	ENICPMD_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_enic_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_enic_driver = {
-	.type = PMD_PDEV,
-	.init = rte_enic_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_enic_driver, enic);
+DRIVER_REGISTER_PCI(enic, rte_enic_pmd);
 DRIVER_REGISTER_PCI_TABLE(enic, pci_id_enic_map);
drivers/net/fm10k/fm10k_ethdev.c +3 -20
index 217853f..ee99d60 100644
@@ -3061,30 +3061,13 @@ static struct eth_driver rte_pmd_fm10k = {
 		.id_table = pci_id_fm10k_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_fm10k_dev_init,
 	.eth_dev_uninit = eth_fm10k_dev_uninit,
 	.dev_private_size = sizeof(struct fm10k_adapter),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI FM10K devices.
- */
-static int
-rte_pmd_fm10k_init(__rte_unused const char *name,
-	__rte_unused const char *params)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_pmd_fm10k);
-	return 0;
-}
-
-static struct rte_driver rte_fm10k_driver = {
-	.type = PMD_PDEV,
-	.init = rte_pmd_fm10k_init,
-};
-
-PMD_REGISTER_DRIVER(rte_fm10k_driver, fm10k);
+DRIVER_REGISTER_PCI(fm10k, rte_pmd_fm10k);
 DRIVER_REGISTER_PCI_TABLE(fm10k, pci_id_fm10k_map);
drivers/net/i40e/i40e_ethdev.c +3 -21
index daac236..4e42ecf 100644
@@ -667,6 +667,8 @@ static struct eth_driver rte_i40e_pmd = {
 		.id_table = pci_id_i40e_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_i40e_dev_init,
 	.eth_dev_uninit = eth_i40e_dev_uninit,
@@ -701,27 +703,7 @@ rte_i40e_dev_atomic_write_link_status(struct rte_eth_dev *dev,
 	return 0;
 }
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI IXGBE devices.
- */
-static int
-rte_i40e_pmd_init(const char *name __rte_unused,
-		  const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_i40e_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_i40e_driver = {
-	.type = PMD_PDEV,
-	.init = rte_i40e_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_i40e_driver, i40e);
+DRIVER_REGISTER_PCI(i40e, rte_i40e_pmd);
 DRIVER_REGISTER_PCI_TABLE(i40e, pci_id_i40e_map);
 
 /*
drivers/net/i40e/i40e_ethdev_vf.c +3 -22
index a616ae0..6526a66 100644
@@ -1557,34 +1557,15 @@ static struct eth_driver rte_i40evf_pmd = {
 		.name = "rte_i40evf_pmd",
 		.id_table = pci_id_i40evf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = i40evf_dev_init,
 	.eth_dev_uninit = i40evf_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_adapter),
 };
 
-/*
- * VF Driver initialization routine.
- * Invoked one at EAL init time.
- * Register itself as the [Virtual Poll Mode] Driver of PCI Fortville devices.
- */
-static int
-rte_i40evf_pmd_init(const char *name __rte_unused,
-		    const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_i40evf_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_i40evf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_i40evf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_i40evf_driver, i40evf);
+DRIVER_REGISTER_PCI(i40evf, rte_i40evf_pmd);
 DRIVER_REGISTER_PCI_TABLE(i40evf, pci_id_i40evf_map);
 
 static int
drivers/net/ixgbe/ixgbe_ethdev.c +6 -40

69 lines not on this page · raw message

drivers/net/mlx4/mlx4.c +3 -12
index 304c846..2bed4de 100644
@@ -5922,12 +5922,10 @@ static struct eth_driver mlx4_driver = {
 /**
  * Driver initialization routine.
  */
-static int
-rte_mlx4_pmd_init(const char *name, const char *args)
+RTE_INIT(rte_mlx4_pmd_init);
+static void
+rte_mlx4_pmd_init(void)
 {
-	(void)name;
-	(void)args;
-
 	RTE_BUILD_BUG_ON(sizeof(wr_id_t) != sizeof(uint64_t));
 	/*
 	 * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
@@ -5938,13 +5936,6 @@ rte_mlx4_pmd_init(const char *name, const char *args)
 	setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
 	ibv_fork_init();
 	rte_eal_pci_register(&mlx4_driver.pci_drv);
-	return 0;
 }
 
-static struct rte_driver rte_mlx4_driver = {
-	.type = PMD_PDEV,
-	.init = rte_mlx4_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_mlx4_driver, mlx4);
 DRIVER_REGISTER_PCI_TABLE(mlx4, mlx4_pci_id_map);
drivers/net/mlx5/mlx5.c +3 -11
index d96a9af..3658769 100644
@@ -739,11 +739,10 @@ static struct eth_driver mlx5_driver = {
 /**
  * Driver initialization routine.
  */
-static int
-rte_mlx5_pmd_init(const char *name, const char *args)
+RTE_INIT(rte_mlx5_pmd_init);
+static void
+rte_mlx5_pmd_init(void)
 {
-	(void)name;
-	(void)args;
 	/*
 	 * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
 	 * huge pages. Calling ibv_fork_init() during init allows
@@ -753,13 +752,6 @@ rte_mlx5_pmd_init(const char *name, const char *args)
 	setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
 	ibv_fork_init();
 	rte_eal_pci_register(&mlx5_driver.pci_drv);
-	return 0;
 }
 
-static struct rte_driver rte_mlx5_driver = {
-	.type = PMD_PDEV,
-	.init = rte_mlx5_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_mlx5_driver, mlx5);
 DRIVER_REGISTER_PCI_TABLE(mlx5, mlx5_pci_id_map);
drivers/net/nfp/nfp_net.c +3 -18
index 99a258a..b37007e 100644
@@ -2464,29 +2464,14 @@ static struct eth_driver rte_nfp_net_pmd = {
 		.id_table = pci_id_nfp_net_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			     RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = nfp_net_init,
 	.dev_private_size = sizeof(struct nfp_net_adapter),
 };
 
-static int
-nfp_net_pmd_init(const char *name __rte_unused,
-		 const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	PMD_INIT_LOG(INFO, "librte_pmd_nfp_net version %s\n",
-		     NFP_NET_PMD_VERSION);
-
-	rte_eth_driver_register(&rte_nfp_net_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_nfp_net_driver = {
-	.type = PMD_PDEV,
-	.init = nfp_net_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_nfp_net_driver, nfp);
+DRIVER_REGISTER_PCI(nfp, rte_nfp_net_pmd);
 DRIVER_REGISTER_PCI_TABLE(nfp, pci_id_nfp_net_map);
 
 /*
drivers/net/qede/qede_ethdev.c +8 -32
index 82e44b8..2143d2a 100644
@@ -1482,7 +1482,9 @@ static struct eth_driver rte_qedevf_pmd = {
 		    .id_table = pci_id_qedevf_map,
 		    .drv_flags =
 		    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-		    },
+		    .devinit = rte_eth_dev_pci_probe,
+		    .devuninit = rte_eth_dev_pci_remove,
+		   },
 	.eth_dev_init = qedevf_eth_dev_init,
 	.eth_dev_uninit = qedevf_eth_dev_uninit,
 	.dev_private_size = sizeof(struct qede_dev),
@@ -1494,41 +1496,15 @@ static struct eth_driver rte_qede_pmd = {
 		    .id_table = pci_id_qede_map,
 		    .drv_flags =
 		    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-		    },
+		    .devinit = rte_eth_dev_pci_probe,
+		    .devuninit = rte_eth_dev_pci_remove,
+		   },
 	.eth_dev_init = qede_eth_dev_init,
 	.eth_dev_uninit = qede_eth_dev_uninit,
 	.dev_private_size = sizeof(struct qede_dev),
 };
 
-static int
-rte_qedevf_pmd_init(const char *name __rte_unused,
-		    const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_qedevf_pmd);
-
-	return 0;
-}
-
-static int
-rte_qede_pmd_init(const char *name __rte_unused,
-		  const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_qede_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_qedevf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_qede_pmd_init
-};
-
-static struct rte_driver rte_qede_driver = {
-	.type = PMD_PDEV,
-	.init = rte_qedevf_pmd_init
-};
-
-PMD_REGISTER_DRIVER(rte_qede_driver, qede);
+DRIVER_REGISTER_PCI(qede, rte_qede_pmd);
 DRIVER_REGISTER_PCI_TABLE(qede, pci_id_qede_map);
-PMD_REGISTER_DRIVER(rte_qedevf_driver, qedevf);
+DRIVER_REGISTER_PCI(qedevf, rte_qedevf_pmd);
 DRIVER_REGISTER_PCI_TABLE(qedevf, pci_id_qedevf_map);
drivers/net/szedata2/rte_eth_szedata2.c +3 -21
index 483d789..d5e1551 100644
@@ -1574,31 +1574,13 @@ static struct eth_driver szedata2_eth_driver = {
 	.pci_drv = {
 		.name     = RTE_SZEDATA2_PCI_DRIVER_NAME,
 		.id_table = rte_szedata2_pci_id_table,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init     = rte_szedata2_eth_dev_init,
 	.eth_dev_uninit   = rte_szedata2_eth_dev_uninit,
 	.dev_private_size = sizeof(struct pmd_internals),
 };
 
-static int
-rte_szedata2_init(const char *name __rte_unused,
-		const char *args __rte_unused)
-{
-	rte_eth_driver_register(&szedata2_eth_driver);
-	return 0;
-}
-
-static int
-rte_szedata2_uninit(const char *name __rte_unused)
-{
-	return 0;
-}
-
-static struct rte_driver rte_szedata2_driver = {
-	.type = PMD_PDEV,
-	.init = rte_szedata2_init,
-	.uninit = rte_szedata2_uninit,
-};
-
-PMD_REGISTER_DRIVER(rte_szedata2_driver, RTE_SZEDATA2_DRIVER_NAME);
+DRIVER_REGISTER_PCI(RTE_SZEDATA2_DRIVER_NAME, szedata2_eth_driver);
 DRIVER_REGISTER_PCI_TABLE(RTE_SZEDATA2_DRIVER_NAME, rte_szedata2_pci_id_table);
drivers/net/thunderx/nicvf_ethdev.c +3 -17
index 4f875c0..8d90f8d 100644
@@ -1762,26 +1762,12 @@ static struct eth_driver rte_nicvf_pmd = {
 		.name = "rte_nicvf_pmd",
 		.id_table = pci_id_nicvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = nicvf_eth_dev_init,
 	.dev_private_size = sizeof(struct nicvf),
 };
 
-static int
-rte_nicvf_pmd_init(const char *name __rte_unused, const char *para __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	PMD_INIT_LOG(INFO, "librte_pmd_thunderx nicvf version %s",
-			THUNDERX_NICVF_PMD_VERSION);
-
-	rte_eth_driver_register(&rte_nicvf_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_nicvf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_nicvf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_nicvf_driver, thunderx_nicvf);
+DRIVER_REGISTER_PCI(thunderx_nicvf, rte_nicvf_pmd);
 DRIVER_REGISTER_PCI_TABLE(thunderx_nicvf, pci_id_nicvf_map);
drivers/net/virtio/virtio_ethdev.c +7 -18
index 850e3ba..d3cfbaf 100644
@@ -1307,29 +1307,24 @@ static struct eth_driver rte_virtio_pmd = {
 		.name = "rte_virtio_pmd",
 		.id_table = pci_id_virtio_map,
 		.drv_flags = RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_virtio_dev_init,
 	.eth_dev_uninit = eth_virtio_dev_uninit,
 	.dev_private_size = sizeof(struct virtio_hw),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI virtio devices.
- * Returns 0 on success.
- */
-static int
-rte_virtio_pmd_init(const char *name __rte_unused,
-		    const char *param __rte_unused)
+RTE_INIT(rte_virtio_pmd_init);
+static void
+rte_virtio_pmd_init(void)
 {
 	if (rte_eal_iopl_init() != 0) {
 		PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
-		return -1;
+		return;
 	}
 
-	rte_eth_driver_register(&rte_virtio_pmd);
-	return 0;
+	rte_eal_pci_register(&rte_virtio_pmd.pci_drv);
 }
 
 /*
@@ -1563,10 +1558,4 @@ __rte_unused uint8_t is_rx)
 	return 0;
 }
 
-static struct rte_driver rte_virtio_driver = {
-	.type = PMD_PDEV,
-	.init = rte_virtio_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_virtio_driver, virtio_net);
 DRIVER_REGISTER_PCI_TABLE(virtio_net, pci_id_virtio_map);
drivers/net/vmxnet3/vmxnet3_ethdev.c +3 -20
index 5874215..25475f8 100644
@@ -331,26 +331,14 @@ static struct eth_driver rte_vmxnet3_pmd = {
 		.name = "rte_vmxnet3_pmd",
 		.id_table = pci_id_vmxnet3_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_vmxnet3_dev_init,
 	.eth_dev_uninit = eth_vmxnet3_dev_uninit,
 	.dev_private_size = sizeof(struct vmxnet3_hw),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of Virtual PCI VMXNET3 devices.
- */
-static int
-rte_vmxnet3_pmd_init(const char *name __rte_unused, const char *param __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_vmxnet3_pmd);
-	return 0;
-}
-
 static int
 vmxnet3_dev_configure(struct rte_eth_dev *dev)
 {
@@ -948,10 +936,5 @@ vmxnet3_process_events(struct vmxnet3_hw *hw)
 }
 #endif
 
-static struct rte_driver rte_vmxnet3_driver = {
-	.type = PMD_PDEV,
-	.init = rte_vmxnet3_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_vmxnet3_driver, vmxnet3);
+DRIVER_REGISTER_PCI(vmxnet3, rte_vmxnet3_pmd);
 DRIVER_REGISTER_PCI_TABLE(vmxnet3, pci_id_vmxnet3_map);
Signature · 1 line
2.7.4
#151 lore raw

PATCH v6 9/17 crypto: get rid of crypto driver register callback

In reply to Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register crypto drivers through a dedicated channel.

---
 lib/librte_cryptodev/rte_cryptodev.c           | 22 -------------------
 lib/librte_cryptodev/rte_cryptodev_pmd.h       | 30 --------------------------
 lib/librte_cryptodev/rte_cryptodev_version.map |  1 -
 3 files changed, 53 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +0 -22
index 3a75f2c..d7be111 100644
@@ -535,28 +535,6 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv,
-		enum pmd_type type)
-{
-	/* Call crypto device initialization directly if device is virtual */
-	if (type == PMD_VDEV)
-		return rte_cryptodev_pci_probe((struct rte_pci_driver *)cryptodrv,
-				NULL);
-
-	/*
-	 * Register PCI driver for physical device intialisation during
-	 * PCI probing
-	 */
-	cryptodrv->pci_drv.devinit = rte_cryptodev_pci_probe;
-	cryptodrv->pci_drv.devuninit = rte_cryptodev_pci_remove;
-
-	rte_eal_pci_register(&cryptodrv->pci_drv);
-
-	return 0;
-}
-
-
 uint16_t
 rte_cryptodev_queue_pair_count(uint8_t dev_id)
 {
lib/librte_cryptodev/rte_cryptodev_pmd.h +0 -30
index 3fb7c7c..99fd69e 100644
@@ -491,36 +491,6 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 extern int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);
 
-
-/**
- * Register a Crypto [Poll Mode] driver.
- *
- * Function invoked by the initialization function of a Crypto driver
- * to simultaneously register itself as Crypto Poll Mode Driver and to either:
- *
- *	a - register itself as PCI driver if the crypto device is a physical
- *		device, by invoking the rte_eal_pci_register() function to
- *		register the *pci_drv* structure embedded in the *crypto_drv*
- *		structure, after having stored the address of the
- *		rte_cryptodev_init() function in the *devinit* field of the
- *		*pci_drv* structure.
- *
- *		During the PCI probing phase, the rte_cryptodev_init()
- *		function is invoked for each PCI [device] matching the
- *		embedded PCI identifiers provided by the driver.
- *
- *	b, complete the initialization sequence if the device is a virtual
- *		device by calling the rte_cryptodev_init() directly passing a
- *		NULL parameter for the rte_pci_device structure.
- *
- *   @param crypto_drv	crypto_driver structure associated with the crypto
- *					driver.
- *   @param type		pmd type
- */
-extern int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
-		enum pmd_type type);
-
 /**
  * Executes all the user application registered callbacks for the specific
  * device.
lib/librte_cryptodev/rte_cryptodev_version.map +0 -1
index 7aa7f4e..be016d9 100644
@@ -14,7 +14,6 @@ DPDK_16.04 {
 	rte_cryptodev_info_get;
 	rte_cryptodev_pmd_allocate;
 	rte_cryptodev_pmd_callback_process;
-	rte_cryptodev_pmd_driver_register;
 	rte_cryptodev_pmd_release_device;
 	rte_cryptodev_pmd_virtual_dev_init;
 	rte_cryptodev_sym_session_create;
Signature · 1 line
2.7.4
#153 lore raw

PATCH v6 10/17 ethdev: get rid of eth driver register callback

In reply to Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register ethdev drivers through a dedicated channel.

---
 lib/librte_ether/rte_ethdev.c          | 22 ----------------------
 lib/librte_ether/rte_ethdev.h          | 12 ------------
 lib/librte_ether/rte_ether_version.map |  1 -
 3 files changed, 35 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -22
index 25eb032..89c7b31 100644
@@ -340,28 +340,6 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-/**
- * Register an Ethernet [Poll Mode] driver.
- *
- * Function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * 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
- * the *pci_drv* structure.
- * During the PCI probing phase, the rte_eth_dev_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_pci_probe;
-	eth_drv->pci_drv.devuninit = rte_eth_dev_pci_remove;
-	rte_eal_pci_register(&eth_drv->pci_drv);
-}
-
 int
 rte_eth_dev_is_valid_port(uint8_t port_id)
 {
lib/librte_ether/rte_ethdev.h +0 -12
index a2ec9d1..d2718b5 100644
@@ -1871,18 +1871,6 @@ struct eth_driver {
 };
 
 /**
- * @internal
- * A function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * Poll Mode Driver (PMD).
- *
- * @param eth_drv
- *   The pointer to the *eth_driver* structure associated with
- *   the Ethernet driver.
- */
-void rte_eth_driver_register(struct eth_driver *eth_drv);
-
-/**
  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
  * the bitmap link_speeds of the struct rte_eth_conf
  *
lib/librte_ether/rte_ether_version.map +0 -1
index c5ef869..27d8161 100644
@@ -78,7 +78,6 @@ DPDK_2.2 {
 	rte_eth_dev_vlan_filter;
 	rte_eth_dev_wd_timeout_store;
 	rte_eth_dma_zone_reserve;
-	rte_eth_driver_register;
 	rte_eth_led_off;
 	rte_eth_led_on;
 	rte_eth_link;
Signature · 1 line
2.7.4
#155 lore raw

PATCH v6 11/17 eal/linux: move back interrupt thread init before setting affinity

In reply to Shreyansh Jain

Now that virtio pci driver is initialized in a constructor, iopl() stuff happens early enough so that interrupt thread can be created right after plugin loading.
This way, chelsio driver should be happy again [1].

[1] http://dpdk.org/ml/archives/dev/2015-November/028289.html

---
 lib/librte_eal/linuxapp/eal/eal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +3 -3
index fe9c704..259a7e4 100644
@@ -834,6 +834,9 @@ rte_eal_init(int argc, char **argv)
 	if (eal_plugins_init() < 0)
 		rte_panic("Cannot init plugins\n");
 
+	if (rte_eal_intr_init() < 0)
+		rte_panic("Cannot init interrupt-handling thread\n");
+
 	eal_thread_init_master(rte_config.master_lcore);
 
 	ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
@@ -845,9 +848,6 @@ rte_eal_init(int argc, char **argv)
 	if (rte_eal_dev_init() < 0)
 		rte_panic("Cannot init pmd devices\n");
 
-	if (rte_eal_intr_init() < 0)
-		rte_panic("Cannot init interrupt-handling thread\n");
-
 	RTE_LCORE_FOREACH_SLAVE(i) {
 
 		/*
Signature · 1 line
2.7.4
Reviewed-by on v6 11/17
#156 lore raw

Re: [PATCH v6 11/17] eal/linux: move back interrupt thread init before setting affinity

Quoted 11 lines · On Tue, 12 Jul 2016 11:31:16 +0530 Shreyansh Jain <[email protected]>…

Now that virtio pci driver is initialized in a constructor, iopl() stuff happens early enough so that interrupt thread can be created right after plugin loading.
This way, chelsio driver should be happy again [1].

[1] http://dpdk.org/ml/archives/dev/2015-November/028289.html

---

#157 lore raw

PATCH v6 12/17 pci: add a helper for device name

In reply to Shreyansh Jain

eal is a better place than crypto / ethdev for naming resources. Add a helper in eal and make use of it in crypto / ethdev.

---
 lib/librte_cryptodev/rte_cryptodev.c    | 27 ++++-----------------------
 lib/librte_eal/common/include/rte_pci.h | 25 +++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.c           | 24 ++++--------------------
 3 files changed, 33 insertions(+), 43 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +4 -23
index d7be111..60c6384 100644
@@ -367,23 +367,6 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 	return cryptodev;
 }
 
-static inline int
-rte_cryptodev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
-{
-	int ret;
-
-	if ((name == NULL) || (pci_dev == NULL))
-		return -EINVAL;
-
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
 int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
 {
@@ -446,9 +429,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
 	if (cryptodrv == NULL)
 		return -ENODEV;
 
-	/* Create unique Crypto device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 	if (cryptodev == NULL)
@@ -503,9 +485,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -EINVAL;
 
-	/* Create unique device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
 	if (cryptodev == NULL)
lib/librte_eal/common/include/rte_pci.h +25 -0
index 3027adf..06508fa 100644
@@ -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. */
@@ -95,6 +96,7 @@ const char *pci_get_sysfs_path(void);
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
+#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
@@ -308,6 +310,29 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
 }
 #undef GET_PCIADDR_FIELD
 
+/**
+ * Utility function to write a pci device name, this device name can later be
+ * used to retrieve the corresponding rte_pci_addr using above functions.
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address
+ * @param output
+ *	The output buffer string
+ * @param size
+ *	The output buffer size
+ * @return
+ *  0 on success, negative on error.
+ */
+static inline void
+rte_eal_pci_device_name(const struct rte_pci_addr *addr,
+		    char *output, size_t size)
+{
+	RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
+	RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
+			    addr->domain, addr->bus,
+			    addr->devid, addr->function) >= 0);
+}
+
 /* Compare two PCI device addresses. */
 /**
  * Utility function to compare two PCI device addresses.
lib/librte_ether/rte_ethdev.c +4 -20
index 89c7b31..147b26f 100644
@@ -220,20 +220,6 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	return eth_dev;
 }
 
-static int
-rte_eth_dev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
-{
-	int ret;
-
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
 int
 rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 {
@@ -257,9 +243,8 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
 
 	eth_drv = (struct eth_driver *)pci_drv;
 
-	/* Create unique Ethernet device name using PCI address */
-	rte_eth_dev_create_unique_device_name(ethdev_name,
-			sizeof(ethdev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
+			sizeof(ethdev_name));
 
 	eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
 	if (eth_dev == NULL)
@@ -310,9 +295,8 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -EINVAL;
 
-	/* Create unique Ethernet device name using PCI address */
-	rte_eth_dev_create_unique_device_name(ethdev_name,
-			sizeof(ethdev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
+			sizeof(ethdev_name));
 
 	eth_dev = rte_eth_dev_allocated(ethdev_name);
 	if (eth_dev == NULL)
Signature · 1 line
2.7.4
#158 lore raw

Re: [PATCH v6 12/17] pci: add a helper for device name

Quoted 1 line · On Tue, 12 Jul 2016 11:31:17 +0530 Shreyansh Jain <[email protected]>…

eal is a better place than crypto / ethdev for naming resources.

s/for naming/to name/

What is meant by "resources" here?

Quoted 83 lines

Add a helper in eal and make use of it in crypto / ethdev.

---
 lib/librte_cryptodev/rte_cryptodev.c    | 27 ++++-----------------------
 lib/librte_eal/common/include/rte_pci.h | 25 +++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.c           | 24 ++++--------------------
 3 files changed, 33 insertions(+), 43 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +4 -23
index d7be111..60c6384 100644
@@ -367,23 +367,6 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 	return cryptodev;
 }
 
-static inline int
-rte_cryptodev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
-{
-	int ret;
-
-	if ((name == NULL) || (pci_dev == NULL))
-		return -EINVAL;
-
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
 int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
 {
@@ -446,9 +429,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
 	if (cryptodrv == NULL)
 		return -ENODEV;
 
-	/* Create unique Crypto device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 	if (cryptodev == NULL)
@@ -503,9 +485,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -EINVAL;
 
-	/* Create unique device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
 	if (cryptodev == NULL)
lib/librte_eal/common/include/rte_pci.h +2 -0
index 3027adf..06508fa 100644
@@ -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. */
@@ -95,6 +96,7 @@ const char *pci_get_sysfs_path(void);
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
+#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8

lib/librte_eal/common/include/rte_pci.h eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr) · line 315

Quoted 6 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
@@ -308,6 +310,29 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
 }
 #undef GET_PCIADDR_FIELD
 
+/**
+ * Utility function to write a pci device name, this device name can later be
+ * used to retrieve the corresponding rte_pci_addr using above functions.

What about saying "using functions eal_parse_pci_*BDF"? The specification "above" is quite uncertain...

Quoted 22 lines
lib/librte_eal/common/include/rte_pci.h +20 -0
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address
+ * @param output
+ *	The output buffer string
+ * @param size
+ *	The output buffer size
+ * @return
+ *  0 on success, negative on error.
+ */
+static inline void
+rte_eal_pci_device_name(const struct rte_pci_addr *addr,
+		    char *output, size_t size)
+{
+	RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
+	RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
+			    addr->domain, addr->bus,
+			    addr->devid, addr->function) >= 0);
+}
+
 /* Compare two PCI device addresses. */
 /**

[...]

#159 lore raw

Re: [PATCH v6 12/17] pci: add a helper for device name

Quoted 6 lines · Jan Viktorin
Quoted 1 line · On Tue, 12 Jul 2016 11:31:17 +0530 Shreyansh Jain <[email protected]>…

eal is a better place than crypto / ethdev for naming resources.

s/for naming/to name/

OK.

Quoted 2 lines

What is meant by "resources" here?

This has historic context (from earlier version of this patch).
But I could relate the word 'resources' to EAL representation of devices - whether PCI or Crypto. Or, Resource == Device.

Quoted 87 lines
Quoted 87 lines

Add a helper in eal and make use of it in crypto / ethdev.

---
 lib/librte_cryptodev/rte_cryptodev.c    | 27 ++++-----------------------
 lib/librte_eal/common/include/rte_pci.h | 25 +++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.c           | 24 ++++--------------------
 3 files changed, 33 insertions(+), 43 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +4 -23
index d7be111..60c6384 100644
@@ -367,23 +367,6 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 	return cryptodev;
 }
 
-static inline int
-rte_cryptodev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
-{
-	int ret;
-
-	if ((name == NULL) || (pci_dev == NULL))
-		return -EINVAL;
-
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
 int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
 {
@@ -446,9 +429,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
 	if (cryptodrv == NULL)
 		return -ENODEV;
 
-	/* Create unique Crypto device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 	if (cryptodev == NULL)
@@ -503,9 +485,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -EINVAL;
 
-	/* Create unique device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
 	if (cryptodev == NULL)
lib/librte_eal/common/include/rte_pci.h +2 -0
index 3027adf..06508fa 100644
@@ -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. */
@@ -95,6 +96,7 @@ const char *pci_get_sysfs_path(void);
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
+#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
@@ -308,6 +310,29 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
 }
 #undef GET_PCIADDR_FIELD
 
Quoted 6 lines

lib/librte_eal/common/include/rte_pci.h eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr) · line 315

Quoted 3 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
+/**
+ * Utility function to write a pci device name, this device name can later be
+ * used to retrieve the corresponding rte_pci_addr using above functions.

What about saying "using functions eal_parse_pci_*BDF"? The specification "above" is quite uncertain...

Agree that 'above' is positional word and should be avoided. I will change that to "... using eal_parse_pci_* BDF helpers". OK?

Quoted 27 lines
Quoted 23 lines
lib/librte_eal/common/include/rte_pci.h +20 -0
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address
+ * @param output
+ *	The output buffer string
+ * @param size
+ *	The output buffer size
+ * @return
+ *  0 on success, negative on error.
+ */
+static inline void
+rte_eal_pci_device_name(const struct rte_pci_addr *addr,
+		    char *output, size_t size)
+{
+	RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
+	RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
+			    addr->domain, addr->bus,
+			    addr->devid, addr->function) >= 0);
+}
+
 /* Compare two PCI device addresses. */
 /**

[...]

#160 lore raw

Re: [PATCH v6 12/17] pci: add a helper for device name

2016-07-15 15:09, Shreyansh jain:

Quoted 6 lines · Jan Viktorin
Quoted 1 line

What is meant by "resources" here?

This has historic context (from earlier version of this patch).
But I could relate the word 'resources' to EAL representation of devices - whether PCI or Crypto. Or, Resource == Device.

We need to define a precise wording, especially for the words
- interface
- resource
- device
- driver
- module
Following are my thoughts:

An interface is a view of a resource through an API (e.g. an ethdev port). A resource is a well identified hardware (e.g. a PCI device id). A device is a hardware function (e.g. a networking port).
Note that some PCI NICs have only one PCI device id for several ports (Chelsio and Mellanox cases). That's why we need to distinguish device and resource.

A driver is the code handling a device.
I have read the word module in some patch proposals but I don't really know what it refers to. Is it a group of drivers in the same file/directory?

#161 lore raw

Re: [PATCH v6 12/17] pci: add a helper for device name

Quoted 23 lines · On Fri, 15 Jul 2016 11:56:38 +0200 Thomas Monjalon <[email protected]>…

2016-07-15 15:09, Shreyansh jain:

Quoted 6 lines · Jan Viktorin
Quoted 1 line

What is meant by "resources" here?

This has historic context (from earlier version of this patch).
But I could relate the word 'resources' to EAL representation of devices - whether PCI or Crypto. Or, Resource == Device.

We need to define a precise wording, especially for the words
- interface
- resource
- device
- driver
- module
Following are my thoughts:

An interface is a view of a resource through an API (e.g. an ethdev port). A resource is a well identified hardware (e.g. a PCI device id). A device is a hardware function (e.g. a networking port).
Note that some PCI NICs have only one PCI device id for several ports (Chelsio and Mellanox cases). That's why we need to distinguish device and resource.

Quoted 3 lines

A driver is the code handling a device.
I have read the word module in some patch proposals but I don't really know what it refers to. Is it a group of drivers in the same file/directory?

Well, yes, initially there was proposed a kind of module. However, after David as sent the patchset prepare for rte_device/driver, you can see that there is no need for such object (probably). A module might be helpful when thinking about the metadata (as done by Neil Horman). But as far as I know there was no need for this... So a module has no data abstraction now and I am not going to make any.

Jan

#162 lore raw

Re: [PATCH v6 12/17] pci: add a helper for device name

In reply to Shreyansh jain
Quoted 8 lines · On Fri, 15 Jul 2016 15:09:58 +0530 Shreyansh jain <[email protected]>…
Quoted 6 lines · Jan Viktorin
Quoted 1 line · On Tue, 12 Jul 2016 11:31:17 +0530 Shreyansh Jain <[email protected]>…

eal is a better place than crypto / ethdev for naming resources.

s/for naming/to name/

Quoted 8 lines

OK.

Quoted 2 lines

What is meant by "resources" here?

This has historic context (from earlier version of this patch).
But I could relate the word 'resources' to EAL representation of devices - whether PCI or Crypto. Or, Resource == Device.

If it is possible I'd like more "device". But I think it's not that critical thing...

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Add a helper in eal and make use of it in crypto / ethdev.

[...]

Quoted 20 lines
Quoted 13 lines
Quoted 13 lines

TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */

lib/librte_eal/common/include/rte_pci.h +1 -0
@@ -95,6 +96,7 @@ const char *pci_get_sysfs_path(void);
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
+#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
@@ -308,6 +310,29 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
 }
 #undef GET_PCIADDR_FIELD
 
Quoted 6 lines

lib/librte_eal/common/include/rte_pci.h eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr) · line 315

Quoted 3 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
+/**
+ * Utility function to write a pci device name, this device name can later be
+ * used to retrieve the corresponding rte_pci_addr using above functions.  

What about saying "using functions eal_parse_pci_*BDF"? The specification "above" is quite uncertain...

Quoted 2 lines

Agree that 'above' is positional word and should be avoided. I will change that to "... using eal_parse_pci_* BDF helpers". OK?

OK.

[...]

Signature · 4 lines
   Jan Viktorin                  E-mail: [email protected]
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic
#163 lore raw

Re: [PATCH v6 12/17] pci: add a helper for device name

In reply to Shreyansh jain
Quoted 8 lines · Shreyansh jain
Quoted 6 lines · Jan Viktorin
Quoted 1 line · On Tue, 12 Jul 2016 11:31:17 +0530 Shreyansh Jain <[email protected]>…

eal is a better place than crypto / ethdev for naming resources.

s/for naming/to name/

Quoted 9 lines

OK.

Quoted 2 lines

What is meant by "resources" here?

This has historic context (from earlier version of this patch).
But I could relate the word 'resources' to EAL representation of devices - whether PCI or Crypto. Or, Resource == Device.

If I go by what Thomas is proposing for meaning of 'resource' [1], and the fact that all methods in this patchset refer to 'devices', I will change the patch context to 'EAL is a better place than crypto / ethdev to name devices'.

[1] http://dpdk.org/ml/archives/dev/2016-July/044056.html

Quoted 126 lines
Quoted 87 lines
Quoted 87 lines

Add a helper in eal and make use of it in crypto / ethdev.

---
 lib/librte_cryptodev/rte_cryptodev.c    | 27 ++++-----------------------
 lib/librte_eal/common/include/rte_pci.h | 25 +++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.c           | 24 ++++--------------------
 3 files changed, 33 insertions(+), 43 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +4 -23
index d7be111..60c6384 100644
@@ -367,23 +367,6 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 	return cryptodev;
 }
 
-static inline int
-rte_cryptodev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
-{
-	int ret;
-
-	if ((name == NULL) || (pci_dev == NULL))
-		return -EINVAL;
-
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
 int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
 {
@@ -446,9 +429,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
 	if (cryptodrv == NULL)
 		return -ENODEV;
 
-	/* Create unique Crypto device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 	if (cryptodev == NULL)
@@ -503,9 +485,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -EINVAL;
 
-	/* Create unique device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
 	if (cryptodev == NULL)
lib/librte_eal/common/include/rte_pci.h +2 -0
index 3027adf..06508fa 100644
@@ -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. */
@@ -95,6 +96,7 @@ const char *pci_get_sysfs_path(void);
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
+#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
@@ -308,6 +310,29 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
 }
 #undef GET_PCIADDR_FIELD
 
Quoted 6 lines

lib/librte_eal/common/include/rte_pci.h eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr) · line 315

Quoted 3 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
+/**
+ * Utility function to write a pci device name, this device name can later be
+ * used to retrieve the corresponding rte_pci_addr using above functions.

What about saying "using functions eal_parse_pci_*BDF"? The specification "above" is quite uncertain...

Agree that 'above' is positional word and should be avoided. I will change that to "... using eal_parse_pci_* BDF helpers". OK?

Quoted 27 lines
Quoted 23 lines
lib/librte_eal/common/include/rte_pci.h +20 -0
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address
+ * @param output
+ *	The output buffer string
+ * @param size
+ *	The output buffer size
+ * @return
+ *  0 on success, negative on error.
+ */
+static inline void
+rte_eal_pci_device_name(const struct rte_pci_addr *addr,
+		    char *output, size_t size)
+{
+	RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
+	RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
+			    addr->domain, addr->bus,
+			    addr->devid, addr->function) >= 0);
+}
+
 /* Compare two PCI device addresses. */
 /**

[...]

#164 lore raw

PATCH v6 13/17 pci: add a helper to update a device

In reply to Shreyansh Jain

This helper updates a pci device object with latest information it can find.
It will be used mainly for hotplug code.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c     | 49 +++++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_common_pci.c  |  2 --
 lib/librte_eal/common/eal_private.h     | 13 +++++++++
 lib/librte_eal/common/include/rte_pci.h |  3 ++
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 13 +++++++++
 5 files changed, 78 insertions(+), 2 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +49 -0
index a73cbb0..1d91c78 100644
@@ -406,6 +406,55 @@ error:
 	return -1;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	int fd;
+	struct pci_conf matches[2];
+	struct pci_match_conf match = {
+		.pc_sel = {
+			.pc_domain = addr->domain,
+			.pc_bus = addr->bus,
+			.pc_dev = addr->devid,
+			.pc_func = addr->function,
+		},
+	};
+	struct pci_conf_io conf_io = {
+		.pat_buf_len = 0,
+		.num_patterns = 1,
+		.patterns = &match,
+		.match_buf_len = sizeof(matches),
+		.matches = &matches[0],
+	};
+
+	fd = open("/dev/pci", O_RDONLY);
+	if (fd < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
+		goto error;
+	}
+
+	if (ioctl(fd, PCIOCGETCONF, &conf_io) < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error with ioctl on /dev/pci: %s\n",
+				__func__, strerror(errno));
+		goto error;
+	}
+
+	if (conf_io.num_matches != 1)
+		goto error;
+
+	if (pci_scan_one(fd, &matches[0]) < 0)
+		goto error;
+
+	close(fd);
+
+	return 0;
+
+error:
+	if (fd >= 0)
+		close(fd);
+	return -1;
+}
+
 /* Read PCI config space. */
 int rte_eal_pci_read_config(const struct rte_pci_device *dev,
 			    void *buf, size_t len, off_t offset)
lib/librte_eal/common/eal_common_pci.c +0 -2
index 6a0f6ac..58f0c74 100644
@@ -87,8 +87,6 @@ struct pci_driver_list pci_driver_list =
 struct pci_device_list pci_device_list =
 	TAILQ_HEAD_INITIALIZER(pci_device_list);
 
-#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
-
 const char *pci_get_sysfs_path(void)
 {
 	const char *path = NULL;
lib/librte_eal/common/eal_private.h +13 -0
index 06a68f6..b8ff9c5 100644
@@ -152,6 +152,19 @@ struct rte_pci_driver;
 struct rte_pci_device;
 
 /**
+ * Update a pci device object by asking the kernel for the latest information.
+ *
+ * This function is private to EAL.
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address to look for
+ * @return
+ *   - 0 on success.
+ *   - negative on error.
+ */
+int pci_update_device(const struct rte_pci_addr *addr);
+
+/**
  * Unbind kernel driver for this device
  *
  * This function is private to EAL.
lib/librte_eal/common/include/rte_pci.h +3 -0
index 06508fa..5c2062c 100644
@@ -107,6 +107,9 @@ const char *pci_get_sysfs_path(void);
 /** Nb. of values in PCI resource format. */
 #define PCI_RESOURCE_FMT_NVAL 3
 
+/** Default sysfs path for PCI device search. */
+#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
+
 /**
  * A structure describing a PCI resource.
  */
lib/librte_eal/linuxapp/eal/eal_pci.c +13 -0
index f0215ee..8f3ef20 100644
@@ -417,6 +417,19 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 	return 0;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	char filename[PATH_MAX];
+
+	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
+		 SYSFS_PCI_DEVICES, addr->domain, addr->bus, addr->devid,
+		 addr->function);
+
+	return pci_scan_one(filename, addr->domain, addr->bus, addr->devid,
+			    addr->function);
+}
+
 /*
  * split up a pci address into its constituent parts.
  */
Signature · 1 line
2.7.4
#165 lore raw

Re: [PATCH v6 13/17] pci: add a helper to update a device

Quoted 79 lines · On Tue, 12 Jul 2016 11:31:18 +0530 Shreyansh Jain <[email protected]>…

This helper updates a pci device object with latest information it can find.
It will be used mainly for hotplug code.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c     | 49 +++++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_common_pci.c  |  2 --
 lib/librte_eal/common/eal_private.h     | 13 +++++++++
 lib/librte_eal/common/include/rte_pci.h |  3 ++
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 13 +++++++++
 5 files changed, 78 insertions(+), 2 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +49 -0
index a73cbb0..1d91c78 100644
@@ -406,6 +406,55 @@ error:
 	return -1;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	int fd;
+	struct pci_conf matches[2];
+	struct pci_match_conf match = {
+		.pc_sel = {
+			.pc_domain = addr->domain,
+			.pc_bus = addr->bus,
+			.pc_dev = addr->devid,
+			.pc_func = addr->function,
+		},
+	};
+	struct pci_conf_io conf_io = {
+		.pat_buf_len = 0,
+		.num_patterns = 1,
+		.patterns = &match,
+		.match_buf_len = sizeof(matches),
+		.matches = &matches[0],
+	};
+
+	fd = open("/dev/pci", O_RDONLY);
+	if (fd < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
+		goto error;
+	}
+
+	if (ioctl(fd, PCIOCGETCONF, &conf_io) < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error with ioctl on /dev/pci: %s\n",
+				__func__, strerror(errno));
+		goto error;
+	}
+
+	if (conf_io.num_matches != 1)
+		goto error;
+
+	if (pci_scan_one(fd, &matches[0]) < 0)
+		goto error;
+
+	close(fd);
+
+	return 0;
+
+error:
+	if (fd >= 0)
+		close(fd);
+	return -1;
+}
+
 /* Read PCI config space. */
 int rte_eal_pci_read_config(const struct rte_pci_device *dev,
 			    void *buf, size_t len, off_t offset)
lib/librte_eal/common/eal_common_pci.c +0 -0
index 6a0f6ac..58f0c74 100644

lib/librte_eal/common/eal_common_pci.c struct pci_driver_list pci_driver_list = · line 91

Quoted 5 lines
lib/librte_eal/common/eal_common_pci.c +0 -2
@@ -87,8 +87,6 @@ struct pci_driver_list pci_driver_list =
 struct pci_device_list pci_device_list =
 	TAILQ_HEAD_INITIALIZER(pci_device_list);
 
-#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
-

Is this delete correct? The SYSFS_PCI_DEVICES was moved here from rte_pci.h. A relict of some rebase?

Quoted 32 lines
lib/librte_eal/common/eal_common_pci.c +0 -0
 const char *pci_get_sysfs_path(void)
 {
 	const char *path = NULL;
lib/librte_eal/common/eal_private.h +13 -0
index 06a68f6..b8ff9c5 100644
@@ -152,6 +152,19 @@ struct rte_pci_driver;
 struct rte_pci_device;
 
 /**
+ * Update a pci device object by asking the kernel for the latest information.
+ *
+ * This function is private to EAL.
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address to look for
+ * @return
+ *   - 0 on success.
+ *   - negative on error.
+ */
+int pci_update_device(const struct rte_pci_addr *addr);
+
+/**
  * Unbind kernel driver for this device
  *
  * This function is private to EAL.
lib/librte_eal/common/include/rte_pci.h +0 -0
index 06508fa..5c2062c 100644

lib/librte_eal/common/include/rte_pci.h const char *pci_get_sysfs_path(void); · line 112

Quoted 6 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
@@ -107,6 +107,9 @@ const char *pci_get_sysfs_path(void);
 /** Nb. of values in PCI resource format. */
 #define PCI_RESOURCE_FMT_NVAL 3
 
+/** Default sysfs path for PCI device search. */
+#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
+

Why adding SYSFS_PCI_DEVICES here? The pci_get_sysfs_path is used for this purpose. Again, a rebase issue?

Quoted 8 lines
lib/librte_eal/common/include/rte_pci.h +0 -0
 /**
  * A structure describing a PCI resource.
  */
lib/librte_eal/linuxapp/eal/eal_pci.c +0 -0
index f0215ee..8f3ef20 100644

lib/librte_eal/linuxapp/eal/eal_pci.c pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, · line 426

Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +7 -0
@@ -417,6 +417,19 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 	return 0;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	char filename[PATH_MAX];
+
+	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
+		 SYSFS_PCI_DEVICES, addr->domain, addr->bus, addr->devid,

Use pci_get_sysfs_path here.

Quoted 9 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +6 -0
+		 addr->function);
+
+	return pci_scan_one(filename, addr->domain, addr->bus, addr->devid,
+			    addr->function);
+}
+
 /*
  * split up a pci address into its constituent parts.
  */
Signature · 4 lines
  Jan Viktorin                E-mail: [email protected]
  System Architect            Web:    www.RehiveTech.com
  RehiveTech
  Brno, Czech Republic
#166 lore raw

Re: [PATCH v6 13/17] pci: add a helper to update a device

Quoted 85 lines · Jan Viktorin
Quoted 82 lines · On Tue, 12 Jul 2016 11:31:18 +0530 Shreyansh Jain <[email protected]>…

This helper updates a pci device object with latest information it can find.
It will be used mainly for hotplug code.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c     | 49 +++++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_common_pci.c  |  2 --
 lib/librte_eal/common/eal_private.h     | 13 +++++++++
 lib/librte_eal/common/include/rte_pci.h |  3 ++
 lib/librte_eal/linuxapp/eal/eal_pci.c   | 13 +++++++++
 5 files changed, 78 insertions(+), 2 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +49 -0
index a73cbb0..1d91c78 100644
@@ -406,6 +406,55 @@ error:
 	return -1;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	int fd;
+	struct pci_conf matches[2];
+	struct pci_match_conf match = {
+		.pc_sel = {
+			.pc_domain = addr->domain,
+			.pc_bus = addr->bus,
+			.pc_dev = addr->devid,
+			.pc_func = addr->function,
+		},
+	};
+	struct pci_conf_io conf_io = {
+		.pat_buf_len = 0,
+		.num_patterns = 1,
+		.patterns = &match,
+		.match_buf_len = sizeof(matches),
+		.matches = &matches[0],
+	};
+
+	fd = open("/dev/pci", O_RDONLY);
+	if (fd < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
+		goto error;
+	}
+
+	if (ioctl(fd, PCIOCGETCONF, &conf_io) < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error with ioctl on /dev/pci: %s\n",
+				__func__, strerror(errno));
+		goto error;
+	}
+
+	if (conf_io.num_matches != 1)
+		goto error;
+
+	if (pci_scan_one(fd, &matches[0]) < 0)
+		goto error;
+
+	close(fd);
+
+	return 0;
+
+error:
+	if (fd >= 0)
+		close(fd);
+	return -1;
+}
+
 /* Read PCI config space. */
 int rte_eal_pci_read_config(const struct rte_pci_device *dev,
 			    void *buf, size_t len, off_t offset)
lib/librte_eal/common/eal_common_pci.c +0 -0
index 6a0f6ac..58f0c74 100644
@@ -87,8 +87,6 @@ struct pci_driver_list pci_driver_list =
 struct pci_device_list pci_device_list =
 	TAILQ_HEAD_INITIALIZER(pci_device_list);
 
Quoted 5 lines

lib/librte_eal/common/eal_common_pci.c struct pci_driver_list pci_driver_list = · line 91

Quoted 2 lines
lib/librte_eal/common/eal_common_pci.c +0 -2
-#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
-

Is this delete correct? The SYSFS_PCI_DEVICES was moved here from rte_pci.h. A relict of some rebase?

My miss - I had though of using pci_get_sysfs_path post v5, (as you have mentioned below) but while re-creating the patches I missed out.

Quoted 36 lines
Quoted 36 lines
lib/librte_eal/common/eal_common_pci.c +0 -0
 const char *pci_get_sysfs_path(void)
 {
 	const char *path = NULL;
lib/librte_eal/common/eal_private.h +13 -0
index 06a68f6..b8ff9c5 100644
@@ -152,6 +152,19 @@ struct rte_pci_driver;
 struct rte_pci_device;
 
 /**
+ * Update a pci device object by asking the kernel for the latest information.
+ *
+ * This function is private to EAL.
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address to look for
+ * @return
+ *   - 0 on success.
+ *   - negative on error.
+ */
+int pci_update_device(const struct rte_pci_addr *addr);
+
+/**
  * Unbind kernel driver for this device
  *
  * This function is private to EAL.
lib/librte_eal/common/include/rte_pci.h +0 -0
index 06508fa..5c2062c 100644
@@ -107,6 +107,9 @@ const char *pci_get_sysfs_path(void);
 /** Nb. of values in PCI resource format. */
 #define PCI_RESOURCE_FMT_NVAL 3
 
Quoted 6 lines

lib/librte_eal/common/include/rte_pci.h const char *pci_get_sysfs_path(void); · line 112

Quoted 3 lines
lib/librte_eal/common/include/rte_pci.h +3 -0
+/** Default sysfs path for PCI device search. */
+#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
+

Why adding SYSFS_PCI_DEVICES here? The pci_get_sysfs_path is used for this purpose. Again, a rebase issue?

Once pci_get_sysfs_path is used, this change would be redundant.

Quoted 12 lines
Quoted 12 lines
lib/librte_eal/common/include/rte_pci.h +0 -0
 /**
  * A structure describing a PCI resource.
  */
lib/librte_eal/linuxapp/eal/eal_pci.c +0 -0
index f0215ee..8f3ef20 100644
@@ -417,6 +417,19 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 	return 0;
 }
 
Quoted 9 lines

lib/librte_eal/linuxapp/eal/eal_pci.c pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, · line 426

Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +7 -0
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	char filename[PATH_MAX];
+
+	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
+		 SYSFS_PCI_DEVICES, addr->domain, addr->bus, addr->devid,

Use pci_get_sysfs_path here.

My miss. I will change this.

Quoted 13 lines
Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +6 -0
+		 addr->function);
+
+	return pci_scan_one(filename, addr->domain, addr->bus, addr->devid,
+			    addr->function);
+}
+
 /*
  * split up a pci address into its constituent parts.
  */
#167 lore raw

PATCH v6 14/17 ethdev: do not scan all pci devices on attach

In reply to Shreyansh Jain

No need to scan all devices, we only need to update the device being attached.

---
 lib/librte_eal/common/eal_common_pci.c | 11 ++++++++---
 lib/librte_ether/rte_ethdev.c          |  3 ---
 2 files changed, 8 insertions(+), 6 deletions(-)
lib/librte_eal/common/eal_common_pci.c +8 -3
index 58f0c74..e001837 100644
@@ -339,6 +339,11 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 	if (addr == NULL)
 		return -1;
 
+	/* update current pci device in global list, kernel bindings might have
+	 * changed since last time we looked at it */
+	if (pci_update_device(addr) < 0)
+		goto err_return;
+
 	TAILQ_FOREACH(dev, &pci_device_list, next) {
 		if (rte_eal_compare_pci_addr(&dev->addr, addr))
 			continue;
@@ -351,9 +356,9 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 	return -1;
 
 err_return:
-	RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT
-			" cannot be used\n", dev->addr.domain, dev->addr.bus,
-			dev->addr.devid, dev->addr.function);
+	RTE_LOG(WARNING, EAL,
+		"Requested device " PCI_PRI_FMT " cannot be used\n",
+		addr->domain, addr->bus, addr->devid, addr->function);
 	return -1;
 }
 
lib/librte_ether/rte_ethdev.c +0 -3
index 147b26f..a667012 100644
@@ -469,9 +469,6 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 static int
 rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
 {
-	/* re-construct pci_device_list */
-	if (rte_eal_pci_scan())
-		goto err;
 	/* Invoke probe func of the driver can handle the new device. */
 	if (rte_eal_pci_probe_one(addr))
 		goto err;
Signature · 1 line
2.7.4
#168 lore raw

PATCH v6 15/17 eal: add hotplug operations for pci and vdev

In reply to Shreyansh Jain

Hotplug which deals with resources should come from the layer that already handles them, i.e. EAL.

For both attach and detach operations, 'name' is used to select the bus that will handle the request.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  2 ++
 lib/librte_eal/common/eal_common_dev.c          | 47 +++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_dev.h         | 25 +++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 ++
 4 files changed, 76 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
index 1852c4a..6f9324f 100644
@@ -159,5 +159,7 @@ DPDK_16.07 {
 	rte_keepalive_mark_sleep;
 	rte_keepalive_register_relay_callback;
 	rte_thread_setname;
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
 
 } DPDK_16.04;
lib/librte_eal/common/eal_common_dev.c +47 -0

50 lines not on this page · raw message

lib/librte_eal/common/include/rte_dev.h +25 -0
index 994650b..2f0579c 100644
@@ -178,6 +178,31 @@ int rte_eal_vdev_init(const char *name, const char *args);
  */
 int rte_eal_vdev_uninit(const char *name);
 
+/**
+ * Attach a resource to a registered driver.
+ *
+ * @param name
+ *   The resource name, that refers to a pci resource or some private
+ *   way of designating a resource for vdev drivers. Based on this
+ *   resource name, eal will identify a driver capable of handling
+ *   this resource and pass this resource to the driver probing
+ *   function.
+ * @param devargs
+ *   Device arguments to be passed to the driver.
+ * @return
+ *   0 on success, negative on error.
+ */
+int rte_eal_dev_attach(const char *name, const char *devargs);
+
+/**
+ * Detach a resource from its driver.
+ *
+ * @param name
+ *   Same description as for rte_eal_dev_attach().
+ *   Here, eal will call the driver detaching function.
+ */
+int rte_eal_dev_detach(const char *name);
+
 #define DRIVER_EXPORT_NAME_ARRAY(n, idx) n##idx[]
 
 #define DRIVER_EXPORT_NAME(name, idx) \
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
index a617b9e..db866b8 100644
@@ -163,5 +163,7 @@ DPDK_16.07 {
 	rte_keepalive_mark_sleep;
 	rte_keepalive_register_relay_callback;
 	rte_thread_setname;
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
 
 } DPDK_16.04;
Signature · 1 line
2.7.4
#169 lore raw

Re: [PATCH v6 15/17] eal: add hotplug operations for pci and vdev

Quoted 49 lines · On Tue, 12 Jul 2016 11:31:20 +0530 Shreyansh Jain <[email protected]>…

Hotplug which deals with resources should come from the layer that already handles them, i.e. EAL.

For both attach and detach operations, 'name' is used to select the bus that will handle the request.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  2 ++
 lib/librte_eal/common/eal_common_dev.c          | 47 +++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_dev.h         | 25 +++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 ++
 4 files changed, 76 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
index 1852c4a..6f9324f 100644
@@ -159,5 +159,7 @@ DPDK_16.07 {
 	rte_keepalive_mark_sleep;
 	rte_keepalive_register_relay_callback;
 	rte_thread_setname;
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
 
 } DPDK_16.04;
lib/librte_eal/common/eal_common_dev.c +14 -0
index a8a4146..14c6cf1 100644
@@ -150,3 +150,50 @@ rte_eal_vdev_uninit(const char *name)
 	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
 	return -EINVAL;
 }
+
+int rte_eal_dev_attach(const char *name, const char *devargs)
+{
+	struct rte_pci_addr addr;
+	int ret = -1;
+
+	if (name == NULL || devargs == NULL) {
+		RTE_LOG(ERR, EAL, "Invalid device arguments provided\n");
+		return ret;
+	}
+
+	if (eal_parse_pci_DomBDF(name, &addr) == 0) {
+		if (rte_eal_pci_probe_one(&addr) < 0)
+			goto err;

lib/librte_eal/common/eal_common_dev.c rte_eal_vdev_uninit(const char *name) · line 176

Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +10 -0
+
+	} else {
+		if (rte_eal_vdev_init(name, devargs))
+			goto err;
+	}
+
+	return 0;
+
+err:
+	RTE_LOG(ERR, EAL, "Driver cannot attach the device\n");

I think this log can be more specific. We have the name of the device. It might be confusing to the user when the attach fails and there is no simple way how to determine which one.

Quoted 11 lines
lib/librte_eal/common/eal_common_dev.c +11 -0
+	return ret;
+}
+
+int rte_eal_dev_detach(const char *name)
+{
+	struct rte_pci_addr addr;
+
+	if (name == NULL)
+		goto err;
+
+	if (eal_parse_pci_DomBDF(name, &addr) == 0) {

lib/librte_eal/common/eal_common_dev.c rte_eal_vdev_uninit(const char *name) · line 197

Quoted 10 lines
lib/librte_eal/common/eal_common_dev.c +10 -0
+		if (rte_eal_pci_detach(&addr) < 0)
+			goto err;
+	} else {
+		if (rte_eal_vdev_uninit(name))
+			goto err;
+	}
+	return 0;
+
+err:
+	RTE_LOG(ERR, EAL, "Driver cannot detach the device\n");

Same as for attach.

lib/librte_eal/common/include/rte_dev.h int rte_eal_vdev_init(const char *name, const char *args); · line 182

Quoted 12 lines
lib/librte_eal/common/eal_common_dev.c +2 -0
+	return -1;
+}
lib/librte_eal/common/include/rte_dev.h +2 -0
index 994650b..2f0579c 100644
@@ -178,6 +178,31 @@ int rte_eal_vdev_init(const char *name, const char *args);
  */
 int rte_eal_vdev_uninit(const char *name);
 
+/**
+ * Attach a resource to a registered driver.

From my POV, the term "resource" is not good here. We have rte_pci_resource but we refer to a device here. The function is called rte_eal_DEV_attach. No idea why to call it a resource.

Quoted 6 lines
lib/librte_eal/common/include/rte_dev.h +6 -0
+ *
+ * @param name
+ *   The resource name, that refers to a pci resource or some private
+ *   way of designating a resource for vdev drivers. Based on this
+ *   resource name, eal will identify a driver capable of handling
+ *   this resource and pass this resource to the driver probing

lib/librte_eal/common/include/rte_dev.h int rte_eal_vdev_init(const char *name, const char *args); · line 198

Quoted 10 lines
lib/librte_eal/common/include/rte_dev.h +10 -0
+ *   function.
+ * @param devargs
+ *   Device arguments to be passed to the driver.
+ * @return
+ *   0 on success, negative on error.
+ */
+int rte_eal_dev_attach(const char *name, const char *devargs);
+
+/**
+ * Detach a resource from its driver.

Same here for resource.

Jan

Quoted 22 lines
lib/librte_eal/common/include/rte_dev.h +7 -0
+ *
+ * @param name
+ *   Same description as for rte_eal_dev_attach().
+ *   Here, eal will call the driver detaching function.
+ */
+int rte_eal_dev_detach(const char *name);
+
 #define DRIVER_EXPORT_NAME_ARRAY(n, idx) n##idx[]
 
 #define DRIVER_EXPORT_NAME(name, idx) \
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
index a617b9e..db866b8 100644
@@ -163,5 +163,7 @@ DPDK_16.07 {
 	rte_keepalive_mark_sleep;
 	rte_keepalive_register_relay_callback;
 	rte_thread_setname;
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
 
 } DPDK_16.04;
#170 lore raw

Re: [PATCH v6 15/17] eal: add hotplug operations for pci and vdev

Quoted 58 lines · Jan Viktorin
Quoted 55 lines · On Tue, 12 Jul 2016 11:31:20 +0530 Shreyansh Jain <[email protected]>…

Hotplug which deals with resources should come from the layer that already handles them, i.e. EAL.

For both attach and detach operations, 'name' is used to select the bus that will handle the request.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  2 ++
 lib/librte_eal/common/eal_common_dev.c          | 47 +++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_dev.h         | 25 +++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 ++
 4 files changed, 76 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +2 -0
index 1852c4a..6f9324f 100644
@@ -159,5 +159,7 @@ DPDK_16.07 {
 	rte_keepalive_mark_sleep;
 	rte_keepalive_register_relay_callback;
 	rte_thread_setname;
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
 
 } DPDK_16.04;
lib/librte_eal/common/eal_common_dev.c +20 -0
index a8a4146..14c6cf1 100644
@@ -150,3 +150,50 @@ rte_eal_vdev_uninit(const char *name)
 	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
 	return -EINVAL;
 }
+
+int rte_eal_dev_attach(const char *name, const char *devargs)
+{
+	struct rte_pci_addr addr;
+	int ret = -1;
+
+	if (name == NULL || devargs == NULL) {
+		RTE_LOG(ERR, EAL, "Invalid device arguments provided\n");
+		return ret;
+	}
+
+	if (eal_parse_pci_DomBDF(name, &addr) == 0) {
+		if (rte_eal_pci_probe_one(&addr) < 0)
+			goto err;
+
+	} else {
+		if (rte_eal_vdev_init(name, devargs))
+			goto err;
+	}
+
Quoted 8 lines

lib/librte_eal/common/eal_common_dev.c rte_eal_vdev_uninit(const char *name) · line 176

Quoted 4 lines
lib/librte_eal/common/eal_common_dev.c +4 -0
+	return 0;
+
+err:
+	RTE_LOG(ERR, EAL, "Driver cannot attach the device\n");

I think this log can be more specific. We have the name of the device. It might be confusing to the user when the attach fails and there is no simple way how to determine which one.

Agree. I will update with 'name'.

Quoted 16 lines
Quoted 16 lines
lib/librte_eal/common/eal_common_dev.c +15 -0
+	return ret;
+}
+
+int rte_eal_dev_detach(const char *name)
+{
+	struct rte_pci_addr addr;
+
+	if (name == NULL)
+		goto err;
+
+	if (eal_parse_pci_DomBDF(name, &addr) == 0) {
+		if (rte_eal_pci_detach(&addr) < 0)
+			goto err;
+	} else {
+		if (rte_eal_vdev_uninit(name))
Quoted 8 lines

lib/librte_eal/common/eal_common_dev.c rte_eal_vdev_uninit(const char *name) · line 197

Quoted 6 lines
lib/librte_eal/common/eal_common_dev.c +6 -0
+			goto err;
+	}
+	return 0;
+
+err:
+	RTE_LOG(ERR, EAL, "Driver cannot detach the device\n");

Same as for attach.

OK.

Quoted 11 lines
Quoted 11 lines
lib/librte_eal/common/eal_common_dev.c +2 -0
+	return -1;
+}
lib/librte_eal/common/include/rte_dev.h +0 -0
index 994650b..2f0579c 100644
@@ -178,6 +178,31 @@ int rte_eal_vdev_init(const char *name, const char *args);
  */
 int rte_eal_vdev_uninit(const char *name);
 
Quoted 6 lines

lib/librte_eal/common/include/rte_dev.h int rte_eal_vdev_init(const char *name, const char *args); · line 182

Quoted 2 lines
lib/librte_eal/common/include/rte_dev.h +2 -0
+/**
+ * Attach a resource to a registered driver.

From my POV, the term "resource" is not good here. We have rte_pci_resource but we refer to a device here. The function is called rte_eal_DEV_attach. No idea why to call it a resource.

Your point of 'resource' for 'rte_eal_*dev*_attach' makes sense.
Ideally I wouldn't have given much heed to this - for me 'resource' is just a device representation within EAL. But, now that you have highlighted, name<=>comment is certainly mismatch.

I will change.

Quoted 11 lines
Quoted 11 lines
lib/librte_eal/common/include/rte_dev.h +10 -0
+ *
+ * @param name
+ *   The resource name, that refers to a pci resource or some private
+ *   way of designating a resource for vdev drivers. Based on this
+ *   resource name, eal will identify a driver capable of handling
+ *   this resource and pass this resource to the driver probing
+ *   function.
+ * @param devargs
+ *   Device arguments to be passed to the driver.
+ * @return
Quoted 8 lines

lib/librte_eal/common/include/rte_dev.h int rte_eal_vdev_init(const char *name, const char *args); · line 198

Quoted 6 lines
lib/librte_eal/common/include/rte_dev.h +6 -0
+ *   0 on success, negative on error.
+ */
+int rte_eal_dev_attach(const char *name, const char *devargs);
+
+/**
+ * Detach a resource from its driver.

Same here for resource.

I will change to "Detach a device from its driver".

Quoted 26 lines

Jan

Quoted 22 lines
lib/librte_eal/common/include/rte_dev.h +7 -0
+ *
+ * @param name
+ *   Same description as for rte_eal_dev_attach().
+ *   Here, eal will call the driver detaching function.
+ */
+int rte_eal_dev_detach(const char *name);
+
 #define DRIVER_EXPORT_NAME_ARRAY(n, idx) n##idx[]
 
 #define DRIVER_EXPORT_NAME(name, idx) \
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
index a617b9e..db866b8 100644
@@ -163,5 +163,7 @@ DPDK_16.07 {
 	rte_keepalive_mark_sleep;
 	rte_keepalive_register_relay_callback;
 	rte_thread_setname;
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
 
 } DPDK_16.04;
#171 lore raw

PATCH v6 16/17 ethdev: convert to eal hotplug

In reply to Shreyansh Jain

Remove bus logic from ethdev hotplug by using eal for this.

Current api is preserved:
- the last port that has been created is tracked to return it to the application when attaching,
- the internal device name is reused when detaching.

We can not get rid of ethdev hotplug yet since we still need some mechanism to inform applications of port creation/removal to substitute for ethdev hotplug api.

dev_type field in struct rte_eth_dev and rte_eth_dev_allocate are kept as is, but this information is not needed anymore and is removed in the following commit.

---
 lib/librte_ether/rte_ethdev.c | 207 +++++++-----------------------------------
 1 file changed, 33 insertions(+), 174 deletions(-)
lib/librte_ether/rte_ethdev.c +33 -174
index a667012..8d14fd7 100644
@@ -72,6 +72,7 @@
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 static struct rte_eth_dev_data *rte_eth_dev_data;
+static uint8_t eth_dev_last_created_port;
 static uint8_t nb_ports;
 
 /* spinlock for eth device callbacks */
@@ -216,6 +217,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	eth_dev->data->port_id = port_id;
 	eth_dev->attached = DEV_ATTACHED;
 	eth_dev->dev_type = type;
+	eth_dev_last_created_port = port_id;
 	nb_ports++;
 	return eth_dev;
 }
@@ -347,27 +349,6 @@ rte_eth_dev_count(void)
 	return nb_ports;
 }
 
-static enum rte_eth_dev_type
-rte_eth_dev_get_device_type(uint8_t port_id)
-{
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, RTE_ETH_DEV_UNKNOWN);
-	return rte_eth_devices[port_id].dev_type;
-}
-
-static int
-rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
-{
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
-
-	if (addr == NULL) {
-		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
-		return -EINVAL;
-	}
-
-	*addr = rte_eth_devices[port_id].pci_dev->addr;
-	return 0;
-}
-
 int
 rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 {
@@ -413,34 +394,6 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id)
 }
 
 static int
-rte_eth_dev_get_port_by_addr(const struct rte_pci_addr *addr, uint8_t *port_id)
-{
-	int i;
-	struct rte_pci_device *pci_dev = NULL;
-
-	if (addr == NULL) {
-		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
-		return -EINVAL;
-	}
-
-	*port_id = RTE_MAX_ETHPORTS;
-
-	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-
-		pci_dev = rte_eth_devices[i].pci_dev;
-
-		if (pci_dev &&
-			!rte_eal_compare_pci_addr(&pci_dev->addr, addr)) {
-
-			*port_id = i;
-
-			return 0;
-		}
-	}
-	return -ENODEV;
-}
-
-static int
 rte_eth_dev_is_detachable(uint8_t port_id)
 {
 	uint32_t dev_flags;
@@ -465,124 +418,45 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 		return 1;
 }
 
-/* attach the new physical device, then store port_id of the device */
-static int
-rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
-{
-	/* Invoke probe func of the driver can handle the new device. */
-	if (rte_eal_pci_probe_one(addr))
-		goto err;
-
-	if (rte_eth_dev_get_port_by_addr(addr, port_id))
-		goto err;
-
-	return 0;
-err:
-	return -1;
-}
-
-/* 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)
-{
-	struct rte_pci_addr freed_addr;
-	struct rte_pci_addr vp;
-
-	/* get pci address by port id */
-	if (rte_eth_dev_get_addr_by_port(port_id, &freed_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)
-		goto err;
-
-	/* invoke devuninit func of the pci driver,
-	 * also remove the device from pci_device_list */
-	if (rte_eal_pci_detach(&freed_addr))
-		goto err;
-
-	*addr = freed_addr;
-	return 0;
-err:
-	return -1;
-}
-
-/* attach the new virtual device, then store port_id of the device */
-static int
-rte_eth_dev_attach_vdev(const char *vdevargs, uint8_t *port_id)
-{
-	char *name = NULL, *args = NULL;
-	int ret = -1;
-
-	/* parse vdevargs, then retrieve device name and args */
-	if (rte_eal_parse_devargs_str(vdevargs, &name, &args))
-		goto end;
-
-	/* walk around dev_driver_list to find the driver of the device,
-	 * then invoke probe function of the driver.
-	 * rte_eal_vdev_init() updates port_id allocated after
-	 * initialization.
-	 */
-	if (rte_eal_vdev_init(name, args))
-		goto end;
-
-	if (rte_eth_dev_get_port_by_name(name, port_id))
-		goto end;
-
-	ret = 0;
-end:
-	free(name);
-	free(args);
-
-	return ret;
-}
-
-/* detach the new virtual device, then store the name of the device */
-static int
-rte_eth_dev_detach_vdev(uint8_t port_id, char *vdevname)
-{
-	char name[RTE_ETH_NAME_MAX_LEN];
-
-	/* get device name by port id */
-	if (rte_eth_dev_get_name_by_port(port_id, name))
-		goto err;
-	/* walk around dev_driver_list to find the driver of the device,
-	 * then invoke uninit function of the driver */
-	if (rte_eal_vdev_uninit(name))
-		goto err;
-
-	strncpy(vdevname, name, sizeof(name));
-	return 0;
-err:
-	return -1;
-}
-
 /* attach the new device, then store port_id of the device */
 int
 rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
+	int current = eth_dev_last_created_port;
+	char *name = NULL;
+	char *args = NULL;
 
 	if ((devargs == NULL) || (port_id == NULL)) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	if (eal_parse_pci_DomBDF(devargs, &addr) == 0) {
-		ret = rte_eth_dev_attach_pdev(&addr, port_id);
-		if (ret < 0)
-			goto err;
-	} else {
-		ret = rte_eth_dev_attach_vdev(devargs, port_id);
-		if (ret < 0)
-			goto err;
+	/* parse devargs, then retrieve device name and args */
+	if (rte_eal_parse_devargs_str(devargs, &name, &args))
+		goto err;
+
+	ret = rte_eal_dev_attach(name, args);
+	if (ret < 0)
+		goto err;
+
+	/* no point looking at eth_dev_last_created_port if no port exists */
+	if (!nb_ports) {
+		ret = -1;
+		goto err;
+	}
+	/* if nothing happened, there is a bug here, since some driver told us
+	 * it did attach a device, but did not create a port */
+	if (current == eth_dev_last_created_port) {
+		ret = -1;
+		goto err;
 	}
+	*port_id = eth_dev_last_created_port;
+	ret = 0;
 
-	return 0;
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n");
+	free(name);
+	free(args);
 	return ret;
 }
 
@@ -590,7 +464,6 @@ err:
 int
 rte_eth_dev_detach(uint8_t port_id, char *name)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
 
 	if (name == NULL) {
@@ -598,33 +471,19 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
 		goto err;
 	}
 
-	/* check whether the driver supports detach feature, or not */
+	/* FIXME: move this to eal, once device flags are relocated there */
 	if (rte_eth_dev_is_detachable(port_id))
 		goto err;
 
-	if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {
-		ret = rte_eth_dev_get_addr_by_port(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		ret = rte_eth_dev_detach_pdev(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		snprintf(name, RTE_ETH_NAME_MAX_LEN,
-			"%04x:%02x:%02x.%d",
-			addr.domain, addr.bus,
-			addr.devid, addr.function);
-	} else {
-		ret = rte_eth_dev_detach_vdev(port_id, name);
-		if (ret < 0)
-			goto err;
-	}
+	snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
+		 "%s", rte_eth_devices[port_id].data->name);
+	ret = rte_eal_dev_detach(name);
+	if (ret < 0)
+		goto err;
 
 	return 0;
 
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n");
 	return ret;
 }
 
Signature · 1 line
2.7.4
#172 lore raw

Re: [PATCH v6 16/17] ethdev: convert to eal hotplug

Quoted 32 lines · On Tue, 12 Jul 2016 11:31:21 +0530 Shreyansh Jain <[email protected]>…

Remove bus logic from ethdev hotplug by using eal for this.

Current api is preserved:
- the last port that has been created is tracked to return it to the application when attaching,
- the internal device name is reused when detaching.

We can not get rid of ethdev hotplug yet since we still need some mechanism to inform applications of port creation/removal to substitute for ethdev hotplug api.

dev_type field in struct rte_eth_dev and rte_eth_dev_allocate are kept as is, but this information is not needed anymore and is removed in the following commit.

---
 lib/librte_ether/rte_ethdev.c | 207 +++++++-----------------------------------
 1 file changed, 33 insertions(+), 174 deletions(-)
lib/librte_ether/rte_ethdev.c +1 -0
index a667012..8d14fd7 100644
@@ -72,6 +72,7 @@
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 static struct rte_eth_dev_data *rte_eth_dev_data;
+static uint8_t eth_dev_last_created_port;
 static uint8_t nb_ports;
 

[...]

Quoted 23 lines
lib/librte_ether/rte_ethdev.c +3 -9
-
 /* attach the new device, then store port_id of the device */
 int
 rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
+	int current = eth_dev_last_created_port;
+	char *name = NULL;
+	char *args = NULL;
 
 	if ((devargs == NULL) || (port_id == NULL)) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	if (eal_parse_pci_DomBDF(devargs, &addr) == 0) {
-		ret = rte_eth_dev_attach_pdev(&addr, port_id);
-		if (ret < 0)
-			goto err;
-	} else {
-		ret = rte_eth_dev_attach_vdev(devargs, port_id);
-		if (ret < 0)

lib/librte_ether/rte_ethdev.c rte_eth_dev_is_detachable(uint8_t port_id) · line 443

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +9 -1
-			goto err;
+	/* parse devargs, then retrieve device name and args */
+	if (rte_eal_parse_devargs_str(devargs, &name, &args))
+		goto err;
+
+	ret = rte_eal_dev_attach(name, args);
+	if (ret < 0)
+		goto err;
+
+	/* no point looking at eth_dev_last_created_port if no port exists */

I am not sure about this comment. What is "no point"?

Isn't this also a potential bug? (Like the one below.) How could it happen there is no port after a successful attach?

lib/librte_ether/rte_ethdev.c rte_eth_dev_is_detachable(uint8_t port_id) · line 452

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +9 -0
+	if (!nb_ports) {
+		ret = -1;
+		goto err;
+	}
+	/* if nothing happened, there is a bug here, since some driver told us
+	 * it did attach a device, but did not create a port */
+	if (current == eth_dev_last_created_port) {
+		ret = -1;
+		goto err;

Should we log this? Or call some kind panic?

Quoted 47 lines
lib/librte_ether/rte_ethdev.c +5 -22
 	}
+	*port_id = eth_dev_last_created_port;
+	ret = 0;
 
-	return 0;
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n");
+	free(name);
+	free(args);
 	return ret;
 }
@@ -590,7 +464,6 @@ err:
 int
 rte_eth_dev_detach(uint8_t port_id, char *name)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
 
 	if (name == NULL) {
@@ -598,33 +471,19 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
 		goto err;
 	}
 
-	/* check whether the driver supports detach feature, or not */
+	/* FIXME: move this to eal, once device flags are relocated there */
 	if (rte_eth_dev_is_detachable(port_id))
 		goto err;
 
-	if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {
-		ret = rte_eth_dev_get_addr_by_port(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		ret = rte_eth_dev_detach_pdev(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		snprintf(name, RTE_ETH_NAME_MAX_LEN,
-			"%04x:%02x:%02x.%d",
-			addr.domain, addr.bus,
-			addr.devid, addr.function);
-	} else {
-		ret = rte_eth_dev_detach_vdev(port_id, name);
-		if (ret < 0)
-			goto err;
-	}

lib/librte_ether/rte_ethdev.c rte_eth_dev_detach(uint8_t port_id, char *name) · line 627

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +5 -1
+	snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
+		 "%s", rte_eth_devices[port_id].data->name);
+	ret = rte_eal_dev_detach(name);
+	if (ret < 0)
+		goto err;
 
 	return 0;
 
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n");

I'd be more specific about the failing device, we have its name.

Quoted 3 lines
lib/librte_ether/rte_ethdev.c +0 -0
 	return ret;
 }
 
#173 lore raw

Re: [PATCH v6 16/17] ethdev: convert to eal hotplug

Quoted 74 lines · Jan Viktorin
Quoted 32 lines · On Tue, 12 Jul 2016 11:31:21 +0530 Shreyansh Jain <[email protected]>…

Remove bus logic from ethdev hotplug by using eal for this.

Current api is preserved:
- the last port that has been created is tracked to return it to the application when attaching,
- the internal device name is reused when detaching.

We can not get rid of ethdev hotplug yet since we still need some mechanism to inform applications of port creation/removal to substitute for ethdev hotplug api.

dev_type field in struct rte_eth_dev and rte_eth_dev_allocate are kept as is, but this information is not needed anymore and is removed in the following commit.

---
 lib/librte_ether/rte_ethdev.c | 207 +++++++-----------------------------------
 1 file changed, 33 insertions(+), 174 deletions(-)
lib/librte_ether/rte_ethdev.c +1 -0
index a667012..8d14fd7 100644
@@ -72,6 +72,7 @@
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 static struct rte_eth_dev_data *rte_eth_dev_data;
+static uint8_t eth_dev_last_created_port;
 static uint8_t nb_ports;
 

[...]

Quoted 23 lines
lib/librte_ether/rte_ethdev.c +3 -9
-
 /* attach the new device, then store port_id of the device */
 int
 rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
+	int current = eth_dev_last_created_port;
+	char *name = NULL;
+	char *args = NULL;
 
 	if ((devargs == NULL) || (port_id == NULL)) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	if (eal_parse_pci_DomBDF(devargs, &addr) == 0) {
-		ret = rte_eth_dev_attach_pdev(&addr, port_id);
-		if (ret < 0)
-			goto err;
-	} else {
-		ret = rte_eth_dev_attach_vdev(devargs, port_id);
-		if (ret < 0)

lib/librte_ether/rte_ethdev.c rte_eth_dev_is_detachable(uint8_t port_id) · line 443

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +9 -1
-			goto err;
+	/* parse devargs, then retrieve device name and args */
+	if (rte_eal_parse_devargs_str(devargs, &name, &args))
+		goto err;
+
+	ret = rte_eal_dev_attach(name, args);
+	if (ret < 0)
+		goto err;
+
+	/* no point looking at eth_dev_last_created_port if no port exists */

I am not sure about this comment. What is "no point"?

Quoted 2 lines

Isn't this also a potential bug? (Like the one below.) How could it happen there is no port after a successful attach?

Yes, even searching through code path I couldn't find a positive case where control would reach here without nb_ports>0. Though, i am not sure if some rough application attempts to mix-up calls - and that, in my opinion, is not worth checking. Should I remove it?

Quoted 12 lines

lib/librte_ether/rte_ethdev.c rte_eth_dev_is_detachable(uint8_t port_id) · line 452

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +9 -0
+	if (!nb_ports) {
+		ret = -1;
+		goto err;
+	}
+	/* if nothing happened, there is a bug here, since some driver told us
+	 * it did attach a device, but did not create a port */
+	if (current == eth_dev_last_created_port) {
+		ret = -1;
+		goto err;

Should we log this? Or call some kind panic?

I will place a log because applications should have a chance to ignore a device which cannot be attached for whatever reason.

Quoted 54 lines
Quoted 54 lines
lib/librte_ether/rte_ethdev.c +10 -22
 	}
+	*port_id = eth_dev_last_created_port;
+	ret = 0;
 
-	return 0;
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n");
+	free(name);
+	free(args);
 	return ret;
 }
@@ -590,7 +464,6 @@ err:
 int
 rte_eth_dev_detach(uint8_t port_id, char *name)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
 
 	if (name == NULL) {
@@ -598,33 +471,19 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
 		goto err;
 	}
 
-	/* check whether the driver supports detach feature, or not */
+	/* FIXME: move this to eal, once device flags are relocated there */
 	if (rte_eth_dev_is_detachable(port_id))
 		goto err;
 
-	if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {
-		ret = rte_eth_dev_get_addr_by_port(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		ret = rte_eth_dev_detach_pdev(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		snprintf(name, RTE_ETH_NAME_MAX_LEN,
-			"%04x:%02x:%02x.%d",
-			addr.domain, addr.bus,
-			addr.devid, addr.function);
-	} else {
-		ret = rte_eth_dev_detach_vdev(port_id, name);
-		if (ret < 0)
-			goto err;
-	}
+	snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
+		 "%s", rte_eth_devices[port_id].data->name);
+	ret = rte_eal_dev_detach(name);
+	if (ret < 0)
+		goto err;
 
Quoted 6 lines

lib/librte_ether/rte_ethdev.c rte_eth_dev_detach(uint8_t port_id, char *name) · line 627

Quoted 4 lines
lib/librte_ether/rte_ethdev.c +0 -1
 	return 0;
 
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n");

I'd be more specific about the failing device, we have its name.

Agree. I will add 'name' to this.

Quoted 4 lines
Quoted 3 lines
lib/librte_ether/rte_ethdev.c +0 -0
 	return ret;
 }
 
#174 lore raw

Re: [PATCH v6 16/17] ethdev: convert to eal hotplug

Quoted 75 lines · On Fri, 15 Jul 2016 16:06:25 +0530 Shreyansh jain <[email protected]>…
Quoted 74 lines · Jan Viktorin
Quoted 32 lines · On Tue, 12 Jul 2016 11:31:21 +0530 Shreyansh Jain <[email protected]>…

Remove bus logic from ethdev hotplug by using eal for this.

Current api is preserved:
- the last port that has been created is tracked to return it to the application when attaching,
- the internal device name is reused when detaching.

We can not get rid of ethdev hotplug yet since we still need some mechanism to inform applications of port creation/removal to substitute for ethdev hotplug api.

dev_type field in struct rte_eth_dev and rte_eth_dev_allocate are kept as is, but this information is not needed anymore and is removed in the following commit.

---
 lib/librte_ether/rte_ethdev.c | 207 +++++++-----------------------------------
 1 file changed, 33 insertions(+), 174 deletions(-)
lib/librte_ether/rte_ethdev.c +1 -0
index a667012..8d14fd7 100644
@@ -72,6 +72,7 @@
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 static struct rte_eth_dev_data *rte_eth_dev_data;
+static uint8_t eth_dev_last_created_port;
 static uint8_t nb_ports;
 

[...]

Quoted 23 lines
lib/librte_ether/rte_ethdev.c +3 -9
-
 /* attach the new device, then store port_id of the device */
 int
 rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
+	int current = eth_dev_last_created_port;
+	char *name = NULL;
+	char *args = NULL;
 
 	if ((devargs == NULL) || (port_id == NULL)) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	if (eal_parse_pci_DomBDF(devargs, &addr) == 0) {
-		ret = rte_eth_dev_attach_pdev(&addr, port_id);
-		if (ret < 0)
-			goto err;
-	} else {
-		ret = rte_eth_dev_attach_vdev(devargs, port_id);
-		if (ret < 0)

lib/librte_ether/rte_ethdev.c rte_eth_dev_is_detachable(uint8_t port_id) · line 443

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +9 -1
-			goto err;
+	/* parse devargs, then retrieve device name and args */
+	if (rte_eal_parse_devargs_str(devargs, &name, &args))
+		goto err;
+
+	ret = rte_eal_dev_attach(name, args);
+	if (ret < 0)
+		goto err;
+
+	/* no point looking at eth_dev_last_created_port if no port exists */  

I am not sure about this comment. What is "no point"?

Quoted 6 lines
Quoted 2 lines

Isn't this also a potential bug? (Like the one below.) How could it happen there is no port after a successful attach?

Yes, even searching through code path I couldn't find a positive case where control would reach here without nb_ports>0. Though, i am not sure if some rough application attempts to mix-up calls - and that, in my opinion, is not worth checking. Should I remove it?

At least a loud log might be helpful. If there is really no path to reach this point, I'd put RTE_VERIFY here.

Quoted 14 lines
Quoted 13 lines

lib/librte_ether/rte_ethdev.c rte_eth_dev_is_detachable(uint8_t port_id) · line 452

Quoted 11 lines
lib/librte_ether/rte_ethdev.c +9 -0
+	if (!nb_ports) {
+		ret = -1;
+		goto err;
+	}
+	/* if nothing happened, there is a bug here, since some driver told us
+	 * it did attach a device, but did not create a port */
+	if (current == eth_dev_last_created_port) {
+		ret = -1;
+		goto err;  

Should we log this? Or call some kind panic?

Quoted 1 line

I will place a log because applications should have a chance to ignore a device which cannot be attached for whatever reason.

OK, we just should shout loudly if it means a bug...

[...]

Signature · 4 lines
   Jan Viktorin                  E-mail: [email protected]
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic
#175 lore raw

PATCH v6 17/17 ethdev: get rid of device type

In reply to Shreyansh Jain

Now that hotplug has been moved to eal, there is no reason to keep the device type in this layer.

---
 app/test/virtual_pmd.c                    |  2 +-
 drivers/net/af_packet/rte_eth_af_packet.c |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c    |  2 +-
 drivers/net/cxgbe/cxgbe_main.c            |  2 +-
 drivers/net/mlx4/mlx4.c                   |  2 +-
 drivers/net/mlx5/mlx5.c                   |  2 +-
 drivers/net/mpipe/mpipe_tilegx.c          |  2 +-
 drivers/net/null/rte_eth_null.c           |  2 +-
 drivers/net/pcap/rte_eth_pcap.c           |  2 +-
 drivers/net/ring/rte_eth_ring.c           |  2 +-
 drivers/net/vhost/rte_eth_vhost.c         |  2 +-
 drivers/net/virtio/virtio_user_ethdev.c   |  2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |  2 +-
 examples/ip_pipeline/init.c               | 22 ----------------------
 lib/librte_ether/rte_ethdev.c             |  5 ++---
 lib/librte_ether/rte_ethdev.h             | 15 +--------------
 16 files changed, 16 insertions(+), 52 deletions(-)
app/test/virtual_pmd.c +1 -1
index b4bd2f2..8a1f0d0 100644
@@ -581,7 +581,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 		goto err;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto err;
 
drivers/net/af_packet/rte_eth_af_packet.c +1 -1
index f795566..d629ee3 100644
@@ -666,7 +666,7 @@ rte_pmd_init_internals(const char *name,
 	}
 
 	/* reserve an ethdev entry */
-	*eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	*eth_dev = rte_eth_dev_allocate(name);
 	if (*eth_dev == NULL)
 		goto error;
 
drivers/net/bonding/rte_eth_bond_api.c +1 -1
index 203ebe9..8514652 100644
@@ -189,7 +189,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	}
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
 		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
drivers/net/cxgbe/cxgbe_main.c +1 -1
index ceaf5ab..922155b 100644
@@ -1150,7 +1150,7 @@ int cxgbe_probe(struct adapter *adapter)
 		 */
 
 		/* reserve an ethdev entry */
-		pi->eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+		pi->eth_dev = rte_eth_dev_allocate(name);
 		if (!pi->eth_dev)
 			goto out_free;
 
drivers/net/mlx4/mlx4.c +1 -1
index 2bed4de..b333ad6 100644
@@ -5803,7 +5803,7 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
 			snprintf(name, sizeof(name), "%s port %u",
 				 ibv_get_device_name(ibv_dev), port);
-			eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+			eth_dev = rte_eth_dev_allocate(name);
 		}
 		if (eth_dev == NULL) {
 			ERROR("can not allocate rte ethdev");
drivers/net/mlx5/mlx5.c +1 -1
index 3658769..ebad7cb 100644
@@ -617,7 +617,7 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
 			snprintf(name, sizeof(name), "%s port %u",
 				 ibv_get_device_name(ibv_dev), port);
-			eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+			eth_dev = rte_eth_dev_allocate(name);
 		}
 		if (eth_dev == NULL) {
 			ERROR("can not allocate rte ethdev");
drivers/net/mpipe/mpipe_tilegx.c +1 -1
index 93f8730..c0d0e3b 100644
@@ -1587,7 +1587,7 @@ rte_pmd_mpipe_devinit(const char *ifname,
 		return -ENODEV;
 	}
 
-	eth_dev = rte_eth_dev_allocate(ifname, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(ifname);
 	if (!eth_dev) {
 		RTE_LOG(ERR, PMD, "%s: Failed to allocate device.\n", ifname);
 		rte_free(priv);
drivers/net/null/rte_eth_null.c +1 -1
index 7a24884..ce49945 100644
@@ -517,7 +517,7 @@ eth_dev_null_create(const char *name,
 		goto error;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto error;
 
drivers/net/pcap/rte_eth_pcap.c +1 -1
index 7e213eb..7fbc60e 100644
@@ -822,7 +822,7 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 		goto error;
 
 	/* reserve an ethdev entry */
-	*eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	*eth_dev = rte_eth_dev_allocate(name);
 	if (*eth_dev == NULL)
 		goto error;
 
drivers/net/ring/rte_eth_ring.c +1 -1
index a7048c7..5690dcd 100644
@@ -303,7 +303,7 @@ do_eth_dev_ring_create(const char *name,
 	}
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
 		rte_errno = ENOSPC;
 		goto error;
drivers/net/vhost/rte_eth_vhost.c +1 -1
index 7539cd4..2bb761b 100644
@@ -714,7 +714,7 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
 		goto error;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto error;
 
drivers/net/virtio/virtio_user_ethdev.c +1 -1
index 782d7d3..17d5848 100644
@@ -277,7 +277,7 @@ virtio_user_eth_dev_alloc(const char *name)
 	struct virtio_hw *hw;
 	struct virtio_user_dev *dev;
 
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (!eth_dev) {
 		PMD_INIT_LOG(ERR, "cannot alloc rte_eth_dev");
 		return NULL;
drivers/net/xenvirt/rte_eth_xenvirt.c +1 -1
index 99f6cc8..6b15381 100644
@@ -654,7 +654,7 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 		goto err;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto err;
 
examples/ip_pipeline/init.c +0 -22
index cd167f6..0dbc332 100644
@@ -606,29 +606,12 @@ app_link_set_tcp_syn_filter(struct app_params *app, struct app_link_params *cp)
 	}
 }
 
-static int
-app_link_is_virtual(struct app_link_params *p)
-{
-	uint32_t pmd_id = p->pmd_id;
-	struct rte_eth_dev *dev = &rte_eth_devices[pmd_id];
-
-	if (dev->dev_type == RTE_ETH_DEV_VIRTUAL)
-		return 1;
-
-	return 0;
-}
-
 void
 app_link_up_internal(struct app_params *app, struct app_link_params *cp)
 {
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 1;
-		return;
-	}
-
 	/* For each link, add filters for IP of current link */
 	if (cp->ip != 0) {
 		for (i = 0; i < app->n_links; i++) {
@@ -736,11 +719,6 @@ app_link_down_internal(struct app_params *app, struct app_link_params *cp)
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 0;
-		return;
-	}
-
 	/* PMD link down */
 	status = rte_eth_dev_set_link_down(cp->pmd_id);
 	if (status < 0)
lib/librte_ether/rte_ethdev.c +2 -3
index 8d14fd7..58e174e 100644
@@ -191,7 +191,7 @@ rte_eth_dev_find_free_port(void)
 }
 
 struct rte_eth_dev *
-rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
+rte_eth_dev_allocate(const char *name)
 {
 	uint8_t port_id;
 	struct rte_eth_dev *eth_dev;
@@ -216,7 +216,6 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
 	eth_dev->data->port_id = port_id;
 	eth_dev->attached = DEV_ATTACHED;
-	eth_dev->dev_type = type;
 	eth_dev_last_created_port = port_id;
 	nb_ports++;
 	return eth_dev;
@@ -248,7 +247,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
 	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
 			sizeof(ethdev_name));
 
-	eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
+	eth_dev = rte_eth_dev_allocate(ethdev_name);
 	if (eth_dev == NULL)
 		return -ENOMEM;
 
lib/librte_ether/rte_ethdev.h +1 -14
index d2718b5..f5bee39 100644
@@ -1603,17 +1603,6 @@ struct rte_eth_rxtx_callback {
 };
 
 /**
- * The eth device type.
- */
-enum rte_eth_dev_type {
-	RTE_ETH_DEV_UNKNOWN,	/**< unknown device type */
-	RTE_ETH_DEV_PCI,
-		/**< Physical function and Virtual function of PCI devices */
-	RTE_ETH_DEV_VIRTUAL,	/**< non hardware device */
-	RTE_ETH_DEV_MAX		/**< max value of this enum */
-};
-
-/**
  * @internal
  * The generic data structure associated with each ethernet device.
  *
@@ -1643,7 +1632,6 @@ struct rte_eth_dev {
 	 */
 	struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
 	uint8_t attached; /**< Flag indicating the port is attached */
-	enum rte_eth_dev_type dev_type; /**< Flag indicating the device type */
 } __rte_cache_aligned;
 
 struct rte_eth_dev_sriov {
@@ -1756,8 +1744,7 @@ struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(const char *name,
-		enum rte_eth_dev_type type);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
 
 /**
  * @internal
Signature · 1 line
2.7.4
#176 lore raw

Re: [PATCH v6 17/17] ethdev: get rid of device type

Quoted 24 lines · On Tue, 12 Jul 2016 11:31:22 +0530 Shreyansh Jain <[email protected]>…

Now that hotplug has been moved to eal, there is no reason to keep the device type in this layer.

---
 app/test/virtual_pmd.c                    |  2 +-
 drivers/net/af_packet/rte_eth_af_packet.c |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c    |  2 +-
 drivers/net/cxgbe/cxgbe_main.c            |  2 +-
 drivers/net/mlx4/mlx4.c                   |  2 +-
 drivers/net/mlx5/mlx5.c                   |  2 +-
 drivers/net/mpipe/mpipe_tilegx.c          |  2 +-
 drivers/net/null/rte_eth_null.c           |  2 +-
 drivers/net/pcap/rte_eth_pcap.c           |  2 +-
 drivers/net/ring/rte_eth_ring.c           |  2 +-
 drivers/net/vhost/rte_eth_vhost.c         |  2 +-
 drivers/net/virtio/virtio_user_ethdev.c   |  2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |  2 +-
 examples/ip_pipeline/init.c               | 22 ----------------------
 lib/librte_ether/rte_ethdev.c             |  5 ++---
 lib/librte_ether/rte_ethdev.h             | 15 +--------------
 16 files changed, 16 insertions(+), 52 deletions(-)

[...]

Quoted 28 lines
examples/ip_pipeline/init.c +0 -17
-static int
-app_link_is_virtual(struct app_link_params *p)
-{
-	uint32_t pmd_id = p->pmd_id;
-	struct rte_eth_dev *dev = &rte_eth_devices[pmd_id];
-
-	if (dev->dev_type == RTE_ETH_DEV_VIRTUAL)
-		return 1;
-
-	return 0;
-}
-
 void
 app_link_up_internal(struct app_params *app, struct app_link_params *cp)
 {
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 1;
-		return;
-	}
-
 	/* For each link, add filters for IP of current link */
 	if (cp->ip != 0) {
 		for (i = 0; i < app->n_links; i++) {

examples/ip_pipeline/init.c app_link_down_internal(struct app_params *app, struct app_link_params *cp) · line 722

Quoted 9 lines
examples/ip_pipeline/init.c +0 -5
@@ -736,11 +719,6 @@ app_link_down_internal(struct app_params *app, struct app_link_params *cp)
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 0;
-		return;
-	}
-
 	/* PMD link down */

I understand that app_link_is_virtual is useless. However, it changes semantics. What is the behaviour of the app_link_up_internal after this change?

Quoted 2 lines
examples/ip_pipeline/init.c +0 -0
 	status = rte_eth_dev_set_link_down(cp->pmd_id);
 	if (status < 0)

[...]

#177 lore raw

v7 cover Prepare for rte_device / rte_driver

In reply to Shreyansh Jain

* Original patch series is from David Marchand [1], [2].
* Link with patch series [4] from Jan Viktorin for a more complete picture of proposed EAL device heirarchy changes.
* This might not be in-sync with pmdinfogen as PMD_REGISTER_DRIVER is removed [7].

David created the original patchset based on the discussions on list [3]. Being a large piece of work, this patchset introduces first level of changes for generalizing the driver-device relationship for supporting hotplug.

Overview of this work as per David [3], as well as notes from Thomas [9] & Jan:
- pdev -> PCI registeration using helpers (introduced in this series)
- removal of eth/crypto driver registeration callbacks. These are now handled by PCI registeration helpers (this patch)
- rte_device=>pci/vdev device heirarchy (by this [4] series)
- removal of PMD_PDEV type (this patch) and PMD_VDEV (by this [4] series)
- Support for hotplugging

This patchset is based on master (b0a1419)

[1] http://dpdk.org/ml/archives/dev/2016-January/032387.html
[2] http://dpdk.org/ml/archives/dev/2016-April/037686.html
[3] http://dpdk.org/ml/archives/dev/2016-January/031390.html
[4] http://dpdk.org/ml/archives/dev/2016-July/043645.html
[5] http://dpdk.org/ml/archives/dev/2016-June/042439.html
[6] http://dpdk.org/ml/archives/dev/2016-June/042444.html
[7] http://dpdk.org/ml/archives/dev/2016-July/043172.html
[8] http://dpdk.org/ml/archives/dev/2016-July/044004.html
[9] http://dpdk.org/ml/archives/dev/2016-July/044086.html

Changes since v6:
- rebase over 16.07 (b0a1419)
- DRIVER_REGISTER_PCI macro is now passed pci_drv rather than drv
- review comments regarding missing information in log messages
- new API additions to 16.11 map objects
- review comment in [5] and [7] are not included in this series.

Changes since v5:
- Rebase over master (11c5e45d8)
- Rename RTE_EAL_PCI_REGISTER helper macro to DRIVER_REGISTER_PCI to be in sync with DRIVER_REGISTER_PCI_TABLE. [Probably, in future, both can be merged]
- Modifications to bnxt and thunderx driver PMD registeration files for using the simplified PCI device registeration helper macro

Changes since v4:
- Fix compilation issue after rebase on HEAD (913154e) in previous series
- Retain rte_eth_dev_get_port_by_name and rte_eth_dev_get_name_by_port which were removed by previous patchset. These are being used by pdump library

Changes since v3:
- rebase over HEAD (913154e)
- Update arguments to RTE_EAL_PCI_REGISTER macro as per Jan's suggestion
- modify qede driver to use RTE_EAL_PCI_REGISTER
- Argument check in hotplug functions

Changes since v2:
- rebase over HEAD (d76c193)
- Move SYSFS_PCI_DRIVERS macro to rte_pci.h to avoid compilation issue

Changes since v1:
- rebased on HEAD, new drivers should be okay
- patches have been split into smaller pieces
- RTE_INIT macro has been added, but in the end, I am not sure it is useful
- device type has been removed from ethdev, as it was used only by hotplug
- getting rid of pmd type in eal patch (patch 5 of initial series) has been dropped for now, we can do this once vdev drivers have been converted

David Marchand, Shreyansh Jain (17):
pci: no need for dynamic tailq init
crypto: no need for a crypto pmd type
drivers: align pci driver definitions
eal: remove duplicate function declaration
eal: introduce init macros
crypto: export init/uninit common wrappers for pci drivers
ethdev: export init/uninit common wrappers for pci drivers
drivers: convert all pdev drivers as pci drivers
crypto: get rid of crypto driver register callback
ethdev: get rid of eth driver register callback eal/linux: move back interrupt thread init before setting affinity
pci: add a helper for device name
pci: add a helper to update a device
ethdev: do not scan all pci devices on attach
eal: add hotplug operations for pci and vdev
ethdev: convert to eal hotplug
ethdev: get rid of device type

 app/test/virtual_pmd.c                          |   2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c          |  18 +-
 drivers/net/af_packet/rte_eth_af_packet.c       |   2 +-
 drivers/net/bnx2x/bnx2x_ethdev.c                |  34 +--
 drivers/net/bnxt/bnxt_ethdev.c                  |  16 +-
 drivers/net/bonding/rte_eth_bond_api.c          |   2 +-
 drivers/net/cxgbe/cxgbe_ethdev.c                |  24 +--
 drivers/net/cxgbe/cxgbe_main.c                  |   2 +-
 drivers/net/e1000/em_ethdev.c                   |  16 +-
 drivers/net/e1000/igb_ethdev.c                  |  39 +---
 drivers/net/ena/ena_ethdev.c                    |  19 +-
 drivers/net/enic/enic_ethdev.c                  |  23 +-
 drivers/net/fm10k/fm10k_ethdev.c                |  23 +-
 drivers/net/i40e/i40e_ethdev.c                  |  24 +--
 drivers/net/i40e/i40e_ethdev_vf.c               |  25 +--
 drivers/net/ixgbe/ixgbe_ethdev.c                |  46 +---
 drivers/net/mlx4/mlx4.c                         |  17 +-
 drivers/net/mlx5/mlx5.c                         |  16 +-
 drivers/net/mpipe/mpipe_tilegx.c                |   2 +-
 drivers/net/nfp/nfp_net.c                       |  23 +-
 drivers/net/null/rte_eth_null.c                 |   2 +-
 drivers/net/pcap/rte_eth_pcap.c                 |   2 +-
 drivers/net/qede/qede_ethdev.c                  |  40 +---
 drivers/net/ring/rte_eth_ring.c                 |   2 +-
 drivers/net/szedata2/rte_eth_szedata2.c         |  24 +--
 drivers/net/thunderx/nicvf_ethdev.c             |  20 +-
 drivers/net/vhost/rte_eth_vhost.c               |   2 +-
 drivers/net/virtio/virtio_ethdev.c              |  25 +--
 drivers/net/virtio/virtio_user_ethdev.c         |   2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c            |  23 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c           |   2 +-
 examples/ip_pipeline/init.c                     |  22 --
 lib/librte_cryptodev/rte_cryptodev.c            |  67 ++----
 lib/librte_cryptodev/rte_cryptodev.h            |   2 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h        |  45 ++--
 lib/librte_cryptodev/rte_cryptodev_version.map  |   8 +-
 lib/librte_eal/bsdapp/eal/eal_pci.c             |  52 ++++-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   7 +
 lib/librte_eal/common/eal_common_dev.c          |  48 +++++
 lib/librte_eal/common/eal_common_pci.c          |  17 +-
 lib/librte_eal/common/eal_private.h             |  20 +-
 lib/librte_eal/common/include/rte_dev.h         |  30 ++-
 lib/librte_eal/common/include/rte_eal.h         |   3 +
 lib/librte_eal/common/include/rte_pci.h         |  35 +++
 lib/librte_eal/common/include/rte_tailq.h       |   4 +-
 lib/librte_eal/linuxapp/eal/eal.c               |   7 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c           |  16 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   7 +
 lib/librte_ether/rte_ethdev.c                   | 272 ++++--------------------
 lib/librte_ether/rte_ethdev.h                   |  40 ++--
 lib/librte_ether/rte_ether_version.map          |   9 +
 51 files changed, 415 insertions(+), 813 deletions(-)
Signature · 1 line
2.7.4
#178 lore raw

PATCH v7 1/17 pci: no need for dynamic tailq init

These lists can be initialized once and for all at build time. With this, those lists are only manipulated in a common place (and we could even make them private).

A nice side effect is that pci drivers can now register in constructors.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c    | 3 ---
 lib/librte_eal/common/eal_common_pci.c | 6 ++++--
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 3 ---
 3 files changed, 4 insertions(+), 8 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +0 -3
index 374b68f..a73cbb0 100644
@@ -623,9 +623,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 int
 rte_eal_pci_init(void)
 {
-	TAILQ_INIT(&pci_driver_list);
-	TAILQ_INIT(&pci_device_list);
-
 	/* for debug purposes, PCI can be disabled */
 	if (internal_config.no_pci)
 		return 0;
lib/librte_eal/common/eal_common_pci.c +4 -2
index 7248c38..6a0f6ac 100644
@@ -82,8 +82,10 @@
 
 #include "eal_private.h"
 
-struct pci_driver_list pci_driver_list;
-struct pci_device_list pci_device_list;
+struct pci_driver_list pci_driver_list =
+	TAILQ_HEAD_INITIALIZER(pci_driver_list);
+struct pci_device_list pci_device_list =
+	TAILQ_HEAD_INITIALIZER(pci_device_list);
 
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 
lib/librte_eal/linuxapp/eal/eal_pci.c +0 -3
index cd9de7c..f0215ee 100644
@@ -743,9 +743,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 int
 rte_eal_pci_init(void)
 {
-	TAILQ_INIT(&pci_driver_list);
-	TAILQ_INIT(&pci_device_list);
-
 	/* for debug purposes, PCI can be disabled */
 	if (internal_config.no_pci)
 		return 0;
Signature · 1 line
2.7.4
#179 lore raw

PATCH v7 2/17 crypto: no need for a crypto pmd type

In reply to Shreyansh Jain

This information is not used and just adds noise.

---
 lib/librte_cryptodev/rte_cryptodev.c     | 8 +++-----
 lib/librte_cryptodev/rte_cryptodev.h     | 2 --
 lib/librte_cryptodev/rte_cryptodev_pmd.h | 3 +--
 3 files changed, 4 insertions(+), 9 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +3 -5
index fc4123b..6434894 100644
@@ -319,7 +319,7 @@ rte_cryptodev_find_free_device_index(void)
 }
 
 struct rte_cryptodev *
-rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id)
+rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 {
 	struct rte_cryptodev *cryptodev;
 	uint8_t dev_id;
@@ -358,7 +358,6 @@ rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id)
 		cryptodev->data->dev_started = 0;
 
 		cryptodev->attached = RTE_CRYPTODEV_ATTACHED;
-		cryptodev->pmd_type = type;
 
 		cryptodev_globals.nb_devs++;
 	}
@@ -407,7 +406,7 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 	struct rte_cryptodev *cryptodev;
 
 	/* allocate device structure */
-	cryptodev = rte_cryptodev_pmd_allocate(name, PMD_VDEV, socket_id);
+	cryptodev = rte_cryptodev_pmd_allocate(name, socket_id);
 	if (cryptodev == NULL)
 		return NULL;
 
@@ -449,8 +448,7 @@ rte_cryptodev_init(struct rte_pci_driver *pci_drv,
 	rte_cryptodev_create_unique_device_name(cryptodev_name,
 			sizeof(cryptodev_name), pci_dev);
 
-	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, PMD_PDEV,
-			rte_socket_id());
+	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 	if (cryptodev == NULL)
 		return -ENOMEM;
 
lib/librte_cryptodev/rte_cryptodev.h +0 -2
index affbdec..13f46e4 100644
@@ -613,8 +613,6 @@ struct rte_cryptodev {
 
 	enum rte_cryptodev_type dev_type;
 	/**< Crypto device type */
-	enum pmd_type pmd_type;
-	/**< PMD type - PDEV / VDEV */
 
 	struct rte_cryptodev_cb_list link_intr_cbs;
 	/**< User application callback for interrupts if present */
lib/librte_cryptodev/rte_cryptodev_pmd.h +1 -2
index 7d049ea..c977c61 100644
@@ -454,13 +454,12 @@ struct rte_cryptodev_ops {
  * to that slot for the driver to use.
  *
  * @param	name		Unique identifier name for each device
- * @param	type		Device type of this Crypto device
  * @param	socket_id	Socket to allocate resources on.
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
 struct rte_cryptodev *
-rte_cryptodev_pmd_allocate(const char *name, enum pmd_type type, int socket_id);
+rte_cryptodev_pmd_allocate(const char *name, int socket_id);
 
 /**
  * Creates a new virtual crypto device and returns the pointer
Signature · 1 line
2.7.4
#180 lore raw

PATCH v7 3/17 drivers: align pci driver definitions

In reply to Shreyansh Jain

Pure coding style, but it might make it easier later if we want to move fields in rte_cryptodev_driver and eth_driver structures.

---
 drivers/crypto/qat/rte_qat_cryptodev.c | 2 +-
 drivers/net/ena/ena_ethdev.c           | 2 +-
 drivers/net/nfp/nfp_net.c              | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/qat/rte_qat_cryptodev.c +1 -1
index 82ab047..1e9e0ba 100644
@@ -113,7 +113,7 @@ crypto_qat_dev_init(__attribute__((unused)) struct rte_cryptodev_driver *crypto_
 }
 
 static struct rte_cryptodev_driver rte_qat_pmd = {
-	{
+	.pci_drv = {
 		.id_table = pci_id_qat_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
 	},
drivers/net/ena/ena_ethdev.c +1 -1
index ac0803d..9418d50 100644
@@ -1685,7 +1685,7 @@ static uint16_t eth_ena_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 }
 
 static struct eth_driver rte_ena_pmd = {
-	{
+	.pci_drv = {
 		.name = "rte_ena_pmd",
 		.id_table = pci_id_ena_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
drivers/net/nfp/nfp_net.c +1 -1
index 82e3e4e..99a258a 100644
@@ -2459,7 +2459,7 @@ static struct rte_pci_id pci_id_nfp_net_map[] = {
 };
 
 static struct eth_driver rte_nfp_net_pmd = {
-	{
+	.pci_drv = {
 		.name = "rte_nfp_net_pmd",
 		.id_table = pci_id_nfp_net_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
Signature · 1 line
2.7.4
#181 lore raw

PATCH v7 4/17 eal: remove duplicate function declaration

In reply to Shreyansh Jain

rte_eal_dev_init is declared in both eal_private.h and rte_dev.h since its introduction.
This function has been exported in ABI, so remove it from eal_private.h

Fixes e57f20e05177 ("eal: make vdev init path generic for both virtual and pci devices")
---
 lib/librte_eal/common/eal_private.h | 7 -------
 lib/librte_eal/linuxapp/eal/eal.c   | 1 +
 2 files changed, 1 insertion(+), 7 deletions(-)
lib/librte_eal/common/eal_private.h +0 -7
index 857dc3e..06a68f6 100644
@@ -259,13 +259,6 @@ int rte_eal_intr_init(void);
 int rte_eal_alarm_init(void);
 
 /**
- * This function initialises any virtual devices
- *
- * This function is private to the EAL.
- */
-int rte_eal_dev_init(void);
-
-/**
  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
  * etc.) loaded.
  *
lib/librte_eal/linuxapp/eal/eal.c +1 -0
index 3fb2188..fe9c704 100644
@@ -70,6 +70,7 @@
 #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>
Signature · 1 line
2.7.4
#182 lore raw

PATCH v7 5/17 eal: introduce init macros

In reply to Shreyansh Jain

Introduce a RTE_INIT macro used to mark an init function as a constructor. Current eal macros have been converted to use this (no functional impact). DRIVER_REGISTER_PCI is added as a helper for pci drivers.

---
 lib/librte_eal/common/include/rte_dev.h   | 4 ++--
 lib/librte_eal/common/include/rte_eal.h   | 3 +++
 lib/librte_eal/common/include/rte_pci.h   | 9 +++++++++
 lib/librte_eal/common/include/rte_tailq.h | 4 ++--
 4 files changed, 16 insertions(+), 4 deletions(-)
lib/librte_eal/common/include/rte_dev.h +2 -2
index 95789f9..994650b 100644
@@ -185,8 +185,8 @@ static const char DRIVER_EXPORT_NAME_ARRAY(this_pmd_name, idx) \
 __attribute__((used)) = RTE_STR(name)
 
 #define PMD_REGISTER_DRIVER(drv, nm)\
-void devinitfn_ ##drv(void);\
-void __attribute__((constructor, used)) devinitfn_ ##drv(void)\
+RTE_INIT(devinitfn_ ##drv);\
+static void devinitfn_ ##drv(void)\
 {\
 	(drv).name = RTE_STR(nm);\
 	rte_eal_driver_register(&drv);\
lib/librte_eal/common/include/rte_eal.h +3 -0
index a71d6f5..186f3c6 100644
@@ -252,6 +252,9 @@ static inline int rte_gettid(void)
 	return RTE_PER_LCORE(_thread_id);
 }
 
+#define RTE_INIT(func) \
+static void __attribute__((constructor, used)) func(void)
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/common/include/rte_pci.h +9 -0
index fa74962..ffeb94c 100644
@@ -470,6 +470,15 @@ void rte_eal_pci_dump(FILE *f);
  */
 void rte_eal_pci_register(struct rte_pci_driver *driver);
 
+/** Helper for PCI device registeration from driver (eth, crypto) instance */
+#define DRIVER_REGISTER_PCI(nm, pci_drv) \
+RTE_INIT(pciinitfn_ ##nm); \
+static void pciinitfn_ ##nm(void) \
+{ \
+	(pci_drv).name = RTE_STR(nm);\
+	rte_eal_pci_register(&pci_drv); \
+}
+
 /**
  * Unregister a PCI driver.
  *
lib/librte_eal/common/include/rte_tailq.h +2 -2
index cc3c0f1..cc386e4 100644
@@ -148,8 +148,8 @@ struct rte_tailq_head *rte_eal_tailq_lookup(const char *name);
 int rte_eal_tailq_register(struct rte_tailq_elem *t);
 
 #define EAL_REGISTER_TAILQ(t) \
-void tailqinitfn_ ##t(void); \
-void __attribute__((constructor, used)) tailqinitfn_ ##t(void) \
+RTE_INIT(tailqinitfn_ ##t); \
+static void tailqinitfn_ ##t(void) \
 { \
 	if (rte_eal_tailq_register(&t) < 0) \
 		rte_panic("Cannot initialize tailq: %s\n", t.name); \
Signature · 1 line
2.7.4
#183 lore raw

PATCH v7 6/17 crypto: export init/uninit common wrappers for pci drivers

In reply to Shreyansh Jain

Preparing for getting rid of rte_cryptodev_driver, here are two wrappers that can be used by pci drivers that assume a 1 to 1 association between pci resource and upper interface.

---
 lib/librte_cryptodev/rte_cryptodev.c           | 16 ++++++++--------
 lib/librte_cryptodev/rte_cryptodev_pmd.h       | 12 ++++++++++++
 lib/librte_cryptodev/rte_cryptodev_version.map |  7 +++++++
 3 files changed, 27 insertions(+), 8 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +8 -8
index 6434894..b1e82b6 100644
@@ -429,9 +429,9 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 	return cryptodev;
 }
 
-static int
-rte_cryptodev_init(struct rte_pci_driver *pci_drv,
-		struct rte_pci_device *pci_dev)
+int
+rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
+			struct rte_pci_device *pci_dev)
 {
 	struct rte_cryptodev_driver *cryptodrv;
 	struct rte_cryptodev *cryptodev;
@@ -490,8 +490,8 @@ rte_cryptodev_init(struct rte_pci_driver *pci_drv,
 	return -ENXIO;
 }
 
-static int
-rte_cryptodev_uninit(struct rte_pci_device *pci_dev)
+int
+rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 {
 	const struct rte_cryptodev_driver *cryptodrv;
 	struct rte_cryptodev *cryptodev;
@@ -539,15 +539,15 @@ 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,
+		return rte_cryptodev_pci_probe((struct rte_pci_driver *)cryptodrv,
 				NULL);
 
 	/*
 	 * Register PCI driver for physical device intialisation during
 	 * PCI probing
 	 */
-	cryptodrv->pci_drv.devinit = rte_cryptodev_init;
-	cryptodrv->pci_drv.devuninit = rte_cryptodev_uninit;
+	cryptodrv->pci_drv.devinit = rte_cryptodev_pci_probe;
+	cryptodrv->pci_drv.devuninit = rte_cryptodev_pci_remove;
 
 	rte_eal_pci_register(&cryptodrv->pci_drv);
 
lib/librte_cryptodev/rte_cryptodev_pmd.h +12 -0
index c977c61..3fb7c7c 100644
@@ -534,6 +534,18 @@ rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
 void rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev,
 				enum rte_cryptodev_event_type event);
 
+/**
+ * Wrapper for use by pci drivers as a .devinit function to attach to a crypto
+ * interface.
+ */
+int rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
+			    struct rte_pci_device *pci_dev);
+
+/**
+ * Wrapper for use by pci drivers as a .devuninit function to detach a crypto
+ * interface.
+ */
+int rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev);
 
 #ifdef __cplusplus
 }
lib/librte_cryptodev/rte_cryptodev_version.map +7 -0
index a08fd20..1fc0d57 100644
@@ -39,3 +39,10 @@ DPDK_16.07 {
 	rte_cryptodev_parse_vdev_init_params;
 
 } DPDK_16.04;
+
+DPDK_16.11 {
+	global:
+
+	rte_cryptodev_pci_probe;
+	rte_cryptodev_pci_remove;
+} DPDK_16.07;
Signature · 1 line
2.7.4
#184 lore raw

PATCH v7 7/17 ethdev: export init/uninit common wrappers for pci drivers

In reply to Shreyansh Jain

Preparing for getting rid of eth_drv, here are two wrappers that can be used by pci drivers that assume a 1 to 1 association between pci resource and upper interface.

---
 lib/librte_ether/rte_ethdev.c          | 14 +++++++-------
 lib/librte_ether/rte_ethdev.h          | 13 +++++++++++++
 lib/librte_ether/rte_ether_version.map |  9 +++++++++
 3 files changed, 29 insertions(+), 7 deletions(-)
lib/librte_ether/rte_ethdev.c +7 -7
index f62a9ec..8825219 100644
@@ -245,9 +245,9 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
-static int
-rte_eth_dev_init(struct rte_pci_driver *pci_drv,
-		 struct rte_pci_device *pci_dev)
+int
+rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
+		      struct rte_pci_device *pci_dev)
 {
 	struct eth_driver    *eth_drv;
 	struct rte_eth_dev *eth_dev;
@@ -299,8 +299,8 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 	return diag;
 }
 
-static int
-rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
+int
+rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 {
 	const struct eth_driver *eth_drv;
 	struct rte_eth_dev *eth_dev;
@@ -357,8 +357,8 @@ rte_eth_dev_uninit(struct rte_pci_device *pci_dev)
 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;
+	eth_drv->pci_drv.devinit = rte_eth_dev_pci_probe;
+	eth_drv->pci_drv.devuninit = rte_eth_dev_pci_remove;
 	rte_eal_pci_register(&eth_drv->pci_drv);
 }
 
lib/librte_ether/rte_ethdev.h +13 -0
index b0fe033..37d78bf 100644
@@ -4368,6 +4368,19 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id);
 int
 rte_eth_dev_get_name_by_port(uint8_t port_id, char *name);
 
+/**
+ * Wrapper for use by pci drivers as a .devinit function to attach to a ethdev
+ * interface.
+ */
+int rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
+			  struct rte_pci_device *pci_dev);
+
+/**
+ * Wrapper for use by pci drivers as a .devuninit function to detach a ethdev
+ * interface.
+ */
+int rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev);
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_ether/rte_ether_version.map +9 -0
index 45ddf44..17e7448 100644
@@ -138,4 +138,13 @@ DPDK_16.07 {
 	rte_eth_dev_get_name_by_port;
 	rte_eth_dev_get_port_by_name;
 	rte_eth_xstats_get_names;
+
 } DPDK_16.04;
+
+DPDK_16.11 {
+	global:
+
+	rte_eth_dev_pci_probe;
+	rte_eth_dev_pci_remove;
+
+} DPDK_16.07;
Signature · 1 line
2.7.4
#185 lore raw

PATCH v7 8/17 drivers: convert all pdev drivers as pci drivers

In reply to Shreyansh Jain

Simplify crypto and ethdev pci drivers init by using newly introduced init macros and helpers.
Those drivers then don't need to register as "rte_driver"s anymore.

Exceptions:
- virtio and mlx* use RTE_INIT directly as they have custom initialization steps.
- VDEV devices are not modified - they continue to use PMD_REGISTER_DRIVER.

---
 drivers/crypto/qat/rte_qat_cryptodev.c  | 16 +++---------
 drivers/net/bnx2x/bnx2x_ethdev.c        | 34 +++++-------------------
 drivers/net/bnxt/bnxt_ethdev.c          | 16 +++---------
 drivers/net/cxgbe/cxgbe_ethdev.c        | 24 +++--------------
 drivers/net/e1000/em_ethdev.c           | 16 +++---------
 drivers/net/e1000/igb_ethdev.c          | 39 +++++-----------------------
 drivers/net/ena/ena_ethdev.c            | 17 +++---------
 drivers/net/enic/enic_ethdev.c          | 23 +++--------------
 drivers/net/fm10k/fm10k_ethdev.c        | 23 +++--------------
 drivers/net/i40e/i40e_ethdev.c          | 24 +++--------------
 drivers/net/i40e/i40e_ethdev_vf.c       | 25 +++---------------
 drivers/net/ixgbe/ixgbe_ethdev.c        | 46 +++++----------------------------
 drivers/net/mlx4/mlx4.c                 | 15 +++--------
 drivers/net/mlx5/mlx5.c                 | 14 +++-------
 drivers/net/nfp/nfp_net.c               | 21 +++------------
 drivers/net/qede/qede_ethdev.c          | 40 ++++++----------------------
 drivers/net/szedata2/rte_eth_szedata2.c | 24 +++--------------
 drivers/net/thunderx/nicvf_ethdev.c     | 20 +++-----------
 drivers/net/virtio/virtio_ethdev.c      | 25 +++++-------------
 drivers/net/vmxnet3/vmxnet3_ethdev.c    | 23 +++--------------
 20 files changed, 78 insertions(+), 407 deletions(-)
drivers/crypto/qat/rte_qat_cryptodev.c +3 -13
index 1e9e0ba..b94af59 100644
@@ -116,23 +116,13 @@ static struct rte_cryptodev_driver rte_qat_pmd = {
 	.pci_drv = {
 		.id_table = pci_id_qat_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_cryptodev_pci_probe,
+		.devuninit = rte_cryptodev_pci_remove,
 	},
 	.cryptodev_init = crypto_qat_dev_init,
 	.dev_private_size = sizeof(struct qat_pmd_private),
 };
 
-static int
-rte_qat_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	return rte_cryptodev_pmd_driver_register(&rte_qat_pmd, PMD_PDEV);
-}
-
-static struct rte_driver pmd_qat_drv = {
-	.type = PMD_PDEV,
-	.init = rte_qat_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(pmd_qat_drv, CRYPTODEV_NAME_QAT_SYM_PMD);
+DRIVER_REGISTER_PCI(CRYPTODEV_NAME_QAT_SYM_PMD, rte_qat_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(CRYPTODEV_NAME_QAT_SYM_PMD, pci_id_qat_map);
 
drivers/net/bnx2x/bnx2x_ethdev.c +6 -28
index f3ab355..214b655 100644
@@ -621,6 +621,8 @@ static struct eth_driver rte_bnx2x_pmd = {
 		.name = "rte_bnx2x_pmd",
 		.id_table = pci_id_bnx2x_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_bnx2x_dev_init,
 	.dev_private_size = sizeof(struct bnx2x_softc),
@@ -634,38 +636,14 @@ static struct eth_driver rte_bnx2xvf_pmd = {
 		.name = "rte_bnx2xvf_pmd",
 		.id_table = pci_id_bnx2xvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_bnx2xvf_dev_init,
 	.dev_private_size = sizeof(struct bnx2x_softc),
 };
 
-static int rte_bnx2x_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_bnx2x_pmd);
-
-	return 0;
-}
-
-static int rte_bnx2xvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_bnx2xvf_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_bnx2x_driver = {
-	.type = PMD_PDEV,
-	.init = rte_bnx2x_pmd_init,
-};
-
-static struct rte_driver rte_bnx2xvf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_bnx2xvf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_bnx2x_driver, bnx2x);
+DRIVER_REGISTER_PCI(bnx2x, rte_bnx2x_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(bnx2x, pci_id_bnx2x_map);
-PMD_REGISTER_DRIVER(rte_bnx2xvf_driver, bnx2xvf);
+DRIVER_REGISTER_PCI(bnx2xvf, rte_bnx2xvf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(bnx2xvf, pci_id_bnx2xvf_map);
drivers/net/bnxt/bnxt_ethdev.c +3 -13
index 3795fac..28eb8b9 100644
@@ -1048,23 +1048,13 @@ static struct eth_driver bnxt_rte_pmd = {
 		    .name = "rte_" DRV_MODULE_NAME "_pmd",
 		    .id_table = bnxt_pci_id_map,
 		    .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		    .devinit = rte_eth_dev_pci_probe,
+		    .devuninit = rte_eth_dev_pci_remove,
 		    },
 	.eth_dev_init = bnxt_dev_init,
 	.eth_dev_uninit = bnxt_dev_uninit,
 	.dev_private_size = sizeof(struct bnxt),
 };
 
-static int bnxt_rte_pmd_init(const char *name, const char *params __rte_unused)
-{
-	RTE_LOG(INFO, PMD, "bnxt_rte_pmd_init() called for %s\n", name);
-	rte_eth_driver_register(&bnxt_rte_pmd);
-	return 0;
-}
-
-static struct rte_driver bnxt_pmd_drv = {
-	.type = PMD_PDEV,
-	.init = bnxt_rte_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(bnxt_pmd_drv, bnxt);
+DRIVER_REGISTER_PCI(bnxt, bnxt_rte_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(bnxt, bnxt_pci_id_map);
drivers/net/cxgbe/cxgbe_ethdev.c +3 -21
index 9208a61..431b06d 100644
@@ -1042,30 +1042,12 @@ static struct eth_driver rte_cxgbe_pmd = {
 		.name = "rte_cxgbe_pmd",
 		.id_table = cxgb4_pci_tbl,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_cxgbe_dev_init,
 	.dev_private_size = sizeof(struct port_info),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI CXGBE devices.
- */
-static int rte_cxgbe_pmd_init(const char *name __rte_unused,
-			      const char *params __rte_unused)
-{
-	CXGBE_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_cxgbe_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_cxgbe_driver = {
-	.type = PMD_PDEV,
-	.init = rte_cxgbe_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_cxgbe_driver, cxgb4);
+DRIVER_REGISTER_PCI(cxgb4, rte_cxgbe_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(cxgb4, cxgb4_pci_tbl);
-
drivers/net/e1000/em_ethdev.c +3 -13
index ad104ed..1281c8b 100644
@@ -395,6 +395,8 @@ static struct eth_driver rte_em_pmd = {
 		.id_table = pci_id_em_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_em_dev_init,
 	.eth_dev_uninit = eth_em_dev_uninit,
@@ -402,13 +404,6 @@ static struct eth_driver rte_em_pmd = {
 };
 
 static int
-rte_em_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_em_pmd);
-	return 0;
-}
-
-static int
 em_hw_init(struct e1000_hw *hw)
 {
 	int diag;
@@ -1799,10 +1794,5 @@ eth_em_set_mc_addr_list(struct rte_eth_dev *dev,
 	return 0;
 }
 
-struct rte_driver em_pmd_drv = {
-	.type = PMD_PDEV,
-	.init = rte_em_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(em_pmd_drv, em);
+DRIVER_REGISTER_PCI(em, rte_em_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(em, pci_id_em_map);
drivers/net/e1000/igb_ethdev.c +6 -33
index fbf4d09..6842eab 100644
@@ -1047,6 +1047,8 @@ static struct eth_driver rte_igb_pmd = {
 		.id_table = pci_id_igb_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_igb_dev_init,
 	.eth_dev_uninit = eth_igb_dev_uninit,
@@ -1061,19 +1063,14 @@ static struct eth_driver rte_igbvf_pmd = {
 		.name = "rte_igbvf_pmd",
 		.id_table = pci_id_igbvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_igbvf_dev_init,
 	.eth_dev_uninit = eth_igbvf_dev_uninit,
 	.dev_private_size = sizeof(struct e1000_adapter),
 };
 
-static int
-rte_igb_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_igb_pmd);
-	return 0;
-}
-
 static void
 igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
 {
@@ -1085,20 +1082,6 @@ igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
 	E1000_WRITE_REG(hw, E1000_RCTL, rctl);
 }
 
-/*
- * VF Driver initialization routine.
- * Invoked one at EAL init time.
- * Register itself as the [Virtual Poll Mode] Driver of PCI IGB devices.
- */
-static int
-rte_igbvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_igbvf_pmd);
-	return 0;
-}
-
 static int
 igb_check_mq_mode(struct rte_eth_dev *dev)
 {
@@ -5049,16 +5032,6 @@ eth_igb_set_eeprom(struct rte_eth_dev *dev,
 	return nvm->ops.write(hw,  first, length, data);
 }
 
-static struct rte_driver pmd_igb_drv = {
-	.type = PMD_PDEV,
-	.init = rte_igb_pmd_init,
-};
-
-static struct rte_driver pmd_igbvf_drv = {
-	.type = PMD_PDEV,
-	.init = rte_igbvf_pmd_init,
-};
-
 static int
 eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
 {
@@ -5220,7 +5193,7 @@ eth_igb_configure_msix_intr(struct rte_eth_dev *dev)
 	E1000_WRITE_FLUSH(hw);
 }
 
-PMD_REGISTER_DRIVER(pmd_igb_drv, igb);
+DRIVER_REGISTER_PCI(igb, rte_igb_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(igb, pci_id_igb_map);
-PMD_REGISTER_DRIVER(pmd_igbvf_drv, igbvf);
+DRIVER_REGISTER_PCI(igbvf, rte_igbvf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(igbvf, pci_id_igbvf_map);
drivers/net/ena/ena_ethdev.c +3 -14
index 9418d50..ee906d4 100644
@@ -1689,23 +1689,12 @@ static struct eth_driver rte_ena_pmd = {
 		.name = "rte_ena_pmd",
 		.id_table = pci_id_ena_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_ena_dev_init,
 	.dev_private_size = sizeof(struct ena_adapter),
 };
 
-static int
-rte_ena_pmd_init(const char *name __rte_unused,
-		 const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_ena_pmd);
-	return 0;
-};
-
-struct rte_driver ena_pmd_drv = {
-	.type = PMD_PDEV,
-	.init = rte_ena_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(ena_pmd_drv, ena);
+DRIVER_REGISTER_PCI(ena, rte_ena_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(ena, pci_id_ena_map);
drivers/net/enic/enic_ethdev.c +3 -20
index 47b07c9..59812d0 100644
@@ -616,29 +616,12 @@ static struct eth_driver rte_enic_pmd = {
 		.name = "rte_enic_pmd",
 		.id_table = pci_id_enic_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_enicpmd_dev_init,
 	.dev_private_size = sizeof(struct enic),
 };
 
-/* Driver initialization routine.
- * Invoked once at EAL init time.
- * Register as the [Poll Mode] Driver of Cisco ENIC device.
- */
-static int
-rte_enic_pmd_init(__rte_unused const char *name,
-	 __rte_unused const char *params)
-{
-	ENICPMD_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_enic_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_enic_driver = {
-	.type = PMD_PDEV,
-	.init = rte_enic_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_enic_driver, enic);
+DRIVER_REGISTER_PCI(enic, rte_enic_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(enic, pci_id_enic_map);
drivers/net/fm10k/fm10k_ethdev.c +3 -20
index 01f4a72..26cdc10 100644
@@ -3059,30 +3059,13 @@ static struct eth_driver rte_pmd_fm10k = {
 		.id_table = pci_id_fm10k_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_fm10k_dev_init,
 	.eth_dev_uninit = eth_fm10k_dev_uninit,
 	.dev_private_size = sizeof(struct fm10k_adapter),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI FM10K devices.
- */
-static int
-rte_pmd_fm10k_init(__rte_unused const char *name,
-	__rte_unused const char *params)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_pmd_fm10k);
-	return 0;
-}
-
-static struct rte_driver rte_fm10k_driver = {
-	.type = PMD_PDEV,
-	.init = rte_pmd_fm10k_init,
-};
-
-PMD_REGISTER_DRIVER(rte_fm10k_driver, fm10k);
+DRIVER_REGISTER_PCI(fm10k, rte_pmd_fm10k.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(fm10k, pci_id_fm10k_map);
drivers/net/i40e/i40e_ethdev.c +3 -21
index d0aeb70..dacaaea 100644
@@ -667,6 +667,8 @@ static struct eth_driver rte_i40e_pmd = {
 		.id_table = pci_id_i40e_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_i40e_dev_init,
 	.eth_dev_uninit = eth_i40e_dev_uninit,
@@ -701,27 +703,7 @@ rte_i40e_dev_atomic_write_link_status(struct rte_eth_dev *dev,
 	return 0;
 }
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI IXGBE devices.
- */
-static int
-rte_i40e_pmd_init(const char *name __rte_unused,
-		  const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	rte_eth_driver_register(&rte_i40e_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_i40e_driver = {
-	.type = PMD_PDEV,
-	.init = rte_i40e_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_i40e_driver, i40e);
+DRIVER_REGISTER_PCI(i40e, rte_i40e_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(i40e, pci_id_i40e_map);
 
 /*
drivers/net/i40e/i40e_ethdev_vf.c +3 -22
index a616ae0..4a745f9 100644
@@ -1557,34 +1557,15 @@ static struct eth_driver rte_i40evf_pmd = {
 		.name = "rte_i40evf_pmd",
 		.id_table = pci_id_i40evf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = i40evf_dev_init,
 	.eth_dev_uninit = i40evf_dev_uninit,
 	.dev_private_size = sizeof(struct i40e_adapter),
 };
 
-/*
- * VF Driver initialization routine.
- * Invoked one at EAL init time.
- * Register itself as the [Virtual Poll Mode] Driver of PCI Fortville devices.
- */
-static int
-rte_i40evf_pmd_init(const char *name __rte_unused,
-		    const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_i40evf_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_i40evf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_i40evf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_i40evf_driver, i40evf);
+DRIVER_REGISTER_PCI(i40evf, rte_i40evf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(i40evf, pci_id_i40evf_map);
 
 static int
drivers/net/ixgbe/ixgbe_ethdev.c +6 -40

69 lines not on this page · raw message

drivers/net/mlx4/mlx4.c +3 -12
index 304c846..2bed4de 100644
@@ -5922,12 +5922,10 @@ static struct eth_driver mlx4_driver = {
 /**
  * Driver initialization routine.
  */
-static int
-rte_mlx4_pmd_init(const char *name, const char *args)
+RTE_INIT(rte_mlx4_pmd_init);
+static void
+rte_mlx4_pmd_init(void)
 {
-	(void)name;
-	(void)args;
-
 	RTE_BUILD_BUG_ON(sizeof(wr_id_t) != sizeof(uint64_t));
 	/*
 	 * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
@@ -5938,13 +5936,6 @@ rte_mlx4_pmd_init(const char *name, const char *args)
 	setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
 	ibv_fork_init();
 	rte_eal_pci_register(&mlx4_driver.pci_drv);
-	return 0;
 }
 
-static struct rte_driver rte_mlx4_driver = {
-	.type = PMD_PDEV,
-	.init = rte_mlx4_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_mlx4_driver, mlx4);
 DRIVER_REGISTER_PCI_TABLE(mlx4, mlx4_pci_id_map);
drivers/net/mlx5/mlx5.c +3 -11
index d96a9af..3658769 100644
@@ -739,11 +739,10 @@ static struct eth_driver mlx5_driver = {
 /**
  * Driver initialization routine.
  */
-static int
-rte_mlx5_pmd_init(const char *name, const char *args)
+RTE_INIT(rte_mlx5_pmd_init);
+static void
+rte_mlx5_pmd_init(void)
 {
-	(void)name;
-	(void)args;
 	/*
 	 * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use
 	 * huge pages. Calling ibv_fork_init() during init allows
@@ -753,13 +752,6 @@ rte_mlx5_pmd_init(const char *name, const char *args)
 	setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
 	ibv_fork_init();
 	rte_eal_pci_register(&mlx5_driver.pci_drv);
-	return 0;
 }
 
-static struct rte_driver rte_mlx5_driver = {
-	.type = PMD_PDEV,
-	.init = rte_mlx5_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_mlx5_driver, mlx5);
 DRIVER_REGISTER_PCI_TABLE(mlx5, mlx5_pci_id_map);
drivers/net/nfp/nfp_net.c +3 -18
index 99a258a..cbaf219 100644
@@ -2464,29 +2464,14 @@ static struct eth_driver rte_nfp_net_pmd = {
 		.id_table = pci_id_nfp_net_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
 			     RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = nfp_net_init,
 	.dev_private_size = sizeof(struct nfp_net_adapter),
 };
 
-static int
-nfp_net_pmd_init(const char *name __rte_unused,
-		 const char *params __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	PMD_INIT_LOG(INFO, "librte_pmd_nfp_net version %s\n",
-		     NFP_NET_PMD_VERSION);
-
-	rte_eth_driver_register(&rte_nfp_net_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_nfp_net_driver = {
-	.type = PMD_PDEV,
-	.init = nfp_net_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_nfp_net_driver, nfp);
+DRIVER_REGISTER_PCI(nfp, rte_nfp_net_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(nfp, pci_id_nfp_net_map);
 
 /*
drivers/net/qede/qede_ethdev.c +8 -32
index 82e44b8..a92dd3b 100644
@@ -1482,7 +1482,9 @@ static struct eth_driver rte_qedevf_pmd = {
 		    .id_table = pci_id_qedevf_map,
 		    .drv_flags =
 		    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-		    },
+		    .devinit = rte_eth_dev_pci_probe,
+		    .devuninit = rte_eth_dev_pci_remove,
+		   },
 	.eth_dev_init = qedevf_eth_dev_init,
 	.eth_dev_uninit = qedevf_eth_dev_uninit,
 	.dev_private_size = sizeof(struct qede_dev),
@@ -1494,41 +1496,15 @@ static struct eth_driver rte_qede_pmd = {
 		    .id_table = pci_id_qede_map,
 		    .drv_flags =
 		    RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
-		    },
+		    .devinit = rte_eth_dev_pci_probe,
+		    .devuninit = rte_eth_dev_pci_remove,
+		   },
 	.eth_dev_init = qede_eth_dev_init,
 	.eth_dev_uninit = qede_eth_dev_uninit,
 	.dev_private_size = sizeof(struct qede_dev),
 };
 
-static int
-rte_qedevf_pmd_init(const char *name __rte_unused,
-		    const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_qedevf_pmd);
-
-	return 0;
-}
-
-static int
-rte_qede_pmd_init(const char *name __rte_unused,
-		  const char *params __rte_unused)
-{
-	rte_eth_driver_register(&rte_qede_pmd);
-
-	return 0;
-}
-
-static struct rte_driver rte_qedevf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_qede_pmd_init
-};
-
-static struct rte_driver rte_qede_driver = {
-	.type = PMD_PDEV,
-	.init = rte_qedevf_pmd_init
-};
-
-PMD_REGISTER_DRIVER(rte_qede_driver, qede);
+DRIVER_REGISTER_PCI(qede, rte_qede_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(qede, pci_id_qede_map);
-PMD_REGISTER_DRIVER(rte_qedevf_driver, qedevf);
+DRIVER_REGISTER_PCI(qedevf, rte_qedevf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(qedevf, pci_id_qedevf_map);
drivers/net/szedata2/rte_eth_szedata2.c +3 -21
index 483d789..6d21024 100644
@@ -1574,31 +1574,13 @@ static struct eth_driver szedata2_eth_driver = {
 	.pci_drv = {
 		.name     = RTE_SZEDATA2_PCI_DRIVER_NAME,
 		.id_table = rte_szedata2_pci_id_table,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init     = rte_szedata2_eth_dev_init,
 	.eth_dev_uninit   = rte_szedata2_eth_dev_uninit,
 	.dev_private_size = sizeof(struct pmd_internals),
 };
 
-static int
-rte_szedata2_init(const char *name __rte_unused,
-		const char *args __rte_unused)
-{
-	rte_eth_driver_register(&szedata2_eth_driver);
-	return 0;
-}
-
-static int
-rte_szedata2_uninit(const char *name __rte_unused)
-{
-	return 0;
-}
-
-static struct rte_driver rte_szedata2_driver = {
-	.type = PMD_PDEV,
-	.init = rte_szedata2_init,
-	.uninit = rte_szedata2_uninit,
-};
-
-PMD_REGISTER_DRIVER(rte_szedata2_driver, RTE_SZEDATA2_DRIVER_NAME);
+DRIVER_REGISTER_PCI(RTE_SZEDATA2_DRIVER_NAME, szedata2_eth_driver.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(RTE_SZEDATA2_DRIVER_NAME, rte_szedata2_pci_id_table);
drivers/net/thunderx/nicvf_ethdev.c +3 -17
index 4f875c0..ad7d607 100644
@@ -1762,26 +1762,12 @@ static struct eth_driver rte_nicvf_pmd = {
 		.name = "rte_nicvf_pmd",
 		.id_table = pci_id_nicvf_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = nicvf_eth_dev_init,
 	.dev_private_size = sizeof(struct nicvf),
 };
 
-static int
-rte_nicvf_pmd_init(const char *name __rte_unused, const char *para __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-	PMD_INIT_LOG(INFO, "librte_pmd_thunderx nicvf version %s",
-			THUNDERX_NICVF_PMD_VERSION);
-
-	rte_eth_driver_register(&rte_nicvf_pmd);
-	return 0;
-}
-
-static struct rte_driver rte_nicvf_driver = {
-	.type = PMD_PDEV,
-	.init = rte_nicvf_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_nicvf_driver, thunderx_nicvf);
+DRIVER_REGISTER_PCI(thunderx_nicvf, rte_nicvf_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(thunderx_nicvf, pci_id_nicvf_map);
drivers/net/virtio/virtio_ethdev.c +7 -18
index 07d6449..5453709 100644
@@ -1307,29 +1307,24 @@ static struct eth_driver rte_virtio_pmd = {
 		.name = "rte_virtio_pmd",
 		.id_table = pci_id_virtio_map,
 		.drv_flags = RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_virtio_dev_init,
 	.eth_dev_uninit = eth_virtio_dev_uninit,
 	.dev_private_size = sizeof(struct virtio_hw),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of PCI virtio devices.
- * Returns 0 on success.
- */
-static int
-rte_virtio_pmd_init(const char *name __rte_unused,
-		    const char *param __rte_unused)
+RTE_INIT(rte_virtio_pmd_init);
+static void
+rte_virtio_pmd_init(void)
 {
 	if (rte_eal_iopl_init() != 0) {
 		PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD");
-		return -1;
+		return;
 	}
 
-	rte_eth_driver_register(&rte_virtio_pmd);
-	return 0;
+	rte_eal_pci_register(&rte_virtio_pmd.pci_drv);
 }
 
 /*
@@ -1563,10 +1558,4 @@ __rte_unused uint8_t is_rx)
 	return 0;
 }
 
-static struct rte_driver rte_virtio_driver = {
-	.type = PMD_PDEV,
-	.init = rte_virtio_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_virtio_driver, virtio_net);
 DRIVER_REGISTER_PCI_TABLE(virtio_net, pci_id_virtio_map);
drivers/net/vmxnet3/vmxnet3_ethdev.c +3 -20
index 5874215..d732979 100644
@@ -331,26 +331,14 @@ static struct eth_driver rte_vmxnet3_pmd = {
 		.name = "rte_vmxnet3_pmd",
 		.id_table = pci_id_vmxnet3_map,
 		.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
+		.devinit = rte_eth_dev_pci_probe,
+		.devuninit = rte_eth_dev_pci_remove,
 	},
 	.eth_dev_init = eth_vmxnet3_dev_init,
 	.eth_dev_uninit = eth_vmxnet3_dev_uninit,
 	.dev_private_size = sizeof(struct vmxnet3_hw),
 };
 
-/*
- * Driver initialization routine.
- * Invoked once at EAL init time.
- * Register itself as the [Poll Mode] Driver of Virtual PCI VMXNET3 devices.
- */
-static int
-rte_vmxnet3_pmd_init(const char *name __rte_unused, const char *param __rte_unused)
-{
-	PMD_INIT_FUNC_TRACE();
-
-	rte_eth_driver_register(&rte_vmxnet3_pmd);
-	return 0;
-}
-
 static int
 vmxnet3_dev_configure(struct rte_eth_dev *dev)
 {
@@ -948,10 +936,5 @@ vmxnet3_process_events(struct vmxnet3_hw *hw)
 }
 #endif
 
-static struct rte_driver rte_vmxnet3_driver = {
-	.type = PMD_PDEV,
-	.init = rte_vmxnet3_pmd_init,
-};
-
-PMD_REGISTER_DRIVER(rte_vmxnet3_driver, vmxnet3);
+DRIVER_REGISTER_PCI(vmxnet3, rte_vmxnet3_pmd.pci_drv);
 DRIVER_REGISTER_PCI_TABLE(vmxnet3, pci_id_vmxnet3_map);
Signature · 1 line
2.7.4
#186 lore raw

PATCH v7 9/17 crypto: get rid of crypto driver register callback

In reply to Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register crypto drivers through a dedicated channel.

---
 lib/librte_cryptodev/rte_cryptodev.c           | 22 -------------------
 lib/librte_cryptodev/rte_cryptodev_pmd.h       | 30 --------------------------
 lib/librte_cryptodev/rte_cryptodev_version.map |  1 -
 3 files changed, 53 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +0 -22
index b1e82b6..2a3b649 100644
@@ -533,28 +533,6 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *cryptodrv,
-		enum pmd_type type)
-{
-	/* Call crypto device initialization directly if device is virtual */
-	if (type == PMD_VDEV)
-		return rte_cryptodev_pci_probe((struct rte_pci_driver *)cryptodrv,
-				NULL);
-
-	/*
-	 * Register PCI driver for physical device intialisation during
-	 * PCI probing
-	 */
-	cryptodrv->pci_drv.devinit = rte_cryptodev_pci_probe;
-	cryptodrv->pci_drv.devuninit = rte_cryptodev_pci_remove;
-
-	rte_eal_pci_register(&cryptodrv->pci_drv);
-
-	return 0;
-}
-
-
 uint16_t
 rte_cryptodev_queue_pair_count(uint8_t dev_id)
 {
lib/librte_cryptodev/rte_cryptodev_pmd.h +0 -30
index 3fb7c7c..99fd69e 100644
@@ -491,36 +491,6 @@ rte_cryptodev_pmd_virtual_dev_init(const char *name, size_t dev_private_size,
 extern int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev);
 
-
-/**
- * Register a Crypto [Poll Mode] driver.
- *
- * Function invoked by the initialization function of a Crypto driver
- * to simultaneously register itself as Crypto Poll Mode Driver and to either:
- *
- *	a - register itself as PCI driver if the crypto device is a physical
- *		device, by invoking the rte_eal_pci_register() function to
- *		register the *pci_drv* structure embedded in the *crypto_drv*
- *		structure, after having stored the address of the
- *		rte_cryptodev_init() function in the *devinit* field of the
- *		*pci_drv* structure.
- *
- *		During the PCI probing phase, the rte_cryptodev_init()
- *		function is invoked for each PCI [device] matching the
- *		embedded PCI identifiers provided by the driver.
- *
- *	b, complete the initialization sequence if the device is a virtual
- *		device by calling the rte_cryptodev_init() directly passing a
- *		NULL parameter for the rte_pci_device structure.
- *
- *   @param crypto_drv	crypto_driver structure associated with the crypto
- *					driver.
- *   @param type		pmd type
- */
-extern int
-rte_cryptodev_pmd_driver_register(struct rte_cryptodev_driver *crypto_drv,
-		enum pmd_type type);
-
 /**
  * Executes all the user application registered callbacks for the specific
  * device.
lib/librte_cryptodev/rte_cryptodev_version.map +0 -1
index 1fc0d57..9627ac4 100644
@@ -14,7 +14,6 @@ DPDK_16.04 {
 	rte_cryptodev_info_get;
 	rte_cryptodev_pmd_allocate;
 	rte_cryptodev_pmd_callback_process;
-	rte_cryptodev_pmd_driver_register;
 	rte_cryptodev_pmd_release_device;
 	rte_cryptodev_pmd_virtual_dev_init;
 	rte_cryptodev_sym_session_create;
Signature · 1 line
2.7.4
#187 lore raw

PATCH v7 10/17 ethdev: get rid of eth driver register callback

In reply to Shreyansh Jain

Now that all pdev are pci drivers, we don't need to register ethdev drivers through a dedicated channel.

---
 lib/librte_ether/rte_ethdev.c | 22 ----------------------
 lib/librte_ether/rte_ethdev.h | 12 ------------
 2 files changed, 34 deletions(-)
lib/librte_ether/rte_ethdev.c +0 -22
index 8825219..3bccf20 100644
@@ -340,28 +340,6 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	return 0;
 }
 
-/**
- * Register an Ethernet [Poll Mode] driver.
- *
- * Function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * 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
- * the *pci_drv* structure.
- * During the PCI probing phase, the rte_eth_dev_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_pci_probe;
-	eth_drv->pci_drv.devuninit = rte_eth_dev_pci_remove;
-	rte_eal_pci_register(&eth_drv->pci_drv);
-}
-
 int
 rte_eth_dev_is_valid_port(uint8_t port_id)
 {
lib/librte_ether/rte_ethdev.h +0 -12
index 37d78bf..b005c1b 100644
@@ -1871,18 +1871,6 @@ struct eth_driver {
 };
 
 /**
- * @internal
- * A function invoked by the initialization function of an Ethernet driver
- * to simultaneously register itself as a PCI driver and as an Ethernet
- * Poll Mode Driver (PMD).
- *
- * @param eth_drv
- *   The pointer to the *eth_driver* structure associated with
- *   the Ethernet driver.
- */
-void rte_eth_driver_register(struct eth_driver *eth_drv);
-
-/**
  * Convert a numerical speed in Mbps to a bitmap flag that can be used in
  * the bitmap link_speeds of the struct rte_eth_conf
  *
Signature · 1 line
2.7.4
#188 lore raw

PATCH v7 11/17 eal/linux: move back interrupt thread init before setting affinity

In reply to Shreyansh Jain

Now that virtio pci driver is initialized in a constructor, iopl() stuff happens early enough so that interrupt thread can be created right after plugin loading.
This way, chelsio driver should be happy again [1].

[1] http://dpdk.org/ml/archives/dev/2015-November/028289.html

---
 lib/librte_eal/linuxapp/eal/eal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +3 -3
index fe9c704..259a7e4 100644
@@ -834,6 +834,9 @@ rte_eal_init(int argc, char **argv)
 	if (eal_plugins_init() < 0)
 		rte_panic("Cannot init plugins\n");
 
+	if (rte_eal_intr_init() < 0)
+		rte_panic("Cannot init interrupt-handling thread\n");
+
 	eal_thread_init_master(rte_config.master_lcore);
 
 	ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
@@ -845,9 +848,6 @@ rte_eal_init(int argc, char **argv)
 	if (rte_eal_dev_init() < 0)
 		rte_panic("Cannot init pmd devices\n");
 
-	if (rte_eal_intr_init() < 0)
-		rte_panic("Cannot init interrupt-handling thread\n");
-
 	RTE_LCORE_FOREACH_SLAVE(i) {
 
 		/*
Signature · 1 line
2.7.4
#189 lore raw

PATCH v7 12/17 pci: add a helper for device name

In reply to Shreyansh Jain

Eal is a better place than crypto / ethdev to name devices. Add a helper in eal and make use of it in crypto / ethdev.

---
 lib/librte_cryptodev/rte_cryptodev.c    | 27 ++++-----------------------
 lib/librte_eal/common/include/rte_pci.h | 26 ++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.c           | 24 ++++--------------------
 3 files changed, 34 insertions(+), 43 deletions(-)
lib/librte_cryptodev/rte_cryptodev.c +4 -23
index 2a3b649..c81e366 100644
@@ -365,23 +365,6 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id)
 	return cryptodev;
 }
 
-static inline int
-rte_cryptodev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
-{
-	int ret;
-
-	if ((name == NULL) || (pci_dev == NULL))
-		return -EINVAL;
-
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
 int
 rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev)
 {
@@ -444,9 +427,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv,
 	if (cryptodrv == NULL)
 		return -ENODEV;
 
-	/* Create unique Crypto device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id());
 	if (cryptodev == NULL)
@@ -501,9 +483,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -EINVAL;
 
-	/* Create unique device name using PCI address */
-	rte_cryptodev_create_unique_device_name(cryptodev_name,
-			sizeof(cryptodev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name,
+			sizeof(cryptodev_name));
 
 	cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name);
 	if (cryptodev == NULL)
lib/librte_eal/common/include/rte_pci.h +26 -0
index ffeb94c..9eea092 100644
@@ -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. */
@@ -95,6 +96,7 @@ const char *pci_get_sysfs_path(void);
 
 /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */
 #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
+#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X")
 
 /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */
 #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
@@ -308,6 +310,30 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr)
 }
 #undef GET_PCIADDR_FIELD
 
+/**
+ * Utility function to write a pci device name, this device name can later be
+ * used to retrieve the corresponding rte_pci_addr using eal_parse_pci_*
+ * BDF helpers.
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address
+ * @param output
+ *	The output buffer string
+ * @param size
+ *	The output buffer size
+ * @return
+ *  0 on success, negative on error.
+ */
+static inline void
+rte_eal_pci_device_name(const struct rte_pci_addr *addr,
+		    char *output, size_t size)
+{
+	RTE_VERIFY(size >= PCI_PRI_STR_SIZE);
+	RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT,
+			    addr->domain, addr->bus,
+			    addr->devid, addr->function) >= 0);
+}
+
 /* Compare two PCI device addresses. */
 /**
  * Utility function to compare two PCI device addresses.
lib/librte_ether/rte_ethdev.c +4 -20
index 3bccf20..a1bb043 100644
@@ -220,20 +220,6 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	return eth_dev;
 }
 
-static int
-rte_eth_dev_create_unique_device_name(char *name, size_t size,
-		struct rte_pci_device *pci_dev)
-{
-	int ret;
-
-	ret = snprintf(name, size, "%d:%d.%d",
-			pci_dev->addr.bus, pci_dev->addr.devid,
-			pci_dev->addr.function);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
 int
 rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 {
@@ -257,9 +243,8 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
 
 	eth_drv = (struct eth_driver *)pci_drv;
 
-	/* Create unique Ethernet device name using PCI address */
-	rte_eth_dev_create_unique_device_name(ethdev_name,
-			sizeof(ethdev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
+			sizeof(ethdev_name));
 
 	eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
 	if (eth_dev == NULL)
@@ -310,9 +295,8 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev)
 	if (pci_dev == NULL)
 		return -EINVAL;
 
-	/* Create unique Ethernet device name using PCI address */
-	rte_eth_dev_create_unique_device_name(ethdev_name,
-			sizeof(ethdev_name), pci_dev);
+	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
+			sizeof(ethdev_name));
 
 	eth_dev = rte_eth_dev_allocated(ethdev_name);
 	if (eth_dev == NULL)
Signature · 1 line
2.7.4
#190 lore raw

PATCH v7 13/17 pci: add a helper to update a device

In reply to Shreyansh Jain

This helper updates a pci device object with latest information it can find.
It will be used mainly for hotplug code.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c   | 49 +++++++++++++++++++++++++++++++++++
 lib/librte_eal/common/eal_private.h   | 13 ++++++++++
 lib/librte_eal/linuxapp/eal/eal_pci.c | 13 ++++++++++
 3 files changed, 75 insertions(+)
lib/librte_eal/bsdapp/eal/eal_pci.c +49 -0
index a73cbb0..1d91c78 100644
@@ -406,6 +406,55 @@ error:
 	return -1;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	int fd;
+	struct pci_conf matches[2];
+	struct pci_match_conf match = {
+		.pc_sel = {
+			.pc_domain = addr->domain,
+			.pc_bus = addr->bus,
+			.pc_dev = addr->devid,
+			.pc_func = addr->function,
+		},
+	};
+	struct pci_conf_io conf_io = {
+		.pat_buf_len = 0,
+		.num_patterns = 1,
+		.patterns = &match,
+		.match_buf_len = sizeof(matches),
+		.matches = &matches[0],
+	};
+
+	fd = open("/dev/pci", O_RDONLY);
+	if (fd < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
+		goto error;
+	}
+
+	if (ioctl(fd, PCIOCGETCONF, &conf_io) < 0) {
+		RTE_LOG(ERR, EAL, "%s(): error with ioctl on /dev/pci: %s\n",
+				__func__, strerror(errno));
+		goto error;
+	}
+
+	if (conf_io.num_matches != 1)
+		goto error;
+
+	if (pci_scan_one(fd, &matches[0]) < 0)
+		goto error;
+
+	close(fd);
+
+	return 0;
+
+error:
+	if (fd >= 0)
+		close(fd);
+	return -1;
+}
+
 /* Read PCI config space. */
 int rte_eal_pci_read_config(const struct rte_pci_device *dev,
 			    void *buf, size_t len, off_t offset)
lib/librte_eal/common/eal_private.h +13 -0
index 06a68f6..b8ff9c5 100644
@@ -152,6 +152,19 @@ struct rte_pci_driver;
 struct rte_pci_device;
 
 /**
+ * Update a pci device object by asking the kernel for the latest information.
+ *
+ * This function is private to EAL.
+ *
+ * @param addr
+ *	The PCI Bus-Device-Function address to look for
+ * @return
+ *   - 0 on success.
+ *   - negative on error.
+ */
+int pci_update_device(const struct rte_pci_addr *addr);
+
+/**
  * Unbind kernel driver for this device
  *
  * This function is private to EAL.
lib/librte_eal/linuxapp/eal/eal_pci.c +13 -0
index f0215ee..62da4d4 100644
@@ -417,6 +417,19 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 	return 0;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+	char filename[PATH_MAX];
+
+	snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
+		 pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid,
+		 addr->function);
+
+	return pci_scan_one(filename, addr->domain, addr->bus, addr->devid,
+				addr->function);
+}
+
 /*
  * split up a pci address into its constituent parts.
  */
Signature · 1 line
2.7.4
#191 lore raw

PATCH v7 14/17 ethdev: do not scan all pci devices on attach

In reply to Shreyansh Jain

No need to scan all devices, we only need to update the device being attached.

---
 lib/librte_eal/common/eal_common_pci.c | 11 ++++++++---
 lib/librte_ether/rte_ethdev.c          |  3 ---
 2 files changed, 8 insertions(+), 6 deletions(-)
lib/librte_eal/common/eal_common_pci.c +8 -3
index 6a0f6ac..da0038f 100644
@@ -341,6 +341,11 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 	if (addr == NULL)
 		return -1;
 
+	/* update current pci device in global list, kernel bindings might have
+	 * changed since last time we looked at it */
+	if (pci_update_device(addr) < 0)
+		goto err_return;
+
 	TAILQ_FOREACH(dev, &pci_device_list, next) {
 		if (rte_eal_compare_pci_addr(&dev->addr, addr))
 			continue;
@@ -353,9 +358,9 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)
 	return -1;
 
 err_return:
-	RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT
-			" cannot be used\n", dev->addr.domain, dev->addr.bus,
-			dev->addr.devid, dev->addr.function);
+	RTE_LOG(WARNING, EAL,
+		"Requested device " PCI_PRI_FMT " cannot be used\n",
+		addr->domain, addr->bus, addr->devid, addr->function);
 	return -1;
 }
 
lib/librte_ether/rte_ethdev.c +0 -3
index a1bb043..fdeac86 100644
@@ -469,9 +469,6 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 static int
 rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
 {
-	/* re-construct pci_device_list */
-	if (rte_eal_pci_scan())
-		goto err;
 	/* Invoke probe func of the driver can handle the new device. */
 	if (rte_eal_pci_probe_one(addr))
 		goto err;
Signature · 1 line
2.7.4
#192 lore raw

PATCH v7 15/17 eal: add hotplug operations for pci and vdev

In reply to Shreyansh Jain

Hotplug invocations, which deals with devices, should come from the layer that already handles them, i.e. EAL.

For both attach and detach operations, 'name' is used to select the bus that will handle the request.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  7 ++++
 lib/librte_eal/common/eal_common_dev.c          | 48 +++++++++++++++++++++++++
 lib/librte_eal/common/include/rte_dev.h         | 26 ++++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 ++++
 4 files changed, 88 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +7 -0
index a335e04..7b3d409 100644
@@ -162,3 +162,10 @@ DPDK_16.07 {
 	rte_thread_setname;
 
 } DPDK_16.04;
+
+DPDK_16.11 {
+	global:
+
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
+} DPDK_16.07;
lib/librte_eal/common/eal_common_dev.c +48 -0

51 lines not on this page · raw message

lib/librte_eal/common/include/rte_dev.h +26 -0
index 994650b..a4f08b5 100644
@@ -178,6 +178,32 @@ int rte_eal_vdev_init(const char *name, const char *args);
  */
 int rte_eal_vdev_uninit(const char *name);
 
+/**
+ * Attach a device to a registered driver.
+ *
+ * @param name
+ *   The device name, that refers to a pci device (or some private
+ *   way of designating a vdev device). Based on this device name, eal
+ *   will identify a driver capable of handling it and pass it to the
+ *   driver probing function.
+ * @param devargs
+ *   Device arguments to be passed to the driver.
+ * @return
+ *   0 on success, negative on error.
+ */
+int rte_eal_dev_attach(const char *name, const char *devargs);
+
+/**
+ * Detach a device from its driver.
+ *
+ * @param name
+ *   Same description as for rte_eal_dev_attach().
+ *   Here, eal will call the driver detaching function.
+ * @return
+ *   0 on success, negative on error.
+ */
+int rte_eal_dev_detach(const char *name);
+
 #define DRIVER_EXPORT_NAME_ARRAY(n, idx) n##idx[]
 
 #define DRIVER_EXPORT_NAME(name, idx) \
lib/librte_eal/linuxapp/eal/rte_eal_version.map +7 -0
index db8c984..c0bd391 100644
@@ -166,3 +166,10 @@ DPDK_16.07 {
 	rte_thread_setname;
 
 } DPDK_16.04;
+
+DPDK_16.11 {
+	global:
+
+	rte_eal_dev_attach;
+	rte_eal_dev_detach;
+} DPDK_16.07;
Signature · 1 line
2.7.4
#193 lore raw

PATCH v7 16/17 ethdev: convert to eal hotplug

In reply to Shreyansh Jain

Remove bus logic from ethdev hotplug by using eal for this.

Current api is preserved:
- the last port that has been created is tracked to return it to the application when attaching,
- the internal device name is reused when detaching.

We can not get rid of ethdev hotplug yet since we still need some mechanism to inform applications of port creation/removal to substitute for ethdev hotplug api.

dev_type field in struct rte_eth_dev and rte_eth_dev_allocate are kept as is, but this information is not needed anymore and is removed in the following commit.

---
 lib/librte_ether/rte_ethdev.c | 208 +++++++-----------------------------------
 1 file changed, 34 insertions(+), 174 deletions(-)
lib/librte_ether/rte_ethdev.c +34 -174
index fdeac86..86c9d1a 100644
@@ -72,6 +72,7 @@
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 static struct rte_eth_dev_data *rte_eth_dev_data;
+static uint8_t eth_dev_last_created_port;
 static uint8_t nb_ports;
 
 /* spinlock for eth device callbacks */
@@ -216,6 +217,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	eth_dev->data->port_id = port_id;
 	eth_dev->attached = DEV_ATTACHED;
 	eth_dev->dev_type = type;
+	eth_dev_last_created_port = port_id;
 	nb_ports++;
 	return eth_dev;
 }
@@ -347,27 +349,6 @@ rte_eth_dev_count(void)
 	return nb_ports;
 }
 
-static enum rte_eth_dev_type
-rte_eth_dev_get_device_type(uint8_t port_id)
-{
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, RTE_ETH_DEV_UNKNOWN);
-	return rte_eth_devices[port_id].dev_type;
-}
-
-static int
-rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
-{
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
-
-	if (addr == NULL) {
-		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
-		return -EINVAL;
-	}
-
-	*addr = rte_eth_devices[port_id].pci_dev->addr;
-	return 0;
-}
-
 int
 rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 {
@@ -413,34 +394,6 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id)
 }
 
 static int
-rte_eth_dev_get_port_by_addr(const struct rte_pci_addr *addr, uint8_t *port_id)
-{
-	int i;
-	struct rte_pci_device *pci_dev = NULL;
-
-	if (addr == NULL) {
-		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
-		return -EINVAL;
-	}
-
-	*port_id = RTE_MAX_ETHPORTS;
-
-	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-
-		pci_dev = rte_eth_devices[i].pci_dev;
-
-		if (pci_dev &&
-			!rte_eal_compare_pci_addr(&pci_dev->addr, addr)) {
-
-			*port_id = i;
-
-			return 0;
-		}
-	}
-	return -ENODEV;
-}
-
-static int
 rte_eth_dev_is_detachable(uint8_t port_id)
 {
 	uint32_t dev_flags;
@@ -465,124 +418,46 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 		return 1;
 }
 
-/* attach the new physical device, then store port_id of the device */
-static int
-rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)
-{
-	/* Invoke probe func of the driver can handle the new device. */
-	if (rte_eal_pci_probe_one(addr))
-		goto err;
-
-	if (rte_eth_dev_get_port_by_addr(addr, port_id))
-		goto err;
-
-	return 0;
-err:
-	return -1;
-}
-
-/* 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)
-{
-	struct rte_pci_addr freed_addr;
-	struct rte_pci_addr vp;
-
-	/* get pci address by port id */
-	if (rte_eth_dev_get_addr_by_port(port_id, &freed_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)
-		goto err;
-
-	/* invoke devuninit func of the pci driver,
-	 * also remove the device from pci_device_list */
-	if (rte_eal_pci_detach(&freed_addr))
-		goto err;
-
-	*addr = freed_addr;
-	return 0;
-err:
-	return -1;
-}
-
-/* attach the new virtual device, then store port_id of the device */
-static int
-rte_eth_dev_attach_vdev(const char *vdevargs, uint8_t *port_id)
-{
-	char *name = NULL, *args = NULL;
-	int ret = -1;
-
-	/* parse vdevargs, then retrieve device name and args */
-	if (rte_eal_parse_devargs_str(vdevargs, &name, &args))
-		goto end;
-
-	/* walk around dev_driver_list to find the driver of the device,
-	 * then invoke probe function of the driver.
-	 * rte_eal_vdev_init() updates port_id allocated after
-	 * initialization.
-	 */
-	if (rte_eal_vdev_init(name, args))
-		goto end;
-
-	if (rte_eth_dev_get_port_by_name(name, port_id))
-		goto end;
-
-	ret = 0;
-end:
-	free(name);
-	free(args);
-
-	return ret;
-}
-
-/* detach the new virtual device, then store the name of the device */
-static int
-rte_eth_dev_detach_vdev(uint8_t port_id, char *vdevname)
-{
-	char name[RTE_ETH_NAME_MAX_LEN];
-
-	/* get device name by port id */
-	if (rte_eth_dev_get_name_by_port(port_id, name))
-		goto err;
-	/* walk around dev_driver_list to find the driver of the device,
-	 * then invoke uninit function of the driver */
-	if (rte_eal_vdev_uninit(name))
-		goto err;
-
-	strncpy(vdevname, name, sizeof(name));
-	return 0;
-err:
-	return -1;
-}
-
 /* attach the new device, then store port_id of the device */
 int
 rte_eth_dev_attach(const char *devargs, uint8_t *port_id)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
+	int current = eth_dev_last_created_port;
+	char *name = NULL;
+	char *args = NULL;
 
 	if ((devargs == NULL) || (port_id == NULL)) {
 		ret = -EINVAL;
 		goto err;
 	}
 
-	if (eal_parse_pci_DomBDF(devargs, &addr) == 0) {
-		ret = rte_eth_dev_attach_pdev(&addr, port_id);
-		if (ret < 0)
-			goto err;
-	} else {
-		ret = rte_eth_dev_attach_vdev(devargs, port_id);
-		if (ret < 0)
-			goto err;
+	/* parse devargs, then retrieve device name and args */
+	if (rte_eal_parse_devargs_str(devargs, &name, &args))
+		goto err;
+
+	ret = rte_eal_dev_attach(name, args);
+	if (ret < 0)
+		goto err;
+
+	/* no point looking at eth_dev_last_created_port if no port exists */
+	if (!nb_ports) {
+		RTE_LOG(ERR, EAL, "No ports founds for device (%s)\n", name);
+		ret = -1;
+		goto err;
+	}
+	/* if nothing happened, there is a bug here, since some driver told us
+	 * it did attach a device, but did not create a port */
+	if (current == eth_dev_last_created_port) {
+		ret = -1;
+		goto err;
 	}
+	*port_id = eth_dev_last_created_port;
+	ret = 0;
 
-	return 0;
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n");
+	free(name);
+	free(args);
 	return ret;
 }
 
@@ -590,7 +465,6 @@ err:
 int
 rte_eth_dev_detach(uint8_t port_id, char *name)
 {
-	struct rte_pci_addr addr;
 	int ret = -1;
 
 	if (name == NULL) {
@@ -598,33 +472,19 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
 		goto err;
 	}
 
-	/* check whether the driver supports detach feature, or not */
+	/* FIXME: move this to eal, once device flags are relocated there */
 	if (rte_eth_dev_is_detachable(port_id))
 		goto err;
 
-	if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {
-		ret = rte_eth_dev_get_addr_by_port(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		ret = rte_eth_dev_detach_pdev(port_id, &addr);
-		if (ret < 0)
-			goto err;
-
-		snprintf(name, RTE_ETH_NAME_MAX_LEN,
-			"%04x:%02x:%02x.%d",
-			addr.domain, addr.bus,
-			addr.devid, addr.function);
-	} else {
-		ret = rte_eth_dev_detach_vdev(port_id, name);
-		if (ret < 0)
-			goto err;
-	}
+	snprintf(name, sizeof(rte_eth_devices[port_id].data->name),
+		 "%s", rte_eth_devices[port_id].data->name);
+	ret = rte_eal_dev_detach(name);
+	if (ret < 0)
+		goto err;
 
 	return 0;
 
 err:
-	RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n");
 	return ret;
 }
 
Signature · 1 line
2.7.4
#194 lore raw

PATCH v7 17/17 ethdev: get rid of device type

In reply to Shreyansh Jain

Now that hotplug has been moved to eal, there is no reason to keep the device type in this layer.

---
 app/test/virtual_pmd.c                    |  2 +-
 drivers/net/af_packet/rte_eth_af_packet.c |  2 +-
 drivers/net/bonding/rte_eth_bond_api.c    |  2 +-
 drivers/net/cxgbe/cxgbe_main.c            |  2 +-
 drivers/net/mlx4/mlx4.c                   |  2 +-
 drivers/net/mlx5/mlx5.c                   |  2 +-
 drivers/net/mpipe/mpipe_tilegx.c          |  2 +-
 drivers/net/null/rte_eth_null.c           |  2 +-
 drivers/net/pcap/rte_eth_pcap.c           |  2 +-
 drivers/net/ring/rte_eth_ring.c           |  2 +-
 drivers/net/vhost/rte_eth_vhost.c         |  2 +-
 drivers/net/virtio/virtio_user_ethdev.c   |  2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c     |  2 +-
 examples/ip_pipeline/init.c               | 22 ----------------------
 lib/librte_ether/rte_ethdev.c             |  5 ++---
 lib/librte_ether/rte_ethdev.h             | 15 +--------------
 16 files changed, 16 insertions(+), 52 deletions(-)
app/test/virtual_pmd.c +1 -1
index b4bd2f2..8a1f0d0 100644
@@ -581,7 +581,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr,
 		goto err;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto err;
 
drivers/net/af_packet/rte_eth_af_packet.c +1 -1
index f795566..d629ee3 100644
@@ -666,7 +666,7 @@ rte_pmd_init_internals(const char *name,
 	}
 
 	/* reserve an ethdev entry */
-	*eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	*eth_dev = rte_eth_dev_allocate(name);
 	if (*eth_dev == NULL)
 		goto error;
 
drivers/net/bonding/rte_eth_bond_api.c +1 -1
index 203ebe9..8514652 100644
@@ -189,7 +189,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
 	}
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
 		RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
 		goto err;
drivers/net/cxgbe/cxgbe_main.c +1 -1
index ceaf5ab..922155b 100644
@@ -1150,7 +1150,7 @@ int cxgbe_probe(struct adapter *adapter)
 		 */
 
 		/* reserve an ethdev entry */
-		pi->eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+		pi->eth_dev = rte_eth_dev_allocate(name);
 		if (!pi->eth_dev)
 			goto out_free;
 
drivers/net/mlx4/mlx4.c +1 -1
index 2bed4de..b333ad6 100644
@@ -5803,7 +5803,7 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
 			snprintf(name, sizeof(name), "%s port %u",
 				 ibv_get_device_name(ibv_dev), port);
-			eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+			eth_dev = rte_eth_dev_allocate(name);
 		}
 		if (eth_dev == NULL) {
 			ERROR("can not allocate rte ethdev");
drivers/net/mlx5/mlx5.c +1 -1
index 3658769..ebad7cb 100644
@@ -617,7 +617,7 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
 			snprintf(name, sizeof(name), "%s port %u",
 				 ibv_get_device_name(ibv_dev), port);
-			eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_PCI);
+			eth_dev = rte_eth_dev_allocate(name);
 		}
 		if (eth_dev == NULL) {
 			ERROR("can not allocate rte ethdev");
drivers/net/mpipe/mpipe_tilegx.c +1 -1
index 93f8730..c0d0e3b 100644
@@ -1587,7 +1587,7 @@ rte_pmd_mpipe_devinit(const char *ifname,
 		return -ENODEV;
 	}
 
-	eth_dev = rte_eth_dev_allocate(ifname, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(ifname);
 	if (!eth_dev) {
 		RTE_LOG(ERR, PMD, "%s: Failed to allocate device.\n", ifname);
 		rte_free(priv);
drivers/net/null/rte_eth_null.c +1 -1
index 7a24884..ce49945 100644
@@ -517,7 +517,7 @@ eth_dev_null_create(const char *name,
 		goto error;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto error;
 
drivers/net/pcap/rte_eth_pcap.c +1 -1
index 7e213eb..7fbc60e 100644
@@ -822,7 +822,7 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues,
 		goto error;
 
 	/* reserve an ethdev entry */
-	*eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	*eth_dev = rte_eth_dev_allocate(name);
 	if (*eth_dev == NULL)
 		goto error;
 
drivers/net/ring/rte_eth_ring.c +1 -1
index a7048c7..5690dcd 100644
@@ -303,7 +303,7 @@ do_eth_dev_ring_create(const char *name,
 	}
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL) {
 		rte_errno = ENOSPC;
 		goto error;
drivers/net/vhost/rte_eth_vhost.c +1 -1
index 7539cd4..2bb761b 100644
@@ -714,7 +714,7 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
 		goto error;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto error;
 
drivers/net/virtio/virtio_user_ethdev.c +1 -1
index daef09b..aadfdc0 100644
@@ -277,7 +277,7 @@ virtio_user_eth_dev_alloc(const char *name)
 	struct virtio_hw *hw;
 	struct virtio_user_dev *dev;
 
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (!eth_dev) {
 		PMD_INIT_LOG(ERR, "cannot alloc rte_eth_dev");
 		return NULL;
drivers/net/xenvirt/rte_eth_xenvirt.c +1 -1
index 99f6cc8..6b15381 100644
@@ -654,7 +654,7 @@ eth_dev_xenvirt_create(const char *name, const char *params,
 		goto err;
 
 	/* reserve an ethdev entry */
-	eth_dev = rte_eth_dev_allocate(name, RTE_ETH_DEV_VIRTUAL);
+	eth_dev = rte_eth_dev_allocate(name);
 	if (eth_dev == NULL)
 		goto err;
 
examples/ip_pipeline/init.c +0 -22
index cd167f6..0dbc332 100644
@@ -606,29 +606,12 @@ app_link_set_tcp_syn_filter(struct app_params *app, struct app_link_params *cp)
 	}
 }
 
-static int
-app_link_is_virtual(struct app_link_params *p)
-{
-	uint32_t pmd_id = p->pmd_id;
-	struct rte_eth_dev *dev = &rte_eth_devices[pmd_id];
-
-	if (dev->dev_type == RTE_ETH_DEV_VIRTUAL)
-		return 1;
-
-	return 0;
-}
-
 void
 app_link_up_internal(struct app_params *app, struct app_link_params *cp)
 {
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 1;
-		return;
-	}
-
 	/* For each link, add filters for IP of current link */
 	if (cp->ip != 0) {
 		for (i = 0; i < app->n_links; i++) {
@@ -736,11 +719,6 @@ app_link_down_internal(struct app_params *app, struct app_link_params *cp)
 	uint32_t i;
 	int status;
 
-	if (app_link_is_virtual(cp)) {
-		cp->state = 0;
-		return;
-	}
-
 	/* PMD link down */
 	status = rte_eth_dev_set_link_down(cp->pmd_id);
 	if (status < 0)
lib/librte_ether/rte_ethdev.c +2 -3
index 86c9d1a..cf38f32 100644
@@ -191,7 +191,7 @@ rte_eth_dev_find_free_port(void)
 }
 
 struct rte_eth_dev *
-rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
+rte_eth_dev_allocate(const char *name)
 {
 	uint8_t port_id;
 	struct rte_eth_dev *eth_dev;
@@ -216,7 +216,6 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 	snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name);
 	eth_dev->data->port_id = port_id;
 	eth_dev->attached = DEV_ATTACHED;
-	eth_dev->dev_type = type;
 	eth_dev_last_created_port = port_id;
 	nb_ports++;
 	return eth_dev;
@@ -248,7 +247,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv,
 	rte_eal_pci_device_name(&pci_dev->addr, ethdev_name,
 			sizeof(ethdev_name));
 
-	eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI);
+	eth_dev = rte_eth_dev_allocate(ethdev_name);
 	if (eth_dev == NULL)
 		return -ENOMEM;
 
lib/librte_ether/rte_ethdev.h +1 -14
index b005c1b..2a697ec 100644
@@ -1603,17 +1603,6 @@ struct rte_eth_rxtx_callback {
 };
 
 /**
- * The eth device type.
- */
-enum rte_eth_dev_type {
-	RTE_ETH_DEV_UNKNOWN,	/**< unknown device type */
-	RTE_ETH_DEV_PCI,
-		/**< Physical function and Virtual function of PCI devices */
-	RTE_ETH_DEV_VIRTUAL,	/**< non hardware device */
-	RTE_ETH_DEV_MAX		/**< max value of this enum */
-};
-
-/**
  * @internal
  * The generic data structure associated with each ethernet device.
  *
@@ -1643,7 +1632,6 @@ struct rte_eth_dev {
 	 */
 	struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
 	uint8_t attached; /**< Flag indicating the port is attached */
-	enum rte_eth_dev_type dev_type; /**< Flag indicating the device type */
 } __rte_cache_aligned;
 
 struct rte_eth_dev_sriov {
@@ -1756,8 +1744,7 @@ struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
  * @return
  *   - Slot in the rte_dev_devices array for a new device;
  */
-struct rte_eth_dev *rte_eth_dev_allocate(const char *name,
-		enum rte_eth_dev_type type);
+struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
 
 /**
  * @internal
Signature · 1 line
2.7.4
#195 lore raw

Re: [PATCH v7 00/17] Prepare for rte_device / rte_driver

In reply to Shreyansh Jain

Thank you. Hope to find some time this week to do my part.

Jan

Quoted 140 lines · On Mon, 1 Aug 2016 16:15:15 +0530 Shreyansh Jain <[email protected]> wrote:

* Original patch series is from David Marchand [1], [2].
* Link with patch series [4] from Jan Viktorin for a more complete picture of proposed EAL device heirarchy changes.
* This might not be in-sync with pmdinfogen as PMD_REGISTER_DRIVER is removed [7].

David created the original patchset based on the discussions on list [3]. Being a large piece of work, this patchset introduces first level of changes for generalizing the driver-device relationship for supporting hotplug.

Overview of this work as per David [3], as well as notes from Thomas [9] & Jan:
- pdev -> PCI registeration using helpers (introduced in this series)
- removal of eth/crypto driver registeration callbacks. These are now handled by PCI registeration helpers (this patch)
- rte_device=>pci/vdev device heirarchy (by this [4] series)
- removal of PMD_PDEV type (this patch) and PMD_VDEV (by this [4] series)
- Support for hotplugging

This patchset is based on master (b0a1419)

[1] http://dpdk.org/ml/archives/dev/2016-January/032387.html
[2] http://dpdk.org/ml/archives/dev/2016-April/037686.html
[3] http://dpdk.org/ml/archives/dev/2016-January/031390.html
[4] http://dpdk.org/ml/archives/dev/2016-July/043645.html
[5] http://dpdk.org/ml/archives/dev/2016-June/042439.html
[6] http://dpdk.org/ml/archives/dev/2016-June/042444.html
[7] http://dpdk.org/ml/archives/dev/2016-July/043172.html
[8] http://dpdk.org/ml/archives/dev/2016-July/044004.html
[9] http://dpdk.org/ml/archives/dev/2016-July/044086.html

Changes since v6:
- rebase over 16.07 (b0a1419)
- DRIVER_REGISTER_PCI macro is now passed pci_drv rather than drv
- review comments regarding missing information in log messages
- new API additions to 16.11 map objects
- review comment in [5] and [7] are not included in this series.

Changes since v5:
- Rebase over master (11c5e45d8)
- Rename RTE_EAL_PCI_REGISTER helper macro to DRIVER_REGISTER_PCI to be in sync with DRIVER_REGISTER_PCI_TABLE. [Probably, in future, both can be merged]
- Modifications to bnxt and thunderx driver PMD registeration files for using the simplified PCI device registeration helper macro

Changes since v4:
- Fix compilation issue after rebase on HEAD (913154e) in previous series
- Retain rte_eth_dev_get_port_by_name and rte_eth_dev_get_name_by_port which were removed by previous patchset. These are being used by pdump library

Changes since v3:
- rebase over HEAD (913154e)
- Update arguments to RTE_EAL_PCI_REGISTER macro as per Jan's suggestion
- modify qede driver to use RTE_EAL_PCI_REGISTER
- Argument check in hotplug functions

Changes since v2:
- rebase over HEAD (d76c193)
- Move SYSFS_PCI_DRIVERS macro to rte_pci.h to avoid compilation issue

Changes since v1:
- rebased on HEAD, new drivers should be okay
- patches have been split into smaller pieces
- RTE_INIT macro has been added, but in the end, I am not sure it is useful
- device type has been removed from ethdev, as it was used only by hotplug
- getting rid of pmd type in eal patch (patch 5 of initial series) has been dropped for now, we can do this once vdev drivers have been converted

David Marchand, Shreyansh Jain (17):
pci: no need for dynamic tailq init
crypto: no need for a crypto pmd type
drivers: align pci driver definitions
eal: remove duplicate function declaration
eal: introduce init macros
crypto: export init/uninit common wrappers for pci drivers
ethdev: export init/uninit common wrappers for pci drivers
drivers: convert all pdev drivers as pci drivers
crypto: get rid of crypto driver register callback
ethdev: get rid of eth driver register callback eal/linux: move back interrupt thread init before setting affinity
pci: add a helper for device name
pci: add a helper to update a device
ethdev: do not scan all pci devices on attach
eal: add hotplug operations for pci and vdev
ethdev: convert to eal hotplug
ethdev: get rid of device type

 app/test/virtual_pmd.c                          |   2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c          |  18 +-
 drivers/net/af_packet/rte_eth_af_packet.c       |   2 +-
 drivers/net/bnx2x/bnx2x_ethdev.c                |  34 +--
 drivers/net/bnxt/bnxt_ethdev.c                  |  16 +-
 drivers/net/bonding/rte_eth_bond_api.c          |   2 +-
 drivers/net/cxgbe/cxgbe_ethdev.c                |  24 +--
 drivers/net/cxgbe/cxgbe_main.c                  |   2 +-
 drivers/net/e1000/em_ethdev.c                   |  16 +-
 drivers/net/e1000/igb_ethdev.c                  |  39 +---
 drivers/net/ena/ena_ethdev.c                    |  19 +-
 drivers/net/enic/enic_ethdev.c                  |  23 +-
 drivers/net/fm10k/fm10k_ethdev.c                |  23 +-
 drivers/net/i40e/i40e_ethdev.c                  |  24 +--
 drivers/net/i40e/i40e_ethdev_vf.c               |  25 +--
 drivers/net/ixgbe/ixgbe_ethdev.c                |  46 +---
 drivers/net/mlx4/mlx4.c                         |  17 +-
 drivers/net/mlx5/mlx5.c                         |  16 +-
 drivers/net/mpipe/mpipe_tilegx.c                |   2 +-
 drivers/net/nfp/nfp_net.c                       |  23 +-
 drivers/net/null/rte_eth_null.c                 |   2 +-
 drivers/net/pcap/rte_eth_pcap.c                 |   2 +-
 drivers/net/qede/qede_ethdev.c                  |  40 +---
 drivers/net/ring/rte_eth_ring.c                 |   2 +-
 drivers/net/szedata2/rte_eth_szedata2.c         |  24 +--
 drivers/net/thunderx/nicvf_ethdev.c             |  20 +-
 drivers/net/vhost/rte_eth_vhost.c               |   2 +-
 drivers/net/virtio/virtio_ethdev.c              |  25 +--
 drivers/net/virtio/virtio_user_ethdev.c         |   2 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c            |  23 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c           |   2 +-
 examples/ip_pipeline/init.c                     |  22 --
 lib/librte_cryptodev/rte_cryptodev.c            |  67 ++----
 lib/librte_cryptodev/rte_cryptodev.h            |   2 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h        |  45 ++--
 lib/librte_cryptodev/rte_cryptodev_version.map  |   8 +-
 lib/librte_eal/bsdapp/eal/eal_pci.c             |  52 ++++-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   7 +
 lib/librte_eal/common/eal_common_dev.c          |  48 +++++
 lib/librte_eal/common/eal_common_pci.c          |  17 +-
 lib/librte_eal/common/eal_private.h             |  20 +-
 lib/librte_eal/common/include/rte_dev.h         |  30 ++-
 lib/librte_eal/common/include/rte_eal.h         |   3 +
 lib/librte_eal/common/include/rte_pci.h         |  35 +++
 lib/librte_eal/common/include/rte_tailq.h       |   4 +-
 lib/librte_eal/linuxapp/eal/eal.c               |   7 +-
 lib/librte_eal/linuxapp/eal/eal_pci.c           |  16 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   7 +
 lib/librte_ether/rte_ethdev.c                   | 272 ++++--------------------
 lib/librte_ether/rte_ethdev.h                   |  40 ++--
 lib/librte_ether/rte_ether_version.map          |   9 +
 51 files changed, 415 insertions(+), 813 deletions(-)
Signature · 4 lines
   Jan Viktorin                  E-mail: [email protected]
   System Architect              Web:    www.RehiveTech.com
   RehiveTech
   Brno, Czech Republic
#196 lore raw

v8 cover Introducing rte_driver/rte_device generalization

In reply to Shreyansh Jain

Based on master (e22856313fff2)

Background:
===========

It includes two different patch-sets floated on ML earlier:
* Original patch series is from David Marchand [1], [2]. `- This focused mainly on PCI (PDEV) part
`- v7 of this was posted by me [8] in August/2016
* Patch series [4] from Jan Viktorin
`- This focused on VDEV and rte_device integration

Introduction:
=============

This patch series introduces a generic device model, moving away from PCI centric code layout. Key change is to introduce rte_driver/rte_device structures at the top level which are inherited by rte_XXX_driver/rte_XXX_device - where XXX belongs to {pci, vdev, soc (in future),...}.

Key motivation for this series is to move away from PCI centric design of EAL to a more hierarchical device model - pivoted around a generic driver and device. Each specific driver and device can inherit the common properties of the generic set and build upon it through driver/device specific functions.

Earlier, the EAL device initialization model was:
(Refer: [3])

--
Constructor:
|- PMD_DRIVER_REGISTER(rte_driver)
`- insert into dev_driver_list, rte_driver object

rte_eal_init():

  |- rte_eal_pci_init()
  |  `- scan and fill pci_device_list from sysfs
  |
  |- rte_eal_dev_init()
  |  `- For each rte_driver in dev_driver_list
  |     `- call the rte_driver->init() function
  |        |- PMDs designed to call rte_eth_driver_register(eth_driver)
  |        |- eth_driver have rte_pci_driver embedded in them
  |        `- rte_eth_driver_register installs the 
  |           rte_pci_driver->devinit/devuninit callbacks.
  |
  |- rte_eal_pci_probe()
  |  |- For each device detected, dev_driver_list is parsed and matching is
  |  |  done.
  |  |- For each matching device, the rte_pci_driver->devinit() is called.
  |  |- Default map is to rte_eth_dev_init() which in turn creates a
  |  |  new ethernet device (eth_dev)
  |  |  `- eth_drv->eth_dev_init() is called which is implemented by 

`--| individual PMD drivers.

--

The structure of driver looks something like:

 +------------+     ._____.
 | rte_driver <-----| PMD |___
 |  .init     |     `-----`   \
 +----.-------+      |         \
      `-.            |         What PMD actually is
         \           |          |
          +----------v----+     |
          | eth_driver    |     |
          | .eth_dev_init |     |
          +----.----------+     |
               `-.              |
                  \             |
                   +------------v---+
                   | rte_pci_driver |
                   | .pci_devinit   |
                   +----------------+

and all devices are part of a following linked lists:
- dev_driver_list for all rte_drivers
- pci_device_list for all devices, whether PCI or VDEV

Quoted 1 line

From the above:

* a PMD initializes a rte_driver, eth_driver even though actually it is a pci_driver
* initialization routines are passed from rte_driver->pci_driver->eth_driver even though they should ideally be rte_eal_init()->rte_pci_driver()
* For a single driver/device type model, this is not necessarily a functional issue - but more of a design language.
* But, when number of driver/device type increase, this would create problem in how driver<=>device links are represented.

Proposed Architecture:
======================

A nice representation has already been created by David in [3]. Copying that here:

                +------------------+ +-------------------------------+
                |                  | |                               |
                | rte_pci_device   | | rte_pci_driver                |
                |                  | |                               |
+-------------+ | +--------------+ | | +---------------------------+ |
|             | | |              | | | |                           | |
| rte_eth_dev +---> rte_device   +-----> rte_driver                | |
|             | | |  char name[] | | | |  char name[]              | |
+-------------+ | |              | | | |  int init(rte_device *)   | |
                | +--------------+ | | |  int uninit(rte_device *) | |
                |                  | | |                           | |
                +------------------+ | +---------------------------+ |
                                     |                               |
                                     +-------------------------------+

- for ethdev on top of vdev devices

                +------------------+ +-------------------------------+
                |                  | |                               |
                | drv specific     | | rte_vdev_driver               |
                |                  | |                               |
+-------------+ | +--------------+ | | +---------------------------+ |
|             | | |              | | | |                           | |
| rte_eth_dev +---> rte_device   +-----> rte_driver                | |
|             | | |  char name[] | | | |  char name[]              | |
+-------------+ | |              | | | |  int init(rte_device *)   | |
                | +--------------+ | | |  int uninit(rte_device *) | |
                |                  | | |                           | |
                +------------------+ | +---------------------------+ |
                                     |                               |
                                     |   int priv_size               |
                                     |                               |
                                     +-------------------------------+

Representing from above, it would be:

+--------------+
| rte_driver   |
|  name        |
|  <Future>    |
+------^-------+      pci_driver_list
       |                   /                vdev_driver_list
       `---. <<Inherits>> /                  /
           |\____________/_______           /
           |            /        \         /
           +-----------/-----+   +--------/---------+
           | rte_pci_driver  |   | rte_vdev_driver  |
           |  pci_devinit()  |   |  vdev_devinit()  |
           |  pci_devuninit()|   |  vdev_devuninit()|
           |  <more>         |   |  <more>          |
           +-----------------+   +------------------+
+--------------+
| rte_device   |
|  name        |
|  <Future>    |
+------^-------+        pci_device_list
       |                   /               xxx_device_list
       `---. <<Inherits>> /                  /
           |\____________/________          /
           |            /         \        /
           +-----------/-----+   +--------/---------+
           | rte_pci_device  |   | rte_xxx_device   |
           |  <dev data>     |   |  <dev data>      |
           |  <flags/intr>   |   |  <flags/intr>    |
           |  <more>         |   |  <more>          |
           +-----------------+   +------------------+

* Each driver type has its own structure which derives from the generic rte_driver structure.
\- Each driver type maintains its own list, at the same time, rte_driver
list also exists - so that *all* drivers can be looped on, if required.
* Each device, associated with one or more drivers, has its own type derived from rte_device
\- Each device _may_ maintain its own list (for example, in current
implementation, vdev is not maintaining it).

==Introducing a new device/driver type implies==
- creating their own rte_<xxx>.h file which contains the device/driver definitions.
- defining the DRIVER_REGISTER_XXX helpers

==Hotplugging Support==
- devices should be able to support attach/detach operations.
- Earlier these functions were part of ethdev. They have been moved to eal to be more generic.

About the Patches:
==================

There are a large number of patches for this - primarily because the changes are quite varied and keeping them logically separate yet compilable is important. Most of the patches are small and those which are large touch the drivers (PMDs) to accommodate the structure changes:

- Patches 0001~0003 are for introducing the container_of function (so that rte_device can be obtained from rte_pci_device, for example), and removing unused code.
- Patches 0004~0007 just perform the ground work for enabling change from rte_driver/eth_driver based PMDs to rte_xxx_driver based PMDs
- In patch 0008, all the pdev PMDs are changed to support rte_pci_driver ( including cryptodev, which is eventually generalized with PCI)
- Patch 0009~0010 merge the crypto and pci functions for registration and naming.
- Patches 0011~0014 deal with hotplugging - hotplug no more invokes scan of complete bus and has been generalized into EAl from ethdev.
- Patches 0015 introduces vdev init/uninit into separate C units and enables its compilation. Patch 0016~0017 build on it and remove the remaining legacy support for vdev/pdev distinctions.
- Patches 0018~0022 enable the vdev drivers to register using the DRIVER_REGISTER_* operations, and remove their rte_driver->init()
- Patch 0023 enables the rte_driver registration into a common driver linked list.
- Patches 0024~0025 introduce the rte_device, a generalization of rte_xxx_device, and associated operation of creating rte_device linked list. It also enables the drivers to use rte_device.name/numa_node members rather than rte_xxx_device specific members.

Notes:
======

* Some sign-off were already provided by Jan on the original v5; But, as a large number of merges have been made, I am leaving those out just in case it is not sync with initial understanding.

* This might not be in-sync with pmdinfogen as PMD_REGISTER_DRIVER is removed [7].

References:
===========

[1] http://dpdk.org/ml/archives/dev/2016-January/032387.html
[2] http://dpdk.org/ml/archives/dev/2016-April/037686.html
[3] http://dpdk.org/ml/archives/dev/2016-January/031390.html
[4] http://dpdk.org/ml/archives/dev/2016-July/043645.html
[5] http://dpdk.org/ml/archives/dev/2016-June/042439.html
[6] http://dpdk.org/ml/archives/dev/2016-June/042444.html
[7] http://dpdk.org/ml/archives/dev/2016-July/043172.html
[8] http://dpdk.org/ml/archives/dev/2016-August/044941.html

Changes since v7:
- Rebase over master (e22856313fff2)
- Merge the patch series by David [1][2] and Jan [4] into a single set hereafter, PCI and VDEV, both are re-factored for rte_device/driver model

Changes since v6:
- rebase over 16.07 (b0a1419)
- DRIVER_REGISTER_PCI macro is now passed pci_drv rather than drv
- review comments regarding missing information in log messages
- new API additions to 16.11 map objects
- review comment in [5] and [7] are not included in this series.

Changes since v5:
- Rebase over master (11c5e45d8)
- Rename RTE_EAL_PCI_REGISTER helper macro to DRIVER_REGISTER_PCI to be in sync
with DRIVER_REGISTER_PCI_TABLE. [Probably, in future, both can be merged]
- Modifications to bnxt and thunderx driver PMD registration files for using the simplified PCI device registration helper macro

Changes since v4:
- Fix compilation issue after rebase on HEAD (913154e) in previous series
- Retain rte_eth_dev_get_port_by_name and rte_eth_dev_get_name_by_port which were removed by previous patchset. These are being used by pdump library

Changes since v3:
- rebase over HEAD (913154e)
- Update arguments to RTE_EAL_PCI_REGISTER macro as per Jan's suggestion
- modify qede driver to use RTE_EAL_PCI_REGISTER
- Argument check in hotplug functions

Changes since v2:
- rebase over HEAD (d76c193)
- Move SYSFS_PCI_DRIVERS macro to rte_pci.h to avoid compilation issue

Changes since v1:
- rebased on HEAD, new drivers should be okay
- patches have been split into smaller pieces
- RTE_INIT macro has been added, but in the end, I am not sure it is useful
- device type has been removed from ethdev, as it was used only by hotplug
- getting rid of pmd type in eal patch (patch 5 of initial series) has been dropped for now, we can do this once vdev drivers have been converted

Shreyansh Jain (25):
eal: define macro container_of
eal: remove duplicate function declaration
pci: no need for dynamic tailq init
crypto: no need for a crypto pmd type
drivers: align pci driver definitions
eal: introduce init macros
driver: init/uninit common wrappers for PCI drivers
drivers: convert all pdev drivers as pci drivers
driver: Remove driver register callbacks for crypto/net eal/pci: Helpers for device name parsing/update
ethdev: do not scan all pci devices on attach
eal: add hotplug operations for pci and vdev
ethdev: convert to eal hotplug
ethdev: get rid of device type
eal: extract vdev infra
eal: Remove PDEV/VDEV unused code
drivers: convert PMD_VDEV drivers to use rte_vdev_driver
eal: move init/uninit to rte_vdev_driver
eal: remove PMD_DRIVER_REGISTER and unused pmd_types
eal: rte_pci.h includes rte_dev.h
eal: rename and move rte_pci_resource
eal/pci: inherit rte_driver by rte_pci_driver
eal: call rte_eal_driver_register
eal: introduce rte_device
eal/pci: Create rte_device list and fallback on its members

 app/test/test_pci.c                             |  10 +-
 app/test/virtual_pmd.c                          |   8 +-
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c        |   7 +-
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c      |   7 +-
 drivers/crypto/kasumi/rte_kasumi_pmd.c          |   7 +-
 drivers/crypto/null/null_crypto_pmd.c           |   7 +-
 drivers/crypto/qat/qat_qp.c                     |   2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c          |  18 +-
 drivers/crypto/snow3g/rte_snow3g_pmd.c          |   7 +-
 drivers/net/af_packet/rte_eth_af_packet.c       |  11 +-
 drivers/net/bnx2x/bnx2x_ethdev.c                |  36 +--
 drivers/net/bnxt/bnxt_ethdev.c                  |  17 +-
 drivers/net/bonding/rte_eth_bond_api.c          |   2 +-
 drivers/net/bonding/rte_eth_bond_pmd.c          |   9 +-
 drivers/net/cxgbe/cxgbe_ethdev.c                |  25 +--
 drivers/net/cxgbe/cxgbe_main.c                  |   2 +-
 drivers/net/cxgbe/sge.c                         |   7 +-
 drivers/net/e1000/em_ethdev.c                   |  17 +-
 drivers/net/e1000/igb_ethdev.c                  |  41 +---
 drivers/net/ena/ena_ethdev.c                    |  20 +-
 drivers/net/enic/enic_ethdev.c                  |  24 +-
 drivers/net/fm10k/fm10k_ethdev.c                |  30 +--
 drivers/net/i40e/i40e_ethdev.c                  |  31 +--
 drivers/net/i40e/i40e_ethdev_vf.c               |  26 +--
 drivers/net/i40e/i40e_fdir.c                    |   2 +-
 drivers/net/ixgbe/ixgbe_ethdev.c                |  48 +---
 drivers/net/mlx4/mlx4.c                         |  21 +-
 drivers/net/mlx5/mlx5.c                         |  20 +-
 drivers/net/mpipe/mpipe_tilegx.c                |  18 +-
 drivers/net/nfp/nfp_net.c                       |  28 +--
 drivers/net/null/rte_eth_null.c                 |  11 +-
 drivers/net/pcap/rte_eth_pcap.c                 |  11 +-
 drivers/net/qede/qede_ethdev.c                  |  42 +---
 drivers/net/ring/rte_eth_ring.c                 |  11 +-
 drivers/net/szedata2/rte_eth_szedata2.c         |  28 +--
 drivers/net/thunderx/nicvf_ethdev.c             |  21 +-
 drivers/net/vhost/rte_eth_vhost.c               |  11 +-
 drivers/net/virtio/virtio_ethdev.c              |  28 +--
 drivers/net/virtio/virtio_pci.c                 |   5 +-
 drivers/net/virtio/virtio_user_ethdev.c         |  10 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c            |  27 +--
 drivers/net/vmxnet3/vmxnet3_rxtx.c              |   2 +-
 drivers/net/xenvirt/rte_eth_xenvirt.c           |   9 +-
 examples/ip_pipeline/init.c                     |  22 --
 lib/librte_cryptodev/rte_cryptodev.c            |  71 ++----
 lib/librte_cryptodev/rte_cryptodev.h            |   2 -
 lib/librte_cryptodev/rte_cryptodev_pmd.h        |  45 ++--
 lib/librte_cryptodev/rte_cryptodev_version.map  |   8 +-
 lib/librte_eal/bsdapp/eal/Makefile              |   1 +
 lib/librte_eal/bsdapp/eal/eal_pci.c             |  54 ++++-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   7 +
 lib/librte_eal/common/Makefile                  |   2 +-
 lib/librte_eal/common/eal_common_dev.c          |  95 ++++----
 lib/librte_eal/common/eal_common_pci.c          |  34 ++-
 lib/librte_eal/common/eal_common_vdev.c         | 106 +++++++++
 lib/librte_eal/common/eal_private.h             |  20 +-
 lib/librte_eal/common/include/rte_common.h      |  16 ++
 lib/librte_eal/common/include/rte_dev.h         |  77 +++++--
 lib/librte_eal/common/include/rte_eal.h         |   3 +
 lib/librte_eal/common/include/rte_pci.h         |  53 +++--
 lib/librte_eal/common/include/rte_tailq.h       |   4 +-
 lib/librte_eal/common/include/rte_vdev.h        |  96 ++++++++
 lib/librte_eal/linuxapp/eal/Makefile            |   1 +
 lib/librte_eal/linuxapp/eal/eal.c               |   1 +
 lib/librte_eal/linuxapp/eal/eal_pci.c           |  23 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  10 +
 lib/librte_ether/rte_ethdev.c                   | 280 +++++-------------------
 lib/librte_ether/rte_ethdev.h                   |  40 ++--
 lib/librte_ether/rte_ether_version.map          |   9 +
 69 files changed, 784 insertions(+), 1020 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_vdev.c
 create mode 100644 lib/librte_eal/common/include/rte_vdev.h
Signature · 1 line
2.7.4
#197 lore raw

PATCH v8 1/25 eal: define macro container_of

---
 lib/librte_eal/common/include/rte_common.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/librte_eal/common/include/rte_common.h +16 -0
index 332f2a4..a9b6792 100644
@@ -322,6 +322,22 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif
 
+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *      ...
+ *      struct child c;
+ *      ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#define container_of(p, type, member) \
+	((type *) (((char *) (p)) - offsetof(type, member)))
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)
Signature · 1 line
2.7.4
#198 lore raw

Re: [PATCH v8 01/25] eal: define macro container_of

Quoted 24 lines · Shreyansh Jain
---
 lib/librte_eal/common/include/rte_common.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/librte_eal/common/include/rte_common.h +9 -0
index 332f2a4..a9b6792 100644
@@ -322,6 +322,22 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif
 
+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *      ...
+ *      struct child c;
+ *      ...
+ *  };

lib/librte_eal/common/include/rte_common.h rte_bsf32(uint32_t v) · line 343

Quoted 10 lines
lib/librte_eal/common/include/rte_common.h +7 -0
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#define container_of(p, type, member) \
+	((type *) (((char *) (p)) - offsetof(type, member)))
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)

This gives compilation error for mlx5, because the libraries mlx depends defines same macro:
.../rte_common.h:338:9: error: 'container_of' macro redefined /usr/include/infiniband/verbs.h:77:9: note: previous definition is here

Does it make sense to protect macro with
#ifndef container_of
...
#endif

OR

add a dpdk prefix?

Regards,
ferruh

#199 lore raw

Re: [PATCH v8 01/25] eal: define macro container_of

Hi Ferruh,

Quoted 32 lines · Ferruh Yigit
Quoted 31 lines · Shreyansh Jain
---
 lib/librte_eal/common/include/rte_common.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/librte_eal/common/include/rte_common.h +16 -0
index 332f2a4..a9b6792 100644
@@ -322,6 +322,22 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif
 
+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *      ...
+ *      struct child c;
+ *      ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#define container_of(p, type, member) \
+	((type *) (((char *) (p)) - offsetof(type, member)))
+
 #define _RTE_STR(x) #x
Quoted 8 lines

lib/librte_eal/common/include/rte_common.h rte_bsf32(uint32_t v) · line 343

Quoted 3 lines
lib/librte_eal/common/include/rte_common.h +0 -0
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)

This gives compilation error for mlx5, because the libraries mlx depends defines same macro:
..../rte_common.h:338:9: error: 'container_of' macro redefined /usr/include/infiniband/verbs.h:77:9: note: previous definition is here

I thought testing with scripts/test-build.sh and default configuration would compile all drivers - I was wrong. I will retest the patches and release again.

Is there a better way to test that no driver breaks? Any particular parameters I should use for test-build.sh?

I used 'x86_64-native-linuxapp-gcc+default+debug+shared' for all patches.

Quoted 6 lines

Does it make sense to protect macro with
#ifndef container_of
....
#endif

Quoted 8 lines

OR

add a dpdk prefix?

Regards,
ferruh

-
Shreyansh

#200 lore raw

Re: [PATCH v8 01/25] eal: define macro container_of

2016-08-30 09:57, Shreyansh Jain:

Quoted 6 lines · Ferruh Yigit
Quoted 4 lines

This gives compilation error for mlx5, because the libraries mlx depends defines same macro:
..../rte_common.h:338:9: error: 'container_of' macro redefined /usr/include/infiniband/verbs.h:77:9: note: previous definition is here

Quoted 6 lines

I thought testing with scripts/test-build.sh and default configuration would compile all drivers - I was wrong. I will retest the patches and release again.

Is there a better way to test that no driver breaks? Any particular parameters I should use for test-build.sh?

Yes I suggest to create a file ~/.config/dpdk/devel.config to adapt the configuration to your system.
Once you have installed the required dependencies, you can make this kind of configuration:

mlxdep=$root/mlx/mofed-3.3-1.0.0.0
szedep=$root/sze/usr-1.1.4
if echo $DPDK_TARGET | grep -q '^x86_64' ; then
export DPDK_DEP_ARCHIVE=y
export DPDK_DEP_ZLIB=y
export DPDK_DEP_PCAP=y
export DPDK_DEP_SSL=y
export DPDK_DEP_MOFED=y
export DPDK_DEP_SZE=y
export DPDK_DEP_CFLAGS="-I$mlxdep/include -I$szedep/include" export DPDK_DEP_LDFLAGS="-L$mlxdep/lib -L$szedep/lib64 -rpath=$szedep/lib64" export AESNI_MULTI_BUFFER_LIB_PATH=$root/aesni/ipsec-043
export LIBSSO_SNOW3G_PATH=$root/libsso/libsso-snow3g-0.3.1 export LIBSSO_KASUMI_PATH=$root/libsso/libsso-kasumi-0.3.1
fi

Quoted 1 line

I used 'x86_64-native-linuxapp-gcc+default+debug+shared' for all patches.

It is a good idea to test also with clang (x86_64-native-linuxapp-clang) and another arch (e.g. arm64-thunderx-linuxapp-gcc).

#201 lore raw

Re: [PATCH v8 01/25] eal: define macro container_of

Hi Thomas,

Quoted 11 lines · Thomas Monjalon

2016-08-30 09:57, Shreyansh Jain:

Quoted 10 lines · Ferruh Yigit
Quoted 4 lines

This gives compilation error for mlx5, because the libraries mlx depends defines same macro:
..../rte_common.h:338:9: error: 'container_of' macro redefined /usr/include/infiniband/verbs.h:77:9: note: previous definition is here

I thought testing with scripts/test-build.sh and default configuration would compile all drivers - I was wrong. I will retest the patches and release again.

Quoted 7 lines
Quoted 2 lines

Is there a better way to test that no driver breaks? Any particular parameters I should use for test-build.sh?

Yes I suggest to create a file ~/.config/dpdk/devel.config to adapt the configuration to your system.
Once you have installed the required dependencies, you can make this kind of configuration:

Ok.

Quoted 3 lines

mlxdep=$root/mlx/mofed-3.3-1.0.0.0
szedep=$root/sze/usr-1.1.4

What does '$root' here refer to?
I am assuming 'mofed-3.3-1.0.0.0' and 'usr-1.1.4' are part of some dependencies that I should be revolving. Is that so? As of now I don't have much idea about this - I will have a look and ping back in case I am stuck.

Quoted 5 lines

if echo $DPDK_TARGET | grep -q '^x86_64' ; then
export DPDK_DEP_ARCHIVE=y
export DPDK_DEP_ZLIB=y
export DPDK_DEP_PCAP=y
export DPDK_DEP_SSL=y

Quoted 8 lines

export DPDK_DEP_MOFED=y
export DPDK_DEP_SZE=y
export DPDK_DEP_CFLAGS="-I$mlxdep/include -I$szedep/include" export DPDK_DEP_LDFLAGS="-L$mlxdep/lib -L$szedep/lib64 -rpath=$szedep/lib64" export AESNI_MULTI_BUFFER_LIB_PATH=$root/aesni/ipsec-043
export LIBSSO_SNOW3G_PATH=$root/libsso/libsso-snow3g-0.3.1 export LIBSSO_KASUMI_PATH=$root/libsso/libsso-kasumi-0.3.1
fi

Thanks. I will try the above.

Quoted 5 lines
Quoted 2 lines

I used 'x86_64-native-linuxapp-gcc+default+debug+shared' for all patches.

It is a good idea to test also with clang (x86_64-native-linuxapp-clang) and another arch (e.g. arm64-thunderx-linuxapp-gcc).

Before releasing v9, I will do these steps.
Thank you for suggestions.

-
Shreyansh

#202 lore raw

Re: [PATCH v8 01/25] eal: define macro container_of

2016-08-30 17:29, Shreyansh Jain:

Quoted 10 lines · Thomas Monjalon
Quoted 8 lines

2016-08-30 09:57, Shreyansh Jain:

Quoted 2 lines

Is there a better way to test that no driver breaks? Any particular parameters I should use for test-build.sh?

Yes I suggest to create a file ~/.config/dpdk/devel.config to adapt the configuration to your system.
Once you have installed the required dependencies, you can make this kind of configuration:

Quoted 6 lines

Ok.

Quoted 2 lines

mlxdep=$root/mlx/mofed-3.3-1.0.0.0
szedep=$root/sze/usr-1.1.4

What does '$root' here refer to?

It is the directory where I compile the DPDK dependencies.

Quoted 2 lines

I am assuming 'mofed-3.3-1.0.0.0' and 'usr-1.1.4' are part of some dependencies that I should be revolving. Is that so?

Yes, download and compile them as explain in the respective guides.

Quoted 8 lines

As of now I don't have much idea about this - I will have a look and ping back in case I am stuck.

Quoted 5 lines

if echo $DPDK_TARGET | grep -q '^x86_64' ; then
export DPDK_DEP_ARCHIVE=y
export DPDK_DEP_ZLIB=y
export DPDK_DEP_PCAP=y
export DPDK_DEP_SSL=y

You need to install the packages to resolve these dependencies (libarchive-dev, libzip-dev, libpcap-dev, libcrypto-dev).

Quoted 19 lines
Quoted 8 lines

export DPDK_DEP_MOFED=y
export DPDK_DEP_SZE=y
export DPDK_DEP_CFLAGS="-I$mlxdep/include -I$szedep/include" export DPDK_DEP_LDFLAGS="-L$mlxdep/lib -L$szedep/lib64 -rpath=$szedep/lib64" export AESNI_MULTI_BUFFER_LIB_PATH=$root/aesni/ipsec-043
export LIBSSO_SNOW3G_PATH=$root/libsso/libsso-snow3g-0.3.1 export LIBSSO_KASUMI_PATH=$root/libsso/libsso-kasumi-0.3.1
fi

Thanks. I will try the above.

Quoted 5 lines
Quoted 2 lines

I used 'x86_64-native-linuxapp-gcc+default+debug+shared' for all patches.

It is a good idea to test also with clang (x86_64-native-linuxapp-clang) and another arch (e.g. arm64-thunderx-linuxapp-gcc).

Before releasing v9, I will do these steps.
Thank you for suggestions.

#203 lore raw

Re: [PATCH v8 01/25] eal: define macro container_of

Hi Thomas,

Quoted 11 lines · Thomas Monjalon

2016-08-30 17:29, Shreyansh Jain:

Quoted 10 lines · Thomas Monjalon
Quoted 8 lines

2016-08-30 09:57, Shreyansh Jain:

Quoted 2 lines

Is there a better way to test that no driver breaks? Any particular parameters I should use for test-build.sh?

Yes I suggest to create a file ~/.config/dpdk/devel.config to adapt the configuration to your system.
Once you have installed the required dependencies, you can make this kind of configuration:

Quoted 8 lines
Quoted 6 lines

Ok.

Quoted 2 lines

mlxdep=$root/mlx/mofed-3.3-1.0.0.0
szedep=$root/sze/usr-1.1.4

What does '$root' here refer to?

It is the directory where I compile the DPDK dependencies.

Ok - understood. I guessed the same

Quoted 5 lines
Quoted 3 lines

I am assuming 'mofed-3.3-1.0.0.0' and 'usr-1.1.4' are part of some dependencies that I should be revolving. Is that so?

Yes, download and compile them as explain in the respective guides.

Ok.

Quoted 4 lines
Quoted 4 lines

As of now I don't have much idea about this - I will have a look and ping back in case I am stuck.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

if echo $DPDK_TARGET | grep -q '^x86_64' ; then
export DPDK_DEP_ARCHIVE=y
export DPDK_DEP_ZLIB=y
export DPDK_DEP_PCAP=y
export DPDK_DEP_SSL=y

You need to install the packages to resolve these dependencies (libarchive-dev, libzip-dev, libpcap-dev, libcrypto-dev).

Thanks for the info.

Quoted 13 lines
Quoted 13 lines
Quoted 9 lines

export DPDK_DEP_MOFED=y
export DPDK_DEP_SZE=y
export DPDK_DEP_CFLAGS="-I$mlxdep/include -I$szedep/include" export DPDK_DEP_LDFLAGS="-L$mlxdep/lib -L$szedep/lib64 -rpath=$szedep/lib64" export AESNI_MULTI_BUFFER_LIB_PATH=$root/aesni/ipsec-043
export LIBSSO_SNOW3G_PATH=$root/libsso/libsso-snow3g-0.3.1 export LIBSSO_KASUMI_PATH=$root/libsso/libsso-kasumi-0.3.1
fi

Thanks. I will try the above.

Quoted 1 line
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I used 'x86_64-native-linuxapp-gcc+default+debug+shared' for all patches.

It is a good idea to test also with clang (x86_64-native-linuxapp-clang) and another arch (e.g. arm64-thunderx-linuxapp-gcc).

Before releasing v9, I will do these steps.
Thank you for suggestions.

-
Shreyansh

#204 lore raw

Re: [PATCH v8 01/25] eal: define macro container_of

In reply to Ferruh Yigit

Hi Ferruh,

Forgot to add a comment in previous reply to this email:

Quoted 41 lines · Ferruh Yigit
Quoted 24 lines · Shreyansh Jain
---
 lib/librte_eal/common/include/rte_common.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/librte_eal/common/include/rte_common.h +9 -0
index 332f2a4..a9b6792 100644
@@ -322,6 +322,22 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif
 
+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *      ...
+ *      struct child c;
+ *      ...
+ *  };

lib/librte_eal/common/include/rte_common.h rte_bsf32(uint32_t v) · line 343

Quoted 10 lines
lib/librte_eal/common/include/rte_common.h +7 -0
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#define container_of(p, type, member) \
+	((type *) (((char *) (p)) - offsetof(type, member)))
+
 #define _RTE_STR(x) #x
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)

This gives compilation error for mlx5, because the libraries mlx depends defines same macro:
..../rte_common.h:338:9: error: 'container_of' macro redefined /usr/include/infiniband/verbs.h:77:9: note: previous definition is here

Quoted 4 lines

Does it make sense to protect macro with
#ifndef container_of
....
#endif

Sounds good - probably would prevent double definition in future if someone includes any linux header having similar definition.

Generally the container_of definitions are consistent - that is, they would invariably use the offsetof from member. In which case, creating a new dpdk_* would only duplicate. Thus, I prefer the #ifndef.

Quoted 9 lines

OR

add a dpdk prefix?

Regards,
ferruh

-
Shreyansh

#205 lore raw

Re: [PATCH v8 01/25] eal: define macro container_of

In reply to Ferruh Yigit

Hi Ferruh,

Quoted 32 lines · Ferruh Yigit
Quoted 31 lines · Shreyansh Jain
---
 lib/librte_eal/common/include/rte_common.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
lib/librte_eal/common/include/rte_common.h +16 -0
index 332f2a4..a9b6792 100644
@@ -322,6 +322,22 @@ rte_bsf32(uint32_t v)
 #define offsetof(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER)
 #endif
 
+/**
+ * Return pointer to the wrapping struct instance.
+ * Example:
+ *
+ *  struct wrapper {
+ *      ...
+ *      struct child c;
+ *      ...
+ *  };
+ *
+ *  struct child *x = obtain(...);
+ *  struct wrapper *w = container_of(x, struct wrapper, c);
+ */
+#define container_of(p, type, member) \
+	((type *) (((char *) (p)) - offsetof(type, member)))
+
 #define _RTE_STR(x) #x
Quoted 8 lines

lib/librte_eal/common/include/rte_common.h rte_bsf32(uint32_t v) · line 343

Quoted 3 lines
lib/librte_eal/common/include/rte_common.h +0 -0
 /** Take a macro value and get a string version of it */
 #define RTE_STR(x) _RTE_STR(x)

This gives compilation error for mlx5, because the libraries mlx depends defines same macro:
..../rte_common.h:338:9: error: 'container_of' macro redefined /usr/include/infiniband/verbs.h:77:9: note: previous definition is here

I have converted into a conditional macro in v9.
I still couldn't compile and test mlx* - my environment is still not prepared. Though, I can see that this error is not being reported anymore.

Quoted 6 lines

Does it make sense to protect macro with
#ifndef container_of
....
#endif

Quoted 8 lines

OR

add a dpdk prefix?

Regards,
ferruh

-
Shreyansh

#206 lore raw

PATCH v8 2/25 eal: remove duplicate function declaration

In reply to Shreyansh Jain

rte_eal_dev_init is declared in both eal_private.h and rte_dev.h since its introduction.
This function has been exported in ABI, so remove it from eal_private.h

Fixes e57f20e05177 ("eal: make vdev init path generic for both virtual and pci devices")
---
 lib/librte_eal/common/eal_private.h | 7 -------
 lib/librte_eal/linuxapp/eal/eal.c   | 1 +
 2 files changed, 1 insertion(+), 7 deletions(-)
lib/librte_eal/common/eal_private.h +0 -7
index 19f7535..ca1aec6 100644
@@ -237,13 +237,6 @@ int rte_eal_intr_init(void);
 int rte_eal_alarm_init(void);
 
 /**
- * This function initialises any virtual devices
- *
- * This function is private to the EAL.
- */
-int rte_eal_dev_init(void);
-
-/**
  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,
  * etc.) loaded.
  *
lib/librte_eal/linuxapp/eal/eal.c +1 -0
index d5b81a3..9412983 100644
@@ -70,6 +70,7 @@
 #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>
Signature · 1 line
2.7.4
#207 lore raw

PATCH v8 3/25 pci: no need for dynamic tailq init

In reply to Shreyansh Jain

These lists can be initialized once and for all at build time. With this, those lists are only manipulated in a common place (and we could even make them private).

A nice side effect is that pci drivers can now register in constructors.

---
 lib/librte_eal/bsdapp/eal/eal_pci.c    | 3 ---
 lib/librte_eal/common/eal_common_pci.c | 6 ++++--
 lib/librte_eal/linuxapp/eal/eal_pci.c  | 3 ---
 3 files changed, 4 insertions(+), 8 deletions(-)
lib/librte_eal/bsdapp/eal/eal_pci.c +0 -3
index 374b68f..a73cbb0 100644
@@ -623,9 +623,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 int
 rte_eal_pci_init(void)
 {
-	TAILQ_INIT(&pci_driver_list);
-	TAILQ_INIT(&pci_device_list);
-
 	/* for debug purposes, PCI can be disabled */
 	if (internal_config.no_pci)
 		return 0;
lib/librte_eal/common/eal_common_pci.c +4 -2
index 7248c38..6a0f6ac 100644
@@ -82,8 +82,10 @@
 
 #include "eal_private.h"
 
-struct pci_driver_list pci_driver_list;
-struct pci_device_list pci_device_list;
+struct pci_driver_list pci_driver_list =
+	TAILQ_HEAD_INITIALIZER(pci_driver_list);
+struct pci_device_list pci_device_list =
+	TAILQ_HEAD_INITIALIZER(pci_device_list);
 
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 
lib/librte_eal/linuxapp/eal/eal_pci.c +0 -3
index cd9de7c..f0215ee 100644
@@ -743,9 +743,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 int
 rte_eal_pci_init(void)
 {
-	TAILQ_INIT(&pci_driver_list);
-	TAILQ_INIT(&pci_device_list);
-
 	/* for debug purposes, PCI can be disabled */
 	if (internal_config.no_pci)
 		return 0;
Signature · 1 line
2.7.4