diff --git a/Cargo.toml b/Cargo.toml index f2a0aafb24..f67bc36c1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,7 +73,7 @@ idle-poll = [] [dependencies] hermit-macro = { path = "hermit-macro" } -virtio-spec = { path = "virtio-spec", features = ["zerocopy"] } +virtio = { package = "virtio-spec", path = "virtio-spec", features = ["zerocopy"] } ahash = { version = "0.8", default-features = false } align-address = "0.3" anstyle = { version = "1", default-features = false } diff --git a/src/arch/riscv64/kernel/devicetree.rs b/src/arch/riscv64/kernel/devicetree.rs index 2905f3cb8a..d0a42c9d9c 100644 --- a/src/arch/riscv64/kernel/devicetree.rs +++ b/src/arch/riscv64/kernel/devicetree.rs @@ -3,7 +3,7 @@ use core::ptr::NonNull; use fdt::Fdt; #[cfg(all(feature = "tcp", not(feature = "pci")))] -use virtio_spec::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters}; +use virtio::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters}; #[cfg(all(feature = "tcp", not(feature = "pci")))] use volatile::VolatileRef; @@ -209,7 +209,7 @@ pub fn init_drivers() { // Verify the device-ID to find the network card let id = mmio.as_ptr().device_id().read(); - if id != virtio_spec::Id::Net { + if id != virtio::Id::Net { debug!("It's not a network card at {mmio:p}"); } else { info!("Found network card at {mmio:p}"); diff --git a/src/arch/x86_64/kernel/mmio.rs b/src/arch/x86_64/kernel/mmio.rs index 5dd28bcdc6..510e9d44f0 100644 --- a/src/arch/x86_64/kernel/mmio.rs +++ b/src/arch/x86_64/kernel/mmio.rs @@ -5,7 +5,7 @@ use core::{ptr, str}; use align_address::Align; use hermit_sync::{without_interrupts, InterruptTicketMutex}; -use virtio_spec::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters}; +use virtio::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters}; use volatile::VolatileRef; use crate::arch::x86_64::mm::paging::{ @@ -62,7 +62,7 @@ unsafe fn check_ptr(ptr: *mut u8) -> Option Result<(), VirtioFsError> { - let device_features = virtio_spec::fs::F::from(self.com_cfg.dev_features()); + fn negotiate_features(&mut self, driver_features: virtio::fs::F) -> Result<(), VirtioFsError> { + let device_features = virtio::fs::F::from(self.com_cfg.dev_features()); if device_features.requirements_satisfied() { debug!("Feature set wanted by filesystem driver are in conformance with specification.") @@ -95,7 +92,7 @@ impl VirtioFsDriver { // Indicate device, that driver is able to handle it self.com_cfg.set_drv(); - let features = virtio_spec::fs::F::VERSION_1; + let features = virtio::fs::F::VERSION_1; self.negotiate_features(features)?; // Indicates the device, that the current feature set is final for the driver @@ -183,10 +180,10 @@ pub mod error { FailFeatureNeg(u16), /// The first field contains the feature bits wanted by the driver. /// but which are incompatible with the device feature set, second field. - IncompatibleFeatureSets(virtio_spec::fs::F, virtio_spec::fs::F), + IncompatibleFeatureSets(virtio::fs::F, virtio::fs::F), /// Set of features does not adhere to the requirements of features /// indicated by the specification - FeatureRequirementsNotMet(virtio_spec::fs::F), + FeatureRequirementsNotMet(virtio::fs::F), Unknown, } } diff --git a/src/drivers/fs/virtio_pci.rs b/src/drivers/fs/virtio_pci.rs index 7f4af03d7d..3f297a1a93 100644 --- a/src/drivers/fs/virtio_pci.rs +++ b/src/drivers/fs/virtio_pci.rs @@ -55,7 +55,7 @@ impl VirtioFsDriver { Some(FsDevCfg { raw: dev_cfg, dev_id: cap.dev_id(), - features: virtio_spec::fs::F::empty(), + features: virtio::fs::F::empty(), }) } diff --git a/src/drivers/net/virtio/mmio.rs b/src/drivers/net/virtio/mmio.rs index d47e35de26..5a14f54eac 100644 --- a/src/drivers/net/virtio/mmio.rs +++ b/src/drivers/net/virtio/mmio.rs @@ -7,7 +7,7 @@ use alloc::vec::Vec; use core::str::FromStr; use smoltcp::phy::ChecksumCapabilities; -use virtio_spec::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters}; +use virtio::mmio::{DeviceRegisterVolatileFieldAccess, DeviceRegisters}; use volatile::VolatileRef; use crate::drivers::net::virtio::{CtrlQueue, NetDevCfg, RxQueues, TxQueues, VirtioNetDriver}; @@ -22,20 +22,20 @@ impl VirtioNetDriver { mut registers: VolatileRef<'static, DeviceRegisters>, irq: u8, ) -> Result { - let dev_cfg_raw: &'static virtio_spec::net::Config = unsafe { + let dev_cfg_raw: &'static virtio::net::Config = unsafe { &*registers .borrow_mut() .as_mut_ptr() .config() .as_raw_ptr() - .cast::() + .cast::() .as_ptr() }; let dev_cfg_raw = VolatileRef::from_ref(dev_cfg_raw); let dev_cfg = NetDevCfg { raw: dev_cfg_raw, dev_id, - features: virtio_spec::net::F::empty(), + features: virtio::net::F::empty(), }; let isr_stat = IsrStatus::new(registers.borrow_mut()); let notif_cfg = NotifCfg::new(registers.borrow_mut()); @@ -64,7 +64,7 @@ impl VirtioNetDriver { pub fn print_information(&mut self) { self.com_cfg.print_information(); - if self.dev_status() == virtio_spec::net::S::LINK_UP { + if self.dev_status() == virtio::net::S::LINK_UP { info!("The link of the network device is up!"); } } diff --git a/src/drivers/net/virtio/mod.rs b/src/drivers/net/virtio/mod.rs index 1e8f776198..d50eebd0cc 100644 --- a/src/drivers/net/virtio/mod.rs +++ b/src/drivers/net/virtio/mod.rs @@ -20,8 +20,8 @@ use align_address::Align; use pci_types::InterruptLine; use smoltcp::phy::{Checksum, ChecksumCapabilities}; use smoltcp::wire::{EthernetFrame, Ipv4Packet, Ipv6Packet, ETHERNET_HEADER_LEN}; -use virtio_spec::net::{ConfigVolatileFieldAccess, Hdr, HdrF}; -use virtio_spec::FeatureBits; +use virtio::net::{ConfigVolatileFieldAccess, Hdr, HdrF}; +use virtio::FeatureBits; use volatile::access::ReadOnly; use volatile::VolatileRef; @@ -44,9 +44,9 @@ use crate::executor::device::{RxToken, TxToken}; /// Handling the right access to fields, as some are read-only /// for the driver. pub(crate) struct NetDevCfg { - pub raw: VolatileRef<'static, virtio_spec::net::Config, ReadOnly>, + pub raw: VolatileRef<'static, virtio::net::Config, ReadOnly>, pub dev_id: u16, - pub features: virtio_spec::net::F, + pub features: virtio::net::F, } pub struct CtrlQueue(Option>); @@ -156,7 +156,7 @@ impl RxQueues { fn add(&mut self, vq: Rc, dev_cfg: &NetDevCfg) { let num_buff: u16 = vq.size().into(); - let rx_size = if dev_cfg.features.contains(virtio_spec::net::F::MRG_RXBUF) { + let rx_size = if dev_cfg.features.contains(virtio::net::F::MRG_RXBUF) { (1514 + mem::size_of::()) .align_up(core::mem::size_of::>()) } else { @@ -297,9 +297,9 @@ impl TxQueues { // Unwrapping is safe, as one virtq will be definitely in the vector. let vq = self.vqs.first().unwrap(); - if dev_cfg.features.contains(virtio_spec::net::F::GUEST_TSO4) - | dev_cfg.features.contains(virtio_spec::net::F::GUEST_TSO6) - | dev_cfg.features.contains(virtio_spec::net::F::GUEST_UFO) + if dev_cfg.features.contains(virtio::net::F::GUEST_TSO4) + | dev_cfg.features.contains(virtio::net::F::GUEST_TSO6) + | dev_cfg.features.contains(virtio::net::F::GUEST_UFO) { // Virtio specification v1.1. - 5.1.6.2 point 5. // Header and data are added as ONE output descriptor to the transmitvq. @@ -428,7 +428,7 @@ impl NetworkDriver for VirtioNetDriver { /// Returns the mac address of the device. /// If VIRTIO_NET_F_MAC is not set, the function panics currently! fn get_mac_address(&self) -> [u8; 6] { - if self.dev_cfg.features.contains(virtio_spec::net::F::MAC) { + if self.dev_cfg.features.contains(virtio::net::F::MAC) { loop { let before = self.com_cfg.config_generation(); let mac = self.dev_cfg.raw.as_ptr().mac().read(); @@ -652,11 +652,11 @@ impl VirtioNetDriver { /// Returns the current status of the device, if VIRTIO_NET_F_STATUS /// has been negotiated. Otherwise assumes an active device. #[cfg(not(feature = "pci"))] - pub fn dev_status(&self) -> virtio_spec::net::S { - if self.dev_cfg.features.contains(virtio_spec::net::F::STATUS) { + pub fn dev_status(&self) -> virtio::net::S { + if self.dev_cfg.features.contains(virtio::net::F::STATUS) { self.dev_cfg.raw.as_ptr().status().read() } else { - virtio_spec::net::S::LINK_UP + virtio::net::S::LINK_UP } } @@ -664,13 +664,13 @@ impl VirtioNetDriver { /// If feature VIRTIO_NET_F_STATUS has not been negotiated, then we assume the link is up! #[cfg(feature = "pci")] pub fn is_link_up(&self) -> bool { - if self.dev_cfg.features.contains(virtio_spec::net::F::STATUS) { + if self.dev_cfg.features.contains(virtio::net::F::STATUS) { self.dev_cfg .raw .as_ptr() .status() .read() - .contains(virtio_spec::net::S::LINK_UP) + .contains(virtio::net::S::LINK_UP) } else { true } @@ -678,13 +678,13 @@ impl VirtioNetDriver { #[allow(dead_code)] pub fn is_announce(&self) -> bool { - if self.dev_cfg.features.contains(virtio_spec::net::F::STATUS) { + if self.dev_cfg.features.contains(virtio::net::F::STATUS) { self.dev_cfg .raw .as_ptr() .status() .read() - .contains(virtio_spec::net::S::ANNOUNCE) + .contains(virtio::net::S::ANNOUNCE) } else { false } @@ -697,7 +697,7 @@ impl VirtioNetDriver { /// Returns 1 (i.e. minimum number of pairs) if VIRTIO_NET_F_MQ is not set. #[allow(dead_code)] pub fn get_max_vq_pairs(&self) -> u16 { - if self.dev_cfg.features.contains(virtio_spec::net::F::MQ) { + if self.dev_cfg.features.contains(virtio::net::F::MQ) { self.dev_cfg .raw .as_ptr() @@ -736,34 +736,34 @@ impl VirtioNetDriver { // Indicate device, that driver is able to handle it self.com_cfg.set_drv(); - let minimal_features = virtio_spec::net::F::VERSION_1 | virtio_spec::net::F::MAC; + let minimal_features = virtio::net::F::VERSION_1 | virtio::net::F::MAC; // If wanted, push new features into feats here: let mut features = minimal_features // Indirect descriptors can be used - | virtio_spec::net::F::INDIRECT_DESC + | virtio::net::F::INDIRECT_DESC // Packed Vq can be used - | virtio_spec::net::F::RING_PACKED - | virtio_spec::net::F::NOTIFICATION_DATA + | virtio::net::F::RING_PACKED + | virtio::net::F::NOTIFICATION_DATA // Host should avoid the creation of checksums - | virtio_spec::net::F::CSUM + | virtio::net::F::CSUM // Guest avoids the creation of checksums - | virtio_spec::net::F::GUEST_CSUM + | virtio::net::F::GUEST_CSUM // MTU setting can be used - | virtio_spec::net::F::MTU + | virtio::net::F::MTU // Driver can merge receive buffers - | virtio_spec::net::F::MRG_RXBUF + | virtio::net::F::MRG_RXBUF // the link status can be announced - | virtio_spec::net::F::STATUS + | virtio::net::F::STATUS // Multiqueue support - | virtio_spec::net::F::MQ; + | virtio::net::F::MQ; // Currently the driver does NOT support the features below. // In order to provide functionality for these, the driver // needs to take care of calculating checksum in // RxQueues.post_processing() - // | virtio_spec::net::F::GUEST_TSO4 - // | virtio_spec::net::F::GUEST_TSO6 + // | virtio::net::F::GUEST_TSO4 + // | virtio::net::F::GUEST_TSO6 // Negotiate features with device. Automatically reduces selected feats in order to meet device capabilities. // Aborts in case incompatible features are selected by the driver or the device does not support min_feat_set. @@ -844,28 +844,21 @@ impl VirtioNetDriver { // At this point the device is "live" self.com_cfg.drv_ok(); - if self.dev_cfg.features.contains(virtio_spec::net::F::CSUM) - && self - .dev_cfg - .features - .contains(virtio_spec::net::F::GUEST_CSUM) + if self.dev_cfg.features.contains(virtio::net::F::CSUM) + && self.dev_cfg.features.contains(virtio::net::F::GUEST_CSUM) { self.checksums.udp = Checksum::None; self.checksums.tcp = Checksum::None; - } else if self.dev_cfg.features.contains(virtio_spec::net::F::CSUM) { + } else if self.dev_cfg.features.contains(virtio::net::F::CSUM) { self.checksums.udp = Checksum::Rx; self.checksums.tcp = Checksum::Rx; - } else if self - .dev_cfg - .features - .contains(virtio_spec::net::F::GUEST_CSUM) - { + } else if self.dev_cfg.features.contains(virtio::net::F::GUEST_CSUM) { self.checksums.udp = Checksum::Tx; self.checksums.tcp = Checksum::Tx; } debug!("{:?}", self.checksums); - if self.dev_cfg.features.contains(virtio_spec::net::F::MTU) { + if self.dev_cfg.features.contains(virtio::net::F::MTU) { self.mtu = self.dev_cfg.raw.as_ptr().mtu().read().to_ne(); } @@ -876,9 +869,9 @@ impl VirtioNetDriver { /// and the device. fn negotiate_features( &mut self, - driver_features: virtio_spec::net::F, + driver_features: virtio::net::F, ) -> Result<(), VirtioNetError> { - let device_features = virtio_spec::net::F::from(self.com_cfg.dev_features()); + let device_features = virtio::net::F::from(self.com_cfg.dev_features()); if device_features.requirements_satisfied() { info!("Feature set wanted by network driver are in conformance with specification."); @@ -906,12 +899,8 @@ impl VirtioNetDriver { } // Add a control if feature is negotiated - if self.dev_cfg.features.contains(virtio_spec::net::F::CTRL_VQ) { - if self - .dev_cfg - .features - .contains(virtio_spec::net::F::RING_PACKED) - { + if self.dev_cfg.features.contains(virtio::net::F::CTRL_VQ) { + if self.dev_cfg.features.contains(virtio::net::F::RING_PACKED) { self.ctrl_vq = CtrlQueue(Some(Rc::new( PackedVq::new( &mut self.com_cfg, @@ -951,7 +940,7 @@ impl VirtioNetDriver { // - the plus 1 is due to the possibility of an existing control queue // - the num_queues is found in the ComCfg struct of the device and defines the maximal number // of supported queues. - if self.dev_cfg.features.contains(virtio_spec::net::F::MQ) { + if self.dev_cfg.features.contains(virtio::net::F::MQ) { if self .dev_cfg .raw @@ -987,11 +976,7 @@ impl VirtioNetDriver { assert_eq!(self.num_vqs % 2, 0); for i in 0..(self.num_vqs / 2) { - if self - .dev_cfg - .features - .contains(virtio_spec::net::F::RING_PACKED) - { + if self.dev_cfg.features.contains(virtio::net::F::RING_PACKED) { let vq = PackedVq::new( &mut self.com_cfg, &self.notif_cfg, @@ -1072,9 +1057,9 @@ pub mod error { FailFeatureNeg(u16), /// Set of features does not adhere to the requirements of features /// indicated by the specification - FeatureRequirementsNotMet(virtio_spec::net::F), + FeatureRequirementsNotMet(virtio::net::F), /// The first field contains the feature bits wanted by the driver. /// but which are incompatible with the device feature set, second field. - IncompatibleFeatureSets(virtio_spec::net::F, virtio_spec::net::F), + IncompatibleFeatureSets(virtio::net::F, virtio::net::F), } } diff --git a/src/drivers/net/virtio/pci.rs b/src/drivers/net/virtio/pci.rs index 55d18fe4c4..88271f6bb9 100644 --- a/src/drivers/net/virtio/pci.rs +++ b/src/drivers/net/virtio/pci.rs @@ -19,8 +19,8 @@ use crate::drivers::virtio::transport::pci::{PciCap, UniCapsColl}; // Backend-dependent interface for Virtio network driver impl VirtioNetDriver { fn map_cfg(cap: &PciCap) -> Option { - let dev_cfg: &'static virtio_spec::net::Config = - match pci::map_dev_cfg::(cap) { + let dev_cfg: &'static virtio::net::Config = + match pci::map_dev_cfg::(cap) { Some(cfg) => cfg, None => return None, }; @@ -30,7 +30,7 @@ impl VirtioNetDriver { Some(NetDevCfg { raw: dev_cfg, dev_id: cap.dev_id(), - features: virtio_spec::net::F::empty(), + features: virtio::net::F::empty(), }) } diff --git a/src/drivers/virtio/transport/mmio.rs b/src/drivers/virtio/transport/mmio.rs index b842f517f7..1344e392ef 100644 --- a/src/drivers/virtio/transport/mmio.rs +++ b/src/drivers/virtio/transport/mmio.rs @@ -5,11 +5,11 @@ use core::mem; -use virtio_spec::mmio::{ +use virtio::mmio::{ DeviceRegisterVolatileFieldAccess, DeviceRegisterVolatileWideFieldAccess, DeviceRegisters, InterruptStatus, NotificationData, }; -use virtio_spec::{le32, DeviceStatus}; +use virtio::{le32, DeviceStatus}; use volatile::VolatileRef; #[cfg(any(feature = "tcp", feature = "udp"))] @@ -201,7 +201,7 @@ impl ComCfg { } /// Returns the features offered by the device. - pub fn dev_features(&mut self) -> virtio_spec::F { + pub fn dev_features(&mut self) -> virtio::F { let ptr = self.com_cfg.as_mut_ptr(); // Indicate device to show high 32 bits in device_feature field. @@ -218,11 +218,11 @@ impl ComCfg { // read low 32 bits of device features device_features |= u64::from(ptr.device_features().read().to_ne()); - virtio_spec::F::from_bits_retain(u128::from(device_features).into()) + virtio::F::from_bits_retain(u128::from(device_features).into()) } /// Write selected features into driver_select field. - pub fn set_drv_features(&mut self, features: virtio_spec::F) { + pub fn set_drv_features(&mut self, features: virtio::F) { let ptr = self.com_cfg.as_mut_ptr(); let features = features.bits().to_ne() as u64; @@ -385,7 +385,7 @@ pub(crate) fn init_device( // Verify the device-ID to find the network card match registers.as_ptr().device_id().read() { #[cfg(any(feature = "tcp", feature = "udp"))] - virtio_spec::Id::Net => { + virtio::Id::Net => { match VirtioNetDriver::init(dev_id, registers, irq_no) { Ok(virt_net_drv) => { info!("Virtio network driver initialized."); diff --git a/src/drivers/virtio/transport/pci.rs b/src/drivers/virtio/transport/pci.rs index 2499b565d5..e4ca160d38 100644 --- a/src/drivers/virtio/transport/pci.rs +++ b/src/drivers/virtio/transport/pci.rs @@ -8,11 +8,11 @@ use core::ptr::NonNull; use core::{mem, ptr}; use pci_types::capability::PciCapability; -use virtio_spec::pci::{ +use virtio::pci::{ CapCfgType, CapData, CommonCfg, CommonCfgVolatileFieldAccess, CommonCfgVolatileWideFieldAccess, IsrStatus as IsrStatusRaw, NotificationData, }; -use virtio_spec::{le16, le32, DeviceStatus}; +use virtio::{le16, le32, DeviceStatus}; use volatile::VolatileRef; #[cfg(all(not(feature = "rtl8139"), any(feature = "tcp", feature = "udp")))] @@ -452,7 +452,7 @@ impl ComCfg { } /// Returns the features offered by the device. - pub fn dev_features(&mut self) -> virtio_spec::F { + pub fn dev_features(&mut self) -> virtio::F { let com_cfg = self.com_cfg.as_mut_ptr(); let device_feature_select = com_cfg.device_feature_select(); let device_feature = com_cfg.device_feature(); @@ -474,11 +474,11 @@ impl ComCfg { // read low 32 bits of device features device_features |= u64::from(device_feature.read().to_ne()); - virtio_spec::F::from_bits_retain(u128::from(device_features).into()) + virtio::F::from_bits_retain(u128::from(device_features).into()) } /// Write selected features into driver_select field. - pub fn set_drv_features(&mut self, features: virtio_spec::F) { + pub fn set_drv_features(&mut self, features: virtio::F) { let features = features.bits().to_ne() as u64; let com_cfg = self.com_cfg.as_mut_ptr(); let driver_feature_select = com_cfg.driver_feature_select(); @@ -903,11 +903,11 @@ pub(crate) fn init_device( )); } - let id = virtio_spec::Id::from(u8::try_from(device_id - 0x1040).unwrap()); + let id = virtio::Id::from(u8::try_from(device_id - 0x1040).unwrap()); let virt_drv = match id { #[cfg(all(not(feature = "rtl8139"), any(feature = "tcp", feature = "udp")))] - virtio_spec::Id::Net => match VirtioNetDriver::init(device) { + virtio::Id::Net => match VirtioNetDriver::init(device) { Ok(virt_net_drv) => { info!("Virtio network driver initialized."); Ok(VirtioDriver::Network(virt_net_drv)) @@ -921,7 +921,7 @@ pub(crate) fn init_device( } }, #[cfg(feature = "fuse")] - virtio_spec::Id::Fs => { + virtio::Id::Fs => { // TODO: check subclass // TODO: proper error handling on driver creation fail match VirtioFsDriver::init(device) { diff --git a/src/drivers/virtio/virtqueue/mod.rs b/src/drivers/virtio/virtqueue/mod.rs index f2146d4157..285cf3fe73 100644 --- a/src/drivers/virtio/virtqueue/mod.rs +++ b/src/drivers/virtio/virtqueue/mod.rs @@ -171,7 +171,7 @@ pub trait Virtq: VirtqPrivate { notif_cfg: &NotifCfg, size: VqSize, index: VqIndex, - features: virtio_spec::F, + features: virtio::F, ) -> Result where Self: Sized; @@ -2590,7 +2590,7 @@ pub mod error { /// referring to). BufferToLarge, QueueSizeNotAllowed(u16), - FeatureNotSupported(virtio_spec::F), + FeatureNotSupported(virtio::F), AllocationError, } diff --git a/src/drivers/virtio/virtqueue/packed.rs b/src/drivers/virtio/virtqueue/packed.rs index 5eedb75a36..31d2765542 100644 --- a/src/drivers/virtio/virtqueue/packed.rs +++ b/src/drivers/virtio/virtqueue/packed.rs @@ -1028,7 +1028,7 @@ impl Virtq for PackedVq { notif_cfg: &NotifCfg, size: VqSize, index: VqIndex, - features: virtio_spec::F, + features: virtio::F, ) -> Result { // Currently we do not have support for in order use. // This steems from the fact, that the packedVq ReadCtrl currently is not @@ -1037,9 +1037,9 @@ impl Virtq for PackedVq { // TransferTokens are inserted into the queue. Furthermore the Queue should // carry a feature u64 in order to check which features are used currently // and adjust its ReadCtrl accordingly. - if features.contains(virtio_spec::F::IN_ORDER) { + if features.contains(virtio::F::IN_ORDER) { info!("PackedVq has no support for VIRTIO_F_IN_ORDER. Aborting..."); - return Err(VirtqError::FeatureNotSupported(virtio_spec::F::IN_ORDER)); + return Err(VirtqError::FeatureNotSupported(virtio::F::IN_ORDER)); } // Get a handler to the queues configuration area. @@ -1091,11 +1091,11 @@ impl Virtq for PackedVq { let mut notif_ctrl = NotifCtrl::new(notif_cfg.notification_location(&mut vq_handler)); - if features.contains(virtio_spec::F::NOTIFICATION_DATA) { + if features.contains(virtio::F::NOTIFICATION_DATA) { notif_ctrl.enable_notif_data(); } - if features.contains(virtio_spec::F::EVENT_IDX) { + if features.contains(virtio::F::EVENT_IDX) { drv_event.borrow_mut().f_notif_idx = true; } diff --git a/src/drivers/virtio/virtqueue/split.rs b/src/drivers/virtio/virtqueue/split.rs index 5cafa70c49..4783f26cea 100644 --- a/src/drivers/virtio/virtqueue/split.rs +++ b/src/drivers/virtio/virtqueue/split.rs @@ -10,7 +10,7 @@ use core::cell::{RefCell, UnsafeCell}; use core::mem::{size_of, MaybeUninit}; use core::ptr::{self, NonNull}; -use virtio_spec::{le16, le32, le64}; +use virtio::{le16, le32, le64}; use volatile::access::ReadOnly; use volatile::{map_field, VolatilePtr, VolatileRef}; @@ -392,7 +392,7 @@ impl Virtq for SplitVq { notif_cfg: &NotifCfg, size: VqSize, index: VqIndex, - features: virtio_spec::F, + features: virtio::F, ) -> Result { // Get a handler to the queues configuration area. let mut vq_handler = match com_cfg.select_vq(index.into()) { @@ -482,7 +482,7 @@ impl Virtq for SplitVq { let mut notif_ctrl = NotifCtrl::new(notif_cfg.notification_location(&mut vq_handler)); - if features.contains(virtio_spec::F::NOTIFICATION_DATA) { + if features.contains(virtio::F::NOTIFICATION_DATA) { notif_ctrl.enable_notif_data(); } diff --git a/virtio-spec/src/features.rs b/virtio-spec/src/features.rs index a0459589b6..ba7488077d 100644 --- a/virtio-spec/src/features.rs +++ b/virtio-spec/src/features.rs @@ -16,15 +16,16 @@ where /// # Examples /// /// ``` - /// use virtio_spec::FeatureBits; + /// # use virtio_spec as virtio; + /// use virtio::FeatureBits; /// /// assert_eq!( - /// virtio_spec::net::F::GUEST_TSO4.requirements(), - /// virtio_spec::net::F::GUEST_CSUM + /// virtio::net::F::GUEST_TSO4.requirements(), + /// virtio::net::F::GUEST_CSUM /// ); /// assert_eq!( - /// virtio_spec::net::F::GUEST_ECN.requirements(), - /// virtio_spec::net::F::GUEST_TSO4 | virtio_spec::net::F::GUEST_TSO6 + /// virtio::net::F::GUEST_ECN.requirements(), + /// virtio::net::F::GUEST_TSO4 | virtio::net::F::GUEST_TSO6 /// ); /// ``` fn requirements(&self) -> Self { @@ -36,14 +37,15 @@ where /// # Examples /// /// ``` - /// use virtio_spec::FeatureBits; + /// # use virtio_spec as virtio; + /// use virtio::FeatureBits; /// - /// assert!((virtio_spec::net::F::GUEST_TSO4 - /// | virtio_spec::net::F::GUEST_CSUM) + /// assert!((virtio::net::F::GUEST_TSO4 + /// | virtio::net::F::GUEST_CSUM) /// .requirements_satisfied()); - /// assert!((virtio_spec::net::F::GUEST_ECN - /// | virtio_spec::net::F::GUEST_TSO4 - /// | virtio_spec::net::F::GUEST_CSUM) + /// assert!((virtio::net::F::GUEST_ECN + /// | virtio::net::F::GUEST_TSO4 + /// | virtio::net::F::GUEST_CSUM) /// .requirements_satisfied()); /// ``` fn requirements_satisfied(&self) -> bool { @@ -208,37 +210,37 @@ macro_rules! feature_bits { const $Flag = $value; )* - /// Device-independent Bit. See [`virtio_spec::F::INDIRECT_DESC`](crate::F::INDIRECT_DESC). + /// Device-independent Bit. See [`virtio::F::INDIRECT_DESC`](crate::F::INDIRECT_DESC). const INDIRECT_DESC = $crate::F::INDIRECT_DESC.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::EVENT_IDX`](crate::F::EVENT_IDX). + /// Device-independent Bit. See [`virtio::F::EVENT_IDX`](crate::F::EVENT_IDX). const EVENT_IDX = $crate::F::EVENT_IDX.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::VERSION_1`](crate::F::VERSION_1). + /// Device-independent Bit. See [`virtio::F::VERSION_1`](crate::F::VERSION_1). const VERSION_1 = $crate::F::VERSION_1.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::ACCESS_PLATFORM`](crate::F::ACCESS_PLATFORM). + /// Device-independent Bit. See [`virtio::F::ACCESS_PLATFORM`](crate::F::ACCESS_PLATFORM). const ACCESS_PLATFORM = $crate::F::ACCESS_PLATFORM.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::RING_PACKED`](crate::F::RING_PACKED). + /// Device-independent Bit. See [`virtio::F::RING_PACKED`](crate::F::RING_PACKED). const RING_PACKED = $crate::F::RING_PACKED.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::IN_ORDER`](crate::F::IN_ORDER). + /// Device-independent Bit. See [`virtio::F::IN_ORDER`](crate::F::IN_ORDER). const IN_ORDER = $crate::F::IN_ORDER.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::ORDER_PLATFORM`](crate::F::ORDER_PLATFORM). + /// Device-independent Bit. See [`virtio::F::ORDER_PLATFORM`](crate::F::ORDER_PLATFORM). const ORDER_PLATFORM = $crate::F::ORDER_PLATFORM.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::SR_IOV`](crate::F::SR_IOV). + /// Device-independent Bit. See [`virtio::F::SR_IOV`](crate::F::SR_IOV). const SR_IOV = $crate::F::SR_IOV.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::NOTIFICATION_DATA`](crate::F::NOTIFICATION_DATA). + /// Device-independent Bit. See [`virtio::F::NOTIFICATION_DATA`](crate::F::NOTIFICATION_DATA). const NOTIFICATION_DATA = $crate::F::NOTIFICATION_DATA.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::NOTIF_CONFIG_DATA`](crate::F::NOTIF_CONFIG_DATA). + /// Device-independent Bit. See [`virtio::F::NOTIF_CONFIG_DATA`](crate::F::NOTIF_CONFIG_DATA). const NOTIF_CONFIG_DATA = $crate::F::NOTIF_CONFIG_DATA.bits().to_ne(); - /// Device-independent Bit. See [`virtio_spec::F::RING_RESET`](crate::F::RING_RESET). + /// Device-independent Bit. See [`virtio::F::RING_RESET`](crate::F::RING_RESET). const RING_RESET = $crate::F::RING_RESET.bits().to_ne(); } }