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

Function virtual_ethdev_create

dpdk/app/test/virtual_pmd.c:502–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500
501
502int
503virtual_ethdev_create(const char *name, struct rte_ether_addr *mac_addr,
504 uint8_t socket_id, uint8_t isr_support)
505{
506 struct rte_pci_device *pci_dev = NULL;
507 struct rte_eth_dev *eth_dev = NULL;
508 struct rte_pci_driver *pci_drv = NULL;
509 struct rte_pci_id *id_table = NULL;
510 struct virtual_ethdev_private *dev_private = NULL;
511 char name_buf[RTE_RING_NAMESIZE];
512
513
514 /* now do all data allocation - for eth_dev structure, dummy pci driver
515 * and internal (dev_private) data
516 */
517
518 pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, socket_id);
519 if (pci_dev == NULL)
520 goto err;
521
522 pci_drv = rte_zmalloc_socket(name, sizeof(*pci_drv), 0, socket_id);
523 if (pci_drv == NULL)
524 goto err;
525
526 id_table = rte_zmalloc_socket(name, sizeof(*id_table), 0, socket_id);
527 if (id_table == NULL)
528 goto err;
529 id_table->device_id = 0xBEEF;
530
531 dev_private = rte_zmalloc_socket(name, sizeof(*dev_private), 0, socket_id);
532 if (dev_private == NULL)
533 goto err;
534
535 snprintf(name_buf, sizeof(name_buf), "%s_rxQ", name);
536 dev_private->rx_queue = rte_ring_create(name_buf, MAX_PKT_BURST, socket_id,
537 0);
538 if (dev_private->rx_queue == NULL)
539 goto err;
540
541 snprintf(name_buf, sizeof(name_buf), "%s_txQ", name);
542 dev_private->tx_queue = rte_ring_create(name_buf, MAX_PKT_BURST, socket_id,
543 0);
544 if (dev_private->tx_queue == NULL)
545 goto err;
546
547 /* reserve an ethdev entry */
548 eth_dev = rte_eth_dev_allocate(name);
549 if (eth_dev == NULL)
550 goto err;
551
552 pci_dev->device.numa_node = socket_id;
553 pci_dev->device.name = eth_dev->data->name;
554 pci_drv->driver.name = virtual_ethdev_driver_name;
555 pci_drv->id_table = id_table;
556
557 if (isr_support)
558 pci_drv->drv_flags |= RTE_PCI_DRV_INTR_LSC;
559 else

Calls 8

rte_zmalloc_socketFunction · 0.85
snprintfFunction · 0.85
rte_ring_createFunction · 0.85
rte_eth_dev_allocateFunction · 0.85
rte_zmallocFunction · 0.85
rte_freeFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected