return 0;
}
-
-static void
-virtio_set_vtpci_ops(struct virtio_hw *hw)
-{
-#ifdef RTE_VIRTIO_USER
- if (hw->bus_type == VIRTIO_BUS_USER)
- VTPCI_OPS(hw) = &virtio_user_ops;
- else
-#endif
- if (hw->bus_type == VIRTIO_BUS_PCI_MODERN)
- VTPCI_OPS(hw) = &modern_ops;
- else if (hw->bus_type == VIRTIO_BUS_PCI_LEGACY)
- VTPCI_OPS(hw) = &legacy_ops;
-
- return;
-}
-
/*
* This function is based on probe() function in virtio_pci.c
* It returns 0 on success.
eth_dev->rx_descriptor_done = virtio_dev_rx_queue_done;
if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
- virtio_set_vtpci_ops(hw);
set_rxtx_funcs(eth_dev);
return 0;
}
if (virtio_read_caps(pci_dev, hw) == 0) {
PMD_INIT_LOG(INFO, "modern virtio pci detected.");
virtio_hw_internal[hw->port_id].vtpci_ops = &modern_ops;
- hw->bus_type = VIRTIO_BUS_PCI_MODERN;
dev->modern = true;
goto msix_detect;
}
}
virtio_hw_internal[hw->port_id].vtpci_ops = &legacy_ops;
- hw->bus_type = VIRTIO_BUS_PCI_LEGACY;
dev->modern = false;
msix_detect:
struct virtio_net_config;
-enum virtio_bus_type {
- VIRTIO_BUS_UNKNOWN,
- VIRTIO_BUS_PCI_LEGACY,
- VIRTIO_BUS_PCI_MODERN,
- VIRTIO_BUS_USER,
-};
-
struct virtio_hw {
- enum virtio_bus_type bus_type;
struct virtnet_ctl *cvq;
uint64_t req_guest_features;
uint64_t guest_features;
return -1;
}
} else {
+ if (dev->modern)
+ VTPCI_OPS(hw) = &modern_ops;
+ else
+ VTPCI_OPS(hw) = &legacy_ops;
+
ret = virtio_remap_pci(RTE_ETH_DEV_TO_PCI(eth_dev), dev);
if (ret < 0) {
PMD_INIT_LOG(ERR, "Failed to remap PCI device\n");
err_unmap:
rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));
- if (hw->bus_type == VIRTIO_BUS_PCI_LEGACY)
+ if (!dev->modern)
rte_pci_ioport_unmap(VTPCI_IO(hw));
return ret;
* Here just pretend that we support msix.
*/
hw->use_msix = 1;
- hw->bus_type = VIRTIO_BUS_USER;
hw->use_vec_rx = 0;
hw->use_vec_tx = 0;
hw->use_inorder_rx = 0;
return -1;
}
+ dev = eth_dev->data->dev_private;
+ hw = &dev->hw;
+ VTPCI_OPS(hw) = &virtio_user_ops;
+
if (eth_virtio_dev_init(eth_dev) < 0) {
PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails");
rte_eth_dev_release_port(eth_dev);