lede/package/kernel/r8125/patches/100-kernel-6.9-support.patch
=?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= ae9e8d4c84 kernel: r8125: update to v9.015.00
Changelog: https://github.com/openwrt/rtl8125/compare/9.014.01...9.015.00

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2025-03-05 23:01:19 +08:00

102 lines
3.8 KiB
Diff

--- a/src/r8125_n.c
+++ b/src/r8125_n.c
@@ -7314,7 +7314,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 rtl8125_private *tp = netdev_priv(net);
struct ethtool_eee *eee = &tp->eee;
@@ -7347,9 +7351,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;
@@ -7357,11 +7367,18 @@ 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 rtl8125_private *tp = netdev_priv(net);
struct ethtool_eee *eee = &tp->eee;
u64 advertising;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+ u32 adv;
+#endif
int rc = 0;
if (!HW_HAS_WRITE_PHY_MCU_RAM_CODE(tp) ||
@@ -7393,6 +7410,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 %llu\n",
+ adv, advertising);
+ rc = -EINVAL;
+ goto out;
+ }
+#else
if (!edata->advertised) {
edata->advertised = advertising & eee->supported;
} else if (edata->advertised & ~advertising) {
@@ -7401,18 +7430,32 @@ 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
//tp->eee.eee_enabled = edata->eee_enabled;
//tp->eee_adv_t = rtl8125_ethtool_adv_to_mmd_eee_adv_cap1_t(edata->advertised);
+#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->tx_lpi_enabled = edata->tx_lpi_enabled;
//eee->tx_lpi_timer = edata->tx_lpi_timer;
eee->eee_enabled = edata->eee_enabled;