| 1498 | }; |
| 1499 | |
| 1500 | static int |
| 1501 | eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name, |
| 1502 | int16_t queues, const unsigned int numa_node, uint64_t flags, |
| 1503 | uint64_t disable_flags) |
| 1504 | { |
| 1505 | const char *name = rte_vdev_device_name(dev); |
| 1506 | struct rte_eth_dev_data *data; |
| 1507 | struct pmd_internal *internal = NULL; |
| 1508 | struct rte_eth_dev *eth_dev = NULL; |
| 1509 | struct rte_ether_addr *eth_addr = NULL; |
| 1510 | |
| 1511 | VHOST_LOG(INFO, "Creating VHOST-USER backend on numa socket %u\n", |
| 1512 | numa_node); |
| 1513 | |
| 1514 | /* reserve an ethdev entry */ |
| 1515 | eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internal)); |
| 1516 | if (eth_dev == NULL) |
| 1517 | goto error; |
| 1518 | data = eth_dev->data; |
| 1519 | |
| 1520 | eth_addr = rte_zmalloc_socket(name, sizeof(*eth_addr), 0, numa_node); |
| 1521 | if (eth_addr == NULL) |
| 1522 | goto error; |
| 1523 | data->mac_addrs = eth_addr; |
| 1524 | *eth_addr = base_eth_addr; |
| 1525 | eth_addr->addr_bytes[5] = eth_dev->data->port_id; |
| 1526 | |
| 1527 | /* now put it all together |
| 1528 | * - store queue data in internal, |
| 1529 | * - point eth_dev_data to internals |
| 1530 | * - and point eth_dev structure to new eth_dev_data structure |
| 1531 | */ |
| 1532 | internal = eth_dev->data->dev_private; |
| 1533 | internal->iface_name = rte_malloc_socket(name, strlen(iface_name) + 1, |
| 1534 | 0, numa_node); |
| 1535 | if (internal->iface_name == NULL) |
| 1536 | goto error; |
| 1537 | strcpy(internal->iface_name, iface_name); |
| 1538 | |
| 1539 | data->nb_rx_queues = queues; |
| 1540 | data->nb_tx_queues = queues; |
| 1541 | internal->max_queues = queues; |
| 1542 | internal->vid = -1; |
| 1543 | internal->flags = flags; |
| 1544 | internal->disable_flags = disable_flags; |
| 1545 | data->dev_link = pmd_link; |
| 1546 | data->dev_flags = RTE_ETH_DEV_INTR_LSC | |
| 1547 | RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; |
| 1548 | data->promiscuous = 1; |
| 1549 | data->all_multicast = 1; |
| 1550 | |
| 1551 | eth_dev->dev_ops = &ops; |
| 1552 | eth_dev->rx_queue_count = eth_rx_queue_count; |
| 1553 | |
| 1554 | /* finally assign rx and tx ops */ |
| 1555 | eth_dev->rx_pkt_burst = eth_vhost_rx; |
| 1556 | eth_dev->tx_pkt_burst = eth_vhost_tx; |
| 1557 |
no test coverage detected