MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_eth_dev_pci_allocate

Function rte_eth_dev_pci_allocate

dpdk/lib/ethdev/ethdev_pci.h:79–127  ·  view source on GitHub ↗

* @internal * Allocates a new ethdev slot for an Ethernet device and returns the pointer * to that slot for the driver to use. * * @param dev * Pointer to the PCI device * * @param private_data_size * Size of private data structure * * @return * A pointer to a rte_eth_dev or NULL if allocation failed. */

Source from the content-addressed store, hash-verified

77 * A pointer to a rte_eth_dev or NULL if allocation failed.
78 */
79static inline struct rte_eth_dev *
80rte_eth_dev_pci_allocate(struct rte_pci_device *dev, size_t private_data_size)
81{
82 struct rte_eth_dev *eth_dev;
83 const char *name;
84
85 if (!dev)
86 return NULL;
87
88 name = dev->device.name;
89
90 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
91 eth_dev = rte_eth_dev_allocate(name);
92 if (!eth_dev)
93 return NULL;
94
95 if (private_data_size) {
96 /* Try and alloc the private-data structure on socket local to the device */
97 eth_dev->data->dev_private = rte_zmalloc_socket(name,
98 private_data_size, RTE_CACHE_LINE_SIZE,
99 dev->device.numa_node);
100
101 /* if cannot allocate memory on the socket local to the device
102 * use rte_malloc to allocate memory on some other socket, if available.
103 */
104 if (eth_dev->data->dev_private == NULL) {
105 eth_dev->data->dev_private = rte_zmalloc(name,
106 private_data_size, RTE_CACHE_LINE_SIZE);
107
108 if (eth_dev->data->dev_private == NULL) {
109 rte_eth_dev_release_port(eth_dev);
110 return NULL;
111 }
112 /* got memory, but not local, so issue warning */
113 RTE_ETHDEV_LOG(WARNING,
114 "Private data for ethdev '%s' not allocated on local NUMA node %d\n",
115 dev->device.name, dev->device.numa_node);
116 }
117 }
118 } else {
119 eth_dev = rte_eth_dev_attach_secondary(name);
120 if (!eth_dev)
121 return NULL;
122 }
123
124 eth_dev->device = &dev->device;
125 rte_eth_copy_pci_info(eth_dev, dev);
126 return eth_dev;
127}
128
129typedef int (*eth_dev_pci_callback_t)(struct rte_eth_dev *eth_dev);
130

Callers 2

eth_ark_pci_probeFunction · 0.85

Calls 7

rte_eal_process_typeFunction · 0.85
rte_eth_dev_allocateFunction · 0.85
rte_zmalloc_socketFunction · 0.85
rte_zmallocFunction · 0.85
rte_eth_dev_release_portFunction · 0.85
rte_eth_copy_pci_infoFunction · 0.85

Tested by

no test coverage detected