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

Function rte_bbdev_allocate

dpdk/lib/bbdev/rte_bbdev.c:173–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173struct rte_bbdev *
174rte_bbdev_allocate(const char *name)
175{
176 int ret;
177 struct rte_bbdev *bbdev;
178 uint16_t dev_id;
179
180 if (name == NULL) {
181 rte_bbdev_log(ERR, "Invalid null device name");
182 return NULL;
183 }
184
185 if (rte_bbdev_get_named_dev(name) != NULL) {
186 rte_bbdev_log(ERR, "Device \"%s\" is already allocated", name);
187 return NULL;
188 }
189
190 dev_id = find_free_dev_id();
191 if (dev_id == RTE_BBDEV_MAX_DEVS) {
192 rte_bbdev_log(ERR, "Reached maximum number of devices");
193 return NULL;
194 }
195
196 bbdev = &rte_bbdev_devices[dev_id];
197
198 if (rte_bbdev_data == NULL) {
199 ret = rte_bbdev_data_alloc();
200 if (ret != 0)
201 return NULL;
202 }
203
204 bbdev->data = find_bbdev_data(name);
205 if (bbdev->data == NULL) {
206 rte_bbdev_log(ERR,
207 "Max BBDevs already allocated in multi-process environment!");
208 return NULL;
209 }
210
211 rte_atomic_fetch_add_explicit(&bbdev->data->process_cnt, 1, rte_memory_order_relaxed);
212 bbdev->data->dev_id = dev_id;
213 bbdev->state = RTE_BBDEV_INITIALIZED;
214
215 ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name);
216 if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) {
217 rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name);
218 return NULL;
219 }
220
221 /* init user callbacks */
222 TAILQ_INIT(&(bbdev->list_cbs));
223
224 num_devs++;
225
226 rte_bbdev_log_debug("Initialised device %s (id = %u). Num devices = %u",
227 name, dev_id, num_devs);
228
229 return bbdev;
230}

Callers 10

turbo_sw_bbdev_createFunction · 0.85
null_bbdev_createFunction · 0.85
la12xx_bbdev_createFunction · 0.85
fpga_5gnr_fec_probeFunction · 0.85
fpga_lte_fec_probeFunction · 0.85
acc100_pci_probeFunction · 0.85
vrb_pci_probeFunction · 0.85
test_bbdev_driver_initFunction · 0.85
test_bbdev_callbackFunction · 0.85
test_bbdev_get_named_devFunction · 0.85

Calls 5

rte_bbdev_get_named_devFunction · 0.85
find_free_dev_idFunction · 0.85
rte_bbdev_data_allocFunction · 0.85
find_bbdev_dataFunction · 0.85
snprintfFunction · 0.85

Tested by 3

test_bbdev_driver_initFunction · 0.68
test_bbdev_callbackFunction · 0.68
test_bbdev_get_named_devFunction · 0.68