Skip to content

Commit

Permalink
fix calculation of the queue size
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Aug 14, 2023
1 parent d83c9a9 commit d854eba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions src/drivers/net/virtio_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl RxQueues {
// as many packages as possible inside the queue.
let buff_def = [
Bytes::new(mem::size_of::<VirtioNetHdr>()).unwrap(),
Bytes::new(65550 + ETHERNET_HEADER_LEN).unwrap(),
Bytes::new(65550).unwrap(),
];

let spec = if dev_cfg
Expand All @@ -218,10 +218,7 @@ impl RxQueues {
{
BuffSpec::Indirect(&buff_def)
} else {
BuffSpec::Single(
Bytes::new(mem::size_of::<VirtioNetHdr>() + 65550 + ETHERNET_HEADER_LEN)
.unwrap(),
)
BuffSpec::Single(Bytes::new(mem::size_of::<VirtioNetHdr>() + 65550).unwrap())
};

let num_buff: u16 = vq.size().into();
Expand Down Expand Up @@ -408,9 +405,7 @@ impl TxQueues {
// Header and data are added as ONE output descriptor to the transmitvq.
// Hence we are interpreting this, as the fact, that send packets must be inside a single descriptor.
// As usize is currently safe as the minimal usize is defined as 16bit in rust.
let buff_def =
Bytes::new(mem::size_of::<VirtioNetHdr>() + 65550 + ETHERNET_HEADER_LEN)
.unwrap();
let buff_def = Bytes::new(mem::size_of::<VirtioNetHdr>() + 65550).unwrap();
let spec = BuffSpec::Single(buff_def);

let num_buff: u16 = vq.size().into();
Expand Down

0 comments on commit d854eba

Please sign in to comment.