Skip to content

Commit

Permalink
Merge pull request #836 from stlankes/mtu
Browse files Browse the repository at this point in the history
move MTU check in the hardware independent part
  • Loading branch information
stlankes authored Aug 13, 2023
2 parents 7753b5b + 93d3092 commit 200a155
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/drivers/net/virtio_mmio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use core::ptr::read_volatile;
use core::str::FromStr;
use core::sync::atomic::{fence, Ordering};

use crate::drivers::net::virtio_net::constants::{FeatureSet, Features, Status};
use crate::drivers::net::virtio_net::constants::{FeatureSet, Status};
use crate::drivers::net::virtio_net::{CtrlQueue, NetDevCfg, RxQueues, TxQueues, VirtioNetDriver};
use crate::drivers::virtio::error::{VirtioError, VirtioNetError};
use crate::drivers::virtio::transport::mmio::{ComCfg, IsrStatus, MmioRegisterLayout, NotifCfg};
Expand Down Expand Up @@ -124,8 +124,6 @@ impl VirtioNetDriver {

let mtu = if let Some(my_mtu) = hermit_var!("HERMIT_MTU") {
u16::from_str(&my_mtu).unwrap() + 14
} else if dev_cfg.features.is_feature(Features::VIRTIO_NET_F_MTU) {
dev_cfg.raw.get_mtu()
} else {
// fallback to the default MTU
1514
Expand Down
4 changes: 4 additions & 0 deletions src/drivers/net/virtio_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,10 @@ impl VirtioNetDriver {
// At this point the device is "live"
self.com_cfg.drv_ok();

if self.dev_cfg.features.is_feature(Features::VIRTIO_NET_F_MTU) {
self.mtu = self.dev_cfg.raw.get_mtu();
}

Ok(())
}

Expand Down
4 changes: 1 addition & 3 deletions src/drivers/net/virtio_pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use core::cell::RefCell;
use core::str::FromStr;

use crate::arch::pci::PciConfigRegion;
use crate::drivers::net::virtio_net::constants::{FeatureSet, Features};
use crate::drivers::net::virtio_net::constants::FeatureSet;
use crate::drivers::net::virtio_net::{CtrlQueue, NetDevCfg, RxQueues, TxQueues, VirtioNetDriver};
use crate::drivers::pci::{PciCommand, PciDevice};
use crate::drivers::virtio::error::{self, VirtioError};
Expand Down Expand Up @@ -133,8 +133,6 @@ impl VirtioNetDriver {

let mtu = if let Some(my_mtu) = hermit_var!("HERMIT_MTU") {
u16::from_str(&my_mtu).unwrap() + 14
} else if dev_cfg.features.is_feature(Features::VIRTIO_NET_F_MTU) {
dev_cfg.raw.get_mtu()
} else {
// fallback to the default MTU
1514
Expand Down

0 comments on commit 200a155

Please sign in to comment.