Large tables of "magic numbers" in r8169 driver
John Scott
jscott at posteo.net
Mon Aug 10 18:33:49 UTC 2026
Hi,
While researching a related issue for Debian, I found that the kernel's in-tree driver for these Realtek Ethernet NICs has many tables of magic numbers that are opaque and seem to have been crafted with internal information at Realtek. See drivers/net/ethernet/realtek/r8169_main.c for example, and look for the definition of the rtl_enable_ltr() function around line 3000, as well as "fix-up" code in rtl8411b_fix_phy_down(). Inside the rtl_hw_start_8411_2() function there's even this concession:
> /* The following Realtek-provided magic fixes an issue with the RX unit
> * getting confused after the PHY having been powered-down.
> */
> r8168_mac_ocp_write(tp, 0xFC28, 0x0000);
> r8168_mac_ocp_write(tp, 0xFC2A, 0x0000);
> r8168_mac_ocp_write(tp, 0xFC2C, 0x0000);
> r8168_mac_ocp_write(tp, 0xFC2E, 0x0000);
Much of this is in code added fairly recently, as in rtl_hw_start_8125_common(). This is present in Linux-libre; how do we feel about this sort of thing? I want to make sure it wasn't missed and its inclusion is intentional.
For some NICs though (I think I have an RTL8168 handy?) I don't think the firmware is necessary, so this driver is still useful but is complicated by the fact that it supports both very old and very new NICs. If the secret numbers are only needed for the new generation, maybe the tables can be zeroed out in anticipation that older NICS will never reach the code.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 411 bytes
Desc: This is a digitally signed message part
URL: <http://www.fsfla.org/pipermail/linux-libre/attachments/20260810/71534bd6/attachment.sig>
More information about the linux-libre
mailing list