From fe0240f27e9df2d0b8c0981741360f2f87b09536 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Sat, 17 Aug 2024 21:30:35 +0200 Subject: [PATCH] kernel: r8101: print link status when link up MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 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 --- package/kernel/r8101/Makefile | 4 +- ...101-print-link-speed-and-duplex-mode.patch | 100 ++++++++++++++++++ 2 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 package/kernel/r8101/patches/200-r8101-print-link-speed-and-duplex-mode.patch diff --git a/package/kernel/r8101/Makefile b/package/kernel/r8101/Makefile index d385d8308c..2a09855c05 100644 --- a/package/kernel/r8101/Makefile +++ b/package/kernel/r8101/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=r8101 PKG_VERSION:=1.039.00 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://github.com/openwrt/rtl8101/releases/download/$(PKG_VERSION) @@ -18,7 +18,7 @@ include $(INCLUDE_DIR)/package.mk define KernelPackage/r8101 SUBMENU:=Network Devices TITLE:=Realtek RTL8101 PCI Fast Ethernet driver - DEPENDS:=@PCI_SUPPORT + DEPENDS:=@PCI_SUPPORT +kmod-libphy FILES:=$(PKG_BUILD_DIR)/src/r8101.ko AUTOLOAD:=$(call AutoProbe,r8101) PROVIDES:=kmod-r8169 diff --git a/package/kernel/r8101/patches/200-r8101-print-link-speed-and-duplex-mode.patch b/package/kernel/r8101/patches/200-r8101-print-link-speed-and-duplex-mode.patch new file mode 100644 index 0000000000..e112d14168 --- /dev/null +++ b/package/kernel/r8101/patches/200-r8101-print-link-speed-and-duplex-mode.patch @@ -0,0 +1,100 @@ +From ec0de750e20073b23c91b67f4bc3ab71c50f0eed Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 17 Aug 2024 21:19:54 +0200 +Subject: [PATCH] r8101: 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 +--- + src/r8101.h | 2 ++ + src/r8101_n.c | 42 +++++++++++++++++++++++++++++++++++++++--- + 2 files changed, 41 insertions(+), 3 deletions(-) + +--- a/src/r8101.h ++++ b/src/r8101.h +@@ -1162,6 +1162,8 @@ enum RTL8101_register_content { + LinkStatus = 0x02, + FullDup = 0x01, + ++#define RTL8101_FULL_DUPLEX_MASK (FullDup) ++ + /* ResetCounterCommand */ + CounterReset = 0x1, + /* DumpCounterCommand */ +--- a/src/r8101_n.c ++++ b/src/r8101_n.c +@@ -39,6 +39,7 @@ This driver is modified from r8169.c in + #include + #include + #include ++#include + #include + #include + #include +@@ -2838,6 +2839,34 @@ rtl8101_issue_offset_99_event(struct rtl + } + } + ++static unsigned int rtl8101_phy_duplex(u8 status) ++{ ++ unsigned int duplex = DUPLEX_UNKNOWN; ++ ++ if (status & LinkStatus) { ++ if (status & RTL8101_FULL_DUPLEX_MASK) ++ duplex = DUPLEX_FULL; ++ else ++ duplex = DUPLEX_HALF; ++ } ++ ++ return duplex; ++} ++ ++static int rtl8101_phy_speed(u8 status) ++{ ++ int speed = SPEED_UNKNOWN; ++ ++ if (status & LinkStatus) { ++ if (status & _100bps) ++ speed = SPEED_100; ++ else if (status & _10bps) ++ speed = SPEED_10; ++ } ++ ++ return speed; ++} ++ + static void + rtl8101_check_link_status(struct net_device *dev) + { +@@ -2913,8 +2942,15 @@ rtl8101_check_link_status(struct net_dev + tp->phy_reg_aner = rtl8101_mdio_read(tp, MII_EXPANSION); + tp->phy_reg_anlpar = rtl8101_mdio_read(tp, MII_LPA); + +- 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 = rtl8101_phy_duplex(phy_status); ++ const int phy_speed = rtl8101_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 (tp->mcfg == CFG_METHOD_11 || tp->mcfg == CFG_METHOD_12 || + tp->mcfg == CFG_METHOD_13) { +@@ -2925,7 +2961,7 @@ rtl8101_check_link_status(struct net_dev + rtl8101_mdio_write(tp, 0x1F, 0x0000); + } + 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); + + tp->phy_reg_aner = 0; + tp->phy_reg_anlpar = 0; -- 2.30.2