# Realtek 8168 NIC weirdness

## bulliver

Built a new system yesterday, installed Gentoo. Went fine.  Spent this afternoon setting up X and my desktop. At some point I realized my network was no longer working. 

Repeated attempts to restart the interface only resulted in being assigned a "link local" address 169.254.8.87. The system uses dhcp and typically gets assigned an IP something like 192.168.2.10. Also started getting this in dmesg:

```

r8169 000:02:00.0: Direct firmware load failed with error -2

r8169 000:02:00.0: Falling back to user helper

r8169 000:02:00.0 enp2s0: unable to load firmware patch rtl_nic/rtl8168d-1.fw (-2)

```

Did some searching, seems you have to load firmware for this driver? emerge linux-firmware? I never did that. '/lib/firmware' doesn't exist. 

How does a nic that worked fine for the installation, and a day and half after suddenly decide it needs firmware?

Can't ping my gateway, can't ping anything. Decided to fire up the install CD again to see about downloading the firmware. The exact same CD that auto-detected and configured the interface yesterday is now giving me the same link local IP address. What?!?!?! The install CD is NOT giving me the dmesg errors however. So I even reset my BIOS to defaults, even though the only thing I changed was adding the IOMMU device. 

lspci:

```
02:00.0 Ethernet controller: Realtek Semiconductor Co LTD RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 09)
```

NIC is an onboard, using driver r8169 built in to the kernel. 

I have no idea what even to look for here...just baffled and confused.

----------

## bulliver

Well, I dunno. 

After trying 10-15 or so permutations of various kernel configurations the box is back online. I'm hesitant to mark my problem as 'solved' however, as certain things still seem to be flaky. For instance...from the console I attempted to ping google, but it just hung and did nothing until I ctrl-c'ed it. Did that several times, but after firing up KDE ping works just fine from an eterm. Not sure if that is related in any way.

I took the opportunity to emerge linux-firmware, so now the firmware that the kernel was complaining about is on disk. I gather this is relevant to the kernel config CONFIG_FIRMWARE_IN_KERNEL. Set to yes it builds the blob into the kernel, and if no it looks in /lib/firmware and loads from userspace. Is that right?

I also noticed there is a r8168 driver in net-misc. I tried to emerge it but it failed because I have r8169 built in to the kernel. So I guess my next step will be to build a kernel without r8169 and try the r8168 driver....

----------

## Cr0t

This post is super old an old, but run "ethtool -i eth0". This will show you, if the firmware has been loaded.

----------

## Logicien

Because the r8169 support is compile in the kernel image, the firmware files that r8169 need should be compile in  the kernel image too. If not, when the NIC is probe and detected by the Linux image, the r8169 support will not have access to the firmware files it need until the real root partition will be mount. This can be the problem.

That's why I always compile the NIC support in module. Than when the module is load, the real root partition is mounted and the module have access to the firmware files too.

----------

## Cr0t

 *Logicien wrote:*   

> Because the r8169 support is compile in the kernel image, the firmware files that r8169 need should be compile in  the kernel image too. If not, when the NIC is probe and detected by the Linux image, the r8169 support will not have access to the firmware files it need until the real root partition will be mount. This can be the problem.
> 
> That's why I always compile the NIC support in module. Than when the module is load, the real root partition is mounted and the module have access to the firmware files too.

 I am unable to get the firmware loaded myself. Is it possible to identify if the driver tried to load the firmware?

