You are not logged in.

#1 2020-06-08 01:11:58

quagmire
Member
Registered: 2017-06-03
Posts: 4

[SOLVED] Ethernet card doesn't detect carrier while using battery

Hello everyone,
This is my first post so I apologize if I put it in the wrong category or if I'm providing too much/little information with respect to what is needed.

I'm using a Lenovo Thinkpad T495, installed using the normal procedure written in the wiki, in dual boot with windows 10.
I recently noticed that whenever i plug in the ethernet cable with the computer already booted up it doesn't connect to the network, but only while I'm using the battery as power source.
As soon as i connect the pc to the external power the network is detected and it connects to the network.
I'm also able to access the wired network if i boot the laptop with the ethernet cable already inserted (with or without battery).
Removing external power while the PC is connected to the network leaves the connection up (that is, until i disconnect the ethernet and plug it again, then I'm back in the first case).

What is very strange to me is that the NIC actually connects to the network when I plug in the cable: LEDs on the switch (to which the pc is connected) lights up and signal not only a connection, but that is is 100Mb/s.
This means that my pc recognized the link to be 100Mb/s capable! (yes, unfortunately I don't have a gigabit LAN)
This happens even though the LEDs on the PC's card remain off.

I tried looking for solutions on T495 and Ethernet wiki page but found nothing that seems relatable to me.
In particular, I think I'm not affected by the "Realtek no link / WOL problem" because the nic works sometimes without windows intervention, and not "until windows boots up", and the card's LED turns on at POST time.

I tried also looking into the system logs (linked below) to see if I could find the source of the problem and maybe that lead to something: at a certain point there's a "r8169 ... : can't disable ASPM; OS doesn't have ASPM control" warning.
I searched for "ASPM r8169" and found a this AUR package which however prints an error while installing it (it seems it was created for an older kernel and not updated since 2018).
The pacman output is:

...
==> dkms install r8169_aspm/v4.15.3 -k 5.6.15-arch1-1
Error! Bad return status for module build on kernel: 5.6.15-arch1-1 (x86_64)
Consult /var/lib/dkms/r8169_aspm/v4.15.3/build/make.log for more information.
==> Warning, `dkms install r8169_aspm/v4.15.3 -k 5.6.15-arch1-1' returned 10

After a reboot, ethernet cards simply won't show anymore and I could only use wifi.

Other possibly useful outputs:
lspci -v (only ethernet portions: this pc has another nic that would be used if i had a docking station)

03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0e)
        Subsystem: Lenovo Device 5125
        Flags: bus master, fast devsel, latency 0, IRQ 74, IOMMU group 12
        I/O ports at 3400 [size=256]
        Memory at d0814000 (64-bit, non-prefetchable) [size=4K]
        Memory at d0800000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Endpoint, MSI 01
        Capabilities: [b0] MSI-X: Enable+ Count=4 Masked-
        Capabilities: [d0] Vital Product Data
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Virtual Channel
        Capabilities: [160] Device Serial Number 01-00-00-00-68-4c-e0-00
        Capabilities: [170] Latency Tolerance Reporting
        Capabilities: [178] L1 PM Substates
        Kernel driver in use: r8169
        Kernel modules: r8169

04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 10)
        Subsystem: Lenovo Device 5125
        Flags: bus master, fast devsel, latency 0, IRQ 77, IOMMU group 13
        I/O ports at 2000 [size=256]
        Memory at d0704000 (64-bit, non-prefetchable) [size=4K]
        Memory at d0700000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Endpoint, MSI 01
        Capabilities: [b0] MSI-X: Enable+ Count=4 Masked-
        Capabilities: [d0] Vital Product Data
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Virtual Channel
        Capabilities: [160] Device Serial Number 01-00-00-00-68-4c-e0-00
        Capabilities: [170] Latency Tolerance Reporting
        Capabilities: [178] L1 PM Substates
        Kernel driver in use: r8169
        Kernel modules: r8169

ip link while the network cable is connected, but not the power chord

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp3s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether f8:75:a4:4a:ae:82 brd ff:ff:ff:ff:ff:ff
3: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether f8:75:a4:4a:ae:81 brd ff:ff:ff:ff:ff:ff
4: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether 28:7f:cf:80:e0:e4 brd ff:ff:ff:ff:ff:ff

journald -b output when ethernet is connected before boot
https://gist.github.com/c21c8601832a861 … 592a07c78e

journald -b output when ethernet is connected after ~1m after boot end (circa 02:36), then I wait ~1m and then connect the laptop to power
https://gist.github.com/aefd81e8f689c6d … df9ca11d28

EDIT: corrected ip output

Last edited by quagmire (2020-11-10 00:23:39)

Offline

#2 2020-06-08 07:33:13

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,033
Website

Re: [SOLVED] Ethernet card doesn't detect carrier while using battery

So the DKMS driver failed to build.
What does /var/lib/dkms/r8169_aspm/v4.15.3/build/make.log contain?
Giggity.

Offline

#3 2020-06-08 12:54:13

quagmire
Member
Registered: 2017-06-03
Posts: 4

Re: [SOLVED] Ethernet card doesn't detect carrier while using battery

Thank you for your reply.
That file contains

DKMS make.log for r8169_aspm-v4.15.3 for kernel 5.6.15-arch1-1 (x86_64)
Mon 08 Jun 2020 10:52:49 AM CEST
make: Entering directory '/usr/lib/modules/5.6.15-arch1-1/build'
  CC [M]  /var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.o
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c:28:10: fatal error: linux/pci-aspm.h: No such file or directory
   28 | #include <linux/pci-aspm.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [scripts/Makefile.build:268: /var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.o] Error 1
make: *** [Makefile:1695: /var/lib/dkms/r8169_aspm/v4.15.3/build] Error 2
make: Leaving directory '/usr/lib/modules/5.6.15-arch1-1/build'

(I had to rebuild the package because the log was not in english)
Actually, I'm sorry for not having included in my first post but I was a bit sleepy and didn't notice the file was mentioned in the error message.

Because of the error I tried searching for a package that provided /usr/include/linux/pci-aspm.h but using pkgfile, but found nothing.

While searching some more on the web I found this and so I tried editing the package removing the #include as done in the diff file provided in the issue.
This didn't solve anything, as other compilation errors arose:

DKMS make.log for r8169_aspm-v4.15.3 for kernel 5.6.15-arch1-1 (x86_64)
Mon 08 Jun 2020 02:15:40 PM CEST
make: Entering directory '/usr/lib/modules/5.6.15-arch1-1/build'
  CC [M]  /var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.o
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c: In function ‘rtl_ack_events’:
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c:1552:2: error: implicit declaration of function ‘mmiowb’ [-Werror=implicit-function-declaration]
 1552 |  mmiowb();
      |  ^~~~~~
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c: In function ‘rtl_reset_work’:
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c:7197:2: error: implicit declaration of function ‘synchronize_sched’; did you mean ‘synchronize_net’? [-Werror=implicit-function-declaration]
 7197 |  synchronize_sched();
      |  ^~~~~~~~~~~~~~~~~
      |  synchronize_net
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c: At top level:
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c:8356:21: error: initialization of ‘void (*)(struct net_device *, unsigned int)’ from incompatible pointer type ‘void (*)(struct net_device *)’ [-Werror=incompatible-pointer-types]
 8356 |  .ndo_tx_timeout  = rtl8169_tx_timeout,
      |                     ^~~~~~~~~~~~~~~~~~
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c:8356:21: note: (near initialization for ‘rtl_netdev_ops.ndo_tx_timeout’)
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c: In function ‘r8168_phy_power_down’:
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c:5012:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
 5012 |   rtl_writephy(tp, 0x0e, 0x0200);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.c:5013:2: note: here
 5013 |  default:
      |  ^~~~~~~
cc1: some warnings being treated as errors
make[1]: *** [scripts/Makefile.build:268: /var/lib/dkms/r8169_aspm/v4.15.3/build/r8169_aspm.o] Error 1
make: *** [Makefile:1695: /var/lib/dkms/r8169_aspm/v4.15.3/build] Error 2
make: Leaving directory '/usr/lib/modules/5.6.15-arch1-1/build'

Also, I noticed that the github repo of the already mentioned AUR package mentions that maybe the package is outdated, while on the comments in the AUR there's a mention to a sysfs parameter that was to be introduced in linux 5.5 (and it was) to enable ASPM on a link via sysfs.

I searched a bit on the internet on how to try activating this feature but online it seems more of a feature that generates more problems by activating it rather than keeping it disabled, I will try to activate this feature later anyway (right now for some hours I won't be able to test the ethernet card)

Below, I'm still using the "stock" (non-AUR) r8169

Another thing that I found is that if I turn the interface down and then up using ip link it actually connects to the network.
Note that the interface is reported as down before running the commands, and setting it up directly doesn't work.
Below an extract from what I wrote in the shell:

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp3s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether f8:75:a4:4a:ae:82 brd ff:ff:ff:ff:ff:ff
3: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether f8:75:a4:4a:ae:81 brd ff:ff:ff:ff:ff:ff
4: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether 28:7f:cf:80:e0:e4 brd ff:ff:ff:ff:ff:ff

$ su
Password:

# ip link set enp4s0 up

# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp3s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether f8:75:a4:4a:ae:82 brd ff:ff:ff:ff:ff:ff
3: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether f8:75:a4:4a:ae:81 brd ff:ff:ff:ff:ff:ff
4: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether 28:7f:cf:80:e0:e4 brd ff:ff:ff:ff:ff:ff

# ip link set enp4s0 down

# ip link set enp4s0 up
 ... now it connects to the wired network ...

Here the syslog when I ran the previous commands (since when I became superuser)

This could be a solution but it would be nice to know why it doesn't work by just connecting the cable

Offline

#4 2020-06-09 22:38:14

quagmire
Member
Registered: 2017-06-03
Posts: 4

Re: [SOLVED] Ethernet card doesn't detect carrier while using battery

I tried booting with the pcie_aspm=force kernel parameter but there's no change.
I also tried getting info with ethtool and interestingly it behaves like the card isn't there (only when the NIC doesn't work correctly):

# ethtool enp4s0
netlink error: device not present
netlink error: No such device
netlink error: device not present
netlink error: No such device
netlink error: device not present
netlink error: No such device
netlink error: device not present
netlink error: No such device
netlink error: device not present
netlink error: No such device
No data available

# ethtool noSuchCard
netlink error: no device matches name (offset 24)
netlink error: No such device
netlink error: no device matches name (offset 24)
netlink error: No such device
netlink error: no device matches name (offset 24)
netlink error: No such device
netlink error: no device matches name (offset 24)
netlink error: No such device
netlink error: no device matches name (offset 24)
netlink error: No such device
No data available

While experimenting, i also noticed that if I turn the interface down with ip link set enp4s0 down the switch LEDs turn off (and ethtool then finds the NIC)!

Offline

#5 2020-11-10 00:22:58

quagmire
Member
Registered: 2017-06-03
Posts: 4

Re: [SOLVED] Ethernet card doesn't detect carrier while using battery

I eventually solved the issue by blacklisting the r8169 module that is in charge of the ethernet card and using the r8168 module that is available from the package with the same name.
I'm going to update the wiki now if i manage to

Offline

#6 2020-11-21 20:30:54

ratijas
Member
Registered: 2020-11-21
Posts: 2
Website

Re: [SOLVED] Ethernet card doesn't detect carrier while using battery

r8168-dkms module solved it for me too. Although I have already run into need to reinsert the module after sleep.

I wonder, why the code is not merged in-tree upstream? Just because Realtek?

Last edited by ratijas (2020-11-23 10:57:03)


"Everything not saved will be lost" -- Nintendo quit screen message.

"Anything not merged upstream will be left behind" -- my attitude.

Offline

#7 2020-11-23 11:14:04

ratijas
Member
Registered: 2020-11-21
Posts: 2
Website

Re: [SOLVED] Ethernet card doesn't detect carrier while using battery

OK, well, update report on the problem with new driver.

After waking up my laptop from sleep, it can no longer connect via Ethernet (the very same port in question, ruled by newly installed r8168-dkms driver). Symptoms, however, are different from those of r8169. This time

ip link

reports flags UP,LOWER_UP, state is UP, and

ethtool enp3s0

is not broken and actually shows real data:

Settings for enp3s0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  100baseT/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
        Link partner advertised pause frame use: Symmetric
        Link partner advertised auto-negotiation: Yes
        Link partner advertised FEC modes: Not reported
        Speed: 100Mb/s
        Duplex: Full
        Auto-negotiation: on
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        MDI-X: Unknown
        Supports Wake-on: pumbg
        Wake-on: d
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
        Link detected: yes

... it's just that NetworkManager or whatever is trying to negotiate the connection fail to do so, which causes KDE/Plasma constantly spin the connection status and report failures every 30 seconds or so.

My cable is straight-through 8-pin, the Ethernet port on a laptop is Gigabit, and the other end is connected to a 4-pin FastEthernet on a home Wi-Fi router, Keenetic Start.

With that being said, Speed: 100Mb/s, Duplex: Full mode reported by ethtool seem to be correct. I wonder, why MDI-X: Unknown — may that has something to do with the problem?


"Everything not saved will be lost" -- Nintendo quit screen message.

"Anything not merged upstream will be left behind" -- my attitude.

Offline

Board footer

Powered by FluxBB