1*e32effb1SLoGin use virtio_drivers::transport::Transport; 2*e32effb1SLoGin 3*e32effb1SLoGin use super::transport_pci::PciTransport; 4*e32effb1SLoGin 5*e32effb1SLoGin pub enum VirtIOTransport { 6*e32effb1SLoGin Pci(PciTransport), 7*e32effb1SLoGin } 8*e32effb1SLoGin 9*e32effb1SLoGin impl core::fmt::Debug for VirtIOTransport { 10*e32effb1SLoGin fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 11*e32effb1SLoGin match self { 12*e32effb1SLoGin VirtIOTransport::Pci(_) => write!(f, "VirtIOTransport::Pci"), 13*e32effb1SLoGin } 14*e32effb1SLoGin } 15*e32effb1SLoGin } 16*e32effb1SLoGin 17*e32effb1SLoGin impl Transport for VirtIOTransport { 18*e32effb1SLoGin #[inline(always)] 19*e32effb1SLoGin fn finish_init(&mut self) { 20*e32effb1SLoGin match self { 21*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.finish_init(), 22*e32effb1SLoGin } 23*e32effb1SLoGin } 24*e32effb1SLoGin 25*e32effb1SLoGin #[inline(always)] 26*e32effb1SLoGin fn device_type(&self) -> virtio_drivers::transport::DeviceType { 27*e32effb1SLoGin match self { 28*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.device_type(), 29*e32effb1SLoGin } 30*e32effb1SLoGin } 31*e32effb1SLoGin 32*e32effb1SLoGin #[inline(always)] 33*e32effb1SLoGin fn read_device_features(&mut self) -> u64 { 34*e32effb1SLoGin match self { 35*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.read_device_features(), 36*e32effb1SLoGin } 37*e32effb1SLoGin } 38*e32effb1SLoGin 39*e32effb1SLoGin #[inline(always)] 40*e32effb1SLoGin fn write_driver_features(&mut self, driver_features: u64) { 41*e32effb1SLoGin match self { 42*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.write_driver_features(driver_features), 43*e32effb1SLoGin } 44*e32effb1SLoGin } 45*e32effb1SLoGin 46*e32effb1SLoGin #[inline(always)] 47*e32effb1SLoGin fn max_queue_size(&mut self, queue: u16) -> u32 { 48*e32effb1SLoGin match self { 49*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.max_queue_size(queue), 50*e32effb1SLoGin } 51*e32effb1SLoGin } 52*e32effb1SLoGin 53*e32effb1SLoGin #[inline(always)] 54*e32effb1SLoGin fn notify(&mut self, queue: u16) { 55*e32effb1SLoGin match self { 56*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.notify(queue), 57*e32effb1SLoGin } 58*e32effb1SLoGin } 59*e32effb1SLoGin 60*e32effb1SLoGin #[inline(always)] 61*e32effb1SLoGin fn get_status(&self) -> virtio_drivers::transport::DeviceStatus { 62*e32effb1SLoGin match self { 63*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.get_status(), 64*e32effb1SLoGin } 65*e32effb1SLoGin } 66*e32effb1SLoGin 67*e32effb1SLoGin #[inline(always)] 68*e32effb1SLoGin fn set_status(&mut self, status: virtio_drivers::transport::DeviceStatus) { 69*e32effb1SLoGin match self { 70*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.set_status(status), 71*e32effb1SLoGin } 72*e32effb1SLoGin } 73*e32effb1SLoGin 74*e32effb1SLoGin #[inline(always)] 75*e32effb1SLoGin fn set_guest_page_size(&mut self, guest_page_size: u32) { 76*e32effb1SLoGin match self { 77*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.set_guest_page_size(guest_page_size), 78*e32effb1SLoGin } 79*e32effb1SLoGin } 80*e32effb1SLoGin 81*e32effb1SLoGin #[inline(always)] 82*e32effb1SLoGin fn requires_legacy_layout(&self) -> bool { 83*e32effb1SLoGin match self { 84*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.requires_legacy_layout(), 85*e32effb1SLoGin } 86*e32effb1SLoGin } 87*e32effb1SLoGin 88*e32effb1SLoGin #[inline(always)] 89*e32effb1SLoGin fn queue_set( 90*e32effb1SLoGin &mut self, 91*e32effb1SLoGin queue: u16, 92*e32effb1SLoGin size: u32, 93*e32effb1SLoGin descriptors: virtio_drivers::PhysAddr, 94*e32effb1SLoGin driver_area: virtio_drivers::PhysAddr, 95*e32effb1SLoGin device_area: virtio_drivers::PhysAddr, 96*e32effb1SLoGin ) { 97*e32effb1SLoGin match self { 98*e32effb1SLoGin VirtIOTransport::Pci(transport) => { 99*e32effb1SLoGin transport.queue_set(queue, size, descriptors, driver_area, device_area) 100*e32effb1SLoGin } 101*e32effb1SLoGin } 102*e32effb1SLoGin } 103*e32effb1SLoGin 104*e32effb1SLoGin #[inline(always)] 105*e32effb1SLoGin fn queue_unset(&mut self, queue: u16) { 106*e32effb1SLoGin match self { 107*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.queue_unset(queue), 108*e32effb1SLoGin } 109*e32effb1SLoGin } 110*e32effb1SLoGin 111*e32effb1SLoGin #[inline(always)] 112*e32effb1SLoGin fn queue_used(&mut self, queue: u16) -> bool { 113*e32effb1SLoGin match self { 114*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.queue_used(queue), 115*e32effb1SLoGin } 116*e32effb1SLoGin } 117*e32effb1SLoGin 118*e32effb1SLoGin #[inline(always)] 119*e32effb1SLoGin fn ack_interrupt(&mut self) -> bool { 120*e32effb1SLoGin match self { 121*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.ack_interrupt(), 122*e32effb1SLoGin } 123*e32effb1SLoGin } 124*e32effb1SLoGin 125*e32effb1SLoGin #[inline(always)] 126*e32effb1SLoGin fn config_space<T: 'static>(&self) -> virtio_drivers::Result<core::ptr::NonNull<T>> { 127*e32effb1SLoGin match self { 128*e32effb1SLoGin VirtIOTransport::Pci(transport) => transport.config_space(), 129*e32effb1SLoGin } 130*e32effb1SLoGin } 131*e32effb1SLoGin } 132