GithubHelp home page GithubHelp logo

mtorromeo / r8168 Goto Github PK

View Code? Open in Web Editor NEW
233.0 19.0 77.0 733 KB

Linux device driver for Realtek Ethernet controllers (unofficial mirror)

Home Page: https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software

Shell 0.14% C 99.35% Makefile 0.52%

r8168's Introduction

<Linux device driver for Realtek Ethernet controllers>

	This is the Linux device driver released for RealTek Gigabit Ethernet controllers with PCI-Express interface.

<Requirements>

	- Kernel source tree (supported Linux kernel 2.6.x and 2.4.x)
	- For linux kernel 2.4.x, this driver supports 2.4.20 and latter.
	- Compiler/binutils for kernel compilation

<Quick install with proper kernel settings>
	Unpack the tarball :
		# tar vjxf r8168-8.aaa.bb.tar.bz2

	Change to the directory:
		# cd r8168-8.aaa.bb

	If you are running the target kernel, then you should be able to do :

		# ./autorun.sh	(as root or with sudo)

	You can check whether the driver is loaded by using following commands.

		# lsmod | grep r8168
		# ifconfig -a

	If there is a device name, ethX, shown on the monitor, the linux
	driver is loaded. Then, you can use the following command to activate
	the ethX.

		# ifconfig ethX up

		,where X=0,1,2,...

<Set the network related information>
	1. Set manually
		a. Set the IP address of your machine.

			# ifconfig ethX "the IP address of your machine"

		b. Set the IP address of DNS.

		   Insert the following configuration in /etc/resolv.conf.

			nameserver "the IP address of DNS"

		c. Set the IP address of gateway.

			# route add default gw "the IP address of gateway"

	2. Set by doing configurations in /etc/sysconfig/network-scripts
	   /ifcfg-ethX for Redhat and Fedora, or /etc/sysconfig/network
	   /ifcfg-ethX for SuSE. There are two examples to set network
	   configurations.

		a. Fixed IP address:
			DEVICE=eth0
			BOOTPROTO=static
			ONBOOT=yes
			TYPE=ethernet
			NETMASK=255.255.255.0
			IPADDR=192.168.1.1
			GATEWAY=192.168.1.254
			BROADCAST=192.168.1.255

		b. DHCP:
			DEVICE=eth0
			BOOTPROTO=dhcp
			ONBOOT=yes

<Modify the MAC address>
	There are two ways to modify the MAC address of the NIC.
	1. Use ifconfig:

		# ifconfig ethX hw ether YY:YY:YY:YY:YY:YY

	   ,where X is the device number assigned by Linux kernel, and
		  YY:YY:YY:YY:YY:YY is the MAC address assigned by the user.

	2. Use ip:

		# ip link set ethX address YY:YY:YY:YY:YY:YY

	   ,where X is the device number assigned by Linux kernel, and
		  YY:YY:YY:YY:YY:YY is the MAC address assigned by the user.

<Force Link Status>

	1. Force the link status when insert the driver.

	   If the user is in the path ~/r8168, the link status can be forced
	   to one of the 5 modes as following command.

		# insmod ./src/r8168.ko speed=SPEED_MODE duplex=DUPLEX_MODE autoneg=NWAY_OPTION

		,where
			SPEED_MODE	= 1000	for 1000Mbps
					= 100	for 100Mbps
					= 10	for 10Mbps
			DUPLEX_MODE	= 0	for half-duplex
					= 1	for full-duplex
			NWAY_OPTION	= 0	for auto-negotiation off (true force)
					= 1	for auto-negotiation on (nway force)
		For example:

			# insmod ./src/r8168.ko speed=100 duplex=0 autoneg=1

		will force PHY to operate in 100Mpbs Half-duplex(nway force).

	2. Force the link status by using ethtool.
		a. Insert the driver first.
		b. Make sure that ethtool exists in /sbin.
		c. Force the link status as the following command.

			# ethtool -s ethX speed SPEED_MODE duplex DUPLEX_MODE autoneg NWAY_OPTION

			,where
				SPEED_MODE	= 1000	for 1000Mbps
						= 100	for 100Mbps
						= 10	for 10Mbps
				DUPLEX_MODE	= half	for half-duplex
						= full	for full-duplex
				NWAY_OPTION	= off	for auto-negotiation off (true force)
						= on	for auto-negotiation on (nway force)

		For example:

			# ethtool -s eth0 speed 100 duplex full autoneg on

		will force PHY to operate in 100Mpbs Full-duplex(nway force).

<Jumbo Frame>
	Transmitting Jumbo Frames, whose packet size is bigger than 1500 bytes, please change mtu by the following command.

	# ifconfig ethX mtu MTU

	, where X=0,1,2,..., and MTU is configured by user.

	RTL8168B/8111B supports Jumbo Frame size up to 4 kBytes.
	RTL8168C/8111C and RTL8168CP/8111CP support Jumbo Frame size up to 6 kBytes.
	RTL8168D/8111D supports Jumbo Frame size up to 9 kBytes.

r8168's People

Contributors

mtorromeo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

r8168's Issues

Fix for PopOS latest kernel 6.1.11 compile failure

Remove the last parameter weight in r8168.h to make the module compile with PopOS 6.1.11

6.1.11-76060111-generic #202302091138~1675975749~22.04~f771a7f SMP PREEMPT_DYNAMIC Thu F x86_64 x86_64 x86_64 GNU/Linux

-#define RTL_NAPI_CONFIG(ndev, priv, function, weight)   netif_napi_add(ndev, &priv->napi, function, weight)
+#define RTL_NAPI_CONFIG(ndev, priv, function, weight)   netif_napi_add(ndev, &priv->napi, function)

Connectivity issues after waking up

Using built-in into kernel r8169 module, I had issues with interface literally being unreachable / missing / semi-non-visible to the system iff laptop is working on batteries and Ethernet twisted pair was unplugged and plugged back in.

Module r8168 solves the "battery curse" it seems. But now I have another problem.

After waking up from sleeping state (definitely not hibernate — never tried that one), I'm loosing connectivity on the port. Symptoms are similar. While NetworkManager attempts to establish a connection, dmesg -w shows this line after a certain timeout:

