Skip to contentSkip to conversation

Generic devargs parsing

PATCH Superseded Gaetan Rivet 6 participants 145 messages May 24, 2017 – Jul 9, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Generic devargs parsing

The second part of the work outlined in [1] and [2]. The first part is at [3].

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.

Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.

With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.

Buses needs only to implement the "parse" method for their devices to be declared in this way.

[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html

This patchset depends on:

[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/

Gaetan Rivet (14):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper

 app/test-pmd/testpmd.c                      |   9 +-
 app/test-pmd/testpmd.h                      |   2 +
 doc/guides/rel_notes/deprecation.rst        |   5 +
 drivers/net/bnxt/bnxt.h                     |   1 +
 drivers/net/bonding/rte_eth_bond_args.c     |   1 +
 drivers/net/e1000/e1000_ethdev.h            |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.h            |   1 +
 drivers/net/mlx5/mlx5.h                     |   1 +
 drivers/net/sfc/sfc.h                       |   1 +
 drivers/net/virtio/virtio_pci.c             |   5 +-
 lib/librte_eal/common/eal_common_devargs.c  | 137 ++++++++++++++++------------
 lib/librte_eal/common/eal_common_options.c  |  13 +--
 lib/librte_eal/common/eal_common_pci.c      |  15 +--
 lib/librte_eal/common/eal_common_vdev.c     |  12 +--
 lib/librte_eal/common/include/rte_bus.h     |  17 ++++
 lib/librte_eal/common/include/rte_dev.h     |  12 +++
 lib/librte_eal/common/include/rte_devargs.h |  42 +++++----
 lib/librte_eal/common/include/rte_pci.h     |   9 --
 lib/librte_eal/common/include/rte_vdev.h    |   2 +-
 19 files changed, 167 insertions(+), 119 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/14 net/bonding: properly reference PCI header

---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
index e3bdad9..b6a924e 100644
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/14 net/bnxt: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
index 4418c7f..678a844 100644
@@ -37,6 +37,7 @@
 #include <inttypes.h>
 #include <sys/queue.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_memory.h>
 #include <rte_lcore.h>
Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/14 net/mlx5: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
index 67fd742..50c4fdd 100644
@@ -54,6 +54,7 @@
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
+#include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#4 lore raw

PATCH 4/14 net/e1000: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
index 8352d0a..6f25428 100644
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include <rte_time.h>
+#include <rte_pci.h>
 
 #define E1000_INTEL_VENDOR_ID 0x8086
 
Signature · 1 line
2.1.4
#5 lore raw

PATCH 5/14 net/ixgbe: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index b576a6f..fc39a3e 100644
@@ -39,6 +39,7 @@
 #include "ixgbe_bypass.h"
 #include <rte_time.h>
 #include <rte_hash.h>
+#include <rte_pci.h>
 
 /* need update link, bit flag */
 #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
#6 lore raw

PATCH 6/14 net/sfc: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
index fad0ce0..ec82e87 100644
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#7 lore raw

PATCH 7/14 app/testpmd: properly reference PCI header

In reply to Gaetan Rivet
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
index a15598b..d61a4ad 100644
@@ -34,6 +34,8 @@
 #ifndef _TESTPMD_H_
 #define _TESTPMD_H_
 
+#include <rte_pci.h>
+
 #define RTE_PORT_ALL            (~(portid_t)0x0)
 
 #define RTE_TEST_RX_DESC_MAX    2048
Signature · 1 line
2.1.4
#8 lore raw

PATCH 8/14 dev: device kernel module is a device attribute

In reply to Gaetan Rivet

It is used in generic device structures and must not be tied to a bus.

---
 lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++
 lib/librte_eal/common/include/rte_pci.h |  9 ---------
 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
index 7092b16..d4b0953 100644
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 } while (0)
 
 /**
+ * Device driver.
+ */
+enum rte_kernel_driver {
+	RTE_KDRV_UNKNOWN = 0,
+	RTE_KDRV_IGB_UIO,
+	RTE_KDRV_VFIO,
+	RTE_KDRV_UIO_GENERIC,
+	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
+};
+
+/**
  * A generic memory resource representation.
  */
 struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
index ab64c63..45c5082 100644
@@ -149,15 +149,6 @@ struct rte_pci_addr {
 
 struct rte_devargs;
 
-enum rte_kernel_driver {
-	RTE_KDRV_UNKNOWN = 0,
-	RTE_KDRV_IGB_UIO,
-	RTE_KDRV_VFIO,
-	RTE_KDRV_UIO_GENERIC,
-	RTE_KDRV_NIC_UIO,
-	RTE_KDRV_NONE,
-};
-
 /**
  * A structure describing a PCI device.
  */
Signature · 1 line
2.1.4
#9 lore raw

PATCH 9/14 bus: introduce bus scan policies

In reply to Gaetan Rivet

Scan policies describe the way a bus should scan the system to search for possible devices.

Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices

---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
index 0b48e66..fa08454 100644
@@ -123,6 +123,22 @@ typedef int (*rte_bus_detach_t)(struct rte_device *dev);
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
 /**
+ * Bus scan policies
+ */
+enum rte_bus_scan_mode {
+	RTE_BUS_SCAN_UNDEFINED,
+	RTE_BUS_SCAN_WHITELIST,
+	RTE_BUS_SCAN_BLACKLIST,
+};
+
+/**
+ * A structure used to configure bus operations.
+ */
+struct rte_bus_conf {
+	enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
+};
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -134,6 +150,7 @@ struct rte_bus {
 	rte_bus_attach_t attach;     /**< Probe single device for drivers */
 	rte_bus_detach_t detach;     /**< Remove single device from driver */
 	rte_bus_parse_t parse;       /**< Parse a device name */
+	struct rte_bus_conf conf;    /**< Bus configuration */
 };
 
 /**
Signature · 1 line
2.1.4
#10 lore raw

PATCH 10/14 devargs: parse bus policies

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
index 8bb72a2..a5014bf 100644
@@ -130,6 +130,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 
 		break;
 	}
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	}
 
 	free(buf);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
Signature · 1 line
2.1.4
#11 lore raw

PATCH 11/14 devargs: generic device representation

In reply to Gaetan Rivet

Remove the dependency of this subsystem upon bus specific device representation.

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

---
 app/test-pmd/testpmd.c                      |  9 ++----
 lib/librte_eal/common/eal_common_devargs.c  | 48 +++++------------------------
 lib/librte_eal/common/eal_common_pci.c      |  9 ++++--
 lib/librte_eal/common/eal_common_vdev.c     | 11 +++----
 lib/librte_eal/common/include/rte_devargs.h | 16 ++--------
 lib/librte_eal/common/include/rte_vdev.h    |  2 +-
 6 files changed, 24 insertions(+), 71 deletions(-)
app/test-pmd/testpmd.c +2 -7
index d1041af..daeece2 100644
@@ -1807,7 +1807,6 @@ rmv_event_callback(void *arg)
 {
 	struct rte_eth_dev *dev;
 	struct rte_devargs *da;
-	char name[32] = "";
 	uint8_t port_id = (intptr_t)arg;
 
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
@@ -1816,12 +1815,8 @@ rmv_event_callback(void *arg)
 
 	stop_port(port_id);
 	close_port(port_id);
-	if (da->type == RTE_DEVTYPE_VIRTUAL)
-		snprintf(name, sizeof(name), "%s", da->virt.drv_name);
-	else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI)
-		rte_pci_device_name(&da->pci.addr, name, sizeof(name));
-	printf("removing device %s\n", name);
-	rte_eal_dev_detach(name);
+	printf("removing device %s\n", da->name);
+	rte_eal_dev_detach(da->name);
 	dev->state = RTE_ETH_DEV_UNUSED;
 }
 
lib/librte_eal/common/eal_common_devargs.c +8 -40

66 lines not on this page · raw message

lib/librte_eal/common/eal_common_pci.c +6 -3
index 0f171ec..17d272a 100644
@@ -102,12 +102,15 @@ const char *pci_get_sysfs_path(void)
 static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 {
 	struct rte_devargs *devargs;
+	struct rte_pci_addr addr;
+	struct rte_bus *pbus;
 
+	pbus = rte_bus_from_name(PCI_BUS_NAME);
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&
-			devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)
+		if (devargs->bus != pbus)
 			continue;
-		if (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))
+		devargs->bus->parse(devargs->name, &addr);
+		if (!rte_eal_compare_pci_addr(&dev->addr, &addr))
 			return devargs;
 	}
 	return NULL;
lib/librte_eal/common/eal_common_vdev.c +5 -6
index 539835a..eab5f9d 100644
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)
 	if (args)
 		devargs->args = strdup(args);
 
-	ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", name);
-	if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) {
+	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name);
+	if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
 		free(devargs->args);
 		free(devargs);
 		return NULL;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args)
 
 	dev->device.devargs = devargs;
 	dev->device.numa_node = SOCKET_ID_ANY;
-	dev->device.name = devargs->virt.drv_name;
+	dev->device.name = devargs->name;
 
 	ret = vdev_probe_all_drivers(dev);
 	if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)
 		if (devargs->bus != vbus)
 			continue;
 
-		dev = find_vdev(devargs->virt.drv_name);
+		dev = find_vdev(devargs->name);
 		if (dev)
 			continue;
 
@@ -314,7 +313,7 @@ vdev_scan(void)
 
 		dev->device.devargs = devargs;
 		dev->device.numa_node = SOCKET_ID_ANY;
-		dev->device.name = devargs->virt.drv_name;
+		dev->device.name = devargs->name;
 
 		TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 	}
lib/librte_eal/common/include/rte_devargs.h +2 -14
index 1f50a24..6a26d3d 100644
@@ -50,7 +50,6 @@ extern "C" {
 
 #include <stdio.h>
 #include <sys/queue.h>
-#include <rte_pci.h>
 #include <rte_bus.h>
 
 /**
@@ -77,21 +76,10 @@ struct rte_devargs {
 	TAILQ_ENTRY(rte_devargs) next;
 	/** Type of device. */
 	enum rte_devtype type;
-	RTE_STD_C11
-	union {
-		/** Used if type is RTE_DEVTYPE_*_PCI. */
-		struct {
-			/** PCI location. */
-			struct rte_pci_addr addr;
-		} pci;
-		/** Used if type is RTE_DEVTYPE_VIRTUAL. */
-		struct {
-			/** Driver name. */
-			char drv_name[32];
-		} virt;
-	};
 	/** Bus handle for the device. */
 	struct rte_bus *bus;
+	/** Name of the device. */
+	char name[32];
 	/** Arguments string as given by user or "" for no argument. */
 	char *args;
 };
lib/librte_eal/common/include/rte_vdev.h +1 -1
index 2d02c68..4debcde 100644
@@ -52,7 +52,7 @@ static inline const char *
 rte_vdev_device_name(const struct rte_vdev_device *dev)
 {
 	if (dev && dev->device.devargs)
-		return dev->device.devargs->virt.drv_name;
+		return dev->device.devargs->name;
 	return NULL;
 }
 
Signature · 1 line
2.1.4
#12 lore raw

PATCH 12/14 net/virtio: do not reference device type

In reply to Gaetan Rivet
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
index b7b3d61..cd48fb5 100644
@@ -38,6 +38,7 @@
 #endif
 
 #include <rte_io.h>
+#include <rte_bus.h>
 
 #include "virtio_pci.h"
 #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
 	if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
 		    (!dev->device.devargs ||
-		     dev->device.devargs->type !=
-			RTE_DEVTYPE_WHITELISTED_PCI)) {
+		     dev->device.devargs->bus !=
+		     rte_bus_from_name(PCI_BUS_NAME))) {
 			PMD_INIT_LOG(INFO,
 				"skip kernel managed virtio device.");
 			return 1;
Signature · 1 line
2.1.4
#13 lore raw

PATCH 13/14 devargs: generic device types

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c  |  4 ++--
 lib/librte_eal/common/eal_common_options.c  | 13 +++----------
 lib/librte_eal/common/eal_common_pci.c      |  6 +++---
 lib/librte_eal/common/eal_common_vdev.c     |  1 -
 lib/librte_eal/common/include/rte_devargs.h |  6 +++---
 5 files changed, 11 insertions(+), 19 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
index 51ffb45..d423125 100644
@@ -115,14 +115,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", buf);
 	if (ret < 0 || ret >= (int)sizeof(devargs->name))
 		goto fail;
-	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
 			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
 			goto fail;
 		}
-	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
lib/librte_eal/common/eal_common_options.c +3 -10
index f470195..075b0ea 100644
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,
 	switch (opt) {
 	/* blacklist */
 	case 'b':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED,
 				optarg) < 0) {
 			return -1;
 		}
 		break;
 	/* whitelist */
 	case 'w':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 
 	case OPT_VDEV_NUM:
-		if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)
 		return -1;
 	}
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
-		rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
-		RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
-			"cannot be used at the same time\n");
-		return -1;
-	}
-
 	return 0;
 }
 
lib/librte_eal/common/eal_common_pci.c +3 -3
index 17d272a..6d9fdda 100644
@@ -229,7 +229,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 	/* no initialization when blacklisted, return without error */
 	if (dev->device.devargs != NULL &&
 		dev->device.devargs->type ==
-			RTE_DEVTYPE_BLACKLISTED_PCI) {
+			RTE_DEVTYPE_BLACKLISTED) {
 		RTE_LOG(INFO, EAL, "  Device is blacklisted, not"
 			" initializing\n");
 		return 1;
@@ -416,7 +416,7 @@ rte_pci_probe(void)
 	int probe_all = 0;
 	int ret = 0;
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
+	if (rte_pci_bus.bus.conf.scan_mode == RTE_BUS_SCAN_WHITELIST)
 		probe_all = 1;
 
 	FOREACH_DEVICE_ON_PCIBUS(dev) {
@@ -431,7 +431,7 @@ rte_pci_probe(void)
 		if (probe_all)
 			ret = pci_probe_all_drivers(dev);
 		else if (devargs != NULL &&
-			devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
+			devargs->type == RTE_DEVTYPE_WHITELISTED)
 			ret = pci_probe_all_drivers(dev);
 		if (ret < 0) {
 			RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
index eab5f9d..fc5e2d2 100644
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)
 	if (!devargs)
 		return NULL;
 
-	devargs->type = RTE_DEVTYPE_VIRTUAL;
 	devargs->bus = rte_bus_from_name(VIRTUAL_BUS_NAME);
 	if (args)
 		devargs->args = strdup(args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
index 6a26d3d..6e9e134 100644
@@ -56,9 +56,9 @@ extern "C" {
  * Type of generic device
  */
 enum rte_devtype {
-	RTE_DEVTYPE_WHITELISTED_PCI,
-	RTE_DEVTYPE_BLACKLISTED_PCI,
-	RTE_DEVTYPE_VIRTUAL,
+	RTE_DEVTYPE_UNDEFINED,
+	RTE_DEVTYPE_WHITELISTED,
+	RTE_DEVTYPE_BLACKLISTED,
 };
 
 /**
Signature · 1 line
2.1.4
#14 lore raw

PATCH 14/14 devargs: introduce cleaner parsing helper

In reply to Gaetan Rivet

Introduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.

The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.

A deprecation notice is issued.

This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.

---
 doc/guides/rel_notes/deprecation.rst        |  5 ++
 lib/librte_eal/common/eal_common_devargs.c  | 86 ++++++++++++++++++++---------
 lib/librte_eal/common/include/rte_devargs.h | 20 +++++++
 3 files changed, 85 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index ba9b5a2..f90cd87 100644
@@ -128,3 +128,8 @@ Deprecation Notices
   The non-"do-sig" versions of the hash tables will be removed
   (including the ``signature_offset`` parameter)
   and the "do-sig" versions renamed accordingly.
+
+* eal: the following function is deprecated starting from 17.08 and will
+  be removed in 17.11:
+
+  - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +60 -26

116 lines not on this page · raw message

lib/librte_eal/common/include/rte_devargs.h +20 -0
index 6e9e134..2ab8864 100644
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
 /**
+ * Parse a device string.
+ *
+ * Verify that a bus is capable of handling the device passed
+ * in argument. Store which bus will handle the device, its name
+ * and the eventual device parameters.
+ *
+ * @param dev
+ *   The device declaration string.
+ * @param da
+ *   The devargs structure holding the device information.
+ *
+ * @return
+ *   - 0 on success.
+ *   - Negative errno on error.
+ */
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);
+
+/**
  * Add a device to the user device list
  *
  * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
#15 lore raw

v2 cover Generic devargs parsing

In reply to Gaetan Rivet

The second part of the work outlined in [1] and [2]. The first part is at [3].

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.

Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.

With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.

Buses needs only to implement the "parse" method for their devices to be declared in this way.

[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html

This patchset depends on:

[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/

v1 -> v2:

* fix PCI whitelist mode

Gaetan Rivet (14):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper

 app/test-pmd/testpmd.c                      |   9 +-
 app/test-pmd/testpmd.h                      |   2 +
 doc/guides/rel_notes/deprecation.rst        |   5 +
 drivers/net/bnxt/bnxt.h                     |   1 +
 drivers/net/bonding/rte_eth_bond_args.c     |   1 +
 drivers/net/e1000/e1000_ethdev.h            |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.h            |   1 +
 drivers/net/mlx5/mlx5.h                     |   1 +
 drivers/net/sfc/sfc.h                       |   1 +
 drivers/net/virtio/virtio_pci.c             |   5 +-
 lib/librte_eal/common/eal_common_devargs.c  | 137 ++++++++++++++++------------
 lib/librte_eal/common/eal_common_options.c  |  13 +--
 lib/librte_eal/common/eal_common_pci.c      |  15 +--
 lib/librte_eal/common/eal_common_vdev.c     |  12 +--
 lib/librte_eal/common/include/rte_bus.h     |  17 ++++
 lib/librte_eal/common/include/rte_dev.h     |  12 +++
 lib/librte_eal/common/include/rte_devargs.h |  42 +++++----
 lib/librte_eal/common/include/rte_pci.h     |   9 --
 lib/librte_eal/common/include/rte_vdev.h    |   2 +-
 19 files changed, 167 insertions(+), 119 deletions(-)
Signature · 1 line
2.1.4
#16 lore raw

PATCH v2 1/14 net/bonding: properly reference PCI header

---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
index e3bdad9..b6a924e 100644
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
Signature · 1 line
2.1.4
#17 lore raw

PATCH v2 2/14 net/bnxt: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
index 4418c7f..678a844 100644
@@ -37,6 +37,7 @@
 #include <inttypes.h>
 #include <sys/queue.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_memory.h>
 #include <rte_lcore.h>
Signature · 1 line
2.1.4
#18 lore raw

PATCH v2 3/14 net/mlx5: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
index 67fd742..50c4fdd 100644
@@ -54,6 +54,7 @@
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
+#include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#19 lore raw

PATCH v2 4/14 net/e1000: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
index 8352d0a..6f25428 100644
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include <rte_time.h>
+#include <rte_pci.h>
 
 #define E1000_INTEL_VENDOR_ID 0x8086
 
Signature · 1 line
2.1.4
#20 lore raw

PATCH v2 5/14 net/ixgbe: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index b576a6f..fc39a3e 100644
@@ -39,6 +39,7 @@
 #include "ixgbe_bypass.h"
 #include <rte_time.h>
 #include <rte_hash.h>
+#include <rte_pci.h>
 
 /* need update link, bit flag */
 #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
#21 lore raw

PATCH v2 6/14 net/sfc: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
index fad0ce0..ec82e87 100644
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#22 lore raw

PATCH v2 7/14 app/testpmd: properly reference PCI header

In reply to Gaetan Rivet
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
index a15598b..d61a4ad 100644
@@ -34,6 +34,8 @@
 #ifndef _TESTPMD_H_
 #define _TESTPMD_H_
 
+#include <rte_pci.h>
+
 #define RTE_PORT_ALL            (~(portid_t)0x0)
 
 #define RTE_TEST_RX_DESC_MAX    2048
Signature · 1 line
2.1.4
#23 lore raw

PATCH v2 8/14 dev: device kernel module is a device attribute

In reply to Gaetan Rivet

It is used in generic device structures and must not be tied to a bus.

---
 lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++
 lib/librte_eal/common/include/rte_pci.h |  9 ---------
 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
index 7092b16..d4b0953 100644
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 } while (0)
 
 /**
+ * Device driver.
+ */
+enum rte_kernel_driver {
+	RTE_KDRV_UNKNOWN = 0,
+	RTE_KDRV_IGB_UIO,
+	RTE_KDRV_VFIO,
+	RTE_KDRV_UIO_GENERIC,
+	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
+};
+
+/**
  * A generic memory resource representation.
  */
 struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
index ab64c63..45c5082 100644
@@ -149,15 +149,6 @@ struct rte_pci_addr {
 
 struct rte_devargs;
 
-enum rte_kernel_driver {
-	RTE_KDRV_UNKNOWN = 0,
-	RTE_KDRV_IGB_UIO,
-	RTE_KDRV_VFIO,
-	RTE_KDRV_UIO_GENERIC,
-	RTE_KDRV_NIC_UIO,
-	RTE_KDRV_NONE,
-};
-
 /**
  * A structure describing a PCI device.
  */
Signature · 1 line
2.1.4
#24 lore raw

PATCH v2 9/14 bus: introduce bus scan policies

In reply to Gaetan Rivet

Scan policies describe the way a bus should scan the system to search for possible devices.

Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices

---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
index 0b48e66..fa08454 100644
@@ -123,6 +123,22 @@ typedef int (*rte_bus_detach_t)(struct rte_device *dev);
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
 /**
+ * Bus scan policies
+ */
+enum rte_bus_scan_mode {
+	RTE_BUS_SCAN_UNDEFINED,
+	RTE_BUS_SCAN_WHITELIST,
+	RTE_BUS_SCAN_BLACKLIST,
+};
+
+/**
+ * A structure used to configure bus operations.
+ */
+struct rte_bus_conf {
+	enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
+};
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -134,6 +150,7 @@ struct rte_bus {
 	rte_bus_attach_t attach;     /**< Probe single device for drivers */
 	rte_bus_detach_t detach;     /**< Remove single device from driver */
 	rte_bus_parse_t parse;       /**< Parse a device name */
+	struct rte_bus_conf conf;    /**< Bus configuration */
 };
 
 /**
Signature · 1 line
2.1.4
#25 lore raw

PATCH v2 10/14 devargs: parse bus policies

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
index 8bb72a2..a5014bf 100644
@@ -130,6 +130,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 
 		break;
 	}
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	}
 
 	free(buf);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
Signature · 1 line
2.1.4
#26 lore raw

PATCH v2 11/14 devargs: generic device representation

In reply to Gaetan Rivet

Remove the dependency of this subsystem upon bus specific device representation.

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

---
 app/test-pmd/testpmd.c                      |  9 ++----
 lib/librte_eal/common/eal_common_devargs.c  | 48 +++++------------------------
 lib/librte_eal/common/eal_common_pci.c      |  9 ++++--
 lib/librte_eal/common/eal_common_vdev.c     | 11 +++----
 lib/librte_eal/common/include/rte_devargs.h | 16 ++--------
 lib/librte_eal/common/include/rte_vdev.h    |  2 +-
 6 files changed, 24 insertions(+), 71 deletions(-)
app/test-pmd/testpmd.c +2 -7
index d1041af..daeece2 100644
@@ -1807,7 +1807,6 @@ rmv_event_callback(void *arg)
 {
 	struct rte_eth_dev *dev;
 	struct rte_devargs *da;
-	char name[32] = "";
 	uint8_t port_id = (intptr_t)arg;
 
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
@@ -1816,12 +1815,8 @@ rmv_event_callback(void *arg)
 
 	stop_port(port_id);
 	close_port(port_id);
-	if (da->type == RTE_DEVTYPE_VIRTUAL)
-		snprintf(name, sizeof(name), "%s", da->virt.drv_name);
-	else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI)
-		rte_pci_device_name(&da->pci.addr, name, sizeof(name));
-	printf("removing device %s\n", name);
-	rte_eal_dev_detach(name);
+	printf("removing device %s\n", da->name);
+	rte_eal_dev_detach(da->name);
 	dev->state = RTE_ETH_DEV_UNUSED;
 }
 
lib/librte_eal/common/eal_common_devargs.c +8 -40

66 lines not on this page · raw message

lib/librte_eal/common/eal_common_pci.c +6 -3
index 44cfa3c..b26ebf0 100644
@@ -102,12 +102,15 @@ const char *pci_get_sysfs_path(void)
 static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 {
 	struct rte_devargs *devargs;
+	struct rte_pci_addr addr;
+	struct rte_bus *pbus;
 
+	pbus = rte_bus_from_name(PCI_BUS_NAME);
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&
-			devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)
+		if (devargs->bus != pbus)
 			continue;
-		if (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))
+		devargs->bus->parse(devargs->name, &addr);
+		if (!rte_eal_compare_pci_addr(&dev->addr, &addr))
 			return devargs;
 	}
 	return NULL;
lib/librte_eal/common/eal_common_vdev.c +5 -6
index 539835a..eab5f9d 100644
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)
 	if (args)
 		devargs->args = strdup(args);
 
-	ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", name);
-	if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) {
+	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name);
+	if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
 		free(devargs->args);
 		free(devargs);
 		return NULL;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args)
 
 	dev->device.devargs = devargs;
 	dev->device.numa_node = SOCKET_ID_ANY;
-	dev->device.name = devargs->virt.drv_name;
+	dev->device.name = devargs->name;
 
 	ret = vdev_probe_all_drivers(dev);
 	if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)
 		if (devargs->bus != vbus)
 			continue;
 
-		dev = find_vdev(devargs->virt.drv_name);
+		dev = find_vdev(devargs->name);
 		if (dev)
 			continue;
 
@@ -314,7 +313,7 @@ vdev_scan(void)
 
 		dev->device.devargs = devargs;
 		dev->device.numa_node = SOCKET_ID_ANY;
-		dev->device.name = devargs->virt.drv_name;
+		dev->device.name = devargs->name;
 
 		TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 	}
lib/librte_eal/common/include/rte_devargs.h +2 -14
index 1f50a24..6a26d3d 100644
@@ -50,7 +50,6 @@ extern "C" {
 
 #include <stdio.h>
 #include <sys/queue.h>
-#include <rte_pci.h>
 #include <rte_bus.h>
 
 /**
@@ -77,21 +76,10 @@ struct rte_devargs {
 	TAILQ_ENTRY(rte_devargs) next;
 	/** Type of device. */
 	enum rte_devtype type;
-	RTE_STD_C11
-	union {
-		/** Used if type is RTE_DEVTYPE_*_PCI. */
-		struct {
-			/** PCI location. */
-			struct rte_pci_addr addr;
-		} pci;
-		/** Used if type is RTE_DEVTYPE_VIRTUAL. */
-		struct {
-			/** Driver name. */
-			char drv_name[32];
-		} virt;
-	};
 	/** Bus handle for the device. */
 	struct rte_bus *bus;
+	/** Name of the device. */
+	char name[32];
 	/** Arguments string as given by user or "" for no argument. */
 	char *args;
 };
lib/librte_eal/common/include/rte_vdev.h +1 -1
index 2d02c68..4debcde 100644
@@ -52,7 +52,7 @@ static inline const char *
 rte_vdev_device_name(const struct rte_vdev_device *dev)
 {
 	if (dev && dev->device.devargs)
-		return dev->device.devargs->virt.drv_name;
+		return dev->device.devargs->name;
 	return NULL;
 }
 
Signature · 1 line
2.1.4
#27 lore raw

PATCH v2 12/14 net/virtio: do not reference device type

In reply to Gaetan Rivet
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
index b7b3d61..cd48fb5 100644
@@ -38,6 +38,7 @@
 #endif
 
 #include <rte_io.h>
+#include <rte_bus.h>
 
 #include "virtio_pci.h"
 #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
 	if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
 		    (!dev->device.devargs ||
-		     dev->device.devargs->type !=
-			RTE_DEVTYPE_WHITELISTED_PCI)) {
+		     dev->device.devargs->bus !=
+		     rte_bus_from_name(PCI_BUS_NAME))) {
 			PMD_INIT_LOG(INFO,
 				"skip kernel managed virtio device.");
 			return 1;
Signature · 1 line
2.1.4
#28 lore raw

PATCH v2 13/14 devargs: generic device types

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c  |  4 ++--
 lib/librte_eal/common/eal_common_options.c  | 13 +++----------
 lib/librte_eal/common/eal_common_pci.c      |  6 +++---
 lib/librte_eal/common/eal_common_vdev.c     |  1 -
 lib/librte_eal/common/include/rte_devargs.h |  6 +++---
 5 files changed, 11 insertions(+), 19 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
index 51ffb45..d423125 100644
@@ -115,14 +115,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", buf);
 	if (ret < 0 || ret >= (int)sizeof(devargs->name))
 		goto fail;
-	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
 			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
 			goto fail;
 		}
