vm-virtio: Improve virtio-net rx queue processing

The frame buffer must be updated depending on the amount read from it,
which depends on the number and depth of descriptors available at the
time of the processing.

This patch handles this buffer update, and allow for large buffers to be
correctly processed in multiple rounds.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-04-21 17:34:41 +02:00
parent 03dd24978e
commit 24c2b67aa4

View File

@ -430,7 +430,15 @@ impl RxVirtio {
// Mark that we have at least one pending packet and we need to interrupt the guest.
self.deferred_irqs = true;
write_count >= self.bytes_read
// Update the frame_buf buffer.
if write_count < self.bytes_read {
self.frame_buf.copy_within(write_count..self.bytes_read, 0);
self.bytes_read -= write_count;
false
} else {
self.bytes_read = 0;
true
}
}
}