DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/14] Generic devargs parsing
@ 2017-05-24 15:14 Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 01/14] net/bonding: properly reference PCI header Gaetan Rivet
                   ` (14 more replies)
  0 siblings, 15 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

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

-- 
2.1.4

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

* [dpdk-dev] [PATCH 01/14] net/bonding: properly reference PCI header
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 02/14] net/bnxt: " Gaetan Rivet
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index e3bdad9..b6a924e 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH 02/14] net/bnxt: properly reference PCI header
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 01/14] net/bonding: properly reference PCI header Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 03/14] net/mlx5: " Gaetan Rivet
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 4418c7f..678a844 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH 03/14] net/mlx5: properly reference PCI header
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 01/14] net/bonding: properly reference PCI header Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 02/14] net/bnxt: " Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 04/14] net/e1000: " Gaetan Rivet
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 67fd742..50c4fdd 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH 04/14] net/e1000: properly reference PCI header
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (2 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 03/14] net/mlx5: " Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 05/14] net/ixgbe: " Gaetan Rivet
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 8352d0a..6f25428 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH 05/14] net/ixgbe: properly reference PCI header
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (3 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 04/14] net/e1000: " Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 06/14] net/sfc: " Gaetan Rivet
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index b576a6f..fc39a3e 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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

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

* [dpdk-dev] [PATCH 06/14] net/sfc: properly reference PCI header
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (4 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 05/14] net/ixgbe: " Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 07/14] app/testpmd: " Gaetan Rivet
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index fad0ce0..ec82e87 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH 07/14] app/testpmd: properly reference PCI header
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (5 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 06/14] net/sfc: " Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 08/14] dev: device kernel module is a device attribute Gaetan Rivet
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index a15598b..d61a4ad 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH 08/14] dev: device kernel module is a device attribute
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (6 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 07/14] app/testpmd: " Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 09/14] bus: introduce bus scan policies Gaetan Rivet
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 7092b16..d4b0953 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -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 {
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index ab64c63..45c5082 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -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.
  */
-- 
2.1.4

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

* [dpdk-dev] [PATCH 09/14] bus: introduce bus scan policies
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (7 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 08/14] dev: device kernel module is a device attribute Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 10/14] devargs: parse bus policies Gaetan Rivet
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 0b48e66..fa08454 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -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 */
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH 10/14] devargs: parse bus policies
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (8 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 09/14] bus: introduce bus scan policies Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 11/14] devargs: generic device representation Gaetan Rivet
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 8bb72a2..a5014bf 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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);
-- 
2.1.4

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

* [dpdk-dev] [PATCH 11/14] devargs: generic device representation
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (9 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 10/14] devargs: parse bus policies Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 12/14] net/virtio: do not reference device type Gaetan Rivet
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index d1041af..daeece2 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index a5014bf..51ffb45 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -40,7 +40,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <rte_pci.h>
 #include <rte_devargs.h>
 #include "eal_private.h"
 
@@ -112,24 +111,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
 		goto fail;
 
-	switch (devargs->type) {
-	case RTE_DEVTYPE_WHITELISTED_PCI:
-	case RTE_DEVTYPE_BLACKLISTED_PCI:
-		/* try to parse pci identifier */
-		if (eal_parse_pci_BDF(buf, &devargs->pci.addr) != 0 &&
-		    eal_parse_pci_DomBDF(buf, &devargs->pci.addr) != 0)
-			goto fail;
-
-		break;
-	case RTE_DEVTYPE_VIRTUAL:
-		/* save driver name */
-		ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", buf);
-		if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name))
-			goto fail;
-
-		break;
-	}
+	/* save device name. */
+	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 (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
@@ -181,27 +166,10 @@ rte_eal_devargs_dump(FILE *f)
 {
 	struct rte_devargs *devargs;
 
-	fprintf(f, "User device white list:\n");
+	fprintf(f, "User device list:\n");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
-			fprintf(f, "  PCI whitelist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI)
-			fprintf(f, "  PCI blacklist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
-			fprintf(f, "  VIRTUAL %s %s\n",
-			       devargs->virt.drv_name,
-			       devargs->args);
-		else
-			fprintf(f, "  UNKNOWN %s\n", devargs->args);
+		fprintf(f, "  [%s]: %s %s\n",
+			(devargs->bus ? devargs->bus->name : "??"),
+			devargs->name, devargs->args);
 	}
 }
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 0f171ec..17d272a 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 539835a..eab5f9d 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
 	}
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 1f50a24..6a26d3d 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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;
 };
diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h
index 2d02c68..4debcde 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -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;
 }
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH 12/14] net/virtio: do not reference device type
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (10 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 11/14] devargs: generic device representation Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 13/14] devargs: generic device types Gaetan Rivet
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index b7b3d61..cd48fb5 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH 13/14] devargs: generic device types
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (11 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 12/14] net/virtio: do not reference device type Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 14/14] devargs: introduce cleaner parsing helper Gaetan Rivet
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 51ffb45..d423125 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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) {
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index f470195..075b0ea 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 17d272a..6d9fdda 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index eab5f9d..fc5e2d2 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6a26d3d..6e9e134 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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,
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH 14/14] devargs: introduce cleaner parsing helper
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (12 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 13/14] devargs: generic device types Gaetan Rivet
@ 2017-05-24 15:14 ` Gaetan Rivet
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:14 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index ba9b5a2..f90cd87 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -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``
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index d423125..7bca015 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -77,44 +77,80 @@ rte_eal_parse_devargs_str(const char *devargs_str,
 	return 0;
 }
 
-/* store a whitelist parameter for later parsing */
 int
-rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da)
 {
-	struct rte_devargs *devargs = NULL;
-	const char *dev = devargs_str;
 	struct rte_bus *bus;
-	char *buf = NULL;
+	const char *c;
+	const size_t maxlen = sizeof(da->name);
 	size_t i;
-	int ret;
-
-	/* use malloc instead of rte_malloc as it's called early at init */
-	devargs = malloc(sizeof(*devargs));
-	if (devargs == NULL)
-		goto fail;
-
-	memset(devargs, 0, sizeof(*devargs));
-	devargs->type = devtype;
 
+	if ((dev) == NULL || (da) == NULL)
+		return -EINVAL;
+	c = dev;
+	/* Retrieve eventual bus info */
 	bus = rte_bus_from_name(dev);
 	if (bus) {
 		i = rte_bus_name_valid(dev);
-		dev += i + 1;
-	} else {
-		bus = rte_bus_from_dev(dev);
+		if (dev[i] == '\0') {
+			fprintf(stderr, "WARNING: device name matches a bus name.\n");
+			bus = NULL;
+		} else {
+			c = &dev[i+1];
+		}
+	}
+	/* 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);
+			da->name[i-1] = '\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 declaration\n");
-			goto fail;
+			fprintf(stderr, "ERROR: failed to parse bus info from device \"%s\"\n",
+				da->name);
+			return -EFAULT;
 		}
 	}
-	devargs->bus = bus;
-	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
+	da->bus = bus;
+	/* Parse eventual device arguments */
+	if (c[i] == ',')
+		da->args = strdup(&c[i+1]);
+	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)
+{
+	struct rte_devargs *devargs = NULL;
+	const char *dev = devargs_str;
+	struct rte_bus *bus;
+
+	/* use calloc instead of rte_zmalloc as it's called early at init */
+	devargs = calloc(1, sizeof(*devargs));
+	if (devargs == NULL)
 		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;
@@ -131,12 +167,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:
-	free(buf);
 	if (devargs) {
 		free(devargs->args);
 		free(devargs);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6e9e134..2ab8864 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing
  2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
                   ` (13 preceding siblings ...)
  2017-05-24 15:14 ` [dpdk-dev] [PATCH 14/14] devargs: introduce cleaner parsing helper Gaetan Rivet
@ 2017-05-24 16:16 ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 01/14] net/bonding: properly reference PCI header Gaetan Rivet
                     ` (14 more replies)
  14 siblings, 15 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: 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(-)

-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 01/14] net/bonding: properly reference PCI header
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 02/14] net/bnxt: " Gaetan Rivet
                     ` (13 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index e3bdad9..b6a924e 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 02/14] net/bnxt: properly reference PCI header
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 01/14] net/bonding: properly reference PCI header Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 03/14] net/mlx5: " Gaetan Rivet
                     ` (12 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 4418c7f..678a844 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 03/14] net/mlx5: properly reference PCI header
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 01/14] net/bonding: properly reference PCI header Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 02/14] net/bnxt: " Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 04/14] net/e1000: " Gaetan Rivet
                     ` (11 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 67fd742..50c4fdd 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 04/14] net/e1000: properly reference PCI header
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (2 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 03/14] net/mlx5: " Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 05/14] net/ixgbe: " Gaetan Rivet
                     ` (10 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 8352d0a..6f25428 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 05/14] net/ixgbe: properly reference PCI header
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (3 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 04/14] net/e1000: " Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 06/14] net/sfc: " Gaetan Rivet
                     ` (9 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index b576a6f..fc39a3e 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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

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

* [dpdk-dev] [PATCH v2 06/14] net/sfc: properly reference PCI header
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (4 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 05/14] net/ixgbe: " Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 07/14] app/testpmd: " Gaetan Rivet
                     ` (8 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index fad0ce0..ec82e87 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 07/14] app/testpmd: properly reference PCI header
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (5 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 06/14] net/sfc: " Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 08/14] dev: device kernel module is a device attribute Gaetan Rivet
                     ` (7 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index a15598b..d61a4ad 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 08/14] dev: device kernel module is a device attribute
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (6 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 07/14] app/testpmd: " Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 09/14] bus: introduce bus scan policies Gaetan Rivet
                     ` (6 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 7092b16..d4b0953 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -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 {
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index ab64c63..45c5082 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -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.
  */
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 09/14] bus: introduce bus scan policies
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (7 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 08/14] dev: device kernel module is a device attribute Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 10/14] devargs: parse bus policies Gaetan Rivet
                     ` (5 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: 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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 0b48e66..fa08454 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -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 */
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 10/14] devargs: parse bus policies
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (8 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 09/14] bus: introduce bus scan policies Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 11/14] devargs: generic device representation Gaetan Rivet
                     ` (4 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 8bb72a2..a5014bf 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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);
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 11/14] devargs: generic device representation
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (9 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 10/14] devargs: parse bus policies Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 12/14] net/virtio: do not reference device type Gaetan Rivet
                     ` (3 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index d1041af..daeece2 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index a5014bf..51ffb45 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -40,7 +40,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <rte_pci.h>
 #include <rte_devargs.h>
 #include "eal_private.h"
 
@@ -112,24 +111,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
 		goto fail;
 
-	switch (devargs->type) {
-	case RTE_DEVTYPE_WHITELISTED_PCI:
-	case RTE_DEVTYPE_BLACKLISTED_PCI:
-		/* try to parse pci identifier */
-		if (eal_parse_pci_BDF(buf, &devargs->pci.addr) != 0 &&
-		    eal_parse_pci_DomBDF(buf, &devargs->pci.addr) != 0)
-			goto fail;
-
-		break;
-	case RTE_DEVTYPE_VIRTUAL:
-		/* save driver name */
-		ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", buf);
-		if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name))
-			goto fail;
-
-		break;
-	}
+	/* save device name. */
+	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 (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
@@ -181,27 +166,10 @@ rte_eal_devargs_dump(FILE *f)
 {
 	struct rte_devargs *devargs;
 
-	fprintf(f, "User device white list:\n");
+	fprintf(f, "User device list:\n");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
-			fprintf(f, "  PCI whitelist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI)
-			fprintf(f, "  PCI blacklist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
-			fprintf(f, "  VIRTUAL %s %s\n",
-			       devargs->virt.drv_name,
-			       devargs->args);
-		else
-			fprintf(f, "  UNKNOWN %s\n", devargs->args);
+		fprintf(f, "  [%s]: %s %s\n",
+			(devargs->bus ? devargs->bus->name : "??"),
+			devargs->name, devargs->args);
 	}
 }
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 44cfa3c..b26ebf0 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 539835a..eab5f9d 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
 	}
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 1f50a24..6a26d3d 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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;
 };
diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h
index 2d02c68..4debcde 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -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;
 }
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 12/14] net/virtio: do not reference device type
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (10 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 11/14] devargs: generic device representation Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 13/14] devargs: generic device types Gaetan Rivet
                     ` (2 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index b7b3d61..cd48fb5 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 13/14] devargs: generic device types
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (11 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 12/14] net/virtio: do not reference device type Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 14/14] devargs: introduce cleaner parsing helper Gaetan Rivet
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 51ffb45..d423125 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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) {
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index f470195..075b0ea 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index b26ebf0..7c385f4 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index eab5f9d..fc5e2d2 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6a26d3d..6e9e134 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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,
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH v2 14/14] devargs: introduce cleaner parsing helper
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (12 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 13/14] devargs: generic device types Gaetan Rivet
@ 2017-05-24 16:16   ` Gaetan Rivet
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-05-24 16:16 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index ba9b5a2..f90cd87 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -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``
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index d423125..7bca015 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -77,44 +77,80 @@ rte_eal_parse_devargs_str(const char *devargs_str,
 	return 0;
 }
 
-/* store a whitelist parameter for later parsing */
 int
-rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da)
 {
-	struct rte_devargs *devargs = NULL;
-	const char *dev = devargs_str;
 	struct rte_bus *bus;
-	char *buf = NULL;
+	const char *c;
+	const size_t maxlen = sizeof(da->name);
 	size_t i;
-	int ret;
-
-	/* use malloc instead of rte_malloc as it's called early at init */
-	devargs = malloc(sizeof(*devargs));
-	if (devargs == NULL)
-		goto fail;
-
-	memset(devargs, 0, sizeof(*devargs));
-	devargs->type = devtype;
 
+	if ((dev) == NULL || (da) == NULL)
+		return -EINVAL;
+	c = dev;
+	/* Retrieve eventual bus info */
 	bus = rte_bus_from_name(dev);
 	if (bus) {
 		i = rte_bus_name_valid(dev);
-		dev += i + 1;
-	} else {
-		bus = rte_bus_from_dev(dev);
+		if (dev[i] == '\0') {
+			fprintf(stderr, "WARNING: device name matches a bus name.\n");
+			bus = NULL;
+		} else {
+			c = &dev[i+1];
+		}
+	}
+	/* 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);
+			da->name[i-1] = '\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 declaration\n");
-			goto fail;
+			fprintf(stderr, "ERROR: failed to parse bus info from device \"%s\"\n",
+				da->name);
+			return -EFAULT;
 		}
 	}
-	devargs->bus = bus;
-	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
+	da->bus = bus;
+	/* Parse eventual device arguments */
+	if (c[i] == ',')
+		da->args = strdup(&c[i+1]);
+	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)
+{
+	struct rte_devargs *devargs = NULL;
+	const char *dev = devargs_str;
+	struct rte_bus *bus;
+
+	/* use calloc instead of rte_zmalloc as it's called early at init */
+	devargs = calloc(1, sizeof(*devargs));
+	if (devargs == NULL)
 		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;
@@ -131,12 +167,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:
-	free(buf);
 	if (devargs) {
 		free(devargs->args);
 		free(devargs);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6e9e134..2ab8864 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing
  2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
                     ` (13 preceding siblings ...)
  2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 14/14] devargs: introduce cleaner parsing helper Gaetan Rivet
@ 2017-06-01 10:10   ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 01/14] net/bonding: properly reference PCI header Gaetan Rivet
                       ` (14 more replies)
  14 siblings, 15 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

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

-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 01/14] net/bonding: properly reference PCI header
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 02/14] net/bnxt: " Gaetan Rivet
                       ` (13 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index e3bdad9..b6a924e 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 02/14] net/bnxt: properly reference PCI header
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 01/14] net/bonding: properly reference PCI header Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 03/14] net/mlx5: " Gaetan Rivet
                       ` (12 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 4418c7f..678a844 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 03/14] net/mlx5: properly reference PCI header
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 01/14] net/bonding: properly reference PCI header Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 02/14] net/bnxt: " Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 04/14] net/e1000: " Gaetan Rivet
                       ` (11 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 67fd742..50c4fdd 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 04/14] net/e1000: properly reference PCI header
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (2 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 03/14] net/mlx5: " Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 05/14] net/ixgbe: " Gaetan Rivet
                       ` (10 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 8352d0a..6f25428 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 05/14] net/ixgbe: properly reference PCI header
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (3 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 04/14] net/e1000: " Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 06/14] net/sfc: " Gaetan Rivet
                       ` (9 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index b576a6f..fc39a3e 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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

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

* [dpdk-dev] [PATCH v3 06/14] net/sfc: properly reference PCI header
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (4 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 05/14] net/ixgbe: " Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 07/14] app/testpmd: " Gaetan Rivet
                       ` (8 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

From: Gaetan Rivet <g.rivet2@gmail.com>

Signed-off-by: Gaetan Rivet <g.rivet2@gmail.com>
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index fad0ce0..ec82e87 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 07/14] app/testpmd: properly reference PCI header
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (5 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 06/14] net/sfc: " Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 08/14] dev: device kernel module is a device attribute Gaetan Rivet
                       ` (7 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index a15598b..d61a4ad 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 08/14] dev: device kernel module is a device attribute
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (6 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 07/14] app/testpmd: " Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 09/14] bus: introduce bus scan policies Gaetan Rivet
                       ` (6 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index c530797..58160e1 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -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 {
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index ab64c63..45c5082 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -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.
  */
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 09/14] bus: introduce bus scan policies
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (7 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 08/14] dev: device kernel module is a device attribute Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 10/14] devargs: parse bus policies Gaetan Rivet
                       ` (5 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: 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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 4489d1d..b5d7a88 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -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 */
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 10/14] devargs: parse bus policies
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (8 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 09/14] bus: introduce bus scan policies Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 11/14] devargs: generic device representation Gaetan Rivet
                       ` (4 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 8bb72a2..a5014bf 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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);
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 11/14] devargs: generic device representation
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (9 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 10/14] devargs: parse bus policies Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 12/14] net/virtio: do not reference device type Gaetan Rivet
                       ` (3 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index d1041af..daeece2 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index a5014bf..51ffb45 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -40,7 +40,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <rte_pci.h>
 #include <rte_devargs.h>
 #include "eal_private.h"
 
@@ -112,24 +111,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
 		goto fail;
 
-	switch (devargs->type) {
-	case RTE_DEVTYPE_WHITELISTED_PCI:
-	case RTE_DEVTYPE_BLACKLISTED_PCI:
-		/* try to parse pci identifier */
-		if (eal_parse_pci_BDF(buf, &devargs->pci.addr) != 0 &&
-		    eal_parse_pci_DomBDF(buf, &devargs->pci.addr) != 0)
-			goto fail;
-
-		break;
-	case RTE_DEVTYPE_VIRTUAL:
-		/* save driver name */
-		ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", buf);
-		if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name))
-			goto fail;
-
-		break;
-	}
+	/* save device name. */
+	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 (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
@@ -181,27 +166,10 @@ rte_eal_devargs_dump(FILE *f)
 {
 	struct rte_devargs *devargs;
 
-	fprintf(f, "User device white list:\n");
+	fprintf(f, "User device list:\n");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
-			fprintf(f, "  PCI whitelist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI)
-			fprintf(f, "  PCI blacklist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
-			fprintf(f, "  VIRTUAL %s %s\n",
-			       devargs->virt.drv_name,
-			       devargs->args);
-		else
-			fprintf(f, "  UNKNOWN %s\n", devargs->args);
+		fprintf(f, "  [%s]: %s %s\n",
+			(devargs->bus ? devargs->bus->name : "??"),
+			devargs->name, devargs->args);
 	}
 }
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index c698cf8..d6658c2 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index ea58706..f618bbb 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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 = {
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 1f50a24..6a26d3d 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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;
 };
diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h
index 2d02c68..4debcde 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -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;
 }
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 12/14] net/virtio: do not reference device type
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (10 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 11/14] devargs: generic device representation Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 13/14] devargs: generic device types Gaetan Rivet
                       ` (2 subsequent siblings)
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index b7b3d61..cd48fb5 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 13/14] devargs: generic device types
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (11 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 12/14] net/virtio: do not reference device type Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 14/14] devargs: introduce cleaner parsing helper Gaetan Rivet
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 51ffb45..d423125 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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) {
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index f470195..075b0ea 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index d6658c2..2a52b9e 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index f618bbb..082bbae 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6a26d3d..6e9e134 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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,
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH v3 14/14] devargs: introduce cleaner parsing helper
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (12 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 13/14] devargs: generic device types Gaetan Rivet
@ 2017-06-01 10:10     ` Gaetan Rivet
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
  14 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:10 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index ba9b5a2..f90cd87 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -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``
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index d423125..7bca015 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -77,44 +77,80 @@ rte_eal_parse_devargs_str(const char *devargs_str,
 	return 0;
 }
 
-/* store a whitelist parameter for later parsing */
 int
-rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da)
 {
-	struct rte_devargs *devargs = NULL;
-	const char *dev = devargs_str;
 	struct rte_bus *bus;
-	char *buf = NULL;
+	const char *c;
+	const size_t maxlen = sizeof(da->name);
 	size_t i;
-	int ret;
-
-	/* use malloc instead of rte_malloc as it's called early at init */
-	devargs = malloc(sizeof(*devargs));
-	if (devargs == NULL)
-		goto fail;
-
-	memset(devargs, 0, sizeof(*devargs));
-	devargs->type = devtype;
 
+	if ((dev) == NULL || (da) == NULL)
+		return -EINVAL;
+	c = dev;
+	/* Retrieve eventual bus info */
 	bus = rte_bus_from_name(dev);
 	if (bus) {
 		i = rte_bus_name_valid(dev);
-		dev += i + 1;
-	} else {
-		bus = rte_bus_from_dev(dev);
+		if (dev[i] == '\0') {
+			fprintf(stderr, "WARNING: device name matches a bus name.\n");
+			bus = NULL;
+		} else {
+			c = &dev[i+1];
+		}
+	}
+	/* 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);
+			da->name[i-1] = '\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 declaration\n");
-			goto fail;
+			fprintf(stderr, "ERROR: failed to parse bus info from device \"%s\"\n",
+				da->name);
+			return -EFAULT;
 		}
 	}
-	devargs->bus = bus;
-	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
+	da->bus = bus;
+	/* Parse eventual device arguments */
+	if (c[i] == ',')
+		da->args = strdup(&c[i+1]);
+	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)
+{
+	struct rte_devargs *devargs = NULL;
+	const char *dev = devargs_str;
+	struct rte_bus *bus;
+
+	/* use calloc instead of rte_zmalloc as it's called early at init */
+	devargs = calloc(1, sizeof(*devargs));
+	if (devargs == NULL)
 		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;
@@ -131,12 +167,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:
-	free(buf);
 	if (devargs) {
 		free(devargs->args);
 		free(devargs);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6e9e134..2ab8864 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing
  2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
                       ` (13 preceding siblings ...)
  2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 14/14] devargs: introduce cleaner parsing helper Gaetan Rivet