-	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
lib/librte_eal/common/eal_common_options.c +3 -10
index f470195..075b0ea 100644
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,
 	switch (opt) {
 	/* blacklist */
 	case 'b':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED,
 				optarg) < 0) {
 			return -1;
 		}
 		break;
 	/* whitelist */
 	case 'w':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 
 	case OPT_VDEV_NUM:
-		if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)
 		return -1;
 	}
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
-		rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
-		RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
-			"cannot be used at the same time\n");
-		return -1;
-	}
-
 	return 0;
 }
 
lib/librte_eal/common/eal_common_pci.c +3 -3
index b26ebf0..7c385f4 100644
@@ -229,7 +229,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 	/* no initialization when blacklisted, return without error */
 	if (dev->device.devargs != NULL &&
 		dev->device.devargs->type ==
-			RTE_DEVTYPE_BLACKLISTED_PCI) {
+			RTE_DEVTYPE_BLACKLISTED) {
 		RTE_LOG(INFO, EAL, "  Device is blacklisted, not"
 			" initializing\n");
 		return 1;
@@ -416,7 +416,7 @@ rte_pci_probe(void)
 	int probe_all = 0;
 	int ret = 0;
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
+	if (rte_pci_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST)
 		probe_all = 1;
 
 	FOREACH_DEVICE_ON_PCIBUS(dev) {
@@ -431,7 +431,7 @@ rte_pci_probe(void)
 		if (probe_all)
 			ret = pci_probe_all_drivers(dev);
 		else if (devargs != NULL &&
-			devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
+			devargs->type == RTE_DEVTYPE_WHITELISTED)
 			ret = pci_probe_all_drivers(dev);
 		if (ret < 0) {
 			RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
index eab5f9d..fc5e2d2 100644
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)
 	if (!devargs)
 		return NULL;
 
-	devargs->type = RTE_DEVTYPE_VIRTUAL;
 	devargs->bus = rte_bus_from_name(VIRTUAL_BUS_NAME);
 	if (args)
 		devargs->args = strdup(args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
index 6a26d3d..6e9e134 100644
@@ -56,9 +56,9 @@ extern "C" {
  * Type of generic device
  */
 enum rte_devtype {
-	RTE_DEVTYPE_WHITELISTED_PCI,
-	RTE_DEVTYPE_BLACKLISTED_PCI,
-	RTE_DEVTYPE_VIRTUAL,
+	RTE_DEVTYPE_UNDEFINED,
+	RTE_DEVTYPE_WHITELISTED,
+	RTE_DEVTYPE_BLACKLISTED,
 };
 
 /**
Signature · 1 line
2.1.4
#29 lore raw

PATCH v2 14/14 devargs: introduce cleaner parsing helper

In reply to Gaetan Rivet

Introduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.

The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.

A deprecation notice is issued.

This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.

---
 doc/guides/rel_notes/deprecation.rst        |  5 ++
 lib/librte_eal/common/eal_common_devargs.c  | 86 ++++++++++++++++++++---------
 lib/librte_eal/common/include/rte_devargs.h | 20 +++++++
 3 files changed, 85 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index ba9b5a2..f90cd87 100644
@@ -128,3 +128,8 @@ Deprecation Notices
   The non-"do-sig" versions of the hash tables will be removed
   (including the ``signature_offset`` parameter)
   and the "do-sig" versions renamed accordingly.
+
+* eal: the following function is deprecated starting from 17.08 and will
+  be removed in 17.11:
+
+  - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +60 -26

116 lines not on this page · raw message

lib/librte_eal/common/include/rte_devargs.h +20 -0
index 6e9e134..2ab8864 100644
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
 /**
+ * Parse a device string.
+ *
+ * Verify that a bus is capable of handling the device passed
+ * in argument. Store which bus will handle the device, its name
+ * and the eventual device parameters.
+ *
+ * @param dev
+ *   The device declaration string.
+ * @param da
+ *   The devargs structure holding the device information.
+ *
+ * @return
+ *   - 0 on success.
+ *   - Negative errno on error.
+ */
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);
+
+/**
  * Add a device to the user device list
  *
  * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
#30 lore raw

v3 cover Generic devargs parsing

In reply to Gaetan Rivet

The second part of the work outlined in [1] and [2]. The first part is at [3].

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.

Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.

With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.

Buses needs only to implement the "parse" method for their devices to be declared in this way.

[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html

This patchset depends on:

[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/

v1 -> v2:

* fix PCI whitelist mode

v2 -> v3:

* Rebase the series on the new plug / unplug API

Gaetan Rivet (14):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper

 app/test-pmd/testpmd.c                      |   9 +-
 app/test-pmd/testpmd.h                      |   2 +
 doc/guides/rel_notes/deprecation.rst        |   5 +
 drivers/net/bnxt/bnxt.h                     |   1 +
 drivers/net/bonding/rte_eth_bond_args.c     |   1 +
 drivers/net/e1000/e1000_ethdev.h            |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.h            |   1 +
 drivers/net/mlx5/mlx5.h                     |   1 +
 drivers/net/sfc/sfc.h                       |   1 +
 drivers/net/virtio/virtio_pci.c             |   5 +-
 lib/librte_eal/common/eal_common_devargs.c  | 137 ++++++++++++++++------------
 lib/librte_eal/common/eal_common_options.c  |  13 +--
 lib/librte_eal/common/eal_common_pci.c      |  15 +--
 lib/librte_eal/common/eal_common_vdev.c     |  16 ++--
 lib/librte_eal/common/include/rte_bus.h     |  17 ++++
 lib/librte_eal/common/include/rte_dev.h     |  12 +++
 lib/librte_eal/common/include/rte_devargs.h |  42 +++++----
 lib/librte_eal/common/include/rte_pci.h     |   9 --
 lib/librte_eal/common/include/rte_vdev.h    |   2 +-
 19 files changed, 169 insertions(+), 121 deletions(-)
Signature · 1 line
2.1.4
#31 lore raw

PATCH v3 1/14 net/bonding: properly reference PCI header

---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
index e3bdad9..b6a924e 100644
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
Signature · 1 line
2.1.4
#32 lore raw

PATCH v3 2/14 net/bnxt: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
index 4418c7f..678a844 100644
@@ -37,6 +37,7 @@
 #include <inttypes.h>
 #include <sys/queue.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_memory.h>
 #include <rte_lcore.h>
Signature · 1 line
2.1.4
#33 lore raw

PATCH v3 3/14 net/mlx5: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
index 67fd742..50c4fdd 100644
@@ -54,6 +54,7 @@
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
+#include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#34 lore raw

PATCH v3 4/14 net/e1000: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
index 8352d0a..6f25428 100644
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include <rte_time.h>
+#include <rte_pci.h>
 
 #define E1000_INTEL_VENDOR_ID 0x8086
 
Signature · 1 line
2.1.4
#35 lore raw

PATCH v3 5/14 net/ixgbe: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index b576a6f..fc39a3e 100644
@@ -39,6 +39,7 @@
 #include "ixgbe_bypass.h"
 #include <rte_time.h>
 #include <rte_hash.h>
+#include <rte_pci.h>
 
 /* need update link, bit flag */
 #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
#36 lore raw

PATCH v3 6/14 net/sfc: properly reference PCI header

In reply to Gaetan Rivet

From: Gaetan Rivet <[email protected]>

---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
index fad0ce0..ec82e87 100644
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#37 lore raw

PATCH v3 7/14 app/testpmd: properly reference PCI header

In reply to Gaetan Rivet
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
index a15598b..d61a4ad 100644
@@ -34,6 +34,8 @@
 #ifndef _TESTPMD_H_
 #define _TESTPMD_H_
 
+#include <rte_pci.h>
+
 #define RTE_PORT_ALL            (~(portid_t)0x0)
 
 #define RTE_TEST_RX_DESC_MAX    2048
Signature · 1 line
2.1.4
#38 lore raw

PATCH v3 8/14 dev: device kernel module is a device attribute

In reply to Gaetan Rivet

It is used in generic device structures and must not be tied to a bus.

---
 lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++
 lib/librte_eal/common/include/rte_pci.h |  9 ---------
 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
index c530797..58160e1 100644
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 } while (0)
 
 /**
+ * Device driver.
+ */
+enum rte_kernel_driver {
+	RTE_KDRV_UNKNOWN = 0,
+	RTE_KDRV_IGB_UIO,
+	RTE_KDRV_VFIO,
+	RTE_KDRV_UIO_GENERIC,
+	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
+};
+
+/**
  * A generic memory resource representation.
  */
 struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
index ab64c63..45c5082 100644
@@ -149,15 +149,6 @@ struct rte_pci_addr {
 
 struct rte_devargs;
 
-enum rte_kernel_driver {
-	RTE_KDRV_UNKNOWN = 0,
-	RTE_KDRV_IGB_UIO,
-	RTE_KDRV_VFIO,
-	RTE_KDRV_UIO_GENERIC,
-	RTE_KDRV_NIC_UIO,
-	RTE_KDRV_NONE,
-};
-
 /**
  * A structure describing a PCI device.
  */
Signature · 1 line
2.1.4
#39 lore raw

PATCH v3 9/14 bus: introduce bus scan policies

In reply to Gaetan Rivet

Scan policies describe the way a bus should scan the system to search for possible devices.

Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices

---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
index 4489d1d..b5d7a88 100644
@@ -126,6 +126,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_devargs *da);
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
 /**
+ * Bus scan policies
+ */
+enum rte_bus_scan_mode {
+	RTE_BUS_SCAN_UNDEFINED,
+	RTE_BUS_SCAN_WHITELIST,
+	RTE_BUS_SCAN_BLACKLIST,
+};
+
+/**
+ * A structure used to configure bus operations.
+ */
+struct rte_bus_conf {
+	enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
+};
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -137,6 +153,7 @@ struct rte_bus {
 	rte_bus_plug_t plug;         /**< Probe single device for drivers */
 	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
 	rte_bus_parse_t parse;       /**< Parse a device name */
+	struct rte_bus_conf conf;    /**< Bus configuration */
 };
 
 /**
Signature · 1 line
2.1.4
#40 lore raw

PATCH v3 10/14 devargs: parse bus policies

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
index 8bb72a2..a5014bf 100644
@@ -130,6 +130,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 
 		break;
 	}
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	}
 
 	free(buf);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
Signature · 1 line
2.1.4
#41 lore raw

PATCH v3 11/14 devargs: generic device representation

In reply to Gaetan Rivet

Remove the dependency of this subsystem upon bus specific device representation.

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

---
 app/test-pmd/testpmd.c                      |  9 ++----
 lib/librte_eal/common/eal_common_devargs.c  | 48 +++++------------------------
 lib/librte_eal/common/eal_common_pci.c      |  9 ++++--
 lib/librte_eal/common/eal_common_vdev.c     | 15 +++++----
 lib/librte_eal/common/include/rte_devargs.h | 16 ++--------
 lib/librte_eal/common/include/rte_vdev.h    |  2 +-
 6 files changed, 26 insertions(+), 73 deletions(-)
app/test-pmd/testpmd.c +2 -7
index d1041af..daeece2 100644
@@ -1807,7 +1807,6 @@ rmv_event_callback(void *arg)
 {
 	struct rte_eth_dev *dev;
 	struct rte_devargs *da;
-	char name[32] = "";
 	uint8_t port_id = (intptr_t)arg;
 
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
@@ -1816,12 +1815,8 @@ rmv_event_callback(void *arg)
 
 	stop_port(port_id);
 	close_port(port_id);
-	if (da->type == RTE_DEVTYPE_VIRTUAL)
-		snprintf(name, sizeof(name), "%s", da->virt.drv_name);
-	else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI)
-		rte_pci_device_name(&da->pci.addr, name, sizeof(name));
-	printf("removing device %s\n", name);
-	rte_eal_dev_detach(name);
+	printf("removing device %s\n", da->name);
+	rte_eal_dev_detach(da->name);
 	dev->state = RTE_ETH_DEV_UNUSED;
 }
 
lib/librte_eal/common/eal_common_devargs.c +8 -40

66 lines not on this page · raw message

lib/librte_eal/common/eal_common_pci.c +6 -3
index c698cf8..d6658c2 100644
@@ -102,12 +102,15 @@ const char *pci_get_sysfs_path(void)
 static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 {
 	struct rte_devargs *devargs;
+	struct rte_pci_addr addr;
+	struct rte_bus *pbus;
 
+	pbus = rte_bus_from_name(PCI_BUS_NAME);
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&
-			devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)
+		if (devargs->bus != pbus)
 			continue;
-		if (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))
+		devargs->bus->parse(devargs->name, &addr);
+		if (!rte_eal_compare_pci_addr(&dev->addr, &addr))
 			return devargs;
 	}
 	return NULL;
lib/librte_eal/common/eal_common_vdev.c +7 -8
index ea58706..f618bbb 100644
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)
 	if (args)
 		devargs->args = strdup(args);
 
-	ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", name);
-	if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) {
+	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name);
+	if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
 		free(devargs->args);
 		free(devargs);
 		return NULL;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args)
 
 	dev->device.devargs = devargs;
 	dev->device.numa_node = SOCKET_ID_ANY;
-	dev->device.name = devargs->virt.drv_name;
+	dev->device.name = devargs->name;
 
 	ret = vdev_probe_all_drivers(dev);
 	if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)
 		if (devargs->bus != vbus)
 			continue;
 
-		dev = find_vdev(devargs->virt.drv_name);
+		dev = find_vdev(devargs->name);
 		if (dev)
 			continue;
 
@@ -314,7 +313,7 @@ vdev_scan(void)
 
 		dev->device.devargs = devargs;
 		dev->device.numa_node = SOCKET_ID_ANY;
-		dev->device.name = devargs->virt.drv_name;
+		dev->device.name = devargs->name;
 
 		TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 	}
@@ -358,13 +357,13 @@ vdev_find_device(rte_dev_match_t match, const void *data)
 static int
 vdev_plug(struct rte_devargs *da)
 {
-	return rte_vdev_init(da->virt.drv_name, da->args);
+	return rte_vdev_init(da->name, da->args);
 }
 
 static int
 vdev_unplug(struct rte_devargs *da)
 {
-	return rte_vdev_uninit(da->virt.drv_name);
+	return rte_vdev_uninit(da->name);
 }
 
 static struct rte_bus rte_vdev_bus = {
lib/librte_eal/common/include/rte_devargs.h +2 -14
index 1f50a24..6a26d3d 100644
@@ -50,7 +50,6 @@ extern "C" {
 
 #include <stdio.h>
 #include <sys/queue.h>
-#include <rte_pci.h>
 #include <rte_bus.h>
 
 /**
@@ -77,21 +76,10 @@ struct rte_devargs {
 	TAILQ_ENTRY(rte_devargs) next;
 	/** Type of device. */
 	enum rte_devtype type;
-	RTE_STD_C11
-	union {
-		/** Used if type is RTE_DEVTYPE_*_PCI. */
-		struct {
-			/** PCI location. */
-			struct rte_pci_addr addr;
-		} pci;
-		/** Used if type is RTE_DEVTYPE_VIRTUAL. */
-		struct {
-			/** Driver name. */
-			char drv_name[32];
-		} virt;
-	};
 	/** Bus handle for the device. */
 	struct rte_bus *bus;
+	/** Name of the device. */
+	char name[32];
 	/** Arguments string as given by user or "" for no argument. */
 	char *args;
 };
lib/librte_eal/common/include/rte_vdev.h +1 -1
index 2d02c68..4debcde 100644
@@ -52,7 +52,7 @@ static inline const char *
 rte_vdev_device_name(const struct rte_vdev_device *dev)
 {
 	if (dev && dev->device.devargs)
-		return dev->device.devargs->virt.drv_name;
+		return dev->device.devargs->name;
 	return NULL;
 }
 
Signature · 1 line
2.1.4
#42 lore raw

PATCH v3 12/14 net/virtio: do not reference device type

In reply to Gaetan Rivet
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
index b7b3d61..cd48fb5 100644
@@ -38,6 +38,7 @@
 #endif
 
 #include <rte_io.h>
+#include <rte_bus.h>
 
 #include "virtio_pci.h"
 #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
 	if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
 		    (!dev->device.devargs ||
-		     dev->device.devargs->type !=
-			RTE_DEVTYPE_WHITELISTED_PCI)) {
+		     dev->device.devargs->bus !=
+		     rte_bus_from_name(PCI_BUS_NAME))) {
 			PMD_INIT_LOG(INFO,
 				"skip kernel managed virtio device.");
 			return 1;
Signature · 1 line
2.1.4
#43 lore raw

PATCH v3 13/14 devargs: generic device types

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c  |  4 ++--
 lib/librte_eal/common/eal_common_options.c  | 13 +++----------
 lib/librte_eal/common/eal_common_pci.c      |  6 +++---
 lib/librte_eal/common/eal_common_vdev.c     |  1 -
 lib/librte_eal/common/include/rte_devargs.h |  6 +++---
 5 files changed, 11 insertions(+), 19 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
index 51ffb45..d423125 100644
@@ -115,14 +115,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", buf);
 	if (ret < 0 || ret >= (int)sizeof(devargs->name))
 		goto fail;
-	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
 			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
 			goto fail;
 		}
-	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
lib/librte_eal/common/eal_common_options.c +3 -10
index f470195..075b0ea 100644
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,
 	switch (opt) {
 	/* blacklist */
 	case 'b':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED,
 				optarg) < 0) {
 			return -1;
 		}
 		break;
 	/* whitelist */
 	case 'w':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 
 	case OPT_VDEV_NUM:
-		if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)
 		return -1;
 	}
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
-		rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
-		RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
-			"cannot be used at the same time\n");
-		return -1;
-	}
-
 	return 0;
 }
 
