Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing linux/pci-aspm.h in latest Linux release candidate #19

Closed
stuart-little opened this issue Sep 25, 2019 · 4 comments
Closed

missing linux/pci-aspm.h in latest Linux release candidate #19

stuart-little opened this issue Sep 25, 2019 · 4 comments

Comments

@stuart-little
Copy link

@stuart-little stuart-little commented Sep 25, 2019

r8168_n.c includes linux/pci-aspm.h:

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
#include <linux/pci-aspm.h>                                                                                                                                                                                                                
#endif

The problem: the latest releases of the Linux kernel remove that file from the tree. For instance, there's

commit 20d3618b25c7e83136f6ff123e59c88230f9cb17
Merge: 5f9e832c1370 7ce2e76a0420
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Mon Sep 23 16:10:06 2019 -0500

    Merge branch 'pci/aspm'
    
      - Consolidate ASPM interfaces in linux/pci.h (Krzysztof Wilczynski)
    
    * pci/aspm:
      PCI: Move ASPM declarations to linux/pci.h

r8168_n.c already includes linux/pci.h unconditionally, so it should be fine on this front. I do however get a number of warnings when I comment out the #include <linux/pci-aspm.h> in r8168_n.c (different issue).

@simonbcn
Copy link

@simonbcn simonbcn commented Dec 3, 2019

@rockyprabowo the problem is that the sources in your repository are not up to date. The last version is 8.047.05 and in your repository the last version is 8.047.04.

@r900
Copy link

@r900 r900 commented Dec 22, 2019

@simonbcn 8.047.05 has the same problem, this little patch here helps for now: https://701200.bugs.gentoo.org/attachment.cgi?id=600406

@Erriez
Copy link

@Erriez Erriez commented Nov 28, 2021

Building with the applied fix results in build errors Debian 11.10 AMD64. Reason to build this driver from source is that the maximum link speed is 100Mbps and cannot be set to 1Gbps.

Manual source patch

# git diff
diff --git a/r8168-8.047.05/src/r8168_n.c b/r8168-8.047.05/src/r8168_n.c
index 1451d36..bf19c7b 100644
--- a/r8168-8.047.05/src/r8168_n.c
+++ b/r8168-8.047.05/src/r8168_n.c
@@ -56,7 +56,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/completion.h>
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) && LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
 #include <linux/pci-aspm.h>
 #endif
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,37)

The diff above is a workaround for the following build error:

Realtek-PCIe-GBE-NIC-Driver/r8168-8.047.05/src/r8168_n.c:60:10: fatal error: linux/pci-aspm.h: No such file or directory
   60 | #include <linux/pci-aspm.h>
      |          ^~~~~~~~~~~~~~~~~~

Rebuild with applied diff results in compile errors incompatible pointer type:

# sh autorun.sh 

