Skip to content

Commit fa8f751

Browse files
committed
refactor(net): more descriptive queue notifications method
Rename `signal_used_queue` to `try_signal_queue`. Add a description for the `try_signal_queue` method. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent dc86e91 commit fa8f751

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/vmm/src/devices/virtio/net/device.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ impl Net {
264264
&self.tx_rate_limiter
265265
}
266266

267-
fn signal_used_queue(&mut self, queue_type: NetQueue) -> Result<(), DeviceError> {
267+
/// Trigger queue notification for the guest if we used enough descriptors
268+
/// for the notification to be enabled.
269+
/// https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html#x1-320005
270+
/// 2.6.7.1 Driver Requirements: Used Buffer Notification Suppression
271+
fn try_signal_queue(&mut self, queue_type: NetQueue) -> Result<(), DeviceError> {
268272
// This is safe since we checked in the event handler that the device is activated.
269273
let mem = self.device_state.mem().unwrap();
270274

@@ -552,9 +556,7 @@ impl Net {
552556
}
553557
}
554558

555-
// At this point we processed as many Rx frames as possible.
556-
// We have to wake the guest if at least one descriptor chain has been used.
557-
self.signal_used_queue(NetQueue::Rx)
559+
self.try_signal_queue(NetQueue::Rx)
558560
}
559561

560562
// Process the deferred frame first, then continue reading from tap.
@@ -566,7 +568,7 @@ impl Net {
566568
return self.process_rx();
567569
}
568570

569-
self.signal_used_queue(NetQueue::Rx)
571+
self.try_signal_queue(NetQueue::Rx)
570572
}
571573

572574
fn resume_rx(&mut self) -> Result<(), DeviceError> {
@@ -647,7 +649,7 @@ impl Net {
647649
self.metrics.no_tx_avail_buffer.inc();
648650
}
649651

650-
self.signal_used_queue(NetQueue::Tx)?;
652+
self.try_signal_queue(NetQueue::Tx)?;
651653

652654
// An incoming frame for the MMDS may trigger the transmission of a new message.
653655
if process_rx_for_mmds {

0 commit comments

Comments
 (0)