lib/librte_eal/common/eal_common_pci.c +3 -3
index d6658c2..2a52b9e 100644
@@ -229,7 +229,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 	/* no initialization when blacklisted, return without error */
 	if (dev->device.devargs != NULL &&
 		dev->device.devargs->type ==
-			RTE_DEVTYPE_BLACKLISTED_PCI) {
+			RTE_DEVTYPE_BLACKLISTED) {
 		RTE_LOG(INFO, EAL, "  Device is blacklisted, not"
 			" initializing\n");
 		return 1;
@@ -416,7 +416,7 @@ rte_pci_probe(void)
 	int probe_all = 0;
 	int ret = 0;
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
+	if (rte_pci_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST)
 		probe_all = 1;
 
 	FOREACH_DEVICE_ON_PCIBUS(dev) {
@@ -431,7 +431,7 @@ rte_pci_probe(void)
 		if (probe_all)
 			ret = pci_probe_all_drivers(dev);
 		else if (devargs != NULL &&
-			devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
+			devargs->type == RTE_DEVTYPE_WHITELISTED)
 			ret = pci_probe_all_drivers(dev);
 		if (ret < 0) {
 			RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
index f618bbb..082bbae 100644
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)
 	if (!devargs)
 		return NULL;
 
-	devargs->type = RTE_DEVTYPE_VIRTUAL;
 	devargs->bus = rte_bus_from_name(VIRTUAL_BUS_NAME);
 	if (args)
 		devargs->args = strdup(args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
index 6a26d3d..6e9e134 100644
@@ -56,9 +56,9 @@ extern "C" {
  * Type of generic device
  */
 enum rte_devtype {
-	RTE_DEVTYPE_WHITELISTED_PCI,
-	RTE_DEVTYPE_BLACKLISTED_PCI,
-	RTE_DEVTYPE_VIRTUAL,
+	RTE_DEVTYPE_UNDEFINED,
+	RTE_DEVTYPE_WHITELISTED,
+	RTE_DEVTYPE_BLACKLISTED,
 };
 
 /**
Signature · 1 line
2.1.4
#44 lore raw

PATCH v3 14/14 devargs: introduce cleaner parsing helper

In reply to Gaetan Rivet

Introduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.

The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.

A deprecation notice is issued.

This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.

---
 doc/guides/rel_notes/deprecation.rst        |  5 ++
 lib/librte_eal/common/eal_common_devargs.c  | 86 ++++++++++++++++++++---------
 lib/librte_eal/common/include/rte_devargs.h | 20 +++++++
 3 files changed, 85 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index ba9b5a2..f90cd87 100644
@@ -128,3 +128,8 @@ Deprecation Notices
   The non-"do-sig" versions of the hash tables will be removed
   (including the ``signature_offset`` parameter)
   and the "do-sig" versions renamed accordingly.
+
+* eal: the following function is deprecated starting from 17.08 and will
+  be removed in 17.11:
+
+  - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +60 -26

116 lines not on this page · raw message

lib/librte_eal/common/include/rte_devargs.h +20 -0
index 6e9e134..2ab8864 100644
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
 /**
+ * Parse a device string.
+ *
+ * Verify that a bus is capable of handling the device passed
+ * in argument. Store which bus will handle the device, its name
+ * and the eventual device parameters.
+ *
+ * @param dev
+ *   The device declaration string.
+ * @param da
+ *   The devargs structure holding the device information.
+ *
+ * @return
+ *   - 0 on success.
+ *   - Negative errno on error.
+ */
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);
+
+/**
  * Add a device to the user device list
  *
  * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
#45 lore raw

v4 cover Generic devargs parsing

In reply to Gaetan Rivet

The second part of the work outlined in [1] and [2]. The first part is at [3].

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.

Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.

With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.

Buses needs only to implement the "parse" method for their devices to be declared in this way.

[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html

This patchset depends on:

[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/

v1 -> v2:

* fix PCI whitelist mode

v2 -> v3:

* Rebase the series on the new plug / unplug API

v3 -> v4:

* Fix rte_devargs parsing helper
* Introduce new rte_devargs clone function
* Introduce new rte_devargs release function
* Fix test application for rte_devargs.
TODO: rewrite complete rte_devargs autotest.
* Fix a few rte_pci references.
* Update EAL command line help for -w / -b

Gaetan Rivet (19):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc

 app/test-pmd/testpmd.c                          |   9 +-
 app/test-pmd/testpmd.h                          |   2 +
 doc/guides/rel_notes/deprecation.rst            |   5 +
 drivers/net/bnxt/bnxt.h                         |   1 +
 drivers/net/bonding/rte_eth_bond_args.c         |   1 +
 drivers/net/e1000/e1000_ethdev.h                |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.h                |   1 +
 drivers/net/mlx5/mlx5.h                         |   1 +
 drivers/net/sfc/sfc.h                           |   1 +
 drivers/net/virtio/virtio_pci.c                 |   5 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   2 +
 lib/librte_eal/common/eal_common_devargs.c      | 178 ++++++++++++++++--------
 lib/librte_eal/common/eal_common_options.c      |  31 ++---
 lib/librte_eal/common/eal_common_pci.c          |  16 ++-
 lib/librte_eal/common/eal_common_vdev.c         |  18 ++-
 lib/librte_eal/common/eal_options.h             |   8 +-
 lib/librte_eal/common/include/rte_bus.h         |  17 +++
 lib/librte_eal/common/include/rte_dev.h         |  12 ++
 lib/librte_eal/common/include/rte_devargs.h     |  68 ++++++---
 lib/librte_eal/common/include/rte_pci.h         |   9 --
 lib/librte_eal/common/include/rte_vdev.h        |   2 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   2 +
 test/test/test_devargs.c                        |  45 +++---
 test/test/virtual_pmd.c                         |   1 +
 24 files changed, 278 insertions(+), 158 deletions(-)
Signature · 1 line
2.1.4
#46 lore raw

PATCH v4 1/19 net/bonding: properly reference PCI header

---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
index dc468d2..ed217fb 100644
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
Signature · 1 line
2.1.4
#47 lore raw

PATCH v4 2/19 net/bnxt: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
index 54428ba..4609792 100644
@@ -38,6 +38,7 @@
 #include <stdbool.h>
 #include <sys/queue.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_memory.h>
 #include <rte_lcore.h>
Signature · 1 line
2.1.4
#48 lore raw

PATCH v4 3/19 net/mlx5: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
index 1148dee..9ef2c11 100644
@@ -54,6 +54,7 @@
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
+#include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#49 lore raw

PATCH v4 4/19 net/e1000: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
index 4979895..ac380ed 100644
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include <rte_time.h>
+#include <rte_pci.h>
 
 #define E1000_INTEL_VENDOR_ID 0x8086
 
Signature · 1 line
2.1.4
#50 lore raw

PATCH v4 5/19 net/ixgbe: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index e2d0139..bb5ecd5 100644
@@ -39,6 +39,7 @@
 #include "ixgbe_bypass.h"
 #include <rte_time.h>
 #include <rte_hash.h>
+#include <rte_pci.h>
 
 /* need update link, bit flag */
 #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
#51 lore raw

Re: [PATCH v4 05/19] net/ixgbe: properly reference PCI header

Why to introduce this change ?

Even without this patch, all files can be built successfully.
Each.*.o.d files in x86_64-native-linuxapp-gcc keeps same in both with and without this patch. So there is no need to add the line at least in the config of x86_64-native-linuxapp-gcc.

Quoted 27 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Thursday, June 8, 2017 7:57 AM
To: [email protected]
Cc: Gaetan Rivet <[email protected]>
Subject: [dpdk-dev] [PATCH v4 05/19] net/ixgbe: properly reference PCI header

---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -1
index e2d0139..bb5ecd5 100644
@@ -39,6 +39,7 @@
 #include "ixgbe_bypass.h"
 #include <rte_time.h>
 #include <rte_hash.h>
+#include <rte_pci.h>
 
 /* need update link, bit flag */
 #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
--

2.1.4

#52 lore raw

Re: [PATCH v4 05/19] net/ixgbe: properly reference PCI header

Hi,

Quoted 7 lines · Wei

Why to introduce this change ?

Even without this patch, all files can be built successfully.
Each.*.o.d files in x86_64-native-linuxapp-gcc keeps same in both with and without this patch. So there is no need to add the line at least in the config of x86_64-native-linuxapp-gcc.

In order to remove the PCI bus from the EAL, I need to remove all references to it from EAL headers.

rte_devargs.h previously included rte_pci.h, which then was included by several other parts of the DPDK.

This needs to be fixed, as afterward, the commit

* devargs: generic device representation

removes the PCI include.

This include was faulty anyway, as normally all compile units (or at least independent DPDK parts) should be self-sufficient in terms of includes, due to this exact situation where libraries are moved around and their dependencies are updated.

Quoted 28 lines
Quoted 27 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Thursday, June 8, 2017 7:57 AM
To: [email protected]
Cc: Gaetan Rivet <[email protected]>
Subject: [dpdk-dev] [PATCH v4 05/19] net/ixgbe: properly reference PCI header

---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -1
index e2d0139..bb5ecd5 100644
@@ -39,6 +39,7 @@
 #include "ixgbe_bypass.h"
 #include <rte_time.h>
 #include <rte_hash.h>
+#include <rte_pci.h>
 
 /* need update link, bit flag */
 #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
--

2.1.4

Signature · 2 lines
Gaëtan Rivet
6WIND
#53 lore raw

PATCH v4 6/19 net/sfc: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
index 007ed24..41dff48 100644
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#54 lore raw

PATCH v4 7/19 app/testpmd: properly reference PCI header

In reply to Gaetan Rivet
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
index 1838241..90a6568 100644
@@ -34,6 +34,8 @@
 #ifndef _TESTPMD_H_
 #define _TESTPMD_H_
 
+#include <rte_pci.h>
+
 #define RTE_PORT_ALL            (~(portid_t)0x0)
 
 #define RTE_TEST_RX_DESC_MAX    2048
Signature · 1 line
2.1.4
#55 lore raw

PATCH v4 8/19 test: properly reference PCI header

In reply to Gaetan Rivet
---
 test/test/virtual_pmd.c | 1 +
 1 file changed, 1 insertion(+)
test/test/virtual_pmd.c +1 -0
index e9dd8ac..f3ee82f 100644
@@ -33,6 +33,7 @@
 
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
+#include <rte_pci.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_memory.h>
Signature · 1 line
2.1.4
#56 lore raw

PATCH v4 9/19 dev: device kernel module is a device attribute

In reply to Gaetan Rivet

It is used in generic device structures and must not be tied to a bus.

---
 lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++
 lib/librte_eal/common/include/rte_pci.h |  9 ---------
 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
index 9f35b1f..3162822 100644
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 } while (0)
 
 /**
+ * Device driver.
+ */
+enum rte_kernel_driver {
+	RTE_KDRV_UNKNOWN = 0,
+	RTE_KDRV_IGB_UIO,
+	RTE_KDRV_VFIO,
+	RTE_KDRV_UIO_GENERIC,
+	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
+};
+
+/**
  * A generic memory resource representation.
  */
 struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
index b82ab9e..51b084e 100644
@@ -120,15 +120,6 @@ struct rte_pci_addr {
 
 struct rte_devargs;
 
-enum rte_kernel_driver {
-	RTE_KDRV_UNKNOWN = 0,
-	RTE_KDRV_IGB_UIO,
-	RTE_KDRV_VFIO,
-	RTE_KDRV_UIO_GENERIC,
-	RTE_KDRV_NIC_UIO,
-	RTE_KDRV_NONE,
-};
-
 /**
  * A structure describing a PCI device.
  */
Signature · 1 line
2.1.4
#57 lore raw

PATCH v4 10/19 bus: introduce bus scan policies

In reply to Gaetan Rivet

Scan policies describe the way a bus should scan the system to search for possible devices.

Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices

---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
index 4bed780..fd94755 100644
@@ -137,6 +137,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
 /**
+ * Bus scan policies
+ */
+enum rte_bus_scan_mode {
+	RTE_BUS_SCAN_UNDEFINED,
+	RTE_BUS_SCAN_WHITELIST,
+	RTE_BUS_SCAN_BLACKLIST,
+};
+
+/**
+ * A structure used to configure bus operations.
+ */
+struct rte_bus_conf {
+	enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
+};
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -148,6 +164,7 @@ struct rte_bus {
 	rte_bus_plug_t plug;         /**< Probe single device for drivers */
 	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
 	rte_bus_parse_t parse;       /**< Parse a device name */
+	struct rte_bus_conf conf;    /**< Bus configuration */
 };
 
 /**
Signature · 1 line
2.1.4
#58 lore raw

PATCH v4 11/19 devargs: parse bus policies

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
index 8bb72a2..a5014bf 100644
@@ -130,6 +130,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 
 		break;
 	}
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	}
 
 	free(buf);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
Signature · 1 line
2.1.4
#59 lore raw

PATCH v4 12/19 devargs: generic device representation

In reply to Gaetan Rivet

Remove the dependency of this subsystem upon bus specific device representation.

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

---
 app/test-pmd/testpmd.c                      |  9 ++----
 lib/librte_eal/common/eal_common_devargs.c  | 48 +++++------------------------
 lib/librte_eal/common/eal_common_pci.c      |  9 ++++--
 lib/librte_eal/common/eal_common_vdev.c     | 17 +++++-----
 lib/librte_eal/common/include/rte_devargs.h | 16 ++--------
 lib/librte_eal/common/include/rte_vdev.h    |  2 +-
 test/test/test_devargs.c                    |  9 ++----
 7 files changed, 30 insertions(+), 80 deletions(-)
app/test-pmd/testpmd.c +2 -7
index 17ae446..f36de2f 100644
@@ -1810,7 +1810,6 @@ rmv_event_callback(void *arg)
 {
 	struct rte_eth_dev *dev;
 	struct rte_devargs *da;
-	char name[32] = "";
 	uint8_t port_id = (intptr_t)arg;
 
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
@@ -1819,12 +1818,8 @@ rmv_event_callback(void *arg)
 
 	stop_port(port_id);
 	close_port(port_id);
-	if (da->type == RTE_DEVTYPE_VIRTUAL)
-		snprintf(name, sizeof(name), "%s", da->virt.drv_name);
-	else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI)
-		rte_pci_device_name(&da->pci.addr, name, sizeof(name));
-	printf("removing device %s\n", name);
-	rte_eal_dev_detach(name);
+	printf("removing device %s\n", da->name);
+	rte_eal_dev_detach(da->name);
 	dev->state = RTE_ETH_DEV_UNUSED;
 }
 
lib/librte_eal/common/eal_common_devargs.c +8 -40

66 lines not on this page · raw message

lib/librte_eal/common/eal_common_pci.c +6 -3
index 3075eee..83ae378 100644
@@ -73,12 +73,15 @@ const char *pci_get_sysfs_path(void)
 static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 {
 	struct rte_devargs *devargs;
+	struct rte_pci_addr addr;
+	struct rte_bus *pbus;
 
+	pbus = rte_bus_from_name(PCI_BUS_NAME);
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&
-			devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)
+		if (devargs->bus != pbus)
 			continue;
-		if (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))
+		devargs->bus->parse(devargs->name, &addr);
+		if (!rte_eal_compare_pci_addr(&dev->addr, &addr))
 			return devargs;
 	}
 	return NULL;
lib/librte_eal/common/eal_common_vdev.c +8 -9
index 7cc3c6c..c56fb6d 100644
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)
 	if (args)
 		devargs->args = strdup(args);
 
-	ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", name);
-	if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) {
+	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name);
+	if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
 		free(devargs->args);
 		free(devargs);
 		return NULL;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args)
 
 	dev->device.devargs = devargs;
 	dev->device.numa_node = SOCKET_ID_ANY;
-	dev->device.name = devargs->virt.drv_name;
+	dev->device.name = devargs->name;
 
 	ret = vdev_probe_all_drivers(dev);
 	if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)
 		if (devargs->bus != vbus)
 			continue;
 
-		dev = find_vdev(devargs->virt.drv_name);
+		dev = find_vdev(devargs->name);
 		if (dev)
 			continue;
 
@@ -314,7 +313,7 @@ vdev_scan(void)
 
 		dev->device.devargs = devargs;
 		dev->device.numa_node = SOCKET_ID_ANY;
-		dev->device.name = devargs->virt.drv_name;
+		dev->device.name = devargs->name;
 
 		TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 	}
@@ -361,12 +360,12 @@ vdev_plug(struct rte_devargs *da)
 	struct rte_vdev_device *dev;
 	int ret;
 
-	ret = rte_vdev_init(da->virt.drv_name, da->args);
+	ret = rte_vdev_init(da->name, da->args);
 	if (ret) {
 		rte_errno = -ret;
 		return NULL;
 	}
-	dev = find_vdev(da->virt.drv_name);
+	dev = find_vdev(da->name);
 	return &dev->device;
 }
 
@@ -381,7 +380,7 @@ vdev_unplug(struct rte_device *dev)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	ret = rte_vdev_uninit(da->virt.drv_name);
+	ret = rte_vdev_uninit(da->name);
 	if (ret)
 		rte_errno = -ret;
 	return ret;
lib/librte_eal/common/include/rte_devargs.h +2 -14
index 1f50a24..6a26d3d 100644
@@ -50,7 +50,6 @@ extern "C" {
 
 #include <stdio.h>
 #include <sys/queue.h>
-#include <rte_pci.h>
 #include <rte_bus.h>
 
 /**
@@ -77,21 +76,10 @@ struct rte_devargs {
 	TAILQ_ENTRY(rte_devargs) next;
 	/** Type of device. */
 	enum rte_devtype type;
-	RTE_STD_C11
-	union {
-		/** Used if type is RTE_DEVTYPE_*_PCI. */
-		struct {
-			/** PCI location. */
-			struct rte_pci_addr addr;
-		} pci;
-		/** Used if type is RTE_DEVTYPE_VIRTUAL. */
-		struct {
-			/** Driver name. */
-			char drv_name[32];
-		} virt;
-	};
 	/** Bus handle for the device. */
 	struct rte_bus *bus;
+	/** Name of the device. */
+	char name[32];
 	/** Arguments string as given by user or "" for no argument. */
 	char *args;
 };
lib/librte_eal/common/include/rte_vdev.h +1 -1
index 2d02c68..4debcde 100644
@@ -52,7 +52,7 @@ static inline const char *
 rte_vdev_device_name(const struct rte_vdev_device *dev)
 {
 	if (dev && dev->device.devargs)
-		return dev->device.devargs->virt.drv_name;
+		return dev->device.devargs->name;
 	return NULL;
 }
 
test/test/test_devargs.c +3 -6
index 63242f1..18f54ed 100644
@@ -90,8 +90,8 @@ test_devargs(void)
 	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,k1=val,k2=val2") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
-	if (strncmp(devargs->virt.drv_name, "net_ring1",
-			sizeof(devargs->virt.drv_name)) != 0)
+	if (strncmp(devargs->name, "net_ring1",
+			sizeof(devargs->name)) != 0)
 		goto fail;
 	if (!devargs->args || strcmp(devargs->args, "k1=val,k2=val2") != 0)
 		goto fail;
@@ -101,10 +101,7 @@ test_devargs(void)
 	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "04:00.1") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
-	if (devargs->pci.addr.domain != 0 ||
-		devargs->pci.addr.bus != 4 ||
-		devargs->pci.addr.devid != 0 ||
-		devargs->pci.addr.function != 1)
+	if (strcmp(devargs->name, "04:00.1") != 0)
 		goto fail;
 	if (!devargs->args || strcmp(devargs->args, "") != 0)
 		goto fail;
Signature · 1 line
2.1.4
#60 lore raw

PATCH v4 13/19 pci: update device name

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_pci.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_eal/common/eal_common_pci.c +1 -0
index 83ae378..a31e490 100644
@@ -325,6 +325,7 @@ rte_pci_probe_one(const struct rte_pci_addr *addr)
 		ret = pci_probe_all_drivers(dev);
 		if (ret)
 			goto err_return;
+		dev->device.name = dev->device.devargs->name;
 		return 0;
 	}
 	return -1;
Signature · 1 line
2.1.4
#61 lore raw

PATCH v4 14/19 net/virtio: do not reference device type

In reply to Gaetan Rivet
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
index b7b3d61..cd48fb5 100644
@@ -38,6 +38,7 @@
 #endif
 
 #include <rte_io.h>
+#include <rte_bus.h>
 
 #include "virtio_pci.h"
 #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
 	if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
 		    (!dev->device.devargs ||
-		     dev->device.devargs->type !=
-			RTE_DEVTYPE_WHITELISTED_PCI)) {
+		     dev->device.devargs->bus !=
+		     rte_bus_from_name(PCI_BUS_NAME))) {
 			PMD_INIT_LOG(INFO,
 				"skip kernel managed virtio device.");
 			return 1;
Signature · 1 line
2.1.4
#62 lore raw

PATCH v4 15/19 devargs: generic device types

In reply to Gaetan Rivet

rte_devargs now represents any device from any bus.
The related devtypes do not identify a bus anymore, only which scan policy the device subscribes to.

The bus itself is identified by a bus handle previously introduced.

---
 lib/librte_eal/common/eal_common_devargs.c  |  4 ++--
 lib/librte_eal/common/eal_common_options.c  | 13 +++--------
 lib/librte_eal/common/eal_common_pci.c      |  6 ++---
 lib/librte_eal/common/eal_common_vdev.c     |  1 -
 lib/librte_eal/common/include/rte_devargs.h |  6 ++---
 test/test/test_devargs.c                    | 36 +++++++++++++++--------------
 6 files changed, 30 insertions(+), 36 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
index 51ffb45..d423125 100644
@@ -115,14 +115,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", buf);
 	if (ret < 0 || ret >= (int)sizeof(devargs->name))
 		goto fail;
-	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
 			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
 			goto fail;
 		}
-	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
lib/librte_eal/common/eal_common_options.c +3 -10
index f470195..075b0ea 100644
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,
 	switch (opt) {
 	/* blacklist */
 	case 'b':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED,
 				optarg) < 0) {
 			return -1;
 		}
 		break;
 	/* whitelist */
 	case 'w':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 
 	case OPT_VDEV_NUM:
-		if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)
 		return -1;
 	}
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
-		rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
-		RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
-			"cannot be used at the same time\n");
-		return -1;
-	}
-
 	return 0;
 }
 
lib/librte_eal/common/eal_common_pci.c +3 -3
index a31e490..b4f8056 100644
@@ -200,7 +200,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 	/* no initialization when blacklisted, return without error */
 	if (dev->device.devargs != NULL &&
 		dev->device.devargs->type ==
-			RTE_DEVTYPE_BLACKLISTED_PCI) {
+			RTE_DEVTYPE_BLACKLISTED) {
 		RTE_LOG(INFO, EAL, "  Device is blacklisted, not"
 			" initializing\n");
 		return 1;
@@ -388,7 +388,7 @@ rte_pci_probe(void)
 	int probe_all = 0;
 	int ret = 0;
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
+	if (rte_pci_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST)
 		probe_all = 1;
 
 	FOREACH_DEVICE_ON_PCIBUS(dev) {
@@ -403,7 +403,7 @@ rte_pci_probe(void)
 		if (probe_all)
 			ret = pci_probe_all_drivers(dev);
 		else if (devargs != NULL &&
-			devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
+			devargs->type == RTE_DEVTYPE_WHITELISTED)
 			ret = pci_probe_all_drivers(dev);
 		if (ret < 0) {
 			RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
index c56fb6d..d921345 100644
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)
 	if (!devargs)
 		return NULL;
 
-	devargs->type = RTE_DEVTYPE_VIRTUAL;
 	devargs->bus = rte_bus_from_name(VIRTUAL_BUS_NAME);
 	if (args)
 		devargs->args = strdup(args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
index 6a26d3d..6e9e134 100644
@@ -56,9 +56,9 @@ extern "C" {
  * Type of generic device
  */
 enum rte_devtype {
-	RTE_DEVTYPE_WHITELISTED_PCI,
-	RTE_DEVTYPE_BLACKLISTED_PCI,
-	RTE_DEVTYPE_VIRTUAL,
+	RTE_DEVTYPE_UNDEFINED,
+	RTE_DEVTYPE_WHITELISTED,
+	RTE_DEVTYPE_BLACKLISTED,
 };
 
 /**
test/test/test_devargs.c +19 -17
index 18f54ed..149c9c9 100644
@@ -64,30 +64,32 @@ test_devargs(void)
 	TAILQ_INIT(&devargs_list);
 
 	/* test valid cases */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "08:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "08:00.1") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "0000:5:00.0") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "0000:5:00.0") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0,arg=val") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "04:00.0,arg=val") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "0000:01:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "0000:01:00.1") < 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED) != 4)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED) != 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 0)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_UNDEFINED) != 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring0") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED, "net_ring0") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,key=val,k2=val2") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
+				"net_ring1,key=val,k2=val2") < 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_UNDEFINED) != 2)
 		goto fail;
 	free_devargs_list();
 
 	/* check virtual device with argument parsing */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,k1=val,k2=val2") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
+				"net_ring1,k1=val,k2=val2") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
 	if (strncmp(devargs->name, "net_ring1",
@@ -98,7 +100,7 @@ test_devargs(void)
 	free_devargs_list();
 
 	/* check PCI device with empty argument parsing */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "04:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "04:00.1") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
 	if (strcmp(devargs->name, "04:00.1") != 0)
@@ -108,15 +110,15 @@ test_devargs(void)
 	free_devargs_list();
 
 	/* test error case: bad PCI address */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "08:1") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "08:1") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "00.1") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "00.1") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "foo") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "foo") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, ",") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, ",") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "000f:0:0") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "000f:0:0") == 0)
 		goto fail;
 
 	devargs_list = save_devargs_list;
Signature · 1 line
2.1.4
#63 lore raw

PATCH v4 16/19 devargs: introduce cleaner parsing helper

In reply to Gaetan Rivet

Introduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.

The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.

A deprecation notice is issued.

This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.

---
 doc/guides/rel_notes/deprecation.rst        |  5 ++
 lib/librte_eal/common/eal_common_devargs.c  | 89 ++++++++++++++++++++---------
 lib/librte_eal/common/include/rte_devargs.h | 20 +++++++
 3 files changed, 88 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index 1786a59..fb95ced 100644
@@ -105,3 +105,8 @@ Deprecation Notices
   The non-"do-sig" versions of the hash tables will be removed
   (including the ``signature_offset`` parameter)
   and the "do-sig" versions renamed accordingly.
+
+* eal: the following function is deprecated starting from 17.08 and will
+  be removed in 17.11:
+
+  - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +63 -26

119 lines not on this page · raw message

lib/librte_eal/common/include/rte_devargs.h +20 -0
index 6e9e134..2ab8864 100644
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
 /**
+ * Parse a device string.
+ *
+ * Verify that a bus is capable of handling the device passed
+ * in argument. Store which bus will handle the device, its name
+ * and the eventual device parameters.
+ *
+ * @param dev
+ *   The device declaration string.
+ * @param da
+ *   The devargs structure holding the device information.
+ *
+ * @return
+ *   - 0 on success.
+ *   - Negative errno on error.
+ */
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);
+
+/**
  * Add a device to the user device list
  *
  * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
#64 lore raw

PATCH v4 17/19 devargs: clone function

In reply to Gaetan Rivet

This function returns a deep copy of an rte_devargs.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_devargs.c      | 20 ++++++++++++++++++++
 lib/librte_eal/common/include/rte_devargs.h     | 12 ++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 4 files changed, 34 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index 04fa882..a506968 100644
@@ -203,5 +203,6 @@ DPDK_17.08 {
 
 	rte_bus_from_name;
 	rte_bus_from_dev;
+	rte_eal_devargs_clone;
 
 } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +20 -0
index b69a2b2..07b89ef 100644
@@ -41,6 +41,7 @@
 #include <string.h>
 
 #include <rte_devargs.h>
+#include <rte_tailq.h>
 #include "eal_private.h"
 
 /** Global list of user devices */
@@ -182,6 +183,25 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	return -1;
 }
 
+/* Deep-copy of an rte_devargs. */
+struct rte_devargs *
+rte_eal_devargs_clone(struct rte_devargs *da)
+{
+	struct rte_devargs *clone;
+
+	clone = calloc(1, sizeof(*clone));
+	if (clone == NULL)
+		return NULL;
+	snprintf(clone->name, sizeof(clone->name), "%s", da->name);
+	clone->args = strdup(da->args ? da->args : "");
+	clone->bus = da->bus;
+	if (clone->args == NULL) {
+		free(clone);
+		return NULL;
+	}
+	return clone;
+}
+
 /* count the number of devices of a specified type */
 unsigned int
 rte_eal_devargs_type_count(enum rte_devtype devtype)
lib/librte_eal/common/include/rte_devargs.h +12 -0
index 2ab8864..892b035 100644
@@ -163,6 +163,18 @@ rte_eal_devargs_parse(const char *dev,
 int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str);
 
 /**
+ * Deep copy an rte_devargs.
+ *
+ * @param da
+ *   Source devargs.
+ *
+ * @return
+ *   The pointer to the new rte_devargs on success.
+ *   NULL on error.
+ */
+struct rte_devargs *rte_eal_devargs_clone(struct rte_devargs *da);
+
+/**
  * Count the number of user devices of a specified type
  *
  * @param devtype
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
index a5127d6..6e6638a 100644
@@ -207,5 +207,6 @@ DPDK_17.08 {
 
 	rte_bus_from_name;
 	rte_bus_from_dev;
+	rte_eal_devargs_clone;
 
 } DPDK_17.05;
Signature · 1 line
2.1.4
#65 lore raw

PATCH v4 18/19 devargs: remove function

In reply to Gaetan Rivet

This function is now necessary due to the new unplug rte_bus API.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_devargs.c      | 18 ++++++++++++++++++
 lib/librte_eal/common/include/rte_devargs.h     | 14 ++++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 4 files changed, 34 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index a506968..d069de0 100644
@@ -204,5 +204,6 @@ DPDK_17.08 {
 	rte_bus_from_name;
 	rte_bus_from_dev;
 	rte_eal_devargs_clone;
+	rte_eal_devargs_rmv;
 
 } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +18 -0
index 07b89ef..1a6a67f 100644
@@ -183,6 +183,24 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	return -1;
 }
 
+/* Remove and free an rte_devargs. */
+int
+rte_eal_devargs_rmv(struct rte_devargs *da)
+{
+	struct rte_devargs *d;
+	void *tmp;
+
+	TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) {
+		if (d == da) {
+			TAILQ_REMOVE(&devargs_list, d, next);
+			free(d->args);
+			free(d);
+			return 0;
+		}
+	}
+	return 1;
+}
+
 /* Deep-copy of an rte_devargs. */
 struct rte_devargs *
 rte_eal_devargs_clone(struct rte_devargs *da)
