mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
package: add kmod-r8168 ethernet driver
r8168 is an out of tree driver provided by Realtek for RTL8168 devices. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> [Refresh our patch] Signed-off-by: AnYun <amadeus@openjmu.xyz>
This commit is contained in:
parent
1ba4b04f46
commit
0061cb8a1f
33
package/kernel/r8168/Makefile
Normal file
33
package/kernel/r8168/Makefile
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=r8168
|
||||||
|
PKG_VERSION:=8.053.00
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||||
|
PKG_SOURCE_URL:=https://github.com/openwrt/rtl8168/releases/download/$(PKG_VERSION)
|
||||||
|
PKG_HASH:=52f1e6200672b598a04d4ac21ac92a8a9e128b38208c7b03a464bfa93bbfcc8f
|
||||||
|
|
||||||
|
PKG_BUILD_PARALLEL:=1
|
||||||
|
PKG_LICENSE:=GPLv2
|
||||||
|
PKG_MAINTAINER:=Alvaro Fernandez Rojas <noltari@gmail.com>
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/kernel.mk
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
define KernelPackage/r8168
|
||||||
|
SUBMENU:=Network Devices
|
||||||
|
TITLE:=Realtek RTL8168 PCI Gigabit Ethernet driver
|
||||||
|
DEPENDS:=@PCI_SUPPORT +kmod-libphy
|
||||||
|
FILES:=$(PKG_BUILD_DIR)/src/r8168.ko
|
||||||
|
AUTOLOAD:=$(call AutoProbe,r8168)
|
||||||
|
PROVIDES:=kmod-r8169
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
+$(KERNEL_MAKE) $(PKG_JOBS) \
|
||||||
|
M="$(PKG_BUILD_DIR)/src" \
|
||||||
|
modules
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call KernelPackage,r8168))
|
@ -0,0 +1,28 @@
|
|||||||
|
From c0e1ae03f564f0e3db492ef2f25357b5da7977d7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
|
||||||
|
Date: Sat, 10 Aug 2024 20:12:40 +0200
|
||||||
|
Subject: [PATCH] r8168_n: fix proc_dump_rx_desc_2 on 32 bits
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
|
||||||
|
---
|
||||||
|
src/r8168_n.c | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
--- a/src/r8168_n.c
|
||||||
|
+++ b/src/r8168_n.c
|
||||||
|
@@ -1655,9 +1655,9 @@ static int proc_dump_rx_desc_2(struct se
|
||||||
|
j, k);
|
||||||
|
for (i=0; i<(tp->RxDescLength/4); i++) {
|
||||||
|
if (!(i % 4))
|
||||||
|
- seq_printf(m, "\n%04llx ",
|
||||||
|
- ((u64)pdword + (i * 4) -
|
||||||
|
- (u64)tp->RxDescArray));
|
||||||
|
+ seq_printf(m, "\n%04x ",
|
||||||
|
+ (u32) ((uintptr_t)pdword + (i * 4) -
|
||||||
|
+ (uintptr_t)tp->RxDescArray));
|
||||||
|
seq_printf(m, "%08x ", pdword[i]);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
From 0078930e0c374d327cd3281e5e2f7ff97b40b335 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
|
||||||
|
Date: Sun, 4 Aug 2024 16:15:12 +0800
|
||||||
|
Subject: [PATCH] r8168: print link speed and duplex mode
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Like other Ethernet drivers, print link speed and duplex mode
|
||||||
|
when the interface is up. Formatting output at the same time.
|
||||||
|
|
||||||
|
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
|
||||||
|
---
|
||||||
|
src/r8168.h | 2 ++
|
||||||
|
src/r8168_n.c | 44 +++++++++++++++++++++++++++++++++++++++++---
|
||||||
|
2 files changed, 43 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
--- a/src/r8168.h
|
||||||
|
+++ b/src/r8168.h
|
||||||
|
@@ -1385,6 +1385,8 @@ enum RTL8168_register_content {
|
||||||
|
LinkStatus = 0x02,
|
||||||
|
FullDup = 0x01,
|
||||||
|
|
||||||
|
+#define RTL8168_FULL_DUPLEX_MASK (_1000bpsF | FullDup)
|
||||||
|
+
|
||||||
|
/* DBG_reg */
|
||||||
|
Fix_Nak_1 = (1 << 4),
|
||||||
|
Fix_Nak_2 = (1 << 3),
|
||||||
|
--- a/src/r8168_n.c
|
||||||
|
+++ b/src/r8168_n.c
|
||||||
|
@@ -43,6 +43,7 @@
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/version.h>
|
||||||
|
#include <linux/pci.h>
|
||||||
|
+#include <linux/phy.h>
|
||||||
|
#include <linux/netdevice.h>
|
||||||
|
#include <linux/etherdevice.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
@@ -5373,6 +5374,36 @@ rtl8168_link_down_patch(struct net_devic
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
+static unsigned int rtl8168_phy_duplex(u8 status)
|
||||||
|
+{
|
||||||
|
+ unsigned int duplex = DUPLEX_UNKNOWN;
|
||||||
|
+
|
||||||
|
+ if (status & LinkStatus) {
|
||||||
|
+ if (status & RTL8168_FULL_DUPLEX_MASK)
|
||||||
|
+ duplex = DUPLEX_FULL;
|
||||||
|
+ else
|
||||||
|
+ duplex = DUPLEX_HALF;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return duplex;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int rtl8168_phy_speed(u8 status)
|
||||||
|
+{
|
||||||
|
+ int speed = SPEED_UNKNOWN;
|
||||||
|
+
|
||||||
|
+ if (status & LinkStatus) {
|
||||||
|
+ if (status & _1000bpsF)
|
||||||
|
+ speed = SPEED_1000;
|
||||||
|
+ else if (status & _100bps)
|
||||||
|
+ speed = SPEED_100;
|
||||||
|
+ else if (status & _10bps)
|
||||||
|
+ speed = SPEED_10;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return speed;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
rtl8168_check_link_status(struct net_device *dev)
|
||||||
|
{
|
||||||
|
@@ -5392,11 +5423,18 @@ rtl8168_check_link_status(struct net_dev
|
||||||
|
if (link_status_on) {
|
||||||
|
rtl8168_link_on_patch(dev);
|
||||||
|
|
||||||
|
- if (netif_msg_ifup(tp))
|
||||||
|
- printk(KERN_INFO PFX "%s: link up\n", dev->name);
|
||||||
|
+ if (netif_msg_ifup(tp)) {
|
||||||
|
+ const u8 phy_status = RTL_R8(tp, PHYstatus);
|
||||||
|
+ const unsigned int phy_duplex = rtl8168_phy_duplex(phy_status);
|
||||||
|
+ const int phy_speed = rtl8168_phy_speed(phy_status);
|
||||||
|
+ printk(KERN_INFO PFX "%s: Link is Up - %s/%s\n",
|
||||||
|
+ dev->name,
|
||||||
|
+ phy_speed_to_str(phy_speed),
|
||||||
|
+ phy_duplex_to_str(phy_duplex));
|
||||||
|
+ }
|
||||||
|
} else {
|
||||||
|
if (netif_msg_ifdown(tp))
|
||||||
|
- printk(KERN_INFO PFX "%s: link down\n", dev->name);
|
||||||
|
+ printk(KERN_INFO PFX "%s: Link is Down\n", dev->name);
|
||||||
|
|
||||||
|
rtl8168_link_down_patch(dev);
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
--- a/src/r8168_n.c
|
--- a/src/r8168_n.c
|
||||||
+++ b/src/r8168_n.c
|
+++ b/src/r8168_n.c
|
||||||
@@ -47,6 +47,7 @@
|
@@ -48,6 +48,7 @@
|
||||||
#include <linux/etherdevice.h>
|
#include <linux/etherdevice.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/mii.h>
|
#include <linux/mii.h>
|
||||||
@ -8,35 +8,30 @@
|
|||||||
#include <linux/if_vlan.h>
|
#include <linux/if_vlan.h>
|
||||||
#include <linux/crc32.h>
|
#include <linux/crc32.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
@@ -25945,6 +25946,22 @@ rtl8168_setup_mqs_reg(struct rtl8168_pri
|
@@ -25984,6 +25985,18 @@ rtl8168_setup_mqs_reg(struct rtl8168_pri
|
||||||
tp->imr_reg[3] = IntrMask3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+static int rtl8168_led_configuration(struct rtl8168_private *tp)
|
static void
|
||||||
|
+rtl8168_led_configuration(struct rtl8168_private *tp)
|
||||||
+{
|
+{
|
||||||
+ u32 led_data;
|
+ u32 led_data;
|
||||||
+ int ret;
|
+ int ret;
|
||||||
+
|
+
|
||||||
+ ret = of_property_read_u32(tp->pci_dev->dev.of_node,
|
+ ret = of_property_read_u32(tp->pci_dev->dev.of_node,
|
||||||
+ "realtek,led-data", &led_data);
|
+ "realtek,led-data", &led_data);
|
||||||
+
|
+ if (!ret)
|
||||||
+ if (ret)
|
+ RTL_W16(tp, CustomLED, led_data);
|
||||||
+ return ret;
|
|
||||||
+
|
|
||||||
+ RTL_W16(tp, CustomLED, led_data);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
static void
|
+static void
|
||||||
rtl8168_init_software_variable(struct net_device *dev)
|
rtl8168_init_software_variable(struct net_device *dev)
|
||||||
{
|
{
|
||||||
@@ -26640,6 +26657,8 @@ err1:
|
struct rtl8168_private *tp = netdev_priv(dev);
|
||||||
|
@@ -26678,6 +26691,7 @@ err1:
|
||||||
if (tp->InitRxDescType == RX_DESC_RING_TYPE_2)
|
if (tp->InitRxDescType == RX_DESC_RING_TYPE_2)
|
||||||
tp->RxDescLength = RX_DESC_LEN_TYPE_2;
|
tp->RxDescLength = RX_DESC_LEN_TYPE_2;
|
||||||
|
|
||||||
+ rtl8168_led_configuration(tp);
|
+ rtl8168_led_configuration(tp);
|
||||||
+
|
|
||||||
tp->NicCustLedValue = RTL_R16(tp, CustomLED);
|
tp->NicCustLedValue = RTL_R16(tp, CustomLED);
|
||||||
|
|
||||||
rtl8168_get_hw_wol(dev);
|
rtl8168_get_hw_wol(dev);
|
@ -1,38 +0,0 @@
|
|||||||
#
|
|
||||||
# Download realtek r8168 linux driver from official site:
|
|
||||||
# [https://www.realtek.com/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software]
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
|
||||||
include $(INCLUDE_DIR)/kernel.mk
|
|
||||||
|
|
||||||
PKG_NAME:=r8168
|
|
||||||
PKG_VERSION:=8.053.00
|
|
||||||
PKG_RELEASE:=1
|
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
|
||||||
PKG_SOURCE_URL:=https://codeload.github.com/mtorromeo/r8168/tar.gz/$(PKG_VERSION)?
|
|
||||||
PKG_HASH:=7c00cc13f17c45e1d1002e4c390f118204b04d42caba9d04d8ae95e953770857
|
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
|
||||||
|
|
||||||
define KernelPackage/r8168
|
|
||||||
TITLE:=Driver for Realtek r8168 chipsets
|
|
||||||
SUBMENU:=Network Devices
|
|
||||||
VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
|
|
||||||
FILES:= $(PKG_BUILD_DIR)/src/r8168.ko
|
|
||||||
AUTOLOAD:=$(call AutoProbe,r8168)
|
|
||||||
CONFLICTS:=kmod-r8169
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/r8168/description
|
|
||||||
This package contains a driver for Realtek r8168 chipsets.
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
+$(KERNEL_MAKE) M=$(PKG_BUILD_DIR)/src modules
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call KernelPackage,r8168))
|
|
Loading…
Reference in New Issue
Block a user