Skip to content

Commit

Permalink
feat(net): add MRG_RXBUF support to virtio-net device
Browse files Browse the repository at this point in the history
Now virtio-net device VIRTIO_NET_F_MRG_RXBUF feature which allows it
to write single packet into multiple descriptor chains.
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.

Signed-off-by: Egor Lazarchuk <[email protected]>
  • Loading branch information
ShadowCurse committed Oct 7, 2024
1 parent 630bc52 commit 94018eb
Show file tree
Hide file tree
Showing 5 changed files with 281 additions and 114 deletions.
7 changes: 6 additions & 1 deletion src/vmm/src/devices/virtio/iovec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,15 @@ impl IoVecBufferMut {
/// In contrast to the equivalent [`IoVecBuffer::len()`] which returns `u32`, this one returns
/// `usize` since the buffer can contain multiple `DescriptorChain` objects, so we don't have
/// the limit that the length of a buffer is limited by `u32`.
pub(crate) fn len(&self) -> usize {
pub fn len(&self) -> usize {
self.len
}

/// Returns true if there is buffer is empty.
pub fn is_empty(&self) -> bool {
self.len == 0
}

/// Returns a pointer to the memory keeping the `iovec` structs
pub fn as_iovec_mut_slice(&mut self) -> &mut [iovec] {
self.vecs.as_mut_slice()
Expand Down
Loading

0 comments on commit 94018eb

Please sign in to comment.