lib/librte_eal/common/include/rte_devargs.h +14 -0
index 892b035..f61707c 100644
@@ -163,6 +163,20 @@ rte_eal_devargs_parse(const char *dev,
 int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str);
 
 /**
+ * Remove a device from the user device list.
+ * The devargs is then freed.
+ *
+ * @param da
+ *   devargs to remove.
+ *
+ * @return
+ *   0 on success.
+ *   <0 on error.
+ *   >0 if the devargs was not within the user device list.
+ */
+int rte_eal_devargs_rmv(struct rte_devargs *da);
+
+/**
  * Deep copy an rte_devargs.
  *
  * @param da
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
index 6e6638a..19eec05 100644
@@ -208,5 +208,6 @@ DPDK_17.08 {
 	rte_bus_from_name;
 	rte_bus_from_dev;
 	rte_eal_devargs_clone;
+	rte_eal_devargs_rmv;
 
 } DPDK_17.05;
Signature · 1 line
2.1.4
#66 lore raw

PATCH v4 19/19 eal: change whitelist / blacklist command line doc

In reply to Gaetan Rivet

The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.

Update the source code accordingly.

---
 lib/librte_eal/common/eal_common_options.c | 18 +++++++++---------
 lib/librte_eal/common/eal_options.h        |  8 ++++----
 2 files changed, 13 insertions(+), 13 deletions(-)
lib/librte_eal/common/eal_common_options.c +9 -9
index 075b0ea..245a276 100644
@@ -86,8 +86,8 @@ eal_long_options[] = {
 	{OPT_NO_HUGE,           0, NULL, OPT_NO_HUGE_NUM          },
 	{OPT_NO_PCI,            0, NULL, OPT_NO_PCI_NUM           },
 	{OPT_NO_SHCONF,         0, NULL, OPT_NO_SHCONF_NUM        },
-	{OPT_PCI_BLACKLIST,     1, NULL, OPT_PCI_BLACKLIST_NUM    },
-	{OPT_PCI_WHITELIST,     1, NULL, OPT_PCI_WHITELIST_NUM    },
+	{OPT_BUS_BLACKLIST,     1, NULL, OPT_BUS_BLACKLIST_NUM    },
+	{OPT_BUS_WHITELIST,     1, NULL, OPT_BUS_WHITELIST_NUM    },
 	{OPT_PROC_TYPE,         1, NULL, OPT_PROC_TYPE_NUM        },
 	{OPT_SOCKET_MEM,        1, NULL, OPT_SOCKET_MEM_NUM       },
 	{OPT_SYSLOG,            1, NULL, OPT_SYSLOG_NUM           },
@@ -1049,14 +1049,14 @@ eal_common_usage(void)
 	       "  -n CHANNELS         Number of memory channels\n"
 	       "  -m MB               Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
 	       "  -r RANKS            Force number of memory ranks (don't detect)\n"
-	       "  -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
-	       "                      Prevent EAL from using this PCI device. The argument\n"
-	       "                      format is <domain:bus:devid.func>.\n"
-	       "  -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
-	       "                      Only use the specified PCI devices. The argument format\n"
-	       "                      is <[domain:]bus:devid.func>. This option can be present\n"
+	       "  -b, --"OPT_BUS_BLACKLIST" Black list a device on its bus.\n"
+	       "                      Prevents EAL from using this device. The argument\n"
+	       "                      format depends on the bus.\n"
+	       "  -w, --"OPT_BUS_WHITELIST" White list a device on its bus.\n"
+	       "                      Only use the specified devices. The argument format\n"
+	       "                      depends on the bus. This option can be present\n"
 	       "                      several times (once per device).\n"
-	       "                      [NOTE: PCI whitelist cannot be used with -b option]\n"
+	       "                      [NOTE: whitelist cannot be used with -b option]\n"
 	       "  --"OPT_VDEV"              Add a virtual device.\n"
 	       "                      The argument format is <driver><id>[,key=val,...]\n"
 	       "                      (ex: --vdev=net_pcap0,iface=eth2).\n"
lib/librte_eal/common/eal_options.h +4 -4
index a881c62..4c5db07 100644
@@ -37,10 +37,10 @@ enum {
 	/* long options mapped to a short option */
 #define OPT_HELP              "help"
 	OPT_HELP_NUM            = 'h',
-#define OPT_PCI_BLACKLIST     "pci-blacklist"
-	OPT_PCI_BLACKLIST_NUM   = 'b',
-#define OPT_PCI_WHITELIST     "pci-whitelist"
-	OPT_PCI_WHITELIST_NUM   = 'w',
+#define OPT_BUS_BLACKLIST     "bus-blacklist"
+	OPT_BUS_BLACKLIST_NUM   = 'b',
+#define OPT_BUS_WHITELIST     "bus-whitelist"
+	OPT_BUS_WHITELIST_NUM   = 'w',
 
 	/* first long only option value must be >= 256, so that we won't
 	 * conflict with short options */
Signature · 1 line
2.1.4
#67 lore raw

v5 cover Generic devargs parsing

In reply to Gaetan Rivet

The second part of the work outlined in [1] and [2]. The first part is at [3].

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.

Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.

With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.

Buses needs only to implement the "parse" method for their devices to be declared in this way.

[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html

This patchset depends on:

[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/

v1 -> v2:

* fix PCI whitelist mode

v2 -> v3:

* Rebase the series on the new plug / unplug API

v3 -> v4:

* Fix rte_devargs parsing helper
* Introduce new rte_devargs clone function
* Introduce new rte_devargs release function
* Fix test application for rte_devargs.
TODO: rewrite complete rte_devargs autotest.
* Fix a few rte_pci references.
* Update EAL command line help for -w / -b

v5:

* Fix integration issue with new arbitrary bus name parsing.

Gaetan Rivet (19):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc

 app/test-pmd/testpmd.c                          |   9 +-
 app/test-pmd/testpmd.h                          |   2 +
 doc/guides/rel_notes/deprecation.rst            |   5 +
 drivers/net/bnxt/bnxt.h                         |   1 +
 drivers/net/bonding/rte_eth_bond_args.c         |   1 +
 drivers/net/e1000/e1000_ethdev.h                |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.h                |   1 +
 drivers/net/mlx5/mlx5.h                         |   1 +
 drivers/net/sfc/sfc.h                           |   1 +
 drivers/net/virtio/virtio_pci.c                 |   5 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   2 +
 lib/librte_eal/common/eal_common_devargs.c      | 176 ++++++++++++++++--------
 lib/librte_eal/common/eal_common_options.c      |  31 ++---
 lib/librte_eal/common/eal_common_pci.c          |  16 ++-
 lib/librte_eal/common/eal_common_vdev.c         |  18 ++-
 lib/librte_eal/common/eal_options.h             |   8 +-
 lib/librte_eal/common/include/rte_bus.h         |  17 +++
 lib/librte_eal/common/include/rte_dev.h         |  12 ++
 lib/librte_eal/common/include/rte_devargs.h     |  68 ++++++---
 lib/librte_eal/common/include/rte_pci.h         |   9 --
 lib/librte_eal/common/include/rte_vdev.h        |   2 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   2 +
 test/test/test_devargs.c                        |  45 +++---
 test/test/virtual_pmd.c                         |   1 +
 24 files changed, 278 insertions(+), 156 deletions(-)
Signature · 1 line
2.1.4
#68 lore raw

PATCH v5 1/19 net/bonding: properly reference PCI header

---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
index dc468d2..ed217fb 100644
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
Signature · 1 line
2.1.4
#69 lore raw

PATCH v5 2/19 net/bnxt: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
index 1538aa5..07279f7 100644
@@ -38,6 +38,7 @@
 #include <stdbool.h>
 #include <sys/queue.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_memory.h>
 #include <rte_lcore.h>
Signature · 1 line
2.1.4
#70 lore raw

PATCH v5 3/19 net/mlx5: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
index aa8a1a0..f16f778 100644
@@ -54,6 +54,7 @@
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
+#include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#71 lore raw

PATCH v5 4/19 net/e1000: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
index 85fd1a0..5668910 100644
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include <rte_time.h>
+#include <rte_pci.h>
 
 #define E1000_INTEL_VENDOR_ID 0x8086
 
Signature · 1 line
2.1.4
#72 lore raw

PATCH v5 5/19 net/ixgbe: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 10b9967..bcbd62d 100644
@@ -39,6 +39,7 @@
 #include "ixgbe_bypass.h"
 #include <rte_time.h>
 #include <rte_hash.h>
+#include <rte_pci.h>
 
 /* need update link, bit flag */
 #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
#73 lore raw

PATCH v5 6/19 net/sfc: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
index 007ed24..41dff48 100644
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#74 lore raw

PATCH v5 7/19 app/testpmd: properly reference PCI header

In reply to Gaetan Rivet
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
index 1838241..90a6568 100644
@@ -34,6 +34,8 @@
 #ifndef _TESTPMD_H_
 #define _TESTPMD_H_
 
+#include <rte_pci.h>
+
 #define RTE_PORT_ALL            (~(portid_t)0x0)
 
 #define RTE_TEST_RX_DESC_MAX    2048
Signature · 1 line
2.1.4
#75 lore raw

PATCH v5 8/19 test: properly reference PCI header

In reply to Gaetan Rivet
---
 test/test/virtual_pmd.c | 1 +
 1 file changed, 1 insertion(+)
test/test/virtual_pmd.c +1 -0
index e9dd8ac..f3ee82f 100644
@@ -33,6 +33,7 @@
 
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
+#include <rte_pci.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_memory.h>
Signature · 1 line
2.1.4
#76 lore raw

PATCH v5 9/19 dev: device kernel module is a device attribute

In reply to Gaetan Rivet

It is used in generic device structures and must not be tied to a bus.

---
 lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++
 lib/librte_eal/common/include/rte_pci.h |  9 ---------
 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
index 9f35b1f..3162822 100644
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 } while (0)
 
 /**
+ * Device driver.
+ */
+enum rte_kernel_driver {
+	RTE_KDRV_UNKNOWN = 0,
+	RTE_KDRV_IGB_UIO,
+	RTE_KDRV_VFIO,
+	RTE_KDRV_UIO_GENERIC,
+	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
+};
+
+/**
  * A generic memory resource representation.
  */
 struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
index 0284a62..ca9f179 100644
@@ -120,15 +120,6 @@ struct rte_pci_addr {
 
 struct rte_devargs;
 
-enum rte_kernel_driver {
-	RTE_KDRV_UNKNOWN = 0,
-	RTE_KDRV_IGB_UIO,
-	RTE_KDRV_VFIO,
-	RTE_KDRV_UIO_GENERIC,
-	RTE_KDRV_NIC_UIO,
-	RTE_KDRV_NONE,
-};
-
 /**
  * A structure describing a PCI device.
  */
Signature · 1 line
2.1.4
#77 lore raw

PATCH v5 10/19 bus: introduce bus scan policies

In reply to Gaetan Rivet

Scan policies describe the way a bus should scan the system to search for possible devices.

Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices

---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
index 61d9e6e..793a625 100644
@@ -137,6 +137,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
 /**
+ * Bus scan policies
+ */
+enum rte_bus_scan_mode {
+	RTE_BUS_SCAN_UNDEFINED,
+	RTE_BUS_SCAN_WHITELIST,
+	RTE_BUS_SCAN_BLACKLIST,
+};
+
+/**
+ * A structure used to configure bus operations.
+ */
+struct rte_bus_conf {
+	enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
+};
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -148,6 +164,7 @@ struct rte_bus {
 	rte_bus_plug_t plug;         /**< Probe single device for drivers */
 	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
 	rte_bus_parse_t parse;       /**< Parse a device name */
+	struct rte_bus_conf conf;    /**< Bus configuration */
 };
 
 /**
Signature · 1 line
2.1.4
#78 lore raw

Re: [PATCH v5 10/19] bus: introduce bus scan policies

21/06/2017 01:35, Gaetan Rivet:

Quoted 9 lines

Scan policies describe the way a bus should scan the system to search for possible devices.

Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices

[...]

lib/librte_eal/common/include/rte_bus.h struct rte_bus { · line 168

Quoted 6 lines
lib/librte_eal/common/include/rte_bus.h +1 -0
@@ -148,6 +164,7 @@ struct rte_bus {
 	rte_bus_plug_t plug;         /**< Probe single device for drivers */
 	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
 	rte_bus_parse_t parse;       /**< Parse a device name */
+	struct rte_bus_conf conf;    /**< Bus configuration */
 };

You are making explicit what exists currently:
- the PCI bus has a whitelist/blacklist policy
- the vdev bus is only a whitelist
It is a good step to deinterlace some spaghettis in the code.

For the next step, the bus should have no policy. It scans everything. We can have a probing policy, but it should not be stored in the bus. I suggest to add a callback in the probe function which would implement the probing policy:

	FOREACH_DEV_IN_BUS {
		if (user_callback(dev, user_data))
			probe_one(dev);
	}

For compatibility, rte_eal_init() would call rte_bus_probe() with a default callback which checks the whitelists and blacklists for PCI.

#79 lore raw

PATCH v5 11/19 devargs: parse bus policies

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
index d5f297d..ac51b19 100644
@@ -128,6 +128,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 
 		break;
 	}
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	}
 
 	free(buf);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
Signature · 1 line
2.1.4
#80 lore raw

PATCH v5 12/19 devargs: generic device representation

In reply to Gaetan Rivet

Remove the dependency of this subsystem upon bus specific device representation.

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

---
 app/test-pmd/testpmd.c                      |  9 ++----
 lib/librte_eal/common/eal_common_devargs.c  | 48 +++++------------------------
 lib/librte_eal/common/eal_common_pci.c      |  9 ++++--
 lib/librte_eal/common/eal_common_vdev.c     | 17 +++++-----
 lib/librte_eal/common/include/rte_devargs.h | 16 ++--------
 lib/librte_eal/common/include/rte_vdev.h    |  2 +-
 test/test/test_devargs.c                    |  9 ++----
 7 files changed, 30 insertions(+), 80 deletions(-)
app/test-pmd/testpmd.c +2 -7
index b29328a..e19fe89 100644
@@ -1810,7 +1810,6 @@ rmv_event_callback(void *arg)
 {
 	struct rte_eth_dev *dev;
 	struct rte_devargs *da;
-	char name[32] = "";
 	uint8_t port_id = (intptr_t)arg;
 
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
@@ -1819,12 +1818,8 @@ rmv_event_callback(void *arg)
 
 	stop_port(port_id);
 	close_port(port_id);
-	if (da->type == RTE_DEVTYPE_VIRTUAL)
-		snprintf(name, sizeof(name), "%s", da->virt.drv_name);
-	else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI)
-		rte_pci_device_name(&da->pci.addr, name, sizeof(name));
-	printf("removing device %s\n", name);
-	rte_eal_dev_detach(name);
+	printf("removing device %s\n", da->name);
+	rte_eal_dev_detach(da->name);
 	dev->state = RTE_ETH_DEV_UNUSED;
 }
 
lib/librte_eal/common/eal_common_devargs.c +8 -40

66 lines not on this page · raw message

lib/librte_eal/common/eal_common_pci.c +6 -3
index 0f3ecdb..441466d 100644
@@ -73,12 +73,15 @@ const char *pci_get_sysfs_path(void)
 static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 {
 	struct rte_devargs *devargs;
+	struct rte_pci_addr addr;
+	struct rte_bus *pbus;
 
+	pbus = rte_bus_from_name(PCI_BUS_NAME);
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&
-			devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)
+		if (devargs->bus != pbus)
 			continue;
-		if (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))
+		devargs->bus->parse(devargs->name, &addr);
+		if (!rte_eal_compare_pci_addr(&dev->addr, &addr))
 			return devargs;
 	}
 	return NULL;
lib/librte_eal/common/eal_common_vdev.c +8 -9
index 7cc3c6c..c56fb6d 100644
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)
 	if (args)
 		devargs->args = strdup(args);
 
-	ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", name);
-	if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) {
+	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name);
+	if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
 		free(devargs->args);
 		free(devargs);
 		return NULL;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args)
 
 	dev->device.devargs = devargs;
 	dev->device.numa_node = SOCKET_ID_ANY;
-	dev->device.name = devargs->virt.drv_name;
+	dev->device.name = devargs->name;
 
 	ret = vdev_probe_all_drivers(dev);
 	if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)
 		if (devargs->bus != vbus)
 			continue;
 
-		dev = find_vdev(devargs->virt.drv_name);
+		dev = find_vdev(devargs->name);
 		if (dev)
 			continue;
 
@@ -314,7 +313,7 @@ vdev_scan(void)
 
 		dev->device.devargs = devargs;
 		dev->device.numa_node = SOCKET_ID_ANY;
-		dev->device.name = devargs->virt.drv_name;
+		dev->device.name = devargs->name;
 
 		TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 	}
@@ -361,12 +360,12 @@ vdev_plug(struct rte_devargs *da)
 	struct rte_vdev_device *dev;
 	int ret;
 
-	ret = rte_vdev_init(da->virt.drv_name, da->args);
+	ret = rte_vdev_init(da->name, da->args);
 	if (ret) {
 		rte_errno = -ret;
 		return NULL;
 	}
-	dev = find_vdev(da->virt.drv_name);
+	dev = find_vdev(da->name);
 	return &dev->device;
 }
 
@@ -381,7 +380,7 @@ vdev_unplug(struct rte_device *dev)
 		rte_errno = EINVAL;
 		return -1;
 	}
-	ret = rte_vdev_uninit(da->virt.drv_name);
+	ret = rte_vdev_uninit(da->name);
 	if (ret)
 		rte_errno = -ret;
 	return ret;
lib/librte_eal/common/include/rte_devargs.h +2 -14
index 1f50a24..6a26d3d 100644
@@ -50,7 +50,6 @@ extern "C" {
 
 #include <stdio.h>
 #include <sys/queue.h>
-#include <rte_pci.h>
 #include <rte_bus.h>
 
 /**
@@ -77,21 +76,10 @@ struct rte_devargs {
 	TAILQ_ENTRY(rte_devargs) next;
 	/** Type of device. */
 	enum rte_devtype type;
-	RTE_STD_C11
-	union {
-		/** Used if type is RTE_DEVTYPE_*_PCI. */
-		struct {
-			/** PCI location. */
-			struct rte_pci_addr addr;
-		} pci;
-		/** Used if type is RTE_DEVTYPE_VIRTUAL. */
-		struct {
-			/** Driver name. */
-			char drv_name[32];
-		} virt;
-	};
 	/** Bus handle for the device. */
 	struct rte_bus *bus;
+	/** Name of the device. */
+	char name[32];
 	/** Arguments string as given by user or "" for no argument. */
 	char *args;
 };
lib/librte_eal/common/include/rte_vdev.h +1 -1
index 2d02c68..4debcde 100644
@@ -52,7 +52,7 @@ static inline const char *
 rte_vdev_device_name(const struct rte_vdev_device *dev)
 {
 	if (dev && dev->device.devargs)
-		return dev->device.devargs->virt.drv_name;
+		return dev->device.devargs->name;
 	return NULL;
 }
 
test/test/test_devargs.c +3 -6
index 63242f1..18f54ed 100644
@@ -90,8 +90,8 @@ test_devargs(void)
 	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,k1=val,k2=val2") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
-	if (strncmp(devargs->virt.drv_name, "net_ring1",
-			sizeof(devargs->virt.drv_name)) != 0)
+	if (strncmp(devargs->name, "net_ring1",
+			sizeof(devargs->name)) != 0)
 		goto fail;
 	if (!devargs->args || strcmp(devargs->args, "k1=val,k2=val2") != 0)
 		goto fail;
@@ -101,10 +101,7 @@ test_devargs(void)
 	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "04:00.1") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
-	if (devargs->pci.addr.domain != 0 ||
-		devargs->pci.addr.bus != 4 ||
-		devargs->pci.addr.devid != 0 ||
-		devargs->pci.addr.function != 1)
+	if (strcmp(devargs->name, "04:00.1") != 0)
 		goto fail;
 	if (!devargs->args || strcmp(devargs->args, "") != 0)
 		goto fail;
Signature · 1 line
2.1.4
#81 lore raw

Re: [PATCH v5 12/19] devargs: generic device representation

21/06/2017 01:35, Gaetan Rivet:

Quoted 7 lines

Remove the dependency of this subsystem upon bus specific device representation.

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

Quoted 9 lines
---
 app/test-pmd/testpmd.c                      |  9 ++----
 lib/librte_eal/common/eal_common_devargs.c  | 48 +++++------------------------
 lib/librte_eal/common/eal_common_pci.c      |  9 ++++--
 lib/librte_eal/common/eal_common_vdev.c     | 17 +++++-----
 lib/librte_eal/common/include/rte_devargs.h | 16 ++--------
 lib/librte_eal/common/include/rte_vdev.h    |  2 +-
 test/test/test_devargs.c                    |  9 ++----
 7 files changed, 30 insertions(+), 80 deletions(-)

Is it correct to add this change when rebasing?

lib/librte_eal/common/eal_common_pci.c +1 -1
@@ -533,7 +533,7 @@ pci_plug(struct rte_devargs *da)
        struct rte_pci_device *pdev;
        struct rte_pci_addr *addr;
 
-       addr = &da->pci.addr;
+       da->bus->parse(da->name, &addr);
        /*
         * Update eventual pci device in global list.
         * Insert it if none was found.
#82 lore raw

Re: [PATCH v5 12/19] devargs: generic device representation

Quoted 24 lines · Thomas Monjalon

21/06/2017 01:35, Gaetan Rivet:

Quoted 7 lines

Remove the dependency of this subsystem upon bus specific device representation.

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

Quoted 9 lines
---
 app/test-pmd/testpmd.c                      |  9 ++----
 lib/librte_eal/common/eal_common_devargs.c  | 48 +++++------------------------
 lib/librte_eal/common/eal_common_pci.c      |  9 ++++--
 lib/librte_eal/common/eal_common_vdev.c     | 17 +++++-----
 lib/librte_eal/common/include/rte_devargs.h | 16 ++--------
 lib/librte_eal/common/include/rte_vdev.h    |  2 +-
 test/test/test_devargs.c                    |  9 ++----
 7 files changed, 30 insertions(+), 80 deletions(-)

Is it correct to add this change when rebasing?

lib/librte_eal/common/eal_common_pci.c pci_plug(struct rte_devargs *da) · line 539

Quoted 8 lines
lib/librte_eal/common/eal_common_pci.c +1 -1
@@ -533,7 +533,7 @@ pci_plug(struct rte_devargs *da)
        struct rte_pci_device *pdev;
        struct rte_pci_addr *addr;
 
-       addr = &da->pci.addr;
+       da->bus->parse(da->name, &addr);
        /*
         * Update eventual pci device in global list.
         * Insert it if none was found.

This is the spirit of this API at least :).
bus->parse() will verify that the name is correct, as well as interpret it to obtain the bus-specific representation of the device.

Quoted 2 lines
Quoted 2 lines

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

So the PCI address can be removed from rte_devargs. As such, it cannot be intepreted during parsing, and it must be done afterward from within the bus itself.

I was wondering whether I should update all subsystems relying on this previous rte_devargs logic at once, EAL + vdev + PCI + tests etc... But this is the only way to keep compilation atomicity between patches.

Signature · 2 lines
Gaëtan Rivet
6WIND
#83 lore raw

PATCH 1/1 examples/ethtool: explicit PCI header dependency

In reply to Gaetan Rivet

In devargs rework, rte_pci.h won't be included by rte_ethdev.h (via rte_devargs.h) anymore.

rte_ethtool_get_drvinfo() could use rte_devargs.name instead of creating equivalent bus specific name.
For now, it is workarounded by just including rte_pci.h.

---
 examples/ethtool/lib/rte_ethtool.c | 2 ++
 1 file changed, 2 insertions(+)
examples/ethtool/lib/rte_ethtool.c +2 -0
index fabfcb2ba..252382cb5 100644
@@ -36,6 +36,7 @@
 #include <rte_version.h>
 #include <rte_ethdev.h>
 #include <rte_ether.h>
+#include <rte_pci.h>
 #ifdef RTE_LIBRTE_IXGBE_PMD
 #include <rte_pmd_ixgbe.h>
 #endif
@@ -73,6 +74,7 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 		dev_info.driver_name);
 	snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
 		rte_version());
+	/* TODO: replace bus_info by rte_devargs.name */
 	if (dev_info.pci_dev)
 		snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
 			"%04x:%02x:%02x.%x",
Signature · 1 line
2.13.1
#84 lore raw

PATCH v5 13/19 pci: update device name

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_pci.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_eal/common/eal_common_pci.c +1 -0
index 441466d..eed6589 100644
@@ -330,6 +330,7 @@ rte_pci_probe_one(const struct rte_pci_addr *addr)
 		ret = pci_probe_all_drivers(dev);
 		if (ret)
 			goto err_return;
+		dev->device.name = dev->device.devargs->name;
 		return 0;
 	}
 	return -1;
Signature · 1 line
2.1.4
#85 lore raw

