Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VIRTIO_NET_F_MRG_RXBUF to virtio-net #4834

Merged

Conversation

ShadowCurse
Copy link
Contributor

@ShadowCurse ShadowCurse commented Oct 4, 2024

Changes

Add VIRTIO_NET_F_MRG_RXBUF to virtio-net.

Now virtio-net device can split incoming packets across multiple descriptor chains if VIRTIO_NET_F_MRG_RXBUF is enabled by the guest.

Reason

Improves performance of virtio-net device.

Fixes: #1314

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • If a specific issue led to this PR, this PR closes the issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this
    PR.
  • API changes follow the Runbook for Firecracker API changes.
  • User-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.
  • New TODOs link to an issue.
  • Commits meet
    contribution quality standards.

  • This functionality cannot be added in rust-vmm.

@ShadowCurse ShadowCurse force-pushed the bchalios_readv_mrg_buf branch 8 times, most recently from 7cad4af to 97f33c2 Compare October 7, 2024 13:16
@ShadowCurse ShadowCurse marked this pull request as ready for review October 7, 2024 13:17
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 97.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 84.05%. Comparing base (7fc9270) to head (e4fd753).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/vmm/src/devices/virtio/net/persist.rs 50.00% 2 Missing ⚠️
src/vmm/src/devices/virtio/net/device.rs 98.82% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4834      +/-   ##
==========================================
+ Coverage   84.01%   84.05%   +0.04%     
==========================================
  Files         251      251              
  Lines       28019    28061      +42     
==========================================
+ Hits        23541    23588      +47     
+ Misses       4478     4473       -5     
Flag Coverage Δ
5.10-c5n.metal 84.68% <97.14%> (+0.04%) ⬆️
5.10-m5n.metal 84.66% <97.14%> (+0.04%) ⬆️
5.10-m6a.metal 83.97% <97.14%> (+0.04%) ⬆️
5.10-m6g.metal 80.67% <97.14%> (+0.05%) ⬆️
5.10-m6i.metal 84.66% <97.14%> (+0.04%) ⬆️
5.10-m7g.metal 80.67% <97.14%> (+0.05%) ⬆️
6.1-c5n.metal 84.68% <97.14%> (+0.05%) ⬆️
6.1-m5n.metal 84.66% <97.14%> (+0.04%) ⬆️
6.1-m6a.metal 83.97% <97.14%> (+0.04%) ⬆️
6.1-m6g.metal 80.67% <97.14%> (+0.05%) ⬆️
6.1-m6i.metal 84.66% <97.14%> (+0.04%) ⬆️
6.1-m7g.metal 80.67% <97.14%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
@ShadowCurse ShadowCurse force-pushed the bchalios_readv_mrg_buf branch 6 times, most recently from 8190129 to 7bf4b03 Compare October 14, 2024 12:07
@ShadowCurse ShadowCurse self-assigned this Oct 14, 2024
@ShadowCurse ShadowCurse added Type: Enhancement Indicates new feature requests Type: Performance Status: Awaiting review Indicates that a pull request is ready to be reviewed labels Oct 14, 2024
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/net/persist.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/queue.rs Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Show resolved Hide resolved
@ShadowCurse ShadowCurse force-pushed the bchalios_readv_mrg_buf branch 2 times, most recently from f23d061 to 7e767b7 Compare October 14, 2024 14:07
@ShadowCurse ShadowCurse force-pushed the bchalios_readv_mrg_buf branch 6 times, most recently from e825696 to 9446de2 Compare October 14, 2024 16:35
bchalios
bchalios previously approved these changes Oct 15, 2024
Copy link
Contributor

@roypat roypat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any unittests where we explicitly test functionality that's special to mergeable buffers? E.g I see that we extended a bunch of the existing tests to make sure those cases still work for mergeable buffers, but do we have anything where we construct a chain that would be invalid without mergbuf, but can be processed with the feature?

src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
`Queue::add_used()` method first writes a Descriptor head in the used
descriptor ring buffer and then advances the index of this buffer to
let the guest know we used one or more Descriptors.

Carve out each one of these steps in their own function so that we can
add multiple descriptors in the used ring and advance the index only
once we finish handling descriptors in one step.

This will be useful when, in later commits, we will implement
VIRTIO_NET_F_RX_MRGBUF for the RX queue of the network device.

Signed-off-by: Egor Lazarchuk <[email protected]>
@ShadowCurse ShadowCurse force-pushed the bchalios_readv_mrg_buf branch 2 times, most recently from 219941b to c6142c0 Compare October 15, 2024 14:37
kalyazin
kalyazin previously approved these changes Oct 15, 2024
Copy link
Contributor

@kalyazin kalyazin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc LGTM

src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
src/vmm/src/devices/virtio/net/device.rs Outdated Show resolved Hide resolved
@ShadowCurse ShadowCurse force-pushed the bchalios_readv_mrg_buf branch 2 times, most recently from b0363f2 to f07cbf0 Compare October 15, 2024 15:02
Implement VIRTIO_NET_F_MRG_RXBUF feature for VirtIO network device.
It allows receiving a single network frame into multiple descriptor
chains. The amount of descriptor chains (also known as heads) that were
used is written into the `virtio_net_hdr_v1` structure which is located
at the beginning of the guest buffer.

Signed-off-by: Egor Lazarchuk <[email protected]>
Add a note about new `VIRTIO_NET_F_RX_MRGBUF` feature in the virtio-net
device.

Signed-off-by: Egor Lazarchuk <[email protected]>
Copy link
Contributor

@kalyazin kalyazin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc LGTM

@ShadowCurse ShadowCurse merged commit 0f306e5 into firecracker-microvm:main Oct 15, 2024
7 checks passed
@ShadowCurse ShadowCurse deleted the bchalios_readv_mrg_buf branch October 15, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting review Indicates that a pull request is ready to be reviewed Type: Enhancement Indicates new feature requests Type: Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Virtio-net: implement support of VIRTIO_NET_F_MRG_RXBUF
4 participants