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

Function vtpci_init

dpdk/drivers/net/virtio/virtio_pci.c:658–698  ·  view source on GitHub ↗

* Return -1: * if there is error mapping with VFIO/UIO. * if port map error when driver type is KDRV_NONE. * if marked as allowed but driver type is KDRV_UNKNOWN. * Return 1 if kernel driver is managing the device. * Return 0 on success. */

Source from the content-addressed store, hash-verified

656 * Return 0 on success.
657 */
658int
659vtpci_init(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev)
660{
661 struct virtio_hw *hw = &dev->hw;
662
663 RTE_BUILD_BUG_ON(offsetof(struct virtio_pci_dev, hw) != 0);
664
665 /*
666 * Try if we can succeed reading virtio pci caps, which exists
667 * only on modern pci device. If failed, we fallback to legacy
668 * virtio handling.
669 */
670 if (virtio_read_caps(pci_dev, hw) == 0) {
671 PMD_INIT_LOG(INFO, "modern virtio pci detected.");
672 VIRTIO_OPS(hw) = &modern_ops;
673 dev->modern = true;
674 goto msix_detect;
675 }
676
677 PMD_INIT_LOG(INFO, "trying with legacy virtio pci.");
678 if (rte_pci_ioport_map(pci_dev, 0, VTPCI_IO(hw)) < 0) {
679 rte_pci_unmap_device(pci_dev);
680 if (pci_dev->kdrv == RTE_PCI_KDRV_UNKNOWN &&
681 (!pci_dev->device.devargs ||
682 pci_dev->device.devargs->bus !=
683 rte_bus_find_by_name("pci"))) {
684 PMD_INIT_LOG(INFO,
685 "skip kernel managed virtio device.");
686 return 1;
687 }
688 return -1;
689 }
690
691 VIRTIO_OPS(hw) = &legacy_ops;
692 dev->modern = false;
693
694msix_detect:
695 VIRTIO_OPS(hw)->intr_detect(hw);
696
697 return 0;
698}
699
700void vtpci_legacy_ioport_unmap(struct virtio_hw *hw)
701{

Callers 1

eth_virtio_pci_initFunction · 0.85

Calls 4

rte_bus_find_by_nameFunction · 0.85
virtio_read_capsFunction · 0.70
rte_pci_ioport_mapFunction · 0.50
rte_pci_unmap_deviceFunction · 0.50

Tested by

no test coverage detected