PATCH v5 14/19 net/virtio: do not reference device type

In reply to Gaetan Rivet
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
index b7b3d61..cd48fb5 100644
@@ -38,6 +38,7 @@
 #endif
 
 #include <rte_io.h>
+#include <rte_bus.h>
 
 #include "virtio_pci.h"
 #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
 	if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
 		    (!dev->device.devargs ||
-		     dev->device.devargs->type !=
-			RTE_DEVTYPE_WHITELISTED_PCI)) {
+		     dev->device.devargs->bus !=
+		     rte_bus_from_name(PCI_BUS_NAME))) {
 			PMD_INIT_LOG(INFO,
 				"skip kernel managed virtio device.");
 			return 1;
Signature · 1 line
2.1.4
#86 lore raw

PATCH v5 15/19 devargs: generic device types

In reply to Gaetan Rivet

rte_devargs now represents any device from any bus.
The related devtypes do not identify a bus anymore, only which scan policy the device subscribes to.

The bus itself is identified by a bus handle previously introduced.

---
 lib/librte_eal/common/eal_common_devargs.c  |  4 ++--
 lib/librte_eal/common/eal_common_options.c  | 13 +++--------
 lib/librte_eal/common/eal_common_pci.c      |  6 ++---
 lib/librte_eal/common/eal_common_vdev.c     |  1 -
 lib/librte_eal/common/include/rte_devargs.h |  6 ++---
 test/test/test_devargs.c                    | 36 +++++++++++++++--------------
 6 files changed, 30 insertions(+), 36 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
index 6ccd857..321a62d 100644
@@ -113,14 +113,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", buf);
 	if (ret < 0 || ret >= (int)sizeof(devargs->name))
 		goto fail;
-	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
 			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
 			goto fail;
 		}
-	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
lib/librte_eal/common/eal_common_options.c +3 -10
index f470195..075b0ea 100644
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,
 	switch (opt) {
 	/* blacklist */
 	case 'b':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED,
 				optarg) < 0) {
 			return -1;
 		}
 		break;
 	/* whitelist */
 	case 'w':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 
 	case OPT_VDEV_NUM:
-		if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)
 		return -1;
 	}
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
-		rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
-		RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
-			"cannot be used at the same time\n");
-		return -1;
-	}
-
 	return 0;
 }
 
lib/librte_eal/common/eal_common_pci.c +3 -3
index eed6589..5733b3c 100644
@@ -200,7 +200,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 	/* no initialization when blacklisted, return without error */
 	if (dev->device.devargs != NULL &&
 		dev->device.devargs->type ==
-			RTE_DEVTYPE_BLACKLISTED_PCI) {
+			RTE_DEVTYPE_BLACKLISTED) {
 		RTE_LOG(INFO, EAL, "  Device is blacklisted, not"
 			" initializing\n");
 		return 1;
@@ -393,7 +393,7 @@ rte_pci_probe(void)
 	int probe_all = 0;
 	int ret = 0;
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
+	if (rte_pci_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST)
 		probe_all = 1;
 
 	FOREACH_DEVICE_ON_PCIBUS(dev) {
@@ -408,7 +408,7 @@ rte_pci_probe(void)
 		if (probe_all)
 			ret = pci_probe_all_drivers(dev);
 		else if (devargs != NULL &&
-			devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
+			devargs->type == RTE_DEVTYPE_WHITELISTED)
 			ret = pci_probe_all_drivers(dev);
 		if (ret < 0) {
 			RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
index c56fb6d..d921345 100644
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)
 	if (!devargs)
 		return NULL;
 
-	devargs->type = RTE_DEVTYPE_VIRTUAL;
 	devargs->bus = rte_bus_from_name(VIRTUAL_BUS_NAME);
 	if (args)
 		devargs->args = strdup(args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
index 6a26d3d..6e9e134 100644
@@ -56,9 +56,9 @@ extern "C" {
  * Type of generic device
  */
 enum rte_devtype {
-	RTE_DEVTYPE_WHITELISTED_PCI,
-	RTE_DEVTYPE_BLACKLISTED_PCI,
-	RTE_DEVTYPE_VIRTUAL,
+	RTE_DEVTYPE_UNDEFINED,
+	RTE_DEVTYPE_WHITELISTED,
+	RTE_DEVTYPE_BLACKLISTED,
 };
 
 /**
test/test/test_devargs.c +19 -17
index 18f54ed..149c9c9 100644
@@ -64,30 +64,32 @@ test_devargs(void)
 	TAILQ_INIT(&devargs_list);
 
 	/* test valid cases */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "08:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "08:00.1") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "0000:5:00.0") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "0000:5:00.0") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0,arg=val") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "04:00.0,arg=val") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "0000:01:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "0000:01:00.1") < 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED) != 4)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED) != 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 0)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_UNDEFINED) != 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring0") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED, "net_ring0") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,key=val,k2=val2") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
+				"net_ring1,key=val,k2=val2") < 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_UNDEFINED) != 2)
 		goto fail;
 	free_devargs_list();
 
 	/* check virtual device with argument parsing */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,k1=val,k2=val2") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
+				"net_ring1,k1=val,k2=val2") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
 	if (strncmp(devargs->name, "net_ring1",
@@ -98,7 +100,7 @@ test_devargs(void)
 	free_devargs_list();
 
 	/* check PCI device with empty argument parsing */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "04:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "04:00.1") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
 	if (strcmp(devargs->name, "04:00.1") != 0)
@@ -108,15 +110,15 @@ test_devargs(void)
 	free_devargs_list();
 
 	/* test error case: bad PCI address */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "08:1") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "08:1") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "00.1") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "00.1") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "foo") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "foo") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, ",") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, ",") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "000f:0:0") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "000f:0:0") == 0)
 		goto fail;
 
 	devargs_list = save_devargs_list;
Signature · 1 line
2.1.4
#87 lore raw

PATCH v5 16/19 devargs: introduce cleaner parsing helper

In reply to Gaetan Rivet

Introduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.

The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.

A deprecation notice is issued.

This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.

---
 doc/guides/rel_notes/deprecation.rst        |  5 ++
 lib/librte_eal/common/eal_common_devargs.c  | 91 ++++++++++++++++++++---------
 lib/librte_eal/common/include/rte_devargs.h | 20 +++++++
 3 files changed, 90 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index 1786a59..fb95ced 100644
@@ -105,3 +105,8 @@ Deprecation Notices
   The non-"do-sig" versions of the hash tables will be removed
   (including the ``signature_offset`` parameter)
   and the "do-sig" versions renamed accordingly.
+
+* eal: the following function is deprecated starting from 17.08 and will
+  be removed in 17.11:
+
+  - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +65 -26

118 lines not on this page · raw message

lib/librte_eal/common/include/rte_devargs.h +20 -0
index 6e9e134..2ab8864 100644
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
 /**
+ * Parse a device string.
+ *
+ * Verify that a bus is capable of handling the device passed
+ * in argument. Store which bus will handle the device, its name
+ * and the eventual device parameters.
+ *
+ * @param dev
+ *   The device declaration string.
+ * @param da
+ *   The devargs structure holding the device information.
+ *
+ * @return
+ *   - 0 on success.
+ *   - Negative errno on error.
+ */
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);
+
+/**
  * Add a device to the user device list
  *
  * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
#88 lore raw

Re: [PATCH v5 16/19] devargs: introduce cleaner parsing helper

21/06/2017 01:35, Gaetan Rivet:

Review

Quoted 3 lines
(quoted diff) +3 -0
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);

You need to export this new function:

lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -203,6 +203,7 @@ DPDK_17.08 {
        rte_bus_from_name;
        rte_bus_from_dev;
        rte_eal_devargs_clone;
+       rte_eal_devargs_parse;
        rte_eal_devargs_rmv;
 
 } DPDK_17.05;
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -208,6 +208,7 @@ DPDK_17.08 {
        rte_bus_from_name;
        rte_bus_from_dev;
        rte_eal_devargs_clone;
+       rte_eal_devargs_parse;
        rte_eal_devargs_rmv;
 
 } DPDK_17.05;
#89 lore raw

Re: [PATCH v5 16/19] devargs: introduce cleaner parsing helper

In reply to Gaetan Rivet
Quoted 42 lines · Gaetan Rivet

Introduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.

The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.

A deprecation notice is issued.

This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.

---

doc/guides/rel_notes/deprecation.rst        |  5 ++
lib/librte_eal/common/eal_common_devargs.c  | 91 ++++++++++++++++++++---------
lib/librte_eal/common/include/rte_devargs.h | 20 +++++++
3 files changed, 90 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index 1786a59..fb95ced 100644
@@ -105,3 +105,8 @@ Deprecation Notices
  The non-"do-sig" versions of the hash tables will be removed
  (including the ``signature_offset`` parameter)
  and the "do-sig" versions renamed accordingly.
+
+* eal: the following function is deprecated starting from 17.08 and will
+  be removed in 17.11:
+
+  - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +0 -0
index 321a62d..f2e11f9 100644

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 82

Quoted 6 lines
lib/librte_eal/common/eal_common_devargs.c +3 -0
@@ -77,6 +77,66 @@ rte_eal_parse_devargs_str(const char *devargs_str,
 	return 0;
 }
 
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da)

Does this line need to be broken into two lines?

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 90

Quoted 8 lines
lib/librte_eal/common/eal_common_devargs.c +8 -0
+{
+	struct rte_bus *bus;
+	const char *c;
+	const size_t maxlen = sizeof(da->name);
+	size_t i;
+
+	if ((dev) == NULL || (da) == NULL)
+		return -EINVAL;

Why have () around these variables and I think the normal method is ‘if (!dev || !da) …’ is that preferred method?

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str,

Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7 -0
+	c = dev;
+	/* Retrieve eventual bus info */
+	bus = rte_bus_from_name(dev);
+	if (bus) {
+		i = strlen(bus->name);
+		if (dev[i] == '\0') {
+			fprintf(stderr, "WARNING: device name matches a bus name.\n”);

At this point has the RTE_LOG() system been inited?

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 104

Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7 -0
+			bus = NULL;
+		} else if (rte_bus_from_dev(dev)) {
+			/* false positive on bus name. */
+			bus = NULL;
+		} else {
+			c = &dev[i+1];
+		}

Single line if/else statements do not use the “{}” around the one line. I believe this is the default rule. Does it count for the 'else if' above it too?

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 113

Quoted 9 lines
lib/librte_eal/common/eal_common_devargs.c +9 -0
+	}
+	/* Store device name */
+	i = 0;
+	while (c[i] != '\0' && c[i] != ',') {
+		da->name[i] = c[i];
+		i++;
+		if (i == maxlen) {
+			fprintf(stderr, "WARNING: Parsing \"%s\": device name should be shorter than %zu\n",
+				dev, maxlen);

Same question here. is this line too long?

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 114

Quoted 1 line
lib/librte_eal/common/eal_common_devargs.c +1 -0
+			da->name[i-1] = '\0’;

I believe the must have spaces around the - e.g. [i - 1]

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 123

Quoted 9 lines
lib/librte_eal/common/eal_common_devargs.c +9 -0
+			return -EINVAL;
+		}
+	}
+	da->name[i] = '\0';
+	if (!bus) {
+		bus = rte_bus_from_dev(da->name);
+		if (!bus) {
+			fprintf(stderr, "ERROR: failed to parse bus info from device \"%s\"\n",
+				da->name);

Same here.

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 130

Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7 -0
+			return -EFAULT;
+		}
+	}
+	da->bus = bus;
+	/* Parse eventual device arguments */
+	if (c[i] == ',')
+		da->args = strdup(&c[i+1]);

[i + 1]

Quoted 100 lines
lib/librte_eal/common/eal_common_devargs.c +9 -0
+	else
+		da->args = strdup("");
+	if (da->args == NULL) {
+		fprintf(stderr, "ERROR: not enough memory to parse arguments\n");
+		return -ENOMEM;
+	}
+	return 0;
+}
+
 /* store a whitelist parameter for later parsing */

int
rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)

lib/librte_eal/common/eal_common_devargs.c +5 -25
@@ -84,35 +144,16 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	struct rte_devargs *devargs = NULL;
 	const char *dev = devargs_str;
 	struct rte_bus *bus;
-	char *buf = NULL;
-	int ret;
 
-	/* use malloc instead of rte_malloc as it's called early at init */
-	devargs = malloc(sizeof(*devargs));
+	/* use calloc instead of rte_zmalloc as it's called early at init */
+	devargs = calloc(1, sizeof(*devargs));
 	if (devargs == NULL)
 		goto fail;
 
-	memset(devargs, 0, sizeof(*devargs));
-	devargs->type = devtype;
-
-	bus = rte_bus_from_name(dev);
-	if (bus) {
-		dev += strlen(bus->name) + 1;
-	} else {
-		bus = rte_bus_from_dev(dev);
-		if (!bus) {
-			fprintf(stderr, "ERROR: failed to parse bus info from device declaration\n");
-			goto fail;
-		}
-	}
-	devargs->bus = bus;
-	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
-		goto fail;
-
-	/* save device name. */
-	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", buf);
-	if (ret < 0 || ret >= (int)sizeof(devargs->name))
+	if (rte_eal_devargs_parse(dev, devargs))
 		goto fail;
+	devargs->type = devtype;
+	bus = devargs->bus;
 	if (devargs->type == RTE_DEVTYPE_WHITELISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
@@ -129,12 +170,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 		}
 	}
 
-	free(buf);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
 	return 0;
 

fail:

lib/librte_eal/common/eal_common_devargs.c +0 -1
-	free(buf);
	if (devargs) {
		free(devargs->args);
		free(devargs);
lib/librte_eal/common/include/rte_devargs.h +20 -0
index 6e9e134..2ab8864 100644
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
 /**
+ * Parse a device string.
+ *
+ * Verify that a bus is capable of handling the device passed
+ * in argument. Store which bus will handle the device, its name
+ * and the eventual device parameters.
+ *
+ * @param dev
+ *   The device declaration string.
+ * @param da
+ *   The devargs structure holding the device information.
+ *
+ * @return
+ *   - 0 on success.
+ *   - Negative errno on error.
+ */
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);
+
+/**
 * Add a device to the user device list
 *
 * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4

Regards,
Keith

#90 lore raw

Re: [PATCH v5 16/19] devargs: introduce cleaner parsing helper

Hi Keith,

Thanks for the review.

Quoted 45 lines · Keith
Quoted 45 lines · Gaetan Rivet

Introduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.

The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.

A deprecation notice is issued.

This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.

---

doc/guides/rel_notes/deprecation.rst        |  5 ++
lib/librte_eal/common/eal_common_devargs.c  | 91 ++++++++++++++++++++---------
lib/librte_eal/common/include/rte_devargs.h | 20 +++++++
3 files changed, 90 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index 1786a59..fb95ced 100644
@@ -105,3 +105,8 @@ Deprecation Notices
  The non-"do-sig" versions of the hash tables will be removed
  (including the ``signature_offset`` parameter)
  and the "do-sig" versions renamed accordingly.
+
+* eal: the following function is deprecated starting from 17.08 and will
+  be removed in 17.11:
+
+  - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +0 -0
index 321a62d..f2e11f9 100644
@@ -77,6 +77,66 @@ rte_eal_parse_devargs_str(const char *devargs_str,
 	return 0;
 }
 
Quoted 6 lines

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 82

Quoted 3 lines
lib/librte_eal/common/eal_common_devargs.c +3 -0
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da)

Does this line need to be broken into two lines?

Not really, will change.

Quoted 11 lines

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 90

Quoted 8 lines
lib/librte_eal/common/eal_common_devargs.c +8 -0
+{
+	struct rte_bus *bus;
+	const char *c;
+	const size_t maxlen = sizeof(da->name);
+	size_t i;
+
+	if ((dev) == NULL || (da) == NULL)
+		return -EINVAL;

Why have () around these variables and I think the normal method is ‘if (!dev || !da) …’ is that preferred method?

No reason for the additional parenthesis.
Otherwise, the explicit test against NULL is preferred in the guideline.

Quoted 10 lines

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str,

Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7 -0
+	c = dev;
+	/* Retrieve eventual bus info */
+	bus = rte_bus_from_name(dev);
+	if (bus) {
+		i = strlen(bus->name);
+		if (dev[i] == '\0') {
+			fprintf(stderr, "WARNING: device name matches a bus name.\n”);

At this point has the RTE_LOG() system been inited?

This helper is typically called very early at init. Right underneath, rte_eal_devargs_add also avoids using RTE_LOG. It may be a mistake, I must look into it.

Quoted 10 lines

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 104

Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7 -0
+			bus = NULL;
+		} else if (rte_bus_from_dev(dev)) {
+			/* false positive on bus name. */
+			bus = NULL;
+		} else {
+			c = &dev[i+1];
+		}

Single line if/else statements do not use the “{}” around the one line. I believe this is the default rule. Does it count for the 'else if' above it too?

Right.

Quoted 12 lines

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 113

Quoted 9 lines
lib/librte_eal/common/eal_common_devargs.c +9 -0
+	}
+	/* Store device name */
+	i = 0;
+	while (c[i] != '\0' && c[i] != ',') {
+		da->name[i] = c[i];
+		i++;
+		if (i == maxlen) {
+			fprintf(stderr, "WARNING: Parsing \"%s\": device name should be shorter than %zu\n",
+				dev, maxlen);

Same question here. is this line too long?

Error strings should not be cut through to allow grepping for it.

Quoted 4 lines

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 114

Quoted 1 line
lib/librte_eal/common/eal_common_devargs.c +1 -0
+			da->name[i-1] = '\0’;

I believe the must have spaces around the - e.g. [i - 1]

yes

Quoted 125 lines

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 123

Quoted 9 lines
lib/librte_eal/common/eal_common_devargs.c +9 -0
+			return -EINVAL;
+		}
+	}
+	da->name[i] = '\0';
+	if (!bus) {
+		bus = rte_bus_from_dev(da->name);
+		if (!bus) {
+			fprintf(stderr, "ERROR: failed to parse bus info from device \"%s\"\n",
+				da->name);

Same here.

lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 130

Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7 -0
+			return -EFAULT;
+		}
+	}
+	da->bus = bus;
+	/* Parse eventual device arguments */
+	if (c[i] == ',')
+		da->args = strdup(&c[i+1]);

[i + 1]

Quoted 100 lines
lib/librte_eal/common/eal_common_devargs.c +9 -0
+	else
+		da->args = strdup("");
+	if (da->args == NULL) {
+		fprintf(stderr, "ERROR: not enough memory to parse arguments\n");
+		return -ENOMEM;
+	}
+	return 0;
+}
+
 /* store a whitelist parameter for later parsing */

int
rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)

lib/librte_eal/common/eal_common_devargs.c +5 -25
@@ -84,35 +144,16 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	struct rte_devargs *devargs = NULL;
 	const char *dev = devargs_str;
 	struct rte_bus *bus;
-	char *buf = NULL;
-	int ret;
 
-	/* use malloc instead of rte_malloc as it's called early at init */
-	devargs = malloc(sizeof(*devargs));
+	/* use calloc instead of rte_zmalloc as it's called early at init */
+	devargs = calloc(1, sizeof(*devargs));
 	if (devargs == NULL)
 		goto fail;
 
-	memset(devargs, 0, sizeof(*devargs));
-	devargs->type = devtype;
-
-	bus = rte_bus_from_name(dev);
-	if (bus) {
-		dev += strlen(bus->name) + 1;
-	} else {
-		bus = rte_bus_from_dev(dev);
-		if (!bus) {
-			fprintf(stderr, "ERROR: failed to parse bus info from device declaration\n");
-			goto fail;
-		}
-	}
-	devargs->bus = bus;
-	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
-		goto fail;
-
-	/* save device name. */
-	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", buf);
-	if (ret < 0 || ret >= (int)sizeof(devargs->name))
+	if (rte_eal_devargs_parse(dev, devargs))
 		goto fail;
+	devargs->type = devtype;
+	bus = devargs->bus;
 	if (devargs->type == RTE_DEVTYPE_WHITELISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
@@ -129,12 +170,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 		}
 	}
 
-	free(buf);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
 	return 0;
 

fail:

lib/librte_eal/common/eal_common_devargs.c +0 -1
-	free(buf);
	if (devargs) {
		free(devargs->args);
		free(devargs);
lib/librte_eal/common/include/rte_devargs.h +20 -0
index 6e9e134..2ab8864 100644
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
 /**
+ * Parse a device string.
+ *
+ * Verify that a bus is capable of handling the device passed
+ * in argument. Store which bus will handle the device, its name
+ * and the eventual device parameters.
+ *
+ * @param dev
+ *   The device declaration string.
+ * @param da
+ *   The devargs structure holding the device information.
+ *
+ * @return
+ *   - 0 on success.
+ *   - Negative errno on error.
+ */
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);
+
+/**
 * Add a device to the user device list
 *
 * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4

Regards,
Keith

Signature · 2 lines
Gaëtan Rivet
6WIND
#91 lore raw

PATCH v5 17/19 devargs: clone function

In reply to Gaetan Rivet

This function returns a deep copy of an rte_devargs.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_devargs.c      | 20 ++++++++++++++++++++
 lib/librte_eal/common/include/rte_devargs.h     | 12 ++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 4 files changed, 34 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index 04fa882..a506968 100644
@@ -203,5 +203,6 @@ DPDK_17.08 {
 
 	rte_bus_from_name;
 	rte_bus_from_dev;
+	rte_eal_devargs_clone;
 
 } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +20 -0
index f2e11f9..10009fa 100644
@@ -41,6 +41,7 @@
 #include <string.h>
 
 #include <rte_devargs.h>
+#include <rte_tailq.h>
 #include "eal_private.h"
 
 /** Global list of user devices */
@@ -182,6 +183,25 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	return -1;
 }
 
+/* Deep-copy of an rte_devargs. */
+struct rte_devargs *
+rte_eal_devargs_clone(struct rte_devargs *da)
+{
+	struct rte_devargs *clone;
+
+	clone = calloc(1, sizeof(*clone));
+	if (clone == NULL)
+		return NULL;
+	snprintf(clone->name, sizeof(clone->name), "%s", da->name);
+	clone->args = strdup(da->args ? da->args : "");
+	clone->bus = da->bus;
+	if (clone->args == NULL) {
+		free(clone);
+		return NULL;
+	}
+	return clone;
+}
+
 /* count the number of devices of a specified type */
 unsigned int
 rte_eal_devargs_type_count(enum rte_devtype devtype)
lib/librte_eal/common/include/rte_devargs.h +12 -0
index 2ab8864..892b035 100644
@@ -163,6 +163,18 @@ rte_eal_devargs_parse(const char *dev,
 int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str);
 
 /**
+ * Deep copy an rte_devargs.
+ *
+ * @param da
+ *   Source devargs.
+ *
+ * @return
+ *   The pointer to the new rte_devargs on success.
+ *   NULL on error.
+ */
+struct rte_devargs *rte_eal_devargs_clone(struct rte_devargs *da);
+
+/**
  * Count the number of user devices of a specified type
  *
  * @param devtype
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
index a5127d6..6e6638a 100644
@@ -207,5 +207,6 @@ DPDK_17.08 {
 
 	rte_bus_from_name;
 	rte_bus_from_dev;
+	rte_eal_devargs_clone;
 
 } DPDK_17.05;
Signature · 1 line
2.1.4
#92 lore raw

PATCH v5 18/19 devargs: remove function

In reply to Gaetan Rivet

This function is now necessary due to the new unplug rte_bus API.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_devargs.c      | 18 ++++++++++++++++++
 lib/librte_eal/common/include/rte_devargs.h     | 14 ++++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 4 files changed, 34 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index a506968..d069de0 100644
@@ -204,5 +204,6 @@ DPDK_17.08 {
 	rte_bus_from_name;
 	rte_bus_from_dev;
 	rte_eal_devargs_clone;
+	rte_eal_devargs_rmv;
 
 } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +18 -0
index 10009fa..bbd57c5 100644
@@ -183,6 +183,24 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	return -1;
 }
 
+/* Remove and free an rte_devargs. */
+int
+rte_eal_devargs_rmv(struct rte_devargs *da)
+{
+	struct rte_devargs *d;
+	void *tmp;
+
+	TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) {
+		if (d == da) {
+			TAILQ_REMOVE(&devargs_list, d, next);
+			free(d->args);
+			free(d);
+			return 0;
+		}
+	}
+	return 1;
+}
+
 /* Deep-copy of an rte_devargs. */
 struct rte_devargs *
 rte_eal_devargs_clone(struct rte_devargs *da)
