Skip to content

Commit 634907e

Browse files
committed
feat(net): add support for VIRTIO_NET_F_MRG_RXBUF
Now virtio-net device can split incoming packets across multiple descriptor chains if VIRTIO_NET_F_MRG_RXBUF is enabled by the guest. The amount of descriptor chains (also known as heads) is written into the `virtio_net_hdr_v1` structure which is located at the very begging of the packet. Virtio spec states that the number of heads used should always be correct: - 1 - if VIRTIO_NET_F_MRG_RXBUF is not negotiated - N - if VIRTIO_NET_F_MRG_RXBUF is negotiated Prior to this commit Firecracker never set the number of used heads to 1, but Linux was fine with it. Now Firecracker always sets correct number of heads. Because of this, some changes were introduced into the unit test code that was generating testing frames. Additionally, because processing of descriptors was taking a big chunk of total time spend in the RX packet processing, move reading of descriptors to the preprocessing step performed when guest notifies Firecracker about new descriptors available for RX queue. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 604d728 commit 634907e

File tree

4 files changed

+687
-124
lines changed

4 files changed

+687
-124
lines changed

src/vmm/src/builder.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,16 @@ pub mod tests {
12251225
MmdsNetworkStack::default_ipv4_addr(),
12261226
Arc::new(Mutex::new(mmds)),
12271227
);
1228-
1228+
// Minimal setup for queues to be considered `valid`
1229+
for q in net.lock().unwrap().queues.iter_mut() {
1230+
q.ready = true;
1231+
q.size = 1;
1232+
// Need to explicitly set these addresses otherwise the aarch64
1233+
// will error out as it's memory does not start at 0.
1234+
q.desc_table = GuestAddress(crate::arch::SYSTEM_MEM_START);
1235+
q.avail_ring = GuestAddress(crate::arch::SYSTEM_MEM_START);
1236+
q.used_ring = GuestAddress(crate::arch::SYSTEM_MEM_START);
1237+
}
12291238
attach_net_devices(vmm, cmdline, net_builder.iter(), event_manager).unwrap();
12301239
}
12311240

0 commit comments

Comments
 (0)