Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(virtio-net): migrate header to virtio-spec #1202

Merged
merged 9 commits into from
May 16, 2024
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ shell = ["simple-shell"]

[dependencies]
hermit-macro = { path = "hermit-macro" }
virtio-spec = { path = "virtio-spec" }
virtio-spec = { path = "virtio-spec", features = ["zerocopy"] }
ahash = { version = "0.8", default-features = false }
align-address = "0.3"
anstyle = { version = "1", default-features = false }
Expand Down
16 changes: 8 additions & 8 deletions src/drivers/fs/virtio_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use alloc::string::{String, ToString};
use alloc::vec::Vec;

use pci_types::InterruptLine;
use virtio_spec::features::VirtioFsF;

use crate::config::VIRTIO_MAX_QUEUE_SIZE;
#[cfg(feature = "pci")]
Expand All @@ -24,7 +23,7 @@ use crate::fs::fuse::{self, FuseInterface};
pub(crate) struct FsDevCfg {
pub raw: &'static FsDevCfgRaw,
pub dev_id: u16,
pub features: VirtioFsF,
pub features: virtio_spec::fs::F,
}

/// Virtio file system driver struct.
Expand Down Expand Up @@ -55,8 +54,11 @@ impl VirtioFsDriver {

/// Negotiates a subset of features, understood and wanted by both the OS
/// and the device.
fn negotiate_features(&mut self, driver_features: VirtioFsF) -> Result<(), VirtioFsError> {
let device_features = VirtioFsF::from(self.com_cfg.dev_features());
fn negotiate_features(
&mut self,
driver_features: virtio_spec::fs::F,
) -> Result<(), VirtioFsError> {
let device_features = virtio_spec::fs::F::from(self.com_cfg.dev_features());

if device_features.contains(driver_features) {
// If device supports subset of features write feature set to common config
Expand Down Expand Up @@ -85,7 +87,7 @@ impl VirtioFsDriver {
// Indicate device, that driver is able to handle it
self.com_cfg.set_drv();

let features = VirtioFsF::VERSION_1;
let features = virtio_spec::fs::F::VERSION_1;
self.negotiate_features(features)?;

// Indicates the device, that the current feature set is final for the driver
Expand Down Expand Up @@ -161,8 +163,6 @@ impl FuseInterface for VirtioFsDriver {

/// Error module of virtios filesystem driver.
pub mod error {
use virtio_spec::features::VirtioFsF;

/// Network filesystem error enum.
#[derive(Debug, Copy, Clone)]
pub enum VirtioFsError {
Expand All @@ -177,7 +177,7 @@ 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(VirtioFsF, VirtioFsF),
IncompatibleFeatureSets(virtio_spec::fs::F, virtio_spec::fs::F),
Unknown,
}
}
4 changes: 1 addition & 3 deletions src/drivers/fs/virtio_pci.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use alloc::vec::Vec;

use virtio_spec::features::VirtioFsF;

use crate::arch::pci::PciConfigRegion;
use crate::drivers::fs::virtio_fs::{FsDevCfg, VirtioFsDriver};
use crate::drivers::pci::PciDevice;
Expand Down Expand Up @@ -57,7 +55,7 @@ impl VirtioFsDriver {
Some(FsDevCfg {
raw: dev_cfg,
dev_id: cap.dev_id(),
features: VirtioFsF::empty(),
features: virtio_spec::fs::F::empty(),
})
}

Expand Down
3 changes: 1 addition & 2 deletions src/drivers/net/virtio_mmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use core::str::FromStr;
use core::sync::atomic::{fence, Ordering};

use smoltcp::phy::ChecksumCapabilities;
use virtio_spec::features::VirtioNetF;

use crate::drivers::net::virtio_net::constants::Status;
use crate::drivers::net::virtio_net::{CtrlQueue, NetDevCfg, RxQueues, TxQueues, VirtioNetDriver};
Expand Down Expand Up @@ -119,7 +118,7 @@ impl VirtioNetDriver {
let dev_cfg = NetDevCfg {
raw: dev_cfg_raw,
dev_id,
features: VirtioNetF::empty(),
features: virtio_spec::net::F::empty(),
};
let isr_stat = IsrStatus::new(registers);
let notif_cfg = NotifCfg::new(registers);
Expand Down
Loading