Expand description
NVMe controller emulator (NVMe 2.0, NVM command set).
This crate emulates an NVMe controller as a PCI device with MMIO BAR0, MSI-X, and admin + I/O queue pairs. It targets the NVMe Base 2.0 specification (version register reports 0x00020000) with vendor ID 0x1414 (Microsoft).
§Architecture
- PCI layer (
NvmeController) — MMIO BAR0 register handling, PCI config space, MSI-X interrupt routing, doorbell writes. - Coordinator — manages enable/reset sequencing, namespace add/remove.
- Admin worker — processes admin commands: Identify Controller/Namespace, Create/Delete I/O Queue, Get/Set Features, Async Event Request.
- I/O workers — pool of tasks (one per completion queue) processing NVM commands: READ, WRITE, FLUSH, Dataset Management (TRIM), and persistent reservation commands.
§What it doesn’t implement
Firmware update, admin-level namespace management (create/delete), multi-path
I/O, end-to-end data protection (PI), and save/restore (SaveRestore
returns not-supported).
§Namespace management
Namespaces can be added and removed at runtime via NvmeControllerClient.
Each namespace wraps a Disk and a background task
monitors capacity changes via wait_resize, completing Async Event Requests
with CHANGED_NAMESPACE_LIST when the disk size changes.
§Key constants
MAX_DATA_TRANSFER_SIZE: 256 KBMAX_QES: 256 queue entriesBAR0_LEN: 64 KB
Modules§
- resolver
- Resource resolver for the nvme controller.
Structs§
- Nsid
Conflict - Error returned when adding a namespace with a conflicting ID.
- Nvme
Controller - An NVMe controller.
- Nvme
Controller Caps - The NVMe controller’s capabilities.
- Nvme
Controller Client - Client for modifying the NVMe controller state at runtime.