diff --git a/drivers/net/rtl8168d/src/device.rs b/drivers/net/rtl8168d/src/device.rs index f140a31243..de3da17bff 100644 --- a/drivers/net/rtl8168d/src/device.rs +++ b/drivers/net/rtl8168d/src/device.rs @@ -342,6 +342,31 @@ impl Rtl8168 { // Lock config self.regs.cmd_9346.write(0); + // Read physical link state. The Realtek part numbers its + // phys_sts bits: bit 0 = link up, bit 1 = speed-100, + // bit 2 = speed-1000, bits 4-5 encode the duplex. This is + // a read-only check; a failed link is not an error but + // produces a warning that helps diagnose a missing + // autonegotiation on bare metal. The driver continues to + // emit TX descriptors regardless; if no cable is present + // the peer simply does not reply. + let phys_sts = self.regs.phys_sts.read(); + if phys_sts & 0x01 == 0 { + log::warn!( + "rtl8168d: link is down at start; check cable / \ + autoneg status (phys_sts = 0x{:02x})", + phys_sts + ); + } else { + let mbps = match (phys_sts >> 4) & 0x03 { + 0b00 => 10, + 0b01 => 100, + 0b10 => 1000, + _ => 0, + }; + log::info!("rtl8168d: link up at {} Mb/s", mbps); + } + log::debug!("Complete!"); Ok(()) }