MCPcopy Index your code
hub / github.com/F-Stack/f-stack / rte_eth_dev_allocate

Function rte_eth_dev_allocate

dpdk/lib/ethdev/ethdev_driver.c:74–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74struct rte_eth_dev *
75rte_eth_dev_allocate(const char *name)
76{
77 uint16_t port_id;
78 struct rte_eth_dev *eth_dev = NULL;
79 size_t name_len;
80
81 name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
82 if (name_len == 0) {
83 RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n");
84 return NULL;
85 }
86
87 if (name_len >= RTE_ETH_NAME_MAX_LEN) {
88 RTE_ETHDEV_LOG(ERR, "Ethernet device name is too long\n");
89 return NULL;
90 }
91
92 /* Synchronize port creation between primary and secondary processes. */
93 rte_spinlock_lock(rte_mcfg_ethdev_get_lock());
94
95 if (eth_dev_shared_data_prepare() == NULL)
96 goto unlock;
97
98 if (eth_dev_allocated(name) != NULL) {
99 RTE_ETHDEV_LOG(ERR,
100 "Ethernet device with name %s already allocated\n",
101 name);
102 goto unlock;
103 }
104
105 port_id = eth_dev_find_free_port();
106 if (port_id == RTE_MAX_ETHPORTS) {
107 RTE_ETHDEV_LOG(ERR,
108 "Reached maximum number of Ethernet ports\n");
109 goto unlock;
110 }
111
112 eth_dev = eth_dev_get(port_id);
113 strlcpy(eth_dev->data->name, name, sizeof(eth_dev->data->name));
114 eth_dev->data->port_id = port_id;
115 eth_dev->data->backer_port_id = RTE_MAX_ETHPORTS;
116 eth_dev->data->mtu = RTE_ETHER_MTU;
117 pthread_mutex_init(&eth_dev->data->flow_ops_mutex, NULL);
118 RTE_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
119 eth_dev_shared_data->allocated_ports++;
120
121unlock:
122 rte_spinlock_unlock(rte_mcfg_ethdev_get_lock());
123
124 return eth_dev;
125}
126
127struct rte_eth_dev *
128rte_eth_dev_allocated(const char *name)

Callers 15

rte_eth_dev_pci_allocateFunction · 0.85
rte_eth_vdev_allocateFunction · 0.85
rte_eth_dev_createFunction · 0.85
eth_ark_dev_initFunction · 0.85
do_eth_dev_ring_createFunction · 0.85
mlx4_pci_probeFunction · 0.85
mana_probe_portFunction · 0.85
nfp_init_app_fw_nicFunction · 0.85
mrvl_eth_dev_createFunction · 0.85
octeontx_createFunction · 0.85
mlx5_dev_spawnFunction · 0.85
mlx5_dev_spawnFunction · 0.85

Calls 11

strnlenFunction · 0.85
rte_mcfg_ethdev_get_lockFunction · 0.85
eth_dev_allocatedFunction · 0.85
eth_dev_find_free_portFunction · 0.85
eth_dev_getFunction · 0.85
pthread_mutex_initFunction · 0.85
rte_eal_process_typeFunction · 0.85
rte_spinlock_lockFunction · 0.50
strlcpyFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by 1

virtual_ethdev_createFunction · 0.68