@ 2017-06-07 23:56     ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 01/19] net/bonding: properly reference PCI header Gaetan Rivet
                         ` (19 more replies)
  14 siblings, 20 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

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

-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 01/19] net/bonding: properly reference PCI header
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 02/19] net/bnxt: " Gaetan Rivet
                         ` (18 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index dc468d2..ed217fb 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 02/19] net/bnxt: properly reference PCI header
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 01/19] net/bonding: properly reference PCI header Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 03/19] net/mlx5: " Gaetan Rivet
                         ` (17 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 54428ba..4609792 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 03/19] net/mlx5: properly reference PCI header
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 01/19] net/bonding: properly reference PCI header Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 02/19] net/bnxt: " Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 04/19] net/e1000: " Gaetan Rivet
                         ` (16 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 1148dee..9ef2c11 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 04/19] net/e1000: properly reference PCI header
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (2 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 03/19] net/mlx5: " Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 05/19] net/ixgbe: " Gaetan Rivet
                         ` (15 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 4979895..ac380ed 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 05/19] net/ixgbe: properly reference PCI header
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (3 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 04/19] net/e1000: " Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-14  9:33         ` Dai, Wei
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 06/19] net/sfc: " Gaetan Rivet
                         ` (14 subsequent siblings)
  19 siblings, 1 reply; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index e2d0139..bb5ecd5 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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

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

* [dpdk-dev] [PATCH v4 06/19] net/sfc: properly reference PCI header
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (4 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 05/19] net/ixgbe: " Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 07/19] app/testpmd: " Gaetan Rivet
                         ` (13 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 007ed24..41dff48 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 07/19] app/testpmd: properly reference PCI header
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (5 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 06/19] net/sfc: " Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 08/19] test: " Gaetan Rivet
                         ` (12 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 1838241..90a6568 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 08/19] test: properly reference PCI header
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (6 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 07/19] app/testpmd: " Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 09/19] dev: device kernel module is a device attribute Gaetan Rivet
                         ` (11 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 test/test/virtual_pmd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/virtual_pmd.c b/test/test/virtual_pmd.c
index e9dd8ac..f3ee82f 100644
--- a/test/test/virtual_pmd.c
+++ b/test/test/virtual_pmd.c
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 09/19] dev: device kernel module is a device attribute
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (7 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 08/19] test: " Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 10/19] bus: introduce bus scan policies Gaetan Rivet
                         ` (10 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 9f35b1f..3162822 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -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 {
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index b82ab9e..51b084e 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -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.
  */
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 10/19] bus: introduce bus scan policies
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (8 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 09/19] dev: device kernel module is a device attribute Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 11/19] devargs: parse bus policies Gaetan Rivet
                         ` (9 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: 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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 4bed780..fd94755 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -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 */
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 11/19] devargs: parse bus policies
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (9 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 10/19] bus: introduce bus scan policies Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 12/19] devargs: generic device representation Gaetan Rivet
                         ` (8 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 8bb72a2..a5014bf 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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);
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 12/19] devargs: generic device representation
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (10 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 11/19] devargs: parse bus policies Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 13/19] pci: update device name Gaetan Rivet
                         ` (7 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 17ae446..f36de2f 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index a5014bf..51ffb45 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -40,7 +40,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <rte_pci.h>
 #include <rte_devargs.h>
 #include "eal_private.h"
 
@@ -112,24 +111,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
 		goto fail;
 
-	switch (devargs->type) {
-	case RTE_DEVTYPE_WHITELISTED_PCI:
-	case RTE_DEVTYPE_BLACKLISTED_PCI:
-		/* try to parse pci identifier */
-		if (eal_parse_pci_BDF(buf, &devargs->pci.addr) != 0 &&
-		    eal_parse_pci_DomBDF(buf, &devargs->pci.addr) != 0)
-			goto fail;
-
-		break;
-	case RTE_DEVTYPE_VIRTUAL:
-		/* save driver name */
-		ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", buf);
-		if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name))
-			goto fail;
-
-		break;
-	}
+	/* save device name. */
+	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 (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
@@ -181,27 +166,10 @@ rte_eal_devargs_dump(FILE *f)
 {
 	struct rte_devargs *devargs;
 
-	fprintf(f, "User device white list:\n");
+	fprintf(f, "User device list:\n");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
-			fprintf(f, "  PCI whitelist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI)
-			fprintf(f, "  PCI blacklist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
-			fprintf(f, "  VIRTUAL %s %s\n",
-			       devargs->virt.drv_name,
-			       devargs->args);
-		else
-			fprintf(f, "  UNKNOWN %s\n", devargs->args);
+		fprintf(f, "  [%s]: %s %s\n",
+			(devargs->bus ? devargs->bus->name : "??"),
+			devargs->name, devargs->args);
 	}
 }
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 3075eee..83ae378 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 7cc3c6c..c56fb6d 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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;
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 1f50a24..6a26d3d 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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;
 };
diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h
index 2d02c68..4debcde 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -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;
 }
 
diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
index 63242f1..18f54ed 100644
--- a/test/test/test_devargs.c
+++ b/test/test/test_devargs.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 13/19] pci: update device name
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (11 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 12/19] devargs: generic device representation Gaetan Rivet
@ 2017-06-07 23:56       ` Gaetan Rivet
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 14/19] net/virtio: do not reference device type Gaetan Rivet
                         ` (6 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 83ae378..a31e490 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 14/19] net/virtio: do not reference device type
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (12 preceding siblings ...)
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 13/19] pci: update device name Gaetan Rivet
@ 2017-06-07 23:57       ` Gaetan Rivet
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 15/19] devargs: generic device types Gaetan Rivet
                         ` (5 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:57 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index b7b3d61..cd48fb5 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 15/19] devargs: generic device types
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (13 preceding siblings ...)
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 14/19] net/virtio: do not reference device type Gaetan Rivet
@ 2017-06-07 23:57       ` Gaetan Rivet
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
                         ` (4 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:57 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 51ffb45..d423125 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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) {
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index f470195..075b0ea 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index a31e490..b4f8056 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index c56fb6d..d921345 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6a26d3d..6e9e134 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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,
 };
 
 /**
diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
index 18f54ed..149c9c9 100644
--- a/test/test/test_devargs.c
+++ b/test/test/test_devargs.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 16/19] devargs: introduce cleaner parsing helper
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (14 preceding siblings ...)
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 15/19] devargs: generic device types Gaetan Rivet
@ 2017-06-07 23:57       ` Gaetan Rivet
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 17/19] devargs: clone function Gaetan Rivet
                         ` (3 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:57 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 1786a59..fb95ced 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -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``
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index d423125..b69a2b2 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -77,44 +77,83 @@ rte_eal_parse_devargs_str(const char *devargs_str,
 	return 0;
 }
 
-/* store a whitelist parameter for later parsing */
 int
-rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
+rte_eal_devargs_parse(const char *dev,
+		      struct rte_devargs *da)
 {
-	struct rte_devargs *devargs = NULL;
-	const char *dev = devargs_str;
 	struct rte_bus *bus;
-	char *buf = NULL;
+	const char *c;
+	const size_t maxlen = sizeof(da->name);
 	size_t i;
-	int ret;
-
-	/* use malloc instead of rte_malloc as it's called early at init */
-	devargs = malloc(sizeof(*devargs));
-	if (devargs == NULL)
-		goto fail;
-
-	memset(devargs, 0, sizeof(*devargs));
-	devargs->type = devtype;
 
+	if ((dev) == NULL || (da) == NULL)
+		return -EINVAL;
+	c = dev;
+	/* Retrieve eventual bus info */
 	bus = rte_bus_from_name(dev);
 	if (bus) {
 		i = rte_bus_name_valid(dev);
-		dev += i + 1;
-	} else {
-		bus = rte_bus_from_dev(dev);
+		if (dev[i] == '\0') {
+			fprintf(stderr, "WARNING: device name matches a bus name.\n");
+			bus = NULL;
+		} else if (rte_bus_from_dev(dev)) {
+			/* false positive on bus name. */
+			bus = NULL;
+		} else {
+			c = &dev[i+1];
+		}
+	}
+	/* 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);
+			da->name[i-1] = '\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 declaration\n");
-			goto fail;
+			fprintf(stderr, "ERROR: failed to parse bus info from device \"%s\"\n",
+				da->name);
+			return -EFAULT;
 		}
 	}
-	devargs->bus = bus;
-	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
+	da->bus = bus;
+	/* Parse eventual device arguments */
+	if (c[i] == ',')
+		da->args = strdup(&c[i+1]);
+	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)
+{
+	struct rte_devargs *devargs = NULL;
+	const char *dev = devargs_str;
+	struct rte_bus *bus;
+
+	/* use calloc instead of rte_zmalloc as it's called early at init */
+	devargs = calloc(1, sizeof(*devargs));
+	if (devargs == NULL)
 		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;
@@ -131,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:
-	free(buf);
 	if (devargs) {
 		free(devargs->args);
 		free(devargs);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6e9e134..2ab8864 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 17/19] devargs: clone function
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (15 preceding siblings ...)
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
@ 2017-06-07 23:57       ` Gaetan Rivet
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 18/19] devargs: remove function Gaetan Rivet
                         ` (2 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:57 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

This function returns a deep copy of an rte_devargs.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 04fa882..a506968 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -203,5 +203,6 @@ DPDK_17.08 {
 
 	rte_bus_from_name;
 	rte_bus_from_dev;
+	rte_eal_devargs_clone;
 
 } DPDK_17.05;
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index b69a2b2..07b89ef 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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)
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 2ab8864..892b035 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index a5127d6..6e6638a 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -207,5 +207,6 @@ DPDK_17.08 {
 
 	rte_bus_from_name;
 	rte_bus_from_dev;
+	rte_eal_devargs_clone;
 
 } DPDK_17.05;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 18/19] devargs: remove function
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (16 preceding siblings ...)
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 17/19] devargs: clone function Gaetan Rivet
@ 2017-06-07 23:57       ` Gaetan Rivet
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:57 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index a506968..d069de0 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 07b89ef..1a6a67f 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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)
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 892b035..f61707c 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 6e6638a..19eec05 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v4 19/19] eal: change whitelist / blacklist command line doc
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (17 preceding siblings ...)
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 18/19] devargs: remove function Gaetan Rivet
@ 2017-06-07 23:57       ` Gaetan Rivet
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:57 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_options.c | 18 +++++++++---------
 lib/librte_eal/common/eal_options.h        |  8 ++++----
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 075b0ea..245a276 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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"
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index a881c62..4c5db07 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -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 */
-- 
2.1.4

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

* Re: [dpdk-dev] [PATCH v4 05/19] net/ixgbe: properly reference PCI header
  2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 05/19] net/ixgbe: " Gaetan Rivet
@ 2017-06-14  9:33         ` Dai, Wei
  2017-06-14  9:48           ` Gaëtan Rivet
  0 siblings, 1 reply; 145+ messages in thread
From: Dai, Wei @ 2017-06-14  9:33 UTC (permalink / raw)
  To: Gaetan Rivet, dev

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.


> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Gaetan Rivet
> Sent: Thursday, June 8, 2017 7:57 AM
> To: dev@dpdk.org
> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> Subject: [dpdk-dev] [PATCH v4 05/19] net/ixgbe: properly reference PCI header
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h
> b/drivers/net/ixgbe/ixgbe_ethdev.h
> index e2d0139..bb5ecd5 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.h
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.h
> @@ -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

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

* Re: [dpdk-dev] [PATCH v4 05/19] net/ixgbe: properly reference PCI header
  2017-06-14  9:33         ` Dai, Wei
@ 2017-06-14  9:48           ` Gaëtan Rivet
  0 siblings, 0 replies; 145+ messages in thread
From: Gaëtan Rivet @ 2017-06-14  9:48 UTC (permalink / raw)
  To: Dai, Wei; +Cc: dev

Hi,

On Wed, Jun 14, 2017 at 09:33:14AM +0000, Dai, Wei wrote:
> 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.

> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Gaetan Rivet
> > Sent: Thursday, June 8, 2017 7:57 AM
> > To: dev@dpdk.org
> > Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> > Subject: [dpdk-dev] [PATCH v4 05/19] net/ixgbe: properly reference PCI header
> > 
> > Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> > ---
> >  drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h
> > b/drivers/net/ixgbe/ixgbe_ethdev.h
> > index e2d0139..bb5ecd5 100644
> > --- a/drivers/net/ixgbe/ixgbe_ethdev.h
> > +++ b/drivers/net/ixgbe/ixgbe_ethdev.h
> > @@ -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
> 

-- 
Gaëtan Rivet
6WIND

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

* [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing
  2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
                         ` (18 preceding siblings ...)
  2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
@ 2017-06-20 23:35       ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 01/19] net/bonding: properly reference PCI header Gaetan Rivet
                           ` (19 more replies)
  19 siblings, 20 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev
  Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
	Jerin Jacob, David Marchand

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

-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 01/19] net/bonding: properly reference PCI header
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 02/19] net/bnxt: " Gaetan Rivet
                           ` (18 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index dc468d2..ed217fb 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 02/19] net/bnxt: properly reference PCI header
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 01/19] net/bonding: properly reference PCI header Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 03/19] net/mlx5: " Gaetan Rivet
                           ` (17 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 1538aa5..07279f7 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 03/19] net/mlx5: properly reference PCI header
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 01/19] net/bonding: properly reference PCI header Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 02/19] net/bnxt: " Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 04/19] net/e1000: " Gaetan Rivet
                           ` (16 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index aa8a1a0..f16f778 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 04/19] net/e1000: properly reference PCI header
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (2 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 03/19] net/mlx5: " Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 05/19] net/ixgbe: " Gaetan Rivet
                           ` (15 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 85fd1a0..5668910 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 05/19] net/ixgbe: properly reference PCI header
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (3 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 04/19] net/e1000: " Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 06/19] net/sfc: " Gaetan Rivet
                           ` (14 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 10b9967..bcbd62d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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

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

* [dpdk-dev] [PATCH v5 06/19] net/sfc: properly reference PCI header
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (4 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 05/19] net/ixgbe: " Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 07/19] app/testpmd: " Gaetan Rivet
                           ` (13 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 007ed24..41dff48 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 07/19] app/testpmd: properly reference PCI header
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (5 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 06/19] net/sfc: " Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 08/19] test: " Gaetan Rivet
                           ` (12 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 1838241..90a6568 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 08/19] test: properly reference PCI header
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (6 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 07/19] app/testpmd: " Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 09/19] dev: device kernel module is a device attribute Gaetan Rivet
                           ` (11 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 test/test/virtual_pmd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/virtual_pmd.c b/test/test/virtual_pmd.c
index e9dd8ac..f3ee82f 100644
--- a/test/test/virtual_pmd.c
+++ b/test/test/virtual_pmd.c
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 09/19] dev: device kernel module is a device attribute
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (7 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 08/19] test: " Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 10/19] bus: introduce bus scan policies Gaetan Rivet
                           ` (10 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 9f35b1f..3162822 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -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 {
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 0284a62..ca9f179 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -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.
  */
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 10/19] bus: introduce bus scan policies
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (8 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 09/19] dev: device kernel module is a device attribute Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-07-04 23:01           ` Thomas Monjalon
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 11/19] devargs: parse bus policies Gaetan Rivet
                           ` (9 subsequent siblings)
  19 siblings, 1 reply; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: 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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 61d9e6e..793a625 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -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 */
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 11/19] devargs: parse bus policies
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (9 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 10/19] bus: introduce bus scan policies Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 12/19] devargs: generic device representation Gaetan Rivet
                           ` (8 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index d5f297d..ac51b19 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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);
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 12/19] devargs: generic device representation
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (10 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 11/19] devargs: parse bus policies Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-28  7:44           ` Thomas Monjalon
  2017-06-28 14:18           ` [dpdk-dev] [PATCH] examples/ethtool: explicit PCI header dependency Thomas Monjalon
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 13/19] pci: update device name Gaetan Rivet
                           ` (7 subsequent siblings)
  19 siblings, 2 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index b29328a..e19fe89 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index ac51b19..6ccd857 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -40,7 +40,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <rte_pci.h>
 #include <rte_devargs.h>
 #include "eal_private.h"
 
@@ -110,24 +109,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args))
 		goto fail;
 
-	switch (devargs->type) {
-	case RTE_DEVTYPE_WHITELISTED_PCI:
-	case RTE_DEVTYPE_BLACKLISTED_PCI:
-		/* try to parse pci identifier */
-		if (eal_parse_pci_BDF(buf, &devargs->pci.addr) != 0 &&
-		    eal_parse_pci_DomBDF(buf, &devargs->pci.addr) != 0)
-			goto fail;
-
-		break;
-	case RTE_DEVTYPE_VIRTUAL:
-		/* save driver name */
-		ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", buf);
-		if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name))
-			goto fail;
-
-		break;
-	}
+	/* save device name. */
+	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 (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
@@ -179,27 +164,10 @@ rte_eal_devargs_dump(FILE *f)
 {
 	struct rte_devargs *devargs;
 
-	fprintf(f, "User device white list:\n");
+	fprintf(f, "User device list:\n");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
-			fprintf(f, "  PCI whitelist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI)
-			fprintf(f, "  PCI blacklist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
-			fprintf(f, "  VIRTUAL %s %s\n",
-			       devargs->virt.drv_name,
-			       devargs->args);
-		else
-			fprintf(f, "  UNKNOWN %s\n", devargs->args);
+		fprintf(f, "  [%s]: %s %s\n",
+			(devargs->bus ? devargs->bus->name : "??"),
+			devargs->name, devargs->args);
 	}
 }
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 0f3ecdb..441466d 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 7cc3c6c..c56fb6d 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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;
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 1f50a24..6a26d3d 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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;
 };
diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h
index 2d02c68..4debcde 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -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;
 }
 
diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
index 63242f1..18f54ed 100644
--- a/test/test/test_devargs.c
+++ b/test/test/test_devargs.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 13/19] pci: update device name
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (11 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 12/19] devargs: generic device representation Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 14/19] net/virtio: do not reference device type Gaetan Rivet
                           ` (6 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 441466d..eed6589 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 14/19] net/virtio: do not reference device type
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (12 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 13/19] pci: update device name Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 15/19] devargs: generic device types Gaetan Rivet
                           ` (5 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index b7b3d61..cd48fb5 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 15/19] devargs: generic device types
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (13 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 14/19] net/virtio: do not reference device type Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
                           ` (4 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 6ccd857..321a62d 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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) {
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index f470195..075b0ea 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index eed6589..5733b3c 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index c56fb6d..d921345 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6a26d3d..6e9e134 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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,
 };
 
 /**
diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
index 18f54ed..149c9c9 100644
--- a/test/test/test_devargs.c
+++ b/test/test/test_devargs.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 16/19] devargs: introduce cleaner parsing helper
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (14 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 15/19] devargs: generic device types Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-27 22:19           ` Thomas Monjalon
  2017-06-27 23:46           ` Wiles, Keith
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 17/19] devargs: clone function Gaetan Rivet
                           ` (3 subsequent siblings)
  19 siblings, 2 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 1786a59..fb95ced 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -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``
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 321a62d..f2e11f9 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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)
+{
+	struct rte_bus *bus;
+	const char *c;
+	const size_t maxlen = sizeof(da->name);
+	size_t i;
+
+	if ((dev) == NULL || (da) == NULL)
+		return -EINVAL;
+	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");
+			bus = NULL;
+		} else if (rte_bus_from_dev(dev)) {
+			/* false positive on bus name. */
+			bus = NULL;
+		} else {
+			c = &dev[i+1];
+		}
+	}
+	/* 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);
+			da->name[i-1] = '\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);
+			return -EFAULT;
+		}
+	}
+	da->bus = bus;
+	/* Parse eventual device arguments */
+	if (c[i] == ',')
+		da->args = strdup(&c[i+1]);
+	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)
@@ -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:
-	free(buf);
 	if (devargs) {
 		free(devargs->args);
 		free(devargs);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6e9e134..2ab8864 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 17/19] devargs: clone function
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (15 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 18/19] devargs: remove function Gaetan Rivet
                           ` (2 subsequent siblings)
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

This function returns a deep copy of an rte_devargs.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 04fa882..a506968 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -203,5 +203,6 @@ DPDK_17.08 {
 
 	rte_bus_from_name;
 	rte_bus_from_dev;
+	rte_eal_devargs_clone;
 
 } DPDK_17.05;
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index f2e11f9..10009fa 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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)
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 2ab8864..892b035 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index a5127d6..6e6638a 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -207,5 +207,6 @@ DPDK_17.08 {
 
 	rte_bus_from_name;
 	rte_bus_from_dev;
+	rte_eal_devargs_clone;
 
 } DPDK_17.05;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 18/19] devargs: remove function
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (16 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 17/19] devargs: clone function Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
  19 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index a506968..d069de0 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 10009fa..bbd57c5 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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)
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 892b035..f61707c 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 6e6638a..19eec05 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v5 19/19] eal: change whitelist / blacklist command line doc
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (17 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 18/19] devargs: remove function Gaetan Rivet
@ 2017-06-20 23:35         ` Gaetan Rivet
  2017-06-26 14:58           ` Mcnamara, John
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
  19 siblings, 1 reply; 145+ messages in thread
From: Gaetan Rivet @ 2017-06-20 23:35 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_options.c | 18 +++++++++---------
 lib/librte_eal/common/eal_options.h        |  8 ++++----
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 075b0ea..245a276 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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"
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index a881c62..4c5db07 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -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 */
-- 
2.1.4

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

* Re: [dpdk-dev] [PATCH v5 19/19] eal: change whitelist / blacklist command line doc
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
@ 2017-06-26 14:58           ` Mcnamara, John
  0 siblings, 0 replies; 145+ messages in thread
From: Mcnamara, John @ 2017-06-26 14:58 UTC (permalink / raw)
  To: Gaetan Rivet, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Gaetan Rivet
> Sent: Wednesday, June 21, 2017 12:36 AM
> To: dev@dpdk.org
> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> Subject: [dpdk-dev] [PATCH v5 19/19] eal: change whitelist / blacklist
> command line doc
> 
> The use of these commands have evolved.
> It is now possible to use whitelist and blacklist on any bus.
> 
> Update the source code accordingly.
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>

Acked-by: John McNamara <john.mcnamara@intel.com>

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

* Re: [dpdk-dev] [PATCH v5 16/19] devargs: introduce cleaner parsing helper
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
@ 2017-06-27 22:19           ` Thomas Monjalon
  2017-06-27 23:46           ` Wiles, Keith
  1 sibling, 0 replies; 145+ messages in thread
From: Thomas Monjalon @ 2017-06-27 22:19 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev

21/06/2017 01:35, Gaetan Rivet:
> +int
> +rte_eal_devargs_parse(const char *dev,
> +		      struct rte_devargs *da);

You need to export this new function:

--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -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;

--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -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;

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

* Re: [dpdk-dev] [PATCH v5 16/19] devargs: introduce cleaner parsing helper
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
  2017-06-27 22:19           ` Thomas Monjalon
@ 2017-06-27 23:46           ` Wiles, Keith
  2017-07-04 21:50             ` Gaëtan Rivet
  1 sibling, 1 reply; 145+ messages in thread
From: Wiles, Keith @ 2017-06-27 23:46 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev


> On Jun 20, 2017, at 4:35 PM, Gaetan Rivet <gaetan.rivet@6wind.com> wrote:
> 
> 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.
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
> 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(-)
> 
> diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
> index 1786a59..fb95ced 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -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``
> diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
> index 321a62d..f2e11f9 100644
> --- a/lib/librte_eal/common/eal_common_devargs.c
> +++ b/lib/librte_eal/common/eal_common_devargs.c
> @@ -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?

> +{
> +	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?

> +	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?

> +			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?

> +	}
> +	/* 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?

> +			da->name[i-1] = '\0’;

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

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

> +			return -EFAULT;
> +		}
> +	}
> +	da->bus = bus;
> +	/* Parse eventual device arguments */
> +	if (c[i] == ',')
> +		da->args = strdup(&c[i+1]);
[i + 1]

> +	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)
> @@ -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:
> -	free(buf);
> 	if (devargs) {
> 		free(devargs->args);
> 		free(devargs);
> diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
> index 6e9e134..2ab8864 100644
> --- a/lib/librte_eal/common/include/rte_devargs.h
> +++ b/lib/librte_eal/common/include/rte_devargs.h
> @@ -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
> -- 
> 2.1.4
> 

Regards,
Keith


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

* Re: [dpdk-dev] [PATCH v5 12/19] devargs: generic device representation
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 12/19] devargs: generic device representation Gaetan Rivet
@ 2017-06-28  7:44           ` Thomas Monjalon
  2017-06-28  8:05             ` Gaëtan Rivet
  2017-06-28 14:18           ` [dpdk-dev] [PATCH] examples/ethtool: explicit PCI header dependency Thomas Monjalon
  1 sibling, 1 reply; 145+ messages in thread
From: Thomas Monjalon @ 2017-06-28  7:44 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev

21/06/2017 01:35, 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.
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
>  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?

--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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.

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

* Re: [dpdk-dev] [PATCH v5 12/19] devargs: generic device representation
  2017-06-28  7:44           ` Thomas Monjalon
@ 2017-06-28  8:05             ` Gaëtan Rivet
  0 siblings, 0 replies; 145+ messages in thread
From: Gaëtan Rivet @ 2017-06-28  8:05 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Wed, Jun 28, 2017 at 09:44:18AM +0200, Thomas Monjalon wrote:
> 21/06/2017 01:35, 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.
> > 
> > Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> > ---
> >  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?
> 
> --- a/lib/librte_eal/common/eal_common_pci.c
> +++ b/lib/librte_eal/common/eal_common_pci.c
> @@ -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.

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

-- 
Gaëtan Rivet
6WIND

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

* [dpdk-dev] [PATCH] examples/ethtool: explicit PCI header dependency
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 12/19] devargs: generic device representation Gaetan Rivet
  2017-06-28  7:44           ` Thomas Monjalon
@ 2017-06-28 14:18           ` Thomas Monjalon
  1 sibling, 0 replies; 145+ messages in thread
From: Thomas Monjalon @ 2017-06-28 14:18 UTC (permalink / raw)
  To: gaetan.rivet; +Cc: dev

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.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 examples/ethtool/lib/rte_ethtool.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index fabfcb2ba..252382cb5 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -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",
-- 
2.13.1

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

* Re: [dpdk-dev] [PATCH v5 16/19] devargs: introduce cleaner parsing helper
  2017-06-27 23:46           ` Wiles, Keith
@ 2017-07-04 21:50             ` Gaëtan Rivet
  0 siblings, 0 replies; 145+ messages in thread
From: Gaëtan Rivet @ 2017-07-04 21:50 UTC (permalink / raw)
  To: Wiles, Keith; +Cc: dev

Hi Keith,

Thanks for the review.

On Tue, Jun 27, 2017 at 11:46:48PM +0000, Wiles, Keith wrote:
> 
> > On Jun 20, 2017, at 4:35 PM, Gaetan Rivet <gaetan.rivet@6wind.com> wrote:
> > 
> > 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.
> > 
> > Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> > ---
> > 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(-)
> > 
> > diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
> > index 1786a59..fb95ced 100644
> > --- a/doc/guides/rel_notes/deprecation.rst
> > +++ b/doc/guides/rel_notes/deprecation.rst
> > @@ -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``
> > diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
> > index 321a62d..f2e11f9 100644
> > --- a/lib/librte_eal/common/eal_common_devargs.c
> > +++ b/lib/librte_eal/common/eal_common_devargs.c
> > @@ -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?
> 

Not really, will change.

> > +{
> > +	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.

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

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

> > +	}
> > +	/* 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.

> > +			da->name[i-1] = '\0’;
> 
> I believe the must have spaces around the - e.g. [i - 1]
> 

yes

> > +			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.
> 
> > +			return -EFAULT;
> > +		}
> > +	}
> > +	da->bus = bus;
> > +	/* Parse eventual device arguments */
> > +	if (c[i] == ',')
> > +		da->args = strdup(&c[i+1]);
> [i + 1]
> 
> > +	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)
> > @@ -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:
> > -	free(buf);
> > 	if (devargs) {
> > 		free(devargs->args);
> > 		free(devargs);
> > diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
> > index 6e9e134..2ab8864 100644
> > --- a/lib/librte_eal/common/include/rte_devargs.h
> > +++ b/lib/librte_eal/common/include/rte_devargs.h
> > @@ -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
> > -- 
> > 2.1.4
> > 
> 
> Regards,
> Keith
> 

-- 
Gaëtan Rivet
6WIND

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

* Re: [dpdk-dev] [PATCH v5 10/19] bus: introduce bus scan policies
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 10/19] bus: introduce bus scan policies Gaetan Rivet
@ 2017-07-04 23:01           ` Thomas Monjalon
  0 siblings, 0 replies; 145+ messages in thread
From: Thomas Monjalon @ 2017-07-04 23:01 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev

21/06/2017 01:35, 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
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
[...]
> @@ -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.

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

* [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing
  2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
                           ` (18 preceding siblings ...)
  2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
@ 2017-07-04 23:56         ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 01/19] net/bonding: properly reference PCI header Gaetan Rivet
                             ` (20 more replies)
  19 siblings, 21 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Bruce Richardson

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

-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 01/19] net/bonding: properly reference PCI header
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 02/19] net/bnxt: " Gaetan Rivet
                             ` (19 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index c718e61..4b99e13 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 02/19] net/bnxt: properly reference PCI header
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 01/19] net/bonding: properly reference PCI header Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 03/19] net/mlx5: " Gaetan Rivet
                             ` (18 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 1538aa5..07279f7 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 03/19] net/mlx5: properly reference PCI header
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 01/19] net/bonding: properly reference PCI header Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 02/19] net/bnxt: " Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 04/19] net/e1000: " Gaetan Rivet
                             ` (17 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 1148dee..9ef2c11 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 04/19] net/e1000: properly reference PCI header
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (2 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 03/19] net/mlx5: " Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 05/19] net/ixgbe: " Gaetan Rivet
                             ` (16 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 9266540..3f521a7 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 05/19] net/ixgbe: properly reference PCI header
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (3 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 04/19] net/e1000: " Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 06/19] net/sfc: " Gaetan Rivet
                             ` (15 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 10b9967..bcbd62d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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

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

* [dpdk-dev] [PATCH v6 06/19] net/sfc: properly reference PCI header
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (4 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 05/19] net/ixgbe: " Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 07/19] app/testpmd: " Gaetan Rivet
                             ` (14 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 007ed24..41dff48 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 07/19] app/testpmd: properly reference PCI header
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (5 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 06/19] net/sfc: " Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 08/19] test: " Gaetan Rivet
                             ` (13 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 364502d..f23114a 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 08/19] test: properly reference PCI header
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (6 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 07/19] app/testpmd: " Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 09/19] dev: device kernel module is a device attribute Gaetan Rivet
                             ` (12 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 test/test/virtual_pmd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/virtual_pmd.c b/test/test/virtual_pmd.c
index db99894..8e698bc 100644
--- a/test/test/virtual_pmd.c
+++ b/test/test/virtual_pmd.c
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 09/19] dev: device kernel module is a device attribute
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (7 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 08/19] test: " Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 10/19] bus: introduce bus scan policies Gaetan Rivet
                             ` (11 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 9f2765d..82c42c7 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -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 {
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 7863f94..884e24c 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -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.
  */
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 10/19] bus: introduce bus scan policies
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (8 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 09/19] dev: device kernel module is a device attribute Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 11/19] devargs: parse bus policies Gaetan Rivet
                             ` (10 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: 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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index aebf57e..37cc230 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -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 */
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 11/19] devargs: parse bus policies
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (9 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 10/19] bus: introduce bus scan policies Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 12/19] devargs: generic device representation Gaetan Rivet
                             ` (9 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 102bd8d..16052a3 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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);
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 12/19] devargs: generic device representation
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (10 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 11/19] devargs: parse bus policies Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 13/19] pci: update device name Gaetan Rivet
                             ` (8 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0a23d82..3b08d41 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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;
 }
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 34fcfa1..b127c0c 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -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);
 }
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 16052a3..7b4dfca 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -40,7 +40,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <rte_pci.h>
 #include <rte_devargs.h>
 #include "eal_private.h"
 
@@ -126,23 +125,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	}
 	devargs->bus = bus;
 
-	switch (devargs->type) {
-	case RTE_DEVTYPE_WHITELISTED_PCI:
-	case RTE_DEVTYPE_BLACKLISTED_PCI:
-		/* try to parse pci identifier */
-		if (bus->parse(devname, &devargs->pci.addr) != 0)
-			goto fail;
-
-		break;
-	case RTE_DEVTYPE_VIRTUAL:
-		/* save driver name */
-		ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", devname);
-		if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name))
-			goto fail;
-
-		break;
-	}
+	/* save device name. */
+	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 (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
@@ -194,27 +180,10 @@ rte_eal_devargs_dump(FILE *f)
 {
 	struct rte_devargs *devargs;
 
-	fprintf(f, "User device white list:\n");
+	fprintf(f, "User device list:\n");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
-			fprintf(f, "  PCI whitelist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI)
-			fprintf(f, "  PCI blacklist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
-			fprintf(f, "  VIRTUAL %s %s\n",
-			       devargs->virt.drv_name,
-			       devargs->args);
-		else
-			fprintf(f, "  UNKNOWN %s\n", devargs->args);
+		fprintf(f, "  [%s]: %s %s\n",
+			(devargs->bus ? devargs->bus->name : "??"),
+			devargs->name, devargs->args);
 	}
 }
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index d7e2fb4..5838cc6 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 8fd1ef7..639ef73 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
 	}
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 1f50a24..6a26d3d 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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;
 };
diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h
index e6b678e..3c07b76 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -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;
 }
 
diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
index 63242f1..18f54ed 100644
--- a/test/test/test_devargs.c
+++ b/test/test/test_devargs.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 13/19] pci: update device name
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (11 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 12/19] devargs: generic device representation Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 14/19] net/virtio: do not reference device type Gaetan Rivet
                             ` (7 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 5838cc6..fa9f1b6 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 14/19] net/virtio: do not reference device type
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (12 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 13/19] pci: update device name Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-05  0:09             ` Gaëtan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 15/19] devargs: generic device types Gaetan Rivet
                             ` (6 subsequent siblings)
  20 siblings, 1 reply; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index b7b3d61..6275359 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 15/19] devargs: generic device types
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (13 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 14/19] net/virtio: do not reference device type Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
                             ` (5 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 7b4dfca..8fe1b39 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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) {
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index f470195..075b0ea 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index fa9f1b6..b8d902b 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 639ef73..517a9f3 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6a26d3d..6e9e134 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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,
 };
 
 /**
diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
index 18f54ed..149c9c9 100644
--- a/test/test/test_devargs.c
+++ b/test/test/test_devargs.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 16/19] devargs: introduce cleaner parsing helper
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (14 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 15/19] devargs: generic device types Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 17/19] devargs: clone function Gaetan Rivet
                             ` (4 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 2e708db..56d0698 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -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``
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 0295ea9..cec3894 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -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;
 
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 8fe1b39..3ea070d 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -86,49 +86,77 @@ bus_name_cmp(const struct rte_bus *bus, const void *_name)
 		       strlen(bus->name));
 }
 
