define KernelPackage/r8169
SUBMENU:=$(NETWORK_DEVICES_MENU)
TITLE:=RealTek RTL-8169 PCI Gigabit Ethernet Adapter kernel support
- DEPENDS:=@PCI_SUPPORT +kmod-mii +r8169-firmware +kmod-phy-realtek +kmod-mdio-devres +kmod-hwmon-core
+ DEPENDS:=@PCI_SUPPORT +kmod-mii +r8169-firmware +kmod-phy-realtek +kmod-mdio-devres
KCONFIG:= \
CONFIG_R8169 \
CONFIG_R8169_LEDS=y
+++ /dev/null
-From 1ffcc8d41306fd2e5f140b276820714a26a11cc4 Mon Sep 17 00:00:00 2001
-From: Heiner Kallweit <hkallweit1@gmail.com>
-Date: Mon, 7 Oct 2024 20:34:12 +0200
-Subject: [PATCH] r8169: add support for the temperature sensor being available
- from RTL8125B
-
-This adds support for the temperature sensor being available from
-RTL8125B. Register information was taken from r8125 vendor driver.
-
-Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
-Reviewed-by: Simon Horman <horms@kernel.org>
-Signed-off-by: David S. Miller <davem@davemloft.net>
----
- drivers/net/ethernet/realtek/r8169_main.c | 44 +++++++++++++++++++++++
- 1 file changed, 44 insertions(+)
-
---- a/drivers/net/ethernet/realtek/r8169_main.c
-+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -16,6 +16,7 @@
- #include <linux/clk.h>
- #include <linux/delay.h>
- #include <linux/ethtool.h>
-+#include <linux/hwmon.h>
- #include <linux/phy.h>
- #include <linux/if_vlan.h>
- #include <linux/in.h>
-@@ -5373,6 +5374,43 @@ static bool rtl_aspm_is_safe(struct rtl8
- return false;
- }
-
-+static umode_t r8169_hwmon_is_visible(const void *drvdata,
-+ enum hwmon_sensor_types type,
-+ u32 attr, int channel)
-+{
-+ return 0444;
-+}
-+
-+static int r8169_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
-+ u32 attr, int channel, long *val)
-+{
-+ struct rtl8169_private *tp = dev_get_drvdata(dev);
-+ int val_raw;
-+
-+ val_raw = phy_read_paged(tp->phydev, 0xbd8, 0x12) & 0x3ff;
-+ if (val_raw >= 512)
-+ val_raw -= 1024;
-+
-+ *val = 1000 * val_raw / 2;
-+
-+ return 0;
-+}
-+
-+static const struct hwmon_ops r8169_hwmon_ops = {
-+ .is_visible = r8169_hwmon_is_visible,
-+ .read = r8169_hwmon_read,
-+};
-+
-+static const struct hwmon_channel_info * const r8169_hwmon_info[] = {
-+ HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
-+ NULL
-+};
-+
-+static const struct hwmon_chip_info r8169_hwmon_chip_info = {
-+ .ops = &r8169_hwmon_ops,
-+ .info = r8169_hwmon_info,
-+};
-+
- static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
- {
- struct rtl8169_private *tp;
-@@ -5547,6 +5585,12 @@ static int rtl_init_one(struct pci_dev *
- if (rc)
- return rc;
-
-+ /* The temperature sensor is available from RTl8125B */
-+ if (IS_REACHABLE(CONFIG_HWMON) && tp->mac_version >= RTL_GIGA_MAC_VER_63)
-+ /* ignore errors */
-+ devm_hwmon_device_register_with_info(&pdev->dev, "nic_temp", tp,
-+ &r8169_hwmon_chip_info,
-+ NULL);
- rc = register_netdev(dev);
- if (rc)
- return rc;
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -4779,11 +4779,7 @@ static void r8169_phylink_handler(struct
+@@ -4778,11 +4778,7 @@ static void r8169_phylink_handler(struct
if (netif_carrier_ok(ndev)) {
rtl_link_chg_patch(tp);
pm_request_resume(d);
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -5529,11 +5529,6 @@ static int rtl_init_one(struct pci_dev *
+@@ -5491,11 +5491,6 @@ static int rtl_init_one(struct pci_dev *
dev->features |= dev->hw_features;
if (rtl_chip_supports_csum_v2(tp)) {
dev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6;
netif_set_tso_max_size(dev, RTL_GSO_MAX_SIZE_V2);
-@@ -5544,6 +5539,17 @@ static int rtl_init_one(struct pci_dev *
+@@ -5506,6 +5501,17 @@ static int rtl_init_one(struct pci_dev *
netif_set_tso_max_segs(dev, RTL_GSO_MAX_SEGS_V1);
}
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -2162,6 +2162,19 @@ static void rtl8169_get_ringparam(struct
+@@ -2161,6 +2161,19 @@ static void rtl8169_get_ringparam(struct
data->tx_pending = NUM_TX_DESC;
}
static void rtl8169_get_pauseparam(struct net_device *dev,
struct ethtool_pauseparam *data)
{
-@@ -2188,6 +2201,69 @@ static int rtl8169_set_pauseparam(struct
+@@ -2187,6 +2200,69 @@ static int rtl8169_set_pauseparam(struct
return 0;
}
static const struct ethtool_ops rtl8169_ethtool_ops = {
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
ETHTOOL_COALESCE_MAX_FRAMES,
-@@ -2209,8 +2285,11 @@ static const struct ethtool_ops rtl8169_
+@@ -2208,8 +2284,11 @@ static const struct ethtool_ops rtl8169_
.get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings,
.get_ringparam = rtl8169_get_ringparam,
};
static enum mac_version rtl8169_get_mac_version(u16 xid, bool gmii)
-@@ -3895,6 +3974,9 @@ static void rtl_hw_start_8125(struct rtl
+@@ -3894,6 +3973,9 @@ static void rtl_hw_start_8125(struct rtl
break;
}
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -4802,10 +4802,8 @@ static void rtl_task(struct work_struct
+@@ -4801,10 +4801,8 @@ static void rtl_task(struct work_struct
container_of(work, struct rtl8169_private, wk.work);
int ret;
if (test_and_clear_bit(RTL_FLAG_TASK_TX_TIMEOUT, tp->wk.flags)) {
/* if chip isn't accessible, reset bus to revive it */
-@@ -4814,7 +4812,7 @@ static void rtl_task(struct work_struct
+@@ -4813,7 +4811,7 @@ static void rtl_task(struct work_struct
if (ret < 0) {
netdev_err(tp->dev, "Can't reset secondary PCI bus, detach NIC\n");
netif_device_detach(tp->dev);
}
}
-@@ -4833,8 +4831,6 @@ reset:
+@@ -4832,8 +4830,6 @@ reset:
} else if (test_and_clear_bit(RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE, tp->wk.flags)) {
rtl_reset_work(tp);
}
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -1347,40 +1347,19 @@ static void rtl8168ep_stop_cmac(struct r
+@@ -1346,40 +1346,19 @@ static void rtl8168ep_stop_cmac(struct r
RTL_W8(tp, IBCR0, RTL_R8(tp, IBCR0) & ~0x01);
}
}
static void rtl8168_driver_start(struct rtl8169_private *tp)
-@@ -1394,7 +1373,8 @@ static void rtl8168_driver_start(struct
+@@ -1393,7 +1372,8 @@ static void rtl8168_driver_start(struct
static void rtl8168dp_driver_stop(struct rtl8169_private *tp)
{
r8168dp_oob_notify(tp, OOB_CMD_DRIVER_STOP);
}
static void rtl8168ep_driver_stop(struct rtl8169_private *tp)
-@@ -1402,7 +1382,8 @@ static void rtl8168ep_driver_stop(struct
+@@ -1401,7 +1381,8 @@ static void rtl8168ep_driver_stop(struct
rtl8168ep_stop_cmac(tp);
r8168ep_ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_STOP);
r8168ep_ocp_write(tp, 0x01, 0x30, r8168ep_ocp_read(tp, 0x30) | 0x01);
RTL_GIGA_MAC_NONE
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -56,6 +56,7 @@
+@@ -55,6 +55,7 @@
#define FIRMWARE_8107E_2 "rtl_nic/rtl8107e-2.fw"
#define FIRMWARE_8125A_3 "rtl_nic/rtl8125a-3.fw"
#define FIRMWARE_8125B_2 "rtl_nic/rtl8125b-2.fw"
#define FIRMWARE_8126A_2 "rtl_nic/rtl8126a-2.fw"
#define FIRMWARE_8126A_3 "rtl_nic/rtl8126a-3.fw"
-@@ -139,6 +140,7 @@ static const struct {
+@@ -138,6 +139,7 @@ static const struct {
[RTL_GIGA_MAC_VER_61] = {"RTL8125A", FIRMWARE_8125A_3},
/* reserve 62 for CFG_METHOD_4 in the vendor driver */
[RTL_GIGA_MAC_VER_63] = {"RTL8125B", FIRMWARE_8125B_2},
[RTL_GIGA_MAC_VER_65] = {"RTL8126A", FIRMWARE_8126A_2},
[RTL_GIGA_MAC_VER_66] = {"RTL8126A", FIRMWARE_8126A_3},
};
-@@ -708,6 +710,7 @@ MODULE_FIRMWARE(FIRMWARE_8168FP_3);
+@@ -707,6 +709,7 @@ MODULE_FIRMWARE(FIRMWARE_8168FP_3);
MODULE_FIRMWARE(FIRMWARE_8107E_2);
MODULE_FIRMWARE(FIRMWARE_8125A_3);
MODULE_FIRMWARE(FIRMWARE_8125B_2);
MODULE_FIRMWARE(FIRMWARE_8126A_2);
MODULE_FIRMWARE(FIRMWARE_8126A_3);
-@@ -2080,10 +2083,7 @@ static void rtl_set_eee_txidle_timer(str
+@@ -2079,10 +2082,7 @@ static void rtl_set_eee_txidle_timer(str
tp->tx_lpi_timer = timer_val;
r8168_mac_ocp_write(tp, 0xe048, timer_val);
break;
tp->tx_lpi_timer = timer_val;
RTL_W16(tp, EEE_TXIDLE_TIMER_8125, timer_val);
break;
-@@ -2295,6 +2295,9 @@ static enum mac_version rtl8169_get_mac_
+@@ -2294,6 +2294,9 @@ static enum mac_version rtl8169_get_mac_
{ 0x7cf, 0x64a, RTL_GIGA_MAC_VER_66 },
{ 0x7cf, 0x649, RTL_GIGA_MAC_VER_65 },
/* 8125B family. */
{ 0x7cf, 0x641, RTL_GIGA_MAC_VER_63 },
-@@ -2562,9 +2565,7 @@ static void rtl_init_rxcfg(struct rtl816
+@@ -2561,9 +2564,7 @@ static void rtl_init_rxcfg(struct rtl816
case RTL_GIGA_MAC_VER_61:
RTL_W32(tp, RxConfig, RX_FETCH_DFLT_8125 | RX_DMA_BURST);
break;
RTL_W32(tp, RxConfig, RX_FETCH_DFLT_8125 | RX_DMA_BURST |
RX_PAUSE_SLOT_ON);
break;
-@@ -3876,6 +3877,12 @@ static void rtl_hw_start_8125b(struct rt
+@@ -3875,6 +3876,12 @@ static void rtl_hw_start_8125b(struct rt
rtl_hw_start_8125_common(tp);
}
static void rtl_hw_start_8126a(struct rtl8169_private *tp)
{
rtl_set_def_aspm_entry_latency(tp);
-@@ -3924,6 +3931,7 @@ static void rtl_hw_config(struct rtl8169
+@@ -3923,6 +3930,7 @@ static void rtl_hw_config(struct rtl8169
[RTL_GIGA_MAC_VER_53] = rtl_hw_start_8117,
[RTL_GIGA_MAC_VER_61] = rtl_hw_start_8125a_2,
[RTL_GIGA_MAC_VER_63] = rtl_hw_start_8125b,
[RTL_GIGA_MAC_VER_65] = rtl_hw_start_8126a,
[RTL_GIGA_MAC_VER_66] = rtl_hw_start_8126a,
};
-@@ -3941,6 +3949,7 @@ static void rtl_hw_start_8125(struct rtl
+@@ -3940,6 +3948,7 @@ static void rtl_hw_start_8125(struct rtl
/* disable interrupt coalescing */
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_61:
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -2227,7 +2227,7 @@ static void rtl8169_get_eth_mac_stats(st
+@@ -2226,7 +2226,7 @@ static void rtl8169_get_eth_mac_stats(st
le64_to_cpu(tp->counters->tx_broadcast64);
mac_stats->MulticastFramesReceivedOK =
le64_to_cpu(tp->counters->rx_multicast64);
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -347,6 +347,8 @@ enum rtl8125_registers {
+@@ -346,6 +346,8 @@ enum rtl8125_registers {
TxPoll_8125 = 0x90,
LEDSEL3 = 0x96,
MAC0_BKP = 0x19e0,
EEE_TXIDLE_TIMER_8125 = 0x6048,
};
-@@ -3770,8 +3772,8 @@ static void rtl_hw_start_8125_common(str
+@@ -3769,8 +3771,8 @@ static void rtl_hw_start_8125_common(str
rtl_pcie_state_l2l3_disable(tp);
RTL_W16(tp, 0x382, 0x221b);
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -663,13 +663,9 @@ struct rtl8169_private {
+@@ -662,13 +662,9 @@ struct rtl8169_private {
struct work_struct work;
} wk;
unsigned supports_gmii:1;
unsigned aspm_manageable:1;
unsigned dash_enabled:1;
-@@ -723,22 +719,12 @@ static inline struct device *tp_to_dev(s
+@@ -722,22 +718,12 @@ static inline struct device *tp_to_dev(s
static void rtl_lock_config_regs(struct rtl8169_private *tp)
{
}
static void rtl_pci_commit(struct rtl8169_private *tp)
-@@ -749,24 +735,18 @@ static void rtl_pci_commit(struct rtl816
+@@ -748,24 +734,18 @@ static void rtl_pci_commit(struct rtl816
static void rtl_mod_config2(struct rtl8169_private *tp, u8 clear, u8 set)
{
}
static bool rtl_is_8125(struct rtl8169_private *tp)
-@@ -1572,7 +1552,6 @@ static void __rtl8169_set_wol(struct rtl
+@@ -1571,7 +1551,6 @@ static void __rtl8169_set_wol(struct rtl
{ WAKE_MAGIC, Config3, MagicPacket }
};
unsigned int i, tmp = ARRAY_SIZE(cfg);
u8 options;
rtl_unlock_config_regs(tp);
-@@ -1591,14 +1570,12 @@ static void __rtl8169_set_wol(struct rtl
+@@ -1590,14 +1569,12 @@ static void __rtl8169_set_wol(struct rtl
r8168_mac_ocp_modify(tp, 0xc0b6, BIT(0), 0);
}
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06:
-@@ -5498,8 +5475,6 @@ static int rtl_init_one(struct pci_dev *
+@@ -5460,8 +5437,6 @@ static int rtl_init_one(struct pci_dev *
tp->supports_gmii = ent->driver_data == RTL_CFG_NO_GBIT ? 0 : 1;
tp->ocp_base = OCP_STD_PHY_BASE;
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -749,6 +749,20 @@ static void rtl_mod_config5(struct rtl81
+@@ -748,6 +748,20 @@ static void rtl_mod_config5(struct rtl81
RTL_W8(tp, Config5, (val & ~clear) | set);
}
static bool rtl_is_8125(struct rtl8169_private *tp)
{
return tp->mac_version >= RTL_GIGA_MAC_VER_61;
-@@ -1539,58 +1553,37 @@ static void rtl8169_get_wol(struct net_d
+@@ -1538,58 +1552,37 @@ static void rtl8169_get_wol(struct net_d
static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
{
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -1432,19 +1432,11 @@ static enum rtl_dash_type rtl_get_dash_t
+@@ -1431,19 +1431,11 @@ static enum rtl_dash_type rtl_get_dash_t
static void rtl_set_d3_pll_down(struct rtl8169_private *tp, bool enable)
{
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -1563,6 +1563,9 @@ static void __rtl8169_set_wol(struct rtl
+@@ -1562,6 +1562,9 @@ static void __rtl8169_set_wol(struct rtl
}
r8169_mod_reg8_cond(tp, Config3, LinkUp, wolopts & WAKE_PHY);
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
-@@ -2547,86 +2547,31 @@ static void rtl8169_init_ring_indexes(st
+@@ -2546,86 +2546,31 @@ static void rtl8169_init_ring_indexes(st
tp->dirty_tx = tp->cur_tx = tp->cur_rx = 0;
}