printf("Testing ring pmd init\n");
- if (rte_pmd_ring_init(name1, params_null) < 0) {
+ if (rte_pmd_ring_devinit(name1, params_null) < 0) {
printf("Testing ring pmd init fail\n");
return -1;
}
- if (rte_pmd_ring_init(name2, params) < 0) {
+ if (rte_pmd_ring_devinit(name2, params) < 0) {
printf("Testing ring pmd init fail\n");
return -1;
}
rte_eth_dev_stop(RXTX_PORT2);
/* Test init same name pmd ring */
- rte_pmd_ring_init(name1, params_null);
+ rte_pmd_ring_devinit(name1, params_null);
return 0;
}
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
+INC += rte_hexdump.h rte_devargs.h rte_vdev.h
ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y)
INC += rte_warnings.h
#include <string.h>
#include <inttypes.h>
-#include <rte_string_fns.h>
-#ifdef RTE_LIBRTE_PMD_RING
-#include <rte_eth_ring.h>
-#endif
-#ifdef RTE_LIBRTE_PMD_PCAP
-#include <rte_eth_pcap.h>
-#endif
-#ifdef RTE_LIBRTE_PMD_XENVIRT
-#include <rte_eth_xenvirt.h>
-#endif
+#include <sys/queue.h>
+
+#include <rte_vdev.h>
+#include <rte_devargs.h>
#include <rte_debug.h>
#include <rte_devargs.h>
+
#include "eal_private.h"
-struct device_init {
- const char *dev_prefix;
- int (*init_fn)(const char*, const char *);
-};
+/** Global list of virtual device drivers. */
+static struct rte_vdev_driver_list vdev_driver_list =
+ TAILQ_HEAD_INITIALIZER(vdev_driver_list);
-#define NUM_DEV_TYPES (sizeof(dev_types)/sizeof(dev_types[0]))
-struct device_init dev_types[] = {
-#ifdef RTE_LIBRTE_PMD_RING
- {
- .dev_prefix = RTE_ETH_RING_PARAM_NAME,
- .init_fn = rte_pmd_ring_init
- },
-#endif
-#ifdef RTE_LIBRTE_PMD_PCAP
- {
- .dev_prefix = RTE_ETH_PCAP_PARAM_NAME,
- .init_fn = rte_pmd_pcap_init
- },
-#endif
-#ifdef RTE_LIBRTE_PMD_XENVIRT
- {
- .dev_prefix = RTE_ETH_XENVIRT_PARAM_NAME,
- .init_fn = rte_pmd_xenvirt_init
- },
-#endif
- {
- .dev_prefix = "-nodev-",
- .init_fn = NULL
- }
-};
+/* register a driver */
+void
+rte_eal_vdev_driver_register(struct rte_vdev_driver *driver)
+{
+ TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
+}
+
+/* unregister a driver */
+void
+rte_eal_vdev_driver_unregister(struct rte_vdev_driver *driver)
+{
+ TAILQ_REMOVE(&vdev_driver_list, driver, next);
+}
int
rte_eal_vdev_init(void)
{
struct rte_devargs *devargs;
- uint8_t i;
+ struct rte_vdev_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. */
/* call the init function for each virtual device */
TAILQ_FOREACH(devargs, &devargs_list, next) {
if (devargs->type != RTE_DEVTYPE_VIRTUAL)
continue;
- for (i = 0; i < NUM_DEV_TYPES; i++) {
+ TAILQ_FOREACH(driver, &vdev_driver_list, next) {
/* search a driver prefix in virtual device name */
- if (!strncmp(dev_types[i].dev_prefix,
- devargs->virtual.drv_name,
- sizeof(dev_types[i].dev_prefix) - 1)) {
- dev_types[i].init_fn(devargs->virtual.drv_name,
- devargs->args);
+ if (!strncmp(driver->name, devargs->virtual.drv_name,
+ strlen(driver->name))) {
+ driver->init(devargs->virtual.drv_name,
+ devargs->args);
break;
}
}
- if (i == NUM_DEV_TYPES) {
+ if (driver == NULL) {
rte_panic("no driver found for %s\n",
devargs->virtual.drv_name);
}
--- /dev/null
+/*-
+ * BSD LICENSE
+ *
+ * Copyright(c) 2014 6WIND S.A.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of 6WIND S.A. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_VDEV_H_
+#define _RTE_VDEV_H_
+
+/**
+ * @file
+ *
+ * RTE Virtual Devices Interface
+ *
+ * This file manages the list of the virtual device drivers.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/queue.h>
+
+/** Double linked list of virtual device drivers. */
+TAILQ_HEAD(rte_vdev_driver_list, rte_vdev_driver);
+
+/**
+ * Initialization function called for each virtual device probing.
+ */
+typedef int (rte_vdev_init_t)(const char *name, const char *args);
+
+/**
+ * A structure describing a virtual device driver.
+ */
+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. */
+};
+
+/**
+ * Register a virtual device driver.
+ *
+ * @param driver
+ * A pointer to a rte_vdev structure describing the driver
+ * to be registered.
+ */
+void rte_eal_vdev_driver_register(struct rte_vdev_driver *driver);
+
+/**
+ * Unregister a virtual device driver.
+ *
+ * @param driver
+ * A pointer to a rte_vdev structure describing the driver
+ * to be unregistered.
+ */
+void rte_eal_vdev_driver_unregister(struct rte_vdev_driver *driver);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_VDEV_H_ */
#
# Export include files
#
-SYMLINK-y-include += rte_eth_pcap.h
+SYMLINK-y-include +=
# this lib depends upon:
DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += lib/librte_mbuf
#include <rte_string_fns.h>
#include <rte_cycles.h>
#include <rte_kvargs.h>
+#include <rte_vdev.h>
#include <net/if.h>
-#include "rte_eth_pcap.h"
+#include <pcap.h>
#define RTE_ETH_PCAP_SNAPSHOT_LEN 65535
#define RTE_ETH_PCAP_SNAPLEN 4096
}
-int
-rte_pmd_pcap_init(const char *name, const char *params)
+static int
+rte_pmd_pcap_devinit(const char *name, const char *params)
{
unsigned numa_node, using_dumpers = 0;
int ret;
}
+static struct rte_vdev_driver pmd_pcap_drv = {
+ .name = "eth_pcap",
+ .init = rte_pmd_pcap_devinit,
+};
+
+__attribute__((constructor))
+static void
+rte_pmd_pcap_init(void)
+{
+ rte_eal_vdev_driver_register(&pmd_pcap_drv);
+}
+++ /dev/null
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _RTE_ETH_PCAP_H_
-#define _RTE_ETH_PCAP_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-#include <pcap.h>
-
-#define RTE_ETH_PCAP_PARAM_NAME "eth_pcap"
-
-/**
- * For use by the EAL only. Called as part of EAL init to set up any dummy NICs
- * configured on command line.
- */
-int rte_pmd_pcap_init(const char *name, const char *params);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_string_fns.h>
+#include <rte_vdev.h>
struct ring_queue {
struct rte_ring *rng;
}
int
-rte_pmd_ring_init(const char *name, const char *params)
+rte_pmd_ring_devinit(const char *name, const char *params)
{
RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name);
}
return 0;
}
+
+static struct rte_vdev_driver pmd_ring_drv = {
+ .name = "eth_ring",
+ .init = rte_pmd_ring_devinit,
+};
+
+__attribute__((constructor))
+static void
+rte_pmd_ring_init(void)
+{
+ rte_eal_vdev_driver_register(&pmd_ring_drv);
+}
#include <rte_ring.h>
-#define RTE_ETH_RING_PARAM_NAME "eth_ring"
-
int rte_eth_from_rings(struct rte_ring * const rx_queues[],
const unsigned nb_rx_queues,
struct rte_ring *const tx_queues[],
int rte_eth_ring_pair_attach(const char *name, const unsigned numa_node);
/**
- * For use by the EAL only. Called as part of EAL init to set up any dummy NICs
+ * For use by test apps only. Called as part of EAL init to set up any dummy NICs
* configured on command line.
*/
-int rte_pmd_ring_init(const char *name, const char *params);
+int rte_pmd_ring_devinit(const char *name, const char *params);
#ifdef __cplusplus
}
/*TODO: Support multiple process model */
-int
-rte_pmd_xenvirt_init(const char *name, const char *params)
+static int
+rte_pmd_xenvirt_devinit(const char *name, const char *params)
{
if (virtio_idx == 0) {
if (xenstore_init() != 0) {
eth_dev_xenvirt_create(name, params, rte_socket_id(), DEV_CREATE);
return 0;
}
+
+static struct rte_vdev_driver pmd_xenvirt_drv = {
+ .name = "eth_xenvirt",
+ .init = rte_pmd_xenvirt_devinit,
+};
+
+__attribute__((constructor))
+static void
+rte_pmd_xenvirt_init(void)
+{
+ rte_eal_vdev_driver_register(&pmd_xenvirt_drv);
+}
#include <rte_mempool.h>
#include <rte_ring.h>
-#define RTE_ETH_XENVIRT_PARAM_NAME "eth_xenvirt"
-
-/**
- * For use by the EAL only. Called as part of EAL init to set up any dummy NICs
- * configured on command line.
- */
-int rte_pmd_xenvirt_init(const char *name, const char *params);
-
/**
* Creates mempool for xen virtio PMD.
* This function uses memzone_reserve to allocate memory for meta data,