lib/librte_eal/common/include/rte_devargs.h +14 -0
index 892b035..f61707c 100644
@@ -163,6 +163,20 @@ rte_eal_devargs_parse(const char *dev,
 int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str);
 
 /**
+ * Remove a device from the user device list.
+ * The devargs is then freed.
+ *
+ * @param da
+ *   devargs to remove.
+ *
+ * @return
+ *   0 on success.
+ *   <0 on error.
+ *   >0 if the devargs was not within the user device list.
+ */
+int rte_eal_devargs_rmv(struct rte_devargs *da);
+
+/**
  * Deep copy an rte_devargs.
  *
  * @param da
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
index 6e6638a..19eec05 100644
@@ -208,5 +208,6 @@ DPDK_17.08 {
 	rte_bus_from_name;
 	rte_bus_from_dev;
 	rte_eal_devargs_clone;
+	rte_eal_devargs_rmv;
 
 } DPDK_17.05;
Signature · 1 line
2.1.4
#93 lore raw

PATCH v5 19/19 eal: change whitelist / blacklist command line doc

In reply to Gaetan Rivet

The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.

Update the source code accordingly.

---
 lib/librte_eal/common/eal_common_options.c | 18 +++++++++---------
 lib/librte_eal/common/eal_options.h        |  8 ++++----
 2 files changed, 13 insertions(+), 13 deletions(-)
lib/librte_eal/common/eal_common_options.c +9 -9
index 075b0ea..245a276 100644
@@ -86,8 +86,8 @@ eal_long_options[] = {
 	{OPT_NO_HUGE,           0, NULL, OPT_NO_HUGE_NUM          },
 	{OPT_NO_PCI,            0, NULL, OPT_NO_PCI_NUM           },
 	{OPT_NO_SHCONF,         0, NULL, OPT_NO_SHCONF_NUM        },
-	{OPT_PCI_BLACKLIST,     1, NULL, OPT_PCI_BLACKLIST_NUM    },
-	{OPT_PCI_WHITELIST,     1, NULL, OPT_PCI_WHITELIST_NUM    },
+	{OPT_BUS_BLACKLIST,     1, NULL, OPT_BUS_BLACKLIST_NUM    },
+	{OPT_BUS_WHITELIST,     1, NULL, OPT_BUS_WHITELIST_NUM    },
 	{OPT_PROC_TYPE,         1, NULL, OPT_PROC_TYPE_NUM        },
 	{OPT_SOCKET_MEM,        1, NULL, OPT_SOCKET_MEM_NUM       },
 	{OPT_SYSLOG,            1, NULL, OPT_SYSLOG_NUM           },
@@ -1049,14 +1049,14 @@ eal_common_usage(void)
 	       "  -n CHANNELS         Number of memory channels\n"
 	       "  -m MB               Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
 	       "  -r RANKS            Force number of memory ranks (don't detect)\n"
-	       "  -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
-	       "                      Prevent EAL from using this PCI device. The argument\n"
-	       "                      format is <domain:bus:devid.func>.\n"
-	       "  -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
-	       "                      Only use the specified PCI devices. The argument format\n"
-	       "                      is <[domain:]bus:devid.func>. This option can be present\n"
+	       "  -b, --"OPT_BUS_BLACKLIST" Black list a device on its bus.\n"
+	       "                      Prevents EAL from using this device. The argument\n"
+	       "                      format depends on the bus.\n"
+	       "  -w, --"OPT_BUS_WHITELIST" White list a device on its bus.\n"
+	       "                      Only use the specified devices. The argument format\n"
+	       "                      depends on the bus. This option can be present\n"
 	       "                      several times (once per device).\n"
-	       "                      [NOTE: PCI whitelist cannot be used with -b option]\n"
+	       "                      [NOTE: whitelist cannot be used with -b option]\n"
 	       "  --"OPT_VDEV"              Add a virtual device.\n"
 	       "                      The argument format is <driver><id>[,key=val,...]\n"
 	       "                      (ex: --vdev=net_pcap0,iface=eth2).\n"
lib/librte_eal/common/eal_options.h +4 -4
index a881c62..4c5db07 100644
@@ -37,10 +37,10 @@ enum {
 	/* long options mapped to a short option */
 #define OPT_HELP              "help"
 	OPT_HELP_NUM            = 'h',
-#define OPT_PCI_BLACKLIST     "pci-blacklist"
-	OPT_PCI_BLACKLIST_NUM   = 'b',
-#define OPT_PCI_WHITELIST     "pci-whitelist"
-	OPT_PCI_WHITELIST_NUM   = 'w',
+#define OPT_BUS_BLACKLIST     "bus-blacklist"
+	OPT_BUS_BLACKLIST_NUM   = 'b',
+#define OPT_BUS_WHITELIST     "bus-whitelist"
+	OPT_BUS_WHITELIST_NUM   = 'w',
 
 	/* first long only option value must be >= 256, so that we won't
 	 * conflict with short options */
Signature · 1 line
2.1.4
Acked-by on v5 19/19
#94 lore raw

Re: [PATCH v5 19/19] eal: change whitelist / blacklist command line doc

Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Wednesday, June 21, 2017 12:36 AM
To: [email protected]
Cc: Gaetan Rivet <[email protected]>
Subject: [dpdk-dev] [PATCH v5 19/19] eal: change whitelist / blacklist command line doc

Quoted 6 lines

The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.

Update the source code accordingly.

#95 lore raw

v6 cover Generic devargs parsing

In reply to Gaetan Rivet

The second part of the work outlined in [1] and [2]. The first part is at [3].

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.

Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.

With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.

Buses needs only to implement the "parse" method for their devices to be declared in this way.

[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html

This patchset depends on:

[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/

v1 -> v2:

* fix PCI whitelist mode

v2 -> v3:

* Rebase the series on the new plug / unplug API

v3 -> v4:

* Fix rte_devargs parsing helper
* Introduce new rte_devargs clone function
* Introduce new rte_devargs release function
* Fix test application for rte_devargs.
TODO: rewrite complete rte_devargs autotest.
* Fix a few rte_pci references.
* Update EAL command line help for -w / -b

v5:

* Fix integration issue with new arbitrary bus name parsing.

v6:

* Follow new hotplug & parse API
* Export rte_eal_devargs_parse symbol
* Improve the devargs parsing in regard to possible bus / dev naming ambiguities.
* A few code style issues fixed.
* The EAL dependency on vdev is not fixed anymore It is beyond the scope of this patchset.

Gaetan Rivet (19):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc

 app/test-pmd/testpmd.c                          |   9 +-
 app/test-pmd/testpmd.h                          |   2 +
 doc/guides/rel_notes/deprecation.rst            |   5 +
 drivers/net/bnxt/bnxt.h                         |   1 +
 drivers/net/bonding/rte_eth_bond_args.c         |   1 +
 drivers/net/e1000/e1000_ethdev.h                |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.h                |   1 +
 drivers/net/mlx5/mlx5.h                         |   1 +
 drivers/net/sfc/sfc.h                           |   1 +
 drivers/net/virtio/virtio_pci.c                 |   5 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   3 +
 lib/librte_eal/common/eal_common_bus.c          |   9 +-
 lib/librte_eal/common/eal_common_devargs.c      | 166 +++++++++++++++---------
 lib/librte_eal/common/eal_common_options.c      |  31 ++---
 lib/librte_eal/common/eal_common_pci.c          |  16 ++-
 lib/librte_eal/common/eal_common_vdev.c         |  12 +-
 lib/librte_eal/common/eal_options.h             |   8 +-
 lib/librte_eal/common/include/rte_bus.h         |  17 +++
 lib/librte_eal/common/include/rte_dev.h         |  12 ++
 lib/librte_eal/common/include/rte_devargs.h     |  68 +++++++---
 lib/librte_eal/common/include/rte_pci.h         |   9 --
 lib/librte_eal/common/include/rte_vdev.h        |   2 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   3 +
 test/test/test_devargs.c                        |  45 ++++---
 test/test/virtual_pmd.c                         |   1 +
 25 files changed, 270 insertions(+), 159 deletions(-)
Signature · 1 line
2.1.4
#96 lore raw

PATCH v6 1/19 net/bonding: properly reference PCI header

---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
index c718e61..4b99e13 100644
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
Signature · 1 line
2.1.4
#97 lore raw

PATCH v6 2/19 net/bnxt: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
index 1538aa5..07279f7 100644
@@ -38,6 +38,7 @@
 #include <stdbool.h>
 #include <sys/queue.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_memory.h>
 #include <rte_lcore.h>
Signature · 1 line
2.1.4
#98 lore raw

PATCH v6 3/19 net/mlx5: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
index 1148dee..9ef2c11 100644
@@ -54,6 +54,7 @@
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
+#include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#99 lore raw

PATCH v6 4/19 net/e1000: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
index 9266540..3f521a7 100644
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include <rte_time.h>
+#include <rte_pci.h>
 
 #define E1000_INTEL_VENDOR_ID 0x8086
 
Signature · 1 line
2.1.4
#100 lore raw

PATCH v6 5/19 net/ixgbe: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 10b9967..bcbd62d 100644
@@ -39,6 +39,7 @@
 #include "ixgbe_bypass.h"
 #include <rte_time.h>
 #include <rte_hash.h>
+#include <rte_pci.h>
 
 /* need update link, bit flag */
 #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
#101 lore raw

PATCH v6 6/19 net/sfc: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
index 007ed24..41dff48 100644
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#102 lore raw

PATCH v6 7/19 app/testpmd: properly reference PCI header

In reply to Gaetan Rivet
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
index 364502d..f23114a 100644
@@ -34,6 +34,8 @@
 #ifndef _TESTPMD_H_
 #define _TESTPMD_H_
 
+#include <rte_pci.h>
+
 #define RTE_PORT_ALL            (~(portid_t)0x0)
 
 #define RTE_TEST_RX_DESC_MAX    2048
Signature · 1 line
2.1.4
#103 lore raw

PATCH v6 8/19 test: properly reference PCI header

In reply to Gaetan Rivet
---
 test/test/virtual_pmd.c | 1 +
 1 file changed, 1 insertion(+)
test/test/virtual_pmd.c +1 -0
index db99894..8e698bc 100644
@@ -33,6 +33,7 @@
 
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
+#include <rte_pci.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_memory.h>
Signature · 1 line
2.1.4
#104 lore raw

PATCH v6 9/19 dev: device kernel module is a device attribute

In reply to Gaetan Rivet

It is used in generic device structures and must not be tied to a bus.

---
 lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++
 lib/librte_eal/common/include/rte_pci.h |  9 ---------
 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
index 9f2765d..82c42c7 100644
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 } while (0)
 
 /**
+ * Device driver.
+ */
+enum rte_kernel_driver {
+	RTE_KDRV_UNKNOWN = 0,
+	RTE_KDRV_IGB_UIO,
+	RTE_KDRV_VFIO,
+	RTE_KDRV_UIO_GENERIC,
+	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
+};
+
+/**
  * A generic memory resource representation.
  */
 struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
index 7863f94..884e24c 100644
@@ -117,15 +117,6 @@ struct rte_pci_addr {
 
 struct rte_devargs;
 
-enum rte_kernel_driver {
-	RTE_KDRV_UNKNOWN = 0,
-	RTE_KDRV_IGB_UIO,
-	RTE_KDRV_VFIO,
-	RTE_KDRV_UIO_GENERIC,
-	RTE_KDRV_NIC_UIO,
-	RTE_KDRV_NONE,
-};
-
 /**
  * A structure describing a PCI device.
  */
Signature · 1 line
2.1.4
#105 lore raw

PATCH v6 10/19 bus: introduce bus scan policies

In reply to Gaetan Rivet

Scan policies describe the way a bus should scan the system to search for possible devices.

Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices

---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
index aebf57e..37cc230 100644
@@ -158,6 +158,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
 /**
+ * Bus scan policies
+ */
+enum rte_bus_scan_mode {
+	RTE_BUS_SCAN_UNDEFINED,
+	RTE_BUS_SCAN_WHITELIST,
+	RTE_BUS_SCAN_BLACKLIST,
+};
+
+/**
+ * A structure used to configure bus operations.
+ */
+struct rte_bus_conf {
+	enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
+};
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -169,6 +185,7 @@ struct rte_bus {
 	rte_bus_plug_t plug;         /**< Probe single device for drivers */
 	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
 	rte_bus_parse_t parse;       /**< Parse a device name */
+	struct rte_bus_conf conf;    /**< Bus configuration */
 };
 
 /**
Signature · 1 line
2.1.4
#106 lore raw

PATCH v6 11/19 devargs: parse bus policies

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
index 102bd8d..16052a3 100644
@@ -143,6 +143,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 
 		break;
 	}
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	}
 
 	free(dev);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
Signature · 1 line
2.1.4
#107 lore raw

PATCH v6 12/19 devargs: generic device representation

In reply to Gaetan Rivet

Remove the dependency of this subsystem upon bus specific device representation.

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

---
 app/test-pmd/testpmd.c                      |  9 +-----
 lib/librte_eal/common/eal_common_bus.c      |  9 +++---
 lib/librte_eal/common/eal_common_devargs.c  | 47 +++++------------------------
 lib/librte_eal/common/eal_common_pci.c      |  9 ++++--
 lib/librte_eal/common/eal_common_vdev.c     | 11 +++----
 lib/librte_eal/common/include/rte_devargs.h | 16 ++--------
 lib/librte_eal/common/include/rte_vdev.h    |  2 +-
 test/test/test_devargs.c                    |  9 ++----
 8 files changed, 31 insertions(+), 81 deletions(-)
app/test-pmd/testpmd.c +1 -8
index 0a23d82..3b08d41 100644
@@ -1809,21 +1809,14 @@ static void
 rmv_event_callback(void *arg)
 {
 	struct rte_eth_dev *dev;
-	struct rte_devargs *da;
-	char name[32] = "";
 	uint8_t port_id = (intptr_t)arg;
 
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
-	da = dev->device->devargs;
 
 	stop_port(port_id);
 	close_port(port_id);
-	if (da->type == RTE_DEVTYPE_VIRTUAL)
-		snprintf(name, sizeof(name), "%s", da->virt.drv_name);
-	else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI)
-		rte_pci_device_name(&da->pci.addr, name, sizeof(name));
-	printf("removing device %s\n", name);
+	printf("removing device %s\n", dev->device->name);
 	rte_eal_dev_detach(dev->device);
 	dev->state = RTE_ETH_DEV_UNUSED;
 }
lib/librte_eal/common/eal_common_bus.c +5 -4
index 34fcfa1..b127c0c 100644
@@ -36,6 +36,7 @@
 #include <sys/queue.h>
 
 #include <rte_bus.h>
+#include <rte_devargs.h>
 
 #include "eal_private.h"
 
@@ -216,12 +217,12 @@ bus_can_parse(const struct rte_bus *bus, const void *_name)
 struct rte_bus *
 rte_bus_find_by_device_name(const char *str)
 {
-	char name[32];
+	struct rte_devargs da;
 	char *c;
 
-	snprintf(name, sizeof(name), "%s", str);
-	c = strchr(name, ',');
+	snprintf(da.name, sizeof(da.name), "%s", str);
+	c = strchr(da.name, ',');
 	if (c != NULL)
 		c[0] = '\0';
-	return rte_bus_find(NULL, bus_can_parse, name);
+	return rte_bus_find(NULL, bus_can_parse, da.name);
 }
lib/librte_eal/common/eal_common_devargs.c +8 -39

65 lines not on this page · raw message

lib/librte_eal/common/eal_common_pci.c +6 -3
index d7e2fb4..5838cc6 100644
@@ -74,12 +74,15 @@ const char *pci_get_sysfs_path(void)
 static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 {
 	struct rte_devargs *devargs;
+	struct rte_pci_addr addr;
+	struct rte_bus *pbus;
 
+	pbus = rte_bus_find_by_name("pci");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&
-			devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)
+		if (devargs->bus != pbus)
 			continue;
-		if (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))
+		devargs->bus->parse(devargs->name, &addr);
+		if (!rte_eal_compare_pci_addr(&dev->addr, &addr))
 			return devargs;
 	}
 	return NULL;
lib/librte_eal/common/eal_common_vdev.c +5 -6
index 8fd1ef7..639ef73 100644
@@ -181,9 +181,8 @@ alloc_devargs(const char *name, const char *args)
 	if (args)
 		devargs->args = strdup(args);
 
-	ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", name);
-	if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) {
+	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name);
+	if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
 		free(devargs->args);
 		free(devargs);
 		return NULL;
@@ -218,7 +217,7 @@ rte_vdev_init(const char *name, const char *args)
 
 	dev->device.devargs = devargs;
 	dev->device.numa_node = SOCKET_ID_ANY;
-	dev->device.name = devargs->virt.drv_name;
+	dev->device.name = devargs->name;
 
 	ret = vdev_probe_all_drivers(dev);
 	if (ret) {
@@ -299,7 +298,7 @@ vdev_scan(void)
 		if (devargs->bus != vbus)
 			continue;
 
-		dev = find_vdev(devargs->virt.drv_name);
+		dev = find_vdev(devargs->name);
 		if (dev)
 			continue;
 
@@ -309,7 +308,7 @@ vdev_scan(void)
 
 		dev->device.devargs = devargs;
 		dev->device.numa_node = SOCKET_ID_ANY;
-		dev->device.name = devargs->virt.drv_name;
+		dev->device.name = devargs->name;
 
 		TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 	}
lib/librte_eal/common/include/rte_devargs.h +2 -14
index 1f50a24..6a26d3d 100644
@@ -50,7 +50,6 @@ extern "C" {
 
 #include <stdio.h>
 #include <sys/queue.h>
-#include <rte_pci.h>
 #include <rte_bus.h>
 
 /**
@@ -77,21 +76,10 @@ struct rte_devargs {
 	TAILQ_ENTRY(rte_devargs) next;
 	/** Type of device. */
 	enum rte_devtype type;
-	RTE_STD_C11
-	union {
-		/** Used if type is RTE_DEVTYPE_*_PCI. */
-		struct {
-			/** PCI location. */
-			struct rte_pci_addr addr;
-		} pci;
-		/** Used if type is RTE_DEVTYPE_VIRTUAL. */
-		struct {
-			/** Driver name. */
-			char drv_name[32];
-		} virt;
-	};
 	/** Bus handle for the device. */
 	struct rte_bus *bus;
+	/** Name of the device. */
+	char name[32];
 	/** Arguments string as given by user or "" for no argument. */
 	char *args;
 };
lib/librte_eal/common/include/rte_vdev.h +1 -1
index e6b678e..3c07b76 100644
@@ -50,7 +50,7 @@ static inline const char *
 rte_vdev_device_name(const struct rte_vdev_device *dev)
 {
 	if (dev && dev->device.devargs)
-		return dev->device.devargs->virt.drv_name;
+		return dev->device.devargs->name;
 	return NULL;
 }
 
test/test/test_devargs.c +3 -6
index 63242f1..18f54ed 100644
@@ -90,8 +90,8 @@ test_devargs(void)
 	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,k1=val,k2=val2") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
-	if (strncmp(devargs->virt.drv_name, "net_ring1",
-			sizeof(devargs->virt.drv_name)) != 0)
+	if (strncmp(devargs->name, "net_ring1",
+			sizeof(devargs->name)) != 0)
 		goto fail;
 	if (!devargs->args || strcmp(devargs->args, "k1=val,k2=val2") != 0)
 		goto fail;
@@ -101,10 +101,7 @@ test_devargs(void)
 	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "04:00.1") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
-	if (devargs->pci.addr.domain != 0 ||
-		devargs->pci.addr.bus != 4 ||
-		devargs->pci.addr.devid != 0 ||
-		devargs->pci.addr.function != 1)
+	if (strcmp(devargs->name, "04:00.1") != 0)
 		goto fail;
 	if (!devargs->args || strcmp(devargs->args, "") != 0)
 		goto fail;
Signature · 1 line
2.1.4
#108 lore raw

PATCH v6 13/19 pci: update device name

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_pci.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_eal/common/eal_common_pci.c +1 -0
index 5838cc6..fa9f1b6 100644
@@ -328,6 +328,7 @@ rte_pci_probe_one(const struct rte_pci_addr *addr)
 		ret = pci_probe_all_drivers(dev);
 		if (ret)
 			goto err_return;
+		dev->device.name = dev->device.devargs->name;
 		return 0;
 	}
 	return -1;
Signature · 1 line
2.1.4
#109 lore raw

PATCH v6 14/19 net/virtio: do not reference device type

In reply to Gaetan Rivet
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
index b7b3d61..6275359 100644
@@ -38,6 +38,7 @@
 #endif
 
 #include <rte_io.h>
+#include <rte_bus.h>
 
 #include "virtio_pci.h"
 #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
 	if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
 		    (!dev->device.devargs ||
-		     dev->device.devargs->type !=
-			RTE_DEVTYPE_WHITELISTED_PCI)) {
+		     dev->device.devargs->bus !=
+		     rte_bus_find_by_name("PCI"))) {
 			PMD_INIT_LOG(INFO,
 				"skip kernel managed virtio device.");
 			return 1;
Signature · 1 line
2.1.4
#110 lore raw

Re: [PATCH v6 14/19] net/virtio: do not reference device type

Quoted 18 lines · Gaetan Rivet
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +1 -0
index b7b3d61..6275359 100644
@@ -38,6 +38,7 @@
 #endif
 
 #include <rte_io.h>
+#include <rte_bus.h>
 
 #include "virtio_pci.h"
 #include "virtio_logs.h"

drivers/net/virtio/virtio_pci.c vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw) · line 689

Quoted 7 lines
drivers/net/virtio/virtio_pci.c +2 -2
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
 	if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
 		    (!dev->device.devargs ||
-		     dev->device.devargs->type !=
-			RTE_DEVTYPE_WHITELISTED_PCI)) {
+		     dev->device.devargs->bus !=
+		     rte_bus_find_by_name("PCI"))) {

Ah, this is the first, won't be last error of this type. It should be "pci" instead.

Incidentally, it could be preferable to use
rte_bus_find_by_device(&dev->device) instead.

Quoted 6 lines
drivers/net/virtio/virtio_pci.c +0 -0
 			PMD_INIT_LOG(INFO,
 				"skip kernel managed virtio device.");
 			return 1;
Signature · 1 line
2.1.4
Signature · 2 lines
Gaëtan Rivet
6WIND
#111 lore raw

PATCH v6 15/19 devargs: generic device types

In reply to Gaetan Rivet

rte_devargs now represents any device from any bus.
The related devtypes do not identify a bus anymore, only which scan policy the device subscribes to.

The bus itself is identified by a bus handle previously introduced.

---
 lib/librte_eal/common/eal_common_devargs.c  |  4 ++--
 lib/librte_eal/common/eal_common_options.c  | 13 +++--------
 lib/librte_eal/common/eal_common_pci.c      |  6 ++---
 lib/librte_eal/common/eal_common_vdev.c     |  1 -
 lib/librte_eal/common/include/rte_devargs.h |  6 ++---
 test/test/test_devargs.c                    | 36 +++++++++++++++--------------
 6 files changed, 30 insertions(+), 36 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
index 7b4dfca..8fe1b39 100644
@@ -129,14 +129,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", devname);
 	if (ret < 0 || ret >= (int)sizeof(devargs->name))
 		goto fail;
-	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
 			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
 			goto fail;
 		}
-	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
lib/librte_eal/common/eal_common_options.c +3 -10
index f470195..075b0ea 100644
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,
 	switch (opt) {
 	/* blacklist */
 	case 'b':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED,
 				optarg) < 0) {
 			return -1;
 		}
 		break;
 	/* whitelist */
 	case 'w':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 
 	case OPT_VDEV_NUM:
-		if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)
 		return -1;
 	}
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
-		rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
-		RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
-			"cannot be used at the same time\n");
-		return -1;
-	}
-
 	return 0;
 }
 
lib/librte_eal/common/eal_common_pci.c +3 -3
index fa9f1b6..b8d902b 100644
@@ -198,7 +198,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 	/* no initialization when blacklisted, return without error */
 	if (dev->device.devargs != NULL &&
 		dev->device.devargs->type ==
-			RTE_DEVTYPE_BLACKLISTED_PCI) {
+			RTE_DEVTYPE_BLACKLISTED) {
 		RTE_LOG(INFO, EAL, "  Device is blacklisted, not"
 			" initializing\n");
 		return 1;
@@ -391,7 +391,7 @@ rte_pci_probe(void)
 	int probe_all = 0;
 	int ret = 0;
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
+	if (rte_pci_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST)
 		probe_all = 1;
 
 	FOREACH_DEVICE_ON_PCIBUS(dev) {
@@ -406,7 +406,7 @@ rte_pci_probe(void)
 		if (probe_all)
 			ret = pci_probe_all_drivers(dev);
 		else if (devargs != NULL &&
-			devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
+			devargs->type == RTE_DEVTYPE_WHITELISTED)
 			ret = pci_probe_all_drivers(dev);
 		if (ret < 0) {
 			RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
index 639ef73..517a9f3 100644
@@ -176,7 +176,6 @@ alloc_devargs(const char *name, const char *args)
 	if (!devargs)
 		return NULL;
 
-	devargs->type = RTE_DEVTYPE_VIRTUAL;
 	devargs->bus = rte_bus_find_by_name("vdev");
 	if (args)
 		devargs->args = strdup(args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
index 6a26d3d..6e9e134 100644
@@ -56,9 +56,9 @@ extern "C" {
  * Type of generic device
  */
 enum rte_devtype {
-	RTE_DEVTYPE_WHITELISTED_PCI,
-	RTE_DEVTYPE_BLACKLISTED_PCI,
-	RTE_DEVTYPE_VIRTUAL,
+	RTE_DEVTYPE_UNDEFINED,
+	RTE_DEVTYPE_WHITELISTED,
+	RTE_DEVTYPE_BLACKLISTED,
 };
 
 /**
test/test/test_devargs.c +19 -17
index 18f54ed..149c9c9 100644
@@ -64,30 +64,32 @@ test_devargs(void)
 	TAILQ_INIT(&devargs_list);
 
 	/* test valid cases */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "08:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "08:00.1") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "0000:5:00.0") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "0000:5:00.0") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0,arg=val") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "04:00.0,arg=val") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "0000:01:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "0000:01:00.1") < 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED) != 4)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED) != 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 0)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_UNDEFINED) != 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring0") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED, "net_ring0") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,key=val,k2=val2") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
+				"net_ring1,key=val,k2=val2") < 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_UNDEFINED) != 2)
 		goto fail;
 	free_devargs_list();
 
 	/* check virtual device with argument parsing */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,k1=val,k2=val2") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
