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 <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2021-03-18 09:35:04 -07:00 committed by Sebastien Boeuf
parent ee871278ee
commit bfa37f89c4

View File

@ -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