Check old driver and unload it.
Build the module and install
/root/Realtek-PCIe-GBE-NIC-Driver/r8168-8.047.05/src/r8168_n.c: In function ‘rtl8168_proc_init’:
/root/Realtek-PCIe-GBE-NIC-Driver/r8168-8.047.05/src/r8168_n.c:1664:47: error: passing argument 4 of ‘proc_create_data’ from incompatible pointer type [-Werror=incompatible-pointer-types]
 1664 |                                               &rtl8168_proc_fops, f->show)) {
      |                                               ^~~~~~~~~~~~~~~~~~
      |                                               |
      |                                               const struct file_operations *
In file included from /root/Realtek-PCIe-GBE-NIC-Driver/r8168-8.047.05/src/r8168_n.c:86:
/usr/src/linux-headers-5.10.0-9-common/include/linux/proc_fs.h:106:13: note: expected ‘const struct proc_ops *’ but argument is of type ‘const struct file_operations *’
  106 |             const struct proc_ops *,
      |             ^~~~~~~~~~~~~~~~~~~~~~~
/root/Realtek-PCIe-GBE-NIC-Driver/r8168-8.047.05/src/r8168_n.c: At top level:
/root/Realtek-PCIe-GBE-NIC-Driver/r8168-8.047.05/src/r8168_n.c:25759:31: error: initialization of ‘void (*)(struct net_device *, unsigned int)’ from incompatible pointer type ‘void (*)(struct net_device *)’ [-Werror=incompatible-pointer-types]
25759 |         .ndo_tx_timeout     = rtl8168_tx_timeout,
      |                               ^~~~~~~~~~~~~~~~~~
/root/Realtek-PCIe-GBE-NIC-Driver/r8168-8.047.05/src/r8168_n.c:25759:31: note: (near initialization for ‘rtl8168_netdev_ops.ndo_tx_timeout’)
cc1: some warnings being treated as errors
make[4]: *** [/usr/src/linux-headers-5.10.0-9-common/scripts/Makefile.build:285: /root/Realtek-PCIe-GBE-NIC-Driver/r8168-8.047.05/src/r8168_n.o] Error 1
make[3]: *** [/usr/src/linux-headers-5.10.0-9-common/Makefile:1846: /root/Realtek-PCIe-GBE-NIC-Driver/r8168-8.047.05/src] Error 2
make[2]: *** [/usr/src/linux-headers-5.10.0-9-common/Makefile:185: __sub-make] Error 2
make[1]: *** [Makefile:140: modules] Error 2
make: *** [Makefile:40: modules] Error 2

Show link speed / driver

# uname -a
Linux htpc 5.10.0-9-amd64 #1 SMP Debian 5.10.70-1 (2021-09-30) x86_64 GNU/Linux


# ethtool enp3s0
Settings for enp3s0:
    Supported ports: [ TP     MII ]
    Supported link modes:   10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Half 1000baseT/Full
    Supported pause frame use: Symmetric Receive-only
    Supports auto-negotiation: Yes
    Supported FEC modes: Not reported
    Advertised link modes:  10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Half 1000baseT/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 Receive-only
    Link partner advertised auto-negotiation: Yes
    Link partner advertised FEC modes: Not reported
    Speed: 100Mb/s
    Duplex: Full
    Auto-negotiation: on
    master-slave cfg: preferred slave
    master-slave status: slave
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: external
    MDI-X: Unknown
    Supports Wake-on: pumbg
    Wake-on: d
    Link detected: yes


# ethtool -i enp3s0
driver: r8169
version: 5.10.0-9-amd64
firmware-version: 
expansion-rom-version: 
bus-info: 0000:03:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no


# apt install lshw
# lshw -class network
  *-network                 
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: enp3s0
       version: 03
       serial: 00:26:18:xx:xx:xx
       size: 100Mbit/s
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list rom ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.10.0-9-amd64 duplex=full ip=192.168.0.167 latency=0 link=yes multicast=yes port=twisted pair speed=100Mbit/s
       resources: irq:19 ioport:e800(size=256) memory:f8fff000-f8ffffff memory:f8ff8000-f8ffbfff memory:fbff0000-fbffffff


# modprobe r8168
modprobe: FATAL: Module r8168 not found in directory /lib/modules/5.10.0-9-amd64

# modprobe r8169
    No output

Any suggestion how to proceed? Thanks!

@Erriez
Copy link

@Erriez Erriez commented Nov 28, 2021

@rockyprabowo the problem is that the sources in your repository are not up to date. The last version is 8.047.05 and in your repository the last version is 8.047.04.

Ouch, wasted a lot of time on this out dated repository. The official Realtek Ethernet driver v8.049.02 `GBE Ethernet LINUX driver r8168 for kernel up to 5.6 works:

# tar xvf r8168-8.049.02.tar.bz2
# cd r8168-8.049/

Follow README

# sh autorun.sh


# ethtool enp3s0
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:  10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/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
	                                     1000baseT/Half 1000baseT/Full
	Link partner advertised pause frame use: Symmetric Receive-only
	Link partner advertised auto-negotiation: Yes
	Link partner advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Auto-negotiation: on
	Port: Twisted Pair
	PHYAD: 0
	Transceiver: internal
	MDI-X: Unknown
	Supports Wake-on: pumbg
	Wake-on: g
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
	Link detected: yes

Problem solved: Linkspeed 1Gbps can be forced or autonegotiation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants