UEFI Network Driver Link Speed Negotiation
Before a UEFI-enabled system can request an IP address via DHCP during a network boot (PXE), the underlying UEFI network driver and Network Interface Card (NIC) must establish a physical layer link with the network switch. This article breaks down the pre-boot link establishment process, detailing the transition from UEFI driver initialization to hardware-level physical layer (PHY) auto-negotiation, link state polling via the Simple Network Protocol, and the eventual handoff to the DHCP client.
Driver Initialization and Binding
The process begins during the UEFI Driver Execution Environment (DXE)
phase. The UEFI Driver Model uses the
EFI_DRIVER_BINDING_PROTOCOL to connect hardware devices to
their respective drivers:
- Device Discovery: The PCI bus driver discovers the
network controller on the PCI bus and installs a handle with the
EFI_PCI_IO_PROTOCOL. - Driver Binding: The network driver's
Supported()function evaluates the device. If compatible, the core invokes the driver'sStart()function. - Register Mapping: The driver maps the NIC’s memory-mapped I/O (MMIO) space, resets the controller, and initializes access to the Medium Access Control (MAC) core and the Physical Layer (PHY) chip, typically via the Management Data Input/Output (MDIO) interface.
Physical Layer (PHY) Auto-Negotiation
Link speed and duplex settings are primarily negotiated at the hardware layer rather than the software layer, following IEEE 802.3 standards.
- Triggering Negotiation: Once the driver brings the PHY out of reset, it configures the PHY's Auto-Negotiation Advertisement Register via MDIO. By default, it advertises all supported speeds (e.g., 10/100/1000/10000 Mbps) and full/half-duplex capabilities.
- Electrical Signaling: The PHY exchanges bursts of pulses—known as Fast Link Pulses (FLP) in 1000BASE-T or Link Code Words—with the link partner (the switch port).
- Technology Resolution: Both devices compare capabilities and select the highest common performance mode according to the priority resolution table defined in IEEE 802.3 (favoring full duplex and highest bandwidth).
Link State Polling via Simple Network Protocol (SNP)
While the PHY and the switch negotiate automatically at the electrical level, the UEFI network driver must monitor and confirm this status before higher-level network operations can start:
- Protocol Installation: The driver installs the
EFI_SIMPLE_NETWORK_PROTOCOL(SNP) on the network device handle. - Media Status Check: Upper-layer drivers (such as
the PXE Base Code or MNP—Managed Network Protocol) call the SNP’s
GetStatus()function. - Hardware Polling:
GetStatus()reads the PHY’s Basic Mode Status Register (BMSR) through MDIO. The driver checks the "Link Status" bit to determine whether the physical link is active. - Link Up Confirmation: If the link is not yet established, the driver executes a polling loop with an implementation-specific timeout (typically between 3 to 10 seconds) to allow the PHY auto-negotiation to complete.
Handoff to the DHCP Stack
Once the PHY confirms a link, the driver reads the resolved speed and
duplex status from the PHY registers, configures the MAC's internal
transmit and receive clocks to match those settings, and flags the
MediaPresent boolean in the
EFI_SIMPLE_NETWORK_MODE structure as TRUE.
With physical connectivity confirmed, the UEFI network stack
initializes the EFI_DHCP4_PROTOCOL or
EFI_DHCP6_PROTOCOL. The system then transmits the initial
DHCP DISCOVER packet onto a stable, synchronized network medium.