Skip to content

Commit

Permalink
Replace frame number with bool value
Browse files Browse the repository at this point in the history
  • Loading branch information
BaderSZ authored and jounathaen committed Feb 19, 2024
1 parent c15d50c commit abe8633
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/linux/virtio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,8 @@ impl VirtioNetPciDevice {
);

match write_packet(&poll_rx_queue, &mut frame_queue, &mmap) {
Ok(sent) => {
// TODO: replace Ok(usize) with bool (if needs notification)
// trace!("wrote {}/{} received frames to guest memory", sent, l);
if sent > 0 && poll_rx_queue.lock().needs_notification(&mmap).unwrap() {
Ok(data_sent) => {
if data_sent && poll_rx_queue.lock().needs_notification(&mmap).unwrap() {
_delay = time::Instant::now();
alert.store(true, Ordering::Release);
irq_evtfd.write(1).unwrap();
Expand Down Expand Up @@ -609,7 +607,7 @@ fn write_packet(
rx_queue: &Arc<Mutex<Queue>>,
frame_queue: &mut Vec<([u8; UHYVE_NET_MTU], usize)>,
mmap: &GuestMemoryMmap,
) -> Result<usize, VirtIOError> {
) -> Result<bool, VirtIOError> {
let mut queue = rx_queue.lock();

if !queue.is_valid(mmap) {
Expand Down Expand Up @@ -662,7 +660,7 @@ fn write_packet(
});
queue.enable_notification(mmap)?;

Ok(l - frame_queue.len())
Ok(l - frame_queue.len() > 0)
}

fn send_available_packets(
Expand Down

0 comments on commit abe8633

Please sign in to comment.