-/* store a whitelist parameter for later parsing */
 int
-rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
+rte_eal_devargs_parse(const char *dev, struct rte_devargs *da)
 {
-	struct rte_devargs *devargs = NULL;
 	struct rte_bus *bus = NULL;
-	char *dev = NULL;
 	const char *devname;
-	int ret;
-
-	/* use malloc instead of rte_malloc as it's called early at init */
-	devargs = malloc(sizeof(*devargs));
-	if (devargs == NULL)
-		goto fail;
-
-	memset(devargs, 0, sizeof(*devargs));
-	devargs->type = devtype;
+	const size_t maxlen = sizeof(da->name);
+	size_t i;
 
-	if (rte_eal_parse_devargs_str(devargs_str, &dev, &devargs->args))
-		goto fail;
-	devname = dev;
+	if (dev == NULL || da == NULL)
+		return -EINVAL;
+	/* Retrieve eventual bus info */
 	do {
+		devname = dev;
 		bus = rte_bus_find(bus, bus_name_cmp, dev);
 		if (bus == NULL)
 			break;
 		devname = dev + strlen(bus->name) + 1;
 		if (rte_bus_find_by_device_name(devname) == bus)
 			break;
-		devname = dev;
 	} while (1);
+	/* Store device name */
+	i = 0;
+	while (devname[i] != '\0' && devname[i] != ',') {
+		da->name[i] = devname[i];
+		i++;
+		if (i == maxlen) {
+			fprintf(stderr, "WARNING: Parsing \"%s\": device name should be shorter than %zu\n",
+				dev, maxlen);
+			da->name[i - 1] = '\0';
+			return -EINVAL;
+		}
+	}
+	da->name[i] = '\0';
 	if (bus == NULL) {
-		bus = rte_bus_find_by_device_name(devname);
+		bus = rte_bus_find_by_device_name(da->name);
 		if (bus == NULL) {
-			fprintf(stderr, "ERROR: failed to parse bus info from device declaration\n");
-			goto fail;
+			fprintf(stderr, "ERROR: failed to parse device \"%s\"\n",
+				da->name);
+			return -EFAULT;
 		}
 	}
-	devargs->bus = bus;
+	da->bus = bus;
+	/* Parse eventual device arguments */
+	if (devname[i] == ',')
+		da->args = strdup(&devname[i + 1]);
+	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)
+{
+	struct rte_devargs *devargs = NULL;
+	struct rte_bus *bus = NULL;
+	const char *dev = devargs_str;
 
-	/* save device name. */
-	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", devname);
-	if (ret < 0 || ret >= (int)sizeof(devargs->name))
+	/* use calloc instead of rte_zmalloc as it's called early at init */
+	devargs = calloc(1, sizeof(*devargs));
+	if (devargs == NULL)
 		goto fail;
+
+	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;
@@ -145,12 +173,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 		}
 	}
 
-	free(dev);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
 	return 0;
 
 fail:
-	free(dev);
 	if (devargs) {
 		free(devargs->args);
 		free(devargs);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6e9e134..2ab8864 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index a118fb1..09b875a 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -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;
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 17/19] devargs: clone function
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (15 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 18/19] devargs: remove function Gaetan Rivet
                             ` (3 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

This function returns a deep copy of an rte_devargs.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index cec3894..05e2475 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 3ea070d..be8951d 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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)
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 2ab8864..892b035 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 09b875a..e9ae497 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 18/19] devargs: remove function
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (16 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 17/19] devargs: clone function Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
                             ` (2 subsequent siblings)
  20 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 05e2475..299b27f 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -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;
 
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index be8951d..7388122 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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)
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 892b035..f61707c 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index e9ae497..6d73e0e 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -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;
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (17 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 18/19] devargs: remove function Gaetan Rivet
@ 2017-07-04 23:56           ` Gaetan Rivet
  2017-07-05  0:23             ` Thomas Monjalon
  2017-07-05 10:27             ` Mcnamara, John
  2017-07-05  0:32           ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Thomas Monjalon
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
  20 siblings, 2 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-04 23:56 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_options.c | 18 +++++++++---------
 lib/librte_eal/common/eal_options.h        |  8 ++++----
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 075b0ea..245a276 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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"
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index a881c62..4c5db07 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -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 */
-- 
2.1.4

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

* Re: [dpdk-dev] [PATCH v6 14/19] net/virtio: do not reference device type
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 14/19] net/virtio: do not reference device type Gaetan Rivet
@ 2017-07-05  0:09             ` Gaëtan Rivet
  0 siblings, 0 replies; 145+ messages in thread
From: Gaëtan Rivet @ 2017-07-05  0:09 UTC (permalink / raw)
  To: dev

On Wed, Jul 05, 2017 at 01:56:44AM +0200, Gaetan Rivet wrote:
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
>  drivers/net/virtio/virtio_pci.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
> index b7b3d61..6275359 100644
> --- a/drivers/net/virtio/virtio_pci.c
> +++ b/drivers/net/virtio/virtio_pci.c
> @@ -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"))) {

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.

>  			PMD_INIT_LOG(INFO,
>  				"skip kernel managed virtio device.");
>  			return 1;
> -- 
> 2.1.4
> 

-- 
Gaëtan Rivet
6WIND

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

* Re: [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
@ 2017-07-05  0:23             ` Thomas Monjalon
  2017-07-05 10:27             ` Mcnamara, John
  1 sibling, 0 replies; 145+ messages in thread
From: Thomas Monjalon @ 2017-07-05  0:23 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev

05/07/2017 01:56, 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.
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>

You forgot the ack from John.

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

* Re: [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (18 preceding siblings ...)
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
@ 2017-07-05  0:32           ` Thomas Monjalon
  2017-07-05  7:46             ` Gaëtan Rivet
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
  20 siblings, 1 reply; 145+ messages in thread
From: Thomas Monjalon @ 2017-07-05  0:32 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev, Jan Blunck, Stephen Hemminger, Bruce Richardson

> 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

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

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

* Re: [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing
  2017-07-05  0:32           ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Thomas Monjalon
@ 2017-07-05  7:46             ` Gaëtan Rivet
  0 siblings, 0 replies; 145+ messages in thread
From: Gaëtan Rivet @ 2017-07-05  7:46 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Jan Blunck, Stephen Hemminger, Bruce Richardson

Hi Thomas,

On Wed, Jul 05, 2017 at 02:32:10AM +0200, Thomas Monjalon wrote:
> > 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
> 
> You forgot my patch "examples/ethtool: explicit PCI header dependency"
> 

Indeed sorry, I missed a few things it seems.

-- 
Gaëtan Rivet
6WIND

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

* Re: [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc
  2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
  2017-07-05  0:23             ` Thomas Monjalon
@ 2017-07-05 10:27             ` Mcnamara, John
  1 sibling, 0 replies; 145+ messages in thread
From: Mcnamara, John @ 2017-07-05 10:27 UTC (permalink / raw)
  To: Gaetan Rivet, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Gaetan Rivet
> Sent: Wednesday, July 5, 2017 12:57 AM
> To: dev@dpdk.org
> Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
> Subject: [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist
> command line doc
> 
> The use of these commands have evolved.
> It is now possible to use whitelist and blacklist on any bus.
> 
> Update the source code accordingly.
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>


Acked-by: John McNamara <john.mcnamara@intel.com>

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

* [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing
  2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
                             ` (19 preceding siblings ...)
  2017-07-05  0:32           ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Thomas Monjalon
@ 2017-07-07  0:04           ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 01/17] net/bonding: properly reference PCI header Gaetan Rivet
                               ` (17 more replies)
  20 siblings, 18 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Bruce Richardson

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

-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 01/17] net/bonding: properly reference PCI header
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 02/17] net/bnxt: " Gaetan Rivet
                               ` (16 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bonding/rte_eth_bond_args.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index a422eb8..4f12050 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -32,6 +32,7 @@
  */
 
 #include <rte_devargs.h>
+#include <rte_pci.h>
 #include <rte_kvargs.h>
 
 #include <cmdline_parse.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 02/17] net/bnxt: properly reference PCI header
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 01/17] net/bonding: properly reference PCI header Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 03/17] net/mlx5: " Gaetan Rivet
                               ` (15 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/bnxt/bnxt.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 1538aa5..07279f7 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 03/17] net/mlx5: properly reference PCI header
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 01/17] net/bonding: properly reference PCI header Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 02/17] net/bnxt: " Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 04/17] net/e1000: " Gaetan Rivet
                               ` (14 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/mlx5/mlx5.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 1148dee..9ef2c11 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 04/17] net/e1000: properly reference PCI header
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (2 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 03/17] net/mlx5: " Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 05/17] net/ixgbe: " Gaetan Rivet
                               ` (13 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/e1000/e1000_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/e1000/e1000_ethdev.h b/drivers/net/e1000/e1000_ethdev.h
index 9266540..3f521a7 100644
--- a/drivers/net/e1000/e1000_ethdev.h
+++ b/drivers/net/e1000/e1000_ethdev.h
@@ -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
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 05/17] net/ixgbe: properly reference PCI header
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (3 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 04/17] net/e1000: " Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 06/17] net/sfc: " Gaetan Rivet
                               ` (12 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 10b9967..bcbd62d 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -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

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

* [dpdk-dev] [PATCH v7 06/17] net/sfc: properly reference PCI header
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (4 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 05/17] net/ixgbe: " Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 07/17] app/testpmd: " Gaetan Rivet
                               ` (11 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/sfc/sfc.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 007ed24..41dff48 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -34,6 +34,7 @@
 
 #include <stdbool.h>
 
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 #include <rte_kvargs.h>
 #include <rte_spinlock.h>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 07/17] app/testpmd: properly reference PCI header
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (5 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 06/17] net/sfc: " Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 08/17] test: " Gaetan Rivet
                               ` (10 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 app/test-pmd/testpmd.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 5cabeef..9cc313e 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -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
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 08/17] test: properly reference PCI header
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (6 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 07/17] app/testpmd: " Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 09/17] examples/ethtool: " Gaetan Rivet
                               ` (9 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 test/test/virtual_pmd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/test/virtual_pmd.c b/test/test/virtual_pmd.c
index db99894..8e698bc 100644
--- a/test/test/virtual_pmd.c
+++ b/test/test/virtual_pmd.c
@@ -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>
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 09/17] examples/ethtool: properly reference PCI header
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (7 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 08/17] test: " Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 10/17] dev: device kernel module is a device attribute Gaetan Rivet
                               ` (8 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Thomas Monjalon

From: Thomas Monjalon <thomas@monjalon.net>

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.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 examples/ethtool/lib/rte_ethtool.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index fabfcb2..252382c 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -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",
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 10/17] dev: device kernel module is a device attribute
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (8 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 09/17] examples/ethtool: " Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 11/17] bus: introduce bus scan policies Gaetan Rivet
                               ` (7 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 0c8f6c8..bcd8b1e 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -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 {
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 406d918..8b12339 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -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.
  */
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 11/17] bus: introduce bus scan policies
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (9 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 10/17] dev: device kernel module is a device attribute Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 12/17] devargs: parse bus policies Gaetan Rivet
                               ` (6 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: 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

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index aebf57e..37cc230 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -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 */
 };
 
 /**
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 12/17] devargs: parse bus policies
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (10 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 11/17] bus: introduce bus scan policies Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-09 14:50               ` Thomas Monjalon
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 13/17] devargs: generic device representation Gaetan Rivet
                               ` (5 subsequent siblings)
  17 siblings, 1 reply; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 102bd8d..16052a3 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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);
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 13/17] devargs: generic device representation
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (11 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 12/17] devargs: parse bus policies Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 14/17] net/virtio: do not reference device type Gaetan Rivet
                               ` (4 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index a7bad73..bce3ecd 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -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;
 }
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 16052a3..7b4dfca 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -40,7 +40,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <rte_pci.h>
 #include <rte_devargs.h>
 #include "eal_private.h"
 
@@ -126,23 +125,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 	}
 	devargs->bus = bus;
 
-	switch (devargs->type) {
-	case RTE_DEVTYPE_WHITELISTED_PCI:
-	case RTE_DEVTYPE_BLACKLISTED_PCI:
-		/* try to parse pci identifier */
-		if (bus->parse(devname, &devargs->pci.addr) != 0)
-			goto fail;
-
-		break;
-	case RTE_DEVTYPE_VIRTUAL:
-		/* save driver name */
-		ret = snprintf(devargs->virt.drv_name,
-			       sizeof(devargs->virt.drv_name), "%s", devname);
-		if (ret < 0 || ret >= (int)sizeof(devargs->virt.drv_name))
-			goto fail;
-
-		break;
-	}
+	/* save device name. */
+	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 (bus->conf.scan_mode == RTE_BUS_SCAN_UNDEFINED) {
 			bus->conf.scan_mode = RTE_BUS_SCAN_WHITELIST;
@@ -194,27 +180,10 @@ rte_eal_devargs_dump(FILE *f)
 {
 	struct rte_devargs *devargs;
 
-	fprintf(f, "User device white list:\n");
+	fprintf(f, "User device list:\n");
 	TAILQ_FOREACH(devargs, &devargs_list, next) {
-		if (devargs->type == RTE_DEVTYPE_WHITELISTED_PCI)
-			fprintf(f, "  PCI whitelist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI)
-			fprintf(f, "  PCI blacklist " PCI_PRI_FMT " %s\n",
-			       devargs->pci.addr.domain,
-			       devargs->pci.addr.bus,
-			       devargs->pci.addr.devid,
-			       devargs->pci.addr.function,
-			       devargs->args);
-		else if (devargs->type == RTE_DEVTYPE_VIRTUAL)
-			fprintf(f, "  VIRTUAL %s %s\n",
-			       devargs->virt.drv_name,
-			       devargs->args);
-		else
-			fprintf(f, "  UNKNOWN %s\n", devargs->args);
+		fprintf(f, "  [%s]: %s %s\n",
+			(devargs->bus ? devargs->bus->name : "??"),
+			devargs->name, devargs->args);
 	}
 }
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index d7e2fb4..5838cc6 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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;
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 8fd1ef7..639ef73 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
 	}
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 6014853..35675fa 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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;
 };
diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h
index e6b678e..3c07b76 100644
--- a/lib/librte_eal/common/include/rte_vdev.h
+++ b/lib/librte_eal/common/include/rte_vdev.h
@@ -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;
 }
 
diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
index 63242f1..18f54ed 100644
--- a/test/test/test_devargs.c
+++ b/test/test/test_devargs.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 14/17] net/virtio: do not reference device type
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (12 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 13/17] devargs: generic device representation Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 15/17] devargs: generic device types Gaetan Rivet
                               ` (3 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: Gaetan Rivet

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/virtio/virtio_pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index b7b3d61..e6eda75 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 15/17] devargs: generic device types
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (13 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 14/17] net/virtio: do not reference device type Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 16/17] devargs: introduce cleaner parsing helper Gaetan Rivet
                               ` (2 subsequent siblings)
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 7b4dfca..8fe1b39 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -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) {
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index f470195..075b0ea 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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;
 }
 
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 5838cc6..e03a407 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -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
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 639ef73..517a9f3 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -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);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 35675fa..a5c4a4a 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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,
 };
 
 /**
diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
index 18f54ed..149c9c9 100644
--- a/test/test/test_devargs.c
+++ b/test/test/test_devargs.c
@@ -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;
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 16/17] devargs: introduce cleaner parsing helper
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (14 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 15/17] devargs: generic device types Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 17/17] eal: change whitelist / blacklist command line doc Gaetan Rivet
  2017-07-08 22:28             ` [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing Thomas Monjalon
  17 siblings, 0 replies; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 2e708db..56d0698 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -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``
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 0295ea9..381f895 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -206,6 +206,7 @@ DPDK_17.08 {
 EXPERIMENTAL {
 	global:
 
+	rte_eal_devargs_parse;
 	rte_eal_hotplug_add;
 	rte_eal_hotplug_remove;
 
diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
index 8fe1b39..3ea070d 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -86,49 +86,77 @@ bus_name_cmp(const struct rte_bus *bus, const void *_name)
 		       strlen(bus->name));
 }
 
-/* store a whitelist parameter for later parsing */
 int
-rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
+rte_eal_devargs_parse(const char *dev, struct rte_devargs *da)
 {
-	struct rte_devargs *devargs = NULL;
 	struct rte_bus *bus = NULL;
-	char *dev = NULL;
 	const char *devname;
-	int ret;
-
-	/* use malloc instead of rte_malloc as it's called early at init */
-	devargs = malloc(sizeof(*devargs));
-	if (devargs == NULL)
-		goto fail;
-
-	memset(devargs, 0, sizeof(*devargs));
-	devargs->type = devtype;
+	const size_t maxlen = sizeof(da->name);
+	size_t i;
 
-	if (rte_eal_parse_devargs_str(devargs_str, &dev, &devargs->args))
-		goto fail;
-	devname = dev;
+	if (dev == NULL || da == NULL)
+		return -EINVAL;
+	/* Retrieve eventual bus info */
 	do {
+		devname = dev;
 		bus = rte_bus_find(bus, bus_name_cmp, dev);
 		if (bus == NULL)
 			break;
 		devname = dev + strlen(bus->name) + 1;
 		if (rte_bus_find_by_device_name(devname) == bus)
 			break;
-		devname = dev;
 	} while (1);
+	/* Store device name */
+	i = 0;
+	while (devname[i] != '\0' && devname[i] != ',') {
+		da->name[i] = devname[i];
+		i++;
+		if (i == maxlen) {
+			fprintf(stderr, "WARNING: Parsing \"%s\": device name should be shorter than %zu\n",
+				dev, maxlen);
+			da->name[i - 1] = '\0';
+			return -EINVAL;
+		}
+	}
+	da->name[i] = '\0';
 	if (bus == NULL) {
-		bus = rte_bus_find_by_device_name(devname);
+		bus = rte_bus_find_by_device_name(da->name);
 		if (bus == NULL) {
-			fprintf(stderr, "ERROR: failed to parse bus info from device declaration\n");
-			goto fail;
+			fprintf(stderr, "ERROR: failed to parse device \"%s\"\n",
+				da->name);
+			return -EFAULT;
 		}
 	}
-	devargs->bus = bus;
+	da->bus = bus;
+	/* Parse eventual device arguments */
+	if (devname[i] == ',')
+		da->args = strdup(&devname[i + 1]);
+	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)
+{
+	struct rte_devargs *devargs = NULL;
+	struct rte_bus *bus = NULL;
+	const char *dev = devargs_str;
 
-	/* save device name. */
-	ret = snprintf(devargs->name, sizeof(devargs->name), "%s", devname);
-	if (ret < 0 || ret >= (int)sizeof(devargs->name))
+	/* use calloc instead of rte_zmalloc as it's called early at init */
+	devargs = calloc(1, sizeof(*devargs));
+	if (devargs == NULL)
 		goto fail;
+
+	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;
@@ -145,12 +173,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)
 		}
 	}
 
-	free(dev);
 	TAILQ_INSERT_TAIL(&devargs_list, devargs, next);
 	return 0;
 
 fail:
