4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include <rte_string_fns.h>
38 #ifdef RTE_LIBRTE_PMD_RING
39 #include <rte_eth_ring.h>
41 #ifdef RTE_LIBRTE_PMD_PCAP
42 #include <rte_eth_pcap.h>
44 #ifdef RTE_LIBRTE_PMD_XENVIRT
45 #include <rte_eth_xenvirt.h>
47 #include <rte_debug.h>
48 #include <rte_devargs.h>
49 #include "eal_private.h"
52 const char *dev_prefix;
53 int (*init_fn)(const char*, const char *);
56 #define NUM_DEV_TYPES (sizeof(dev_types)/sizeof(dev_types[0]))
57 struct device_init dev_types[] = {
58 #ifdef RTE_LIBRTE_PMD_RING
60 .dev_prefix = RTE_ETH_RING_PARAM_NAME,
61 .init_fn = rte_pmd_ring_init
64 #ifdef RTE_LIBRTE_PMD_PCAP
66 .dev_prefix = RTE_ETH_PCAP_PARAM_NAME,
67 .init_fn = rte_pmd_pcap_init
70 #ifdef RTE_LIBRTE_PMD_XENVIRT
72 .dev_prefix = RTE_ETH_XENVIRT_PARAM_NAME,
73 .init_fn = rte_pmd_xenvirt_init
77 .dev_prefix = "-nodev-",
83 rte_eal_non_pci_ethdev_init(void)
85 struct rte_devargs *devargs;
88 /* call the init function for each virtual device */
89 TAILQ_FOREACH(devargs, &devargs_list, next) {
91 if (devargs->type != RTE_DEVTYPE_VIRTUAL)
94 for (i = 0; i < NUM_DEV_TYPES; i++) {
95 /* search a driver prefix in virtual device name */
96 if (!strncmp(dev_types[i].dev_prefix,
97 devargs->virtual.drv_name,
98 sizeof(dev_types[i].dev_prefix) - 1)) {
99 dev_types[i].init_fn(devargs->virtual.drv_name,
105 if (i == NUM_DEV_TYPES) {
106 rte_panic("no driver found for %s\n",
107 devargs->virtual.drv_name);