lede/package/kernel/r8168/patches/100-linux-6.9-support.patch
=?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= a0dbcae1dd kernel: r8168: update to v8.055.00
Changelog: https://github.com/openwrt/rtl8168/compare/8.054.00...8.055.00

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-02-07 12:00:06 +08:00

118 lines
4.3 KiB
Diff

From 94426e16197c244d03aad0434e3490acdaa830fe Mon Sep 17 00:00:00 2001
From: Masato TOYOSHIMA <phoepsilonix@phoepsilonix.love>
Date: Tue, 14 May 2024 14:52:58 +0900
Subject: [PATCH] Linux 6.9 compat: change to ethtool_keee from ethtool_eee
linux/include/linux/ethtool.h
struct ethtool_ops
int (*get_eee)(struct net_device *dev, struct ethtool_keee *eee);
int (*set_eee)(struct net_device *dev, struct ethtool_keee *eee);
change to ethtool_keee from ethtool_eee
rtl_ethtool_get_eee(struct net_device *net, struct ethtool_keee *edata)
rtl_ethtool_set_eee(struct net_device *net, struct ethtool_keee *edata)
---
src/r8168_n.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
--- a/src/r8168_n.c
+++ b/src/r8168_n.c
@@ -8103,7 +8103,11 @@ out:
}
#else
static int
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+rtl_ethtool_get_eee(struct net_device *net, struct ethtool_keee *edata)
+#else
rtl_ethtool_get_eee(struct net_device *net, struct ethtool_eee *edata)
+#endif
{
struct rtl8168_private *tp = netdev_priv(net);
struct ethtool_eee *eee = &tp->eee;
@@ -8137,9 +8141,15 @@ rtl_ethtool_get_eee(struct net_device *n
edata->eee_enabled = !!val;
edata->eee_active = !!(supported & adv & lp);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+ ethtool_convert_legacy_u32_to_link_mode(edata->supported, supported);
+ ethtool_convert_legacy_u32_to_link_mode(edata->advertised, adv);
+ ethtool_convert_legacy_u32_to_link_mode(edata->lp_advertised, lp);
+#else
edata->supported = supported;
edata->advertised = adv;
edata->lp_advertised = lp;
+#endif
edata->tx_lpi_enabled = edata->eee_enabled;
edata->tx_lpi_timer = tx_lpi_timer;
@@ -8147,11 +8157,19 @@ rtl_ethtool_get_eee(struct net_device *n
}
static int
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+rtl_ethtool_set_eee(struct net_device *net, struct ethtool_keee *edata)
+#else
rtl_ethtool_set_eee(struct net_device *net, struct ethtool_eee *edata)
+#endif
{
struct rtl8168_private *tp = netdev_priv(net);
struct ethtool_eee *eee = &tp->eee;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+ u32 advertising, adv;
+#else
u32 advertising;
+#endif
int rc = 0;
if (!rtl8168_support_eee(tp))
@@ -8175,6 +8193,18 @@ rtl_ethtool_set_eee(struct net_device *n
}
advertising = tp->advertising;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+ ethtool_convert_link_mode_to_legacy_u32(&adv, edata->advertised);
+ if (linkmode_empty(edata->advertised)) {
+ adv = advertising & eee->supported;
+ ethtool_convert_legacy_u32_to_link_mode(edata->advertised, adv);
+ } else if (!linkmode_empty(edata->advertised) & ~advertising) {
+ dev_printk(KERN_WARNING, tp_to_dev(tp), "EEE advertised %x must be a subset of autoneg advertised speeds %x\n",
+ adv, advertising);
+ rc = -EINVAL;
+ goto out;
+ }
+#else
if (!edata->advertised) {
edata->advertised = advertising & eee->supported;
} else if (edata->advertised & ~advertising) {
@@ -8183,15 +8213,29 @@ rtl_ethtool_set_eee(struct net_device *n
rc = -EINVAL;
goto out;
}
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+ if (!linkmode_empty(edata->advertised) & ~eee->supported) {
+ dev_printk(KERN_WARNING, tp_to_dev(tp), "EEE advertised %x must be a subset of support %x\n",
+ adv, eee->supported);
+ rc = -EINVAL;
+ goto out;
+ }
+#else
if (edata->advertised & ~eee->supported) {
dev_printk(KERN_WARNING, tp_to_dev(tp), "EEE advertised %x must be a subset of support %x\n",
edata->advertised, eee->supported);
rc = -EINVAL;
goto out;
}
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+ ethtool_convert_link_mode_to_legacy_u32(&eee->advertised, edata->advertised);
+#else
eee->advertised = edata->advertised;
+#endif
eee->eee_enabled = edata->eee_enabled;
if (eee->eee_enabled)