eal: make vdev init path generic for both virtual and pci devices
Currently, physical device pmds use a separate initalization path (rte_pmd_init_all) while virtual devices use a constructor registration and rte_eal_dev_init. Theres no reason to have them be separate. This patch removes the vdev specific nomenclature from the vdev init path and makes it more generic for use with all pmds. This is the first step in converting the physical device pmds to using the same constructor based registration path that the virtual devices use. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
This commit is contained in:
parent
2c62588a53
commit
e57f20e051
@ -70,7 +70,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_cpuflags.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_string_fns.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_hexdump.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_vdev.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c
|
||||
|
||||
CFLAGS_eal.o := -D_GNU_SOURCE
|
||||
#CFLAGS_eal_thread.o := -D_GNU_SOURCE
|
||||
|
@ -875,8 +875,8 @@ rte_eal_init(int argc, char **argv)
|
||||
|
||||
rte_eal_mcfg_complete();
|
||||
|
||||
if (rte_eal_vdev_init() < 0)
|
||||
rte_panic("Cannot init virtual devices\n");
|
||||
if (rte_eal_dev_init() < 0)
|
||||
rte_panic("Cannot init pmd devices\n");
|
||||
|
||||
RTE_LCORE_FOREACH_SLAVE(i) {
|
||||
|
||||
|
@ -38,7 +38,7 @@ INC += rte_pci_dev_ids.h rte_per_lcore.h rte_prefetch.h rte_random.h
|
||||
INC += rte_rwlock.h rte_spinlock.h rte_tailq.h rte_interrupts.h rte_alarm.h
|
||||
INC += rte_string_fns.h rte_cpuflags.h rte_version.h rte_tailq_elem.h
|
||||
INC += rte_eal_memconfig.h rte_malloc_heap.h
|
||||
INC += rte_hexdump.h rte_devargs.h rte_vdev.h
|
||||
INC += rte_hexdump.h rte_devargs.h rte_dev.h
|
||||
|
||||
ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y)
|
||||
INC += rte_warnings.h
|
||||
|
@ -36,41 +36,42 @@
|
||||
#include <inttypes.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <rte_vdev.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_devargs.h>
|
||||
|
||||
#include "eal_private.h"
|
||||
|
||||
/** Global list of virtual device drivers. */
|
||||
static struct rte_vdev_driver_list vdev_driver_list =
|
||||
TAILQ_HEAD_INITIALIZER(vdev_driver_list);
|
||||
/** Global list of device drivers. */
|
||||
static struct rte_driver_list dev_driver_list =
|
||||
TAILQ_HEAD_INITIALIZER(dev_driver_list);
|
||||
|
||||
/* register a driver */
|
||||
void
|
||||
rte_eal_vdev_driver_register(struct rte_vdev_driver *driver)
|
||||
rte_eal_driver_register(struct rte_driver *driver)
|
||||
{
|
||||
TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
|
||||
TAILQ_INSERT_TAIL(&dev_driver_list, driver, next);
|
||||
}
|
||||
|
||||
/* unregister a driver */
|
||||
void
|
||||
rte_eal_vdev_driver_unregister(struct rte_vdev_driver *driver)
|
||||
rte_eal_driver_unregister(struct rte_driver *driver)
|
||||
{
|
||||
TAILQ_REMOVE(&vdev_driver_list, driver, next);
|
||||
TAILQ_REMOVE(&dev_driver_list, driver, next);
|
||||
}
|
||||
|
||||
int
|
||||
rte_eal_vdev_init(void)
|
||||
rte_eal_dev_init(void)
|
||||
{
|
||||
struct rte_devargs *devargs;
|
||||
struct rte_vdev_driver *driver;
|
||||
struct rte_driver *driver;
|
||||
|
||||
/* No need to register drivers that are embeded in DPDK
|
||||
* (pmd_pcap, pmd_ring, ...). The initialization function have
|
||||
* the ((constructor)) attribute so they will register at
|
||||
* startup. */
|
||||
/*
|
||||
* Note that the dev_driver_list is populated here
|
||||
* from calls made to rte_eal_driver_register from constructor functions
|
||||
* embedded into PMD modules via the PMD_REGISTER_DRIVER macro
|
||||
*/
|
||||
|
||||
/* call the init function for each virtual device */
|
||||
TAILQ_FOREACH(devargs, &devargs_list, next) {
|
||||
@ -78,7 +79,10 @@ rte_eal_vdev_init(void)
|
||||
if (devargs->type != RTE_DEVTYPE_VIRTUAL)
|
||||
continue;
|
||||
|
||||
TAILQ_FOREACH(driver, &vdev_driver_list, next) {
|
||||
TAILQ_FOREACH(driver, &dev_driver_list, next) {
|
||||
if (driver->type != PMD_VDEV)
|
||||
continue;
|
||||
|
||||
/* search a driver prefix in virtual device name */
|
||||
if (!strncmp(driver->name, devargs->virtual.drv_name,
|
||||
strlen(driver->name))) {
|
||||
@ -93,5 +97,13 @@ rte_eal_vdev_init(void)
|
||||
devargs->virtual.drv_name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Once the vdevs are initalized, start calling all the pdev drivers */
|
||||
TAILQ_FOREACH(driver, &dev_driver_list, next) {
|
||||
if (driver->type != PMD_PDEV)
|
||||
continue;
|
||||
/* PDEV drivers don't get passed any parameters */
|
||||
driver->init(NULL, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -201,6 +201,6 @@ int rte_eal_alarm_init(void);
|
||||
*
|
||||
* This function is private to the EAL.
|
||||
*/
|
||||
int rte_eal_vdev_init(void);
|
||||
int rte_eal_dev_init(void);
|
||||
|
||||
#endif /* _EAL_PRIVATE_H_ */
|
||||
|
@ -31,15 +31,15 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _RTE_VDEV_H_
|
||||
#define _RTE_VDEV_H_
|
||||
#ifndef _RTE_DEV_H_
|
||||
#define _RTE_DEV_H_
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* RTE Virtual Devices Interface
|
||||
* RTE PMD Driver Registration Interface
|
||||
*
|
||||
* This file manages the list of the virtual device drivers.
|
||||
* This file manages the list of device drivers.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -48,57 +48,60 @@ extern "C" {
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
/** Double linked list of virtual device drivers. */
|
||||
TAILQ_HEAD(rte_vdev_driver_list, rte_vdev_driver);
|
||||
/** Double linked list of device drivers. */
|
||||
TAILQ_HEAD(rte_driver_list, rte_driver);
|
||||
|
||||
/**
|
||||
* Initialization function called for each virtual device probing.
|
||||
* Initialization function called for each device driver once.
|
||||
*/
|
||||
typedef int (rte_vdev_init_t)(const char *name, const char *args);
|
||||
typedef int (rte_dev_init_t)(const char *name, const char *args);
|
||||
|
||||
/**
|
||||
* A structure describing a virtual device driver.
|
||||
* Driver type enumeration
|
||||
*/
|
||||
struct rte_vdev_driver {
|
||||
TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */
|
||||
const char *name; /**< Driver name. */
|
||||
rte_vdev_init_t *init; /**< Device init. function. */
|
||||
enum pmd_type {
|
||||
PMD_VDEV = 0,
|
||||
PMD_PDEV = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a virtual device driver.
|
||||
* A structure describing a device driver.
|
||||
*/
|
||||
struct rte_driver {
|
||||
TAILQ_ENTRY(rte_driver) next; /**< Next in list. */
|
||||
enum pmd_type type; /**< PMD Driver type */
|
||||
const char *name; /**< Driver name. */
|
||||
rte_dev_init_t *init; /**< Device init. function. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a device driver.
|
||||
*
|
||||
* @param driver
|
||||
* A pointer to a rte_vdev structure describing the driver
|
||||
* A pointer to a rte_dev structure describing the driver
|
||||
* to be registered.
|
||||
*/
|
||||
void rte_eal_vdev_driver_register(struct rte_vdev_driver *driver);
|
||||
void rte_eal_driver_register(struct rte_driver *driver);
|
||||
|
||||
/**
|
||||
* Unregister a virtual device driver.
|
||||
* Unregister a device driver.
|
||||
*
|
||||
* @param driver
|
||||
* A pointer to a rte_vdev structure describing the driver
|
||||
* A pointer to a rte_dev structure describing the driver
|
||||
* to be unregistered.
|
||||
*/
|
||||
void rte_eal_vdev_driver_unregister(struct rte_vdev_driver *driver);
|
||||
void rte_eal_driver_unregister(struct rte_driver *driver);
|
||||
|
||||
enum rte_pmd_driver_type {
|
||||
PMD_VDEV = 1
|
||||
};
|
||||
/**
|
||||
* Initalize all the registered drivers in this process
|
||||
*/
|
||||
int rte_eal_dev_init(void);
|
||||
|
||||
extern void rte_eal_nonpci_dev_init_register(const char *name, int (*dev_initfn)(const char *, const char *));
|
||||
#define PMD_REGISTER_DRIVER(d, t)\
|
||||
#define PMD_REGISTER_DRIVER(d)\
|
||||
void devinitfn_ ##d(void);\
|
||||
void __attribute__((constructor, used)) devinitfn_ ##d(void)\
|
||||
{\
|
||||
enum rte_pmd_driver_type _t = (t);\
|
||||
switch(_t)\
|
||||
{\
|
||||
case PMD_VDEV:\
|
||||
rte_eal_vdev_driver_register(&d);\
|
||||
break;\
|
||||
};\
|
||||
rte_eal_driver_register(&d);\
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
@ -78,7 +78,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_cpuflags.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_string_fns.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_hexdump.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_devargs.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_vdev.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_dev.c
|
||||
|
||||
CFLAGS_eal.o := -D_GNU_SOURCE
|
||||
CFLAGS_eal_thread.o := -D_GNU_SOURCE
|
||||
|
@ -1061,8 +1061,8 @@ rte_eal_init(int argc, char **argv)
|
||||
RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%x)\n",
|
||||
rte_config.master_lcore, (int)thread_id);
|
||||
|
||||
if (rte_eal_vdev_init() < 0)
|
||||
rte_panic("Cannot init virtual devices\n");
|
||||
if (rte_eal_dev_init() < 0)
|
||||
rte_panic("Cannot init pmd devices\n");
|
||||
|
||||
RTE_LCORE_FOREACH_SLAVE(i) {
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include <rte_string_fns.h>
|
||||
#include <rte_cycles.h>
|
||||
#include <rte_kvargs.h>
|
||||
#include <rte_vdev.h>
|
||||
#include <rte_dev.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
@ -767,9 +767,10 @@ rte_pmd_pcap_devinit(const char *name, const char *params)
|
||||
|
||||
}
|
||||
|
||||
static struct rte_vdev_driver pmd_pcap_drv = {
|
||||
static struct rte_driver pmd_pcap_drv = {
|
||||
.name = "eth_pcap",
|
||||
.type = PMD_VDEV,
|
||||
.init = rte_pmd_pcap_devinit,
|
||||
};
|
||||
|
||||
PMD_REGISTER_DRIVER(pmd_pcap_drv, PMD_VDEV);
|
||||
PMD_REGISTER_DRIVER(pmd_pcap_drv);
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_memcpy.h>
|
||||
#include <rte_string_fns.h>
|
||||
#include <rte_vdev.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_kvargs.h>
|
||||
|
||||
#define ETH_RING_NUMA_NODE_ACTION_ARG "nodeaction"
|
||||
@ -520,9 +520,10 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct rte_vdev_driver pmd_ring_drv = {
|
||||
static struct rte_driver pmd_ring_drv = {
|
||||
.name = "eth_ring",
|
||||
.type = PMD_VDEV,
|
||||
.init = rte_pmd_ring_devinit,
|
||||
};
|
||||
|
||||
PMD_REGISTER_DRIVER(pmd_ring_drv, PMD_VDEV);
|
||||
PMD_REGISTER_DRIVER(pmd_ring_drv);
|
||||
|
@ -53,7 +53,7 @@
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_memcpy.h>
|
||||
#include <rte_string_fns.h>
|
||||
#include <rte_vdev.h>
|
||||
#include <rte_dev.h>
|
||||
#include <cmdline_parse.h>
|
||||
#include <cmdline_parse_etheraddr.h>
|
||||
|
||||
@ -706,9 +706,10 @@ rte_pmd_xenvirt_devinit(const char *name, const char *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rte_vdev_driver pmd_xenvirt_drv = {
|
||||
static struct rte_driver pmd_xenvirt_drv = {
|
||||
.name = "eth_xenvirt",
|
||||
.type = PMD_VDEV,
|
||||
.init = rte_pmd_xenvirt_devinit,
|
||||
};
|
||||
|
||||
PMD_REGISTER_DRIVER(pmd_xenvirt_drv, PMD_VDEV);
|
||||
PMD_REGISTER_DRIVER(pmd_xenvirt_drv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user