From bfa37f89c4a2550039cbb7adb43fb6f598297adb Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Thu, 18 Mar 2021 09:35:04 -0700 Subject: [PATCH] virtio-devices: net: Refactor 'handle_tx_event' This patch moves out the actual processing on the TX queue from the `handle_tx_event()` function into a separate function, e.g. `process_tx()`. This allows us to resume the TX queue processing without reading from the TX queue EventFd, which is needed for rate limiting support. No functional change. Signed-off-by: Bo Chen --- virtio-devices/src/net.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/virtio-devices/src/net.rs b/virtio-devices/src/net.rs index 981ae8e30..3f3abd9f5 100644 --- a/virtio-devices/src/net.rs +++ b/virtio-devices/src/net.rs @@ -101,11 +101,7 @@ impl NetEpollHandler { Ok(()) } - fn handle_tx_event(&mut self) -> result::Result<(), DeviceError> { - let queue_evt = &self.queue_evt_pair[1]; - if let Err(e) = queue_evt.read() { - error!("Failed to get tx queue event: {:?}", e); - } + fn process_tx(&mut self) -> result::Result<(), DeviceError> { if self .net .process_tx(&mut self.queue_pair[1]) @@ -120,6 +116,17 @@ impl NetEpollHandler { Ok(()) } + fn handle_tx_event(&mut self) -> result::Result<(), DeviceError> { + let queue_evt = &self.queue_evt_pair[1]; + if let Err(e) = queue_evt.read() { + error!("Failed to get tx queue event: {:?}", e); + } + + self.process_tx()?; + + Ok(()) + } + fn handle_rx_tap_event(&mut self) -> result::Result<(), DeviceError> { if self .net