Skip to content

refactor(drivers): moved the virtio PCI transport into a base class shared by virtio drivers - #339

Merged
FlareCoding merged 2 commits into
masterfrom
pr/virtio-transport
Oct 6, 2026
Merged

FlareCoding merged 2 commits into
masterfrom
pr/virtio-transport

Conversation

@FlareCoding

@FlareCoding FlareCoding commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • The virtio PCI transport lived inside the network driver: capability parsing, the status handshake, feature negotiation, queue setup and MSI-X routing. A second virtio device would have had to copy all of it.
  • The transport moves into a virtio_pci_driver base class in drivers/virtio, next to the shared PCI definitions and the virtqueue. virtio-net derives from it and behaves as before.

Note

Medium Risk
Refactors kernel virtio-net bring-up and MMIO/virtqueue setup without intended behavior change; regressions would affect network attach and PCI feature negotiation.

Overview
Extracts the virtio modern PCI transport (capability walk, BAR mapping, status handshake, feature negotiation, virtqueue registration, MSI-X routing helpers, ISR ack, device reset) from virtio_net into a new virtio_pci_driver base under drivers/virtio. virtio-net now derives from that class and keeps only net-specific attach/queue buffer logic, calling start_transport(), setup_queue(), set_driver_ok(), and device_config() instead of inlined transport code.

Shared virtio pieces are relocated and renamed: generic PCI definitions stay in virtio_pci.h (net-only constants/structs move to virtio_net.h), and the virtqueue implementation moves from drivers/net to drivers/virtio/virtqueue.*. Feature negotiation in the base class now takes required vs optional feature masks; virtio-net treats MAC, STATUS, and VERSION_1 as optional and reads negotiated bits from the returned mask. Link-up checks use VIRTIO_NET_S_LINK_UP instead of a raw status bit.

Reviewed by Cursor Bugbot for commit 63d1c32. Bugbot is set up for automated code reviews on this repo. Configure here.

@FlareCoding
FlareCoding added this pull request to stack #342 October 6, 2026 06:09
@FlareCoding
FlareCoding merged commit 95f458f into master Oct 6, 2026
19 checks passed
@FlareCoding
FlareCoding deleted the pr/virtio-transport branch October 6, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant