Skip to content

drivers: add API for VIRTIO devices and add VIRTIO PCI driver #83892

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

Merged
merged 3 commits into from
Jun 2, 2025

Conversation

fkokosinski
Copy link
Member

This PR adds the API for accessing VIRTIO devices, and adds a driver for a VIRTIO PCI device based on the newly added API, and adds a build test for the newly added VIRTIO PCI device. This PR is first of many, and more VIRTIO-related PRs will be submitted when this PR gets merged.

This PR is based on the Virtual I/O Device (VIRTIO) Version 1.3 specification: https://docs.oasis-open.org/virtio/virtio/v1.3/csd01/virtio-v1.3-csd01.pdf.

@fkokosinski fkokosinski marked this pull request as ready for review January 14, 2025 08:51
@henrikbrixandersen henrikbrixandersen added the Architecture Review Discussion in the Architecture WG required label Jan 14, 2025
@henrikbrixandersen
Copy link
Member

@fkokosinski Will you be available for presenting this addition of a new device class to the Architecture WG? /CC @carlescufi

@fkokosinski
Copy link
Member Author

Hey @henrikbrixandersen, would February 11th work for you guys?

@carlescufi
Copy link
Member

Hey @henrikbrixandersen, would February 11th work for you guys?

Yes, that would work.

Copy link
Member

@cfriedt cfriedt left a comment

Choose a reason for hiding this comment

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

Looks pretty great to me other than some minor refinements.

Would be good for @ycsin or @luchnikov to take a look too (at fence operations, among other things).

@carlescufi
Copy link
Member

carlescufi commented Feb 25, 2025

Architecture WG meeting:

  • @fkokosinski introduces the concept of VirtIO, and how this PR is the foundation of a framework in Zephyr that will be able to build upon in later PRs
  • @nashif asks whether this PR can actually be tested at all. As per the author, this is not the case. Today this PR only introduces the building blocks, but it doesn't actually give you any functionality
  • @nashif asks for an RFC where the roadmap towards the next steps after merging this PR are, so that we know what direction we're going towards. @cfriedt agrees with that
  • @fkokosinski and @PiotrZierhoffer will provide an RFC issue

@fkokosinski fkokosinski mentioned this pull request Mar 3, 2025
12 tasks
@fkokosinski fkokosinski force-pushed the 66707_virtio_driver branch from 6e3ffde to 8d78418 Compare March 3, 2025 11:53
@carlescufi carlescufi moved this from Todo to In Progress in Architecture Review Mar 4, 2025
@fkokosinski fkokosinski force-pushed the 66707_virtio_driver branch from 8d78418 to 4361ac6 Compare March 5, 2025 11:36
@fkokosinski
Copy link
Member Author

* @nashif asks whether this PR can actually be tested at all. As per the author, this is not the case. Today this PR only introduces the building blocks, but it doesn't actually give you any functionality

Draft PR that uses the VIRTIO PCI driver can be found here: #86768

* @nashif asks for an RFC where the roadmap towards the next steps after merging this PR are, so that we know what direction we're going towards. @cfriedt agrees with that
* @fkokosinski and @PiotrZierhoffer will provide an RFC issue

RFC issue can be found here: #86561

FYI @cfriedt, @carlescufi

@jmichalski-ant jmichalski-ant force-pushed the 66707_virtio_driver branch 2 times, most recently from c6d4bf8 to 4946df2 Compare May 8, 2025 13:34
soburi
soburi previously approved these changes May 8, 2025
Copy link
Member

@soburi soburi left a comment

Choose a reason for hiding this comment

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

LGTM

@soburi soburi requested review from cfriedt and Copilot May 8, 2025 20:35
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an API for accessing VIRTIO devices and a corresponding VIRTIO PCI driver along with supporting tests and documentation.

  • Introduces API definitions and implementations in include/zephyr/virtio/virtqueue.h and virtio.h.
  • Adds a new VIRTIO PCI driver, updated device bindings, and build/test support via CMake and DTS overlays.
  • Updates documentation and maintainers information for the new VIRTIO functionality.

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/drivers/build_all/virtio/* Added build test case and configuration files for VIRTIO testing
include/zephyr/virtio/*.h New API header files defining virtqueue and virtio interfaces
drivers/virtio/virtqueue.c Implements virtqueue creation and buffer chain handling
drivers/virtio/Kconfig, drivers/virtio/CMakeLists.txt Added configuration and build system support for VIRTIO drivers
dts/bindings/virtio/virtio,pci.yaml Introduces device tree binding for VIRTIO over PCI
doc/hardware/virtualization/virtio.rst Documents VIRTIO concepts and API usage
... (others) Minor updates for integration into the overall virtualization framework

cfriedt
cfriedt previously approved these changes May 10, 2025
This commit adds the API for accessing VIRTIO devices, and adds a driver
for a VIRTIO PCIE device based on the newly added API.

This commit is based on the Virtual I/O Device (VIRTIO) Version 1.3
specification:
https://docs.oasis-open.org/virtio/virtio/v1.3/csd01/virtio-v1.3-csd01.pdf

Signed-off-by: Jakub Michalski <jmichalski@antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
This commit adds virtio section in documentation, describing
virtio-related concepts

Signed-off-by: Jakub Michalski <jmichalski@antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
This commit adds a build test for the VIRTIO PCI device.

Signed-off-by: Jakub Michalski <jmichalski@antmicro.com>
Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
@fkokosinski fkokosinski dismissed stale reviews from cfriedt and soburi via 0f19e62 May 12, 2025 11:00
@fkokosinski fkokosinski force-pushed the 66707_virtio_driver branch from 4946df2 to 0f19e62 Compare May 12, 2025 11:00
Copy link

@fkokosinski
Copy link
Member Author

@soburi we've separated ISR handling into virtio_common, so that stuff between PCI and MMIO can be shared (code-wise).

@cfriedt
Copy link
Member

cfriedt commented May 14, 2025

@carlescufi - is there any additional need to keep this In Progress in Arch Review, or can it be moved to Done?

This was discussed at the arch review meeting 3 months ago.

Most requested changes have been made, tests and docs have been added. An RFC issue was made.

#83892 (comment)

@cfriedt
Copy link
Member

cfriedt commented May 25, 2025

@nashif @MaureenHelm - have you had a chance to (re-)review?

@carlescufi carlescufi removed the Architecture Review Discussion in the Architecture WG required label Jun 2, 2025
@kartben kartben merged commit b756524 into zephyrproject-rtos:main Jun 2, 2025
27 of 28 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Architecture Review Jun 2, 2025
@kgugala kgugala deleted the 66707_virtio_driver branch June 3, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.