summaryrefslogtreecommitdiff
path: root/net-misc/r8152/files/r8152-2.18.1-kernel-6.9-fix.patch
blob: 155a5aa1100bfd800081ed43538a9bc5c39645be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
From 32d026ab6b601cfe2882818921ba379cfbc3031e Mon Sep 17 00:00:00 2001
From: Jay Faulkner <jay@jvf.cc>
Date: Wed, 11 Sep 2024 20:30:33 -0700
Subject: [PATCH] Forward ported version of kernel 6.9.x fix patch

Original version sourced from below; has been forward-ported from
From: https://github.com/wget/realtek-r8152-linux/pull/41
From a5b3b4a882a3a637ccfa447dc7d2e84eac9ef0fc Mon Sep 17 00:00:00 2001
From: "oleg.hoefling" <oleg.hoefling@gmail.com>
---
 r8152.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 46 insertions(+), 4 deletions(-)

diff --git a/r8152.c b/r8152.c
index cee3b23..4063525 100644
--- a/r8152.c
+++ b/r8152.c
@@ -1006,7 +1006,10 @@ struct r8152 {
 		int (*up)(struct r8152 *tp);
 		int (*down)(struct r8152 *tp);
 		void (*unload)(struct r8152 *tp);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+        int (*eee_get)(struct r8152 *tp, struct ethtool_keee *eee);
+        int (*eee_set)(struct r8152 *tp, struct ethtool_keee *eee);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
 		int (*eee_get)(struct r8152 *tp, struct ethtool_eee *eee);
 		int (*eee_set)(struct r8152 *tp, struct ethtool_eee *eee);
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
@@ -23342,8 +23345,13 @@ static void rtl8152_get_strings(struct net_device *dev, u32 stringset, u8 *data)
 	}
 }
 
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+static int r8152_get_eee(struct r8152 *tp, struct ethtool_keee *eee)
+#else
 static int r8152_get_eee(struct r8152 *tp, struct ethtool_eee *eee)
+#endif
 {
 	u32 lp, adv, supported = 0;
 	int ret;
@@ -23369,17 +23377,33 @@ static int r8152_get_eee(struct r8152 *tp, struct ethtool_eee *eee)
 
 	eee->eee_enabled = tp->eee_en;
 	eee->eee_active = !!(supported & adv & lp);
-	eee->supported = supported;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+	ethtool_convert_legacy_u32_to_link_mode(eee->supported, supported);
+	ethtool_convert_legacy_u32_to_link_mode(eee->advertised, tp->eee_adv);
+	ethtool_convert_legacy_u32_to_link_mode(eee->lp_advertised, lp);
+#else
+    eee->supported = supported;
 	eee->advertised = mmd_eee_adv_to_ethtool_adv_t(tp->eee_adv);
 	eee->lp_advertised = lp;
+#endif
 
 out:
 	return (ret < 0) ? ret : 0;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+static int r8152_set_eee(struct r8152 *tp, struct ethtool_keee *eee)
+#else
 static int r8152_set_eee(struct r8152 *tp, struct ethtool_eee *eee)
+#endif
 {
-	u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+    u32 advertised = 0;
+    ethtool_convert_link_mode_to_legacy_u32(&advertised, eee->advertised);
+    u16 val = ethtool_adv_to_mmd_eee_adv_t(advertised);
+#else
+    u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised);
+#endif
 
 	tp->eee_en = eee->eee_enabled;
 	tp->eee_adv = val;
@@ -23387,7 +23411,11 @@ static int r8152_set_eee(struct r8152 *tp, struct ethtool_eee *eee)
 	return rtl_eee_enable(tp, tp->eee_en);
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+static int r8153_get_eee(struct r8152 *tp, struct ethtool_keee *eee)
+#else
 static int r8153_get_eee(struct r8152 *tp, struct ethtool_eee *eee)
+#endif
 {
 	u32 lp, adv, supported = 0;
 	u16 val;
@@ -23410,16 +23438,26 @@ static int r8153_get_eee(struct r8152 *tp, struct ethtool_eee *eee)
 
 	eee->eee_enabled = tp->eee_en;
 	eee->eee_active = !!(supported & adv & lp);
-	eee->supported = supported;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+	ethtool_convert_legacy_u32_to_link_mode(eee->supported, supported);
+	ethtool_convert_legacy_u32_to_link_mode(eee->advertised, tp->eee_adv);
+	ethtool_convert_legacy_u32_to_link_mode(eee->lp_advertised, lp);
+#else
+    eee->supported = supported;
 	eee->advertised = mmd_eee_adv_to_ethtool_adv_t(tp->eee_adv);
 	eee->lp_advertised = lp;
+#endif
 
 out:
 	return (ret < 0) ? ret : 0;
 }
 
 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 r8152 *tp = netdev_priv(net);
 	int ret;
@@ -23446,7 +23484,11 @@ out:
 }
 
 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 r8152 *tp = netdev_priv(net);
 	int ret;
-- 
2.46.0