```
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8110SC/8169SC Gigabit Ethernet (rev 10)

        Subsystem: ABIT Computer Corp. RTL-8110SC/8169SC Gigabit Ethernet

        Kernel driver in use: r8169

        Kernel modules: r8169

04:01.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8110SC/8169SC Gigabit Ethernet (rev 10)

        Subsystem: ABIT Computer Corp. RTL-8110SC/8169SC Gigabit Ethernet

        Kernel driver in use: r8169

        Kernel modules: r8169

[    3.009438] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded

[    3.009544] r8169 0000:04:00.0 (unnamed net_device) (uninitialized): not PCI Express

[    3.009767] r8169 0000:04:00.0 eth0: RTL8169sc/8110sc at 0xffffc900104c6000, 00:50:8d:bb:e6:16, XID 18000000 IRQ 23

[    3.009770] r8169 0000:04:00.0 eth0: jumbo features [frames: 7152 bytes, tx checksumming: ok]

[    3.009785] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded

[    3.009847] r8169 0000:04:01.0 (unnamed net_device) (uninitialized): not PCI Express

[    3.010051] r8169 0000:04:01.0 eth1: RTL8169sc/8110sc at 0xffffc900104c8000, 00:50:8d:bb:e6:17, XID 18000000 IRQ 22

[    3.010054] r8169 0000:04:01.0 eth1: jumbo features [frames: 7152 bytes, tx checksumming: ok]

filename:       /lib/modules/3.19.2-gentoo/kernel/drivers/net/ethernet/realtek/r8169.ko

firmware:       rtl_nic/rtl8107e-2.fw

firmware:       rtl_nic/rtl8107e-1.fw

firmware:       rtl_nic/rtl8168h-2.fw

firmware:       rtl_nic/rtl8168h-1.fw

firmware:       rtl_nic/rtl8168g-3.fw

firmware:       rtl_nic/rtl8168g-2.fw

firmware:       rtl_nic/rtl8106e-2.fw

firmware:       rtl_nic/rtl8106e-1.fw

firmware:       rtl_nic/rtl8411-2.fw

firmware:       rtl_nic/rtl8411-1.fw

firmware:       rtl_nic/rtl8402-1.fw

firmware:       rtl_nic/rtl8168f-2.fw

firmware:       rtl_nic/rtl8168f-1.fw

firmware:       rtl_nic/rtl8105e-1.fw

firmware:       rtl_nic/rtl8168e-3.fw

firmware:       rtl_nic/rtl8168e-2.fw

firmware:       rtl_nic/rtl8168e-1.fw

firmware:       rtl_nic/rtl8168d-2.fw

firmware:       rtl_nic/rtl8168d-1.fw

version:        2.3LK-NAPI

license:        GPL

description:    RealTek RTL-8169 Gigabit Ethernet driver

author:         Realtek and the Linux r8169 crew <netdev@vger.kernel.org>

srcversion:     6FB24800592DD42014AAD0E

alias:          pci:v00000001d00008168sv*sd00002410bc*sc*i*

alias:          pci:v00001737d00001032sv*sd00000024bc*sc*i*

alias:          pci:v000016ECd00000116sv*sd*bc*sc*i*

alias:          pci:v00001259d0000C107sv*sd*bc*sc*i*

alias:          pci:v00001186d00004302sv*sd*bc*sc*i*

alias:          pci:v00001186d00004300sv*sd*bc*sc*i*

alias:          pci:v00001186d00004300sv00001186sd00004B10bc*sc*i*

alias:          pci:v000010ECd00008169sv*sd*bc*sc*i*

alias:          pci:v000010ECd00008168sv*sd*bc*sc*i*

alias:          pci:v000010ECd00008167sv*sd*bc*sc*i*

alias:          pci:v000010ECd00008136sv*sd*bc*sc*i*

alias:          pci:v000010ECd00008129sv*sd*bc*sc*i*

depends:        mii

intree:         Y

vermagic:       3.19.2-gentoo SMP preempt mod_unload

parm:           use_dac:Enable PCI DAC. Unsafe on 32 bit PCI slot. (int)

parm:           debug:Debug verbosity level (0=none, ..., 16=all) (int)

# ethtool -i eth0

driver: r8169

version: 2.3LK-NAPI

firmware-version:

bus-info: 0000:04:00.0

supports-statistics: yes

supports-test: no

supports-eeprom-access: no

supports-register-dump: yes

supports-priv-flags: no

# ethtool -i eth1

driver: r8169

version: 2.3LK-NAPI

firmware-version:

bus-info: 0000:04:01.0

supports-statistics: yes

supports-test: no

supports-eeprom-access: no

supports-register-dump: yes

supports-priv-flags: no

# grep -i firmware /usr/src/linux/.config

CONFIG_PREVENT_FIRMWARE_BUILD=y

# CONFIG_FIRMWARE_IN_KERNEL is not set

CONFIG_EXTRA_FIRMWARE=""

# Altera FPGA firmware download module

# CONFIG_DRM_LOAD_EDID_FIRMWARE is not set

CONFIG_FIRMWARE_EDID=y

# Firmware Drivers

CONFIG_FIRMWARE_MEMMAP=y

# CONFIG_GOOGLE_FIRMWARE is not set

# CONFIG_TEST_FIRMWARE is not set
```

----------

## Cr0t

I found the association in the driver...

```
#define FIRMWARE_8168D_1        "rtl_nic/rtl8168d-1.fw"

#define FIRMWARE_8168D_2        "rtl_nic/rtl8168d-2.fw"

#define FIRMWARE_8168E_1        "rtl_nic/rtl8168e-1.fw"

#define FIRMWARE_8168E_2        "rtl_nic/rtl8168e-2.fw"

#define FIRMWARE_8168E_3        "rtl_nic/rtl8168e-3.fw"

#define FIRMWARE_8168F_1        "rtl_nic/rtl8168f-1.fw"

#define FIRMWARE_8168F_2        "rtl_nic/rtl8168f-2.fw"

#define FIRMWARE_8105E_1        "rtl_nic/rtl8105e-1.fw"

#define FIRMWARE_8402_1         "rtl_nic/rtl8402-1.fw"

#define FIRMWARE_8411_1         "rtl_nic/rtl8411-1.fw"

#define FIRMWARE_8411_2         "rtl_nic/rtl8411-2.fw"

#define FIRMWARE_8106E_1        "rtl_nic/rtl8106e-1.fw"

#define FIRMWARE_8106E_2        "rtl_nic/rtl8106e-2.fw"

#define FIRMWARE_8168G_2        "rtl_nic/rtl8168g-2.fw"

#define FIRMWARE_8168G_3        "rtl_nic/rtl8168g-3.fw"

#define FIRMWARE_8168H_1        "rtl_nic/rtl8168h-1.fw"

#define FIRMWARE_8168H_2        "rtl_nic/rtl8168h-2.fw"

#define FIRMWARE_8107E_1        "rtl_nic/rtl8107e-1.fw"

#define FIRMWARE_8107E_2        "rtl_nic/rtl8107e-2.fw"
```

----------

## chithanh

Does the card work at first and after some time suddenly stop working? This could be an IOMMU issue (especially on AMD systems) and worked around by iommu=pt kernel parameter.

If the card never works, the missing firmware could be at fault. If the driver is compiled into your kernel, then also the firmware file needs to be built-in (through CONFIG_EXTRA_FIRMWARE). If r8169 is a module, then installing the linux-firmware package should be enough.

----------

