Skip to content

Commit

Permalink
Merge pull request #1342 from cagatay-y/virtio-net-fill-fix
Browse files Browse the repository at this point in the history
fix(net/virtio): push the correct number of packets to the queue
  • Loading branch information
mkroening authored Jul 31, 2024
2 parents 64860fc + 2a47e49 commit c9a4757
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/drivers/net/virtio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ impl RxQueues {
Ok(())
}

fn fill_queue(&self, vq: Rc<dyn Virtq>, num_buff: u16) {
for _ in 0..num_buff {
fn fill_queue(&self, vq: Rc<dyn Virtq>, num_packets: u16) {
for _ in 0..num_packets {
let buff_tkn = match AvailBufferToken::new(
vec![],
vec![
Expand Down Expand Up @@ -124,8 +124,8 @@ impl RxQueues {
BufferType::Direct,
) {
Ok(_) => (),
Err(_) => {
error!("Descriptor IDs were exhausted earlier than expected.");
Err(err) => {
error!("{:#?}", err);
break;
}
}
Expand All @@ -136,8 +136,9 @@ impl RxQueues {
///
/// Queues are all populated according to Virtio specification v1.1. - 5.1.6.3.1
fn add(&mut self, vq: Rc<dyn Virtq>) {
let num_buff: u16 = vq.size().into();
self.fill_queue(vq.clone(), num_buff);
const BUFF_PER_PACKET: u16 = 2;
let num_packets: u16 = u16::from(vq.size()) / BUFF_PER_PACKET;
self.fill_queue(vq.clone(), num_packets);
self.vqs.push(vq);
if self.vqs.len() > 1 {
self.is_multi = true;
Expand Down

0 comments on commit c9a4757

Please sign in to comment.