[openwrt/openwrt] kernel: r8168: print link status when link up
LEDE Commits
lede-commits at lists.infradead.org
Sun Aug 18 13:47:34 PDT 2024
noltari pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/2f846a33157e32d52c26cf06825f8eb1db13181d
commit 2f846a33157e32d52c26cf06825f8eb1db13181d
Author: Álvaro Fernández Rojas <noltari at gmail.com>
AuthorDate: Sat Aug 17 21:41:31 2024 +0200
kernel: r8168: print link status when link up
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 at gmail.com>
Signed-off-by: Chukun Pan <amadeus at jmu.edu.cn>
---
package/kernel/r8168/Makefile | 4 +-
...168_n-fix-proc_dump_rx_desc_2-on-32-bits.patch} | 0
...00-r8168-print-link-speed-and-duplex-mode.patch | 98 ++++++++++++++++++++++
3 files changed, 100 insertions(+), 2 deletions(-)
diff --git a/package/kernel/r8168/Makefile b/package/kernel/r8168/Makefile
index 4279399282..dc764bbf2c 100644
--- a/package/kernel/r8168/Makefile
+++ b/package/kernel/r8168/Makefile
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=r8168
PKG_VERSION:=8.053.00
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://github.com/openwrt/rtl8168/releases/download/$(PKG_VERSION)
@@ -18,7 +18,7 @@ include $(INCLUDE_DIR)/package.mk
define KernelPackage/r8168
SUBMENU:=Network Devices
TITLE:=Realtek RTL8168 PCI Gigabit Ethernet driver
- DEPENDS:=@PCI_SUPPORT
+ DEPENDS:=@PCI_SUPPORT +kmod-libphy
FILES:=$(PKG_BUILD_DIR)/src/r8168.ko
AUTOLOAD:=$(call AutoProbe,r8168)
PROVIDES:=kmod-r8169
diff --git a/package/kernel/r8168/patches/0001-r8168_n-fix-proc_dump_rx_desc_2-on-32-bits.patch b/package/kernel/r8168/patches/001-r8168_n-fix-proc_dump_rx_desc_2-on-32-bits.patch
similarity index 100%
rename from package/kernel/r8168/patches/0001-r8168_n-fix-proc_dump_rx_desc_2-on-32-bits.patch
rename to package/kernel/r8168/patches/001-r8168_n-fix-proc_dump_rx_desc_2-on-32-bits.patch
diff --git a/package/kernel/r8168/patches/200-r8168-print-link-speed-and-duplex-mode.patch b/package/kernel/r8168/patches/200-r8168-print-link-speed-and-duplex-mode.patch
new file mode 100644
index 0000000000..0212ae9bc4
--- /dev/null
+++ b/package/kernel/r8168/patches/200-r8168-print-link-speed-and-duplex-mode.patch
@@ -0,0 +1,98 @@
+From 0078930e0c374d327cd3281e5e2f7ff97b40b335 Mon Sep 17 00:00:00 2001
+From: Chukun Pan <amadeus at jmu.edu.cn>
+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 at gmail.com>
+Signed-off-by: Chukun Pan <amadeus at jmu.edu.cn>
+---
+ 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);
+ }
More information about the lede-commits
mailing list