mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
package: add kmod-r8125 ethernet driver
r8125 is an out of tree driver provided by Realtek for RTL8125 devices. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> [Refresh our patch, disable aspm] Signed-off-by: AnYun <amadeus@openjmu.xyz>
This commit is contained in:
parent
0061cb8a1f
commit
b53ecbb75a
48
package/kernel/r8125/Makefile
Normal file
48
package/kernel/r8125/Makefile
Normal file
@ -0,0 +1,48 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=r8125
|
||||
PKG_VERSION:=9.013.02
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=https://github.com/openwrt/rtl8125/releases/download/$(PKG_VERSION)
|
||||
PKG_HASH:=d36410ee99c956f250d9cd08340d8c36567d190f420a8ee128ff6e51225aac0c
|
||||
|
||||
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/r8125
|
||||
SUBMENU:=Network Devices
|
||||
TITLE:=Realtek RTL8125 PCI 2.5 Gigabit Ethernet driver
|
||||
DEPENDS:=@PCI_SUPPORT +kmod-libphy
|
||||
FILES:=$(PKG_BUILD_DIR)/src/r8125.ko
|
||||
AUTOLOAD:=$(call AutoProbe,r8125)
|
||||
PROVIDES:=kmod-r8169
|
||||
VARIANT:=regular
|
||||
endef
|
||||
|
||||
define KernelPackage/r8125-rss
|
||||
$(call KernelPackage/r8125)
|
||||
TITLE+= (RSS)
|
||||
VARIANT:=rss
|
||||
endef
|
||||
|
||||
ifeq ($(BUILD_VARIANT),rss)
|
||||
PKG_MAKE_FLAGS += ENABLE_RSS_SUPPORT=y
|
||||
endif
|
||||
|
||||
PKG_MAKE_FLAGS += CONFIG_ASPM=n
|
||||
|
||||
define Build/Compile
|
||||
+$(KERNEL_MAKE) $(PKG_JOBS) \
|
||||
$(PKG_MAKE_FLAGS) \
|
||||
M="$(PKG_BUILD_DIR)/src" \
|
||||
modules
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,r8125))
|
||||
$(eval $(call KernelPackage,r8125-rss))
|
@ -0,0 +1,26 @@
|
||||
From cd20cf48c0ec2a01fd9f512e25218a6ac8131794 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
|
||||
Date: Sat, 17 Aug 2024 22:07:23 +0200
|
||||
Subject: [PATCH] r8125_rss: silence rxnfc log
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This log is noisy and useless, just ignore it.
|
||||
|
||||
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
|
||||
---
|
||||
src/r8125_rss.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/src/r8125_rss.c
|
||||
+++ b/src/r8125_rss.c
|
||||
@@ -91,7 +91,7 @@ int rtl8125_get_rxnfc(struct net_device
|
||||
struct rtl8125_private *tp = netdev_priv(dev);
|
||||
int ret = -EOPNOTSUPP;
|
||||
|
||||
- netif_info(tp, drv, tp->dev, "rss get rxnfc\n");
|
||||
+ netif_dbg(tp, drv, tp->dev, "rss get rxnfc\n");
|
||||
|
||||
if (!(dev->features & NETIF_F_RXHASH))
|
||||
return ret;
|
@ -0,0 +1,99 @@
|
||||
From e351ac87bc3135e8555587e0bf80efb248ade0b7 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 21:16:23 +0800
|
||||
Subject: [PATCH] r8125: 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/r8125.h | 2 ++
|
||||
src/r8125_n.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 45 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/src/r8125.h
|
||||
+++ b/src/r8125.h
|
||||
@@ -1563,6 +1563,8 @@ enum RTL8125_register_content {
|
||||
LinkStatus = 0x02,
|
||||
FullDup = 0x01,
|
||||
|
||||
+#define RTL8125_FULL_DUPLEX_MASK (_2500bpsF | _1000bpsF | FullDup)
|
||||
+
|
||||
/* DBG_reg */
|
||||
Fix_Nak_1 = (1 << 4),
|
||||
Fix_Nak_2 = (1 << 3),
|
||||
--- a/src/r8125_n.c
|
||||
+++ b/src/r8125_n.c
|
||||
@@ -39,6 +39,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>
|
||||
@@ -5112,6 +5113,38 @@ rtl8125_link_down_patch(struct net_devic
|
||||
#endif
|
||||
}
|
||||
|
||||
+static unsigned int rtl8125_phy_duplex(u16 status)
|
||||
+{
|
||||
+ unsigned int duplex = DUPLEX_UNKNOWN;
|
||||
+
|
||||
+ if (status & LinkStatus) {
|
||||
+ if (status & RTL8125_FULL_DUPLEX_MASK)
|
||||
+ duplex = DUPLEX_FULL;
|
||||
+ else
|
||||
+ duplex = DUPLEX_HALF;
|
||||
+ }
|
||||
+
|
||||
+ return duplex;
|
||||
+}
|
||||
+
|
||||
+static int rtl8125_phy_speed(u16 status)
|
||||
+{
|
||||
+ int speed = SPEED_UNKNOWN;
|
||||
+
|
||||
+ if (status & LinkStatus) {
|
||||
+ if (status & _2500bpsF)
|
||||
+ speed = SPEED_2500;
|
||||
+ else if (status & _1000bpsF)
|
||||
+ speed = SPEED_1000;
|
||||
+ else if (status & _100bps)
|
||||
+ speed = SPEED_100;
|
||||
+ else if (status & _10bps)
|
||||
+ speed = SPEED_10;
|
||||
+ }
|
||||
+
|
||||
+ return speed;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
_rtl8125_check_link_status(struct net_device *dev)
|
||||
{
|
||||
@@ -5120,11 +5153,18 @@ _rtl8125_check_link_status(struct net_de
|
||||
if (tp->link_ok(dev)) {
|
||||
rtl8125_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 u16 phy_status = RTL_R16(tp, PHYstatus);
|
||||
+ const unsigned int phy_duplex = rtl8125_phy_duplex(phy_status);
|
||||
+ const int phy_speed = rtl8125_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);
|
||||
|
||||
rtl8125_link_down_patch(dev);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
--- a/src/r8125_n.c
|
||||
+++ b/src/r8125_n.c
|
||||
@@ -43,6 +43,7 @@
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/mii.h>
|
||||
@ -8,36 +8,34 @@
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/interrupt.h>
|
||||
@@ -13626,6 +13627,23 @@ rtl8125_setup_mqs_reg(struct rtl8125_pri
|
||||
tp->imr_reg[i] = (u16)(IMR1_8125 + (i - 1) * 4);
|
||||
@@ -13667,6 +13668,22 @@ rtl8125_setup_mqs_reg(struct rtl8125_pri
|
||||
}
|
||||
|
||||
+static int
|
||||
static void
|
||||
+rtl8125_led_configuration(struct rtl8125_private *tp)
|
||||
+{
|
||||
+ u32 led_data;
|
||||
+ int ret;
|
||||
+ u32 led_data[4];
|
||||
+ int i, ret;
|
||||
+
|
||||
+ ret = of_property_read_u32(tp->pci_dev->dev.of_node,
|
||||
+ "realtek,led-data", &led_data);
|
||||
+
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ RTL_W16(tp, CustomLED, led_data);
|
||||
+
|
||||
+ return 0;
|
||||
+ const int led_regs[] = { 0x18, 0x86, 0x84, 0x96 };
|
||||
+ ret = of_property_read_u32_array(tp->pci_dev->dev.of_node,
|
||||
+ "led-data", led_data, 4);
|
||||
+ if (!ret) {
|
||||
+ for (i = 0; i < 4; i++) {
|
||||
+ RTL_W16(tp, led_regs[i], led_data[i]);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void
|
||||
+static void
|
||||
rtl8125_init_software_variable(struct net_device *dev)
|
||||
{
|
||||
@@ -14260,6 +14278,8 @@ rtl8125_init_software_variable(struct ne
|
||||
struct rtl8125_private *tp = netdev_priv(dev);
|
||||
@@ -14300,6 +14317,7 @@ rtl8125_init_software_variable(struct ne
|
||||
else if (tp->InitRxDescType == RX_DESC_RING_TYPE_4)
|
||||
tp->rtl8125_rx_config &= ~EnableRxDescV4_1;
|
||||
|
||||
+ rtl8125_led_configuration(tp);
|
||||
+
|
||||
tp->NicCustLedValue = RTL_R16(tp, CustomLED);
|
||||
|
||||
tp->wol_opts = rtl8125_get_hw_wol(tp);
|
@ -1,39 +0,0 @@
|
||||
#
|
||||
# Download realtek r8125 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:=r8125
|
||||
PKG_VERSION:=9.013.02-2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/awesometic/realtek-r8125-dkms/tar.gz/$(PKG_VERSION)?
|
||||
PKG_HASH:=eae10100680de13e8119602c50a1748b8a0669eccd61d9a4515b4c846deb3960
|
||||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/realtek-$(PKG_NAME)-dkms-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
PKG_LICENSE_FILE:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/r8125
|
||||
TITLE:=Driver for Realtek r8125 chipsets
|
||||
SUBMENU:=Network Devices
|
||||
VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
|
||||
FILES:= $(PKG_BUILD_DIR)/src/r8125.ko
|
||||
AUTOLOAD:=$(call AutoProbe,r8125)
|
||||
endef
|
||||
|
||||
define Package/r8125/description
|
||||
This package contains a driver for Realtek r8125 chipsets.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
+$(KERNEL_MAKE) M=$(PKG_BUILD_DIR)/src modules
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,r8125))
|
@ -1,20 +0,0 @@
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -35,7 +35,7 @@ ENABLE_REALWOW_SUPPORT = n
|
||||
ENABLE_DASH_SUPPORT = n
|
||||
ENABLE_DASH_PRINTER_SUPPORT = n
|
||||
CONFIG_DOWN_SPEED_100 = n
|
||||
-CONFIG_ASPM = y
|
||||
+CONFIG_ASPM = n
|
||||
ENABLE_S5WOL = y
|
||||
ENABLE_S5_KEEP_CURR_MAC = n
|
||||
ENABLE_EEE = y
|
||||
@@ -44,7 +44,7 @@ ENABLE_TX_NO_CLOSE = y
|
||||
ENABLE_MULTIPLE_TX_QUEUE = y
|
||||
ENABLE_PTP_SUPPORT = n
|
||||
ENABLE_PTP_MASTER_MODE = n
|
||||
-ENABLE_RSS_SUPPORT = n
|
||||
+ENABLE_RSS_SUPPORT = y
|
||||
ENABLE_LIB_SUPPORT = n
|
||||
ENABLE_USE_FIRMWARE_FILE = n
|
||||
DISABLE_WOL_SUPPORT = n
|
@ -1,11 +0,0 @@
|
||||
--- a/src/r8125_rss.c
|
||||
+++ b/src/r8125_rss.c
|
||||
@@ -91,7 +91,7 @@ int rtl8125_get_rxnfc(struct net_device
|
||||
struct rtl8125_private *tp = netdev_priv(dev);
|
||||
int ret = -EOPNOTSUPP;
|
||||
|
||||
- netif_info(tp, drv, tp->dev, "rss get rxnfc\n");
|
||||
+ netif_dbg(tp, drv, tp->dev, "rss get rxnfc\n");
|
||||
|
||||
if (!(dev->features & NETIF_F_RXHASH))
|
||||
return ret;
|
@ -1,34 +0,0 @@
|
||||
--- a/src/r8125_n.c
|
||||
+++ b/src/r8125_n.c
|
||||
@@ -13628,6 +13628,23 @@ rtl8125_setup_mqs_reg(struct rtl8125_pri
|
||||
}
|
||||
|
||||
static int
|
||||
+rtl8125_devname_configuration(struct rtl8125_private *tp)
|
||||
+{
|
||||
+ const char *devname;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = of_property_read_string(tp->pci_dev->dev.of_node,
|
||||
+ "label", &devname);
|
||||
+
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ strlcpy(tp->dev->name, devname, IFNAMSIZ);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
rtl8125_led_configuration(struct rtl8125_private *tp)
|
||||
{
|
||||
u32 led_data;
|
||||
@@ -14278,6 +14295,7 @@ rtl8125_init_software_variable(struct ne
|
||||
else if (tp->InitRxDescType == RX_DESC_RING_TYPE_4)
|
||||
tp->rtl8125_rx_config &= ~EnableRxDescV4_1;
|
||||
|
||||
+ rtl8125_devname_configuration(tp);
|
||||
rtl8125_led_configuration(tp);
|
||||
|
||||
tp->NicCustLedValue = RTL_R16(tp, CustomLED);
|
Loading…
Reference in New Issue
Block a user