[44819.574442] r8168: enp3s0: link up
[44819.606748] __common_interrupt: 2.36 No irq handler for vector
[44820.597876] r8168: enp3s0: link down
[44822.667766] r8168: enp3s0: link up
[44822.681759] __common_interrupt: 2.36 No irq handler for vector

Demonstration on a video:
Realtek r8168 connectivity issue after waking up

Forgot to show that on a video, but here's an output of ethtool as well:

❯ # woke up after sleep
❯ sudo 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:  100baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: Unknown!
        Duplex: Unknown! (255)
        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: no

❯ # Connecting cable...
❯ sudo 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
        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

Realtek, pls fix

Extra patch for K5.18x

I've generated this extra patch for kernel-5.18-rc2. It works after applying the k5.17 patch. Apply it directly to the file r8168_n.c.

--- r8168_n.c	2022-04-06 22:48:33.303337717 +0100
+++ r8168_n.c	2022-04-13 20:34:11.313345468 +0100
@@ -3665,7 +3665,7 @@
         txd->opts2 = 0;
         while (1) {
                 memset(tmpAddr, pattern++, len - 14);
-                pci_dma_sync_single_for_device(tp->pci_dev,
+                dma_sync_single_for_device(&tp->pci_dev->dev,
                                                le64_to_cpu(mapping),
                                                len, DMA_TO_DEVICE);
                 txd->opts1 = cpu_to_le32(DescOwn | FirstFrag | LastFrag | len);
@@ -3693,7 +3693,7 @@
                 if (rx_len == len) {
                         dma_sync_single_for_cpu(tp_to_dev(tp), le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
                         i = memcmp(skb->data, rx_skb->data, rx_len);
-                        pci_dma_sync_single_for_device(tp->pci_dev, le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
+                        dma_sync_single_for_device(&tp->pci_dev->dev, le64_to_cpu(rxd->addr), tp->rx_buf_sz, DMA_FROM_DEVICE);
                         if (i == 0) {
 //              dev_printk(KERN_INFO, tp_to_dev(tp), "loopback test finished\n",rx_len,len);
                                 break;
@@ -25164,11 +25164,11 @@
 
         if ((sizeof(dma_addr_t) > 4) &&
             use_dac &&
-            !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
-            !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
+            !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
+            !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
                 dev->features |= NETIF_F_HIGHDMA;
         } else {
-                rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+                rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
                 if (rc < 0) {
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
                         if (netif_msg_probe(tp))

module r8168 uses symbol <blah> from namespace <blah>, but does not import it

Compiling the latest version of this code against the latest kernel produces numerous warnings formatted as in the title of this issue. A portion of the standard compilation output:

WARNING: module r8168 uses symbol __x86_indirect_thunk_r11 from namespace _/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pci_read_config_dword from namespace eps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol eth_type_trans from namespace .o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol proc_get_parent_data from namespace deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pskb_expand_head from namespace : $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol __fentry__ from namespace tool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol netdev_err from namespace tool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pci_unregister_driver from namespace eps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol _raw_spin_lock_irqsave from namespace ps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol net_ratelimit from namespace l.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pci_set_power_state from namespace (deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol remove_proc_subtree from namespace (deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol proc_create_data from namespace : $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pci_clear_mwi from namespace l.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol seq_lseek from namespace ltool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol kfree from namespace c/rtltool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol memcpy from namespace /rtltool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pci_request_regions from namespace (deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pci_disable_msi from namespace o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol iounmap from namespace rtltool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol dma_direct_sync_single_for_device from namespace /r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol __pci_register_driver from namespace eps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol unregister_netdev from namespace  $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pci_choose_state from namespace : $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol consume_skb from namespace ool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol netdev_update_features from namespace ps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol rtnl_is_locked from namespace .o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol __napi_alloc_skb from namespace : $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol skb_tstamp_tx from namespace l.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol skb_put from namespace rtltool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pci_enable_device from namespace  $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol _copy_from_user from namespace o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol param_ops_ulong from namespace o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol param_ops_uint from namespace .o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol dma_ops from namespace rtltool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol device_set_wakeup_enable from namespace _/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol free_irq from namespace tltool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol pci_save_state from namespace .o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol strcpy from namespace /rtltool.o: $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.
WARNING: module r8168 uses symbol alloc_etherdev_mqs from namespace $(deps_/usr/src/r8168/src/rtltool.o), but does not import it.

This happens after commenting out the inclusion of linux/pci-aspm.h to fix the issue noted in #19 (comment) (the compilation errors out without that modification).

Version 8.042 - Build error for 2.6.32 kernel

Build for Proxmox 3.4 with kernel 2.6.32-46-pve:

root@proxmox:~/build/r8168-8.042/src# make all KERNELDIR=/lib/modules/2.6.32-46-pve/build
find: `/lib/modules/2.6.32-39-pve/kernel/drivers/net/ethernet': No such file or directory
make -C /lib/modules/2.6.32-46-pve/build SUBDIRS=/root/build/r8168-8.042/src clean
expr: syntax error
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-46-pve'
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-46-pve'
make -C /lib/modules/2.6.32-46-pve/build SUBDIRS=/root/build/r8168-8.042/src modules
expr: syntax error
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-46-pve'
  CC [M]  /root/build/r8168-8.042/src/r8168_n.o
/root/build/r8168-8.042/src/r8168_n.c: In function ‘rtl8168_init_one’:
/root/build/r8168-8.042/src/r8168_n.c:22792:20: error: ‘struct net_device’ has no member named ‘hw_features’
/root/build/r8168-8.042/src/r8168_n.c:22793:20: error: ‘struct net_device’ has no member named ‘hw_features’
/root/build/r8168-8.042/src/r8168_n.c:22796:28: error: ‘struct net_device’ has no member named ‘hw_features’
/root/build/r8168-8.042/src/r8168_n.c:22803:28: error: ‘struct net_device’ has no member named ‘hw_features’
/root/build/r8168-8.042/src/r8168_n.c: In function ‘rtl8168_hw_config’:
/root/build/r8168-8.042/src/r8168_n.c:23221:24: error: ‘struct net_device’ has no member named ‘hw_features’
make[2]: *** [/root/build/r8168-8.042/src/r8168_n.o] Error 1
make[1]: *** [_module_/root/build/r8168-8.042/src] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-46-pve'
make: *** [modules] Error 2

Version 8.041 builds fine.

Error building in new versions

On trying to compile it in Debian with:
Linux Atenea 4.16.0-2-amd64 #1 SMP Debian 4.16.16-2 (2018-06-22) x86_64 GNU/Linux

I get this:
#./autorun.sh

Check old driver and unload it.
Build the module and install
/root/tarjetaeth/r8168/src/r8168_n.c: In function ‘rtl8168_request_esd_timer’:
/root/tarjetaeth/r8168/src/r8168_n.c:22967:9: error: implicit declaration of function ‘setup_timer’; did you mean ‘sk_stop_timer’? [-Werror=implicit-function-declaration]
setup_timer(timer, rtl8168_esd_timer, (unsigned long)dev);
^~~~~~~~~~~
sk_stop_timer
cc1: some warnings being treated as errors
make[5]: *** [/root/tarjetaeth/r8168/src/r8168_n.o] Error 1
make[4]: *** [module/root/tarjetaeth/r8168/src] Error 2
make[3]: *** [sub-make] Error 2
make[2]: *** [all] Error 2
make[1]: *** [modules] Error 2
make: *** [modules] Error 2

Maybe timer.h is missing?

Specify the license

If I am correct, this is all GPL2. You should upload the license so that people know that, as iirc doing so is legally required.

-Werror=incompatible-pointer-types in Linux v5.5

With the very latest version 5.5 of the kernel I am getting

/root/repos/r8168/src/r8168_n.c: In function ‘rtl8168_proc_init’:
/root/repos/r8168/src/r8168_n.c:1670:47: error: passing argument 4 of ‘proc_create_data’ from incompatible pointer type [-Werror=incompatible-pointer-types]
                                               &rtl8168_proc_fops, f->show)) {
                                               ^
In file included from /root/repos/r8168/src/r8168_n.c:92:0:
./include/linux/proc_fs.h:59:31: note: expected ‘const struct proc_ops *’ but argument is of type ‘const struct file_operations *’
 extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
                               ^~~~~~~~~~~~~~~~
/root/repos/r8168/src/r8168_n.c: At top level:
/root/repos/r8168/src/r8168_n.c:25821:31: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
         .ndo_tx_timeout     = rtl8168_tx_timeout,
                               ^~~~~~~~~~~~~~~~~~
/root/repos/r8168/src/r8168_n.c:25821:31: note: (near initialization for ‘rtl8168_netdev_ops.ndo_tx_timeout’)
cc1: some warnings being treated as errors
scripts/Makefile.build:265: recipe for target '/root/repos/r8168/src/r8168_n.o' failed
make[3]: *** [/root/repos/r8168/src/r8168_n.o] Error 1
Makefile:1681: recipe for target '/root/repos/r8168/src' failed
make[2]: *** [/root/repos/r8168/src] Error 2
make[2]: Leaving directory '/root/repos/linux'
Makefile:142: recipe for target 'modules' failed
make[1]: *** [modules] Error 2
make[1]: Leaving directory '/root/repos/r8168/src'
Makefile:40: recipe for target 'modules' failed
make: *** [modules] Error 2

It would appear a struct type has changed in /include/linux/proc_fs.h, from file_operations to proc_ops or some such thing.

Error! Bad return status for module build on kernel: 5.18.0-zen1-1-zen (x86_64)

I received the error in the title of this issue upon doing a full system upgrade on Garuda Linux (an Arch derivative). The kernel upgrade output also provided this line:

Consult /var/lib/dkms/r8168/8.050.02/build/make.log for more information.

The contents of the log file in question:

DKMS make.log for r8168-8.050.02 for kernel 5.18.0-zen1-1-zen (x86_64)
Sun May 29 14:52:40 MDT 2022
make: Entering directory '/usr/lib/modules/5.18.0-zen1-1-zen/build'
  CC [M]  /var/lib/dkms/r8168/8.050.02/build/src/r8168_n.o
  CC [M]  /var/lib/dkms/r8168/8.050.02/build/src/r8168_asf.o
  CC [M]  /var/lib/dkms/r8168/8.050.02/build/src/rtl_eeprom.o
  CC [M]  /var/lib/dkms/r8168/8.050.02/build/src/rtltool.o
/var/lib/dkms/r8168/8.050.02/build/src/r8168_n.c: In function  ^`^xrtl8168_mac_loopback_test ^`^y:
/var/lib/dkms/r8168/8.050.02/build/src/r8168_n.c:3701:17: error: implicit declaration of function  ^`^xpci_dma_sync_single_for_device ^`^y; did you mean  ^`^xdma_sync_single_for_device ^`^y? [-Werror=implicit-fun>
 3701 |                 pci_dma_sync_single_for_device(tp->pci_dev,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                 dma_sync_single_for_device
/var/lib/dkms/r8168/8.050.02/build/src/r8168_n.c: In function  ^`^xrtl8168_init_board ^`^y:
/var/lib/dkms/r8168/8.050.02/build/src/r8168_n.c:26411:14: error: implicit declaration of function  ^`^xpci_set_dma_mask ^`^y [-Werror=implicit-function-declaration]
26411 |             !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
      |              ^~~~~~~~~~~~~~~~
/var/lib/dkms/r8168/8.050.02/build/src/r8168_n.c:26412:14: error: implicit declaration of function  ^`^xpci_set_consistent_dma_mask ^`^y [-Werror=implicit-function-declaration]
26412 |             !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[1]: *** [scripts/Makefile.build:288: /var/lib/dkms/r8168/8.050.02/build/src/r8168_n.o] Error 1
make: *** [Makefile:1829: /var/lib/dkms/r8168/8.050.02/build/src] Error 2
make: Leaving directory '/usr/lib/modules/5.18.0-zen1-1-zen/build'

Let me know if there's any more information I can provide.

[PATCH] Add support for building against an arbitrary kernel version

This diff adds support to build against an arbitrary kernel version, not just the current running version.

Existing behavior is maintained, both of these work:

  • ./autorun.sh
  • ./autorun.sh 5.4.13-1.el7.elrepo.x86_64
diff --git a/autorun.sh b/autorun.sh
index 2c8ce76..d2f09c5 100755
--- a/autorun.sh
+++ b/autorun.sh
@@ -4,12 +4,20 @@
 # invoke insmod with all arguments we got
 # and use a pathname, as insmod doesn't look in . by default
 
-TARGET_PATH=$(find /lib/modules/$(uname -r)/kernel/drivers/net/ethernet -name realtek -type d)
+KVER=$1
+
+if [ -n "$KVER" ]; then
+	shift;
+else
+	KVER=`uname -r`
+fi
+
+TARGET_PATH=$(find /lib/modules/$KVER/kernel/drivers/net/ethernet -name realtek -type d)
 if [ "$TARGET_PATH" = "" ]; then
-	TARGET_PATH=$(find /lib/modules/$(uname -r)/kernel/drivers/net -name realtek -type d)
+	TARGET_PATH=$(find /lib/modules/$KVER/kernel/drivers/net -name realtek -type d)
 fi
 if [ "$TARGET_PATH" = "" ]; then
-	TARGET_PATH=/lib/modules/$(uname -r)/kernel/drivers/net
+	TARGET_PATH=/lib/modules/$KVER/kernel/drivers/net
 fi
 echo
 echo "Check old driver and unload it."
@@ -28,7 +36,7 @@ fi
 echo "Build the module and install"
 echo "-------------------------------" >> log.txt
 date 1>>log.txt
-make $@ all 1>>log.txt || exit 1
+make -C /lib/modules/$KVER/build M=`pwd`/src $@ modules modules_install | tee log.txt || exit 1
 module=`ls src/*.ko`
 module=${module#src/}
 module=${module%.ko}
@@ -54,8 +62,8 @@ elif [ "$module" != "r8169" ]; then
 	fi
 fi
 
-echo "DEPMOD $(uname -r)"
-depmod `uname -r`
+echo "DEPMOD $KVER"
+depmod `echo $KVER`
 echo "load module $module"
 modprobe $module
 
@@ -75,7 +83,7 @@ fi
 if [ "$is_update_initramfs" = "y" ]; then
 	if which update-initramfs >/dev/null ; then
 		echo "Updating initramfs. Please wait."
-		update-initramfs -u -k $(uname -r)
+		update-initramfs -u -k $KVER
 	else
 		echo "update-initramfs: command not found"
 		exit 1

Kernel 5.10 breaks r8168

i'm using linux 5.10.16.arch1-1 (x86_64) and it broke my network after upgrade, switching my kernel to linux-lts and using r8168-lts (8.048.03-61) didn't help. i was previously using r8168 (8.048.03-63) but i don't think i can install the package without having to install linux (kernel 5.10.16). Don't know if it only happened to me but r.i.p my linux :'(. Waiting for an update i guess.

Trisquel 7 RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 03) - Not connecting

I don't know if this team is responsable for driver creation/aprimoration. Now 2021, I've the same problem from a long time ago, getting to be solved over updates. My RTL ethernet (rev 03) not connecting, even I specify static IP and parameters. I've tried many instructions, but the problem still happens.

Version installed (from source): r8168-8.048.03 #Blacklist includes r8169 restriction.
Kernel: 4.15.0-144-generic #148+9.0trisquel7 i686 i686 i686 GNU/Linux.

I've tried Lubuntu system. Same thing. Keeping 32 bits for an old system, as a storage machine.

$ lsmod -v
r8168                 532480  0
$ lspci -v
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 03)
    Subsystem: Realtek Semiconductor Co., Ltd. RTL8111/8168 PCI Express Gigabit Ethernet controller
    Flags: bus master, fast devsel, latency 0, IRQ 24
    I/O ports at ec00 [size=256]
    Memory at dffff000 (64-bit, prefetchable) [size=4K]
    Memory at dfff8000 (64-bit, prefetchable) [size=16K]
    Expansion ROM at febe0000 [disabled] [size=128K]
    Capabilities: <access denied>
    Kernel driver in use: r8168
    Kernel modules: r8168
$ ifconfig
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 70:71:bc:37:e3:3f  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 24  base 0xe000 
$ modinfo r8168
filename:       /lib/modules/4.15.0-144-generic/kernel/drivers/net/ethernet/realtek/r8168.ko
version:        8.048.03-NAPI
license:        GPL
description:    RealTek RTL-8168 Gigabit Ethernet driver
author:         Realtek and the Linux r8168 crew <[email protected]>
srcversion:     3D290B8867C584C2920F0E4
alias:          pci:v00001186d00004300sv00001186sd00004B10bc*sc*i*
alias:          pci:v000010ECd00002600sv*sd*bc*sc*i*
alias:          pci:v000010ECd00002502sv*sd*bc*sc*i*
alias:          pci:v000010ECd00008161sv*sd*bc*sc*i*
alias:          pci:v000010ECd00008168sv*sd*bc*sc*i*
depends:        
retpoline:      Y
name:           r8168
vermagic:       4.15.0-144-generic SMP mod_unload modversions 686 
parm:           speed_mode:force phy operation. Deprecated by ethtool (8). (uint)
parm:           duplex_mode:force phy operation. Deprecated by ethtool (8). (uint)
parm:           autoneg_mode:force phy operation. Deprecated by ethtool (8). (uint)
parm:           advertising_mode:force phy operation. Deprecated by ethtool (8). (uint)
parm:           aspm:Enable ASPM. (int)
parm:           s5wol:Enable Shutdown Wake On Lan. (int)
parm:           s5_keep_curr_mac:Enable Shutdown Keep Current MAC Address. (int)
parm:           rx_copybreak:Copy breakpoint for copy-only-tiny-frames (int)
parm:           use_dac:Enable PCI DAC. Unsafe on 32 bit PCI slot. (int)
parm:           timer_count:Timer Interrupt Interval. (int)
parm:           eee_enable:Enable Energy Efficient Ethernet. (int)
parm:           hwoptimize:Enable HW optimization function. (ulong)
parm:           s0_magic_packet:Enable S0 Magic Packet. (int)
parm:           debug:Debug verbosity level (0=none, ..., 16=all) (int)
$ ethtool -i enp2s0
driver: r8168
version: 8.048.03-NAPI
firmware-version: 
expansion-rom-version: 
bus-info: 0000:02:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no

Ping for this ethernet is not getting feedback, even with static IP address that appears active on router. When dynamic IP, because ethernet try many times to connect, it stops for failure. I used another cable modem, but nothing changed. I think is something related to "Download" negotiation. Before this OS, I had used Windows 10 and ethernet was ok, no problem. But my system needs light OS as Trisquel or Lubuntu. I've used deb package from Trisquel pool tree, available on source website, v8.048.00, but nothing changed and same information as before, of course different verbose for version.

Ubuntu + kernel 4.4.0-105 - link up but network no go

Just for information.

OS: Ubuntu Linux 14.04
Kernel: HWE 4.4.0-105-generic
Driver version: r8168-8.045.08
Build: dkms

Hub (d-link) diod light up. But there is no network - system can't get IP via DHCP.
Or even link not found after reboot.

After apt-get purge r8168-dkms and write r8169 to /etc/modules and update-iniramfs -u and reboot - network is back on-line.

Compilation error on Linux 5.2.17 (error: implicit declaration of function ‘synchronize_sched’; did you mean ‘synchronize_net’)

The (presumably latest) r8168 version fails on a recent 5.2.x kernel when compiling r8168_n.c with the following message –

make -C src/ modules
make: Entering directory '/root/realtek/r8168-8.046.00/src'
make -C /lib/modules/5.2.17.a-1-hardened-arch-atom/build SUBDIRS=/root/realtek/r8168-8.046.00/src modules
make[1]: Entering directory '/home/martin/abs/core/linux-hardened/newer/src/linux-5.2.17'
Makefile:213: ================= WARNING ================
Makefile:214: 'SUBDIRS' will be removed after Linux 5.3
Makefile:215: Please use 'M=' or 'KBUILD_EXTMOD' instead
Makefile:216: ==========================================
  CC [M]  /root/realtek/r8168-8.046.00/src/r8168_n.o
/root/realtek/r8168-8.046.00/src/r8168_n.c: In function ‘rtl8168_down’:
/root/realtek/r8168-8.046.00/src/r8168_n.c:28376:9: error: implicit declaration of function ‘synchronize_sched’; did you mean ‘synchronize_net’? [-Werror=implicit-function-declaration]
28376 |         synchronize_sched();  /* FIXME: should this be synchronize_irq()? */
      |         ^~~~~~~~~~~~~~~~~
      |         synchronize_net
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:279: /root/realtek/r8168-8.046.00/src/r8168_n.o] Error 1
make[1]: *** [Makefile:1597: _module_/root/realtek/r8168-8.046.00/src] Error 2
make[1]: Leaving directory '/home/martin/abs/core/linux-hardened/newer/src/linux-5.2.17'
make: *** [Makefile:104: modules] Error 2
make: Leaving directory '/root/realtek/r8168-8.046.00/src'

Another error occurs when replacing the call to the synchronize_sched() function with synchronize_irc() (as suggested by the code comment) –

make -C src/ modules
make: Entering directory '/root/realtek/r8168-8.046.00/src'
make -C /lib/modules/5.2.17.a-1-hardened-arch-atom/build SUBDIRS=/root/realtek/r8168-8.046.00/src modules
make[1]: Entering directory '/home/martin/abs/core/linux-hardened/newer/src/linux-5.2.17'
Makefile:213: ================= WARNING ================
Makefile:214: 'SUBDIRS' will be removed after Linux 5.3
Makefile:215: Please use 'M=' or 'KBUILD_EXTMOD' instead
Makefile:216: ==========================================
  CC [M]  /root/realtek/r8168-8.046.00/src/r8168_n.o
/root/realtek/r8168-8.046.00/src/r8168_n.c: In function ‘rtl8168_down’:
/root/realtek/r8168-8.046.00/src/r8168_n.c:28376:9: error: too few arguments to function ‘synchronize_irq’
28376 |         synchronize_irq();  /* FIXME: should this be synchronize_irq()? */
      |         ^~~~~~~~~~~~~~~
In file included from ./include/linux/interrupt.h:11,
                 from ./include/linux/pci.h:32,
                 from /root/realtek/r8168-8.046.00/src/r8168_n.c:40:
./include/linux/hardirq.h:12:13: note: declared here
   12 | extern void synchronize_irq(unsigned int irq);
      |             ^~~~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:279: /root/realtek/r8168-8.046.00/src/r8168_n.o] Error 1
make[1]: *** [Makefile:1597: _module_/root/realtek/r8168-8.046.00/src] Error 2
make[1]: Leaving directory '/home/martin/abs/core/linux-hardened/newer/src/linux-5.2.17'
make: *** [Makefile:104: modules] Error 2
make: Leaving directory '/root/realtek/r8168-8.046.00/src'

netlink error: link settings update failed netlink error: Invalid argument

Hi There,

I tried the command below, as per the README. But it does not work for me.

# ethtool -s enp3s0f2 speed 1000 autoneg off
netlink error: link settings update failed
netlink error: Invalid argument

I am using the following OS:

# cat /etc/os-release 
NAME="Linux Mint"
VERSION="21.3 (Virginia)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21.3"
VERSION_ID="21.3"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=virginia
UBUNTU_CODENAME=jammy

Any ideas?

Incidentally, the NIC is unable to negotiate 1000Mbps - it negotiates 100Mbps. I am on a GB router. Any ideas?

My ethtool shows the following:

# ethtool enp3s0f2 
Settings for enp3s0f2:
	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 <=== INCORRECT.  EXPECTED OUTPUT SHOULD INCLUDE: 1000baseT
	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
	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

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

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 <[email protected]>
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).

Kernel-5.17rc

I'm sorry but I forked your project and didn't intend to.
What I wanted was to check if you looked at compiling with the latest kernel.
It won't compile with k5.17 and although I've looked at it I don't know enough to get round the main changes.
Have you looked into it yet?
I have the error list in a differnt system and I can send you it if needed.
pete

Additional patch for K6.4.y+

dkms install produces error in src/r8168_n.c:

'skb_gso_reset'? [-Werror=implicit-function-declaration]
  432 |                 segs = skb_gso_segment(skb, features);
      |                               ^~~~~~~~~~~~~~~
      |                            skb_gso_reset

this patch fix it:

--- a/src/r8168_n.c     2023-08-13 03:33:06.977422132 +0400
+++ b/src/r8168_n.c     2023-08-13 03:38:39.767005101 +0400
@@ -81,6 +81,10 @@
 #include <linux/mdio.h>
 #endif

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,4,0)
+#include <net/gso.h>
+#endif
+
 #include <asm/io.h>
 #include <asm/irq.h>

same error found in discussion

the kernel source line with this function definition

Failed to build with Gentoo kernel 5.6.0

/home/tommy/r8168/src/r8168_n.c: In function ‘rtl8168_proc_init’:
/home/tommy/r8168/src/r8168_n.c:1670:47: error: passing argument 4 of ‘proc_create_data’ from incompatibl>
1670 | &rtl8168_proc_fops, f->show)) {
| ^~~~~~~~~~~~~~~~~~
| |
| const struct file_operations *
In file included from /home/tommy/r8168/src/r8168_n.c:92:
./include/linux/proc_fs.h:59:31: note: expected ‘const struct proc_ops *’ but argument is of type ‘const >
59 | extern struct proc_dir_entry *proc_create_data(const char , umode_t,
| ^~~~~~~~~~~~~~~~
/home/tommy/r8168/src/r8168_n.c: At top level:
/home/tommy/r8168/src/r8168_n.c:25821:31: error: initialization of ‘void (
)(struct net_device *, unsigne>
25821 | .ndo_tx_timeout = rtl8168_tx_timeout,
| ^~~~~~~~~~~~~~~~~~
/home/tommy/r8168/src/r8168_n.c:25821:31: note: (near initialization for ‘rtl8168_netdev_ops.ndo_tx_timeo>
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:268: /home/tommy/r8168/src/r8168_n.o] Error 1
make[2]: *** [Makefile:1685: /home/tommy/r8168/src] Error 2
make[1]: *** [Makefile:140: modules] Error 2
make: *** [Makefile:40: modules] Error 2

r8168 5.10.0-20-amd64 Debian KDE UI freezes and journal: eno1: esd_flag = 0x7bff ; eno1: cmd = 0xff, should be 0x07

Hello,

5.10.0-20-amd64 Debian 11 (stable) with KDE desktop (5.20.5)

$ sudo inxi -Na

Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet driver: N/A modules: r8168 port: N/A 
           bus ID: 03:00.1 chip ID: 10ec:8168 class ID: 0200
           Device-2: Realtek RTL8153 Gigabit Ethernet Adapter type: USB driver: r8152 bus ID: 3-4:3 chip ID: 0bda:8153 
           class ID: 0000 serial: 000001000000

(driver for device 1 not shown, because i ran inxi after removing it: sudo modprobe -r r8168;sudo apt remove r8169-dkms)

I have removed r8168 dkms because it repeatedly caused issue where computer UI (incl. mouse) was freezing every couple second with journal:

Jan 23 07:53:06 h0st kernel: r8168: eno1: link up
Jan 23 07:53:06 h0st kernel: eno1: esd_flag = 0x7bff
                           .
Jan 23 07:53:06 h0st kernel: eno1: pci_sn_h = 0xffffffff, should be 0x01000000 
                           .
Jan 23 07:53:06 h0st kernel: eno1: pci_sn_l = 0xffffffff, should be 0x684ce000 
                           .
Jan 23 07:53:06 h0st kernel: eno1: resv_0x2c_h = 0xffff, should be 0x872e 
                           .
Jan 23 07:53:06 h0st kernel: eno1: resv_0x2c_l = 0xffff, should be 0x103c 
                           .
Jan 23 07:53:06 h0st kernel: eno1: resv_0x24_h = 0xffff, should be 0x0000 
                           .
Jan 23 07:53:06 h0st kernel: eno1: resv_0x24_l = 0xffff, should be 0x0000 
                           .
Jan 23 07:53:06 h0st kernel: eno1: resv_0x20_h = 0xffff, should be 0xfc40 
                           .
Jan 23 07:53:06 h0st kernel: eno1: resv_0x20_l = 0xffff, should be 0x4004 
                           .
Jan 23 07:53:06 h0st kernel: eno1: resv_0x1c_h = 0xffff, should be 0x0000 
                           .
Jan 23 07:53:06 h0st kernel: eno1: resv_0x1c_l = 0xffff, should be 0x0000 
                           .
Jan 23 07:53:06 h0st kernel: eno1: mem_base_h = 0xffff, should be 0xfc41 
                           .
Jan 23 07:53:06 h0st kernel: eno1: mem_base_l = 0xffff, should be 0x1004 
                           .
Jan 23 07:53:06 h0st kernel: eno1: io_base_l = 0xffff, should be 0x2201 
                           .
Jan 23 07:53:06 h0st kernel: eno1: cmd = 0xff, should be 0x07

After unloading using modprobe as shown above, freezing stopped...

Signed Releases

Can we please have signed releases? A signed checksums file with the hashes for the release and source would be great. An end-user can't assume that data integrity has been preserved on an untrusted 3rd party platform, especially for something that is going to be the source of network access for their system. Thank you for your time and your hard work.

Same issue like with kernel's 8169 since last update

Means high latency in connecting to new addresses
Once a connection is established (after 10 to 30 sec) all seems to be normal.
But the next new address takes ages again.

RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller

Additional patch for K6.1-rc

Kernel 6.1-rc needs an additional patch:
`diff -Naur r8168.h r8168.h
--- r8168.h 2022-06-19 03:55:16.000000000 +0100
+++ r8168.h 2022-10-19 17:55:14.380161219 +0100
@@ -561,7 +561,11 @@
typedef struct napi_struct *napi_ptr;
typedef int napi_budget;

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
+#define RTL_NAPI_CONFIG(ndev, priv, function, weight) netif_napi_add(ndev, &priv->napi, function)
+#else
#define RTL_NAPI_CONFIG(ndev, priv, function, weight) netif_napi_add(ndev, &priv->napi, function, weight)
+#endif
#define RTL_NAPI_QUOTA(budget, ndev) min(budget, budget)
#define RTL_GET_PRIV(stuct_ptr, priv_struct) container_of(stuct_ptr, priv_struct, stuct_ptr)
#define RTL_GET_NETDEV(priv_ptr) struct net_device *dev = priv_ptr->dev;`

It also works with rc2.

ubuntu+kernel 4.13.13 : builtin r8169 works badly (mtu 576) but r6168 fully fails

From the Artful (17.10) archive package, r8168-dkms has been installed, the kernel is rebuilt as expected, but after rebooting the network is lost: cant ping !!!
I see that MTU is set to 1500, which is acceptable.
/etc/modprobe.d/r6168.dkms.conf does not blacklist r8169 by default; i've tested both cases, but still the same bad result: no network.

I have no idea to get it working; this is a r6168e chipset on a asrock mobo.
The logical name: enp2s0 , so is it a possible cause ? as its way different of the classic ethX name.

Dell G3 with ubuntu 18.04 gets 100Mbps only

hi,

With new kernel, my RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller gets only 100Mbps.

With the old one, gets Giga.

ethtool -s enp3s0 speed 1000 duplex full autoneg on dont work

Any idea?

create community branch

hello, I have been using this repository for some time and I am still trying to solve my problem with this driver, I understand that this repository is intended to be a mirror of official sources, but the community often offers improvements and bugfixes like #43 Add support to device or #47 Adapted for Linux 6.1 , I suggest so create a second branch 'community' to welcome them and leave the master branch as a mirror of the official versions

Error for kernel 3.10.0-1160.6.1.el7.x86_64

[root@docker-test r8168]# ./autorun.sh

Check old driver and unload it.
Build the module and install
In file included from /root/r8168/src/r8168_n.c:86:0:
/root/r8168/src/r8168.h:48:20: error: redefinition of ‘ether_addr_copy’
static inline void ether_addr_copy(u8 *dst, const u8 *src)
^
In file included from /root/r8168/src/r8168_n.c:46:0:
include/linux/etherdevice.h:246:20: note: previous definition of ‘ether_addr_copy’ was here
static inline void ether_addr_copy(u8 *dst, const u8 *src)
^
/root/r8168/src/r8168_n.c:25908:9: error: unknown field ‘ndo_change_mtu’ specified in initializer
.ndo_change_mtu = rtl8168_change_mtu,
^
/root/r8168/src/r8168_n.c:25908:9: warning: missing braces around initializer [-Wmissing-braces]
/root/r8168/src/r8168_n.c:25908:9: warning: (near initialization for ‘rtl8168_netdev_ops.’) [-Wmissing-braces]
/root/r8168/src/r8168_n.c:25908:9: warning: initialization from incompatible pointer type [enabled by default]
/root/r8168/src/r8168_n.c:25908:9: warning: (near initialization for ‘rtl8168_netdev_ops..ndo_get_stats64’) [enabled by default]
/root/r8168/src/r8168_n.c: In function ‘rtl8168_rx_interrupt’:
/root/r8168/src/r8168_n.c:28659:28: error: ‘struct net_device’ has no member named ‘last_rx’
dev->last_rx = jiffies;
^
make[3]: *** [/root/r8168/src/r8168_n.o] Error 1
make[2]: *** [module/root/r8168/src] Error 2
make[1]: *** [modules] Error 2
make: *** [modules] Error 2

Kernel-5.19-rc1 patch

I've a new patch for r8168_n.c with kernel-5.19.xx. I've only been able to test it on rc1 of course but it also works with kernel-5.18.2x.

--- r8168_n.c	2022-05-06 10:57:21.505281694 +0100
+++ r8168_n.c	2022-06-07 19:23:22.096066995 +0100
@@ -26834,7 +26834,11 @@
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
                 if ((tp->mcfg == CFG_METHOD_1) || (tp->mcfg == CFG_METHOD_2) || (tp->mcfg == CFG_METHOD_3)) {
                         dev->hw_features &= ~NETIF_F_IPV6_CSUM;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
+                        netif_set_tso_max_size(dev, LSO_32K);
+#else
                         netif_set_gso_max_size(dev, LSO_32K);
+#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
                         dev->gso_max_segs = NIC_MAX_PHYS_BUF_COUNT_LSO_64K;
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)
@@ -26848,7 +26852,11 @@
                                 dev->hw_features |= NETIF_F_TSO6;
                                 //dev->features |=  NETIF_F_TSO6;
                         }
-                        netif_set_gso_max_size(dev, LSO_64K);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
+                        netif_set_tso_max_size(dev, LSO_32K);
+#else
+                        netif_set_gso_max_size(dev, LSO_32K);
+#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
                         dev->gso_max_segs = NIC_MAX_PHYS_BUF_COUNT_LSO2;
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0)

AlmaLinux 9 Error

[root@gameserver r8168-8.051.02]# make clean modules
make -C src/ clean
make[1]: Entering directory '/home/download/r8168-8.051.02/src'
make -C /lib/modules/5.14.0-162.23.1.el9_1.x86_64/build M=/home/download/r8168-8.051.02/src clean
make[2]: Entering directory '/usr/src/kernels/5.14.0-162.23.1.el9_1.x86_64'
make[2]: Leaving directory '/usr/src/kernels/5.14.0-162.23.1.el9_1.x86_64'
make[1]: Leaving directory '/home/download/r8168-8.051.02/src'
make -C src/ modules
make[1]: Entering directory '/home/download/r8168-8.051.02/src'
make -C /lib/modules/5.14.0-162.23.1.el9_1.x86_64/build M=/home/download/r8168-8.051.02/src modules
make[2]: Entering directory '/usr/src/kernels/5.14.0-162.23.1.el9_1.x86_64'
CC [M] /home/download/r8168-8.051.02/src/r8168_n.o
/home/download/r8168-8.051.02/src/r8168_n.c: In function ‘rtl8168_proc_open’:
/home/download/r8168-8.051.02/src/r8168_n.c:1755:50: error: implicit declaration of function ‘PDE_DATA’; did you mean ‘NODE_DATA’? [-Werror=implicit-function-declaration]
1755 | int (*show)(struct seq_file *, void ) = PDE_DATA(inode);
| ^~~~~~~~
| NODE_DATA
/home/download/r8168-8.051.02/src/r8168_n.c:1755:50: warning: initialization of ‘int (
)(struct seq_file *, void )’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
/home/download/r8168-8.051.02/src/r8168_n.c: At top level:
/home/download/r8168-8.051.02/src/r8168_n.c:6839:31: error: initialization of ‘void (
)(struct net_device *, struct ethtool_ringparam *, struct kernel_ethtool_ringparam *, struct netlink_ext_ack )’ from incompatible pointer type ‘void ()(struct net_device *, struct ethtool_ringparam )’ [-Werror=incompatible-pointer-types]
6839 | .get_ringparam = rtl8168_get_ringparam,
| ^~~~~~~~~~~~~~~~~~~~~
/home/download/r8168-8.051.02/src/r8168_n.c:6839:31: note: (near initialization for ‘rtl8168_ethtool_ops.get_ringparam’)
/home/download/r8168-8.051.02/src/r8168_n.c:6840:31: error: initialization of ‘int (
)(struct net_device *, struct ethtool_ringparam *, struct kernel_ethtool_ringparam *, struct netlink_ext_ack )’ from incompatible pointer type ‘int ()(struct net_device *, struct ethtool_ringparam *)’ [-Werror=incompatible-pointer-types]
6840 | .set_ringparam = rtl8168_set_ringparam,
| ^~~~~~~~~~~~~~~~~~~~~
/home/download/r8168-8.051.02/src/r8168_n.c:6840:31: note: (near initialization for ‘rtl8168_ethtool_ops.set_ringparam’)
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:295: /home/download/r8168-8.051.02/src/r8168_n.o] Error 1
make[2]: *** [Makefile:1915: /home/download/r8168-8.051.02/src] Error 2
make[2]: Leaving directory '/usr/src/kernels/5.14.0-162.23.1.el9_1.x86_64'
make[1]: *** [Makefile:154: modules] Error 2
make[1]: Leaving directory '/home/download/r8168-8.051.02/src'
make: *** [Makefile:41: modules] Error 2

Error in Solus Budgie

$ sudo ./autorun.sh

Check old driver and unload it.
Build the module and install
/home/aps/Downloads/r8168-master/src/r8168_n.c: In function ‘rtl8168_proc_init’:
/home/aps/Downloads/r8168-master/src/r8168_n.c:1670:47: error: passing argument 4 of ‘proc_create_data’ from incompatible pointer type [-Werror=incompatible-pointer-types]
 1670 |                                               &rtl8168_proc_fops, f->show)) {
      |                                               ^~~~~~~~~~~~~~~~~~
      |                                               |
      |                                               const struct file_operations *
In file included from /home/aps/Downloads/r8168-master/src/r8168_n.c:92:
./include/linux/proc_fs.h:59:31: note: expected ‘const struct proc_ops *’ but argument is of type ‘const struct file_operations *’
   59 | extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
      |                               ^~~~~~~~~~~~~~~~
/home/aps/Downloads/r8168-master/src/r8168_n.c: At top level:
/home/aps/Downloads/r8168-master/src/r8168_n.c:25825:31: error: initialization of ‘void (*)(struct net_device *, unsigned int)’ from incompatible pointer type ‘void (*)(struct net_device *)’ [-Werror=incompatible-pointer-types]
25825 |         .ndo_tx_timeout     = rtl8168_tx_timeout,
      |                               ^~~~~~~~~~~~~~~~~~
/home/aps/Downloads/r8168-master/src/r8168_n.c:25825:31: note: (near initialization for ‘rtl8168_netdev_ops.ndo_tx_timeout’)
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:268: /home/aps/Downloads/r8168-master/src/r8168_n.o] Error 1
make[2]: *** [Makefile:1683: /home/aps/Downloads/r8168-master/src] Error 2
make[1]: *** [Makefile:140: modules] Error 2
make: *** [Makefile:40: modules] Error 2

Linux 6.9 compat: initialization of ‘int (*)(struct net_device *, struct ethtool_keee *)’ from incompatible pointer type ‘int (*)(struct net_device *, struct ethtool_eee *)

When trying to compile the driver for 6.9 kernel series it errors out with:

==> Starting build()...
make: Entering directory '/usr/lib/modules/6.9.0-rc7-1-MANJARO/build'
  CC [M]  /build/linux69-r8168/src/r8168-8.053.00/src/r8168_n.o
  CC [M]  /build/linux69-r8168/src/r8168-8.053.00/src/r8168_asf.o
  CC [M]  /build/linux69-r8168/src/r8168-8.053.00/src/rtl_eeprom.o
  CC [M]  /build/linux69-r8168/src/r8168-8.053.00/src/rtltool.o
  CC [M]  /build/linux69-r8168/src/r8168-8.053.00/src/r8168_firmware.o
/build/linux69-r8168/src/r8168-8.053.00/src/r8168_n.c:8126:20: error: initialization of ‘int (*)(struct net_device *, struct ethtool_keee *)’ from incompatible pointer type ‘int (*)(struct net_device *, struct ethtool_eee *)’ [-Werror=incompatible-pointer-types]
 8126 |         .get_eee = rtl_ethtool_get_eee,
      |                    ^~~~~~~~~~~~~~~~~~~
/build/linux69-r8168/src/r8168-8.053.00/src/r8168_n.c:8126:20: note: (near initialization for ‘rtl8168_ethtool_ops.get_eee’)
/build/linux69-r8168/src/r8168-8.053.00/src/r8168_n.c:8127:20: error: initialization of ‘int (*)(struct net_device *, struct ethtool_keee *)’ from incompatible pointer type ‘int (*)(struct net_device *, struct ethtool_eee *)’ [-Werror=incompatible-pointer-types]
 8127 |         .set_eee = rtl_ethtool_set_eee,
      |                    ^~~~~~~~~~~~~~~~~~~
/build/linux69-r8168/src/r8168-8.053.00/src/r8168_n.c:8127:20: note: (near initialization for ‘rtl8168_ethtool_ops.set_eee’)
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:244: /build/linux69-r8168/src/r8168-8.053.00/src/r8168_n.o] Error 1
make[1]: *** [/usr/lib/modules/6.9.0-rc7-1-MANJARO/build/Makefile:1919: /build/linux69-r8168/src/r8168-8.053.00/src] Error 2
make: *** [Makefile:240: __sub-make] Error 2
make: Leaving directory '/usr/lib/modules/6.9.0-rc7-1-MANJARO/build'
==> ERROR: A failure occurred in build().

Most likely this change is also here needed: torvalds/linux@031a239

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.