Lines Matching +full:virtio +full:- +full:pci
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
29 /* Driver for the legacy VirtIO PCI interface. */
44 #include <dev/pci/pcivar.h>
45 #include <dev/pci/pcireg.h>
47 #include <dev/virtio/virtio.h>
48 #include <dev/virtio/virtqueue.h>
49 #include <dev/virtio/pci/virtio_pci.h>
50 #include <dev/virtio/pci/virtio_pci_legacy_var.h>
112 VIRTIO_PCI_CONFIG_OFF(vtpci_is_msix_enabled(&(_sc)->vtpci_common))
115 bus_read_1((sc)->vtpci_res, (o))
117 bus_write_1((sc)->vtpci_res, (o), (v))
119 * VirtIO specifies that PCI Configuration area is guest endian. However,
120 * since PCI devices are inherently little-endian, on big-endian systems
121 * the bus layer transparently converts it to BE. For virtio-legacy, this
125 le16toh(bus_read_2((sc)->vtpci_res, (o)))
127 le32toh(bus_read_4((sc)->vtpci_res, (o)))
129 bus_write_2((sc)->vtpci_res, (o), (htole16(v)))
131 bus_write_4((sc)->vtpci_res, (o), (htole32(v)))
132 /* PCI Header LE. On BE systems the bus layer takes care of byte swapping. */
134 bus_read_2((sc)->vtpci_res, (o))
136 bus_read_4((sc)->vtpci_res, (o))
138 bus_write_2((sc)->vtpci_res, (o), (v))
140 bus_write_4((sc)->vtpci_res, (o), (v))
158 /* VirtIO PCI interface. */
167 /* VirtIO bus interface. */
188 DRIVER_MODULE(virtio_pci_legacy, pci, vtpci_legacy_driver, 0, 0);
209 device_set_descf(dev, "VirtIO PCI (legacy) %s adapter", name); in vtpci_legacy_probe()
211 /* Prefer transitional modern VirtIO PCI. */ in vtpci_legacy_probe()
222 sc->vtpci_dev = dev; in vtpci_legacy_attach()
223 vtpci_init(&sc->vtpci_common, dev, false); in vtpci_legacy_attach()
231 if (vtpci_is_msix_available(&sc->vtpci_common) && in vtpci_legacy_attach()
233 device_printf(dev, "cannot setup MSI-x resources\n"); in vtpci_legacy_attach()
243 error = vtpci_add_child(&sc->vtpci_common); in vtpci_legacy_attach()
266 error = vtpci_delete_child(&sc->vtpci_common); in vtpci_legacy_detach()
313 vtpci_child_detached(&sc->vtpci_common); in vtpci_legacy_child_detached()
327 cn = &sc->vtpci_common; in vtpci_legacy_read_ivar()
350 cn = &sc->vtpci_common; in vtpci_legacy_write_ivar()
372 features = vtpci_negotiate_features(&sc->vtpci_common, in vtpci_legacy_negotiate_features()
386 return (vtpci_with_feature(&sc->vtpci_common, feature)); in vtpci_legacy_with_feature()
397 cn = &sc->vtpci_common; in vtpci_legacy_alloc_virtqueues()
409 return (vtpci_setup_interrupts(&sc->vtpci_common, type)); in vtpci_legacy_setup_interrupts()
426 cn = &sc->vtpci_common; in vtpci_legacy_reinit()
536 dev = sc->vtpci_dev; in vtpci_legacy_setup_msix()
540 sc->vtpci_msix_table_res = bus_alloc_resource_any( in vtpci_legacy_setup_msix()
542 if (sc->vtpci_msix_table_res == NULL) in vtpci_legacy_setup_msix()
548 sc->vtpci_msix_pba_res = bus_alloc_resource_any( in vtpci_legacy_setup_msix()
550 if (sc->vtpci_msix_pba_res == NULL) in vtpci_legacy_setup_msix()
562 dev = sc->vtpci_dev; in vtpci_legacy_teardown_msix()
564 if (sc->vtpci_msix_pba_res != NULL) { in vtpci_legacy_teardown_msix()
566 rman_get_rid(sc->vtpci_msix_pba_res), in vtpci_legacy_teardown_msix()
567 sc->vtpci_msix_pba_res); in vtpci_legacy_teardown_msix()
568 sc->vtpci_msix_pba_res = NULL; in vtpci_legacy_teardown_msix()
570 if (sc->vtpci_msix_table_res != NULL) { in vtpci_legacy_teardown_msix()
572 rman_get_rid(sc->vtpci_msix_table_res), in vtpci_legacy_teardown_msix()
573 sc->vtpci_msix_table_res); in vtpci_legacy_teardown_msix()
574 sc->vtpci_msix_table_res = NULL; in vtpci_legacy_teardown_msix()
585 dev = sc->vtpci_dev; in vtpci_legacy_alloc_resources()
593 sc->vtpci_res_type = res_types[i]; in vtpci_legacy_alloc_resources()
594 sc->vtpci_res = bus_alloc_resource_any(dev, res_types[i], &rid, in vtpci_legacy_alloc_resources()
596 if (sc->vtpci_res != NULL) in vtpci_legacy_alloc_resources()
599 if (sc->vtpci_res == NULL) in vtpci_legacy_alloc_resources()
610 dev = sc->vtpci_dev; in vtpci_legacy_free_resources()
612 if (sc->vtpci_res != NULL) { in vtpci_legacy_free_resources()
613 bus_release_resource(dev, sc->vtpci_res_type, PCIR_BAR(0), in vtpci_legacy_free_resources()
614 sc->vtpci_res); in vtpci_legacy_free_resources()
615 sc->vtpci_res = NULL; in vtpci_legacy_free_resources()
624 dev = sc->vtpci_dev; in vtpci_legacy_probe_and_attach_child()
625 child = vtpci_child_device(&sc->vtpci_common); in vtpci_legacy_probe_and_attach_child()
653 vector = intr->vti_rid - 1; in vtpci_legacy_register_msix()