+				"net_ring1,k1=val,k2=val2") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
 	if (strncmp(devargs->name, "net_ring1",
@@ -98,7 +100,7 @@ test_devargs(void)
 	free_devargs_list();
 
 	/* check PCI device with empty argument parsing */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "04:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "04:00.1") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
 	if (strcmp(devargs->name, "04:00.1") != 0)
@@ -108,15 +110,15 @@ test_devargs(void)
 	free_devargs_list();
 
 	/* test error case: bad PCI address */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "08:1") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "08:1") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "00.1") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "00.1") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "foo") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "foo") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, ",") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, ",") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "000f:0:0") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "000f:0:0") == 0)
 		goto fail;
 
 	devargs_list = save_devargs_list;
Signature · 1 line
2.1.4
#112 lore raw

PATCH v6 16/19 devargs: introduce cleaner parsing helper

In reply to Gaetan Rivet

Introduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.

The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.

A deprecation notice is issued.

This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.

---
 doc/guides/rel_notes/deprecation.rst            |  5 ++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_devargs.c      | 78 ++++++++++++++++---------
 lib/librte_eal/common/include/rte_devargs.h     | 20 +++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 5 files changed, 79 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index 2e708db..56d0698 100644
@@ -95,3 +95,8 @@ Deprecation Notices
   The non-"do-sig" versions of the hash tables will be removed
   (including the ``signature_offset`` parameter)
   and the "do-sig" versions renamed accordingly.
+
+* eal: the following function is deprecated starting from 17.08 and will
+  be removed in 17.11:
+
+  - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index 0295ea9..cec3894 100644
@@ -200,6 +200,7 @@ DPDK_17.08 {
 	rte_bus_find;
 	rte_bus_find_by_device;
 	rte_bus_find_by_name;
+	rte_eal_devargs_parse;
 
 } DPDK_17.05;
 
lib/librte_eal/common/eal_common_devargs.c +52 -26

113 lines not on this page · raw message

lib/librte_eal/common/include/rte_devargs.h +20 -0
index 6e9e134..2ab8864 100644
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
 /**
+ * Parse a device string.
+ *
+ * Verify that a bus is capable of handling the device passed
+ * in argument. Store which bus will handle the device, its name
+ * and the eventual device parameters.
+ *
+ * @param dev
+ *   The device declaration string.
+ * @param da
+ *   The devargs structure holding the device information.
+ *
+ * @return
+ *   - 0 on success.
+ *   - Negative errno on error.
+ */
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);
+
+/**
  * Add a device to the user device list
  *
  * For PCI devices, the format of arguments string is "PCI_ADDR" or
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
index a118fb1..09b875a 100644
@@ -205,6 +205,7 @@ DPDK_17.08 {
 	rte_bus_find;
 	rte_bus_find_by_device;
 	rte_bus_find_by_name;
+	rte_eal_devargs_parse;
 
 } DPDK_17.05;
 
Signature · 1 line
2.1.4
#113 lore raw

PATCH v6 17/19 devargs: clone function

In reply to Gaetan Rivet

This function returns a deep copy of an rte_devargs.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_devargs.c      | 19 +++++++++++++++++++
 lib/librte_eal/common/include/rte_devargs.h     | 12 ++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 4 files changed, 33 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index cec3894..05e2475 100644
@@ -200,6 +200,7 @@ DPDK_17.08 {
 	rte_bus_find;
 	rte_bus_find_by_device;
 	rte_bus_find_by_name;
+	rte_eal_devargs_clone;
 	rte_eal_devargs_parse;
 
 } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +19 -0
index 3ea070d..be8951d 100644
@@ -185,6 +185,25 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	return -1;
 }
 
+/* Deep-copy of an rte_devargs. */
+struct rte_devargs *
+rte_eal_devargs_clone(struct rte_devargs *da)
+{
+	struct rte_devargs *clone;
+
+	clone = calloc(1, sizeof(*clone));
+	if (clone == NULL)
+		return NULL;
+	snprintf(clone->name, sizeof(clone->name), "%s", da->name);
+	clone->args = strdup(da->args ? da->args : "");
+	clone->bus = da->bus;
+	if (clone->args == NULL) {
+		free(clone);
+		return NULL;
+	}
+	return clone;
+}
+
 /* count the number of devices of a specified type */
 unsigned int
 rte_eal_devargs_type_count(enum rte_devtype devtype)
lib/librte_eal/common/include/rte_devargs.h +12 -0
index 2ab8864..892b035 100644
@@ -163,6 +163,18 @@ rte_eal_devargs_parse(const char *dev,
 int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str);
 
 /**
+ * Deep copy an rte_devargs.
+ *
+ * @param da
+ *   Source devargs.
+ *
+ * @return
+ *   The pointer to the new rte_devargs on success.
+ *   NULL on error.
+ */
+struct rte_devargs *rte_eal_devargs_clone(struct rte_devargs *da);
+
+/**
  * Count the number of user devices of a specified type
  *
  * @param devtype
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
index 09b875a..e9ae497 100644
@@ -205,6 +205,7 @@ DPDK_17.08 {
 	rte_bus_find;
 	rte_bus_find_by_device;
 	rte_bus_find_by_name;
+	rte_eal_devargs_clone;
 	rte_eal_devargs_parse;
 
 } DPDK_17.05;
Signature · 1 line
2.1.4
#114 lore raw

PATCH v6 18/19 devargs: remove function

In reply to Gaetan Rivet

Hotplug support introduces the possibility of removing devices from the system. Allocated resources must be freed.

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_devargs.c      | 19 +++++++++++++++++++
 lib/librte_eal/common/include/rte_devargs.h     | 14 ++++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 4 files changed, 35 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index 05e2475..299b27f 100644
@@ -202,6 +202,7 @@ DPDK_17.08 {
 	rte_bus_find_by_name;
 	rte_eal_devargs_clone;
 	rte_eal_devargs_parse;
+	rte_eal_devargs_rmv;
 
 } DPDK_17.05;
 
lib/librte_eal/common/eal_common_devargs.c +19 -0
index be8951d..7388122 100644
@@ -41,6 +41,7 @@
 #include <string.h>
 
 #include <rte_devargs.h>
+#include <rte_tailq.h>
 #include "eal_private.h"
 
 /** Global list of user devices */
@@ -185,6 +186,24 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	return -1;
 }
 
+/* Remove and free an rte_devargs. */
+int
+rte_eal_devargs_rmv(struct rte_devargs *da)
+{
+	struct rte_devargs *d;
+	void *tmp;
+
+	TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) {
+		if (d == da) {
+			TAILQ_REMOVE(&devargs_list, d, next);
+			free(d->args);
+			free(d);
+			return 0;
+		}
+	}
+	return 1;
+}
+
 /* Deep-copy of an rte_devargs. */
 struct rte_devargs *
 rte_eal_devargs_clone(struct rte_devargs *da)
lib/librte_eal/common/include/rte_devargs.h +14 -0
index 892b035..f61707c 100644
@@ -163,6 +163,20 @@ rte_eal_devargs_parse(const char *dev,
 int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str);
 
 /**
+ * Remove a device from the user device list.
+ * The devargs is then freed.
+ *
+ * @param da
+ *   devargs to remove.
+ *
+ * @return
+ *   0 on success.
+ *   <0 on error.
+ *   >0 if the devargs was not within the user device list.
+ */
+int rte_eal_devargs_rmv(struct rte_devargs *da);
+
+/**
  * Deep copy an rte_devargs.
  *
  * @param da
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
index e9ae497..6d73e0e 100644
@@ -207,6 +207,7 @@ DPDK_17.08 {
 	rte_bus_find_by_name;
 	rte_eal_devargs_clone;
 	rte_eal_devargs_parse;
+	rte_eal_devargs_rmv;
 
 } DPDK_17.05;
 
Signature · 1 line
2.1.4
#115 lore raw

PATCH v6 19/19 eal: change whitelist / blacklist command line doc

In reply to Gaetan Rivet

The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.

Update the source code accordingly.

---
 lib/librte_eal/common/eal_common_options.c | 18 +++++++++---------
 lib/librte_eal/common/eal_options.h        |  8 ++++----
 2 files changed, 13 insertions(+), 13 deletions(-)
lib/librte_eal/common/eal_common_options.c +9 -9
index 075b0ea..245a276 100644
@@ -86,8 +86,8 @@ eal_long_options[] = {
 	{OPT_NO_HUGE,           0, NULL, OPT_NO_HUGE_NUM          },
 	{OPT_NO_PCI,            0, NULL, OPT_NO_PCI_NUM           },
 	{OPT_NO_SHCONF,         0, NULL, OPT_NO_SHCONF_NUM        },
-	{OPT_PCI_BLACKLIST,     1, NULL, OPT_PCI_BLACKLIST_NUM    },
-	{OPT_PCI_WHITELIST,     1, NULL, OPT_PCI_WHITELIST_NUM    },
+	{OPT_BUS_BLACKLIST,     1, NULL, OPT_BUS_BLACKLIST_NUM    },
+	{OPT_BUS_WHITELIST,     1, NULL, OPT_BUS_WHITELIST_NUM    },
 	{OPT_PROC_TYPE,         1, NULL, OPT_PROC_TYPE_NUM        },
 	{OPT_SOCKET_MEM,        1, NULL, OPT_SOCKET_MEM_NUM       },
 	{OPT_SYSLOG,            1, NULL, OPT_SYSLOG_NUM           },
@@ -1049,14 +1049,14 @@ eal_common_usage(void)
 	       "  -n CHANNELS         Number of memory channels\n"
 	       "  -m MB               Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
 	       "  -r RANKS            Force number of memory ranks (don't detect)\n"
-	       "  -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
-	       "                      Prevent EAL from using this PCI device. The argument\n"
-	       "                      format is <domain:bus:devid.func>.\n"
-	       "  -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
-	       "                      Only use the specified PCI devices. The argument format\n"
-	       "                      is <[domain:]bus:devid.func>. This option can be present\n"
+	       "  -b, --"OPT_BUS_BLACKLIST" Black list a device on its bus.\n"
+	       "                      Prevents EAL from using this device. The argument\n"
+	       "                      format depends on the bus.\n"
+	       "  -w, --"OPT_BUS_WHITELIST" White list a device on its bus.\n"
+	       "                      Only use the specified devices. The argument format\n"
+	       "                      depends on the bus. This option can be present\n"
 	       "                      several times (once per device).\n"
-	       "                      [NOTE: PCI whitelist cannot be used with -b option]\n"
+	       "                      [NOTE: whitelist cannot be used with -b option]\n"
 	       "  --"OPT_VDEV"              Add a virtual device.\n"
 	       "                      The argument format is <driver><id>[,key=val,...]\n"
 	       "                      (ex: --vdev=net_pcap0,iface=eth2).\n"
lib/librte_eal/common/eal_options.h +4 -4
index a881c62..4c5db07 100644
@@ -37,10 +37,10 @@ enum {
 	/* long options mapped to a short option */
 #define OPT_HELP              "help"
 	OPT_HELP_NUM            = 'h',
-#define OPT_PCI_BLACKLIST     "pci-blacklist"
-	OPT_PCI_BLACKLIST_NUM   = 'b',
-#define OPT_PCI_WHITELIST     "pci-whitelist"
-	OPT_PCI_WHITELIST_NUM   = 'w',
+#define OPT_BUS_BLACKLIST     "bus-blacklist"
+	OPT_BUS_BLACKLIST_NUM   = 'b',
+#define OPT_BUS_WHITELIST     "bus-whitelist"
+	OPT_BUS_WHITELIST_NUM   = 'w',
 
 	/* first long only option value must be >= 256, so that we won't
 	 * conflict with short options */
Signature · 1 line
2.1.4
#116 lore raw

Re: [PATCH v6 19/19] eal: change whitelist / blacklist command line doc

05/07/2017 01:56, Gaetan Rivet:

Quoted 6 lines

The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.

Update the source code accordingly.

You forgot the ack from John.

Acked-by on v6 19/19
#117 lore raw

Re: [PATCH v6 19/19] eal: change whitelist / blacklist command line doc

In reply to Gaetan Rivet
Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Wednesday, July 5, 2017 12:57 AM
To: [email protected]
Cc: Gaetan Rivet <[email protected]>
Subject: [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc

Quoted 6 lines

The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.

Update the source code accordingly.

#118 lore raw
In reply to Gaetan Rivet
Quoted 12 lines

Gaetan Rivet (19):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies

Quoted 8 lines

devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc

You forgot my patch "examples/ethtool: explicit PCI header dependency"

#119 lore raw

Hi Thomas,

Quoted 21 lines · Thomas Monjalon
Quoted 12 lines

Gaetan Rivet (19):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies

Quoted 8 lines

devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc

Quoted 2 lines

You forgot my patch "examples/ethtool: explicit PCI header dependency"

Indeed sorry, I missed a few things it seems.

Signature · 2 lines
Gaëtan Rivet
6WIND
#120 lore raw

v7 cover Generic devargs parsing

In reply to Gaetan Rivet

The second part of the work outlined in [1] and [2]. The first part is at [3].

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.

Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.

With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.

Buses needs only to implement the "parse" method for their devices to be declared in this way.

[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html

This patchset depends on:

[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/

v1 -> v2:

* fix PCI whitelist mode

v2 -> v3:

* Rebase the series on the new plug / unplug API

v3 -> v4:

* Fix rte_devargs parsing helper
* Introduce new rte_devargs clone function
* Introduce new rte_devargs release function
* Fix test application for rte_devargs.
TODO: rewrite complete rte_devargs autotest.
* Fix a few rte_pci references.
* Update EAL command line help for -w / -b

v5:

* Fix integration issue with new arbitrary bus name parsing.

v6:

* Follow new hotplug & parse API
* Export rte_eal_devargs_parse symbol
* Improve the devargs parsing in regard to possible bus / dev naming ambiguities.
* A few code style issues fixed.
* The EAL dependency on vdev is not fixed anymore It is beyond the scope of this patchset.

v7:

* Remembered to include the example/ethtool
header fix.
* Use new RTE_DEV_NAME_MAX_LEN macro to define rte_devargs name field len.
* Fix virtio reference to old "PCI" bus name.
* rte_eal_devargs_parse is now set as EXPERIMENTAL
* Previous rte_devargs API extensions (clone, removal) are removed from this patchset. They will be introduced when needed.

Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc

Thomas Monjalon (1):
examples/ethtool: properly reference PCI header

 app/test-pmd/testpmd.c                          |   9 +-
 app/test-pmd/testpmd.h                          |   2 +
 doc/guides/rel_notes/deprecation.rst            |   5 +
 drivers/net/bnxt/bnxt.h                         |   1 +
 drivers/net/bonding/rte_eth_bond_args.c         |   1 +
 drivers/net/e1000/e1000_ethdev.h                |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.h                |   1 +
 drivers/net/mlx5/mlx5.h                         |   1 +
 drivers/net/sfc/sfc.h                           |   1 +
 drivers/net/virtio/virtio_pci.c                 |   5 +-
 examples/ethtool/lib/rte_ethtool.c              |   2 +
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   1 +
 lib/librte_eal/common/eal_common_devargs.c      | 128 +++++++++++++-----------
 lib/librte_eal/common/eal_common_options.c      |  31 +++---
 lib/librte_eal/common/eal_common_pci.c          |  15 +--
 lib/librte_eal/common/eal_common_vdev.c         |  12 +--
 lib/librte_eal/common/eal_options.h             |   8 +-
 lib/librte_eal/common/include/rte_bus.h         |  17 ++++
 lib/librte_eal/common/include/rte_dev.h         |  12 +++
 lib/librte_eal/common/include/rte_devargs.h     |  42 ++++----
 lib/librte_eal/common/include/rte_pci.h         |   9 --
 lib/librte_eal/common/include/rte_vdev.h        |   2 +-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   1 +
 test/test/test_devargs.c                        |  45 ++++-----
 test/test/virtual_pmd.c                         |   1 +
 25 files changed, 198 insertions(+), 155 deletions(-)
Signature · 1 line
2.1.4
#121 lore raw

PATCH v7 1/17 net/bonding: properly reference PCI header

---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
index a422eb8..4f12050 100644
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
Signature · 1 line
2.1.4
#122 lore raw

PATCH v7 2/17 net/bnxt: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
index 1538aa5..07279f7 100644
@@ -38,6 +38,7 @@
 #include <stdbool.h>
 #include <sys/queue.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_memory.h>
 #include <rte_lcore.h>
Signature · 1 line
2.1.4
#123 lore raw

PATCH v7 3/17 net/mlx5: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
index 1148dee..9ef2c11 100644
@@ -54,6 +54,7 @@
 #ifdef PEDANTIC
 #pragma GCC diagnostic ignored "-Wpedantic"
 #endif
+#include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#124 lore raw

PATCH v7 4/17 net/e1000: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
index 9266540..3f521a7 100644
@@ -34,6 +34,7 @@
 #ifndef _E1000_ETHDEV_H_
 #define _E1000_ETHDEV_H_
 #include <rte_time.h>
+#include <rte_pci.h>
 
 #define E1000_INTEL_VENDOR_ID 0x8086
 
Signature · 1 line
2.1.4
#125 lore raw

PATCH v7 5/17 net/ixgbe: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
index 10b9967..bcbd62d 100644
@@ -39,6 +39,7 @@
 #include "ixgbe_bypass.h"
 #include <rte_time.h>
 #include <rte_hash.h>
+#include <rte_pci.h>
 
 /* need update link, bit flag */
 #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
#126 lore raw

PATCH v7 6/17 net/sfc: properly reference PCI header

In reply to Gaetan Rivet
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
index 007ed24..41dff48 100644
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
Signature · 1 line
2.1.4
#127 lore raw

PATCH v7 7/17 app/testpmd: properly reference PCI header

In reply to Gaetan Rivet
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
index 5cabeef..9cc313e 100644
@@ -34,6 +34,8 @@
 #ifndef _TESTPMD_H_
 #define _TESTPMD_H_
 
+#include <rte_pci.h>
+
 #define RTE_PORT_ALL            (~(portid_t)0x0)
 
 #define RTE_TEST_RX_DESC_MAX    2048
Signature · 1 line
2.1.4
#128 lore raw

PATCH v7 8/17 test: properly reference PCI header

In reply to Gaetan Rivet
---
 test/test/virtual_pmd.c | 1 +
 1 file changed, 1 insertion(+)
test/test/virtual_pmd.c +1 -0
index db99894..8e698bc 100644
@@ -33,6 +33,7 @@
 
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
+#include <rte_pci.h>
 #include <rte_malloc.h>
 #include <rte_memcpy.h>
 #include <rte_memory.h>
Signature · 1 line
2.1.4
#129 lore raw

PATCH v7 9/17 examples/ethtool: properly reference PCI header

In reply to Gaetan Rivet

From: Thomas Monjalon <[email protected]>

In devargs rework, rte_pci.h won't be included by rte_ethdev.h (via rte_devargs.h) anymore.

rte_ethtool_get_drvinfo() could use rte_devargs.name instead of creating equivalent bus specific name.
For now, it is workarounded by just including rte_pci.h.

---
 examples/ethtool/lib/rte_ethtool.c | 2 ++
 1 file changed, 2 insertions(+)
examples/ethtool/lib/rte_ethtool.c +2 -0
index fabfcb2..252382c 100644
@@ -36,6 +36,7 @@
 #include <rte_version.h>
 #include <rte_ethdev.h>
 #include <rte_ether.h>
+#include <rte_pci.h>
 #ifdef RTE_LIBRTE_IXGBE_PMD
 #include <rte_pmd_ixgbe.h>
 #endif
@@ -73,6 +74,7 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo)
 		dev_info.driver_name);
 	snprintf(drvinfo->version, sizeof(drvinfo->version), "%s",
 		rte_version());
+	/* TODO: replace bus_info by rte_devargs.name */
 	if (dev_info.pci_dev)
 		snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
 			"%04x:%02x:%02x.%x",
Signature · 1 line
2.1.4
#130 lore raw

PATCH v7 10/17 dev: device kernel module is a device attribute

In reply to Gaetan Rivet

It is used in generic device structures and must not be tied to a bus.

---
 lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++
 lib/librte_eal/common/include/rte_pci.h |  9 ---------
 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
index 0c8f6c8..bcd8b1e 100644
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 } while (0)
 
 /**
+ * Device driver.
+ */
+enum rte_kernel_driver {
+	RTE_KDRV_UNKNOWN = 0,
+	RTE_KDRV_IGB_UIO,
+	RTE_KDRV_VFIO,
+	RTE_KDRV_UIO_GENERIC,
+	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
+};
+
+/**
  * A generic memory resource representation.
  */
 struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
index 406d918..8b12339 100644
@@ -117,15 +117,6 @@ struct rte_pci_addr {
 
 struct rte_devargs;
 
-enum rte_kernel_driver {
-	RTE_KDRV_UNKNOWN = 0,
-	RTE_KDRV_IGB_UIO,
-	RTE_KDRV_VFIO,
-	RTE_KDRV_UIO_GENERIC,
-	RTE_KDRV_NIC_UIO,
-	RTE_KDRV_NONE,
-};
-
 /**
  * A structure describing a PCI device.
  */
Signature · 1 line
2.1.4
#131 lore raw

PATCH v7 11/17 bus: introduce bus scan policies

In reply to Gaetan Rivet

Scan policies describe the way a bus should scan the system to search for possible devices.

Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices

---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
index aebf57e..37cc230 100644
@@ -158,6 +158,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
 typedef int (*rte_bus_parse_t)(const char *name, void *addr);
 
 /**
+ * Bus scan policies
+ */
+enum rte_bus_scan_mode {
+	RTE_BUS_SCAN_UNDEFINED,
+	RTE_BUS_SCAN_WHITELIST,
+	RTE_BUS_SCAN_BLACKLIST,
+};
+
+/**
+ * A structure used to configure bus operations.
+ */
+struct rte_bus_conf {
+	enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
+};
+
+/**
  * A structure describing a generic bus.
  */
 struct rte_bus {
@@ -169,6 +185,7 @@ struct rte_bus {
 	rte_bus_plug_t plug;         /**< Probe single device for drivers */
 	rte_bus_unplug_t unplug;     /**< Remove single device from driver */
 	rte_bus_parse_t parse;       /**< Parse a device name */
+	struct rte_bus_conf conf;    /**< Bus configuration */
 };
 
 /**
Signature · 1 line
2.1.4
#132 lore raw

PATCH v7 12/17 devargs: parse bus policies

In reply to Gaetan Rivet
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
index 102bd8d..16052a3 100644
@@ -143,6 +143,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 
 		break;
 	}
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	}
 
 	free(dev);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
Signature · 1 line
2.1.4
#133 lore raw

Re: [PATCH v7 12/17] devargs: parse bus policies

Hi,

I think there is a real bug to fix in 17.08-rc2.
More details below. Proposals are welcome.

07/07/2017 02:04, Gaetan Rivet:

Quoted 11 lines
lib/librte_eal/common/eal_common_devargs.c +5 -0
@@ -143,6 +143,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 
 		break;
 	}
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");

lib/librte_eal/common/eal_common_devargs.c rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) · line 160

Quoted 10 lines
lib/librte_eal/common/eal_common_devargs.c +10 -0
+			goto fail;
+		}
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
+			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
+		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
+			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
+			goto fail;
+		}
+	}

After another look, there is something wrong here.
You are checking a probe policy (wrongly named scan_mode), in a function which can be not related at all with bus probing.

Example with failsafe:
1/ We blacklist a device for the global EAL probe.
So the probing mode is set from "undefined" to "blacklist". 2/ We add the device as a failsafe slave.
3/ The device must be plugged, no matter of the probe policy. But it is seen as a whitelist and rejected because the bus probing is in blacklist mode.

I think it is a serious bug.

PS: thanks Matan for having checked it

#134 lore raw

PATCH v7 13/17 devargs: generic device representation

In reply to Gaetan Rivet

Remove the dependency of this subsystem upon bus specific device representation.

Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.

---
 app/test-pmd/testpmd.c                      |  9 +-----
 lib/librte_eal/common/eal_common_devargs.c  | 47 +++++------------------------
 lib/librte_eal/common/eal_common_pci.c      |  9 ++++--
 lib/librte_eal/common/eal_common_vdev.c     | 11 +++----
 lib/librte_eal/common/include/rte_devargs.h | 16 ++--------
 lib/librte_eal/common/include/rte_vdev.h    |  2 +-
 test/test/test_devargs.c                    |  9 ++----
 7 files changed, 26 insertions(+), 77 deletions(-)
app/test-pmd/testpmd.c +1 -8
index a7bad73..bce3ecd 100644
@@ -1810,21 +1810,14 @@ static void
 rmv_event_callback(void *arg)
 {
 	struct rte_eth_dev *dev;
-	struct rte_devargs *da;
-	char name[32] = "";
 	uint8_t port_id = (intptr_t)arg;
 
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
-	da = dev->device->devargs;
 
 	stop_port(port_id);
 	close_port(port_id);
-	if (da->type == RTE_DEVTYPE_VIRTUAL)
-		snprintf(name, sizeof(name), "%s", da->virt.drv_name);
-	else if (da->type == RTE_DEVTYPE_WHITELISTED_PCI)
-		rte_pci_device_name(&da->pci.addr, name, sizeof(name));
-	printf("removing device %s\n", name);
+	printf("removing device %s\n", dev->device->name);
 	rte_eal_dev_detach(dev->device);
 	dev->state = RTE_ETH_DEV_UNUSED;
 }
lib/librte_eal/common/eal_common_devargs.c +8 -39

65 lines not on this page · raw message

lib/librte_eal/common/eal_common_pci.c +6 -3
index d7e2fb4..5838cc6 100644
@@ -74,12 +74,15 @@ const char *pci_get_sysfs_path(void)
 static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 {
 	struct rte_devargs *devargs;
+	struct rte_pci_addr addr;
+	struct rte_bus *pbus;
 
+	pbus = rte_bus_find_by_name("pci");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type != RTE_DEVTYPE_BLACKLISTED_PCI &&
-			devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)
+		if (devargs->bus != pbus)
 			continue;
-		if (!rte_eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))
+		devargs->bus->parse(devargs->name, &addr);
+		if (!rte_eal_compare_pci_addr(&dev->addr, &addr))
 			return devargs;
 	}
 	return NULL;
lib/librte_eal/common/eal_common_vdev.c +5 -6
index 8fd1ef7..639ef73 100644
@@ -181,9 +181,8 @@ alloc_devargs(const char *name, const char *args)
 	if (args)
 		devargs->args = strdup(args);
 
-	ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", name);
-	if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name)) {
+	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", name);
+	if (ret < 0 || ret >= (int)sizeof(devargs->name)) {
 		free(devargs->args);
 		free(devargs);
 		return NULL;
@@ -218,7 +217,7 @@ rte_vdev_init(const char *name, const char *args)
 
 	dev->device.devargs = devargs;
 	dev->device.numa_node = SOCKET_ID_ANY;
-	dev->device.name = devargs->virt.drv_name;
+	dev->device.name = devargs->name;
 
 	ret = vdev_probe_all_drivers(dev);
 	if (ret) {
@@ -299,7 +298,7 @@ vdev_scan(void)
 		if (devargs->bus != vbus)
 			continue;
 
-		dev = find_vdev(devargs->virt.drv_name);
+		dev = find_vdev(devargs->name);
 		if (dev)
 			continue;
 
@@ -309,7 +308,7 @@ vdev_scan(void)
 
 		dev->device.devargs = devargs;
 		dev->device.numa_node = SOCKET_ID_ANY;
-		dev->device.name = devargs->virt.drv_name;
+		dev->device.name = devargs->name;
 
 		TAILQ_INSERT_TAIL(&vdev_device_list, dev, next);
 	}
lib/librte_eal/common/include/rte_devargs.h +2 -14
index 6014853..35675fa 100644
@@ -50,7 +50,6 @@ extern "C" {
 
 #include <stdio.h>
 #include <sys/queue.h>
-#include <rte_pci.h>
 #include <rte_bus.h>
 
 /**
@@ -77,21 +76,10 @@ struct rte_devargs {
 	TAILQ_ENTRY(rte_devargs) next;
 	/** Type of device. */
 	enum rte_devtype type;
-	RTE_STD_C11
-	union {
-		/** Used if type is RTE_DEVTYPE_*_PCI. */
-		struct {
-			/** PCI location. */
-			struct rte_pci_addr addr;
-		} pci;
-		/** Used if type is RTE_DEVTYPE_VIRTUAL. */
-		struct {
-			/** Driver name. */
-			char drv_name[RTE_DEV_NAME_MAX_LEN];
-		} virt;
-	};
 	/** Bus handle for the device. */
 	struct rte_bus *bus;
+	/** Name of the device. */
+	char name[RTE_DEV_NAME_MAX_LEN];
 	/** Arguments string as given by user or "" for no argument. */
 	char *args;
 };
lib/librte_eal/common/include/rte_vdev.h +1 -1
index e6b678e..3c07b76 100644
@@ -50,7 +50,7 @@ static inline const char *
 rte_vdev_device_name(const struct rte_vdev_device *dev)
 {
 	if (dev && dev->device.devargs)
-		return dev->device.devargs->virt.drv_name;
+		return dev->device.devargs->name;
 	return NULL;
 }
 
test/test/test_devargs.c +3 -6
index 63242f1..18f54ed 100644
@@ -90,8 +90,8 @@ test_devargs(void)
 	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,k1=val,k2=val2") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
-	if (strncmp(devargs->virt.drv_name, "net_ring1",
-			sizeof(devargs->virt.drv_name)) != 0)
+	if (strncmp(devargs->name, "net_ring1",
+			sizeof(devargs->name)) != 0)
 		goto fail;
 	if (!devargs->args || strcmp(devargs->args, "k1=val,k2=val2") != 0)
 		goto fail;
@@ -101,10 +101,7 @@ test_devargs(void)
 	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "04:00.1") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
