DPDK  18.11.11
rte_ethdev_vdev.h
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2017 Brocade Communications Systems, Inc.
5  * Author: Jan Blunck <jblunck@infradead.org>
6  */
7 
8 #ifndef _RTE_ETHDEV_VDEV_H_
9 #define _RTE_ETHDEV_VDEV_H_
10 
11 #include <rte_config.h>
12 #include <rte_malloc.h>
13 #include <rte_bus_vdev.h>
14 #include <rte_ethdev_driver.h>
15 
30 static inline struct rte_eth_dev *
31 rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
32 {
33  struct rte_eth_dev *eth_dev;
34  const char *name = rte_vdev_device_name(dev);
35 
36  eth_dev = rte_eth_dev_allocate(name);
37  if (!eth_dev)
38  return NULL;
39 
40  if (private_data_size) {
41  eth_dev->data->dev_private = rte_zmalloc_socket(name,
42  private_data_size, RTE_CACHE_LINE_SIZE,
43  dev->device.numa_node);
44  if (!eth_dev->data->dev_private) {
45  rte_eth_dev_release_port(eth_dev);
46  return NULL;
47  }
48  }
49 
50  eth_dev->device = &dev->device;
51  eth_dev->intr_handle = NULL;
52 
53  eth_dev->data->kdrv = RTE_KDRV_NONE;
54  eth_dev->data->numa_node = dev->device.numa_node;
55  return eth_dev;
56 }
57 
58 #endif /* _RTE_ETHDEV_VDEV_H_ */
void * rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket)