DPDK  19.11.14
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 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <rte_config.h>
16 #include <rte_malloc.h>
17 #include <rte_bus_vdev.h>
18 #include <rte_ethdev_driver.h>
19 
34 static inline struct rte_eth_dev *
35 rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
36 {
37  struct rte_eth_dev *eth_dev;
38  const char *name = rte_vdev_device_name(dev);
39 
40  eth_dev = rte_eth_dev_allocate(name);
41  if (!eth_dev)
42  return NULL;
43 
44  if (private_data_size) {
45  eth_dev->data->dev_private = rte_zmalloc_socket(name,
46  private_data_size, RTE_CACHE_LINE_SIZE,
47  dev->device.numa_node);
48  if (!eth_dev->data->dev_private) {
49  rte_eth_dev_release_port(eth_dev);
50  return NULL;
51  }
52  }
53 
54  eth_dev->device = &dev->device;
55  eth_dev->intr_handle = NULL;
56 
57  eth_dev->data->kdrv = RTE_KDRV_NONE;
58  eth_dev->data->numa_node = dev->device.numa_node;
59  return eth_dev;
60 }
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif /* _RTE_ETHDEV_VDEV_H_ */
void * rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket)