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

Function eth_dev_null_create

dpdk/drivers/net/null/rte_eth_null.c:535–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

533};
534
535static int
536eth_dev_null_create(struct rte_vdev_device *dev, struct pmd_options *args)
537{
538 const unsigned int nb_rx_queues = 1;
539 const unsigned int nb_tx_queues = 1;
540 struct rte_eth_dev_data *data;
541 struct pmd_internals *internals = NULL;
542 struct rte_eth_dev *eth_dev = NULL;
543
544 static const uint8_t default_rss_key[40] = {
545 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2, 0x41, 0x67, 0x25, 0x3D,
546 0x43, 0xA3, 0x8F, 0xB0, 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
547 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C, 0x6A, 0x42, 0xB7, 0x3B,
548 0xBE, 0xAC, 0x01, 0xFA
549 };
550
551 if (dev->device.numa_node == SOCKET_ID_ANY)
552 dev->device.numa_node = rte_socket_id();
553
554 PMD_LOG(INFO, "Creating null ethdev on numa socket %u",
555 dev->device.numa_node);
556
557 eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internals));
558 if (!eth_dev)
559 return -ENOMEM;
560
561 /* now put it all together
562 * - store queue data in internals,
563 * - store numa_node info in ethdev data
564 * - point eth_dev_data to internals
565 * - and point eth_dev structure to new eth_dev_data structure
566 */
567 /* NOTE: we'll replace the data element, of originally allocated eth_dev
568 * so the nulls are local per-process */
569
570 internals = eth_dev->data->dev_private;
571 internals->packet_size = args->packet_size;
572 internals->packet_copy = args->packet_copy;
573 internals->no_rx = args->no_rx;
574 internals->port_id = eth_dev->data->port_id;
575 rte_eth_random_addr(internals->eth_addr.addr_bytes);
576
577 internals->flow_type_rss_offloads = RTE_ETH_RSS_PROTO_MASK;
578 internals->reta_size = RTE_DIM(internals->reta_conf) * RTE_ETH_RETA_GROUP_SIZE;
579
580 rte_memcpy(internals->rss_key, default_rss_key, 40);
581
582 data = eth_dev->data;
583 data->nb_rx_queues = (uint16_t)nb_rx_queues;
584 data->nb_tx_queues = (uint16_t)nb_tx_queues;
585 data->dev_link = pmd_link;
586 data->mac_addrs = &internals->eth_addr;
587 data->promiscuous = 1;
588 data->all_multicast = 1;
589 data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
590
591 eth_dev->dev_ops = &ops;
592

Callers 1

rte_pmd_null_probeFunction · 0.85

Calls 5

rte_socket_idFunction · 0.85
rte_eth_vdev_allocateFunction · 0.85
rte_eth_random_addrFunction · 0.85
rte_memcpyFunction · 0.50

Tested by

no test coverage detected