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

Function eth_dev_shared_data_prepare

dpdk/lib/ethdev/ethdev_private.c:324–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324void *
325eth_dev_shared_data_prepare(void)
326{
327 const struct rte_memzone *mz;
328
329 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
330 const unsigned int flags = 0;
331
332 if (eth_dev_shared_mz != NULL)
333 goto out;
334
335 /* Allocate port data and ownership shared memory. */
336 mz = rte_memzone_reserve(MZ_RTE_ETH_DEV_DATA,
337 sizeof(*eth_dev_shared_data),
338 rte_socket_id(), flags);
339 if (mz == NULL) {
340 RTE_ETHDEV_LOG(ERR, "Cannot allocate ethdev shared data\n");
341 goto out;
342 }
343
344 eth_dev_shared_mz = mz;
345 eth_dev_shared_data = mz->addr;
346 eth_dev_shared_data->allocated_owners = 0;
347 eth_dev_shared_data->next_owner_id =
348 RTE_ETH_DEV_NO_OWNER + 1;
349 eth_dev_shared_data->allocated_ports = 0;
350 memset(eth_dev_shared_data->data, 0,
351 sizeof(eth_dev_shared_data->data));
352 } else {
353 mz = rte_memzone_lookup(MZ_RTE_ETH_DEV_DATA);
354 if (mz == NULL) {
355 /* Clean remaining any traces of a previous shared mem */
356 eth_dev_shared_mz = NULL;
357 eth_dev_shared_data = NULL;
358 RTE_ETHDEV_LOG(ERR, "Cannot lookup ethdev shared data\n");
359 goto out;
360 }
361 if (mz == eth_dev_shared_mz && mz->addr == eth_dev_shared_data)
362 goto out;
363
364 /* Shared mem changed in primary process, refresh pointers */
365 eth_dev_shared_mz = mz;
366 eth_dev_shared_data = mz->addr;
367 }
368out:
369 return eth_dev_shared_data;
370}
371
372void
373eth_dev_shared_data_release(void)

Callers 9

rte_eth_dev_owner_newFunction · 0.85
rte_eth_dev_owner_setFunction · 0.85
rte_eth_dev_owner_unsetFunction · 0.85
rte_eth_dev_owner_deleteFunction · 0.85
rte_eth_dev_owner_getFunction · 0.85
rte_eth_dev_allocateFunction · 0.85
rte_eth_dev_allocatedFunction · 0.85
rte_eth_dev_release_portFunction · 0.85

Calls 5

rte_eal_process_typeFunction · 0.85
rte_memzone_reserveFunction · 0.85
rte_socket_idFunction · 0.85
memsetFunction · 0.85
rte_memzone_lookupFunction · 0.85

Tested by

no test coverage detected