#include <rte_mbuf.h>
#include <rte_ethdev.h>
+#include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_kvargs.h>
#include <rte_vdev.h>
static struct rte_vdev_driver pmd_af_packet_drv;
static int
-rte_pmd_init_internals(const char *name,
+rte_pmd_init_internals(struct rte_vdev_device *dev,
const int sockfd,
const unsigned nb_queues,
unsigned int blocksize,
unsigned int blockcnt,
unsigned int framesize,
unsigned int framecnt,
- const unsigned numa_node,
struct pmd_internals **internals,
struct rte_eth_dev **eth_dev,
struct rte_kvargs *kvlist)
{
+ const char *name = rte_vdev_device_name(dev);
+ const unsigned int numa_node = dev->device.numa_node;
struct rte_eth_dev_data *data = NULL;
struct rte_kvargs_pair *pair = NULL;
struct ifreq ifr;
}
/* reserve an ethdev entry */
- *eth_dev = rte_eth_dev_allocate(name);
+ *eth_dev = rte_eth_vdev_allocate(dev, 0);
if (*eth_dev == NULL)
goto error;
(*internals)->nb_queues = nb_queues;
+ rte_memcpy(data, (*eth_dev)->data, sizeof(*data));
data->dev_private = *internals;
- data->port_id = (*eth_dev)->data->port_id;
data->nb_rx_queues = (uint16_t)nb_queues;
data->nb_tx_queues = (uint16_t)nb_queues;
data->dev_link = pmd_link;
data->mac_addrs = &(*internals)->eth_addr;
- strncpy(data->name,
- (*eth_dev)->data->name, strlen((*eth_dev)->data->name));
(*eth_dev)->data = data;
(*eth_dev)->dev_ops = &ops;
- (*eth_dev)->driver = NULL;
(*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
- (*eth_dev)->data->drv_name = pmd_af_packet_drv.driver.name;
- (*eth_dev)->data->kdrv = RTE_KDRV_NONE;
- (*eth_dev)->data->numa_node = numa_node;
return 0;
}
static int
-rte_eth_from_packet(const char *name,
+rte_eth_from_packet(struct rte_vdev_device *dev,
int const *sockfd,
- const unsigned numa_node,
struct rte_kvargs *kvlist)
{
+ const char *name = rte_vdev_device_name(dev);
struct pmd_internals *internals = NULL;
struct rte_eth_dev *eth_dev = NULL;
struct rte_kvargs_pair *pair = NULL;
RTE_LOG(INFO, PMD, "%s:\tframe size %d\n", name, framesize);
RTE_LOG(INFO, PMD, "%s:\tframe count %d\n", name, framecount);
- if (rte_pmd_init_internals(name, *sockfd, qpairs,
- blocksize, blockcount,
- framesize, framecount,
- numa_node, &internals, ð_dev,
- kvlist) < 0)
+ if (rte_pmd_init_internals(dev, *sockfd, qpairs,
+ blocksize, blockcount,
+ framesize, framecount,
+ &internals, ð_dev,
+ kvlist) < 0)
return -1;
eth_dev->rx_pkt_burst = eth_af_packet_rx;
static int
rte_pmd_af_packet_probe(struct rte_vdev_device *dev)
{
- const char *name = rte_vdev_device_name(dev);
- unsigned numa_node;
int ret = 0;
struct rte_kvargs *kvlist;
int sockfd = -1;
- RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n", name);
-
- numa_node = rte_socket_id();
+ RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n",
+ rte_vdev_device_name(dev));
kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
if (kvlist == NULL) {
goto exit;
}
- ret = rte_eth_from_packet(name, &sockfd, numa_node, kvlist);
+ if (dev->device.numa_node == SOCKET_ID_ANY)
+ dev->device.numa_node = rte_socket_id();
+
+ ret = rte_eth_from_packet(dev, &sockfd, kvlist);
close(sockfd); /* no longer needed */
exit:
#include <rte_mbuf.h>
#include <rte_malloc.h>
#include <rte_ethdev.h>
+#include <rte_ethdev_vdev.h>
#include <rte_tcp.h>
#include <rte_udp.h>
#include <rte_ip.h>
* and internal (private) data
*/
- if (name == NULL) {
- RTE_BOND_LOG(ERR, "Invalid name specified");
- goto err;
- }
-
if (socket_id >= number_of_sockets()) {
RTE_BOND_LOG(ERR,
"Invalid socket id specified to create bonded device on.");
goto err;
}
- internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
- if (internals == NULL) {
- RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
- goto err;
- }
-
/* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate(name);
+ eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internals));
if (eth_dev == NULL) {
RTE_BOND_LOG(ERR, "Unable to allocate rte_eth_dev");
goto err;
}
- eth_dev->data->dev_private = internals;
+ internals = eth_dev->data->dev_private;
eth_dev->data->nb_rx_queues = (uint16_t)1;
eth_dev->data->nb_tx_queues = (uint16_t)1;
eth_dev->dev_ops = &default_dev_ops;
eth_dev->data->dev_flags = RTE_ETH_DEV_INTR_LSC |
RTE_ETH_DEV_DETACHABLE;
- eth_dev->driver = NULL;
- eth_dev->data->kdrv = RTE_KDRV_NONE;
- eth_dev->data->drv_name = pmd_bond_drv.driver.name;
- eth_dev->data->numa_node = socket_id;
rte_spinlock_init(&internals->lock);
#include <unistd.h>
#include <rte_ethdev.h>
+#include <rte_ethdev_vdev.h>
#include <rte_kni.h>
#include <rte_kvargs.h>
#include <rte_malloc.h>
static struct rte_vdev_driver eth_kni_drv;
static struct rte_eth_dev *
-eth_kni_create(const char *name, struct eth_kni_args *args,
+eth_kni_create(struct rte_vdev_device *vdev,
+ struct eth_kni_args *args,
unsigned int numa_node)
{
- struct pmd_internals *internals = NULL;
+ struct pmd_internals *internals;
struct rte_eth_dev_data *data;
struct rte_eth_dev *eth_dev;
+ const char *name;
RTE_LOG(INFO, PMD, "Creating kni ethdev on numa socket %u\n",
numa_node);
+ name = rte_vdev_device_name(vdev);
data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);
if (data == NULL)
- goto error;
-
- internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
- if (internals == NULL)
- goto error;
+ return NULL;
/* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate(name);
- if (eth_dev == NULL)
- goto error;
+ eth_dev = rte_eth_vdev_allocate(vdev, sizeof(*internals));
+ if (eth_dev == NULL) {
+ rte_free(data);
+ return NULL;
+ }
- data->dev_private = internals;
- data->port_id = eth_dev->data->port_id;
- memmove(data->name, eth_dev->data->name, sizeof(data->name));
+ internals = eth_dev->data->dev_private;
+ rte_memcpy(data, eth_dev->data, sizeof(*data));
data->nb_rx_queues = 1;
data->nb_tx_queues = 1;
data->dev_link = pmd_link;
eth_dev->data = data;
eth_dev->dev_ops = ð_kni_ops;
- eth_dev->device->driver = NULL;
data->dev_flags = RTE_ETH_DEV_DETACHABLE;
- data->kdrv = RTE_KDRV_NONE;
- data->drv_name = eth_kni_drv.driver.name;
- data->numa_node = numa_node;
internals->no_request_thread = args->no_request_thread;
return eth_dev;
-
-error:
- rte_free(data);
- rte_free(internals);
-
- return NULL;
}
static int
if (ret < 0)
return ret;
- eth_dev = eth_kni_create(name, &args, rte_socket_id());
+ eth_dev = eth_kni_create(vdev, &args, rte_socket_id());
if (eth_dev == NULL)
goto kni_uninit;
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+#include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_vdev.h>
static struct rte_vdev_driver pmd_null_drv;
static int
-eth_dev_null_create(const char *name,
- const unsigned numa_node,
+eth_dev_null_create(struct rte_vdev_device *dev,
unsigned packet_size,
unsigned packet_copy)
{
0xBE, 0xAC, 0x01, 0xFA
};
- if (name == NULL)
- return -EINVAL;
+ if (dev->device.numa_node == SOCKET_ID_ANY)
+ dev->device.numa_node = rte_socket_id();
RTE_LOG(INFO, PMD, "Creating null ethdev on numa socket %u\n",
- numa_node);
+ dev->device.numa_node);
/* now do all data allocation - for eth_dev structure, dummy pci driver
* and internal (private) data
*/
- data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);
- if (data == NULL)
- goto error;
-
- internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
- if (internals == NULL)
- goto error;
+ data = rte_zmalloc_socket(rte_vdev_device_name(dev), sizeof(*data), 0,
+ dev->device.numa_node);
+ if (!data)
+ return -ENOMEM;
- /* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate(name);
- if (eth_dev == NULL)
- goto error;
+ eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internals));
+ if (!eth_dev) {
+ rte_free(data);
+ return -ENOMEM;
+ }
/* now put it all together
* - store queue data in internals,
/* NOTE: we'll replace the data element, of originally allocated eth_dev
* so the nulls are local per-process */
+ internals = eth_dev->data->dev_private;
internals->packet_size = packet_size;
internals->packet_copy = packet_copy;
internals->port_id = eth_dev->data->port_id;
rte_memcpy(internals->rss_key, default_rss_key, 40);
- data->dev_private = internals;
- data->port_id = eth_dev->data->port_id;
+ rte_memcpy(data, eth_dev->data, sizeof(*data));
data->nb_rx_queues = (uint16_t)nb_rx_queues;
data->nb_tx_queues = (uint16_t)nb_tx_queues;
data->dev_link = pmd_link;
data->mac_addrs = ð_addr;
- strncpy(data->name, eth_dev->data->name, strlen(eth_dev->data->name));
eth_dev->data = data;
eth_dev->dev_ops = &ops;
- eth_dev->driver = NULL;
data->dev_flags = RTE_ETH_DEV_DETACHABLE;
- data->kdrv = RTE_KDRV_NONE;
- data->drv_name = pmd_null_drv.driver.name;
- data->numa_node = numa_node;
/* finally assign rx and tx ops */
if (packet_copy) {
}
return 0;
-
-error:
- rte_free(data);
- rte_free(internals);
-
- return -1;
}
static inline int
rte_pmd_null_probe(struct rte_vdev_device *dev)
{
const char *name, *params;
- unsigned numa_node;
unsigned packet_size = default_packet_size;
unsigned packet_copy = default_packet_copy;
struct rte_kvargs *kvlist = NULL;
params = rte_vdev_device_args(dev);
RTE_LOG(INFO, PMD, "Initializing pmd_null for %s\n", name);
- numa_node = rte_socket_id();
-
if (params != NULL) {
kvlist = rte_kvargs_parse(params, valid_arguments);
if (kvlist == NULL)
"packet copy is %s\n", packet_size,
packet_copy ? "enabled" : "disabled");
- ret = eth_dev_null_create(name, numa_node, packet_size, packet_copy);
+ ret = eth_dev_null_create(dev, packet_size, packet_copy);
free_kvlist:
if (kvlist)
#include <rte_cycles.h>
#include <rte_ethdev.h>
+#include <rte_ethdev_vdev.h>
#include <rte_kvargs.h>
#include <rte_malloc.h>
#include <rte_mbuf.h>
static struct rte_vdev_driver pmd_pcap_drv;
static int
-pmd_init_internals(const char *name, const unsigned int nb_rx_queues,
+pmd_init_internals(struct rte_vdev_device *vdev,
+ const unsigned int nb_rx_queues,
const unsigned int nb_tx_queues,
struct pmd_internals **internals,
struct rte_eth_dev **eth_dev)
{
struct rte_eth_dev_data *data = NULL;
- unsigned int numa_node = rte_socket_id();
+ unsigned int numa_node = vdev->device.numa_node;
+ const char *name;
+ name = rte_vdev_device_name(vdev);
RTE_LOG(INFO, PMD, "Creating pcap-backed ethdev on numa socket %u\n",
numa_node);
*/
data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);
if (data == NULL)
- goto error;
-
- *internals = rte_zmalloc_socket(name, sizeof(**internals), 0,
- numa_node);
- if (*internals == NULL)
- goto error;
+ return -1;
/* reserve an ethdev entry */
- *eth_dev = rte_eth_dev_allocate(name);
- if (*eth_dev == NULL)
- goto error;
+ *eth_dev = rte_eth_vdev_allocate(vdev, sizeof(**internals));
+ if (*eth_dev == NULL) {
+ rte_free(data);
+ return -1;
+ }
/* now put it all together
* - store queue data in internals,
* - point eth_dev_data to internals
* - and point eth_dev structure to new eth_dev_data structure
*/
- data->dev_private = *internals;
- data->port_id = (*eth_dev)->data->port_id;
- snprintf(data->name, sizeof(data->name), "%s", (*eth_dev)->data->name);
+ *internals = (*eth_dev)->data->dev_private;
+ rte_memcpy(data, (*eth_dev)->data, sizeof(*data));
data->nb_rx_queues = (uint16_t)nb_rx_queues;
data->nb_tx_queues = (uint16_t)nb_tx_queues;
data->dev_link = pmd_link;
*/
(*eth_dev)->data = data;
(*eth_dev)->dev_ops = &ops;
- (*eth_dev)->driver = NULL;
data->dev_flags = RTE_ETH_DEV_DETACHABLE;
- data->kdrv = RTE_KDRV_NONE;
- data->drv_name = pmd_pcap_drv.driver.name;
- data->numa_node = numa_node;
return 0;
-
-error:
- rte_free(data);
- rte_free(*internals);
-
- return -1;
}
static int
-eth_from_pcaps_common(const char *name, struct pmd_devargs *rx_queues,
- const unsigned int nb_rx_queues, struct pmd_devargs *tx_queues,
- const unsigned int nb_tx_queues, struct rte_kvargs *kvlist,
- struct pmd_internals **internals, struct rte_eth_dev **eth_dev)
+eth_from_pcaps_common(struct rte_vdev_device *vdev,
+ struct pmd_devargs *rx_queues, const unsigned int nb_rx_queues,
+ struct pmd_devargs *tx_queues, const unsigned int nb_tx_queues,
+ struct rte_kvargs *kvlist, struct pmd_internals **internals,
+ struct rte_eth_dev **eth_dev)
{
struct rte_kvargs_pair *pair = NULL;
unsigned int k_idx;
if (tx_queues == NULL && nb_tx_queues > 0)
return -1;
- if (pmd_init_internals(name, nb_rx_queues, nb_tx_queues, internals,
+ if (pmd_init_internals(vdev, nb_rx_queues, nb_tx_queues, internals,
eth_dev) < 0)
return -1;
}
static int
-eth_from_pcaps(const char *name, struct pmd_devargs *rx_queues,
- const unsigned int nb_rx_queues, struct pmd_devargs *tx_queues,
- const unsigned int nb_tx_queues, struct rte_kvargs *kvlist,
- int single_iface, unsigned int using_dumpers)
+eth_from_pcaps(struct rte_vdev_device *vdev,
+ struct pmd_devargs *rx_queues, const unsigned int nb_rx_queues,
+ struct pmd_devargs *tx_queues, const unsigned int nb_tx_queues,
+ struct rte_kvargs *kvlist, int single_iface,
+ unsigned int using_dumpers)
{
struct pmd_internals *internals = NULL;
struct rte_eth_dev *eth_dev = NULL;
int ret;
- ret = eth_from_pcaps_common(name, rx_queues, nb_rx_queues,
+ ret = eth_from_pcaps_common(vdev, rx_queues, nb_rx_queues,
tx_queues, nb_tx_queues, kvlist, &internals, ð_dev);
if (ret < 0)
goto free_kvlist;
create_eth:
- ret = eth_from_pcaps(name, &pcaps, pcaps.num_of_queue, &dumpers,
+ ret = eth_from_pcaps(dev, &pcaps, pcaps.num_of_queue, &dumpers,
dumpers.num_of_queue, kvlist, single_iface, is_tx_pcap);
free_kvlist:
#include <rte_common.h>
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+#include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_vdev.h>
#include <rte_kvargs.h>
}
static int
-eth_dev_tap_create(const char *name, char *tap_name, char *remote_iface)
+eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name,
+ char *remote_iface)
{
int numa_node = rte_socket_id();
- struct rte_eth_dev *dev = NULL;
- struct pmd_internals *pmd = NULL;
- struct rte_eth_dev_data *data = NULL;
+ struct rte_eth_dev *dev;
+ struct pmd_internals *pmd;
+ struct rte_eth_dev_data *data;
int i;
RTE_LOG(DEBUG, PMD, " TAP device on numa %u\n", rte_socket_id());
goto error_exit;
}
- pmd = rte_zmalloc_socket(tap_name, sizeof(*pmd), 0, numa_node);
- if (!pmd) {
- RTE_LOG(ERR, PMD, "TAP Unable to allocate internal struct\n");
- goto error_exit;
- }
-
- /* name in allocation and data->name must be consistent */
- snprintf(data->name, sizeof(data->name), "%s", name);
- dev = rte_eth_dev_allocate(name);
+ dev = rte_eth_vdev_allocate(vdev, sizeof(*pmd));
if (!dev) {
RTE_LOG(ERR, PMD, "TAP Unable to allocate device struct\n");
goto error_exit;
}
+ pmd = dev->data->dev_private;
snprintf(pmd->name, sizeof(pmd->name), "%s", tap_name);
-
pmd->nb_queues = RTE_PMD_TAP_MAX_QUEUES;
pmd->ioctl_sock = socket(AF_INET, SOCK_DGRAM, 0);
}
/* Setup some default values */
+ rte_memcpy(data, dev->data, sizeof(*data));
data->dev_private = pmd;
- data->port_id = dev->data->port_id;
- data->mtu = dev->data->mtu;
data->dev_flags = RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC;
- data->kdrv = RTE_KDRV_NONE;
- data->drv_name = pmd_tap_drv.driver.name;
data->numa_node = numa_node;
+ data->drv_name = pmd_tap_drv.driver.name;
data->dev_link = pmd_link;
data->mac_addrs = &pmd->eth_addr;
dev->data = data;
dev->dev_ops = &ops;
- dev->driver = NULL;
dev->rx_pkt_burst = pmd_rx_burst;
dev->tx_pkt_burst = pmd_tx_burst;
return 0;
error_exit:
- RTE_LOG(DEBUG, PMD, "TAP Unable to initialize %s\n", name);
+ RTE_LOG(DEBUG, PMD, "TAP Unable to initialize %s\n",
+ rte_vdev_device_name(vdev));
rte_free(data);
- rte_free(pmd);
-
- rte_eth_dev_release_port(dev);
-
return -EINVAL;
}
RTE_LOG(NOTICE, PMD, "Initializing pmd_tap for %s as %s\n",
name, tap_name);
- ret = eth_dev_tap_create(name, tap_name, remote_iface);
+ ret = eth_dev_tap_create(dev, tap_name, remote_iface);
leave:
if (ret == -1) {
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+#include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_memcpy.h>
#include <rte_vdev.h>
static struct rte_vdev_driver pmd_vhost_drv;
static int
-eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
- const unsigned numa_node, uint64_t flags)
+eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name,
+ int16_t queues, const unsigned int numa_node, uint64_t flags)
{
+ const char *name = rte_vdev_device_name(dev);
struct rte_eth_dev_data *data = NULL;
struct pmd_internal *internal = NULL;
struct rte_eth_dev *eth_dev = NULL;
RTE_LOG(INFO, PMD, "Creating VHOST-USER backend on numa socket %u\n",
numa_node);
- /* now do all data allocation - for eth_dev structure, dummy pci driver
- * and internal (private) data
+ /* now do all data allocation - for eth_dev structure and internal
+ * (private) data
*/
data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);
if (data == NULL)
goto error;
- internal = rte_zmalloc_socket(name, sizeof(*internal), 0, numa_node);
- if (internal == NULL)
- goto error;
-
list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
if (list == NULL)
goto error;
/* reserve an ethdev entry */
- eth_dev = rte_eth_dev_allocate(name);
+ eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internal));
if (eth_dev == NULL)
goto error;
/* now put it all together
* - store queue data in internal,
- * - store numa_node info in ethdev data
* - point eth_dev_data to internals
* - and point eth_dev structure to new eth_dev_data structure
*/
+ internal = eth_dev->data->dev_private;
internal->dev_name = strdup(name);
if (internal->dev_name == NULL)
goto error;
rte_spinlock_init(&vring_state->lock);
vring_states[eth_dev->data->port_id] = vring_state;
- data->dev_private = internal;
- data->port_id = eth_dev->data->port_id;
- memmove(data->name, eth_dev->data->name, sizeof(data->name));
+ /* We'll replace the 'data' originally allocated by eth_dev. So the
+ * vhost PMD resources won't be shared between multi processes.
+ */
+ rte_memcpy(data, eth_dev->data, sizeof(*data));
+ eth_dev->data = data;
+
data->nb_rx_queues = queues;
data->nb_tx_queues = queues;
internal->max_queues = queues;
data->dev_link = pmd_link;
data->mac_addrs = eth_addr;
-
- /* We'll replace the 'data' originally allocated by eth_dev. So the
- * vhost PMD resources won't be shared between multi processes.
- */
- eth_dev->data = data;
- eth_dev->dev_ops = &ops;
- eth_dev->driver = NULL;
data->dev_flags =
RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC;
- data->kdrv = RTE_KDRV_NONE;
- data->drv_name = pmd_vhost_drv.driver.name;
- data->numa_node = numa_node;
+
+ eth_dev->dev_ops = &ops;
/* finally assign rx and tx ops */
eth_dev->rx_pkt_burst = eth_vhost_rx;
return data->port_id;
error:
- if (internal)
+ if (internal) {
+ free(internal->iface_name);
free(internal->dev_name);
+ }
rte_free(vring_state);
rte_free(eth_addr);
if (eth_dev)
static int
rte_pmd_vhost_probe(struct rte_vdev_device *dev)
{
- const char *name;
struct rte_kvargs *kvlist = NULL;
int ret = 0;
char *iface_name;
int client_mode = 0;
int dequeue_zero_copy = 0;
- name = rte_vdev_device_name(dev);
- RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", name);
+ RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n",
+ rte_vdev_device_name(dev));
kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments);
if (kvlist == NULL)
flags |= RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
}
- eth_dev_vhost_create(name, iface_name, queues, rte_socket_id(), flags);
+ if (dev->device.numa_node == SOCKET_ID_ANY)
+ dev->device.numa_node = rte_socket_id();
+
+ eth_dev_vhost_create(dev, iface_name, queues, dev->device.numa_node,
+ flags);
out_free:
rte_kvargs_free(kvlist);
#include <rte_malloc.h>
#include <rte_kvargs.h>
+#include <rte_ethdev_vdev.h>
#include <rte_vdev.h>
#include <rte_alarm.h>
static struct rte_vdev_driver virtio_user_driver;
static struct rte_eth_dev *
-virtio_user_eth_dev_alloc(const char *name)
+virtio_user_eth_dev_alloc(struct rte_vdev_device *vdev)
{
struct rte_eth_dev *eth_dev;
struct rte_eth_dev_data *data;
struct virtio_hw *hw;
struct virtio_user_dev *dev;
- eth_dev = rte_eth_dev_allocate(name);
+ eth_dev = rte_eth_vdev_allocate(vdev, sizeof(*hw));
if (!eth_dev) {
PMD_INIT_LOG(ERR, "cannot alloc rte_eth_dev");
return NULL;
}
data = eth_dev->data;
-
- hw = rte_zmalloc(NULL, sizeof(*hw), 0);
- if (!hw) {
- PMD_INIT_LOG(ERR, "malloc virtio_hw failed");
- rte_eth_dev_release_port(eth_dev);
- return NULL;
- }
+ hw = eth_dev->data->dev_private;
dev = rte_zmalloc(NULL, sizeof(*dev), 0);
if (!dev) {
hw->modern = 0;
hw->use_simple_rxtx = 0;
hw->virtio_user_dev = dev;
- data->dev_private = hw;
- data->drv_name = virtio_user_driver.driver.name;
- data->numa_node = SOCKET_ID_ANY;
- data->kdrv = RTE_KDRV_NONE;
data->dev_flags = RTE_ETH_DEV_DETACHABLE;
- eth_dev->driver = NULL;
return eth_dev;
}
}
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- eth_dev = virtio_user_eth_dev_alloc(rte_vdev_device_name(dev));
+ eth_dev = virtio_user_eth_dev_alloc(dev);
if (!eth_dev) {
PMD_INIT_LOG(ERR, "virtio_user fails to alloc device");
goto end;