-	if (devargs->pci.addr.domain != 0 ||
-		devargs->pci.addr.bus != 4 ||
-		devargs->pci.addr.devid != 0 ||
-		devargs->pci.addr.function != 1)
+	if (strcmp(devargs->name, "04:00.1") != 0)
 		goto fail;
 	if (!devargs->args || strcmp(devargs->args, "") != 0)
 		goto fail;
Signature · 1 line
2.1.4
#135 lore raw

PATCH v7 14/17 net/virtio: do not reference device type

In reply to Gaetan Rivet
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
index b7b3d61..e6eda75 100644
@@ -38,6 +38,7 @@
 #endif
 
 #include <rte_io.h>
+#include <rte_bus.h>
 
 #include "virtio_pci.h"
 #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
 	if (rte_pci_ioport_map(dev, 0, VTPCI_IO(hw)) < 0) {
 		if (dev->kdrv == RTE_KDRV_UNKNOWN &&
 		    (!dev->device.devargs ||
-		     dev->device.devargs->type !=
-			RTE_DEVTYPE_WHITELISTED_PCI)) {
+		     dev->device.devargs->bus !=
+		     rte_bus_find_by_name("pci"))) {
 			PMD_INIT_LOG(INFO,
 				"skip kernel managed virtio device.");
 			return 1;
Signature · 1 line
2.1.4
#136 lore raw

PATCH v7 15/17 devargs: generic device types

In reply to Gaetan Rivet

rte_devargs now represents any device from any bus.
The related devtypes do not identify a bus anymore, only which scan policy the device subscribes to.

The bus itself is identified by a bus handle previously introduced.

---
 lib/librte_eal/common/eal_common_devargs.c  |  4 ++--
 lib/librte_eal/common/eal_common_options.c  | 13 +++--------
 lib/librte_eal/common/eal_common_pci.c      |  6 ++---
 lib/librte_eal/common/eal_common_vdev.c     |  1 -
 lib/librte_eal/common/include/rte_devargs.h |  6 ++---
 test/test/test_devargs.c                    | 36 +++++++++++++++--------------
 6 files changed, 30 insertions(+), 36 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
index 7b4dfca..8fe1b39 100644
@@ -129,14 +129,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", devname);
 	if (ret < 0 || ret >= (int)sizeof(devargs->name))
 		goto fail;
-	if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI) {
+	if (devargs->type == RTE_DEVTYPE_WHITELISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_BLACKLIST) {
 			fprintf(stderr, "ERROR: incompatible device type and bus scan mode\n");
 			goto fail;
 		}
-	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {
+	} else if (devargs->type == RTE_DEVTYPE_BLACKLISTED) {
 		if (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_BLACKLIST;
 		} else if (bus->conf.scan_mode == RTE_BUS_SCAN_WHITELIST) {
lib/librte_eal/common/eal_common_options.c +3 -10
index f470195..075b0ea 100644
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,
 	switch (opt) {
 	/* blacklist */
 	case 'b':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED,
 				optarg) < 0) {
 			return -1;
 		}
 		break;
 	/* whitelist */
 	case 'w':
-		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,
 		break;
 
 	case OPT_VDEV_NUM:
-		if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL,
+		if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
 				optarg) < 0) {
 			return -1;
 		}
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)
 		return -1;
 	}
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
-		rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
-		RTE_LOG(ERR, EAL, "Options blacklist (-b) and whitelist (-w) "
-			"cannot be used at the same time\n");
-		return -1;
-	}
-
 	return 0;
 }
 
lib/librte_eal/common/eal_common_pci.c +3 -3
index 5838cc6..e03a407 100644
@@ -198,7 +198,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
 	/* no initialization when blacklisted, return without error */
 	if (dev->device.devargs != NULL &&
 		dev->device.devargs->type ==
-			RTE_DEVTYPE_BLACKLISTED_PCI) {
+			RTE_DEVTYPE_BLACKLISTED) {
 		RTE_LOG(INFO, EAL, "  Device is blacklisted, not"
 			" initializing\n");
 		return 1;
@@ -390,7 +390,7 @@ rte_pci_probe(void)
 	int probe_all = 0;
 	int ret = 0;
 
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
+	if (rte_pci_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST)
 		probe_all = 1;
 
 	FOREACH_DEVICE_ON_PCIBUS(dev) {
@@ -405,7 +405,7 @@ rte_pci_probe(void)
 		if (probe_all)
 			ret = pci_probe_all_drivers(dev);
 		else if (devargs != NULL &&
-			devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
+			devargs->type == RTE_DEVTYPE_WHITELISTED)
 			ret = pci_probe_all_drivers(dev);
 		if (ret < 0) {
 			RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
index 639ef73..517a9f3 100644
@@ -176,7 +176,6 @@ alloc_devargs(const char *name, const char *args)
 	if (!devargs)
 		return NULL;
 
-	devargs->type = RTE_DEVTYPE_VIRTUAL;
 	devargs->bus = rte_bus_find_by_name("vdev");
 	if (args)
 		devargs->args = strdup(args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
index 35675fa..a5c4a4a 100644
@@ -56,9 +56,9 @@ extern "C" {
  * Type of generic device
  */
 enum rte_devtype {
-	RTE_DEVTYPE_WHITELISTED_PCI,
-	RTE_DEVTYPE_BLACKLISTED_PCI,
-	RTE_DEVTYPE_VIRTUAL,
+	RTE_DEVTYPE_UNDEFINED,
+	RTE_DEVTYPE_WHITELISTED,
+	RTE_DEVTYPE_BLACKLISTED,
 };
 
 /**
test/test/test_devargs.c +19 -17
index 18f54ed..149c9c9 100644
@@ -64,30 +64,32 @@ test_devargs(void)
 	TAILQ_INIT(&devargs_list);
 
 	/* test valid cases */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "08:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "08:00.1") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "0000:5:00.0") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "0000:5:00.0") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0,arg=val") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "04:00.0,arg=val") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "0000:01:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "0000:01:00.1") < 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED) != 4)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED) != 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 0)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_UNDEFINED) != 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring0") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED, "net_ring0") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,key=val,k2=val2") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
+				"net_ring1,key=val,k2=val2") < 0)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_UNDEFINED) != 2)
 		goto fail;
 	free_devargs_list();
 
 	/* check virtual device with argument parsing */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, "net_ring1,k1=val,k2=val2") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_UNDEFINED,
+				"net_ring1,k1=val,k2=val2") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
 	if (strncmp(devargs->name, "net_ring1",
@@ -98,7 +100,7 @@ test_devargs(void)
 	free_devargs_list();
 
 	/* check PCI device with empty argument parsing */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "04:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "04:00.1") < 0)
 		goto fail;
 	devargs = TAILQ_FIRST(&devargs_list);
 	if (strcmp(devargs->name, "04:00.1") != 0)
@@ -108,15 +110,15 @@ test_devargs(void)
 	free_devargs_list();
 
 	/* test error case: bad PCI address */
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "08:1") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "08:1") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "00.1") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "00.1") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "foo") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "foo") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, ",") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, ",") == 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "000f:0:0") == 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED, "000f:0:0") == 0)
 		goto fail;
 
 	devargs_list = save_devargs_list;
Signature · 1 line
2.1.4
#137 lore raw

PATCH v7 16/17 devargs: introduce cleaner parsing helper

In reply to Gaetan Rivet

Introduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require API changes in the future, should this structure be updated.

The old equivalent function is thus being deprecated, as its API does not allow to accompany rte_devargs evolutions.

A deprecation notice is issued.

This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.

---
 doc/guides/rel_notes/deprecation.rst            |  5 ++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/eal_common_devargs.c      | 78 ++++++++++++++++---------
 lib/librte_eal/common/include/rte_devargs.h     | 20 +++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 5 files changed, 79 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index 2e708db..56d0698 100644
@@ -95,3 +95,8 @@ Deprecation Notices
   The non-"do-sig" versions of the hash tables will be removed
   (including the ``signature_offset`` parameter)
   and the "do-sig" versions renamed accordingly.
+
+* eal: the following function is deprecated starting from 17.08 and will
+  be removed in 17.11:
+
+  - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index 0295ea9..381f895 100644
@@ -206,6 +206,7 @@ DPDK_17.08 {
 EXPERIMENTAL {
 	global:
 
+	rte_eal_devargs_parse;
 	rte_eal_hotplug_add;
 	rte_eal_hotplug_remove;
 
lib/librte_eal/common/eal_common_devargs.c +52 -26

113 lines not on this page · raw message

lib/librte_eal/common/include/rte_devargs.h +20 -0
index a5c4a4a..a0427cd 100644
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str,
 				char **drvname, char **drvargs);
 
 /**
+ * Parse a device string.
+ *
+ * Verify that a bus is capable of handling the device passed
+ * in argument. Store which bus will handle the device, its name
+ * and the eventual device parameters.
+ *
+ * @param dev
+ *   The device declaration string.
+ * @param da
+ *   The devargs structure holding the device information.
+ *
+ * @return
+ *   - 0 on success.
+ *   - Negative errno on error.
+ */
+int
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da);
+
+/**
  * Add a device to the user device list
  *
  * For PCI devices, the format of arguments string is "PCI_ADDR" or
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
index a118fb1..0f9e009 100644
@@ -211,6 +211,7 @@ DPDK_17.08 {
 EXPERIMENTAL {
 	global:
 
+	rte_eal_devargs_parse;
 	rte_eal_hotplug_add;
 	rte_eal_hotplug_remove;
 
Signature · 1 line
2.1.4
#138 lore raw

PATCH v7 17/17 eal: change whitelist / blacklist command line doc

In reply to Gaetan Rivet

The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.

Update the source code accordingly.

---
 lib/librte_eal/common/eal_common_options.c | 18 +++++++++---------
 lib/librte_eal/common/eal_options.h        |  8 ++++----
 2 files changed, 13 insertions(+), 13 deletions(-)
lib/librte_eal/common/eal_common_options.c +9 -9
index 075b0ea..245a276 100644
@@ -86,8 +86,8 @@ eal_long_options[] = {
 	{OPT_NO_HUGE,           0, NULL, OPT_NO_HUGE_NUM          },
 	{OPT_NO_PCI,            0, NULL, OPT_NO_PCI_NUM           },
 	{OPT_NO_SHCONF,         0, NULL, OPT_NO_SHCONF_NUM        },
-	{OPT_PCI_BLACKLIST,     1, NULL, OPT_PCI_BLACKLIST_NUM    },
-	{OPT_PCI_WHITELIST,     1, NULL, OPT_PCI_WHITELIST_NUM    },
+	{OPT_BUS_BLACKLIST,     1, NULL, OPT_BUS_BLACKLIST_NUM    },
+	{OPT_BUS_WHITELIST,     1, NULL, OPT_BUS_WHITELIST_NUM    },
 	{OPT_PROC_TYPE,         1, NULL, OPT_PROC_TYPE_NUM        },
 	{OPT_SOCKET_MEM,        1, NULL, OPT_SOCKET_MEM_NUM       },
 	{OPT_SYSLOG,            1, NULL, OPT_SYSLOG_NUM           },
@@ -1049,14 +1049,14 @@ eal_common_usage(void)
 	       "  -n CHANNELS         Number of memory channels\n"
 	       "  -m MB               Memory to allocate (see also --"OPT_SOCKET_MEM")\n"
 	       "  -r RANKS            Force number of memory ranks (don't detect)\n"
-	       "  -b, --"OPT_PCI_BLACKLIST" Add a PCI device in black list.\n"
-	       "                      Prevent EAL from using this PCI device. The argument\n"
-	       "                      format is <domain:bus:devid.func>.\n"
-	       "  -w, --"OPT_PCI_WHITELIST" Add a PCI device in white list.\n"
-	       "                      Only use the specified PCI devices. The argument format\n"
-	       "                      is <[domain:]bus:devid.func>. This option can be present\n"
+	       "  -b, --"OPT_BUS_BLACKLIST" Black list a device on its bus.\n"
+	       "                      Prevents EAL from using this device. The argument\n"
+	       "                      format depends on the bus.\n"
+	       "  -w, --"OPT_BUS_WHITELIST" White list a device on its bus.\n"
+	       "                      Only use the specified devices. The argument format\n"
+	       "                      depends on the bus. This option can be present\n"
 	       "                      several times (once per device).\n"
-	       "                      [NOTE: PCI whitelist cannot be used with -b option]\n"
+	       "                      [NOTE: whitelist cannot be used with -b option]\n"
 	       "  --"OPT_VDEV"              Add a virtual device.\n"
 	       "                      The argument format is <driver><id>[,key=val,...]\n"
 	       "                      (ex: --vdev=net_pcap0,iface=eth2).\n"
lib/librte_eal/common/eal_options.h +4 -4
index a881c62..4c5db07 100644
@@ -37,10 +37,10 @@ enum {
 	/* long options mapped to a short option */
 #define OPT_HELP              "help"
 	OPT_HELP_NUM            = 'h',
-#define OPT_PCI_BLACKLIST     "pci-blacklist"
-	OPT_PCI_BLACKLIST_NUM   = 'b',
-#define OPT_PCI_WHITELIST     "pci-whitelist"
-	OPT_PCI_WHITELIST_NUM   = 'w',
+#define OPT_BUS_BLACKLIST     "bus-blacklist"
+	OPT_BUS_BLACKLIST_NUM   = 'b',
+#define OPT_BUS_WHITELIST     "bus-whitelist"
+	OPT_BUS_WHITELIST_NUM   = 'w',
 
 	/* first long only option value must be >= 256, so that we won't
 	 * conflict with short options */
Signature · 1 line
2.1.4
#139 lore raw

Re: [PATCH v7 17/17] eal: change whitelist / blacklist command line doc

07/07/2017 02:04, Gaetan Rivet:

Quoted 8 lines

The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.

Update the source code accordingly.

---

[...]

Quoted 4 lines
lib/librte_eal/common/eal_options.h +0 -0
@@ -37,10 +37,10 @@ enum {
 	/* long options mapped to a short option */

lib/librte_eal/common/eal_options.h enum { · line 43

Quoted 10 lines
lib/librte_eal/common/eal_options.h +4 -4
 #define OPT_HELP              "help"
 	OPT_HELP_NUM            = 'h',
-#define OPT_PCI_BLACKLIST     "pci-blacklist"
-	OPT_PCI_BLACKLIST_NUM   = 'b',
-#define OPT_PCI_WHITELIST     "pci-whitelist"
-	OPT_PCI_WHITELIST_NUM   = 'w',
+#define OPT_BUS_BLACKLIST     "bus-blacklist"
+	OPT_BUS_BLACKLIST_NUM   = 'b',
+#define OPT_BUS_WHITELIST     "bus-whitelist"
+	OPT_BUS_WHITELIST_NUM   = 'w',

No, we cannot drop an existing option without a prior notice. Let's discuss what should be the command line syntax and agree on a good and complete deprecation notice.
There will be more to change, like making bus explicit.

#140 lore raw
In reply to Gaetan Rivet

07/07/2017 02:04, Gaetan Rivet:

Quoted 4 lines

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

[...]

Quoted 18 lines

Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc

Quoted 2 lines

Thomas Monjalon (1):
examples/ethtool: properly reference PCI header

Series applied, except last patch (17), as explained before. Thanks

#141 lore raw
Quoted 24 lines · Thomas Monjalon

07/07/2017 02:04, Gaetan Rivet:

Quoted 4 lines

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

[...]

Quoted 18 lines

Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc

Quoted 5 lines
Quoted 2 lines

Thomas Monjalon (1):
examples/ethtool: properly reference PCI header

Series applied, except last patch (17), as explained before. Thanks

I wonder why you complain about not having enough reviewers if you anyway ignoring their feedback!

I pointed out multiple times that parsing a device name to deduce the bus is not the right thing to do. This series also tightly couples rte_devargs to rte_bus. It adds hidden functionality to have blacklist/whitelist mode for all busses and even sticks that functionality on the wrong object (devargs).

#142 lore raw

09/07/2017 10:37, Jan Blunck:

Quoted 25 lines · Thomas Monjalon
Quoted 24 lines

07/07/2017 02:04, Gaetan Rivet:

Quoted 4 lines

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

[...]

Quoted 18 lines

Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thomas Monjalon (1):
examples/ethtool: properly reference PCI header

Series applied, except last patch (17), as explained before. Thanks

I wonder why you complain about not having enough reviewers if you anyway ignoring their feedback!

I am not ignoring your feedback at all.
There are 2 things in this series:
1/ decouple devargs and PCI/vdev
2/ couple devargs policies to rte_bus
I agree that we should not have policies in rte_bus (2). However it is the only patches we have for now to achieve (1), which is a required step to move PCI and vdev as real bus drivers.

As explained in the following email, I prefer progressing on (1) and rework (2) in 17.11:

	http://dpdk.org/ml/archives/dev/2017-July/070203.html

What do you think of my proposal, adding a callback in probe?

Quoted 2 lines

I pointed out multiple times that parsing a device name to deduce the bus is not the right thing to do.

Yes, so we need to change the parameter syntax to make the bus name explicit and mandatory. We need a deprecation notice.

Quoted 4 lines

This series also tightly couples rte_devargs to rte_bus. It adds hidden functionality to have blacklist/whitelist mode for all busses and even sticks that functionality on the wrong object (devargs).

Yes, as said above, we must rework it in 17.11.

#143 lore raw
Quoted 35 lines · Thomas Monjalon

09/07/2017 10:37, Jan Blunck:

Quoted 25 lines · Thomas Monjalon
Quoted 24 lines

07/07/2017 02:04, Gaetan Rivet:

Quoted 4 lines

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

[...]

Quoted 18 lines

Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thomas Monjalon (1):
examples/ethtool: properly reference PCI header

Series applied, except last patch (17), as explained before. Thanks

I wonder why you complain about not having enough reviewers if you anyway ignoring their feedback!

Quoted 7 lines

I am not ignoring your feedback at all.
There are 2 things in this series:
1/ decouple devargs and PCI/vdev
2/ couple devargs policies to rte_bus
I agree that we should not have policies in rte_bus (2). However it is the only patches we have for now to achieve (1), which is a required step to move PCI and vdev as real bus drivers.

(1) is easy to achieve. I've explained multiple times that devargs shoudl be:
- bus name
- device name
- device arguments

Somehow I expected that giving suggestions and review comments will lead to people actively working on this picking up the ideas. I guess I was mistaken. I'll save my breath and fix it myself.

Quoted 18 lines

As explained in the following email, I prefer progressing on (1) and rework (2) in 17.11:

        http://dpdk.org/ml/archives/dev/2017-July/070203.html

What do you think of my proposal, adding a callback in probe?

Quoted 2 lines

I pointed out multiple times that parsing a device name to deduce the bus is not the right thing to do.

Yes, so we need to change the parameter syntax to make the bus name explicit and mandatory. We need a deprecation notice.

Quoted 4 lines

This series also tightly couples rte_devargs to rte_bus. It adds hidden functionality to have blacklist/whitelist mode for all busses and even sticks that functionality on the wrong object (devargs).

Yes, as said above, we must rework it in 17.11.

#144 lore raw
Quoted 44 lines · Jan Blunck
Quoted 35 lines · Thomas Monjalon

09/07/2017 10:37, Jan Blunck:

Quoted 25 lines · Thomas Monjalon
Quoted 24 lines

07/07/2017 02:04, Gaetan Rivet:

Quoted 4 lines

In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.

[...]

Quoted 18 lines

Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thomas Monjalon (1):
examples/ethtool: properly reference PCI header

Series applied, except last patch (17), as explained before. Thanks

I wonder why you complain about not having enough reviewers if you anyway ignoring their feedback!

Quoted 7 lines

I am not ignoring your feedback at all.
There are 2 things in this series:
1/ decouple devargs and PCI/vdev
2/ couple devargs policies to rte_bus
I agree that we should not have policies in rte_bus (2). However it is the only patches we have for now to achieve (1), which is a required step to move PCI and vdev as real bus drivers.

Quoted 10 lines

(1) is easy to achieve. I've explained multiple times that devargs shoudl be:
- bus name
- device name
- device arguments

Somehow I expected that giving suggestions and review comments will lead to people actively working on this picking up the ideas. I guess I was mistaken. I'll save my breath and fix it myself.

The goal is to restrict the devargs to this trifecta, eventually. In the meantime however, the way things have been designed previously forces having the "devtype" (now limited to bus scan policy) coupled with it.

It is not possible to remove it without changing the API / usage of EAL parameters.

This functionality was not added to other buses. The latent default whitelist mode was simply made explicit. This does not preclude changing it next release. In any case, it makes the issue obvious and allows comments from reviewer to point out those issue clearly.

Quoted 18 lines
Quoted 18 lines

As explained in the following email, I prefer progressing on (1) and rework (2) in 17.11:

        http://dpdk.org/ml/archives/dev/2017-July/070203.html

What do you think of my proposal, adding a callback in probe?

Quoted 2 lines

I pointed out multiple times that parsing a device name to deduce the bus is not the right thing to do.

Yes, so we need to change the parameter syntax to make the bus name explicit and mandatory. We need a deprecation notice.

Quoted 4 lines

This series also tightly couples rte_devargs to rte_bus. It adds hidden functionality to have blacklist/whitelist mode for all busses and even sticks that functionality on the wrong object (devargs).

Yes, as said above, we must rework it in 17.11.

Signature · 2 lines
Gaëtan Rivet
6WIND