Generic devargs parsing
Subsystems (2)
cover Generic devargs parsing
The second part of the work outlined in [1] and [2]. The first part is at [3].
In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.
The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.
Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.
With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.
Buses needs only to implement the "parse" method for their devices to be declared in this way.
[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html
This patchset depends on:
[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/
Gaetan Rivet (14):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
app/test-pmd/testpmd.c | 9 +- app/test-pmd/testpmd.h | 2 + doc/guides/rel_notes/deprecation.rst | 5 + drivers/net/bnxt/bnxt.h | 1 + drivers/net/bonding/rte_eth_bond_args.c | 1 + drivers/net/e1000/e1000_ethdev.h | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/sfc/sfc.h | 1 + drivers/net/virtio/virtio_pci.c | 5 +- lib/librte_eal/common/eal_common_devargs.c | 137 ++++++++++++++++------------ lib/librte_eal/common/eal_common_options.c | 13 +-- lib/librte_eal/common/eal_common_pci.c | 15 +-- lib/librte_eal/common/eal_common_vdev.c | 12 +-- lib/librte_eal/common/include/rte_bus.h | 17 ++++ lib/librte_eal/common/include/rte_dev.h | 12 +++ lib/librte_eal/common/include/rte_devargs.h | 42 +++++---- lib/librte_eal/common/include/rte_pci.h | 9 -- lib/librte_eal/common/include/rte_vdev.h | 2 +- 19 files changed, 167 insertions(+), 119 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/14 net/bonding: properly reference PCI header
--- drivers/net/bonding/rte_eth_bond_args.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
@@ -32,6 +32,7 @@*/ #include <rte_devargs.h> +#include <rte_pci.h> #include <rte_kvargs.h> #include <cmdline_parse.h>
Signature · 1 line
2.1.4
PATCH 2/14 net/bnxt: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/bnxt/bnxt.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
@@ -37,6 +37,7 @@#include <inttypes.h> #include <sys/queue.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_memory.h> #include <rte_lcore.h>
Signature · 1 line
2.1.4
PATCH 3/14 net/mlx5: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/mlx5/mlx5.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -54,6 +54,7 @@#ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"#endif +#include <rte_pci.h> #include <rte_ether.h> #include <rte_ethdev.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH 4/14 net/e1000: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/e1000/e1000_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
@@ -34,6 +34,7 @@#ifndef _E1000_ETHDEV_H_#define _E1000_ETHDEV_H_#include <rte_time.h> +#include <rte_pci.h> #define E1000_INTEL_VENDOR_ID 0x8086
Signature · 1 line
2.1.4
PATCH 5/14 net/ixgbe: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -39,6 +39,7 @@#include "ixgbe_bypass.h" #include <rte_time.h> #include <rte_hash.h> +#include <rte_pci.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
PATCH 6/14 net/sfc: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/sfc/sfc.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
@@ -34,6 +34,7 @@#include <stdbool.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_kvargs.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH 7/14 app/testpmd: properly reference PCI header
In reply to Gaetan Rivet--- app/test-pmd/testpmd.h | 2 ++ 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
@@ -34,6 +34,8 @@#ifndef _TESTPMD_H_#define _TESTPMD_H_ +#include <rte_pci.h> +#define RTE_PORT_ALL (~(portid_t)0x0)#define RTE_TEST_RX_DESC_MAX 2048
Signature · 1 line
2.1.4
PATCH 8/14 dev: device kernel module is a device attribute
In reply to Gaetan RivetIt is used in generic device structures and must not be tied to a bus.
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) }while (0 )/** +* Device driver. +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , + RTE_KDRV_NONE, +}; + +/** * A generic memory resource representation. */ struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -149,15 +149,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.1.4
PATCH 9/14 bus: introduce bus scan policies
In reply to Gaetan RivetScan policies describe the way a bus should scan the system to search for possible devices.
Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices
--- lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
@@ -123,6 +123,22 @@ typedef int (*rte_bus_detach_t)(struct rte_device *dev);typedef int (*rte_bus_parse_t )(const char *name,void *addr);/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_WHITELIST , +RTE_BUS_SCAN_BLACKLIST , +}; + +/** +* A structure used to configure bus operations. +*/ +struct rte_bus_conf { +enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ +}; + +/** * A structure describing a generic bus. */ struct rte_bus {
@@ -134,6 +150,7 @@ struct rte_bus {rte_bus_attach_t attach;/**< Probe single device for drivers */ rte_bus_detach_t detach;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +struct rte_bus_conf conf;/**< Bus configuration */ };/**
Signature · 1 line
2.1.4
PATCH 10/14 devargs: parse bus policies
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
@@ -130,6 +130,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)break ; } +if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }free (buf);TAILQ_INSERT_TAIL (&devargs_list, devargs, next);
Signature · 1 line
2.1.4
PATCH 11/14 devargs: generic device representation
In reply to Gaetan RivetRemove the dependency of this subsystem upon bus specific device representation.
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
--- app/test-pmd/testpmd.c | 9 ++---- lib/librte_eal/common/eal_common_devargs.c | 48 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 11 +++---- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- 6 files changed, 24 insertions(+), 71 deletions(-)
app/test-pmd/testpmd.c +2 -7
@@ -1807,7 +1807,6 @@ rmv_event_callback(void *arg) {struct rte_eth_dev *dev;struct rte_devargs *da; -char name[32 ] ="" ;uint8_t port_id = (intptr_t )arg;RTE_ETH_VALID_PORTID_OR_RET (port_id);
@@ -1816,12 +1815,8 @@ rmv_event_callback(void *arg)stop_port (port_id);close_port (port_id); -if (da->type ==RTE_DEVTYPE_VIRTUAL ) -snprintf (name,sizeof (name),"%s" , da->virt.drv_name); -else if (da->type ==RTE_DEVTYPE_WHITELISTED_PCI ) -rte_pci_device_name (&da->pci.addr, name,sizeof (name)); -printf ("removing device %s\n" , name); -rte_eal_dev_detach (name); +printf ("removing device %s\n" , da->name); +rte_eal_dev_detach (da->name); dev->state =RTE_ETH_DEV_UNUSED ; }
lib/librte_eal/common/eal_common_devargs.c +8 -40
66 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +6 -3
@@ -102,12 +102,15 @@ const char *pci_get_sysfs_path(void)static struct rte_devargs *pci_devargs_lookup (struct rte_pci_device *dev) {struct rte_devargs *devargs; +struct rte_pci_addr addr; +struct rte_bus *pbus; + pbus =rte_bus_from_name (PCI_BUS_NAME ); TAILQ_FOREACH(devargs, &devargs_list, next) { -if (devargs->type !=RTE_DEVTYPE_BLACKLISTED_PCI && - devargs->type !=RTE_DEVTYPE_WHITELISTED_PCI ) +if (devargs->bus != pbus)continue ; -if (!rte_eal_compare_pci_addr (&dev->addr, &devargs->pci.addr)) + devargs->bus->parse (devargs->name, &addr); +if (!rte_eal_compare_pci_addr (&dev->addr, &addr))return devargs; }return NULL ;
lib/librte_eal/common/eal_common_vdev.c +5 -6
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)if (args) devargs->args =strdup (args); - ret =snprintf (devargs->virt.drv_name, -sizeof (devargs->virt.drv_name),"%s" , name); -if (ret <0 || ret >= (int )sizeof (devargs->virt.drv_name)) { + ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , name); +if (ret <0 || ret >= (int )sizeof (devargs->name)) {free (devargs->args);free (devargs);return NULL ;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name; ret =vdev_probe_all_drivers (dev);if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)if (devargs->bus != vbus)continue ; - dev =find_vdev (devargs->virt.drv_name); + dev =find_vdev (devargs->name);if (dev)continue ;
@@ -314,7 +313,7 @@ vdev_scan(void) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name;TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); }
lib/librte_eal/common/include/rte_devargs.h +2 -14
@@ -50,7 +50,6 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> -#include <rte_pci.h> #include <rte_bus.h> /**
@@ -77,21 +76,10 @@ struct rte_devargs {TAILQ_ENTRY (rte_devargs) next;/** Type of device. */ enum rte_devtype type; -RTE_STD_C11 - union { -/** Used if type is RTE_DEVTYPE_*_PCI. */ -struct { -/** PCI location. */ -struct rte_pci_addr addr; - } pci; -/** Used if type is RTE_DEVTYPE_VIRTUAL. */ -struct { -/** Driver name. */ -char drv_name[32 ]; - } virt; - };/** Bus handle for the device. */ struct rte_bus *bus; +/** Name of the device. */ +char name[32 ];/** Arguments string as given by user or "" for no argument. */ char *args; };
lib/librte_eal/common/include/rte_vdev.h +1 -1
@@ -52,7 +52,7 @@ static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) {if (dev && dev->device.devargs) -return dev->device.devargs->virt.drv_name; +return dev->device.devargs->name;return NULL ; }
Signature · 1 line
2.1.4
PATCH 12/14 net/virtio: do not reference device type
In reply to Gaetan Rivet--- drivers/net/virtio/virtio_pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
@@ -38,6 +38,7 @@#endif #include <rte_io.h> +#include <rte_bus.h> #include "virtio_pci.h" #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)if (rte_pci_ioport_map (dev,0 ,VTPCI_IO (hw)) <0 ) {if (dev->kdrv ==RTE_KDRV_UNKNOWN && (!dev->device.devargs || - dev->device.devargs->type != -RTE_DEVTYPE_WHITELISTED_PCI )) { + dev->device.devargs->bus != +rte_bus_from_name (PCI_BUS_NAME ))) {PMD_INIT_LOG (INFO ,"skip kernel managed virtio device." );return 1 ;
Signature · 1 line
2.1.4
PATCH 13/14 devargs: generic device types
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 4 ++-- lib/librte_eal/common/eal_common_options.c | 13 +++---------- lib/librte_eal/common/eal_common_pci.c | 6 +++--- lib/librte_eal/common/eal_common_vdev.c | 1 - lib/librte_eal/common/include/rte_devargs.h | 6 +++--- 5 files changed, 11 insertions(+), 19 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
@@ -115,14 +115,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , buf);if (ret <0 || ret >= (int )sizeof (devargs->name)) goto fail; -if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (devargs->type ==RTE_DEVTYPE_WHITELISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) {fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); goto fail; } - }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) {
lib/librte_eal/common/eal_common_options.c +3 -10
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,switch (opt) {/* blacklist */ case 'b' : -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED , optarg) <0 ) {return -1 ; }break ;/* whitelist */ case 'w' : -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED , optarg) <0 ) {return -1 ; }
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,break ;case OPT_VDEV_NUM : -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL , +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , optarg) <0 ) {return -1 ; }
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)return -1 ; } -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=0 && -rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=0 ) { -RTE_LOG (ERR ,EAL ,"Options blacklist (-b) and whitelist (-w) " -"cannot be used at the same time\n" ); -return -1 ; - } -return 0 ; }
lib/librte_eal/common/eal_common_pci.c +3 -3
@@ -229,7 +229,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* no initialization when blacklisted, return without error */ if (dev->device.devargs !=NULL && dev->device.devargs->type == -RTE_DEVTYPE_BLACKLISTED_PCI ) { +RTE_DEVTYPE_BLACKLISTED ) {RTE_LOG (INFO ,EAL ," Device is blacklisted, not" " initializing\n" );return 1 ;
@@ -416,7 +416,7 @@ rte_pci_probe(void)int probe_all =0 ;int ret =0 ; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) ==0 ) +if (rte_pci_bus.bus.conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) probe_all =1 ;FOREACH_DEVICE_ON_PCIBUS (dev) {
@@ -431,7 +431,7 @@ rte_pci_probe(void)if (probe_all) ret =pci_probe_all_drivers (dev);else if (devargs !=NULL && - devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) + devargs->type ==RTE_DEVTYPE_WHITELISTED ) ret =pci_probe_all_drivers (dev);if (ret <0 ) { RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)if (!devargs)return NULL ; - devargs->type =RTE_DEVTYPE_VIRTUAL ; devargs->bus =rte_bus_from_name (VIRTUAL_BUS_NAME );if (args) devargs->args =strdup (args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
@@ -56,9 +56,9 @@ extern "C" {* Type of generic device */ enum rte_devtype { -RTE_DEVTYPE_WHITELISTED_PCI , -RTE_DEVTYPE_BLACKLISTED_PCI , -RTE_DEVTYPE_VIRTUAL , +RTE_DEVTYPE_UNDEFINED , +RTE_DEVTYPE_WHITELISTED , +RTE_DEVTYPE_BLACKLISTED , };/**
Signature · 1 line
2.1.4
PATCH 14/14 devargs: introduce cleaner parsing helper
In reply to Gaetan RivetIntroduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.
The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.
A deprecation notice is issued.
This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.
--- doc/guides/rel_notes/deprecation.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 86 ++++++++++++++++++++--------- lib/librte_eal/common/include/rte_devargs.h | 20 +++++++ 3 files changed, 85 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
@@ -128,3 +128,8 @@ Deprecation Notices The non-"do-sig" versions of the hash tables will be removed (including the ``signature_offset`` parameter) and the "do-sig" versions renamed accordingly. + +* eal: the following function is deprecated starting from 17.08 and will + be removed in 17.11: + + - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +60 -26
116 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +20 -0
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs);/** +* Parse a device string. +* +* Verify that a bus is capable of handling the device passed +* in argument. Store which bus will handle the device, its name +* and the eventual device parameters. +* +* @param dev +* The device declaration string. +* @param da +* The devargs structure holding the device information. +* +* @return +* - 0 on success. +* - Negative errno on error. +*/ +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
v2 cover Generic devargs parsing
In reply to Gaetan RivetThe second part of the work outlined in [1] and [2]. The first part is at [3].
In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.
The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.
Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.
With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.
Buses needs only to implement the "parse" method for their devices to be declared in this way.
[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html
This patchset depends on:
[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/
v1 -> v2:
* fix PCI whitelist mode
Gaetan Rivet (14):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
app/test-pmd/testpmd.c | 9 +- app/test-pmd/testpmd.h | 2 + doc/guides/rel_notes/deprecation.rst | 5 + drivers/net/bnxt/bnxt.h | 1 + drivers/net/bonding/rte_eth_bond_args.c | 1 + drivers/net/e1000/e1000_ethdev.h | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/sfc/sfc.h | 1 + drivers/net/virtio/virtio_pci.c | 5 +- lib/librte_eal/common/eal_common_devargs.c | 137 ++++++++++++++++------------ lib/librte_eal/common/eal_common_options.c | 13 +-- lib/librte_eal/common/eal_common_pci.c | 15 +-- lib/librte_eal/common/eal_common_vdev.c | 12 +-- lib/librte_eal/common/include/rte_bus.h | 17 ++++ lib/librte_eal/common/include/rte_dev.h | 12 +++ lib/librte_eal/common/include/rte_devargs.h | 42 +++++---- lib/librte_eal/common/include/rte_pci.h | 9 -- lib/librte_eal/common/include/rte_vdev.h | 2 +- 19 files changed, 167 insertions(+), 119 deletions(-)
Signature · 1 line
2.1.4
PATCH v2 1/14 net/bonding: properly reference PCI header
--- drivers/net/bonding/rte_eth_bond_args.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
@@ -32,6 +32,7 @@*/ #include <rte_devargs.h> +#include <rte_pci.h> #include <rte_kvargs.h> #include <cmdline_parse.h>
Signature · 1 line
2.1.4
PATCH v2 2/14 net/bnxt: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/bnxt/bnxt.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
@@ -37,6 +37,7 @@#include <inttypes.h> #include <sys/queue.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_memory.h> #include <rte_lcore.h>
Signature · 1 line
2.1.4
PATCH v2 3/14 net/mlx5: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/mlx5/mlx5.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -54,6 +54,7 @@#ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"#endif +#include <rte_pci.h> #include <rte_ether.h> #include <rte_ethdev.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v2 4/14 net/e1000: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/e1000/e1000_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
@@ -34,6 +34,7 @@#ifndef _E1000_ETHDEV_H_#define _E1000_ETHDEV_H_#include <rte_time.h> +#include <rte_pci.h> #define E1000_INTEL_VENDOR_ID 0x8086
Signature · 1 line
2.1.4
PATCH v2 5/14 net/ixgbe: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -39,6 +39,7 @@#include "ixgbe_bypass.h" #include <rte_time.h> #include <rte_hash.h> +#include <rte_pci.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
PATCH v2 6/14 net/sfc: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/sfc/sfc.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
@@ -34,6 +34,7 @@#include <stdbool.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_kvargs.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v2 7/14 app/testpmd: properly reference PCI header
In reply to Gaetan Rivet--- app/test-pmd/testpmd.h | 2 ++ 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
@@ -34,6 +34,8 @@#ifndef _TESTPMD_H_#define _TESTPMD_H_ +#include <rte_pci.h> +#define RTE_PORT_ALL (~(portid_t)0x0)#define RTE_TEST_RX_DESC_MAX 2048
Signature · 1 line
2.1.4
PATCH v2 8/14 dev: device kernel module is a device attribute
In reply to Gaetan RivetIt is used in generic device structures and must not be tied to a bus.
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) }while (0 )/** +* Device driver. +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , + RTE_KDRV_NONE, +}; + +/** * A generic memory resource representation. */ struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -149,15 +149,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.1.4
PATCH v2 9/14 bus: introduce bus scan policies
In reply to Gaetan RivetScan policies describe the way a bus should scan the system to search for possible devices.
Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices
--- lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
@@ -123,6 +123,22 @@ typedef int (*rte_bus_detach_t)(struct rte_device *dev);typedef int (*rte_bus_parse_t )(const char *name,void *addr);/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_WHITELIST , +RTE_BUS_SCAN_BLACKLIST , +}; + +/** +* A structure used to configure bus operations. +*/ +struct rte_bus_conf { +enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ +}; + +/** * A structure describing a generic bus. */ struct rte_bus {
@@ -134,6 +150,7 @@ struct rte_bus {rte_bus_attach_t attach;/**< Probe single device for drivers */ rte_bus_detach_t detach;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +struct rte_bus_conf conf;/**< Bus configuration */ };/**
Signature · 1 line
2.1.4
PATCH v2 10/14 devargs: parse bus policies
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
@@ -130,6 +130,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)break ; } +if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }free (buf);TAILQ_INSERT_TAIL (&devargs_list, devargs, next);
Signature · 1 line
2.1.4
PATCH v2 11/14 devargs: generic device representation
In reply to Gaetan RivetRemove the dependency of this subsystem upon bus specific device representation.
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
--- app/test-pmd/testpmd.c | 9 ++---- lib/librte_eal/common/eal_common_devargs.c | 48 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 11 +++---- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- 6 files changed, 24 insertions(+), 71 deletions(-)
app/test-pmd/testpmd.c +2 -7
@@ -1807,7 +1807,6 @@ rmv_event_callback(void *arg) {struct rte_eth_dev *dev;struct rte_devargs *da; -char name[32 ] ="" ;uint8_t port_id = (intptr_t )arg;RTE_ETH_VALID_PORTID_OR_RET (port_id);
@@ -1816,12 +1815,8 @@ rmv_event_callback(void *arg)stop_port (port_id);close_port (port_id); -if (da->type ==RTE_DEVTYPE_VIRTUAL ) -snprintf (name,sizeof (name),"%s" , da->virt.drv_name); -else if (da->type ==RTE_DEVTYPE_WHITELISTED_PCI ) -rte_pci_device_name (&da->pci.addr, name,sizeof (name)); -printf ("removing device %s\n" , name); -rte_eal_dev_detach (name); +printf ("removing device %s\n" , da->name); +rte_eal_dev_detach (da->name); dev->state =RTE_ETH_DEV_UNUSED ; }
lib/librte_eal/common/eal_common_devargs.c +8 -40
66 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +6 -3
@@ -102,12 +102,15 @@ const char *pci_get_sysfs_path(void)static struct rte_devargs *pci_devargs_lookup (struct rte_pci_device *dev) {struct rte_devargs *devargs; +struct rte_pci_addr addr; +struct rte_bus *pbus; + pbus =rte_bus_from_name (PCI_BUS_NAME ); TAILQ_FOREACH(devargs, &devargs_list, next) { -if (devargs->type !=RTE_DEVTYPE_BLACKLISTED_PCI && - devargs->type !=RTE_DEVTYPE_WHITELISTED_PCI ) +if (devargs->bus != pbus)continue ; -if (!rte_eal_compare_pci_addr (&dev->addr, &devargs->pci.addr)) + devargs->bus->parse (devargs->name, &addr); +if (!rte_eal_compare_pci_addr (&dev->addr, &addr))return devargs; }return NULL ;
lib/librte_eal/common/eal_common_vdev.c +5 -6
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)if (args) devargs->args =strdup (args); - ret =snprintf (devargs->virt.drv_name, -sizeof (devargs->virt.drv_name),"%s" , name); -if (ret <0 || ret >= (int )sizeof (devargs->virt.drv_name)) { + ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , name); +if (ret <0 || ret >= (int )sizeof (devargs->name)) {free (devargs->args);free (devargs);return NULL ;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name; ret =vdev_probe_all_drivers (dev);if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)if (devargs->bus != vbus)continue ; - dev =find_vdev (devargs->virt.drv_name); + dev =find_vdev (devargs->name);if (dev)continue ;
@@ -314,7 +313,7 @@ vdev_scan(void) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name;TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); }
lib/librte_eal/common/include/rte_devargs.h +2 -14
@@ -50,7 +50,6 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> -#include <rte_pci.h> #include <rte_bus.h> /**
@@ -77,21 +76,10 @@ struct rte_devargs {TAILQ_ENTRY (rte_devargs) next;/** Type of device. */ enum rte_devtype type; -RTE_STD_C11 - union { -/** Used if type is RTE_DEVTYPE_*_PCI. */ -struct { -/** PCI location. */ -struct rte_pci_addr addr; - } pci; -/** Used if type is RTE_DEVTYPE_VIRTUAL. */ -struct { -/** Driver name. */ -char drv_name[32 ]; - } virt; - };/** Bus handle for the device. */ struct rte_bus *bus; +/** Name of the device. */ +char name[32 ];/** Arguments string as given by user or "" for no argument. */ char *args; };
lib/librte_eal/common/include/rte_vdev.h +1 -1
@@ -52,7 +52,7 @@ static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) {if (dev && dev->device.devargs) -return dev->device.devargs->virt.drv_name; +return dev->device.devargs->name;return NULL ; }
Signature · 1 line
2.1.4
PATCH v2 12/14 net/virtio: do not reference device type
In reply to Gaetan Rivet--- drivers/net/virtio/virtio_pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
@@ -38,6 +38,7 @@#endif #include <rte_io.h> +#include <rte_bus.h> #include "virtio_pci.h" #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)if (rte_pci_ioport_map (dev,0 ,VTPCI_IO (hw)) <0 ) {if (dev->kdrv ==RTE_KDRV_UNKNOWN && (!dev->device.devargs || - dev->device.devargs->type != -RTE_DEVTYPE_WHITELISTED_PCI )) { + dev->device.devargs->bus != +rte_bus_from_name (PCI_BUS_NAME ))) {PMD_INIT_LOG (INFO ,"skip kernel managed virtio device." );return 1 ;
Signature · 1 line
2.1.4
PATCH v2 13/14 devargs: generic device types
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 4 ++-- lib/librte_eal/common/eal_common_options.c | 13 +++---------- lib/librte_eal/common/eal_common_pci.c | 6 +++--- lib/librte_eal/common/eal_common_vdev.c | 1 - lib/librte_eal/common/include/rte_devargs.h | 6 +++--- 5 files changed, 11 insertions(+), 19 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
@@ -115,14 +115,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , buf);if (ret <0 || ret >= (int )sizeof (devargs->name)) goto fail; -if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (devargs->type ==RTE_DEVTYPE_WHITELISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) {fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); goto fail; } - }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) {
lib/librte_eal/common/eal_common_options.c +3 -10
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,switch (opt) {/* blacklist */ case 'b' : -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED , optarg) <0 ) {return -1 ; }break ;/* whitelist */ case 'w' : -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED , optarg) <0 ) {return -1 ; }
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,break ;case OPT_VDEV_NUM : -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL , +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , optarg) <0 ) {return -1 ; }
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)return -1 ; } -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=0 && -rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=0 ) { -RTE_LOG (ERR ,EAL ,"Options blacklist (-b) and whitelist (-w) " -"cannot be used at the same time\n" ); -return -1 ; - } -return 0 ; }
lib/librte_eal/common/eal_common_pci.c +3 -3
@@ -229,7 +229,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* no initialization when blacklisted, return without error */ if (dev->device.devargs !=NULL && dev->device.devargs->type == -RTE_DEVTYPE_BLACKLISTED_PCI ) { +RTE_DEVTYPE_BLACKLISTED ) {RTE_LOG (INFO ,EAL ," Device is blacklisted, not" " initializing\n" );return 1 ;
@@ -416,7 +416,7 @@ rte_pci_probe(void)int probe_all =0 ;int ret =0 ; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) ==0 ) +if (rte_pci_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_WHITELIST ) probe_all =1 ;FOREACH_DEVICE_ON_PCIBUS (dev) {
@@ -431,7 +431,7 @@ rte_pci_probe(void)if (probe_all) ret =pci_probe_all_drivers (dev);else if (devargs !=NULL && - devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) + devargs->type ==RTE_DEVTYPE_WHITELISTED ) ret =pci_probe_all_drivers (dev);if (ret <0 ) { RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)if (!devargs)return NULL ; - devargs->type =RTE_DEVTYPE_VIRTUAL ; devargs->bus =rte_bus_from_name (VIRTUAL_BUS_NAME );if (args) devargs->args =strdup (args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
@@ -56,9 +56,9 @@ extern "C" {* Type of generic device */ enum rte_devtype { -RTE_DEVTYPE_WHITELISTED_PCI , -RTE_DEVTYPE_BLACKLISTED_PCI , -RTE_DEVTYPE_VIRTUAL , +RTE_DEVTYPE_UNDEFINED , +RTE_DEVTYPE_WHITELISTED , +RTE_DEVTYPE_BLACKLISTED , };/**
Signature · 1 line
2.1.4
PATCH v2 14/14 devargs: introduce cleaner parsing helper
In reply to Gaetan RivetIntroduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.
The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.
A deprecation notice is issued.
This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.
--- doc/guides/rel_notes/deprecation.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 86 ++++++++++++++++++++--------- lib/librte_eal/common/include/rte_devargs.h | 20 +++++++ 3 files changed, 85 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
@@ -128,3 +128,8 @@ Deprecation Notices The non-"do-sig" versions of the hash tables will be removed (including the ``signature_offset`` parameter) and the "do-sig" versions renamed accordingly. + +* eal: the following function is deprecated starting from 17.08 and will + be removed in 17.11: + + - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +60 -26
116 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +20 -0
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs);/** +* Parse a device string. +* +* Verify that a bus is capable of handling the device passed +* in argument. Store which bus will handle the device, its name +* and the eventual device parameters. +* +* @param dev +* The device declaration string. +* @param da +* The devargs structure holding the device information. +* +* @return +* - 0 on success. +* - Negative errno on error. +*/ +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
v3 cover Generic devargs parsing
In reply to Gaetan RivetThe second part of the work outlined in [1] and [2]. The first part is at [3].
In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.
The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.
Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.
With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.
Buses needs only to implement the "parse" method for their devices to be declared in this way.
[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html
This patchset depends on:
[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/
v1 -> v2:
* fix PCI whitelist mode
v2 -> v3:
* Rebase the series on the new plug / unplug API
Gaetan Rivet (14):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
app/test-pmd/testpmd.c | 9 +- app/test-pmd/testpmd.h | 2 + doc/guides/rel_notes/deprecation.rst | 5 + drivers/net/bnxt/bnxt.h | 1 + drivers/net/bonding/rte_eth_bond_args.c | 1 + drivers/net/e1000/e1000_ethdev.h | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/sfc/sfc.h | 1 + drivers/net/virtio/virtio_pci.c | 5 +- lib/librte_eal/common/eal_common_devargs.c | 137 ++++++++++++++++------------ lib/librte_eal/common/eal_common_options.c | 13 +-- lib/librte_eal/common/eal_common_pci.c | 15 +-- lib/librte_eal/common/eal_common_vdev.c | 16 ++-- lib/librte_eal/common/include/rte_bus.h | 17 ++++ lib/librte_eal/common/include/rte_dev.h | 12 +++ lib/librte_eal/common/include/rte_devargs.h | 42 +++++---- lib/librte_eal/common/include/rte_pci.h | 9 -- lib/librte_eal/common/include/rte_vdev.h | 2 +- 19 files changed, 169 insertions(+), 121 deletions(-)
Signature · 1 line
2.1.4
PATCH v3 1/14 net/bonding: properly reference PCI header
--- drivers/net/bonding/rte_eth_bond_args.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
@@ -32,6 +32,7 @@*/ #include <rte_devargs.h> +#include <rte_pci.h> #include <rte_kvargs.h> #include <cmdline_parse.h>
Signature · 1 line
2.1.4
PATCH v3 2/14 net/bnxt: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/bnxt/bnxt.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
@@ -37,6 +37,7 @@#include <inttypes.h> #include <sys/queue.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_memory.h> #include <rte_lcore.h>
Signature · 1 line
2.1.4
PATCH v3 3/14 net/mlx5: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/mlx5/mlx5.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -54,6 +54,7 @@#ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"#endif +#include <rte_pci.h> #include <rte_ether.h> #include <rte_ethdev.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v3 4/14 net/e1000: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/e1000/e1000_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
@@ -34,6 +34,7 @@#ifndef _E1000_ETHDEV_H_#define _E1000_ETHDEV_H_#include <rte_time.h> +#include <rte_pci.h> #define E1000_INTEL_VENDOR_ID 0x8086
Signature · 1 line
2.1.4
PATCH v3 5/14 net/ixgbe: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -39,6 +39,7 @@#include "ixgbe_bypass.h" #include <rte_time.h> #include <rte_hash.h> +#include <rte_pci.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
PATCH v3 6/14 net/sfc: properly reference PCI header
In reply to Gaetan RivetFrom: Gaetan Rivet <[email protected]>
--- drivers/net/sfc/sfc.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
@@ -34,6 +34,7 @@#include <stdbool.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_kvargs.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v3 7/14 app/testpmd: properly reference PCI header
In reply to Gaetan Rivet--- app/test-pmd/testpmd.h | 2 ++ 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
@@ -34,6 +34,8 @@#ifndef _TESTPMD_H_#define _TESTPMD_H_ +#include <rte_pci.h> +#define RTE_PORT_ALL (~(portid_t)0x0)#define RTE_TEST_RX_DESC_MAX 2048
Signature · 1 line
2.1.4
PATCH v3 8/14 dev: device kernel module is a device attribute
In reply to Gaetan RivetIt is used in generic device structures and must not be tied to a bus.
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) }while (0 )/** +* Device driver. +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , + RTE_KDRV_NONE, +}; + +/** * A generic memory resource representation. */ struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -149,15 +149,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.1.4
PATCH v3 9/14 bus: introduce bus scan policies
In reply to Gaetan RivetScan policies describe the way a bus should scan the system to search for possible devices.
Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices
--- lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
@@ -126,6 +126,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_devargs *da);typedef int (*rte_bus_parse_t )(const char *name,void *addr);/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_WHITELIST , +RTE_BUS_SCAN_BLACKLIST , +}; + +/** +* A structure used to configure bus operations. +*/ +struct rte_bus_conf { +enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ +}; + +/** * A structure describing a generic bus. */ struct rte_bus {
@@ -137,6 +153,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +struct rte_bus_conf conf;/**< Bus configuration */ };/**
Signature · 1 line
2.1.4
PATCH v3 10/14 devargs: parse bus policies
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
@@ -130,6 +130,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)break ; } +if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }free (buf);TAILQ_INSERT_TAIL (&devargs_list, devargs, next);
Signature · 1 line
2.1.4
PATCH v3 11/14 devargs: generic device representation
In reply to Gaetan RivetRemove the dependency of this subsystem upon bus specific device representation.
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
--- app/test-pmd/testpmd.c | 9 ++---- lib/librte_eal/common/eal_common_devargs.c | 48 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 15 +++++---- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- 6 files changed, 26 insertions(+), 73 deletions(-)
app/test-pmd/testpmd.c +2 -7
@@ -1807,7 +1807,6 @@ rmv_event_callback(void *arg) {struct rte_eth_dev *dev;struct rte_devargs *da; -char name[32 ] ="" ;uint8_t port_id = (intptr_t )arg;RTE_ETH_VALID_PORTID_OR_RET (port_id);
@@ -1816,12 +1815,8 @@ rmv_event_callback(void *arg)stop_port (port_id);close_port (port_id); -if (da->type ==RTE_DEVTYPE_VIRTUAL ) -snprintf (name,sizeof (name),"%s" , da->virt.drv_name); -else if (da->type ==RTE_DEVTYPE_WHITELISTED_PCI ) -rte_pci_device_name (&da->pci.addr, name,sizeof (name)); -printf ("removing device %s\n" , name); -rte_eal_dev_detach (name); +printf ("removing device %s\n" , da->name); +rte_eal_dev_detach (da->name); dev->state =RTE_ETH_DEV_UNUSED ; }
lib/librte_eal/common/eal_common_devargs.c +8 -40
66 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +6 -3
@@ -102,12 +102,15 @@ const char *pci_get_sysfs_path(void)static struct rte_devargs *pci_devargs_lookup (struct rte_pci_device *dev) {struct rte_devargs *devargs; +struct rte_pci_addr addr; +struct rte_bus *pbus; + pbus =rte_bus_from_name (PCI_BUS_NAME ); TAILQ_FOREACH(devargs, &devargs_list, next) { -if (devargs->type !=RTE_DEVTYPE_BLACKLISTED_PCI && - devargs->type !=RTE_DEVTYPE_WHITELISTED_PCI ) +if (devargs->bus != pbus)continue ; -if (!rte_eal_compare_pci_addr (&dev->addr, &devargs->pci.addr)) + devargs->bus->parse (devargs->name, &addr); +if (!rte_eal_compare_pci_addr (&dev->addr, &addr))return devargs; }return NULL ;
lib/librte_eal/common/eal_common_vdev.c +7 -8
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)if (args) devargs->args =strdup (args); - ret =snprintf (devargs->virt.drv_name, -sizeof (devargs->virt.drv_name),"%s" , name); -if (ret <0 || ret >= (int )sizeof (devargs->virt.drv_name)) { + ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , name); +if (ret <0 || ret >= (int )sizeof (devargs->name)) {free (devargs->args);free (devargs);return NULL ;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name; ret =vdev_probe_all_drivers (dev);if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)if (devargs->bus != vbus)continue ; - dev =find_vdev (devargs->virt.drv_name); + dev =find_vdev (devargs->name);if (dev)continue ;
@@ -314,7 +313,7 @@ vdev_scan(void) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name;TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); }
@@ -358,13 +357,13 @@ vdev_find_device(rte_dev_match_t match, const void *data)static int vdev_plug (struct rte_devargs *da) { -return rte_vdev_init (da->virt.drv_name, da->args); +return rte_vdev_init (da->name, da->args); }static int vdev_unplug (struct rte_devargs *da) { -return rte_vdev_uninit (da->virt.drv_name); +return rte_vdev_uninit (da->name); }static struct rte_bus rte_vdev_bus = {
lib/librte_eal/common/include/rte_devargs.h +2 -14
@@ -50,7 +50,6 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> -#include <rte_pci.h> #include <rte_bus.h> /**
@@ -77,21 +76,10 @@ struct rte_devargs {TAILQ_ENTRY (rte_devargs) next;/** Type of device. */ enum rte_devtype type; -RTE_STD_C11 - union { -/** Used if type is RTE_DEVTYPE_*_PCI. */ -struct { -/** PCI location. */ -struct rte_pci_addr addr; - } pci; -/** Used if type is RTE_DEVTYPE_VIRTUAL. */ -struct { -/** Driver name. */ -char drv_name[32 ]; - } virt; - };/** Bus handle for the device. */ struct rte_bus *bus; +/** Name of the device. */ +char name[32 ];/** Arguments string as given by user or "" for no argument. */ char *args; };
lib/librte_eal/common/include/rte_vdev.h +1 -1
@@ -52,7 +52,7 @@ static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) {if (dev && dev->device.devargs) -return dev->device.devargs->virt.drv_name; +return dev->device.devargs->name;return NULL ; }
Signature · 1 line
2.1.4
PATCH v3 12/14 net/virtio: do not reference device type
In reply to Gaetan Rivet--- drivers/net/virtio/virtio_pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
@@ -38,6 +38,7 @@#endif #include <rte_io.h> +#include <rte_bus.h> #include "virtio_pci.h" #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)if (rte_pci_ioport_map (dev,0 ,VTPCI_IO (hw)) <0 ) {if (dev->kdrv ==RTE_KDRV_UNKNOWN && (!dev->device.devargs || - dev->device.devargs->type != -RTE_DEVTYPE_WHITELISTED_PCI )) { + dev->device.devargs->bus != +rte_bus_from_name (PCI_BUS_NAME ))) {PMD_INIT_LOG (INFO ,"skip kernel managed virtio device." );return 1 ;
Signature · 1 line
2.1.4
PATCH v3 13/14 devargs: generic device types
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 4 ++-- lib/librte_eal/common/eal_common_options.c | 13 +++---------- lib/librte_eal/common/eal_common_pci.c | 6 +++--- lib/librte_eal/common/eal_common_vdev.c | 1 - lib/librte_eal/common/include/rte_devargs.h | 6 +++--- 5 files changed, 11 insertions(+), 19 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
@@ -115,14 +115,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , buf);if (ret <0 || ret >= (int )sizeof (devargs->name)) goto fail; -if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (devargs->type ==RTE_DEVTYPE_WHITELISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) {fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); goto fail; } - }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) {
lib/librte_eal/common/eal_common_options.c +3 -10
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,switch (opt) {/* blacklist */ case 'b' : -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED , optarg) <0 ) {return -1 ; }break ;/* whitelist */ case 'w' : -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED , optarg) <0 ) {return -1 ; }
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,break ;case OPT_VDEV_NUM : -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL , +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , optarg) <0 ) {return -1 ; }
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)return -1 ; } -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=0 && -rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=0 ) { -RTE_LOG (ERR ,EAL ,"Options blacklist (-b) and whitelist (-w) " -"cannot be used at the same time\n" ); -return -1 ; - } -return 0 ; }
lib/librte_eal/common/eal_common_pci.c +3 -3
@@ -229,7 +229,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* no initialization when blacklisted, return without error */ if (dev->device.devargs !=NULL && dev->device.devargs->type == -RTE_DEVTYPE_BLACKLISTED_PCI ) { +RTE_DEVTYPE_BLACKLISTED ) {RTE_LOG (INFO ,EAL ," Device is blacklisted, not" " initializing\n" );return 1 ;
@@ -416,7 +416,7 @@ rte_pci_probe(void)int probe_all =0 ;int ret =0 ; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) ==0 ) +if (rte_pci_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_WHITELIST ) probe_all =1 ;FOREACH_DEVICE_ON_PCIBUS (dev) {
@@ -431,7 +431,7 @@ rte_pci_probe(void)if (probe_all) ret =pci_probe_all_drivers (dev);else if (devargs !=NULL && - devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) + devargs->type ==RTE_DEVTYPE_WHITELISTED ) ret =pci_probe_all_drivers (dev);if (ret <0 ) { RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)if (!devargs)return NULL ; - devargs->type =RTE_DEVTYPE_VIRTUAL ; devargs->bus =rte_bus_from_name (VIRTUAL_BUS_NAME );if (args) devargs->args =strdup (args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
@@ -56,9 +56,9 @@ extern "C" {* Type of generic device */ enum rte_devtype { -RTE_DEVTYPE_WHITELISTED_PCI , -RTE_DEVTYPE_BLACKLISTED_PCI , -RTE_DEVTYPE_VIRTUAL , +RTE_DEVTYPE_UNDEFINED , +RTE_DEVTYPE_WHITELISTED , +RTE_DEVTYPE_BLACKLISTED , };/**
Signature · 1 line
2.1.4
PATCH v3 14/14 devargs: introduce cleaner parsing helper
In reply to Gaetan RivetIntroduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.
The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.
A deprecation notice is issued.
This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.
--- doc/guides/rel_notes/deprecation.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 86 ++++++++++++++++++++--------- lib/librte_eal/common/include/rte_devargs.h | 20 +++++++ 3 files changed, 85 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
@@ -128,3 +128,8 @@ Deprecation Notices The non-"do-sig" versions of the hash tables will be removed (including the ``signature_offset`` parameter) and the "do-sig" versions renamed accordingly. + +* eal: the following function is deprecated starting from 17.08 and will + be removed in 17.11: + + - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +60 -26
116 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +20 -0
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs);/** +* Parse a device string. +* +* Verify that a bus is capable of handling the device passed +* in argument. Store which bus will handle the device, its name +* and the eventual device parameters. +* +* @param dev +* The device declaration string. +* @param da +* The devargs structure holding the device information. +* +* @return +* - 0 on success. +* - Negative errno on error. +*/ +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
v4 cover Generic devargs parsing
In reply to Gaetan RivetThe second part of the work outlined in [1] and [2]. The first part is at [3].
In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.
The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.
Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.
With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.
Buses needs only to implement the "parse" method for their devices to be declared in this way.
[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html
This patchset depends on:
[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/
v1 -> v2:
* fix PCI whitelist mode
v2 -> v3:
* Rebase the series on the new plug / unplug API
v3 -> v4:
* Fix rte_devargs parsing helper
* Introduce new rte_devargs clone function
* Introduce new rte_devargs release function
* Fix test application for rte_devargs.
TODO: rewrite complete rte_devargs autotest.
* Fix a few rte_pci references.
* Update EAL command line help for -w / -b
Gaetan Rivet (19):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc
app/test-pmd/testpmd.c | 9 +- app/test-pmd/testpmd.h | 2 + doc/guides/rel_notes/deprecation.rst | 5 + drivers/net/bnxt/bnxt.h | 1 + drivers/net/bonding/rte_eth_bond_args.c | 1 + drivers/net/e1000/e1000_ethdev.h | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/sfc/sfc.h | 1 + drivers/net/virtio/virtio_pci.c | 5 +- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 + lib/librte_eal/common/eal_common_devargs.c | 178 ++++++++++++++++-------- lib/librte_eal/common/eal_common_options.c | 31 ++--- lib/librte_eal/common/eal_common_pci.c | 16 ++- lib/librte_eal/common/eal_common_vdev.c | 18 ++- lib/librte_eal/common/eal_options.h | 8 +- lib/librte_eal/common/include/rte_bus.h | 17 +++ lib/librte_eal/common/include/rte_dev.h | 12 ++ lib/librte_eal/common/include/rte_devargs.h | 68 ++++++--- lib/librte_eal/common/include/rte_pci.h | 9 -- lib/librte_eal/common/include/rte_vdev.h | 2 +- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 + test/test/test_devargs.c | 45 +++--- test/test/virtual_pmd.c | 1 + 24 files changed, 278 insertions(+), 158 deletions(-)
Signature · 1 line
2.1.4
PATCH v4 1/19 net/bonding: properly reference PCI header
--- drivers/net/bonding/rte_eth_bond_args.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
@@ -32,6 +32,7 @@*/ #include <rte_devargs.h> +#include <rte_pci.h> #include <rte_kvargs.h> #include <cmdline_parse.h>
Signature · 1 line
2.1.4
PATCH v4 2/19 net/bnxt: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/bnxt/bnxt.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
@@ -38,6 +38,7 @@#include <stdbool.h> #include <sys/queue.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_memory.h> #include <rte_lcore.h>
Signature · 1 line
2.1.4
PATCH v4 3/19 net/mlx5: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/mlx5/mlx5.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -54,6 +54,7 @@#ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"#endif +#include <rte_pci.h> #include <rte_ether.h> #include <rte_ethdev.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v4 4/19 net/e1000: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/e1000/e1000_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
@@ -34,6 +34,7 @@#ifndef _E1000_ETHDEV_H_#define _E1000_ETHDEV_H_#include <rte_time.h> +#include <rte_pci.h> #define E1000_INTEL_VENDOR_ID 0x8086
Signature · 1 line
2.1.4
PATCH v4 5/19 net/ixgbe: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -39,6 +39,7 @@#include "ixgbe_bypass.h" #include <rte_time.h> #include <rte_hash.h> +#include <rte_pci.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
Re: [PATCH v4 05/19] net/ixgbe: properly reference PCI header
Why to introduce this change ?
Even without this patch, all files can be built successfully.
Each.*.o.d files in x86_64-native-linuxapp-gcc keeps same in both with and without this patch. So there is no need to add the line at least in the config of x86_64-native-linuxapp-gcc.
Quoted 27 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Thursday, June 8, 2017 7:57 AM
To: [email protected]
Cc: Gaetan Rivet <[email protected]>
Subject: [dpdk-dev] [PATCH v4 05/19] net/ixgbe: properly reference PCI headerSigned-off-by Gaetan Rivet <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 1 file changed, 1 insertion(+)drivers/net/ixgbe/ixgbe_ethdev.h +1
-1@@ -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
Re: [PATCH v4 05/19] net/ixgbe: properly reference PCI header
Hi,
Quoted 7 lines · Wei
Why to introduce this change ?
Even without this patch, all files can be built successfully.
Each.*.o.d files in x86_64-native-linuxapp-gcc keeps same in both with and without this patch. So there is no need to add the line at least in the config of x86_64-native-linuxapp-gcc.
In order to remove the PCI bus from the EAL, I need to remove all references to it from EAL headers.
rte_devargs.h previously included rte_pci.h, which then was included by several other parts of the DPDK.
This needs to be fixed, as afterward, the commit
* devargs: generic device representation
removes the PCI include.
This include was faulty anyway, as normally all compile units (or at least independent DPDK parts) should be self-sufficient in terms of includes, due to this exact situation where libraries are moved around and their dependencies are updated.
Quoted 28 lines
Quoted 27 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Thursday, June 8, 2017 7:57 AM
To: [email protected]
Cc: Gaetan Rivet <[email protected]>
Subject: [dpdk-dev] [PATCH v4 05/19] net/ixgbe: properly reference PCI headerSigned-off-by Gaetan Rivet <[email protected]>--- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 1 file changed, 1 insertion(+)drivers/net/ixgbe/ixgbe_ethdev.h +1
-1@@ -39,6 +39,7 @@#include "ixgbe_bypass.h" #include <rte_time.h> #include <rte_hash.h> +#include <rte_pci.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0) --2.1.4
Signature · 2 lines
Gaëtan Rivet 6WIND
PATCH v4 6/19 net/sfc: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/sfc/sfc.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
@@ -34,6 +34,7 @@#include <stdbool.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_kvargs.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v4 7/19 app/testpmd: properly reference PCI header
In reply to Gaetan Rivet--- app/test-pmd/testpmd.h | 2 ++ 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
@@ -34,6 +34,8 @@#ifndef _TESTPMD_H_#define _TESTPMD_H_ +#include <rte_pci.h> +#define RTE_PORT_ALL (~(portid_t)0x0)#define RTE_TEST_RX_DESC_MAX 2048
Signature · 1 line
2.1.4
PATCH v4 8/19 test: properly reference PCI header
In reply to Gaetan Rivet--- test/test/virtual_pmd.c | 1 + 1 file changed, 1 insertion(+)
test/test/virtual_pmd.c +1 -0
@@ -33,6 +33,7 @@#include <rte_mbuf.h> #include <rte_ethdev.h> +#include <rte_pci.h> #include <rte_malloc.h> #include <rte_memcpy.h> #include <rte_memory.h>
Signature · 1 line
2.1.4
PATCH v4 9/19 dev: device kernel module is a device attribute
In reply to Gaetan RivetIt is used in generic device structures and must not be tied to a bus.
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) }while (0 )/** +* Device driver. +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , + RTE_KDRV_NONE, +}; + +/** * A generic memory resource representation. */ struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -120,15 +120,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.1.4
PATCH v4 10/19 bus: introduce bus scan policies
In reply to Gaetan RivetScan policies describe the way a bus should scan the system to search for possible devices.
Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices
--- lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
@@ -137,6 +137,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);typedef int (*rte_bus_parse_t )(const char *name,void *addr);/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_WHITELIST , +RTE_BUS_SCAN_BLACKLIST , +}; + +/** +* A structure used to configure bus operations. +*/ +struct rte_bus_conf { +enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ +}; + +/** * A structure describing a generic bus. */ struct rte_bus {
@@ -148,6 +164,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +struct rte_bus_conf conf;/**< Bus configuration */ };/**
Signature · 1 line
2.1.4
PATCH v4 11/19 devargs: parse bus policies
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
@@ -130,6 +130,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)break ; } +if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }free (buf);TAILQ_INSERT_TAIL (&devargs_list, devargs, next);
Signature · 1 line
2.1.4
PATCH v4 12/19 devargs: generic device representation
In reply to Gaetan RivetRemove the dependency of this subsystem upon bus specific device representation.
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
--- app/test-pmd/testpmd.c | 9 ++---- lib/librte_eal/common/eal_common_devargs.c | 48 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 17 +++++----- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- test/test/test_devargs.c | 9 ++---- 7 files changed, 30 insertions(+), 80 deletions(-)
app/test-pmd/testpmd.c +2 -7
@@ -1810,7 +1810,6 @@ rmv_event_callback(void *arg) {struct rte_eth_dev *dev;struct rte_devargs *da; -char name[32 ] ="" ;uint8_t port_id = (intptr_t )arg;RTE_ETH_VALID_PORTID_OR_RET (port_id);
@@ -1819,12 +1818,8 @@ rmv_event_callback(void *arg)stop_port (port_id);close_port (port_id); -if (da->type ==RTE_DEVTYPE_VIRTUAL ) -snprintf (name,sizeof (name),"%s" , da->virt.drv_name); -else if (da->type ==RTE_DEVTYPE_WHITELISTED_PCI ) -rte_pci_device_name (&da->pci.addr, name,sizeof (name)); -printf ("removing device %s\n" , name); -rte_eal_dev_detach (name); +printf ("removing device %s\n" , da->name); +rte_eal_dev_detach (da->name); dev->state =RTE_ETH_DEV_UNUSED ; }
lib/librte_eal/common/eal_common_devargs.c +8 -40
66 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +6 -3
@@ -73,12 +73,15 @@ const char *pci_get_sysfs_path(void)static struct rte_devargs *pci_devargs_lookup (struct rte_pci_device *dev) {struct rte_devargs *devargs; +struct rte_pci_addr addr; +struct rte_bus *pbus; + pbus =rte_bus_from_name (PCI_BUS_NAME ); TAILQ_FOREACH(devargs, &devargs_list, next) { -if (devargs->type !=RTE_DEVTYPE_BLACKLISTED_PCI && - devargs->type !=RTE_DEVTYPE_WHITELISTED_PCI ) +if (devargs->bus != pbus)continue ; -if (!rte_eal_compare_pci_addr (&dev->addr, &devargs->pci.addr)) + devargs->bus->parse (devargs->name, &addr); +if (!rte_eal_compare_pci_addr (&dev->addr, &addr))return devargs; }return NULL ;
lib/librte_eal/common/eal_common_vdev.c +8 -9
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)if (args) devargs->args =strdup (args); - ret =snprintf (devargs->virt.drv_name, -sizeof (devargs->virt.drv_name),"%s" , name); -if (ret <0 || ret >= (int )sizeof (devargs->virt.drv_name)) { + ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , name); +if (ret <0 || ret >= (int )sizeof (devargs->name)) {free (devargs->args);free (devargs);return NULL ;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name; ret =vdev_probe_all_drivers (dev);if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)if (devargs->bus != vbus)continue ; - dev =find_vdev (devargs->virt.drv_name); + dev =find_vdev (devargs->name);if (dev)continue ;
@@ -314,7 +313,7 @@ vdev_scan(void) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name;TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); }
@@ -361,12 +360,12 @@ vdev_plug(struct rte_devargs *da)struct rte_vdev_device *dev;int ret; - ret =rte_vdev_init (da->virt.drv_name, da->args); + ret =rte_vdev_init (da->name, da->args);if (ret) { rte_errno = -ret;return NULL ; } - dev =find_vdev (da->virt.drv_name); + dev =find_vdev (da->name);return &dev->device; }
@@ -381,7 +380,7 @@ vdev_unplug(struct rte_device *dev) rte_errno =EINVAL ;return -1 ; } - ret =rte_vdev_uninit (da->virt.drv_name); + ret =rte_vdev_uninit (da->name);if (ret) rte_errno = -ret;return ret;
lib/librte_eal/common/include/rte_devargs.h +2 -14
@@ -50,7 +50,6 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> -#include <rte_pci.h> #include <rte_bus.h> /**
@@ -77,21 +76,10 @@ struct rte_devargs {TAILQ_ENTRY (rte_devargs) next;/** Type of device. */ enum rte_devtype type; -RTE_STD_C11 - union { -/** Used if type is RTE_DEVTYPE_*_PCI. */ -struct { -/** PCI location. */ -struct rte_pci_addr addr; - } pci; -/** Used if type is RTE_DEVTYPE_VIRTUAL. */ -struct { -/** Driver name. */ -char drv_name[32 ]; - } virt; - };/** Bus handle for the device. */ struct rte_bus *bus; +/** Name of the device. */ +char name[32 ];/** Arguments string as given by user or "" for no argument. */ char *args; };
lib/librte_eal/common/include/rte_vdev.h +1 -1
@@ -52,7 +52,7 @@ static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) {if (dev && dev->device.devargs) -return dev->device.devargs->virt.drv_name; +return dev->device.devargs->name;return NULL ; }
test/test/test_devargs.c +3 -6
@@ -90,8 +90,8 @@ test_devargs(void)if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,k1=val,k2=val2" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); -if (strncmp (devargs->virt.drv_name,"net_ring1" , -sizeof (devargs->virt.drv_name)) !=0 ) +if (strncmp (devargs->name,"net_ring1" , +sizeof (devargs->name)) !=0 ) goto fail;if (!devargs->args ||strcmp (devargs->args,"k1=val,k2=val2" ) !=0 ) goto fail;
@@ -101,10 +101,7 @@ test_devargs(void)if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"04:00.1" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); -if (devargs->pci.addr.domain !=0 || - devargs->pci.addr.bus !=4 || - devargs->pci.addr.devid !=0 || - devargs->pci.addr.function !=1 ) +if (strcmp (devargs->name,"04:00.1" ) !=0 ) goto fail;if (!devargs->args ||strcmp (devargs->args,"" ) !=0 ) goto fail;
Signature · 1 line
2.1.4
PATCH v4 13/19 pci: update device name
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_pci.c | 1 + 1 file changed, 1 insertion(+)
lib/librte_eal/common/eal_common_pci.c +1 -0
@@ -325,6 +325,7 @@ rte_pci_probe_one(const struct rte_pci_addr *addr) ret =pci_probe_all_drivers (dev);if (ret) goto err_return; + dev->device.name = dev->device.devargs->name;return 0 ; }return -1 ;
Signature · 1 line
2.1.4
PATCH v4 14/19 net/virtio: do not reference device type
In reply to Gaetan Rivet--- drivers/net/virtio/virtio_pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
@@ -38,6 +38,7 @@#endif #include <rte_io.h> +#include <rte_bus.h> #include "virtio_pci.h" #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)if (rte_pci_ioport_map (dev,0 ,VTPCI_IO (hw)) <0 ) {if (dev->kdrv ==RTE_KDRV_UNKNOWN && (!dev->device.devargs || - dev->device.devargs->type != -RTE_DEVTYPE_WHITELISTED_PCI )) { + dev->device.devargs->bus != +rte_bus_from_name (PCI_BUS_NAME ))) {PMD_INIT_LOG (INFO ,"skip kernel managed virtio device." );return 1 ;
Signature · 1 line
2.1.4
PATCH v4 15/19 devargs: generic device types
In reply to Gaetan Rivetrte_devargs now represents any device from any bus.
The related devtypes do not identify a bus anymore, only which scan policy the device subscribes to.
The bus itself is identified by a bus handle previously introduced.
--- lib/librte_eal/common/eal_common_devargs.c | 4 ++-- lib/librte_eal/common/eal_common_options.c | 13 +++-------- lib/librte_eal/common/eal_common_pci.c | 6 ++--- lib/librte_eal/common/eal_common_vdev.c | 1 - lib/librte_eal/common/include/rte_devargs.h | 6 ++--- test/test/test_devargs.c | 36 +++++++++++++++-------------- 6 files changed, 30 insertions(+), 36 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
@@ -115,14 +115,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , buf);if (ret <0 || ret >= (int )sizeof (devargs->name)) goto fail; -if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (devargs->type ==RTE_DEVTYPE_WHITELISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) {fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); goto fail; } - }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) {
lib/librte_eal/common/eal_common_options.c +3 -10
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,switch (opt) {/* blacklist */ case 'b' : -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED , optarg) <0 ) {return -1 ; }break ;/* whitelist */ case 'w' : -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED , optarg) <0 ) {return -1 ; }
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,break ;case OPT_VDEV_NUM : -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL , +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , optarg) <0 ) {return -1 ; }
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)return -1 ; } -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=0 && -rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=0 ) { -RTE_LOG (ERR ,EAL ,"Options blacklist (-b) and whitelist (-w) " -"cannot be used at the same time\n" ); -return -1 ; - } -return 0 ; }
lib/librte_eal/common/eal_common_pci.c +3 -3
@@ -200,7 +200,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* no initialization when blacklisted, return without error */ if (dev->device.devargs !=NULL && dev->device.devargs->type == -RTE_DEVTYPE_BLACKLISTED_PCI ) { +RTE_DEVTYPE_BLACKLISTED ) {RTE_LOG (INFO ,EAL ," Device is blacklisted, not" " initializing\n" );return 1 ;
@@ -388,7 +388,7 @@ rte_pci_probe(void)int probe_all =0 ;int ret =0 ; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) ==0 ) +if (rte_pci_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_WHITELIST ) probe_all =1 ;FOREACH_DEVICE_ON_PCIBUS (dev) {
@@ -403,7 +403,7 @@ rte_pci_probe(void)if (probe_all) ret =pci_probe_all_drivers (dev);else if (devargs !=NULL && - devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) + devargs->type ==RTE_DEVTYPE_WHITELISTED ) ret =pci_probe_all_drivers (dev);if (ret <0 ) { RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)if (!devargs)return NULL ; - devargs->type =RTE_DEVTYPE_VIRTUAL ; devargs->bus =rte_bus_from_name (VIRTUAL_BUS_NAME );if (args) devargs->args =strdup (args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
@@ -56,9 +56,9 @@ extern "C" {* Type of generic device */ enum rte_devtype { -RTE_DEVTYPE_WHITELISTED_PCI , -RTE_DEVTYPE_BLACKLISTED_PCI , -RTE_DEVTYPE_VIRTUAL , +RTE_DEVTYPE_UNDEFINED , +RTE_DEVTYPE_WHITELISTED , +RTE_DEVTYPE_BLACKLISTED , };/**
test/test/test_devargs.c +19 -17
@@ -64,30 +64,32 @@ test_devargs(void)TAILQ_INIT (&devargs_list);/* test valid cases */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"08:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"08:00.1" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"0000:5:00.0" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"0000:5:00.0" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI ,"04:00.0,arg=val" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"04:00.0,arg=val" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI ,"0000:01:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"0000:01:00.1" ) <0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED ) !=4 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED ) !=0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_VIRTUAL ) !=0 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_UNDEFINED ) !=0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring0" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED ,"net_ring0" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,key=val,k2=val2" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , +"net_ring1,key=val,k2=val2" ) <0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_VIRTUAL ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_UNDEFINED ) !=2 ) goto fail;free_devargs_list ();/* check virtual device with argument parsing */ -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,k1=val,k2=val2" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , +"net_ring1,k1=val,k2=val2" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); if (strncmp(devargs->name, "net_ring1",
@@ -98,7 +100,7 @@ test_devargs(void)free_devargs_list ();/* check PCI device with empty argument parsing */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"04:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"04:00.1" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list);if (strcmp (devargs->name,"04:00.1" ) !=0 )
@@ -108,15 +110,15 @@ test_devargs(void)free_devargs_list ();/* test error case: bad PCI address */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"08:1" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"08:1" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"00.1" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"00.1" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"foo" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"foo" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"," ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"," ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"000f:0:0" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"000f:0:0" ) ==0 ) goto fail; devargs_list = save_devargs_list;
Signature · 1 line
2.1.4
PATCH v4 16/19 devargs: introduce cleaner parsing helper
In reply to Gaetan RivetIntroduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.
The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.
A deprecation notice is issued.
This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.
--- doc/guides/rel_notes/deprecation.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 89 ++++++++++++++++++++--------- lib/librte_eal/common/include/rte_devargs.h | 20 +++++++ 3 files changed, 88 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
@@ -105,3 +105,8 @@ Deprecation Notices The non-"do-sig" versions of the hash tables will be removed (including the ``signature_offset`` parameter) and the "do-sig" versions renamed accordingly. + +* eal: the following function is deprecated starting from 17.08 and will + be removed in 17.11: + + - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +63 -26
119 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +20 -0
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs);/** +* Parse a device string. +* +* Verify that a bus is capable of handling the device passed +* in argument. Store which bus will handle the device, its name +* and the eventual device parameters. +* +* @param dev +* The device declaration string. +* @param da +* The devargs structure holding the device information. +* +* @return +* - 0 on success. +* - Negative errno on error. +*/ +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
PATCH v4 17/19 devargs: clone function
In reply to Gaetan RivetThis function returns a deep copy of an rte_devargs.
--- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 20 ++++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 12 ++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 34 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -203,5 +203,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; + rte_eal_devargs_clone; } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +20 -0
@@ -41,6 +41,7 @@#include <string.h> #include <rte_devargs.h> +#include <rte_tailq.h> #include "eal_private.h" /** Global list of user devices */
@@ -182,6 +183,25 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)return -1 ; } +/* Deep-copy of an rte_devargs. */ +struct rte_devargs * +rte_eal_devargs_clone (struct rte_devargs *da) +{ +struct rte_devargs *clone; + + clone =calloc (1 ,sizeof (*clone)); +if (clone ==NULL ) +return NULL ; +snprintf (clone->name,sizeof (clone->name),"%s" , da->name); + clone->args =strdup (da->args ? da->args :"" ); + clone->bus = da->bus; +if (clone->args ==NULL ) { +free (clone); +return NULL ; + } +return clone; +} +/* count the number of devices of a specified type */ unsigned int rte_eal_devargs_type_count (enum rte_devtype devtype)
lib/librte_eal/common/include/rte_devargs.h +12 -0
@@ -163,6 +163,18 @@ rte_eal_devargs_parse(const char *dev,int rte_eal_devargs_add (enum rte_devtype devtype,const char *devargs_str);/** +* Deep copy an rte_devargs. +* +* @param da +* Source devargs. +* +* @return +* The pointer to the new rte_devargs on success. +* NULL on error. +*/ +struct rte_devargs *rte_eal_devargs_clone (struct rte_devargs *da); + +/** * Count the number of user devices of a specified type * * @param devtype
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -207,5 +207,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; + rte_eal_devargs_clone; } DPDK_17.05;
Signature · 1 line
2.1.4
PATCH v4 18/19 devargs: remove function
In reply to Gaetan RivetThis function is now necessary due to the new unplug rte_bus API.
--- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 18 ++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 14 ++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 34 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -204,5 +204,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; rte_eal_devargs_clone; + rte_eal_devargs_rmv; } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +18 -0
@@ -183,6 +183,24 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)return -1 ; } +/* Remove and free an rte_devargs. */ +int +rte_eal_devargs_rmv (struct rte_devargs *da) +{ +struct rte_devargs *d; +void *tmp; + + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { +if (d == da) { +TAILQ_REMOVE (&devargs_list, d, next); +free (d->args); +free (d); +return 0 ; + } + } +return 1 ; +} +/* Deep-copy of an rte_devargs. */ struct rte_devargs *rte_eal_devargs_clone (struct rte_devargs *da)
lib/librte_eal/common/include/rte_devargs.h +14 -0
@@ -163,6 +163,20 @@ rte_eal_devargs_parse(const char *dev,int rte_eal_devargs_add (enum rte_devtype devtype,const char *devargs_str);/** +* Remove a device from the user device list. +* The devargs is then freed. +* +* @param da +* devargs to remove. +* +* @return +* 0 on success. +* <0 on error. +* >0 if the devargs was not within the user device list. +*/ +int rte_eal_devargs_rmv (struct rte_devargs *da); + +/** * Deep copy an rte_devargs. * * @param da
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -208,5 +208,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; rte_eal_devargs_clone; + rte_eal_devargs_rmv; } DPDK_17.05;
Signature · 1 line
2.1.4
PATCH v4 19/19 eal: change whitelist / blacklist command line doc
In reply to Gaetan RivetThe use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.
Update the source code accordingly.
--- lib/librte_eal/common/eal_common_options.c | 18 +++++++++--------- lib/librte_eal/common/eal_options.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-)
lib/librte_eal/common/eal_common_options.c +9 -9
@@ -86,8 +86,8 @@ eal_long_options[] = { {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM }, {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM }, {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM }, - {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM }, - {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM }, + {OPT_BUS_BLACKLIST, 1, NULL, OPT_BUS_BLACKLIST_NUM }, + {OPT_BUS_WHITELIST, 1, NULL, OPT_BUS_WHITELIST_NUM }, {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM }, {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM }, {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
@@ -1049,14 +1049,14 @@ eal_common_usage(void)" -n CHANNELS Number of memory channels\n" " -m MB Memory to allocate (see also --" OPT_SOCKET_MEM ")\n" " -r RANKS Force number of memory ranks (don't detect)\n" -" -b, --" OPT_PCI_BLACKLIST " Add a PCI device in black list.\n" -" Prevent EAL from using this PCI device. The argument\n" -" format is <domain:bus:devid.func>.\n" -" -w, --" OPT_PCI_WHITELIST " Add a PCI device in white list.\n" -" Only use the specified PCI devices. The argument format\n" -" is <[domain:]bus:devid.func>. This option can be present\n" +" -b, --" OPT_BUS_BLACKLIST " Black list a device on its bus.\n" +" Prevents EAL from using this device. The argument\n" +" format depends on the bus.\n" +" -w, --" OPT_BUS_WHITELIST " White list a device on its bus.\n" +" Only use the specified devices. The argument format\n" +" depends on the bus. This option can be present\n" " several times (once per device).\n" -" [NOTE: PCI whitelist cannot be used with -b option]\n" +" [NOTE: whitelist cannot be used with -b option]\n" " --" OPT_VDEV " Add a virtual device.\n" " The argument format is <driver><id>[,key=val,...]\n" " (ex: --vdev=net_pcap0,iface=eth2).\n"
lib/librte_eal/common/eal_options.h +4 -4
@@ -37,10 +37,10 @@ enum {/* long options mapped to a short option */ #define OPT_HELP "help" OPT_HELP_NUM = 'h', -#define OPT_PCI_BLACKLIST "pci-blacklist" - OPT_PCI_BLACKLIST_NUM = 'b', -#define OPT_PCI_WHITELIST "pci-whitelist" - OPT_PCI_WHITELIST_NUM = 'w', +#define OPT_BUS_BLACKLIST "bus-blacklist" + OPT_BUS_BLACKLIST_NUM = 'b', +#define OPT_BUS_WHITELIST "bus-whitelist" + OPT_BUS_WHITELIST_NUM = 'w',/* first long only option value must be >= 256, so that we won't * conflict with short options */
Signature · 1 line
2.1.4
v5 cover Generic devargs parsing
In reply to Gaetan RivetThe second part of the work outlined in [1] and [2]. The first part is at [3].
In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.
The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.
Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.
With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.
Buses needs only to implement the "parse" method for their devices to be declared in this way.
[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html
This patchset depends on:
[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/
v1 -> v2:
* fix PCI whitelist mode
v2 -> v3:
* Rebase the series on the new plug / unplug API
v3 -> v4:
* Fix rte_devargs parsing helper
* Introduce new rte_devargs clone function
* Introduce new rte_devargs release function
* Fix test application for rte_devargs.
TODO: rewrite complete rte_devargs autotest.
* Fix a few rte_pci references.
* Update EAL command line help for -w / -b
v5:
* Fix integration issue with new arbitrary bus name parsing.
Gaetan Rivet (19):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc
app/test-pmd/testpmd.c | 9 +- app/test-pmd/testpmd.h | 2 + doc/guides/rel_notes/deprecation.rst | 5 + drivers/net/bnxt/bnxt.h | 1 + drivers/net/bonding/rte_eth_bond_args.c | 1 + drivers/net/e1000/e1000_ethdev.h | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/sfc/sfc.h | 1 + drivers/net/virtio/virtio_pci.c | 5 +- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 + lib/librte_eal/common/eal_common_devargs.c | 176 ++++++++++++++++-------- lib/librte_eal/common/eal_common_options.c | 31 ++--- lib/librte_eal/common/eal_common_pci.c | 16 ++- lib/librte_eal/common/eal_common_vdev.c | 18 ++- lib/librte_eal/common/eal_options.h | 8 +- lib/librte_eal/common/include/rte_bus.h | 17 +++ lib/librte_eal/common/include/rte_dev.h | 12 ++ lib/librte_eal/common/include/rte_devargs.h | 68 ++++++--- lib/librte_eal/common/include/rte_pci.h | 9 -- lib/librte_eal/common/include/rte_vdev.h | 2 +- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 + test/test/test_devargs.c | 45 +++--- test/test/virtual_pmd.c | 1 + 24 files changed, 278 insertions(+), 156 deletions(-)
Signature · 1 line
2.1.4
PATCH v5 1/19 net/bonding: properly reference PCI header
--- drivers/net/bonding/rte_eth_bond_args.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
@@ -32,6 +32,7 @@*/ #include <rte_devargs.h> +#include <rte_pci.h> #include <rte_kvargs.h> #include <cmdline_parse.h>
Signature · 1 line
2.1.4
PATCH v5 2/19 net/bnxt: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/bnxt/bnxt.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
@@ -38,6 +38,7 @@#include <stdbool.h> #include <sys/queue.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_memory.h> #include <rte_lcore.h>
Signature · 1 line
2.1.4
PATCH v5 3/19 net/mlx5: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/mlx5/mlx5.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -54,6 +54,7 @@#ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"#endif +#include <rte_pci.h> #include <rte_ether.h> #include <rte_ethdev.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v5 4/19 net/e1000: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/e1000/e1000_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
@@ -34,6 +34,7 @@#ifndef _E1000_ETHDEV_H_#define _E1000_ETHDEV_H_#include <rte_time.h> +#include <rte_pci.h> #define E1000_INTEL_VENDOR_ID 0x8086
Signature · 1 line
2.1.4
PATCH v5 5/19 net/ixgbe: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -39,6 +39,7 @@#include "ixgbe_bypass.h" #include <rte_time.h> #include <rte_hash.h> +#include <rte_pci.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
PATCH v5 6/19 net/sfc: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/sfc/sfc.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
@@ -34,6 +34,7 @@#include <stdbool.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_kvargs.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v5 7/19 app/testpmd: properly reference PCI header
In reply to Gaetan Rivet--- app/test-pmd/testpmd.h | 2 ++ 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
@@ -34,6 +34,8 @@#ifndef _TESTPMD_H_#define _TESTPMD_H_ +#include <rte_pci.h> +#define RTE_PORT_ALL (~(portid_t)0x0)#define RTE_TEST_RX_DESC_MAX 2048
Signature · 1 line
2.1.4
PATCH v5 8/19 test: properly reference PCI header
In reply to Gaetan Rivet--- test/test/virtual_pmd.c | 1 + 1 file changed, 1 insertion(+)
test/test/virtual_pmd.c +1 -0
@@ -33,6 +33,7 @@#include <rte_mbuf.h> #include <rte_ethdev.h> +#include <rte_pci.h> #include <rte_malloc.h> #include <rte_memcpy.h> #include <rte_memory.h>
Signature · 1 line
2.1.4
PATCH v5 9/19 dev: device kernel module is a device attribute
In reply to Gaetan RivetIt is used in generic device structures and must not be tied to a bus.
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) }while (0 )/** +* Device driver. +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , + RTE_KDRV_NONE, +}; + +/** * A generic memory resource representation. */ struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -120,15 +120,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.1.4
PATCH v5 10/19 bus: introduce bus scan policies
In reply to Gaetan RivetScan policies describe the way a bus should scan the system to search for possible devices.
Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices
--- lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
@@ -137,6 +137,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);typedef int (*rte_bus_parse_t )(const char *name,void *addr);/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_WHITELIST , +RTE_BUS_SCAN_BLACKLIST , +}; + +/** +* A structure used to configure bus operations. +*/ +struct rte_bus_conf { +enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ +}; + +/** * A structure describing a generic bus. */ struct rte_bus {
@@ -148,6 +164,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +struct rte_bus_conf conf;/**< Bus configuration */ };/**
Signature · 1 line
2.1.4
Re: [PATCH v5 10/19] bus: introduce bus scan policies
21/06/2017 01:35, Gaetan Rivet:
Quoted 9 lines
Scan policies describe the way a bus should scan the system to search for possible devices.
Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devicesSigned-off-by Gaetan Rivet <[email protected]>
[...]
lib/librte_eal/common/include/rte_bus.h struct rte_bus { · line 168
Quoted 6 lines
lib/librte_eal/common/include/rte_bus.h +1
-0@@ -148,6 +164,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +struct rte_bus_conf conf;/**< Bus configuration */ };
You are making explicit what exists currently:
- the PCI bus has a whitelist/blacklist policy
- the vdev bus is only a whitelist
It is a good step to deinterlace some spaghettis in the code.
For the next step, the bus should have no policy. It scans everything. We can have a probing policy, but it should not be stored in the bus. I suggest to add a callback in the probe function which would implement the probing policy:
FOREACH_DEV_IN_BUS {
if (user_callback(dev, user_data))
probe_one(dev);
}For compatibility, rte_eal_init() would call rte_bus_probe() with a default callback which checks the whitelists and blacklists for PCI.
PATCH v5 11/19 devargs: parse bus policies
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
@@ -128,6 +128,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)break ; } +if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }free (buf);TAILQ_INSERT_TAIL (&devargs_list, devargs, next);
Signature · 1 line
2.1.4
PATCH v5 12/19 devargs: generic device representation
In reply to Gaetan RivetRemove the dependency of this subsystem upon bus specific device representation.
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
--- app/test-pmd/testpmd.c | 9 ++---- lib/librte_eal/common/eal_common_devargs.c | 48 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 17 +++++----- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- test/test/test_devargs.c | 9 ++---- 7 files changed, 30 insertions(+), 80 deletions(-)
app/test-pmd/testpmd.c +2 -7
@@ -1810,7 +1810,6 @@ rmv_event_callback(void *arg) {struct rte_eth_dev *dev;struct rte_devargs *da; -char name[32 ] ="" ;uint8_t port_id = (intptr_t )arg;RTE_ETH_VALID_PORTID_OR_RET (port_id);
@@ -1819,12 +1818,8 @@ rmv_event_callback(void *arg)stop_port (port_id);close_port (port_id); -if (da->type ==RTE_DEVTYPE_VIRTUAL ) -snprintf (name,sizeof (name),"%s" , da->virt.drv_name); -else if (da->type ==RTE_DEVTYPE_WHITELISTED_PCI ) -rte_pci_device_name (&da->pci.addr, name,sizeof (name)); -printf ("removing device %s\n" , name); -rte_eal_dev_detach (name); +printf ("removing device %s\n" , da->name); +rte_eal_dev_detach (da->name); dev->state =RTE_ETH_DEV_UNUSED ; }
lib/librte_eal/common/eal_common_devargs.c +8 -40
66 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +6 -3
@@ -73,12 +73,15 @@ const char *pci_get_sysfs_path(void)static struct rte_devargs *pci_devargs_lookup (struct rte_pci_device *dev) {struct rte_devargs *devargs; +struct rte_pci_addr addr; +struct rte_bus *pbus; + pbus =rte_bus_from_name (PCI_BUS_NAME ); TAILQ_FOREACH(devargs, &devargs_list, next) { -if (devargs->type !=RTE_DEVTYPE_BLACKLISTED_PCI && - devargs->type !=RTE_DEVTYPE_WHITELISTED_PCI ) +if (devargs->bus != pbus)continue ; -if (!rte_eal_compare_pci_addr (&dev->addr, &devargs->pci.addr)) + devargs->bus->parse (devargs->name, &addr); +if (!rte_eal_compare_pci_addr (&dev->addr, &addr))return devargs; }return NULL ;
lib/librte_eal/common/eal_common_vdev.c +8 -9
@@ -186,9 +186,8 @@ alloc_devargs(const char *name, const char *args)if (args) devargs->args =strdup (args); - ret =snprintf (devargs->virt.drv_name, -sizeof (devargs->virt.drv_name),"%s" , name); -if (ret <0 || ret >= (int )sizeof (devargs->virt.drv_name)) { + ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , name); +if (ret <0 || ret >= (int )sizeof (devargs->name)) {free (devargs->args);free (devargs);return NULL ;
@@ -223,7 +222,7 @@ rte_vdev_init(const char *name, const char *args) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name; ret =vdev_probe_all_drivers (dev);if (ret) {
@@ -304,7 +303,7 @@ vdev_scan(void)if (devargs->bus != vbus)continue ; - dev =find_vdev (devargs->virt.drv_name); + dev =find_vdev (devargs->name);if (dev)continue ;
@@ -314,7 +313,7 @@ vdev_scan(void) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name;TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); }
@@ -361,12 +360,12 @@ vdev_plug(struct rte_devargs *da)struct rte_vdev_device *dev;int ret; - ret =rte_vdev_init (da->virt.drv_name, da->args); + ret =rte_vdev_init (da->name, da->args);if (ret) { rte_errno = -ret;return NULL ; } - dev =find_vdev (da->virt.drv_name); + dev =find_vdev (da->name);return &dev->device; }
@@ -381,7 +380,7 @@ vdev_unplug(struct rte_device *dev) rte_errno =EINVAL ;return -1 ; } - ret =rte_vdev_uninit (da->virt.drv_name); + ret =rte_vdev_uninit (da->name);if (ret) rte_errno = -ret;return ret;
lib/librte_eal/common/include/rte_devargs.h +2 -14
@@ -50,7 +50,6 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> -#include <rte_pci.h> #include <rte_bus.h> /**
@@ -77,21 +76,10 @@ struct rte_devargs {TAILQ_ENTRY (rte_devargs) next;/** Type of device. */ enum rte_devtype type; -RTE_STD_C11 - union { -/** Used if type is RTE_DEVTYPE_*_PCI. */ -struct { -/** PCI location. */ -struct rte_pci_addr addr; - } pci; -/** Used if type is RTE_DEVTYPE_VIRTUAL. */ -struct { -/** Driver name. */ -char drv_name[32 ]; - } virt; - };/** Bus handle for the device. */ struct rte_bus *bus; +/** Name of the device. */ +char name[32 ];/** Arguments string as given by user or "" for no argument. */ char *args; };
lib/librte_eal/common/include/rte_vdev.h +1 -1
@@ -52,7 +52,7 @@ static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) {if (dev && dev->device.devargs) -return dev->device.devargs->virt.drv_name; +return dev->device.devargs->name;return NULL ; }
test/test/test_devargs.c +3 -6
@@ -90,8 +90,8 @@ test_devargs(void)if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,k1=val,k2=val2" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); -if (strncmp (devargs->virt.drv_name,"net_ring1" , -sizeof (devargs->virt.drv_name)) !=0 ) +if (strncmp (devargs->name,"net_ring1" , +sizeof (devargs->name)) !=0 ) goto fail;if (!devargs->args ||strcmp (devargs->args,"k1=val,k2=val2" ) !=0 ) goto fail;
@@ -101,10 +101,7 @@ test_devargs(void)if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"04:00.1" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); -if (devargs->pci.addr.domain !=0 || - devargs->pci.addr.bus !=4 || - devargs->pci.addr.devid !=0 || - devargs->pci.addr.function !=1 ) +if (strcmp (devargs->name,"04:00.1" ) !=0 ) goto fail;if (!devargs->args ||strcmp (devargs->args,"" ) !=0 ) goto fail;
Signature · 1 line
2.1.4
Re: [PATCH v5 12/19] devargs: generic device representation
21/06/2017 01:35, Gaetan Rivet:
Quoted 7 lines
Remove the dependency of this subsystem upon bus specific device representation.
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
Signed-off-by Gaetan Rivet <[email protected]>
Quoted 9 lines
--- app/test-pmd/testpmd.c | 9 ++---- lib/librte_eal/common/eal_common_devargs.c | 48 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 17 +++++----- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- test/test/test_devargs.c | 9 ++---- 7 files changed, 30 insertions(+), 80 deletions(-)
Is it correct to add this change when rebasing?
lib/librte_eal/common/eal_common_pci.c +1 -1
@@ -533,7 +533,7 @@ pci_plug(struct rte_devargs *da)struct rte_pci_device *pdev;struct rte_pci_addr *addr; - addr = &da->pci.addr; + da->bus->parse (da->name, &addr);/* * Update eventual pci device in global list. * Insert it if none was found.
Re: [PATCH v5 12/19] devargs: generic device representation
Quoted 24 lines · Thomas Monjalon
21/06/2017 01:35, Gaetan Rivet:
Quoted 7 lines
Remove the dependency of this subsystem upon bus specific device representation.
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
Signed-off-by Gaetan Rivet <[email protected]>Quoted 9 lines
--- app/test-pmd/testpmd.c | 9 ++---- lib/librte_eal/common/eal_common_devargs.c | 48 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 17 +++++----- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- test/test/test_devargs.c | 9 ++---- 7 files changed, 30 insertions(+), 80 deletions(-)Is it correct to add this change when rebasing?
lib/librte_eal/common/eal_common_pci.c pci_plug(struct rte_devargs *da) · line 539
Quoted 8 lines
lib/librte_eal/common/eal_common_pci.c +1
-1@@ -533,7 +533,7 @@ pci_plug(struct rte_devargs *da)struct rte_pci_device *pdev;struct rte_pci_addr *addr; - addr = &da->pci.addr; + da->bus->parse (da->name, &addr);/* * Update eventual pci device in global list. * Insert it if none was found.
This is the spirit of this API at least :).bus->parse() will verify that the name is correct, as well as interpret it to obtain the bus-specific representation of the device.
Quoted 2 lines
Quoted 2 lines
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
So the PCI address can be removed from rte_devargs. As such, it cannot be intepreted during parsing, and it must be done afterward from within the bus itself.
I was wondering whether I should update all subsystems relying on this previous rte_devargs logic at once, EAL + vdev + PCI + tests etc... But this is the only way to keep compilation atomicity between patches.
Signature · 2 lines
Gaëtan Rivet 6WIND
PATCH 1/1 examples/ethtool: explicit PCI header dependency
In reply to Gaetan RivetIn devargs rework, rte_pci.h won't be included by rte_ethdev.h (via rte_devargs.h) anymore.
rte_ethtool_get_drvinfo() could use rte_devargs.name instead of creating equivalent bus specific name.
For now, it is workarounded by just including rte_pci.h.
--- examples/ethtool/lib/rte_ethtool.c | 2 ++ 1 file changed, 2 insertions(+)
examples/ethtool/lib/rte_ethtool.c +2 -0
@@ -36,6 +36,7 @@#include <rte_version.h> #include <rte_ethdev.h> #include <rte_ether.h> +#include <rte_pci.h> #ifdef RTE_LIBRTE_IXGBE_PMD #include <rte_pmd_ixgbe.h> #endif
@@ -73,6 +74,7 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo) dev_info.driver_name);snprintf (drvinfo->version,sizeof (drvinfo->version),"%s" ,rte_version ()); +/* TODO: replace bus_info by rte_devargs.name */ if (dev_info.pci_dev) snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), "%04x:%02x:%02x.%x",
Signature · 1 line
2.13.1
PATCH v5 13/19 pci: update device name
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_pci.c | 1 + 1 file changed, 1 insertion(+)
lib/librte_eal/common/eal_common_pci.c +1 -0
@@ -330,6 +330,7 @@ rte_pci_probe_one(const struct rte_pci_addr *addr) ret =pci_probe_all_drivers (dev);if (ret) goto err_return; + dev->device.name = dev->device.devargs->name;return 0 ; }return -1 ;
Signature · 1 line
2.1.4
PATCH v5 14/19 net/virtio: do not reference device type
In reply to Gaetan Rivet--- drivers/net/virtio/virtio_pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
@@ -38,6 +38,7 @@#endif #include <rte_io.h> +#include <rte_bus.h> #include "virtio_pci.h" #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)if (rte_pci_ioport_map (dev,0 ,VTPCI_IO (hw)) <0 ) {if (dev->kdrv ==RTE_KDRV_UNKNOWN && (!dev->device.devargs || - dev->device.devargs->type != -RTE_DEVTYPE_WHITELISTED_PCI )) { + dev->device.devargs->bus != +rte_bus_from_name (PCI_BUS_NAME ))) {PMD_INIT_LOG (INFO ,"skip kernel managed virtio device." );return 1 ;
Signature · 1 line
2.1.4
PATCH v5 15/19 devargs: generic device types
In reply to Gaetan Rivetrte_devargs now represents any device from any bus.
The related devtypes do not identify a bus anymore, only which scan policy the device subscribes to.
The bus itself is identified by a bus handle previously introduced.
--- lib/librte_eal/common/eal_common_devargs.c | 4 ++-- lib/librte_eal/common/eal_common_options.c | 13 +++-------- lib/librte_eal/common/eal_common_pci.c | 6 ++--- lib/librte_eal/common/eal_common_vdev.c | 1 - lib/librte_eal/common/include/rte_devargs.h | 6 ++--- test/test/test_devargs.c | 36 +++++++++++++++-------------- 6 files changed, 30 insertions(+), 36 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
@@ -113,14 +113,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , buf);if (ret <0 || ret >= (int )sizeof (devargs->name)) goto fail; -if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (devargs->type ==RTE_DEVTYPE_WHITELISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) {fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); goto fail; } - }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) {
lib/librte_eal/common/eal_common_options.c +3 -10
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,switch (opt) {/* blacklist */ case 'b' : -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED , optarg) <0 ) {return -1 ; }break ;/* whitelist */ case 'w' : -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED , optarg) <0 ) {return -1 ; }
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,break ;case OPT_VDEV_NUM : -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL , +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , optarg) <0 ) {return -1 ; }
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)return -1 ; } -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=0 && -rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=0 ) { -RTE_LOG (ERR ,EAL ,"Options blacklist (-b) and whitelist (-w) " -"cannot be used at the same time\n" ); -return -1 ; - } -return 0 ; }
lib/librte_eal/common/eal_common_pci.c +3 -3
@@ -200,7 +200,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* no initialization when blacklisted, return without error */ if (dev->device.devargs !=NULL && dev->device.devargs->type == -RTE_DEVTYPE_BLACKLISTED_PCI ) { +RTE_DEVTYPE_BLACKLISTED ) {RTE_LOG (INFO ,EAL ," Device is blacklisted, not" " initializing\n" );return 1 ;
@@ -393,7 +393,7 @@ rte_pci_probe(void)int probe_all =0 ;int ret =0 ; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) ==0 ) +if (rte_pci_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_WHITELIST ) probe_all =1 ;FOREACH_DEVICE_ON_PCIBUS (dev) {
@@ -408,7 +408,7 @@ rte_pci_probe(void)if (probe_all) ret =pci_probe_all_drivers (dev);else if (devargs !=NULL && - devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) + devargs->type ==RTE_DEVTYPE_WHITELISTED ) ret =pci_probe_all_drivers (dev);if (ret <0 ) { RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
@@ -181,7 +181,6 @@ alloc_devargs(const char *name, const char *args)if (!devargs)return NULL ; - devargs->type =RTE_DEVTYPE_VIRTUAL ; devargs->bus =rte_bus_from_name (VIRTUAL_BUS_NAME );if (args) devargs->args =strdup (args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
@@ -56,9 +56,9 @@ extern "C" {* Type of generic device */ enum rte_devtype { -RTE_DEVTYPE_WHITELISTED_PCI , -RTE_DEVTYPE_BLACKLISTED_PCI , -RTE_DEVTYPE_VIRTUAL , +RTE_DEVTYPE_UNDEFINED , +RTE_DEVTYPE_WHITELISTED , +RTE_DEVTYPE_BLACKLISTED , };/**
test/test/test_devargs.c +19 -17
@@ -64,30 +64,32 @@ test_devargs(void)TAILQ_INIT (&devargs_list);/* test valid cases */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"08:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"08:00.1" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"0000:5:00.0" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"0000:5:00.0" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI ,"04:00.0,arg=val" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"04:00.0,arg=val" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI ,"0000:01:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"0000:01:00.1" ) <0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED ) !=4 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED ) !=0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_VIRTUAL ) !=0 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_UNDEFINED ) !=0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring0" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED ,"net_ring0" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,key=val,k2=val2" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , +"net_ring1,key=val,k2=val2" ) <0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_VIRTUAL ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_UNDEFINED ) !=2 ) goto fail;free_devargs_list ();/* check virtual device with argument parsing */ -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,k1=val,k2=val2" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , +"net_ring1,k1=val,k2=val2" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); if (strncmp(devargs->name, "net_ring1",
@@ -98,7 +100,7 @@ test_devargs(void)free_devargs_list ();/* check PCI device with empty argument parsing */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"04:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"04:00.1" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list);if (strcmp (devargs->name,"04:00.1" ) !=0 )
@@ -108,15 +110,15 @@ test_devargs(void)free_devargs_list ();/* test error case: bad PCI address */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"08:1" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"08:1" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"00.1" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"00.1" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"foo" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"foo" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"," ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"," ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"000f:0:0" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"000f:0:0" ) ==0 ) goto fail; devargs_list = save_devargs_list;
Signature · 1 line
2.1.4
PATCH v5 16/19 devargs: introduce cleaner parsing helper
In reply to Gaetan RivetIntroduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.
The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.
A deprecation notice is issued.
This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.
--- doc/guides/rel_notes/deprecation.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 91 ++++++++++++++++++++--------- lib/librte_eal/common/include/rte_devargs.h | 20 +++++++ 3 files changed, 90 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
@@ -105,3 +105,8 @@ Deprecation Notices The non-"do-sig" versions of the hash tables will be removed (including the ``signature_offset`` parameter) and the "do-sig" versions renamed accordingly. + +* eal: the following function is deprecated starting from 17.08 and will + be removed in 17.11: + + - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/common/eal_common_devargs.c +65 -26
118 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +20 -0
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs);/** +* Parse a device string. +* +* Verify that a bus is capable of handling the device passed +* in argument. Store which bus will handle the device, its name +* and the eventual device parameters. +* +* @param dev +* The device declaration string. +* @param da +* The devargs structure holding the device information. +* +* @return +* - 0 on success. +* - Negative errno on error. +*/ +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or
Signature · 1 line
2.1.4
Re: [PATCH v5 16/19] devargs: introduce cleaner parsing helper
21/06/2017 01:35, Gaetan Rivet:
Review
Quoted 3 lines
(quoted diff) +3
-0+int +rte_eal_devargs_parse(const char *dev, + struct rte_devargs *da);
You need to export this new function:
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -203,6 +203,7 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; rte_eal_devargs_clone; + rte_eal_devargs_parse; rte_eal_devargs_rmv; } DPDK_17.05;
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -208,6 +208,7 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; rte_eal_devargs_clone; + rte_eal_devargs_parse; rte_eal_devargs_rmv; } DPDK_17.05;
Re: [PATCH v5 16/19] devargs: introduce cleaner parsing helper
In reply to Gaetan RivetQuoted 42 lines · Gaetan Rivet
Introduce a more versatile helper to parse device strings. This helper expects a generic
rte_devargsstructure 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_devargsevolutions.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_devargsstructure and expects one to be given as input.Signed-off-by Gaetan Rivet <[email protected]>---
doc/guides/rel_notes/deprecation.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 91 ++++++++++++++++++++--------- lib/librte_eal/common/include/rte_devargs.h | 20 +++++++ 3 files changed, 90 insertions(+), 26 deletions(-)doc/guides/rel_notes/deprecation.rst +5
-0@@ -105,3 +105,8 @@ Deprecation Notices The non-"do-sig" versions of the hash tables will be removed (including the ``signature_offset`` parameter) and the "do-sig" versions renamed accordingly. + +* eal: the following function is deprecated starting from 17.08 and will + be removed in 17.11: + + - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``lib/librte_eal/common/eal_common_devargs.c +0
-0
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 82
Quoted 6 lines
lib/librte_eal/common/eal_common_devargs.c +3
-0@@ -77,6 +77,66 @@ rte_eal_parse_devargs_str(const char *devargs_str,return 0 ; } +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da)
Does this line need to be broken into two lines?
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 90
Quoted 8 lines
lib/librte_eal/common/eal_common_devargs.c +8
-0+{ +struct rte_bus *bus; +const char *c; +const size_t maxlen =sizeof (da->name); +size_t i; + +if ((dev) ==NULL || (da) ==NULL ) +return -EINVAL ;
Why have () around these variables and I think the normal method is ‘if (!dev || !da) …’ is that preferred method?
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str,
Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7
-0+ c = dev; +/* Retrieve eventual bus info */ + bus =rte_bus_from_name (dev); +if (bus) { + i =strlen (bus->name); +if (dev[i] =='\0' ) { + fprintf(stderr, "WARNING: device name matches a bus name.\n”);
At this point has the RTE_LOG() system been inited?
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 104
Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7
-0+ bus =NULL ; + }else if (rte_bus_from_dev (dev)) { +/* false positive on bus name. */ + bus =NULL ; + }else { + c = &dev[i+1 ]; + }
Single line if/else statements do not use the “{}” around the one line. I believe this is the default rule. Does it count for the 'else if' above it too?
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 113
Quoted 9 lines
lib/librte_eal/common/eal_common_devargs.c +9
-0+ } +/* Store device name */ + i =0 ; +while (c[i] !='\0' && c[i] !=',' ) { + da->name[i] = c[i]; + i++; +if (i == maxlen) { +fprintf (stderr,"WARNING: Parsing \"%s\": device name should be shorter than %zu\n" , + dev, maxlen);
Same question here. is this line too long?
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 114
Quoted 1 line
lib/librte_eal/common/eal_common_devargs.c +1
-0+ da->name[i-1] = '\0’;
I believe the must have spaces around the - e.g. [i - 1]
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 123
Quoted 9 lines
lib/librte_eal/common/eal_common_devargs.c +9
-0+return -EINVAL ; + } + } + da->name[i] ='\0' ; +if (!bus) { + bus =rte_bus_from_dev (da->name); +if (!bus) { +fprintf (stderr,"ERROR: failed to parse bus info from device \"%s\"\n" , + da->name);
Same here.
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 130
Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7
-0+return -EFAULT ; + } + } + da->bus = bus; +/* Parse eventual device arguments */ +if (c[i] ==',' ) + da->args =strdup (&c[i+1 ]);
[i + 1]
Quoted 100 lines
lib/librte_eal/common/eal_common_devargs.c +9
-0+else + da->args =strdup ("" ); +if (da->args ==NULL ) { +fprintf (stderr,"ERROR: not enough memory to parse arguments\n" ); +return -ENOMEM ; + } +return 0 ; +} +/* store a whitelist parameter for later parsing */ int
rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)lib/librte_eal/common/eal_common_devargs.c +5
-25@@ -84,35 +144,16 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)struct rte_devargs *devargs =NULL ;const char *dev = devargs_str;struct rte_bus *bus; -char *buf =NULL ; -int ret; -/* use malloc instead of rte_malloc as it's called early at init */ - devargs =malloc (sizeof (*devargs)); +/* use calloc instead of rte_zmalloc as it's called early at init */ + devargs =calloc (1 ,sizeof (*devargs));if (devargs ==NULL ) goto fail; -memset (devargs,0 ,sizeof (*devargs)); - devargs->type = devtype; - - bus =rte_bus_from_name (dev); -if (bus) { - dev +=strlen (bus->name) +1 ; - }else { - bus =rte_bus_from_dev (dev); -if (!bus) { -fprintf (stderr,"ERROR: failed to parse bus info from device declaration\n" ); - goto fail; - } - } - devargs->bus = bus; -if (rte_eal_parse_devargs_str (dev, &buf, &devargs->args)) - goto fail; - -/* save device name. */ - ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , buf); -if (ret <0 || ret >= (int )sizeof (devargs->name)) +if (rte_eal_devargs_parse (dev, devargs)) goto fail; + devargs->type = devtype; + bus = devargs->bus;if (devargs->type ==RTE_DEVTYPE_WHITELISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ;@@ -129,12 +170,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) } } -free (buf);TAILQ_INSERT_TAIL (&devargs_list, devargs, next);return 0 ;fail:
lib/librte_eal/common/eal_common_devargs.c +0
-1-free (buf);if (devargs) { free(devargs->args); free(devargs);lib/librte_eal/common/include/rte_devargs.h +20
-0@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs);/** +* Parse a device string. +* +* Verify that a bus is capable of handling the device passed +* in argument. Store which bus will handle the device, its name +* and the eventual device parameters. +* +* @param dev +* The device declaration string. +* @param da +* The devargs structure holding the device information. +* +* @return +* - 0 on success. +* - Negative errno on error. +*/ +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or Signature · 1 line
2.1.4
Regards,
Keith
Re: [PATCH v5 16/19] devargs: introduce cleaner parsing helper
Hi Keith,
Thanks for the review.
Quoted 45 lines · Keith
Quoted 45 lines · Gaetan Rivet
Introduce a more versatile helper to parse device strings. This helper expects a generic
rte_devargsstructure 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_devargsevolutions.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_devargsstructure and expects one to be given as input.Signed-off-by Gaetan Rivet <[email protected]>---
doc/guides/rel_notes/deprecation.rst | 5 ++ lib/librte_eal/common/eal_common_devargs.c | 91 ++++++++++++++++++++--------- lib/librte_eal/common/include/rte_devargs.h | 20 +++++++ 3 files changed, 90 insertions(+), 26 deletions(-)doc/guides/rel_notes/deprecation.rst +5
-0@@ -105,3 +105,8 @@ Deprecation Notices The non-"do-sig" versions of the hash tables will be removed (including the ``signature_offset`` parameter) and the "do-sig" versions renamed accordingly. + +* eal: the following function is deprecated starting from 17.08 and will + be removed in 17.11: + + - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``lib/librte_eal/common/eal_common_devargs.c +0
-0@@ -77,6 +77,66 @@ rte_eal_parse_devargs_str(const char *devargs_str,return 0 ; }
Quoted 6 lines
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 82
Quoted 3 lines
lib/librte_eal/common/eal_common_devargs.c +3
-0+int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da)Does this line need to be broken into two lines?
Not really, will change.
Quoted 11 lines
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 90
Quoted 8 lines
lib/librte_eal/common/eal_common_devargs.c +8
-0+{ +struct rte_bus *bus; +const char *c; +const size_t maxlen =sizeof (da->name); +size_t i; + +if ((dev) ==NULL || (da) ==NULL ) +return -EINVAL ;Why have () around these variables and I think the normal method is ‘if (!dev || !da) …’ is that preferred method?
No reason for the additional parenthesis.
Otherwise, the explicit test against NULL is preferred in the guideline.
Quoted 10 lines
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str,
Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7
-0+ c = dev; +/* Retrieve eventual bus info */ + bus =rte_bus_from_name (dev); +if (bus) { + i =strlen (bus->name); +if (dev[i] =='\0' ) { + fprintf(stderr, "WARNING: device name matches a bus name.\n”);At this point has the
RTE_LOG()system been inited?
This helper is typically called very early at init. Right underneath, rte_eal_devargs_add also avoids using RTE_LOG. It may be a mistake, I must look into it.
Quoted 10 lines
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 104
Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7
-0+ bus =NULL ; + }else if (rte_bus_from_dev (dev)) { +/* false positive on bus name. */ + bus =NULL ; + }else { + c = &dev[i+1 ]; + }Single line if/else statements do not use the “{}” around the one line. I believe this is the default rule. Does it count for the 'else if' above it too?
Right.
Quoted 12 lines
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 113
Quoted 9 lines
lib/librte_eal/common/eal_common_devargs.c +9
-0+ } +/* Store device name */ + i =0 ; +while (c[i] !='\0' && c[i] !=',' ) { + da->name[i] = c[i]; + i++; +if (i == maxlen) { +fprintf (stderr,"WARNING: Parsing \"%s\": device name should be shorter than %zu\n" , + dev, maxlen);Same question here. is this line too long?
Error strings should not be cut through to allow grepping for it.
Quoted 4 lines
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 114
Quoted 1 line
lib/librte_eal/common/eal_common_devargs.c +1
-0+ da->name[i-1] = '\0’;I believe the must have spaces around the - e.g. [i - 1]
yes
Quoted 125 lines
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 123
Quoted 9 lines
lib/librte_eal/common/eal_common_devargs.c +9
-0+return -EINVAL ; + } + } + da->name[i] ='\0' ; +if (!bus) { + bus =rte_bus_from_dev (da->name); +if (!bus) { +fprintf (stderr,"ERROR: failed to parse bus info from device \"%s\"\n" , + da->name);Same here.
lib/librte_eal/common/eal_common_devargs.c rte_eal_parse_devargs_str(const char *devargs_str, · line 130
Quoted 7 lines
lib/librte_eal/common/eal_common_devargs.c +7
-0+return -EFAULT ; + } + } + da->bus = bus; +/* Parse eventual device arguments */ +if (c[i] ==',' ) + da->args =strdup (&c[i+1 ]);[i + 1]
Quoted 100 lines
lib/librte_eal/common/eal_common_devargs.c +9
-0+else + da->args =strdup ("" ); +if (da->args ==NULL ) { +fprintf (stderr,"ERROR: not enough memory to parse arguments\n" ); +return -ENOMEM ; + } +return 0 ; +} +/* store a whitelist parameter for later parsing */ int
rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)lib/librte_eal/common/eal_common_devargs.c +5
-25@@ -84,35 +144,16 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)struct rte_devargs *devargs =NULL ;const char *dev = devargs_str;struct rte_bus *bus; -char *buf =NULL ; -int ret; -/* use malloc instead of rte_malloc as it's called early at init */ - devargs =malloc (sizeof (*devargs)); +/* use calloc instead of rte_zmalloc as it's called early at init */ + devargs =calloc (1 ,sizeof (*devargs));if (devargs ==NULL ) goto fail; -memset (devargs,0 ,sizeof (*devargs)); - devargs->type = devtype; - - bus =rte_bus_from_name (dev); -if (bus) { - dev +=strlen (bus->name) +1 ; - }else { - bus =rte_bus_from_dev (dev); -if (!bus) { -fprintf (stderr,"ERROR: failed to parse bus info from device declaration\n" ); - goto fail; - } - } - devargs->bus = bus; -if (rte_eal_parse_devargs_str (dev, &buf, &devargs->args)) - goto fail; - -/* save device name. */ - ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , buf); -if (ret <0 || ret >= (int )sizeof (devargs->name)) +if (rte_eal_devargs_parse (dev, devargs)) goto fail; + devargs->type = devtype; + bus = devargs->bus;if (devargs->type ==RTE_DEVTYPE_WHITELISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ;@@ -129,12 +170,10 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) } } -free (buf);TAILQ_INSERT_TAIL (&devargs_list, devargs, next);return 0 ;fail:
lib/librte_eal/common/eal_common_devargs.c +0
-1-free (buf);if (devargs) { free(devargs->args); free(devargs);lib/librte_eal/common/include/rte_devargs.h +20
-0@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs);/** +* Parse a device string. +* +* Verify that a bus is capable of handling the device passed +* in argument. Store which bus will handle the device, its name +* and the eventual device parameters. +* +* @param dev +* The device declaration string. +* @param da +* The devargs structure holding the device information. +* +* @return +* - 0 on success. +* - Negative errno on error. +*/ +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or Signature · 1 line
2.1.4Regards,
Keith
Signature · 2 lines
Gaëtan Rivet 6WIND
PATCH v5 17/19 devargs: clone function
In reply to Gaetan RivetThis function returns a deep copy of an rte_devargs.
--- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 20 ++++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 12 ++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 34 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -203,5 +203,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; + rte_eal_devargs_clone; } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +20 -0
@@ -41,6 +41,7 @@#include <string.h> #include <rte_devargs.h> +#include <rte_tailq.h> #include "eal_private.h" /** Global list of user devices */
@@ -182,6 +183,25 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)return -1 ; } +/* Deep-copy of an rte_devargs. */ +struct rte_devargs * +rte_eal_devargs_clone (struct rte_devargs *da) +{ +struct rte_devargs *clone; + + clone =calloc (1 ,sizeof (*clone)); +if (clone ==NULL ) +return NULL ; +snprintf (clone->name,sizeof (clone->name),"%s" , da->name); + clone->args =strdup (da->args ? da->args :"" ); + clone->bus = da->bus; +if (clone->args ==NULL ) { +free (clone); +return NULL ; + } +return clone; +} +/* count the number of devices of a specified type */ unsigned int rte_eal_devargs_type_count (enum rte_devtype devtype)
lib/librte_eal/common/include/rte_devargs.h +12 -0
@@ -163,6 +163,18 @@ rte_eal_devargs_parse(const char *dev,int rte_eal_devargs_add (enum rte_devtype devtype,const char *devargs_str);/** +* Deep copy an rte_devargs. +* +* @param da +* Source devargs. +* +* @return +* The pointer to the new rte_devargs on success. +* NULL on error. +*/ +struct rte_devargs *rte_eal_devargs_clone (struct rte_devargs *da); + +/** * Count the number of user devices of a specified type * * @param devtype
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -207,5 +207,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; + rte_eal_devargs_clone; } DPDK_17.05;
Signature · 1 line
2.1.4
PATCH v5 18/19 devargs: remove function
In reply to Gaetan RivetThis function is now necessary due to the new unplug rte_bus API.
--- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 18 ++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 14 ++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 34 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -204,5 +204,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; rte_eal_devargs_clone; + rte_eal_devargs_rmv; } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +18 -0
@@ -183,6 +183,24 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)return -1 ; } +/* Remove and free an rte_devargs. */ +int +rte_eal_devargs_rmv (struct rte_devargs *da) +{ +struct rte_devargs *d; +void *tmp; + + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { +if (d == da) { +TAILQ_REMOVE (&devargs_list, d, next); +free (d->args); +free (d); +return 0 ; + } + } +return 1 ; +} +/* Deep-copy of an rte_devargs. */ struct rte_devargs *rte_eal_devargs_clone (struct rte_devargs *da)
lib/librte_eal/common/include/rte_devargs.h +14 -0
@@ -163,6 +163,20 @@ rte_eal_devargs_parse(const char *dev,int rte_eal_devargs_add (enum rte_devtype devtype,const char *devargs_str);/** +* Remove a device from the user device list. +* The devargs is then freed. +* +* @param da +* devargs to remove. +* +* @return +* 0 on success. +* <0 on error. +* >0 if the devargs was not within the user device list. +*/ +int rte_eal_devargs_rmv (struct rte_devargs *da); + +/** * Deep copy an rte_devargs. * * @param da
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -208,5 +208,6 @@ DPDK_17.08 { rte_bus_from_name; rte_bus_from_dev; rte_eal_devargs_clone; + rte_eal_devargs_rmv; } DPDK_17.05;
Signature · 1 line
2.1.4
PATCH v5 19/19 eal: change whitelist / blacklist command line doc
In reply to Gaetan RivetThe use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.
Update the source code accordingly.
--- lib/librte_eal/common/eal_common_options.c | 18 +++++++++--------- lib/librte_eal/common/eal_options.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-)
lib/librte_eal/common/eal_common_options.c +9 -9
@@ -86,8 +86,8 @@ eal_long_options[] = { {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM }, {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM }, {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM }, - {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM }, - {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM }, + {OPT_BUS_BLACKLIST, 1, NULL, OPT_BUS_BLACKLIST_NUM }, + {OPT_BUS_WHITELIST, 1, NULL, OPT_BUS_WHITELIST_NUM }, {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM }, {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM }, {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
@@ -1049,14 +1049,14 @@ eal_common_usage(void)" -n CHANNELS Number of memory channels\n" " -m MB Memory to allocate (see also --" OPT_SOCKET_MEM ")\n" " -r RANKS Force number of memory ranks (don't detect)\n" -" -b, --" OPT_PCI_BLACKLIST " Add a PCI device in black list.\n" -" Prevent EAL from using this PCI device. The argument\n" -" format is <domain:bus:devid.func>.\n" -" -w, --" OPT_PCI_WHITELIST " Add a PCI device in white list.\n" -" Only use the specified PCI devices. The argument format\n" -" is <[domain:]bus:devid.func>. This option can be present\n" +" -b, --" OPT_BUS_BLACKLIST " Black list a device on its bus.\n" +" Prevents EAL from using this device. The argument\n" +" format depends on the bus.\n" +" -w, --" OPT_BUS_WHITELIST " White list a device on its bus.\n" +" Only use the specified devices. The argument format\n" +" depends on the bus. This option can be present\n" " several times (once per device).\n" -" [NOTE: PCI whitelist cannot be used with -b option]\n" +" [NOTE: whitelist cannot be used with -b option]\n" " --" OPT_VDEV " Add a virtual device.\n" " The argument format is <driver><id>[,key=val,...]\n" " (ex: --vdev=net_pcap0,iface=eth2).\n"
lib/librte_eal/common/eal_options.h +4 -4
@@ -37,10 +37,10 @@ enum {/* long options mapped to a short option */ #define OPT_HELP "help" OPT_HELP_NUM = 'h', -#define OPT_PCI_BLACKLIST "pci-blacklist" - OPT_PCI_BLACKLIST_NUM = 'b', -#define OPT_PCI_WHITELIST "pci-whitelist" - OPT_PCI_WHITELIST_NUM = 'w', +#define OPT_BUS_BLACKLIST "bus-blacklist" + OPT_BUS_BLACKLIST_NUM = 'b', +#define OPT_BUS_WHITELIST "bus-whitelist" + OPT_BUS_WHITELIST_NUM = 'w',/* first long only option value must be >= 256, so that we won't * conflict with short options */
Signature · 1 line
2.1.4
Re: [PATCH v5 19/19] eal: change whitelist / blacklist command line doc
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Wednesday, June 21, 2017 12:36 AM
To: [email protected]
Cc: Gaetan Rivet <[email protected]>
Subject: [dpdk-dev] [PATCH v5 19/19] eal: change whitelist / blacklist command line doc
Quoted 6 lines
The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.Update the source code accordingly.
Signed-off-by Gaetan Rivet <[email protected]>
v6 cover Generic devargs parsing
In reply to Gaetan RivetThe second part of the work outlined in [1] and [2]. The first part is at [3].
In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.
The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.
Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.
With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.
Buses needs only to implement the "parse" method for their devices to be declared in this way.
[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html
This patchset depends on:
[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/
v1 -> v2:
* fix PCI whitelist mode
v2 -> v3:
* Rebase the series on the new plug / unplug API
v3 -> v4:
* Fix rte_devargs parsing helper
* Introduce new rte_devargs clone function
* Introduce new rte_devargs release function
* Fix test application for rte_devargs.
TODO: rewrite complete rte_devargs autotest.
* Fix a few rte_pci references.
* Update EAL command line help for -w / -b
v5:
* Fix integration issue with new arbitrary bus name parsing.
v6:
* Follow new hotplug & parse API
* Export rte_eal_devargs_parse symbol
* Improve the devargs parsing in regard to possible bus / dev naming ambiguities.
* A few code style issues fixed.
* The EAL dependency on vdev is not fixed anymore It is beyond the scope of this patchset.
Gaetan Rivet (19):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc
app/test-pmd/testpmd.c | 9 +- app/test-pmd/testpmd.h | 2 + doc/guides/rel_notes/deprecation.rst | 5 + drivers/net/bnxt/bnxt.h | 1 + drivers/net/bonding/rte_eth_bond_args.c | 1 + drivers/net/e1000/e1000_ethdev.h | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/sfc/sfc.h | 1 + drivers/net/virtio/virtio_pci.c | 5 +- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 3 + lib/librte_eal/common/eal_common_bus.c | 9 +- lib/librte_eal/common/eal_common_devargs.c | 166 +++++++++++++++--------- lib/librte_eal/common/eal_common_options.c | 31 ++--- lib/librte_eal/common/eal_common_pci.c | 16 ++- lib/librte_eal/common/eal_common_vdev.c | 12 +- lib/librte_eal/common/eal_options.h | 8 +- lib/librte_eal/common/include/rte_bus.h | 17 +++ lib/librte_eal/common/include/rte_dev.h | 12 ++ lib/librte_eal/common/include/rte_devargs.h | 68 +++++++--- lib/librte_eal/common/include/rte_pci.h | 9 -- lib/librte_eal/common/include/rte_vdev.h | 2 +- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 3 + test/test/test_devargs.c | 45 ++++--- test/test/virtual_pmd.c | 1 + 25 files changed, 270 insertions(+), 159 deletions(-)
Signature · 1 line
2.1.4
PATCH v6 1/19 net/bonding: properly reference PCI header
--- drivers/net/bonding/rte_eth_bond_args.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
@@ -32,6 +32,7 @@*/ #include <rte_devargs.h> +#include <rte_pci.h> #include <rte_kvargs.h> #include <cmdline_parse.h>
Signature · 1 line
2.1.4
PATCH v6 2/19 net/bnxt: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/bnxt/bnxt.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
@@ -38,6 +38,7 @@#include <stdbool.h> #include <sys/queue.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_memory.h> #include <rte_lcore.h>
Signature · 1 line
2.1.4
PATCH v6 3/19 net/mlx5: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/mlx5/mlx5.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -54,6 +54,7 @@#ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"#endif +#include <rte_pci.h> #include <rte_ether.h> #include <rte_ethdev.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v6 4/19 net/e1000: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/e1000/e1000_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
@@ -34,6 +34,7 @@#ifndef _E1000_ETHDEV_H_#define _E1000_ETHDEV_H_#include <rte_time.h> +#include <rte_pci.h> #define E1000_INTEL_VENDOR_ID 0x8086
Signature · 1 line
2.1.4
PATCH v6 5/19 net/ixgbe: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -39,6 +39,7 @@#include "ixgbe_bypass.h" #include <rte_time.h> #include <rte_hash.h> +#include <rte_pci.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
PATCH v6 6/19 net/sfc: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/sfc/sfc.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
@@ -34,6 +34,7 @@#include <stdbool.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_kvargs.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v6 7/19 app/testpmd: properly reference PCI header
In reply to Gaetan Rivet--- app/test-pmd/testpmd.h | 2 ++ 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
@@ -34,6 +34,8 @@#ifndef _TESTPMD_H_#define _TESTPMD_H_ +#include <rte_pci.h> +#define RTE_PORT_ALL (~(portid_t)0x0)#define RTE_TEST_RX_DESC_MAX 2048
Signature · 1 line
2.1.4
PATCH v6 8/19 test: properly reference PCI header
In reply to Gaetan Rivet--- test/test/virtual_pmd.c | 1 + 1 file changed, 1 insertion(+)
test/test/virtual_pmd.c +1 -0
@@ -33,6 +33,7 @@#include <rte_mbuf.h> #include <rte_ethdev.h> +#include <rte_pci.h> #include <rte_malloc.h> #include <rte_memcpy.h> #include <rte_memory.h>
Signature · 1 line
2.1.4
PATCH v6 9/19 dev: device kernel module is a device attribute
In reply to Gaetan RivetIt is used in generic device structures and must not be tied to a bus.
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) }while (0 )/** +* Device driver. +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , + RTE_KDRV_NONE, +}; + +/** * A generic memory resource representation. */ struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -117,15 +117,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.1.4
PATCH v6 10/19 bus: introduce bus scan policies
In reply to Gaetan RivetScan policies describe the way a bus should scan the system to search for possible devices.
Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices
--- lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
@@ -158,6 +158,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);typedef int (*rte_bus_parse_t )(const char *name,void *addr);/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_WHITELIST , +RTE_BUS_SCAN_BLACKLIST , +}; + +/** +* A structure used to configure bus operations. +*/ +struct rte_bus_conf { +enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ +}; + +/** * A structure describing a generic bus. */ struct rte_bus {
@@ -169,6 +185,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +struct rte_bus_conf conf;/**< Bus configuration */ };/**
Signature · 1 line
2.1.4
PATCH v6 11/19 devargs: parse bus policies
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
@@ -143,6 +143,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)break ; } +if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }free (dev);TAILQ_INSERT_TAIL (&devargs_list, devargs, next);
Signature · 1 line
2.1.4
PATCH v6 12/19 devargs: generic device representation
In reply to Gaetan RivetRemove the dependency of this subsystem upon bus specific device representation.
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
--- app/test-pmd/testpmd.c | 9 +----- lib/librte_eal/common/eal_common_bus.c | 9 +++--- lib/librte_eal/common/eal_common_devargs.c | 47 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 11 +++---- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- test/test/test_devargs.c | 9 ++---- 8 files changed, 31 insertions(+), 81 deletions(-)
app/test-pmd/testpmd.c +1 -8
@@ -1809,21 +1809,14 @@ static void rmv_event_callback(void *arg) {struct rte_eth_dev *dev; -struct rte_devargs *da; -char name[32 ] ="" ;uint8_t port_id = (intptr_t )arg;RTE_ETH_VALID_PORTID_OR_RET (port_id); dev = &rte_eth_devices[port_id]; - da = dev->device->devargs;stop_port (port_id);close_port (port_id); -if (da->type ==RTE_DEVTYPE_VIRTUAL ) -snprintf (name,sizeof (name),"%s" , da->virt.drv_name); -else if (da->type ==RTE_DEVTYPE_WHITELISTED_PCI ) -rte_pci_device_name (&da->pci.addr, name,sizeof (name)); -printf ("removing device %s\n" , name); +printf ("removing device %s\n" , dev->device->name);rte_eal_dev_detach (dev->device); dev->state =RTE_ETH_DEV_UNUSED ; }
lib/librte_eal/common/eal_common_bus.c +5 -4
@@ -36,6 +36,7 @@#include <sys/queue.h> #include <rte_bus.h> +#include <rte_devargs.h> #include "eal_private.h"
@@ -216,12 +217,12 @@ bus_can_parse(const struct rte_bus *bus, const void *_name)struct rte_bus *rte_bus_find_by_device_name (const char *str) { -char name[32 ]; +struct rte_devargs da;char *c; -snprintf (name,sizeof (name),"%s" , str); - c =strchr (name,',' ); +snprintf (da.name,sizeof (da.name),"%s" , str); + c =strchr (da.name,',' );if (c !=NULL ) c[0 ] ='\0' ; -return rte_bus_find (NULL , bus_can_parse, name); +return rte_bus_find (NULL , bus_can_parse, da.name); }
lib/librte_eal/common/eal_common_devargs.c +8 -39
65 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +6 -3
@@ -74,12 +74,15 @@ const char *pci_get_sysfs_path(void)static struct rte_devargs *pci_devargs_lookup (struct rte_pci_device *dev) {struct rte_devargs *devargs; +struct rte_pci_addr addr; +struct rte_bus *pbus; + pbus =rte_bus_find_by_name ("pci" ); TAILQ_FOREACH(devargs, &devargs_list, next) { -if (devargs->type !=RTE_DEVTYPE_BLACKLISTED_PCI && - devargs->type !=RTE_DEVTYPE_WHITELISTED_PCI ) +if (devargs->bus != pbus)continue ; -if (!rte_eal_compare_pci_addr (&dev->addr, &devargs->pci.addr)) + devargs->bus->parse (devargs->name, &addr); +if (!rte_eal_compare_pci_addr (&dev->addr, &addr))return devargs; }return NULL ;
lib/librte_eal/common/eal_common_vdev.c +5 -6
@@ -181,9 +181,8 @@ alloc_devargs(const char *name, const char *args)if (args) devargs->args =strdup (args); - ret =snprintf (devargs->virt.drv_name, -sizeof (devargs->virt.drv_name),"%s" , name); -if (ret <0 || ret >= (int )sizeof (devargs->virt.drv_name)) { + ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , name); +if (ret <0 || ret >= (int )sizeof (devargs->name)) {free (devargs->args);free (devargs);return NULL ;
@@ -218,7 +217,7 @@ rte_vdev_init(const char *name, const char *args) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name; ret =vdev_probe_all_drivers (dev);if (ret) {
@@ -299,7 +298,7 @@ vdev_scan(void)if (devargs->bus != vbus)continue ; - dev =find_vdev (devargs->virt.drv_name); + dev =find_vdev (devargs->name);if (dev)continue ;
@@ -309,7 +308,7 @@ vdev_scan(void) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name;TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); }
lib/librte_eal/common/include/rte_devargs.h +2 -14
@@ -50,7 +50,6 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> -#include <rte_pci.h> #include <rte_bus.h> /**
@@ -77,21 +76,10 @@ struct rte_devargs {TAILQ_ENTRY (rte_devargs) next;/** Type of device. */ enum rte_devtype type; -RTE_STD_C11 - union { -/** Used if type is RTE_DEVTYPE_*_PCI. */ -struct { -/** PCI location. */ -struct rte_pci_addr addr; - } pci; -/** Used if type is RTE_DEVTYPE_VIRTUAL. */ -struct { -/** Driver name. */ -char drv_name[32 ]; - } virt; - };/** Bus handle for the device. */ struct rte_bus *bus; +/** Name of the device. */ +char name[32 ];/** Arguments string as given by user or "" for no argument. */ char *args; };
lib/librte_eal/common/include/rte_vdev.h +1 -1
@@ -50,7 +50,7 @@ static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) {if (dev && dev->device.devargs) -return dev->device.devargs->virt.drv_name; +return dev->device.devargs->name;return NULL ; }
test/test/test_devargs.c +3 -6
@@ -90,8 +90,8 @@ test_devargs(void)if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,k1=val,k2=val2" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); -if (strncmp (devargs->virt.drv_name,"net_ring1" , -sizeof (devargs->virt.drv_name)) !=0 ) +if (strncmp (devargs->name,"net_ring1" , +sizeof (devargs->name)) !=0 ) goto fail;if (!devargs->args ||strcmp (devargs->args,"k1=val,k2=val2" ) !=0 ) goto fail;
@@ -101,10 +101,7 @@ test_devargs(void)if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"04:00.1" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); -if (devargs->pci.addr.domain !=0 || - devargs->pci.addr.bus !=4 || - devargs->pci.addr.devid !=0 || - devargs->pci.addr.function !=1 ) +if (strcmp (devargs->name,"04:00.1" ) !=0 ) goto fail;if (!devargs->args ||strcmp (devargs->args,"" ) !=0 ) goto fail;
Signature · 1 line
2.1.4
PATCH v6 13/19 pci: update device name
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_pci.c | 1 + 1 file changed, 1 insertion(+)
lib/librte_eal/common/eal_common_pci.c +1 -0
@@ -328,6 +328,7 @@ rte_pci_probe_one(const struct rte_pci_addr *addr) ret =pci_probe_all_drivers (dev);if (ret) goto err_return; + dev->device.name = dev->device.devargs->name;return 0 ; }return -1 ;
Signature · 1 line
2.1.4
PATCH v6 14/19 net/virtio: do not reference device type
In reply to Gaetan Rivet--- drivers/net/virtio/virtio_pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
@@ -38,6 +38,7 @@#endif #include <rte_io.h> +#include <rte_bus.h> #include "virtio_pci.h" #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)if (rte_pci_ioport_map (dev,0 ,VTPCI_IO (hw)) <0 ) {if (dev->kdrv ==RTE_KDRV_UNKNOWN && (!dev->device.devargs || - dev->device.devargs->type != -RTE_DEVTYPE_WHITELISTED_PCI )) { + dev->device.devargs->bus != +rte_bus_find_by_name ("PCI" ))) {PMD_INIT_LOG (INFO ,"skip kernel managed virtio device." );return 1 ;
Signature · 1 line
2.1.4
Re: [PATCH v6 14/19] net/virtio: do not reference device type
Quoted 18 lines · Gaetan Rivet
Signed-off-by Gaetan Rivet <[email protected]>--- drivers/net/virtio/virtio_pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/virtio/virtio_pci.c +1
-0@@ -38,6 +38,7 @@#endif #include <rte_io.h> +#include <rte_bus.h> #include "virtio_pci.h" #include "virtio_logs.h"
drivers/net/virtio/virtio_pci.c vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw) · line 689
Quoted 7 lines
drivers/net/virtio/virtio_pci.c +2
-2@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)if (rte_pci_ioport_map (dev,0 ,VTPCI_IO (hw)) <0 ) {if (dev->kdrv ==RTE_KDRV_UNKNOWN && (!dev->device.devargs || - dev->device.devargs->type != -RTE_DEVTYPE_WHITELISTED_PCI )) { + dev->device.devargs->bus != +rte_bus_find_by_name ("PCI" ))) {
Ah, this is the first, won't be last error of this type. It should be "pci" instead.
Incidentally, it could be preferable to userte_bus_find_by_device(&dev->device) instead.
Quoted 6 lines
drivers/net/virtio/virtio_pci.c +0
-0PMD_INIT_LOG (INFO ,"skip kernel managed virtio device." );return 1 ;Signature · 1 line
2.1.4
Signature · 2 lines
Gaëtan Rivet 6WIND
PATCH v6 15/19 devargs: generic device types
In reply to Gaetan Rivetrte_devargs now represents any device from any bus.
The related devtypes do not identify a bus anymore, only which scan policy the device subscribes to.
The bus itself is identified by a bus handle previously introduced.
--- lib/librte_eal/common/eal_common_devargs.c | 4 ++-- lib/librte_eal/common/eal_common_options.c | 13 +++-------- lib/librte_eal/common/eal_common_pci.c | 6 ++--- lib/librte_eal/common/eal_common_vdev.c | 1 - lib/librte_eal/common/include/rte_devargs.h | 6 ++--- test/test/test_devargs.c | 36 +++++++++++++++-------------- 6 files changed, 30 insertions(+), 36 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
@@ -129,14 +129,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , devname);if (ret <0 || ret >= (int )sizeof (devargs->name)) goto fail; -if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (devargs->type ==RTE_DEVTYPE_WHITELISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) {fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); goto fail; } - }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) {
lib/librte_eal/common/eal_common_options.c +3 -10
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,switch (opt) {/* blacklist */ case 'b' : -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED , optarg) <0 ) {return -1 ; }break ;/* whitelist */ case 'w' : -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED , optarg) <0 ) {return -1 ; }
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,break ;case OPT_VDEV_NUM : -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL , +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , optarg) <0 ) {return -1 ; }
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)return -1 ; } -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=0 && -rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=0 ) { -RTE_LOG (ERR ,EAL ,"Options blacklist (-b) and whitelist (-w) " -"cannot be used at the same time\n" ); -return -1 ; - } -return 0 ; }
lib/librte_eal/common/eal_common_pci.c +3 -3
@@ -198,7 +198,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* no initialization when blacklisted, return without error */ if (dev->device.devargs !=NULL && dev->device.devargs->type == -RTE_DEVTYPE_BLACKLISTED_PCI ) { +RTE_DEVTYPE_BLACKLISTED ) {RTE_LOG (INFO ,EAL ," Device is blacklisted, not" " initializing\n" );return 1 ;
@@ -391,7 +391,7 @@ rte_pci_probe(void)int probe_all =0 ;int ret =0 ; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) ==0 ) +if (rte_pci_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_WHITELIST ) probe_all =1 ;FOREACH_DEVICE_ON_PCIBUS (dev) {
@@ -406,7 +406,7 @@ rte_pci_probe(void)if (probe_all) ret =pci_probe_all_drivers (dev);else if (devargs !=NULL && - devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) + devargs->type ==RTE_DEVTYPE_WHITELISTED ) ret =pci_probe_all_drivers (dev);if (ret <0 ) { RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
@@ -176,7 +176,6 @@ alloc_devargs(const char *name, const char *args)if (!devargs)return NULL ; - devargs->type =RTE_DEVTYPE_VIRTUAL ; devargs->bus =rte_bus_find_by_name ("vdev" );if (args) devargs->args =strdup (args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
@@ -56,9 +56,9 @@ extern "C" {* Type of generic device */ enum rte_devtype { -RTE_DEVTYPE_WHITELISTED_PCI , -RTE_DEVTYPE_BLACKLISTED_PCI , -RTE_DEVTYPE_VIRTUAL , +RTE_DEVTYPE_UNDEFINED , +RTE_DEVTYPE_WHITELISTED , +RTE_DEVTYPE_BLACKLISTED , };/**
test/test/test_devargs.c +19 -17
@@ -64,30 +64,32 @@ test_devargs(void)TAILQ_INIT (&devargs_list);/* test valid cases */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"08:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"08:00.1" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"0000:5:00.0" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"0000:5:00.0" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI ,"04:00.0,arg=val" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"04:00.0,arg=val" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI ,"0000:01:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"0000:01:00.1" ) <0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED ) !=4 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED ) !=0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_VIRTUAL ) !=0 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_UNDEFINED ) !=0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring0" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED ,"net_ring0" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,key=val,k2=val2" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , +"net_ring1,key=val,k2=val2" ) <0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_VIRTUAL ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_UNDEFINED ) !=2 ) goto fail;free_devargs_list ();/* check virtual device with argument parsing */ -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,k1=val,k2=val2" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , +"net_ring1,k1=val,k2=val2" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); if (strncmp(devargs->name, "net_ring1",
@@ -98,7 +100,7 @@ test_devargs(void)free_devargs_list ();/* check PCI device with empty argument parsing */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"04:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"04:00.1" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list);if (strcmp (devargs->name,"04:00.1" ) !=0 )
@@ -108,15 +110,15 @@ test_devargs(void)free_devargs_list ();/* test error case: bad PCI address */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"08:1" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"08:1" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"00.1" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"00.1" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"foo" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"foo" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"," ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"," ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"000f:0:0" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"000f:0:0" ) ==0 ) goto fail; devargs_list = save_devargs_list;
Signature · 1 line
2.1.4
PATCH v6 16/19 devargs: introduce cleaner parsing helper
In reply to Gaetan RivetIntroduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require any API changes in the future, should this structure be updated.
The old equivalent function is thus being deprecated, as its API does not allow to accompany current rte_devargs evolutions.
A deprecation notice is issued.
This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.
--- doc/guides/rel_notes/deprecation.rst | 5 ++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 78 ++++++++++++++++--------- lib/librte_eal/common/include/rte_devargs.h | 20 +++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 5 files changed, 79 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
@@ -95,3 +95,8 @@ Deprecation Notices The non-"do-sig" versions of the hash tables will be removed (including the ``signature_offset`` parameter) and the "do-sig" versions renamed accordingly. + +* eal: the following function is deprecated starting from 17.08 and will + be removed in 17.11: + + - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -200,6 +200,7 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; rte_bus_find_by_name; + rte_eal_devargs_parse; } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +52 -26
113 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +20 -0
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs);/** +* Parse a device string. +* +* Verify that a bus is capable of handling the device passed +* in argument. Store which bus will handle the device, its name +* and the eventual device parameters. +* +* @param dev +* The device declaration string. +* @param da +* The devargs structure holding the device information. +* +* @return +* - 0 on success. +* - Negative errno on error. +*/ +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -205,6 +205,7 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; rte_bus_find_by_name; + rte_eal_devargs_parse; } DPDK_17.05;
Signature · 1 line
2.1.4
PATCH v6 17/19 devargs: clone function
In reply to Gaetan RivetThis function returns a deep copy of an rte_devargs.
--- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 19 +++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 12 ++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 33 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -200,6 +200,7 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; rte_bus_find_by_name; + rte_eal_devargs_clone; rte_eal_devargs_parse; } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +19 -0
@@ -185,6 +185,25 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)return -1 ; } +/* Deep-copy of an rte_devargs. */ +struct rte_devargs * +rte_eal_devargs_clone (struct rte_devargs *da) +{ +struct rte_devargs *clone; + + clone =calloc (1 ,sizeof (*clone)); +if (clone ==NULL ) +return NULL ; +snprintf (clone->name,sizeof (clone->name),"%s" , da->name); + clone->args =strdup (da->args ? da->args :"" ); + clone->bus = da->bus; +if (clone->args ==NULL ) { +free (clone); +return NULL ; + } +return clone; +} +/* count the number of devices of a specified type */ unsigned int rte_eal_devargs_type_count (enum rte_devtype devtype)
lib/librte_eal/common/include/rte_devargs.h +12 -0
@@ -163,6 +163,18 @@ rte_eal_devargs_parse(const char *dev,int rte_eal_devargs_add (enum rte_devtype devtype,const char *devargs_str);/** +* Deep copy an rte_devargs. +* +* @param da +* Source devargs. +* +* @return +* The pointer to the new rte_devargs on success. +* NULL on error. +*/ +struct rte_devargs *rte_eal_devargs_clone (struct rte_devargs *da); + +/** * Count the number of user devices of a specified type * * @param devtype
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -205,6 +205,7 @@ DPDK_17.08 { rte_bus_find; rte_bus_find_by_device; rte_bus_find_by_name; + rte_eal_devargs_clone; rte_eal_devargs_parse; } DPDK_17.05;
Signature · 1 line
2.1.4
PATCH v6 18/19 devargs: remove function
In reply to Gaetan RivetHotplug support introduces the possibility of removing devices from the system. Allocated resources must be freed.
--- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 19 +++++++++++++++++++ lib/librte_eal/common/include/rte_devargs.h | 14 ++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 35 insertions(+)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -202,6 +202,7 @@ DPDK_17.08 { rte_bus_find_by_name; rte_eal_devargs_clone; rte_eal_devargs_parse; + rte_eal_devargs_rmv; } DPDK_17.05;
lib/librte_eal/common/eal_common_devargs.c +19 -0
@@ -41,6 +41,7 @@#include <string.h> #include <rte_devargs.h> +#include <rte_tailq.h> #include "eal_private.h" /** Global list of user devices */
@@ -185,6 +186,24 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)return -1 ; } +/* Remove and free an rte_devargs. */ +int +rte_eal_devargs_rmv (struct rte_devargs *da) +{ +struct rte_devargs *d; +void *tmp; + + TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { +if (d == da) { +TAILQ_REMOVE (&devargs_list, d, next); +free (d->args); +free (d); +return 0 ; + } + } +return 1 ; +} +/* Deep-copy of an rte_devargs. */ struct rte_devargs *rte_eal_devargs_clone (struct rte_devargs *da)
lib/librte_eal/common/include/rte_devargs.h +14 -0
@@ -163,6 +163,20 @@ rte_eal_devargs_parse(const char *dev,int rte_eal_devargs_add (enum rte_devtype devtype,const char *devargs_str);/** +* Remove a device from the user device list. +* The devargs is then freed. +* +* @param da +* devargs to remove. +* +* @return +* 0 on success. +* <0 on error. +* >0 if the devargs was not within the user device list. +*/ +int rte_eal_devargs_rmv (struct rte_devargs *da); + +/** * Deep copy an rte_devargs. * * @param da
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -207,6 +207,7 @@ DPDK_17.08 { rte_bus_find_by_name; rte_eal_devargs_clone; rte_eal_devargs_parse; + rte_eal_devargs_rmv; } DPDK_17.05;
Signature · 1 line
2.1.4
PATCH v6 19/19 eal: change whitelist / blacklist command line doc
In reply to Gaetan RivetThe use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.
Update the source code accordingly.
--- lib/librte_eal/common/eal_common_options.c | 18 +++++++++--------- lib/librte_eal/common/eal_options.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-)
lib/librte_eal/common/eal_common_options.c +9 -9
@@ -86,8 +86,8 @@ eal_long_options[] = { {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM }, {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM }, {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM }, - {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM }, - {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM }, + {OPT_BUS_BLACKLIST, 1, NULL, OPT_BUS_BLACKLIST_NUM }, + {OPT_BUS_WHITELIST, 1, NULL, OPT_BUS_WHITELIST_NUM }, {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM }, {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM }, {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
@@ -1049,14 +1049,14 @@ eal_common_usage(void)" -n CHANNELS Number of memory channels\n" " -m MB Memory to allocate (see also --" OPT_SOCKET_MEM ")\n" " -r RANKS Force number of memory ranks (don't detect)\n" -" -b, --" OPT_PCI_BLACKLIST " Add a PCI device in black list.\n" -" Prevent EAL from using this PCI device. The argument\n" -" format is <domain:bus:devid.func>.\n" -" -w, --" OPT_PCI_WHITELIST " Add a PCI device in white list.\n" -" Only use the specified PCI devices. The argument format\n" -" is <[domain:]bus:devid.func>. This option can be present\n" +" -b, --" OPT_BUS_BLACKLIST " Black list a device on its bus.\n" +" Prevents EAL from using this device. The argument\n" +" format depends on the bus.\n" +" -w, --" OPT_BUS_WHITELIST " White list a device on its bus.\n" +" Only use the specified devices. The argument format\n" +" depends on the bus. This option can be present\n" " several times (once per device).\n" -" [NOTE: PCI whitelist cannot be used with -b option]\n" +" [NOTE: whitelist cannot be used with -b option]\n" " --" OPT_VDEV " Add a virtual device.\n" " The argument format is <driver><id>[,key=val,...]\n" " (ex: --vdev=net_pcap0,iface=eth2).\n"
lib/librte_eal/common/eal_options.h +4 -4
@@ -37,10 +37,10 @@ enum {/* long options mapped to a short option */ #define OPT_HELP "help" OPT_HELP_NUM = 'h', -#define OPT_PCI_BLACKLIST "pci-blacklist" - OPT_PCI_BLACKLIST_NUM = 'b', -#define OPT_PCI_WHITELIST "pci-whitelist" - OPT_PCI_WHITELIST_NUM = 'w', +#define OPT_BUS_BLACKLIST "bus-blacklist" + OPT_BUS_BLACKLIST_NUM = 'b', +#define OPT_BUS_WHITELIST "bus-whitelist" + OPT_BUS_WHITELIST_NUM = 'w',/* first long only option value must be >= 256, so that we won't * conflict with short options */
Signature · 1 line
2.1.4
Re: [PATCH v6 19/19] eal: change whitelist / blacklist command line doc
05/07/2017 01:56, Gaetan Rivet:
Quoted 6 lines
The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.Update the source code accordingly.
Signed-off-by Gaetan Rivet <[email protected]>
You forgot the ack from John.
Re: [PATCH v6 19/19] eal: change whitelist / blacklist command line doc
In reply to Gaetan RivetQuoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Gaetan Rivet
Sent: Wednesday, July 5, 2017 12:57 AM
To: [email protected]
Cc: Gaetan Rivet <[email protected]>
Subject: [dpdk-dev] [PATCH v6 19/19] eal: change whitelist / blacklist command line doc
Quoted 6 lines
The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.Update the source code accordingly.
Signed-off-by Gaetan Rivet <[email protected]>
Quoted 12 lines
Gaetan Rivet (19):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
Quoted 8 lines
devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc
You forgot my patch "examples/ethtool: explicit PCI header dependency"
Hi Thomas,
Quoted 21 lines · Thomas Monjalon
Quoted 12 lines
Gaetan Rivet (19):
net/bonding: properly reference PCI header
net/bnxt: properly reference PCI header
net/mlx5: properly reference PCI header
net/e1000: properly reference PCI header
net/ixgbe: properly reference PCI header
net/sfc: properly reference PCI header
app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policiesQuoted 8 lines
devargs: generic device representation
pci: update device name
net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
devargs: clone function
devargs: remove function
eal: change whitelist / blacklist command line doc
Quoted 2 lines
You forgot my patch "examples/ethtool: explicit PCI header dependency"
Indeed sorry, I missed a few things it seems.
Signature · 2 lines
Gaëtan Rivet 6WIND
v7 cover Generic devargs parsing
In reply to Gaetan RivetThe second part of the work outlined in [1] and [2]. The first part is at [3].
In this patchset, the representation of devices in rte_devargs is made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.
The device type was one of two elements expressed by these flags and the bus handle only covers one. The second is the bus scan behavior, namely "whitelist mode" or "blacklist mode".
These two modes are consequently introduced as bus scan policies, expressed within a bus configuration structure.
Finally, once all specialized parts have been removed from rte_devargs, a cleaner rte_devargs parser is proposed. This parser should allow following further changes without having to update its API, and is already available for third parties to build rte_devargs structures from device declarations.
With this patchset, it is now possible to use any device type on the EAL command line, with either the -w or -b parameters. The bus name can be used to explicitly ask for one bus to handle a device if there is any ambiguity.
Buses needs only to implement the "parse" method for their devices to be declared in this way.
[1]: http://dpdk.org/ml/archives/dev/2017-May/065634.html
[2]: http://dpdk.org/ml/archives/dev/2017-May/065670.html
[3]: http://dpdk.org/ml/archives/dev/2017-May/066341.html
This patchset depends on:
[PATCH 0/9] rte_bus parse API
http://dpdk.org/ml/archives/dev/2017-May/066341.html
http://dpdk.org/dev/patchwork/patch/24499/
v1 -> v2:
* fix PCI whitelist mode
v2 -> v3:
* Rebase the series on the new plug / unplug API
v3 -> v4:
* Fix rte_devargs parsing helper
* Introduce new rte_devargs clone function
* Introduce new rte_devargs release function
* Fix test application for rte_devargs.
TODO: rewrite complete rte_devargs autotest.
* Fix a few rte_pci references.
* Update EAL command line help for -w / -b
v5:
* Fix integration issue with new arbitrary bus name parsing.
v6:
* Follow new hotplug & parse API
* Export rte_eal_devargs_parse symbol
* Improve the devargs parsing in regard to possible bus / dev naming ambiguities.
* A few code style issues fixed.
* The EAL dependency on vdev is not fixed anymore It is beyond the scope of this patchset.
v7:
* Remembered to include the example/ethtool
header fix.
* Use new RTE_DEV_NAME_MAX_LEN macro to define rte_devargs name field len.
* Fix virtio reference to old "PCI" bus name.
* rte_eal_devargs_parse is now set as EXPERIMENTAL
* Previous rte_devargs API extensions (clone, removal) are removed from this patchset. They will be introduced when needed.
Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc
Thomas Monjalon (1):
examples/ethtool: properly reference PCI header
app/test-pmd/testpmd.c | 9 +- app/test-pmd/testpmd.h | 2 + doc/guides/rel_notes/deprecation.rst | 5 + drivers/net/bnxt/bnxt.h | 1 + drivers/net/bonding/rte_eth_bond_args.c | 1 + drivers/net/e1000/e1000_ethdev.h | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/sfc/sfc.h | 1 + drivers/net/virtio/virtio_pci.c | 5 +- examples/ethtool/lib/rte_ethtool.c | 2 + lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 128 +++++++++++++----------- lib/librte_eal/common/eal_common_options.c | 31 +++--- lib/librte_eal/common/eal_common_pci.c | 15 +-- lib/librte_eal/common/eal_common_vdev.c | 12 +-- lib/librte_eal/common/eal_options.h | 8 +- lib/librte_eal/common/include/rte_bus.h | 17 ++++ lib/librte_eal/common/include/rte_dev.h | 12 +++ lib/librte_eal/common/include/rte_devargs.h | 42 ++++---- lib/librte_eal/common/include/rte_pci.h | 9 -- lib/librte_eal/common/include/rte_vdev.h | 2 +- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + test/test/test_devargs.c | 45 ++++----- test/test/virtual_pmd.c | 1 + 25 files changed, 198 insertions(+), 155 deletions(-)
Signature · 1 line
2.1.4
PATCH v7 1/17 net/bonding: properly reference PCI header
--- drivers/net/bonding/rte_eth_bond_args.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/rte_eth_bond_args.c +1 -0
@@ -32,6 +32,7 @@*/ #include <rte_devargs.h> +#include <rte_pci.h> #include <rte_kvargs.h> #include <cmdline_parse.h>
Signature · 1 line
2.1.4
PATCH v7 2/17 net/bnxt: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/bnxt/bnxt.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/bnxt/bnxt.h +1 -0
@@ -38,6 +38,7 @@#include <stdbool.h> #include <sys/queue.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_memory.h> #include <rte_lcore.h>
Signature · 1 line
2.1.4
PATCH v7 3/17 net/mlx5: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/mlx5/mlx5.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -54,6 +54,7 @@#ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"#endif +#include <rte_pci.h> #include <rte_ether.h> #include <rte_ethdev.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v7 4/17 net/e1000: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/e1000/e1000_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/e1000/e1000_ethdev.h +1 -0
@@ -34,6 +34,7 @@#ifndef _E1000_ETHDEV_H_#define _E1000_ETHDEV_H_#include <rte_time.h> +#include <rte_pci.h> #define E1000_INTEL_VENDOR_ID 0x8086
Signature · 1 line
2.1.4
PATCH v7 5/17 net/ixgbe: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/ixgbe/ixgbe_ethdev.h +1 -0
@@ -39,6 +39,7 @@#include "ixgbe_bypass.h" #include <rte_time.h> #include <rte_hash.h> +#include <rte_pci.h> /* need update link, bit flag */ #define IXGBE_FLAG_NEED_LINK_UPDATE (uint32_t)(1 << 0)
Signature · 1 line
2.1.4
PATCH v7 6/17 net/sfc: properly reference PCI header
In reply to Gaetan Rivet--- drivers/net/sfc/sfc.h | 1 + 1 file changed, 1 insertion(+)
drivers/net/sfc/sfc.h +1 -0
@@ -34,6 +34,7 @@#include <stdbool.h> +#include <rte_pci.h> #include <rte_ethdev.h> #include <rte_kvargs.h> #include <rte_spinlock.h>
Signature · 1 line
2.1.4
PATCH v7 7/17 app/testpmd: properly reference PCI header
In reply to Gaetan Rivet--- app/test-pmd/testpmd.h | 2 ++ 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.h +2 -0
@@ -34,6 +34,8 @@#ifndef _TESTPMD_H_#define _TESTPMD_H_ +#include <rte_pci.h> +#define RTE_PORT_ALL (~(portid_t)0x0)#define RTE_TEST_RX_DESC_MAX 2048
Signature · 1 line
2.1.4
PATCH v7 8/17 test: properly reference PCI header
In reply to Gaetan Rivet--- test/test/virtual_pmd.c | 1 + 1 file changed, 1 insertion(+)
test/test/virtual_pmd.c +1 -0
@@ -33,6 +33,7 @@#include <rte_mbuf.h> #include <rte_ethdev.h> +#include <rte_pci.h> #include <rte_malloc.h> #include <rte_memcpy.h> #include <rte_memory.h>
Signature · 1 line
2.1.4
PATCH v7 9/17 examples/ethtool: properly reference PCI header
In reply to Gaetan RivetFrom: Thomas Monjalon <[email protected]>
In devargs rework, rte_pci.h won't be included by rte_ethdev.h (via rte_devargs.h) anymore.
rte_ethtool_get_drvinfo() could use rte_devargs.name instead of creating equivalent bus specific name.
For now, it is workarounded by just including rte_pci.h.
--- examples/ethtool/lib/rte_ethtool.c | 2 ++ 1 file changed, 2 insertions(+)
examples/ethtool/lib/rte_ethtool.c +2 -0
@@ -36,6 +36,7 @@#include <rte_version.h> #include <rte_ethdev.h> #include <rte_ether.h> +#include <rte_pci.h> #ifdef RTE_LIBRTE_IXGBE_PMD #include <rte_pmd_ixgbe.h> #endif
@@ -73,6 +74,7 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo) dev_info.driver_name);snprintf (drvinfo->version,sizeof (drvinfo->version),"%s" ,rte_version ()); +/* TODO: replace bus_info by rte_devargs.name */ if (dev_info.pci_dev) snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), "%04x:%02x:%02x.%x",
Signature · 1 line
2.1.4
PATCH v7 10/17 dev: device kernel module is a device attribute
In reply to Gaetan RivetIt is used in generic device structures and must not be tied to a bus.
--- lib/librte_eal/common/include/rte_dev.h | 12 ++++++++++++ lib/librte_eal/common/include/rte_pci.h | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-)
lib/librte_eal/common/include/rte_dev.h +12 -0
@@ -115,6 +115,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) }while (0 )/** +* Device driver. +*/ +enum rte_kernel_driver { +RTE_KDRV_UNKNOWN =0 , +RTE_KDRV_IGB_UIO , +RTE_KDRV_VFIO , +RTE_KDRV_UIO_GENERIC , +RTE_KDRV_NIC_UIO , + RTE_KDRV_NONE, +}; + +/** * A generic memory resource representation. */ struct rte_mem_resource {
lib/librte_eal/common/include/rte_pci.h +0 -9
@@ -117,15 +117,6 @@ struct rte_pci_addr {struct rte_devargs ; -enum rte_kernel_driver { -RTE_KDRV_UNKNOWN =0 , -RTE_KDRV_IGB_UIO , -RTE_KDRV_VFIO , -RTE_KDRV_UIO_GENERIC , -RTE_KDRV_NIC_UIO , -RTE_KDRV_NONE , -}; -/** * A structure describing a PCI device. */
Signature · 1 line
2.1.4
PATCH v7 11/17 bus: introduce bus scan policies
In reply to Gaetan RivetScan policies describe the way a bus should scan the system to search for possible devices.
Three flags are introduced:
RTE_BUS_SCAN_UNDEFINED: Configuration is irrelevant for this bus
RTE_BUS_SCAN_WHITELIST: Scanning should be limited to declared devices
RTE_BUS_SCAN_BLACKLIST: Scanning should exclude only declared devices
--- lib/librte_eal/common/include/rte_bus.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
lib/librte_eal/common/include/rte_bus.h +17 -0
@@ -158,6 +158,22 @@ typedef int (*rte_bus_unplug_t)(struct rte_device *dev);typedef int (*rte_bus_parse_t )(const char *name,void *addr);/** +* Bus scan policies +*/ +enum rte_bus_scan_mode { +RTE_BUS_SCAN_UNDEFINED , +RTE_BUS_SCAN_WHITELIST , +RTE_BUS_SCAN_BLACKLIST , +}; + +/** +* A structure used to configure bus operations. +*/ +struct rte_bus_conf { +enum rte_bus_scan_mode scan_mode;/**< Scan policy. */ +}; + +/** * A structure describing a generic bus. */ struct rte_bus {
@@ -169,6 +185,7 @@ struct rte_bus {rte_bus_plug_t plug;/**< Probe single device for drivers */ rte_bus_unplug_t unplug;/**< Remove single device from driver */ rte_bus_parse_t parse;/**< Parse a device name */ +struct rte_bus_conf conf;/**< Bus configuration */ };/**
Signature · 1 line
2.1.4
PATCH v7 12/17 devargs: parse bus policies
In reply to Gaetan Rivet--- lib/librte_eal/common/eal_common_devargs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
lib/librte_eal/common/eal_common_devargs.c +15 -0
@@ -143,6 +143,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)break ; } +if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }free (dev);TAILQ_INSERT_TAIL (&devargs_list, devargs, next);
Signature · 1 line
2.1.4
Re: [PATCH v7 12/17] devargs: parse bus policies
Hi,
I think there is a real bug to fix in 17.08-rc2.
More details below. Proposals are welcome.
07/07/2017 02:04, Gaetan Rivet:
Quoted 11 lines
lib/librte_eal/common/eal_common_devargs.c +5
-0@@ -143,6 +143,21 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)break ; } +if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" );
lib/librte_eal/common/eal_common_devargs.c rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) · line 160
Quoted 10 lines
lib/librte_eal/common/eal_common_devargs.c +10
-0+ goto fail; + } + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { +if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { + bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; + }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) { +fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); + goto fail; + } + }
After another look, there is something wrong here.
You are checking a probe policy (wrongly named scan_mode), in a function which can be not related at all with bus probing.
Example with failsafe:
1/ We blacklist a device for the global EAL probe.
So the probing mode is set from "undefined" to "blacklist". 2/ We add the device as a failsafe slave.
3/ The device must be plugged, no matter of the probe policy. But it is seen as a whitelist and rejected because the bus probing is in blacklist mode.
I think it is a serious bug.
PS: thanks Matan for having checked it
PATCH v7 13/17 devargs: generic device representation
In reply to Gaetan RivetRemove the dependency of this subsystem upon bus specific device representation.
Devargs only validates that a device declaration is correct and handled by a bus. The device interpretation is done afterward within the bus.
--- app/test-pmd/testpmd.c | 9 +----- lib/librte_eal/common/eal_common_devargs.c | 47 +++++------------------------ lib/librte_eal/common/eal_common_pci.c | 9 ++++-- lib/librte_eal/common/eal_common_vdev.c | 11 +++---- lib/librte_eal/common/include/rte_devargs.h | 16 ++-------- lib/librte_eal/common/include/rte_vdev.h | 2 +- test/test/test_devargs.c | 9 ++---- 7 files changed, 26 insertions(+), 77 deletions(-)
app/test-pmd/testpmd.c +1 -8
@@ -1810,21 +1810,14 @@ static void rmv_event_callback(void *arg) {struct rte_eth_dev *dev; -struct rte_devargs *da; -char name[32 ] ="" ;uint8_t port_id = (intptr_t )arg;RTE_ETH_VALID_PORTID_OR_RET (port_id); dev = &rte_eth_devices[port_id]; - da = dev->device->devargs;stop_port (port_id);close_port (port_id); -if (da->type ==RTE_DEVTYPE_VIRTUAL ) -snprintf (name,sizeof (name),"%s" , da->virt.drv_name); -else if (da->type ==RTE_DEVTYPE_WHITELISTED_PCI ) -rte_pci_device_name (&da->pci.addr, name,sizeof (name)); -printf ("removing device %s\n" , name); +printf ("removing device %s\n" , dev->device->name);rte_eal_dev_detach (dev->device); dev->state =RTE_ETH_DEV_UNUSED ; }
lib/librte_eal/common/eal_common_devargs.c +8 -39
65 lines not on this page · raw message
lib/librte_eal/common/eal_common_pci.c +6 -3
@@ -74,12 +74,15 @@ const char *pci_get_sysfs_path(void)static struct rte_devargs *pci_devargs_lookup (struct rte_pci_device *dev) {struct rte_devargs *devargs; +struct rte_pci_addr addr; +struct rte_bus *pbus; + pbus =rte_bus_find_by_name ("pci" ); TAILQ_FOREACH(devargs, &devargs_list, next) { -if (devargs->type !=RTE_DEVTYPE_BLACKLISTED_PCI && - devargs->type !=RTE_DEVTYPE_WHITELISTED_PCI ) +if (devargs->bus != pbus)continue ; -if (!rte_eal_compare_pci_addr (&dev->addr, &devargs->pci.addr)) + devargs->bus->parse (devargs->name, &addr); +if (!rte_eal_compare_pci_addr (&dev->addr, &addr))return devargs; }return NULL ;
lib/librte_eal/common/eal_common_vdev.c +5 -6
@@ -181,9 +181,8 @@ alloc_devargs(const char *name, const char *args)if (args) devargs->args =strdup (args); - ret =snprintf (devargs->virt.drv_name, -sizeof (devargs->virt.drv_name),"%s" , name); -if (ret <0 || ret >= (int )sizeof (devargs->virt.drv_name)) { + ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , name); +if (ret <0 || ret >= (int )sizeof (devargs->name)) {free (devargs->args);free (devargs);return NULL ;
@@ -218,7 +217,7 @@ rte_vdev_init(const char *name, const char *args) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name; ret =vdev_probe_all_drivers (dev);if (ret) {
@@ -299,7 +298,7 @@ vdev_scan(void)if (devargs->bus != vbus)continue ; - dev =find_vdev (devargs->virt.drv_name); + dev =find_vdev (devargs->name);if (dev)continue ;
@@ -309,7 +308,7 @@ vdev_scan(void) dev->device.devargs = devargs; dev->device.numa_node =SOCKET_ID_ANY ; - dev->device.name = devargs->virt.drv_name; + dev->device.name = devargs->name;TAILQ_INSERT_TAIL (&vdev_device_list, dev, next); }
lib/librte_eal/common/include/rte_devargs.h +2 -14
@@ -50,7 +50,6 @@ extern "C" {#include <stdio.h> #include <sys/queue.h> -#include <rte_pci.h> #include <rte_bus.h> /**
@@ -77,21 +76,10 @@ struct rte_devargs {TAILQ_ENTRY (rte_devargs) next;/** Type of device. */ enum rte_devtype type; -RTE_STD_C11 - union { -/** Used if type is RTE_DEVTYPE_*_PCI. */ -struct { -/** PCI location. */ -struct rte_pci_addr addr; - } pci; -/** Used if type is RTE_DEVTYPE_VIRTUAL. */ -struct { -/** Driver name. */ -char drv_name[RTE_DEV_NAME_MAX_LEN ]; - } virt; - };/** Bus handle for the device. */ struct rte_bus *bus; +/** Name of the device. */ +char name[RTE_DEV_NAME_MAX_LEN ];/** Arguments string as given by user or "" for no argument. */ char *args; };
lib/librte_eal/common/include/rte_vdev.h +1 -1
@@ -50,7 +50,7 @@ static inline const char * rte_vdev_device_name(const struct rte_vdev_device *dev) {if (dev && dev->device.devargs) -return dev->device.devargs->virt.drv_name; +return dev->device.devargs->name;return NULL ; }
test/test/test_devargs.c +3 -6
@@ -90,8 +90,8 @@ test_devargs(void)if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,k1=val,k2=val2" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); -if (strncmp (devargs->virt.drv_name,"net_ring1" , -sizeof (devargs->virt.drv_name)) !=0 ) +if (strncmp (devargs->name,"net_ring1" , +sizeof (devargs->name)) !=0 ) goto fail;if (!devargs->args ||strcmp (devargs->args,"k1=val,k2=val2" ) !=0 ) goto fail;
@@ -101,10 +101,7 @@ test_devargs(void)if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"04:00.1" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); -if (devargs->pci.addr.domain !=0 || - devargs->pci.addr.bus !=4 || - devargs->pci.addr.devid !=0 || - devargs->pci.addr.function !=1 ) +if (strcmp (devargs->name,"04:00.1" ) !=0 ) goto fail;if (!devargs->args ||strcmp (devargs->args,"" ) !=0 ) goto fail;
Signature · 1 line
2.1.4
PATCH v7 14/17 net/virtio: do not reference device type
In reply to Gaetan Rivet--- drivers/net/virtio/virtio_pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +3 -2
@@ -38,6 +38,7 @@#endif #include <rte_io.h> +#include <rte_bus.h> #include "virtio_pci.h" #include "virtio_logs.h"
@@ -684,8 +685,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)if (rte_pci_ioport_map (dev,0 ,VTPCI_IO (hw)) <0 ) {if (dev->kdrv ==RTE_KDRV_UNKNOWN && (!dev->device.devargs || - dev->device.devargs->type != -RTE_DEVTYPE_WHITELISTED_PCI )) { + dev->device.devargs->bus != +rte_bus_find_by_name ("pci" ))) {PMD_INIT_LOG (INFO ,"skip kernel managed virtio device." );return 1 ;
Signature · 1 line
2.1.4
PATCH v7 15/17 devargs: generic device types
In reply to Gaetan Rivetrte_devargs now represents any device from any bus.
The related devtypes do not identify a bus anymore, only which scan policy the device subscribes to.
The bus itself is identified by a bus handle previously introduced.
--- lib/librte_eal/common/eal_common_devargs.c | 4 ++-- lib/librte_eal/common/eal_common_options.c | 13 +++-------- lib/librte_eal/common/eal_common_pci.c | 6 ++--- lib/librte_eal/common/eal_common_vdev.c | 1 - lib/librte_eal/common/include/rte_devargs.h | 6 ++--- test/test/test_devargs.c | 36 +++++++++++++++-------------- 6 files changed, 30 insertions(+), 36 deletions(-)
lib/librte_eal/common/eal_common_devargs.c +2 -2
@@ -129,14 +129,14 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) ret =snprintf (devargs->name,sizeof (devargs->name),"%s" , devname);if (ret <0 || ret >= (int )sizeof (devargs->name)) goto fail; -if (devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) { +if (devargs->type ==RTE_DEVTYPE_WHITELISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_WHITELIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_BLACKLIST ) {fprintf (stderr,"ERROR: incompatible device type and bus scan mode\n" ); goto fail; } - }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED_PCI ) { + }else if (devargs->type ==RTE_DEVTYPE_BLACKLISTED ) {if (bus->conf.scan_mode ==RTE_BUS_SCAN_UNDEFINED ) { bus->conf.scan_mode =RTE_BUS_SCAN_BLACKLIST ; }else if (bus->conf.scan_mode ==RTE_BUS_SCAN_WHITELIST ) {
lib/librte_eal/common/eal_common_options.c +3 -10
@@ -798,14 +798,14 @@ eal_parse_common_option(int opt, const char *optarg,switch (opt) {/* blacklist */ case 'b' : -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED , optarg) <0 ) {return -1 ; }break ;/* whitelist */ case 'w' : -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI , +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED , optarg) <0 ) {return -1 ; }
@@ -901,7 +901,7 @@ eal_parse_common_option(int opt, const char *optarg,break ;case OPT_VDEV_NUM : -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL , +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , optarg) <0 ) {return -1 ; }
@@ -1025,13 +1025,6 @@ eal_check_common_options(struct internal_config *internal_cfg)return -1 ; } -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=0 && -rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=0 ) { -RTE_LOG (ERR ,EAL ,"Options blacklist (-b) and whitelist (-w) " -"cannot be used at the same time\n" ); -return -1 ; - } -return 0 ; }
lib/librte_eal/common/eal_common_pci.c +3 -3
@@ -198,7 +198,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,/* no initialization when blacklisted, return without error */ if (dev->device.devargs !=NULL && dev->device.devargs->type == -RTE_DEVTYPE_BLACKLISTED_PCI ) { +RTE_DEVTYPE_BLACKLISTED ) {RTE_LOG (INFO ,EAL ," Device is blacklisted, not" " initializing\n" );return 1 ;
@@ -390,7 +390,7 @@ rte_pci_probe(void)int probe_all =0 ;int ret =0 ; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) ==0 ) +if (rte_pci_bus.bus.conf.scan_mode !=RTE_BUS_SCAN_WHITELIST ) probe_all =1 ;FOREACH_DEVICE_ON_PCIBUS (dev) {
@@ -405,7 +405,7 @@ rte_pci_probe(void)if (probe_all) ret =pci_probe_all_drivers (dev);else if (devargs !=NULL && - devargs->type ==RTE_DEVTYPE_WHITELISTED_PCI ) + devargs->type ==RTE_DEVTYPE_WHITELISTED ) ret =pci_probe_all_drivers (dev);if (ret <0 ) { RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT
lib/librte_eal/common/eal_common_vdev.c +0 -1
@@ -176,7 +176,6 @@ alloc_devargs(const char *name, const char *args)if (!devargs)return NULL ; - devargs->type =RTE_DEVTYPE_VIRTUAL ; devargs->bus =rte_bus_find_by_name ("vdev" );if (args) devargs->args =strdup (args);
lib/librte_eal/common/include/rte_devargs.h +3 -3
@@ -56,9 +56,9 @@ extern "C" {* Type of generic device */ enum rte_devtype { -RTE_DEVTYPE_WHITELISTED_PCI , -RTE_DEVTYPE_BLACKLISTED_PCI , -RTE_DEVTYPE_VIRTUAL , +RTE_DEVTYPE_UNDEFINED , +RTE_DEVTYPE_WHITELISTED , +RTE_DEVTYPE_BLACKLISTED , };/**
test/test/test_devargs.c +19 -17
@@ -64,30 +64,32 @@ test_devargs(void)TAILQ_INIT (&devargs_list);/* test valid cases */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"08:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"08:00.1" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"0000:5:00.0" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"0000:5:00.0" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI ,"04:00.0,arg=val" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"04:00.0,arg=val" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_BLACKLISTED_PCI ,"0000:01:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"0000:01:00.1" ) <0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED_PCI ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_WHITELISTED ) !=4 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED_PCI ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_BLACKLISTED ) !=0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_VIRTUAL ) !=0 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_UNDEFINED ) !=0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring0" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED ,"net_ring0" ) <0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,key=val,k2=val2" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , +"net_ring1,key=val,k2=val2" ) <0 ) goto fail; -if (rte_eal_devargs_type_count (RTE_DEVTYPE_VIRTUAL ) !=2 ) +if (rte_eal_devargs_type_count (RTE_DEVTYPE_UNDEFINED ) !=2 ) goto fail;free_devargs_list ();/* check virtual device with argument parsing */ -if (rte_eal_devargs_add (RTE_DEVTYPE_VIRTUAL ,"net_ring1,k1=val,k2=val2" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_UNDEFINED , +"net_ring1,k1=val,k2=val2" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list); if (strncmp(devargs->name, "net_ring1",
@@ -98,7 +100,7 @@ test_devargs(void)free_devargs_list ();/* check PCI device with empty argument parsing */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"04:00.1" ) <0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"04:00.1" ) <0 ) goto fail; devargs =TAILQ_FIRST (&devargs_list);if (strcmp (devargs->name,"04:00.1" ) !=0 )
@@ -108,15 +110,15 @@ test_devargs(void)free_devargs_list ();/* test error case: bad PCI address */ -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"08:1" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"08:1" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"00.1" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"00.1" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"foo" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"foo" ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"," ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"," ) ==0 ) goto fail; -if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED_PCI ,"000f:0:0" ) ==0 ) +if (rte_eal_devargs_add (RTE_DEVTYPE_WHITELISTED ,"000f:0:0" ) ==0 ) goto fail; devargs_list = save_devargs_list;
Signature · 1 line
2.1.4
PATCH v7 16/17 devargs: introduce cleaner parsing helper
In reply to Gaetan RivetIntroduce a more versatile helper to parse device strings. This helper expects a generic rte_devargs structure as storage in order not to require API changes in the future, should this structure be updated.
The old equivalent function is thus being deprecated, as its API does not allow to accompany rte_devargs evolutions.
A deprecation notice is issued.
This new helper will parse bus information as well as device name and device parameters. It does not allocate an rte_devargs structure and expects one to be given as input.
--- doc/guides/rel_notes/deprecation.rst | 5 ++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_devargs.c | 78 ++++++++++++++++--------- lib/librte_eal/common/include/rte_devargs.h | 20 +++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 5 files changed, 79 insertions(+), 26 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
@@ -95,3 +95,8 @@ Deprecation Notices The non-"do-sig" versions of the hash tables will be removed (including the ``signature_offset`` parameter) and the "do-sig" versions renamed accordingly. + +* eal: the following function is deprecated starting from 17.08 and will + be removed in 17.11: + + - ``rte_eal_parse_devargs_str``, replaced by ``rte_eal_devargs_parse``
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
@@ -206,6 +206,7 @@ DPDK_17.08 { EXPERIMENTAL { global: + rte_eal_devargs_parse; rte_eal_hotplug_add; rte_eal_hotplug_remove;
lib/librte_eal/common/eal_common_devargs.c +52 -26
113 lines not on this page · raw message
lib/librte_eal/common/include/rte_devargs.h +20 -0
@@ -119,6 +119,26 @@ int rte_eal_parse_devargs_str(const char *devargs_str, char **drvname, char **drvargs);/** +* Parse a device string. +* +* Verify that a bus is capable of handling the device passed +* in argument. Store which bus will handle the device, its name +* and the eventual device parameters. +* +* @param dev +* The device declaration string. +* @param da +* The devargs structure holding the device information. +* +* @return +* - 0 on success. +* - Negative errno on error. +*/ +int +rte_eal_devargs_parse (const char *dev, +struct rte_devargs *da); + +/** * Add a device to the user device list * * For PCI devices, the format of arguments string is "PCI_ADDR" or
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
@@ -211,6 +211,7 @@ DPDK_17.08 { EXPERIMENTAL { global: + rte_eal_devargs_parse; rte_eal_hotplug_add; rte_eal_hotplug_remove;
Signature · 1 line
2.1.4
PATCH v7 17/17 eal: change whitelist / blacklist command line doc
In reply to Gaetan RivetThe use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.
Update the source code accordingly.
--- lib/librte_eal/common/eal_common_options.c | 18 +++++++++--------- lib/librte_eal/common/eal_options.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-)
lib/librte_eal/common/eal_common_options.c +9 -9
@@ -86,8 +86,8 @@ eal_long_options[] = { {OPT_NO_HUGE, 0, NULL, OPT_NO_HUGE_NUM }, {OPT_NO_PCI, 0, NULL, OPT_NO_PCI_NUM }, {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM }, - {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM }, - {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM }, + {OPT_BUS_BLACKLIST, 1, NULL, OPT_BUS_BLACKLIST_NUM }, + {OPT_BUS_WHITELIST, 1, NULL, OPT_BUS_WHITELIST_NUM }, {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM }, {OPT_SOCKET_MEM, 1, NULL, OPT_SOCKET_MEM_NUM }, {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM },
@@ -1049,14 +1049,14 @@ eal_common_usage(void)" -n CHANNELS Number of memory channels\n" " -m MB Memory to allocate (see also --" OPT_SOCKET_MEM ")\n" " -r RANKS Force number of memory ranks (don't detect)\n" -" -b, --" OPT_PCI_BLACKLIST " Add a PCI device in black list.\n" -" Prevent EAL from using this PCI device. The argument\n" -" format is <domain:bus:devid.func>.\n" -" -w, --" OPT_PCI_WHITELIST " Add a PCI device in white list.\n" -" Only use the specified PCI devices. The argument format\n" -" is <[domain:]bus:devid.func>. This option can be present\n" +" -b, --" OPT_BUS_BLACKLIST " Black list a device on its bus.\n" +" Prevents EAL from using this device. The argument\n" +" format depends on the bus.\n" +" -w, --" OPT_BUS_WHITELIST " White list a device on its bus.\n" +" Only use the specified devices. The argument format\n" +" depends on the bus. This option can be present\n" " several times (once per device).\n" -" [NOTE: PCI whitelist cannot be used with -b option]\n" +" [NOTE: whitelist cannot be used with -b option]\n" " --" OPT_VDEV " Add a virtual device.\n" " The argument format is <driver><id>[,key=val,...]\n" " (ex: --vdev=net_pcap0,iface=eth2).\n"
lib/librte_eal/common/eal_options.h +4 -4
@@ -37,10 +37,10 @@ enum {/* long options mapped to a short option */ #define OPT_HELP "help" OPT_HELP_NUM = 'h', -#define OPT_PCI_BLACKLIST "pci-blacklist" - OPT_PCI_BLACKLIST_NUM = 'b', -#define OPT_PCI_WHITELIST "pci-whitelist" - OPT_PCI_WHITELIST_NUM = 'w', +#define OPT_BUS_BLACKLIST "bus-blacklist" + OPT_BUS_BLACKLIST_NUM = 'b', +#define OPT_BUS_WHITELIST "bus-whitelist" + OPT_BUS_WHITELIST_NUM = 'w',/* first long only option value must be >= 256, so that we won't * conflict with short options */
Signature · 1 line
2.1.4
Re: [PATCH v7 17/17] eal: change whitelist / blacklist command line doc
07/07/2017 02:04, Gaetan Rivet:
Quoted 8 lines
The use of these commands have evolved.
It is now possible to use whitelist and blacklist on any bus.Update the source code accordingly.
Signed-off-by Gaetan Rivet <[email protected]>Acked-by John McNamara <[email protected]>---
[...]
Quoted 4 lines
lib/librte_eal/common/eal_options.h +0
-0@@ -37,10 +37,10 @@ enum {/* long options mapped to a short option */
lib/librte_eal/common/eal_options.h enum { · line 43
Quoted 10 lines
lib/librte_eal/common/eal_options.h +4
-4#define OPT_HELP "help" OPT_HELP_NUM = 'h', -#define OPT_PCI_BLACKLIST "pci-blacklist" - OPT_PCI_BLACKLIST_NUM = 'b', -#define OPT_PCI_WHITELIST "pci-whitelist" - OPT_PCI_WHITELIST_NUM = 'w', +#define OPT_BUS_BLACKLIST "bus-blacklist" + OPT_BUS_BLACKLIST_NUM = 'b', +#define OPT_BUS_WHITELIST "bus-whitelist" + OPT_BUS_WHITELIST_NUM = 'w',
No, we cannot drop an existing option without a prior notice. Let's discuss what should be the command line syntax and agree on a good and complete deprecation notice.
There will be more to change, like making bus explicit.
07/07/2017 02:04, Gaetan Rivet:
Quoted 4 lines
In this patchset, the representation of devices in
rte_devargsis made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.
[...]
Quoted 18 lines
Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc
Quoted 2 lines
Thomas Monjalon (1):
examples/ethtool: properly reference PCI header
Series applied, except last patch (17), as explained before. Thanks
Quoted 24 lines · Thomas Monjalon
07/07/2017 02:04, Gaetan Rivet:
Quoted 4 lines
In this patchset, the representation of devices in
rte_devargsis made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.[...]
Quoted 18 lines
Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc
Quoted 5 lines
Quoted 2 lines
Thomas Monjalon (1):
examples/ethtool: properly reference PCI headerSeries 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).
09/07/2017 10:37, Jan Blunck:
Quoted 25 lines · Thomas Monjalon
Quoted 24 lines
07/07/2017 02:04, Gaetan Rivet:
Quoted 4 lines
In this patchset, the representation of devices in
rte_devargsis made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.[...]
Quoted 18 lines
Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line doc
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Thomas Monjalon (1):
examples/ethtool: properly reference PCI headerSeries applied, except last patch (17), as explained before. Thanks
I wonder why you complain about not having enough reviewers if you anyway ignoring their feedback!
I am not ignoring your feedback at all.
There are 2 things in this series:
1/ decouple devargs and PCI/vdev
2/ couple devargs policies to rte_bus
I agree that we should not have policies in rte_bus (2). However it is the only patches we have for now to achieve (1), which is a required step to move PCI and vdev as real bus drivers.
As explained in the following email, I prefer progressing on (1) and rework (2) in 17.11:
http://dpdk.org/ml/archives/dev/2017-July/070203.html
What do you think of my proposal, adding a callback in probe?
Quoted 2 lines
I pointed out multiple times that parsing a device name to deduce the bus is not the right thing to do.
Yes, so we need to change the parameter syntax to make the bus name explicit and mandatory. We need a deprecation notice.
Quoted 4 lines
This series also tightly couples
rte_devargstorte_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.
Quoted 35 lines · Thomas Monjalon
09/07/2017 10:37, Jan Blunck:
Quoted 25 lines · Thomas Monjalon
Quoted 24 lines
07/07/2017 02:04, Gaetan Rivet:
Quoted 4 lines
In this patchset, the representation of devices in
rte_devargsis made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.[...]
Quoted 18 lines
Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line docQuoted 8 lines
Quoted 5 lines
Quoted 2 lines
Thomas Monjalon (1):
examples/ethtool: properly reference PCI headerSeries applied, except last patch (17), as explained before. Thanks
I wonder why you complain about not having enough reviewers if you anyway ignoring their feedback!
Quoted 7 lines
I am not ignoring your feedback at all.
There are 2 things in this series:
1/ decouple devargs and PCI/vdev
2/ couple devargs policies torte_bus
I agree that we should not have policies inrte_bus(2). However it is the only patches we have for now to achieve (1), which is a required step to move PCI and vdev as real bus drivers.
(1) is easy to achieve. I've explained multiple times that devargs shoudl be:
- bus name
- device name
- device arguments
Somehow I expected that giving suggestions and review comments will lead to people actively working on this picking up the ideas. I guess I was mistaken. I'll save my breath and fix it myself.
Quoted 18 lines
As explained in the following email, I prefer progressing on (1) and rework (2) in 17.11:
http://dpdk.org/ml/archives/dev/2017-July/070203.htmlWhat do you think of my proposal, adding a callback in probe?
Quoted 2 lines
I pointed out multiple times that parsing a device name to deduce the bus is not the right thing to do.
Yes, so we need to change the parameter syntax to make the bus name explicit and mandatory. We need a deprecation notice.
Quoted 4 lines
This series also tightly couples
rte_devargstorte_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.
Quoted 44 lines · Jan Blunck
Quoted 35 lines · Thomas Monjalon
09/07/2017 10:37, Jan Blunck:
Quoted 25 lines · Thomas Monjalon
Quoted 24 lines
07/07/2017 02:04, Gaetan Rivet:
Quoted 4 lines
In this patchset, the representation of devices in
rte_devargsis made generic to remove some dependencies of the EAL on specific buses implementations. Following the device types being characterized by their bus, the DEVTYPE flags are updated not to reference virtual / PCI devices anymore.[...]
Quoted 18 lines
Gaetan Rivet (16):
net/bonding: properly reference PCI header net/bnxt: properly reference PCI header net/mlx5: properly reference PCI header net/e1000: properly reference PCI header net/ixgbe: properly reference PCI header net/sfc: properly reference PCI header app/testpmd: properly reference PCI header
test: properly reference PCI header
dev: device kernel module is a device attribute
bus: introduce bus scan policies
devargs: parse bus policies
devargs: generic device representation net/virtio: do not reference device type
devargs: generic device types
devargs: introduce cleaner parsing helper
eal: change whitelist / blacklist command line docQuoted 8 lines
Quoted 5 lines
Quoted 2 lines
Thomas Monjalon (1):
examples/ethtool: properly reference PCI headerSeries applied, except last patch (17), as explained before. Thanks
I wonder why you complain about not having enough reviewers if you anyway ignoring their feedback!
Quoted 7 lines
I am not ignoring your feedback at all.
There are 2 things in this series:
1/ decouple devargs and PCI/vdev
2/ couple devargs policies torte_bus
I agree that we should not have policies inrte_bus(2). However it is the only patches we have for now to achieve (1), which is a required step to move PCI and vdev as real bus drivers.
Quoted 10 lines
(1) is easy to achieve. I've explained multiple times that devargs shoudl be:
- bus name
- device name
- device argumentsSomehow I expected that giving suggestions and review comments will lead to people actively working on this picking up the ideas. I guess I was mistaken. I'll save my breath and fix it myself.
The goal is to restrict the devargs to this trifecta, eventually. In the meantime however, the way things have been designed previously forces having the "devtype" (now limited to bus scan policy) coupled with it.
It is not possible to remove it without changing the API / usage of EAL parameters.
This functionality was not added to other buses. The latent default whitelist mode was simply made explicit. This does not preclude changing it next release. In any case, it makes the issue obvious and allows comments from reviewer to point out those issue clearly.
Quoted 18 lines
Quoted 18 lines
As explained in the following email, I prefer progressing on (1) and rework (2) in 17.11:
http://dpdk.org/ml/archives/dev/2017-July/070203.htmlWhat do you think of my proposal, adding a callback in probe?
Quoted 2 lines
I pointed out multiple times that parsing a device name to deduce the bus is not the right thing to do.
Yes, so we need to change the parameter syntax to make the bus name explicit and mandatory. We need a deprecation notice.
Quoted 4 lines
This series also tightly couples
rte_devargstorte_bus. It adds hidden functionality to have blacklist/whitelist mode for all busses and even sticks that functionality on the wrong object (devargs).Yes, as said above, we must rework it in 17.11.
Signature · 2 lines
Gaëtan Rivet 6WIND