virtio-net driver rewrite
#118
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request significantly refactors the VirtIO network driver to support multiple network interfaces and improve descriptor management. The changes replace the use of global/static variables with per-interface data structures, update how descriptor tables and rings are managed, and streamline packet transmit/receive logic for better correctness and maintainability.
Key improvements and refactoring:
Per-Interface Data Management:
os_net_mem,netrxdescindex,nettxdescindex, etc.) with per-interface fields accessed via offsets from an interface structure (usingr8/rdxand offsets likent_rx_desc,nt_tx_desc, etc.), enabling support for multiple network interfaces and eliminating shared state. [1] [2] [3] [4] [5] [6] [7] [8]Descriptor Table and Ring Handling:
Transmit and Receive Logic:
net_virtio_transmitandnet_virtio_pollto use per-interface descriptor tables and indices, improved ring index management, and ensured correct address calculations for packet data. Also, improved handling of the used/available rings for packet transmission and reception, including proper wrap-around of indices. [1] [2] [3]Cleanup and Removal of Global State:
netrxdescindex,netrxavailindex,nettxdescindex,nettxavailindex), as these are now managed per interface.General Code Organization and Comments:
These changes make the VirtIO network driver more robust, modular, and ready for environments with multiple network devices.