-
Notifications
You must be signed in to change notification settings - Fork 63
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 support for indirect descriptors in VirtQueue with alloc feature #102
Conversation
4d8a220
to
ada5eb0
Compare
Co-authored-by: Arsering <[email protected]>
Co-authored-by: Arsering <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add a new feature "indirect-desc"?
You mean a cargo feature? Is there any case where you have an allocator available, the VirtIO device implementation supports indirect descriptors, but you wouldn't want to use them? I can't think of one, but if so we could add a flag to the device driver constructor so it could be decided at runtime. |
The conditional compilation attribute |
The reason that indirect descriptor support is guarded by the In an environment where heap allocation is available, I don't see any reason why someone would want to disable just indirect descriptor support at compile-time. |
Okay, I mean we can enable it by default and make it dependent on |
This is based on some of the work in #96, but fixes some issues there with how allocation and DMA memory is handled, adds tests for the indirect virtqueue itself, and also adds support to the fake device support so that device tests will work with indirect queues.
Devices can choose when constructing a
VirtQueue
whether it should support indirect descriptors or not, based on their preference and the device features. For now only theVirtIOBlk
driver uses indirect descriptors (if the underlying device supports it). If aVirtQueue
is constructed with indirect descriptor support then it will use them whenever more than one buffer is added to the queue. There's no point using indirect descriptors for a single buffer so we don't bother.Space for the indirect descriptor lists is allocated (and shared with the device via the HAL) dynamically. This means that it depends on the
alloc
feature, which is enabled by default. If thealloc
feature is disabled, then indirect descriptors will never be used.