-	free(dev);
 	if (devargs) {
 		free(devargs->args);
 		free(devargs);
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index a5c4a4a..a0427cd 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -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
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index a118fb1..0f9e009 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -211,6 +211,7 @@ DPDK_17.08 {
 EXPERIMENTAL {
 	global:
 
+	rte_eal_devargs_parse;
 	rte_eal_hotplug_add;
 	rte_eal_hotplug_remove;
 
-- 
2.1.4

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

* [dpdk-dev] [PATCH v7 17/17] eal: change whitelist / blacklist command line doc
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (15 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 16/17] devargs: introduce cleaner parsing helper Gaetan Rivet
@ 2017-07-07  0:04             ` Gaetan Rivet
  2017-07-08 22:25               ` Thomas Monjalon
  2017-07-08 22:28             ` [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing Thomas Monjalon
  17 siblings, 1 reply; 145+ messages in thread
From: Gaetan Rivet @ 2017-07-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: 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.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
---
 lib/librte_eal/common/eal_common_options.c | 18 +++++++++---------
 lib/librte_eal/common/eal_options.h        |  8 ++++----
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 075b0ea..245a276 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -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"
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index a881c62..4c5db07 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -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 */
-- 
2.1.4

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

* Re: [dpdk-dev] [PATCH v7 17/17] eal: change whitelist / blacklist command line doc
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 17/17] eal: change whitelist / blacklist command line doc Gaetan Rivet
@ 2017-07-08 22:25               ` Thomas Monjalon
  0 siblings, 0 replies; 145+ messages in thread
From: Thomas Monjalon @ 2017-07-08 22:25 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev

07/07/2017 02:04, 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.
> 
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> Acked-by: John McNamara <john.mcnamara@intel.com>
> ---
[...]
> --- a/lib/librte_eal/common/eal_options.h
> +++ b/lib/librte_eal/common/eal_options.h
> @@ -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',

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.

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

* Re: [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing
  2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
                               ` (16 preceding siblings ...)
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 17/17] eal: change whitelist / blacklist command line doc Gaetan Rivet
@ 2017-07-08 22:28             ` Thomas Monjalon
  2017-07-09  8:37               ` Jan Blunck
  17 siblings, 1 reply; 145+ messages in thread
From: Thomas Monjalon @ 2017-07-08 22:28 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev, Jan Blunck, Stephen Hemminger, Bruce Richardson

07/07/2017 02:04, Gaetan Rivet:
> 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.
[...]
> 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

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

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

* Re: [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing
  2017-07-08 22:28             ` [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing Thomas Monjalon
@ 2017-07-09  8:37               ` Jan Blunck
  2017-07-09 10:17                 ` Thomas Monjalon
  0 siblings, 1 reply; 145+ messages in thread
From: Jan Blunck @ 2017-07-09  8:37 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Gaetan Rivet, dev, Stephen Hemminger, Bruce Richardson

On Sat, Jul 8, 2017 at 6:28 PM, Thomas Monjalon <thomas@monjalon.net> wrote:
> 07/07/2017 02:04, Gaetan Rivet:
>> 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.
> [...]
>> 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
>
> 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).

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

* Re: [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing
  2017-07-09  8:37               ` Jan Blunck
@ 2017-07-09 10:17                 ` Thomas Monjalon
  2017-07-09 11:16                   ` Jan Blunck
  0 siblings, 1 reply; 145+ messages in thread
From: Thomas Monjalon @ 2017-07-09 10:17 UTC (permalink / raw)
  To: Jan Blunck; +Cc: dev, Gaetan Rivet, Stephen Hemminger, Bruce Richardson

09/07/2017 10:37, Jan Blunck:
> On Sat, Jul 8, 2017 at 6:28 PM, Thomas Monjalon <thomas@monjalon.net> wrote:
> > 07/07/2017 02:04, Gaetan Rivet:
> >> 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.
> > [...]
> >> 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
> >
> > 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?

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

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

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

* Re: [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing
  2017-07-09 10:17                 ` Thomas Monjalon
@ 2017-07-09 11:16                   ` Jan Blunck
  2017-07-09 11:29                     ` Gaëtan Rivet
  0 siblings, 1 reply; 145+ messages in thread
From: Jan Blunck @ 2017-07-09 11:16 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Gaetan Rivet, Stephen Hemminger, Bruce Richardson

On Sun, Jul 9, 2017 at 6:17 AM, Thomas Monjalon <thomas@monjalon.net> wrote:
> 09/07/2017 10:37, Jan Blunck:
>> On Sat, Jul 8, 2017 at 6:28 PM, Thomas Monjalon <thomas@monjalon.net> wrote:
>> > 07/07/2017 02:04, Gaetan Rivet:
>> >> 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.
>> > [...]
>> >> 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
>> >
>> > 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.

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


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

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

* Re: [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing
  2017-07-09 11:16                   ` Jan Blunck
@ 2017-07-09 11:29                     ` Gaëtan Rivet
  0 siblings, 0 replies; 145+ messages in thread
From: Gaëtan Rivet @ 2017-07-09 11:29 UTC (permalink / raw)
  To: Jan Blunck; +Cc: Thomas Monjalon, dev, Stephen Hemminger, Bruce Richardson

On Sun, Jul 09, 2017 at 07:16:45AM -0400, Jan Blunck wrote:
> On Sun, Jul 9, 2017 at 6:17 AM, Thomas Monjalon <thomas@monjalon.net> wrote:
> > 09/07/2017 10:37, Jan Blunck:
> >> On Sat, Jul 8, 2017 at 6:28 PM, Thomas Monjalon <thomas@monjalon.net> wrote:
> >> > 07/07/2017 02:04, Gaetan Rivet:
> >> >> 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.
> >> > [...]
> >> >> 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
> >> >
> >> > 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.
> 
> (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.

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

-- 
Gaëtan Rivet
6WIND

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

* Re: [dpdk-dev] [PATCH v7 12/17] devargs: parse bus policies
  2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 12/17] devargs: parse bus policies Gaetan Rivet
@ 2017-07-09 14:50               ` Thomas Monjalon
  0 siblings, 0 replies; 145+ messages in thread
From: Thomas Monjalon @ 2017-07-09 14:50 UTC (permalink / raw)
  To: Gaetan Rivet; +Cc: dev, jblunck, matan

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:
> --- a/lib/librte_eal/common/eal_common_devargs.c
> +++ b/lib/librte_eal/common/eal_common_devargs.c
> @@ -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;
> +		}
> +	}

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

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

end of thread, other threads:[~2017-07-09 14:50 UTC | newest]

Thread overview: 145+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-24 15:14 [dpdk-dev] [PATCH 00/14] Generic devargs parsing Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 01/14] net/bonding: properly reference PCI header Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 02/14] net/bnxt: " Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 03/14] net/mlx5: " Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 04/14] net/e1000: " Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 05/14] net/ixgbe: " Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 06/14] net/sfc: " Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 07/14] app/testpmd: " Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 08/14] dev: device kernel module is a device attribute Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 09/14] bus: introduce bus scan policies Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 10/14] devargs: parse bus policies Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 11/14] devargs: generic device representation Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 12/14] net/virtio: do not reference device type Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 13/14] devargs: generic device types Gaetan Rivet
2017-05-24 15:14 ` [dpdk-dev] [PATCH 14/14] devargs: introduce cleaner parsing helper Gaetan Rivet
2017-05-24 16:16 ` [dpdk-dev] [PATCH v2 00/14] Generic devargs parsing Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 01/14] net/bonding: properly reference PCI header Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 02/14] net/bnxt: " Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 03/14] net/mlx5: " Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 04/14] net/e1000: " Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 05/14] net/ixgbe: " Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 06/14] net/sfc: " Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 07/14] app/testpmd: " Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 08/14] dev: device kernel module is a device attribute Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 09/14] bus: introduce bus scan policies Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 10/14] devargs: parse bus policies Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 11/14] devargs: generic device representation Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 12/14] net/virtio: do not reference device type Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 13/14] devargs: generic device types Gaetan Rivet
2017-05-24 16:16   ` [dpdk-dev] [PATCH v2 14/14] devargs: introduce cleaner parsing helper Gaetan Rivet
2017-06-01 10:10   ` [dpdk-dev] [PATCH v3 00/14] Generic devargs parsing Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 01/14] net/bonding: properly reference PCI header Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 02/14] net/bnxt: " Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 03/14] net/mlx5: " Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 04/14] net/e1000: " Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 05/14] net/ixgbe: " Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 06/14] net/sfc: " Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 07/14] app/testpmd: " Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 08/14] dev: device kernel module is a device attribute Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 09/14] bus: introduce bus scan policies Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 10/14] devargs: parse bus policies Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 11/14] devargs: generic device representation Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 12/14] net/virtio: do not reference device type Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 13/14] devargs: generic device types Gaetan Rivet
2017-06-01 10:10     ` [dpdk-dev] [PATCH v3 14/14] devargs: introduce cleaner parsing helper Gaetan Rivet
2017-06-07 23:56     ` [dpdk-dev] [PATCH v4 00/19] Generic devargs parsing Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 01/19] net/bonding: properly reference PCI header Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 02/19] net/bnxt: " Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 03/19] net/mlx5: " Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 04/19] net/e1000: " Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 05/19] net/ixgbe: " Gaetan Rivet
2017-06-14  9:33         ` Dai, Wei
2017-06-14  9:48           ` Gaëtan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 06/19] net/sfc: " Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 07/19] app/testpmd: " Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 08/19] test: " Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 09/19] dev: device kernel module is a device attribute Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 10/19] bus: introduce bus scan policies Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 11/19] devargs: parse bus policies Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 12/19] devargs: generic device representation Gaetan Rivet
2017-06-07 23:56       ` [dpdk-dev] [PATCH v4 13/19] pci: update device name Gaetan Rivet
2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 14/19] net/virtio: do not reference device type Gaetan Rivet
2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 15/19] devargs: generic device types Gaetan Rivet
2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 17/19] devargs: clone function Gaetan Rivet
2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 18/19] devargs: remove function Gaetan Rivet
2017-06-07 23:57       ` [dpdk-dev] [PATCH v4 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
2017-06-20 23:35       ` [dpdk-dev] [PATCH v5 00/19] Generic devargs parsing Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 01/19] net/bonding: properly reference PCI header Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 02/19] net/bnxt: " Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 03/19] net/mlx5: " Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 04/19] net/e1000: " Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 05/19] net/ixgbe: " Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 06/19] net/sfc: " Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 07/19] app/testpmd: " Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 08/19] test: " Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 09/19] dev: device kernel module is a device attribute Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 10/19] bus: introduce bus scan policies Gaetan Rivet
2017-07-04 23:01           ` Thomas Monjalon
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 11/19] devargs: parse bus policies Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 12/19] devargs: generic device representation Gaetan Rivet
2017-06-28  7:44           ` Thomas Monjalon
2017-06-28  8:05             ` Gaëtan Rivet
2017-06-28 14:18           ` [dpdk-dev] [PATCH] examples/ethtool: explicit PCI header dependency Thomas Monjalon
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 13/19] pci: update device name Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 14/19] net/virtio: do not reference device type Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 15/19] devargs: generic device types Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
2017-06-27 22:19           ` Thomas Monjalon
2017-06-27 23:46           ` Wiles, Keith
2017-07-04 21:50             ` Gaëtan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 17/19] devargs: clone function Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 18/19] devargs: remove function Gaetan Rivet
2017-06-20 23:35         ` [dpdk-dev] [PATCH v5 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
2017-06-26 14:58           ` Mcnamara, John
2017-07-04 23:56         ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 01/19] net/bonding: properly reference PCI header Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 02/19] net/bnxt: " Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 03/19] net/mlx5: " Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 04/19] net/e1000: " Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 05/19] net/ixgbe: " Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 06/19] net/sfc: " Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 07/19] app/testpmd: " Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 08/19] test: " Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 09/19] dev: device kernel module is a device attribute Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 10/19] bus: introduce bus scan policies Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 11/19] devargs: parse bus policies Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 12/19] devargs: generic device representation Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 13/19] pci: update device name Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 14/19] net/virtio: do not reference device type Gaetan Rivet
2017-07-05  0:09             ` Gaëtan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 15/19] devargs: generic device types Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 16/19] devargs: introduce cleaner parsing helper Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 17/19] devargs: clone function Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 18/19] devargs: remove function Gaetan Rivet
2017-07-04 23:56           ` [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc Gaetan Rivet
2017-07-05  0:23             ` Thomas Monjalon
2017-07-05 10:27             ` Mcnamara, John
2017-07-05  0:32           ` [dpdk-dev] [PATCH v6 00/19] Generic devargs parsing Thomas Monjalon
2017-07-05  7:46             ` Gaëtan Rivet
2017-07-07  0:04           ` [dpdk-dev] [PATCH v7 00/17] " Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 01/17] net/bonding: properly reference PCI header Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 02/17] net/bnxt: " Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 03/17] net/mlx5: " Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 04/17] net/e1000: " Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 05/17] net/ixgbe: " Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 06/17] net/sfc: " Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 07/17] app/testpmd: " Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 08/17] test: " Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 09/17] examples/ethtool: " Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 10/17] dev: device kernel module is a device attribute Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 11/17] bus: introduce bus scan policies Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 12/17] devargs: parse bus policies Gaetan Rivet
2017-07-09 14:50               ` Thomas Monjalon
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 13/17] devargs: generic device representation Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 14/17] net/virtio: do not reference device type Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 15/17] devargs: generic device types Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 16/17] devargs: introduce cleaner parsing helper Gaetan Rivet
2017-07-07  0:04             ` [dpdk-dev] [PATCH v7 17/17] eal: change whitelist / blacklist command line doc Gaetan Rivet
2017-07-08 22:25               ` Thomas Monjalon
2017-07-08 22:28             ` [dpdk-dev] [PATCH v7 00/17] Generic devargs parsing Thomas Monjalon
2017-07-09  8:37               ` Jan Blunck
2017-07-09 10:17                 ` Thomas Monjalon
2017-07-09 11:16                   ` Jan Blunck
2017-07-09 11:29                     ` Gaëtan Rivet

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