A guest without virtio drivers has one network device to choose in bhyve, the e1000 (82545): a single queue, no MSI-X, no interrupt moderation the driver can steer. Windows is such a guest, as it has no virtio-net driver in the box. So are many closed systems, embedded and NAS appliances among them: they come without virtio-net, and nobody but their vendor can build a driver for them. What most of them do have is a driver for Intel's server adapters. With the e1000 the Windows guest measured below receives at a fraction of what virtio-net does, and with this device at several times the e1000's rate.
Add an emulation of the Intel 82576 Gigabit Ethernet controller (8086:10c9), the chip igb(4) attaches to:
-s N,igb,tap0[,mac=xx:xx:xx:xx:xx:xx][,link=down][,msix=false]
Windows 10, Windows 11 and Windows Server 2022 take it with the driver on their installation media, as do FreeBSD and Linux.
What is implemented:
- the registers in BAR 0, reset, the NVM through EERD, the internal PHY through MDIC;
- 16 receive and 16 transmit queues, legacy and advanced descriptors, transmit head write-back (which the Windows driver relies on);
- receive side scaling: MRQC, RETA, RSSRK, the Toeplitz hash;
- the address filters (RAR, MTA), VLAN filtering, tag insertion and stripping;
- frames of up to 9728 bytes: with RCTL.LPE the limit is RLPML, longer frames are dropped and counted (ROC);
- checksum insertion and TCP segmentation, done in software, and verification of received IPv4, TCP and UDP checksums when RXCSUM asks for it;
- INTx and MSI with ICR/IMS, and MSI-X with 10 vectors (IVAR, EICR/EIMS/EIAC/EIAM), with EITR holding a vector's interrupts apart;
- link state: up unless the guest powers the PHY down or the device was started with link=down;
- the statistics registers;
- snapshots, with pause and resume.
A frame for whose queue the guest has no descriptors is not dropped at once: it waits, and the backend with it, until the guest gives some (at most 10 ms if the queue's SRRCTL says to drop).
Not implemented: SR-IOV, VMDq, IEEE 1588, flow control, wake-up, manageability. Their registers, like every register the device does not know, are plain storage.
The device is written from Intel's 82576EB data sheet and from what the driver in sys/dev/e1000 does with the chip. The registers and their bits have the names of that driver's headers (e1000_regs.h, e1000_defines.h, e1000_82575.h), as in pci_e82545.c. It shares no code with pci_e82545.c: the register layout, the descriptors and the interrupt model differ.
One thread sends for all queues. A thread per queue was tried and halved the throughput of four streams, the threads waiting for each other at the backend.
A snapshot of a guest whose igb uses INTx depends on the PCI code saving pi_lintr.state (D60239), as for the other devices. The drivers use MSI-X where they can.
Measured with a Windows 10 22H2 guest (4 vCPUs) on an i5-10505, iperf3 for 10 seconds to a virtio-net guest on the same host over tap and if_bridge, one and four streams, in Gbit/s; the bhyve is keelOS's, which is based on stable/15:
| device (driver) | sending, 1 / 4 streams | receiving, 1 / 4 streams |
|---|---|---|
| e1000 (in the box) | 8.2 / 7.4 | 1.4 / 1.5 |
| virtio-net (virtio-win) | 8.6 / 7.2 | 5.6 / 7.9 |
| igb (in the box) | 8.9 / 8.3 | 7.2 / 6.9 |
AI assistance: this change was developed with an AI assistant (Anthropic's Claude) under my direction, as keelOS itself is. The assistant wrote the code and this description. QEMU's igb model and the Linux driver were read to understand how the chip and the Windows driver behave; no code or tables were taken from them. The tests in the test plan were run on real hardware.
Signed-off-by: Wanpeng Qian <wanpengqian@gmail.com>
Sponsored by: keelos.dev