Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * ethtool.h: Defines for Linux ethtool. | |
4 | * | |
5 | * Copyright (C) 1998 David S. Miller (davem@redhat.com) | |
6 | * Copyright 2001 Jeff Garzik <jgarzik@pobox.com> | |
7 | * Portions Copyright 2001 Sun Microsystems (thockin@sun.com) | |
8 | * Portions Copyright 2002 Intel (eli.kupermann@intel.com, | |
9 | * christopher.leech@intel.com, | |
10 | * scott.feldman@intel.com) | |
59089d8d | 11 | * Portions Copyright (C) Sun Microsystems 2008 |
1da177e4 | 12 | */ |
1da177e4 LT |
13 | #ifndef _LINUX_ETHTOOL_H |
14 | #define _LINUX_ETHTOOL_H | |
15 | ||
3f1ac7a7 | 16 | #include <linux/bitmap.h> |
3a7da39d | 17 | #include <linux/compat.h> |
dd1c4164 | 18 | #include <linux/if_ether.h> |
f3ccfda1 | 19 | #include <linux/netlink.h> |
607ca46e | 20 | #include <uapi/linux/ethtool.h> |
3ae7c0b2 | 21 | |
3a7da39d BH |
22 | struct compat_ethtool_rx_flow_spec { |
23 | u32 flow_type; | |
127fe533 AD |
24 | union ethtool_flow_union h_u; |
25 | struct ethtool_flow_ext h_ext; | |
26 | union ethtool_flow_union m_u; | |
27 | struct ethtool_flow_ext m_ext; | |
3a7da39d BH |
28 | compat_u64 ring_cookie; |
29 | u32 location; | |
30 | }; | |
31 | ||
32 | struct compat_ethtool_rxnfc { | |
33 | u32 cmd; | |
34 | u32 flow_type; | |
35 | compat_u64 data; | |
36 | struct compat_ethtool_rx_flow_spec fs; | |
37 | u32 rule_cnt; | |
5299a11a | 38 | u32 rule_locs[]; |
3a7da39d BH |
39 | }; |
40 | ||
a1467085 DM |
41 | #include <linux/rculist.h> |
42 | ||
68f512f2 BH |
43 | /** |
44 | * enum ethtool_phys_id_state - indicator state for physical identification | |
45 | * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated | |
46 | * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated | |
47 | * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE | |
48 | * is not supported) | |
49 | * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE | |
50 | * is not supported) | |
51 | */ | |
52 | enum ethtool_phys_id_state { | |
53 | ETHTOOL_ID_INACTIVE, | |
54 | ETHTOOL_ID_ACTIVE, | |
55 | ETHTOOL_ID_ON, | |
56 | ETHTOOL_ID_OFF | |
57 | }; | |
58 | ||
892311f6 EP |
59 | enum { |
60 | ETH_RSS_HASH_TOP_BIT, /* Configurable RSS hash function - Toeplitz */ | |
61 | ETH_RSS_HASH_XOR_BIT, /* Configurable RSS hash function - Xor */ | |
abb521e3 | 62 | ETH_RSS_HASH_CRC32_BIT, /* Configurable RSS hash function - Crc32 */ |
892311f6 EP |
63 | |
64 | /* | |
65 | * Add your fresh new hash function bits above and remember to update | |
66 | * rss_hash_func_strings[] in ethtool.c | |
67 | */ | |
68 | ETH_RSS_HASH_FUNCS_COUNT | |
69 | }; | |
70 | ||
0b70c256 HC |
71 | /** |
72 | * struct kernel_ethtool_ringparam - RX/TX ring configuration | |
73 | * @rx_buf_len: Current length of buffers on the rx ring. | |
9690ae60 | 74 | * @tcp_data_split: Scatter packet headers and data to separate buffers |
4dc84c06 | 75 | * @tx_push: The flag of tx push mode |
5b4e9a7a | 76 | * @rx_push: The flag of rx push mode |
1241e329 | 77 | * @cqe_size: Size of TX/RX completion queue event |
233eb4e7 SA |
78 | * @tx_push_buf_len: Size of TX push buffer |
79 | * @tx_push_buf_max_len: Maximum allowed size of TX push buffer | |
0b70c256 HC |
80 | */ |
81 | struct kernel_ethtool_ringparam { | |
82 | u32 rx_buf_len; | |
9690ae60 | 83 | u8 tcp_data_split; |
4dc84c06 | 84 | u8 tx_push; |
5b4e9a7a | 85 | u8 rx_push; |
1241e329 | 86 | u32 cqe_size; |
233eb4e7 SA |
87 | u32 tx_push_buf_len; |
88 | u32 tx_push_buf_max_len; | |
0b70c256 HC |
89 | }; |
90 | ||
91 | /** | |
92 | * enum ethtool_supported_ring_param - indicator caps for setting ring params | |
93 | * @ETHTOOL_RING_USE_RX_BUF_LEN: capture for setting rx_buf_len | |
1241e329 | 94 | * @ETHTOOL_RING_USE_CQE_SIZE: capture for setting cqe_size |
4dc84c06 | 95 | * @ETHTOOL_RING_USE_TX_PUSH: capture for setting tx_push |
5b4e9a7a | 96 | * @ETHTOOL_RING_USE_RX_PUSH: capture for setting rx_push |
233eb4e7 | 97 | * @ETHTOOL_RING_USE_TX_PUSH_BUF_LEN: capture for setting tx_push_buf_len |
50d73710 | 98 | * @ETHTOOL_RING_USE_TCP_DATA_SPLIT: capture for setting tcp_data_split |
0b70c256 HC |
99 | */ |
100 | enum ethtool_supported_ring_param { | |
233eb4e7 SA |
101 | ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0), |
102 | ETHTOOL_RING_USE_CQE_SIZE = BIT(1), | |
103 | ETHTOOL_RING_USE_TX_PUSH = BIT(2), | |
104 | ETHTOOL_RING_USE_RX_PUSH = BIT(3), | |
105 | ETHTOOL_RING_USE_TX_PUSH_BUF_LEN = BIT(4), | |
50d73710 | 106 | ETHTOOL_RING_USE_TCP_DATA_SPLIT = BIT(5), |
0b70c256 HC |
107 | }; |
108 | ||
892311f6 EP |
109 | #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit)) |
110 | #define __ETH_RSS_HASH(name) __ETH_RSS_HASH_BIT(ETH_RSS_HASH_##name##_BIT) | |
111 | ||
112 | #define ETH_RSS_HASH_TOP __ETH_RSS_HASH(TOP) | |
113 | #define ETH_RSS_HASH_XOR __ETH_RSS_HASH(XOR) | |
abb521e3 | 114 | #define ETH_RSS_HASH_CRC32 __ETH_RSS_HASH(CRC32) |
892311f6 EP |
115 | |
116 | #define ETH_RSS_HASH_UNKNOWN 0 | |
117 | #define ETH_RSS_HASH_NO_CHANGE 0 | |
118 | ||
1da177e4 | 119 | struct net_device; |
c781ff12 | 120 | struct netlink_ext_ack; |
1da177e4 | 121 | |
f0ebc2b6 | 122 | /* Link extended state and substate. */ |
ecc31c60 AC |
123 | struct ethtool_link_ext_state_info { |
124 | enum ethtool_link_ext_state link_ext_state; | |
125 | union { | |
126 | enum ethtool_link_ext_substate_autoneg autoneg; | |
127 | enum ethtool_link_ext_substate_link_training link_training; | |
128 | enum ethtool_link_ext_substate_link_logical_mismatch link_logical_mismatch; | |
129 | enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity; | |
130 | enum ethtool_link_ext_substate_cable_issue cable_issue; | |
3dfb5112 | 131 | enum ethtool_link_ext_substate_module module; |
e2f08207 | 132 | u32 __link_ext_substate; |
ecc31c60 AC |
133 | }; |
134 | }; | |
135 | ||
9a0f830f JK |
136 | struct ethtool_link_ext_stats { |
137 | /* Custom Linux statistic for PHY level link down events. | |
138 | * In a simpler world it should be equal to netdev->carrier_down_count | |
139 | * unfortunately netdev also counts local reconfigurations which don't | |
140 | * actually take the physical link down, not to mention NC-SI which, | |
141 | * if present, keeps the link up regardless of host state. | |
142 | * This statistic counts when PHY _actually_ went down, or lost link. | |
143 | * | |
144 | * Note that we need u64 for ethtool_stats_init() and comparisons | |
145 | * to ETHTOOL_STAT_NOT_SET, but only u32 is exposed to the user. | |
146 | */ | |
147 | u64 link_down_events; | |
148 | }; | |
149 | ||
278bc429 BH |
150 | /** |
151 | * ethtool_rxfh_indir_default - get default value for RX flow hash indirection | |
152 | * @index: Index in RX flow hash indirection table | |
153 | * @n_rx_rings: Number of RX rings to use | |
154 | * | |
155 | * This function provides the default policy for RX flow hash indirection. | |
156 | */ | |
157 | static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings) | |
158 | { | |
159 | return index % n_rx_rings; | |
160 | } | |
161 | ||
3f1ac7a7 DD |
162 | /* declare a link mode bitmap */ |
163 | #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \ | |
164 | DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS) | |
165 | ||
166 | /* drivers must ignore base.cmd and base.link_mode_masks_nwords | |
167 | * fields, but they are allowed to overwrite them (will be ignored). | |
168 | */ | |
169 | struct ethtool_link_ksettings { | |
170 | struct ethtool_link_settings base; | |
171 | struct { | |
172 | __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); | |
173 | __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); | |
174 | __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); | |
175 | } link_modes; | |
012ce4dd | 176 | u32 lanes; |
3f1ac7a7 DD |
177 | }; |
178 | ||
179 | /** | |
180 | * ethtool_link_ksettings_zero_link_mode - clear link_ksettings link mode mask | |
181 | * @ptr : pointer to struct ethtool_link_ksettings | |
182 | * @name : one of supported/advertising/lp_advertising | |
183 | */ | |
184 | #define ethtool_link_ksettings_zero_link_mode(ptr, name) \ | |
185 | bitmap_zero((ptr)->link_modes.name, __ETHTOOL_LINK_MODE_MASK_NBITS) | |
186 | ||
187 | /** | |
188 | * ethtool_link_ksettings_add_link_mode - set bit in link_ksettings | |
189 | * link mode mask | |
190 | * @ptr : pointer to struct ethtool_link_ksettings | |
191 | * @name : one of supported/advertising/lp_advertising | |
192 | * @mode : one of the ETHTOOL_LINK_MODE_*_BIT | |
193 | * (not atomic, no bound checking) | |
194 | */ | |
195 | #define ethtool_link_ksettings_add_link_mode(ptr, name, mode) \ | |
196 | __set_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) | |
197 | ||
606c07f3 LT |
198 | /** |
199 | * ethtool_link_ksettings_del_link_mode - clear bit in link_ksettings | |
200 | * link mode mask | |
201 | * @ptr : pointer to struct ethtool_link_ksettings | |
202 | * @name : one of supported/advertising/lp_advertising | |
203 | * @mode : one of the ETHTOOL_LINK_MODE_*_BIT | |
204 | * (not atomic, no bound checking) | |
205 | */ | |
206 | #define ethtool_link_ksettings_del_link_mode(ptr, name, mode) \ | |
207 | __clear_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) | |
208 | ||
3f1ac7a7 DD |
209 | /** |
210 | * ethtool_link_ksettings_test_link_mode - test bit in ksettings link mode mask | |
211 | * @ptr : pointer to struct ethtool_link_ksettings | |
212 | * @name : one of supported/advertising/lp_advertising | |
213 | * @mode : one of the ETHTOOL_LINK_MODE_*_BIT | |
214 | * (not atomic, no bound checking) | |
215 | * | |
216 | * Returns true/false. | |
217 | */ | |
218 | #define ethtool_link_ksettings_test_link_mode(ptr, name, mode) \ | |
219 | test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) | |
220 | ||
221 | extern int | |
222 | __ethtool_get_link_ksettings(struct net_device *dev, | |
223 | struct ethtool_link_ksettings *link_ksettings); | |
224 | ||
d80a5233 | 225 | struct ethtool_keee { |
1f069de6 HK |
226 | __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); |
227 | __ETHTOOL_DECLARE_LINK_MODE_MASK(advertised); | |
228 | __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertised); | |
d80a5233 | 229 | u32 tx_lpi_timer; |
285cc15c HK |
230 | bool tx_lpi_enabled; |
231 | bool eee_active; | |
232 | bool eee_enabled; | |
d80a5233 HK |
233 | }; |
234 | ||
029ee6b1 YM |
235 | struct kernel_ethtool_coalesce { |
236 | u8 use_cqe_mode_tx; | |
237 | u8 use_cqe_mode_rx; | |
31de2842 DP |
238 | u32 tx_aggr_max_bytes; |
239 | u32 tx_aggr_max_frames; | |
240 | u32 tx_aggr_time_usecs; | |
029ee6b1 YM |
241 | }; |
242 | ||
5a6cd6de AB |
243 | /** |
244 | * ethtool_intersect_link_masks - Given two link masks, AND them together | |
245 | * @dst: first mask and where result is stored | |
246 | * @src: second mask to intersect with | |
247 | * | |
248 | * Given two link mode masks, AND them together and save the result in dst. | |
249 | */ | |
250 | void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst, | |
251 | struct ethtool_link_ksettings *src); | |
252 | ||
6d62b4d5 PR |
253 | void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst, |
254 | u32 legacy_u32); | |
255 | ||
256 | /* return false if src had higher bits set. lower bits always updated. */ | |
257 | bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, | |
258 | const unsigned long *src); | |
259 | ||
95cddcb5 JK |
260 | #define ETHTOOL_COALESCE_RX_USECS BIT(0) |
261 | #define ETHTOOL_COALESCE_RX_MAX_FRAMES BIT(1) | |
262 | #define ETHTOOL_COALESCE_RX_USECS_IRQ BIT(2) | |
263 | #define ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ BIT(3) | |
264 | #define ETHTOOL_COALESCE_TX_USECS BIT(4) | |
265 | #define ETHTOOL_COALESCE_TX_MAX_FRAMES BIT(5) | |
266 | #define ETHTOOL_COALESCE_TX_USECS_IRQ BIT(6) | |
267 | #define ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ BIT(7) | |
268 | #define ETHTOOL_COALESCE_STATS_BLOCK_USECS BIT(8) | |
269 | #define ETHTOOL_COALESCE_USE_ADAPTIVE_RX BIT(9) | |
270 | #define ETHTOOL_COALESCE_USE_ADAPTIVE_TX BIT(10) | |
271 | #define ETHTOOL_COALESCE_PKT_RATE_LOW BIT(11) | |
272 | #define ETHTOOL_COALESCE_RX_USECS_LOW BIT(12) | |
273 | #define ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW BIT(13) | |
274 | #define ETHTOOL_COALESCE_TX_USECS_LOW BIT(14) | |
275 | #define ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW BIT(15) | |
276 | #define ETHTOOL_COALESCE_PKT_RATE_HIGH BIT(16) | |
277 | #define ETHTOOL_COALESCE_RX_USECS_HIGH BIT(17) | |
278 | #define ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH BIT(18) | |
279 | #define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19) | |
280 | #define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH BIT(20) | |
281 | #define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21) | |
029ee6b1 YM |
282 | #define ETHTOOL_COALESCE_USE_CQE_RX BIT(22) |
283 | #define ETHTOOL_COALESCE_USE_CQE_TX BIT(23) | |
31de2842 DP |
284 | #define ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES BIT(24) |
285 | #define ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES BIT(25) | |
286 | #define ETHTOOL_COALESCE_TX_AGGR_TIME_USECS BIT(26) | |
287 | #define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(26, 0) | |
95cddcb5 JK |
288 | |
289 | #define ETHTOOL_COALESCE_USECS \ | |
290 | (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS) | |
291 | #define ETHTOOL_COALESCE_MAX_FRAMES \ | |
292 | (ETHTOOL_COALESCE_RX_MAX_FRAMES | ETHTOOL_COALESCE_TX_MAX_FRAMES) | |
293 | #define ETHTOOL_COALESCE_USECS_IRQ \ | |
294 | (ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ) | |
295 | #define ETHTOOL_COALESCE_MAX_FRAMES_IRQ \ | |
296 | (ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | \ | |
297 | ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ) | |
298 | #define ETHTOOL_COALESCE_USE_ADAPTIVE \ | |
299 | (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_ADAPTIVE_TX) | |
8213f6c9 JK |
300 | #define ETHTOOL_COALESCE_USECS_LOW_HIGH \ |
301 | (ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_TX_USECS_LOW | \ | |
302 | ETHTOOL_COALESCE_RX_USECS_HIGH | ETHTOOL_COALESCE_TX_USECS_HIGH) | |
4f9546d2 JK |
303 | #define ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH \ |
304 | (ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW | \ | |
305 | ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW | \ | |
306 | ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH | \ | |
307 | ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH) | |
812df69b JK |
308 | #define ETHTOOL_COALESCE_PKT_RATE_RX_USECS \ |
309 | (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | \ | |
310 | ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_RX_USECS_HIGH | \ | |
311 | ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \ | |
312 | ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL) | |
029ee6b1 YM |
313 | #define ETHTOOL_COALESCE_USE_CQE \ |
314 | (ETHTOOL_COALESCE_USE_CQE_RX | ETHTOOL_COALESCE_USE_CQE_TX) | |
31de2842 DP |
315 | #define ETHTOOL_COALESCE_TX_AGGR \ |
316 | (ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES | \ | |
317 | ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES | \ | |
318 | ETHTOOL_COALESCE_TX_AGGR_TIME_USECS) | |
95cddcb5 | 319 | |
9a27a330 JK |
320 | #define ETHTOOL_STAT_NOT_SET (~0ULL) |
321 | ||
c5797f8a JK |
322 | static inline void ethtool_stats_init(u64 *stats, unsigned int n) |
323 | { | |
324 | while (n--) | |
325 | stats[n] = ETHTOOL_STAT_NOT_SET; | |
326 | } | |
327 | ||
ca224454 JK |
328 | /* Basic IEEE 802.3 MAC statistics (30.3.1.1.*), not otherwise exposed |
329 | * via a more targeted API. | |
330 | */ | |
331 | struct ethtool_eth_mac_stats { | |
04692c90 | 332 | enum ethtool_mac_stats_src src; |
449c5459 VO |
333 | struct_group(stats, |
334 | u64 FramesTransmittedOK; | |
335 | u64 SingleCollisionFrames; | |
336 | u64 MultipleCollisionFrames; | |
337 | u64 FramesReceivedOK; | |
338 | u64 FrameCheckSequenceErrors; | |
339 | u64 AlignmentErrors; | |
340 | u64 OctetsTransmittedOK; | |
341 | u64 FramesWithDeferredXmissions; | |
342 | u64 LateCollisions; | |
343 | u64 FramesAbortedDueToXSColls; | |
344 | u64 FramesLostDueToIntMACXmitError; | |
345 | u64 CarrierSenseErrors; | |
346 | u64 OctetsReceivedOK; | |
347 | u64 FramesLostDueToIntMACRcvError; | |
348 | u64 MulticastFramesXmittedOK; | |
349 | u64 BroadcastFramesXmittedOK; | |
350 | u64 FramesWithExcessiveDeferral; | |
351 | u64 MulticastFramesReceivedOK; | |
352 | u64 BroadcastFramesReceivedOK; | |
353 | u64 InRangeLengthErrors; | |
354 | u64 OutOfRangeLengthField; | |
355 | u64 FrameTooLongErrors; | |
356 | ); | |
ca224454 JK |
357 | }; |
358 | ||
f09ea6fb JK |
359 | /* Basic IEEE 802.3 PHY statistics (30.3.2.1.*), not otherwise exposed |
360 | * via a more targeted API. | |
361 | */ | |
362 | struct ethtool_eth_phy_stats { | |
04692c90 | 363 | enum ethtool_mac_stats_src src; |
449c5459 VO |
364 | struct_group(stats, |
365 | u64 SymbolErrorDuringCarrier; | |
366 | ); | |
f09ea6fb JK |
367 | }; |
368 | ||
bfad2b97 JK |
369 | /* Basic IEEE 802.3 MAC Ctrl statistics (30.3.3.*), not otherwise exposed |
370 | * via a more targeted API. | |
371 | */ | |
372 | struct ethtool_eth_ctrl_stats { | |
04692c90 | 373 | enum ethtool_mac_stats_src src; |
449c5459 VO |
374 | struct_group(stats, |
375 | u64 MACControlFramesTransmitted; | |
376 | u64 MACControlFramesReceived; | |
377 | u64 UnsupportedOpcodesReceived; | |
378 | ); | |
bfad2b97 JK |
379 | }; |
380 | ||
9a27a330 JK |
381 | /** |
382 | * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames | |
04692c90 VO |
383 | * @src: input field denoting whether stats should be queried from the eMAC or |
384 | * pMAC (if the MM layer is supported). To be ignored otherwise. | |
9a27a330 JK |
385 | * @tx_pause_frames: transmitted pause frame count. Reported to user space |
386 | * as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES. | |
387 | * | |
388 | * Equivalent to `30.3.4.2 aPAUSEMACCtrlFramesTransmitted` | |
389 | * from the standard. | |
390 | * | |
391 | * @rx_pause_frames: received pause frame count. Reported to user space | |
392 | * as %ETHTOOL_A_PAUSE_STAT_RX_FRAMES. Equivalent to: | |
393 | * | |
394 | * Equivalent to `30.3.4.3 aPAUSEMACCtrlFramesReceived` | |
395 | * from the standard. | |
396 | */ | |
397 | struct ethtool_pause_stats { | |
04692c90 | 398 | enum ethtool_mac_stats_src src; |
449c5459 VO |
399 | struct_group(stats, |
400 | u64 tx_pause_frames; | |
401 | u64 rx_pause_frames; | |
402 | ); | |
9a27a330 JK |
403 | }; |
404 | ||
be85dbfe JK |
405 | #define ETHTOOL_MAX_LANES 8 |
406 | ||
407 | /** | |
408 | * struct ethtool_fec_stats - statistics for IEEE 802.3 FEC | |
409 | * @corrected_blocks: number of received blocks corrected by FEC | |
410 | * Reported to user space as %ETHTOOL_A_FEC_STAT_CORRECTED. | |
411 | * | |
412 | * Equivalent to `30.5.1.1.17 aFECCorrectedBlocks` from the standard. | |
413 | * | |
414 | * @uncorrectable_blocks: number of received blocks FEC was not able to correct | |
415 | * Reported to user space as %ETHTOOL_A_FEC_STAT_UNCORR. | |
416 | * | |
417 | * Equivalent to `30.5.1.1.18 aFECUncorrectableBlocks` from the standard. | |
418 | * | |
419 | * @corrected_bits: number of bits corrected by FEC | |
420 | * Similar to @corrected_blocks but counts individual bit changes, | |
421 | * not entire FEC data blocks. This is a non-standard statistic. | |
422 | * Reported to user space as %ETHTOOL_A_FEC_STAT_CORR_BITS. | |
423 | * | |
1271ca00 JC |
424 | * For each of the above fields, the two substructure members are: |
425 | * | |
426 | * - @lanes: per-lane/PCS-instance counts as defined by the standard | |
427 | * - @total: error counts for the entire port, for drivers incapable of reporting | |
be85dbfe JK |
428 | * per-lane stats |
429 | * | |
430 | * Drivers should fill in either only total or per-lane statistics, core | |
431 | * will take care of adding lane values up to produce the total. | |
432 | */ | |
433 | struct ethtool_fec_stats { | |
434 | struct ethtool_fec_stat { | |
435 | u64 total; | |
436 | u64 lanes[ETHTOOL_MAX_LANES]; | |
437 | } corrected_blocks, uncorrectable_blocks, corrected_bits; | |
438 | }; | |
439 | ||
a8b06e9d JK |
440 | /** |
441 | * struct ethtool_rmon_hist_range - byte range for histogram statistics | |
442 | * @low: low bound of the bucket (inclusive) | |
443 | * @high: high bound of the bucket (inclusive) | |
444 | */ | |
445 | struct ethtool_rmon_hist_range { | |
446 | u16 low; | |
447 | u16 high; | |
448 | }; | |
449 | ||
450 | #define ETHTOOL_RMON_HIST_MAX 10 | |
451 | ||
452 | /** | |
453 | * struct ethtool_rmon_stats - selected RMON (RFC 2819) statistics | |
04692c90 VO |
454 | * @src: input field denoting whether stats should be queried from the eMAC or |
455 | * pMAC (if the MM layer is supported). To be ignored otherwise. | |
a8b06e9d JK |
456 | * @undersize_pkts: Equivalent to `etherStatsUndersizePkts` from the RFC. |
457 | * @oversize_pkts: Equivalent to `etherStatsOversizePkts` from the RFC. | |
458 | * @fragments: Equivalent to `etherStatsFragments` from the RFC. | |
459 | * @jabbers: Equivalent to `etherStatsJabbers` from the RFC. | |
460 | * @hist: Packet counter for packet length buckets (e.g. | |
461 | * `etherStatsPkts128to255Octets` from the RFC). | |
462 | * @hist_tx: Tx counters in similar form to @hist, not defined in the RFC. | |
463 | * | |
464 | * Selection of RMON (RFC 2819) statistics which are not exposed via different | |
465 | * APIs, primarily the packet-length-based counters. | |
466 | * Unfortunately different designs choose different buckets beyond | |
467 | * the 1024B mark (jumbo frame teritory), so the definition of the bucket | |
468 | * ranges is left to the driver. | |
469 | */ | |
470 | struct ethtool_rmon_stats { | |
04692c90 | 471 | enum ethtool_mac_stats_src src; |
449c5459 VO |
472 | struct_group(stats, |
473 | u64 undersize_pkts; | |
474 | u64 oversize_pkts; | |
475 | u64 fragments; | |
476 | u64 jabbers; | |
477 | ||
478 | u64 hist[ETHTOOL_RMON_HIST_MAX]; | |
479 | u64 hist_tx[ETHTOOL_RMON_HIST_MAX]; | |
480 | ); | |
a8b06e9d JK |
481 | }; |
482 | ||
c781ff12 VT |
483 | #define ETH_MODULE_EEPROM_PAGE_LEN 128 |
484 | #define ETH_MODULE_MAX_I2C_ADDRESS 0x7f | |
485 | ||
486 | /** | |
487 | * struct ethtool_module_eeprom - EEPROM dump from specified page | |
488 | * @offset: Offset within the specified EEPROM page to begin read, in bytes. | |
489 | * @length: Number of bytes to read. | |
490 | * @page: Page number to read from. | |
491 | * @bank: Page bank number to read from, if applicable by EEPROM spec. | |
492 | * @i2c_address: I2C address of a page. Value less than 0x7f expected. Most | |
493 | * EEPROMs use 0x50 or 0x51. | |
494 | * @data: Pointer to buffer with EEPROM data of @length size. | |
495 | * | |
496 | * This can be used to manage pages during EEPROM dump in ethtool and pass | |
497 | * required information to the driver. | |
498 | */ | |
499 | struct ethtool_module_eeprom { | |
b8c48be2 IS |
500 | u32 offset; |
501 | u32 length; | |
502 | u8 page; | |
503 | u8 bank; | |
504 | u8 i2c_address; | |
505 | u8 *data; | |
c781ff12 VT |
506 | }; |
507 | ||
353407d9 IS |
508 | /** |
509 | * struct ethtool_module_power_mode_params - module power mode parameters | |
510 | * @policy: The power mode policy enforced by the host for the plug-in module. | |
511 | * @mode: The operational power mode of the plug-in module. Should be filled by | |
512 | * device drivers on get operations. | |
513 | */ | |
514 | struct ethtool_module_power_mode_params { | |
515 | enum ethtool_module_power_mode_policy policy; | |
516 | enum ethtool_module_power_mode mode; | |
517 | }; | |
518 | ||
2b30f829 VO |
519 | /** |
520 | * struct ethtool_mm_state - 802.3 MAC merge layer state | |
521 | * @verify_time: | |
522 | * wait time between verification attempts in ms (according to clause | |
523 | * 30.14.1.6 aMACMergeVerifyTime) | |
524 | * @max_verify_time: | |
525 | * maximum accepted value for the @verify_time variable in set requests | |
526 | * @verify_status: | |
527 | * state of the verification state machine of the MM layer (according to | |
528 | * clause 30.14.1.2 aMACMergeStatusVerify) | |
529 | * @tx_enabled: | |
530 | * set if the MM layer is administratively enabled in the TX direction | |
531 | * (according to clause 30.14.1.3 aMACMergeEnableTx) | |
532 | * @tx_active: | |
533 | * set if the MM layer is enabled in the TX direction, which makes FP | |
534 | * possible (according to 30.14.1.5 aMACMergeStatusTx). This should be | |
535 | * true if MM is enabled, and the verification status is either verified, | |
536 | * or disabled. | |
537 | * @pmac_enabled: | |
538 | * set if the preemptible MAC is powered on and is able to receive | |
539 | * preemptible packets and respond to verification frames. | |
540 | * @verify_enabled: | |
541 | * set if the Verify function of the MM layer (which sends SMD-V | |
542 | * verification requests) is administratively enabled (regardless of | |
543 | * whether it is currently in the ETHTOOL_MM_VERIFY_STATUS_DISABLED state | |
544 | * or not), according to clause 30.14.1.4 aMACMergeVerifyDisableTx (but | |
545 | * using positive rather than negative logic). The device should always | |
546 | * respond to received SMD-V requests as long as @pmac_enabled is set. | |
547 | * @tx_min_frag_size: | |
548 | * the minimum size of non-final mPacket fragments that the link partner | |
549 | * supports receiving, expressed in octets. Compared to the definition | |
550 | * from clause 30.14.1.7 aMACMergeAddFragSize which is expressed in the | |
551 | * range 0 to 3 (requiring a translation to the size in octets according | |
552 | * to the formula 64 * (1 + addFragSize) - 4), a value in a continuous and | |
553 | * unbounded range can be specified here. | |
554 | * @rx_min_frag_size: | |
555 | * the minimum size of non-final mPacket fragments that this device | |
556 | * supports receiving, expressed in octets. | |
557 | */ | |
558 | struct ethtool_mm_state { | |
559 | u32 verify_time; | |
560 | u32 max_verify_time; | |
561 | enum ethtool_mm_verify_status verify_status; | |
562 | bool tx_enabled; | |
563 | bool tx_active; | |
564 | bool pmac_enabled; | |
565 | bool verify_enabled; | |
566 | u32 tx_min_frag_size; | |
567 | u32 rx_min_frag_size; | |
568 | }; | |
569 | ||
570 | /** | |
571 | * struct ethtool_mm_cfg - 802.3 MAC merge layer configuration | |
572 | * @verify_time: see struct ethtool_mm_state | |
573 | * @verify_enabled: see struct ethtool_mm_state | |
574 | * @tx_enabled: see struct ethtool_mm_state | |
575 | * @pmac_enabled: see struct ethtool_mm_state | |
576 | * @tx_min_frag_size: see struct ethtool_mm_state | |
577 | */ | |
578 | struct ethtool_mm_cfg { | |
579 | u32 verify_time; | |
580 | bool verify_enabled; | |
581 | bool tx_enabled; | |
582 | bool pmac_enabled; | |
583 | u32 tx_min_frag_size; | |
584 | }; | |
585 | ||
586 | /** | |
587 | * struct ethtool_mm_stats - 802.3 MAC merge layer statistics | |
588 | * @MACMergeFrameAssErrorCount: | |
589 | * received MAC frames with reassembly errors | |
590 | * @MACMergeFrameSmdErrorCount: | |
591 | * received MAC frames/fragments rejected due to unknown or incorrect SMD | |
592 | * @MACMergeFrameAssOkCount: | |
593 | * received MAC frames that were successfully reassembled and passed up | |
594 | * @MACMergeFragCountRx: | |
595 | * number of additional correct SMD-C mPackets received due to preemption | |
596 | * @MACMergeFragCountTx: | |
597 | * number of additional mPackets sent due to preemption | |
598 | * @MACMergeHoldCount: | |
599 | * number of times the MM layer entered the HOLD state, which blocks | |
600 | * transmission of preemptible traffic | |
601 | */ | |
602 | struct ethtool_mm_stats { | |
603 | u64 MACMergeFrameAssErrorCount; | |
604 | u64 MACMergeFrameSmdErrorCount; | |
605 | u64 MACMergeFrameAssOkCount; | |
606 | u64 MACMergeFragCountRx; | |
607 | u64 MACMergeFragCountTx; | |
608 | u64 MACMergeHoldCount; | |
609 | }; | |
610 | ||
fb6e30a7 AZ |
611 | /** |
612 | * struct ethtool_rxfh_param - RXFH (RSS) parameters | |
613 | * @hfunc: Defines the current RSS hash function used by HW (or to be set to). | |
614 | * Valid values are one of the %ETH_RSS_HASH_*. | |
615 | * @indir_size: On SET, the array size of the user buffer for the | |
616 | * indirection table, which may be zero, or | |
617 | * %ETH_RXFH_INDIR_NO_CHANGE. On GET (read from the driver), | |
618 | * the array size of the hardware indirection table. | |
619 | * @indir: The indirection table of size @indir_size entries. | |
620 | * @key_size: On SET, the array size of the user buffer for the hash key, | |
621 | * which may be zero. On GET (read from the driver), the size of the | |
622 | * hardware hash key. | |
623 | * @key: The hash key of size @key_size bytes. | |
dcd8dbf9 AZ |
624 | * @rss_context: RSS context identifier. Context 0 is the default for normal |
625 | * traffic; other contexts can be referenced as the destination for RX flow | |
626 | * classification rules. On SET, %ETH_RXFH_CONTEXT_ALLOC is used | |
627 | * to allocate a new RSS context; on return this field will | |
628 | * contain the ID of the newly allocated context. | |
629 | * @rss_delete: Set to non-ZERO to remove the @rss_context context. | |
13e59344 AZ |
630 | * @input_xfrm: Defines how the input data is transformed. Valid values are one |
631 | * of %RXH_XFRM_*. | |
fb6e30a7 AZ |
632 | */ |
633 | struct ethtool_rxfh_param { | |
634 | u8 hfunc; | |
635 | u32 indir_size; | |
636 | u32 *indir; | |
637 | u32 key_size; | |
638 | u8 *key; | |
dcd8dbf9 AZ |
639 | u32 rss_context; |
640 | u8 rss_delete; | |
13e59344 | 641 | u8 input_xfrm; |
fb6e30a7 AZ |
642 | }; |
643 | ||
1da177e4 | 644 | /** |
8717d07b | 645 | * struct ethtool_ops - optional netdev operations |
012ce4dd DR |
646 | * @cap_link_lanes_supported: indicates if the driver supports lanes |
647 | * parameter. | |
dcd8dbf9 AZ |
648 | * @cap_rss_ctx_supported: indicates if the driver supports RSS |
649 | * contexts. | |
13e59344 AZ |
650 | * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor |
651 | * RSS. | |
95cddcb5 | 652 | * @supported_coalesce_params: supported types of interrupt coalescing. |
0b70c256 | 653 | * @supported_ring_params: supported ring params. |
f20a0a05 VM |
654 | * @get_drvinfo: Report driver/device information. Modern drivers no |
655 | * longer have to implement this callback. Most fields are | |
656 | * correctly filled in by the core using system information, or | |
657 | * populated using other driver operations. | |
8717d07b | 658 | * @get_regs_len: Get buffer length required for @get_regs |
e20b5b61 BH |
659 | * @get_regs: Get device registers |
660 | * @get_wol: Report whether Wake-on-Lan is enabled | |
8717d07b BH |
661 | * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code |
662 | * or zero. | |
663 | * @get_msglevel: Report driver message level. This should be the value | |
664 | * of the @msg_enable field used by netif logging functions. | |
e20b5b61 | 665 | * @set_msglevel: Set driver message level |
8717d07b BH |
666 | * @nway_reset: Restart autonegotiation. Returns a negative error code |
667 | * or zero. | |
668 | * @get_link: Report whether physical link is up. Will only be called if | |
669 | * the netdev is up. Should usually be set to ethtool_op_get_link(), | |
670 | * which uses netif_carrier_ok(). | |
ecc31c60 AC |
671 | * @get_link_ext_state: Report link extended state. Should set link_ext_state and |
672 | * link_ext_substate (link_ext_substate of 0 means link_ext_substate is unknown, | |
673 | * do not attach ext_substate attribute to netlink message). If link_ext_state | |
674 | * and link_ext_substate are unknown, return -ENODATA. If not implemented, | |
675 | * link_ext_state and link_ext_substate will not be sent to userspace. | |
9a0f830f | 676 | * @get_link_ext_stats: Read extra link-related counters. |
d9c65de0 JK |
677 | * @get_eeprom_len: Read range of EEPROM addresses for validation of |
678 | * @get_eeprom and @set_eeprom requests. | |
679 | * Returns 0 if device does not support EEPROM access. | |
e20b5b61 | 680 | * @get_eeprom: Read data from the device EEPROM. |
1da177e4 LT |
681 | * Should fill in the magic field. Don't need to check len for zero |
682 | * or wraparound. Fill in the data argument with the eeprom values | |
683 | * from offset to offset + len. Update len to the amount read. | |
684 | * Returns an error or zero. | |
e20b5b61 | 685 | * @set_eeprom: Write data to the device EEPROM. |
1da177e4 LT |
686 | * Should validate the magic field. Don't need to check len for zero |
687 | * or wraparound. Update len to the amount written. Returns an error | |
688 | * or zero. | |
8717d07b BH |
689 | * @get_coalesce: Get interrupt coalescing parameters. Returns a negative |
690 | * error code or zero. | |
95cddcb5 JK |
691 | * @set_coalesce: Set interrupt coalescing parameters. Supported coalescing |
692 | * types should be set in @supported_coalesce_params. | |
693 | * Returns a negative error code or zero. | |
e20b5b61 | 694 | * @get_ringparam: Report ring sizes |
8717d07b | 695 | * @set_ringparam: Set ring sizes. Returns a negative error code or zero. |
9a27a330 JK |
696 | * @get_pause_stats: Report pause frame statistics. Drivers must not zero |
697 | * statistics which they don't report. The stats structure is initialized | |
698 | * to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics. | |
e20b5b61 | 699 | * @get_pauseparam: Report pause parameters |
8717d07b BH |
700 | * @set_pauseparam: Set pause parameters. Returns a negative error code |
701 | * or zero. | |
e20b5b61 BH |
702 | * @self_test: Run specified self-tests |
703 | * @get_strings: Return a set of strings that describe the requested objects | |
68f512f2 BH |
704 | * @set_phys_id: Identify the physical devices, e.g. by flashing an LED |
705 | * attached to it. The implementation may update the indicator | |
706 | * asynchronously or synchronously, but in either case it must return | |
707 | * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE, | |
fce55922 AB |
708 | * and must either activate asynchronous updates and return zero, return |
709 | * a negative error or return a positive frequency for synchronous | |
710 | * indication (e.g. 1 for one on/off cycle per second). If it returns | |
711 | * a frequency then it will be called again at intervals with the | |
68f512f2 BH |
712 | * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of |
713 | * the indicator accordingly. Finally, it is called with the argument | |
714 | * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a | |
715 | * negative error code or zero. | |
8717d07b BH |
716 | * @get_ethtool_stats: Return extended statistics about the device. |
717 | * This is only useful if the device maintains statistics not | |
718 | * included in &struct rtnl_link_stats64. | |
719 | * @begin: Function to be called before any other operation. Returns a | |
720 | * negative error code or zero. | |
721 | * @complete: Function to be called after any other operation except | |
722 | * @begin. Will be called even if the other operation failed. | |
8717d07b BH |
723 | * @get_priv_flags: Report driver-specific feature flags. |
724 | * @set_priv_flags: Set driver-specific feature flags. Returns a negative | |
725 | * error code or zero. | |
726 | * @get_sset_count: Get number of strings that @get_strings will write. | |
727 | * @get_rxnfc: Get RX flow classification rules. Returns a negative | |
728 | * error code or zero. | |
729 | * @set_rxnfc: Set RX flow classification rules. Returns a negative | |
730 | * error code or zero. | |
731 | * @flash_device: Write a firmware image to device's flash memory. | |
732 | * Returns a negative error code or zero. | |
733 | * @reset: Reset (part of) the device, as specified by a bitmask of | |
734 | * flags from &enum ethtool_reset_flags. Returns a negative | |
735 | * error code or zero. | |
3de0b592 VD |
736 | * @get_rxfh_key_size: Get the size of the RX flow hash key. |
737 | * Returns zero if not supported for this specific device. | |
7850f63f BH |
738 | * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table. |
739 | * Returns zero if not supported for this specific device. | |
892311f6 EP |
740 | * @get_rxfh: Get the contents of the RX flow hash indirection table, hash key |
741 | * and/or hash function. | |
8717d07b | 742 | * Returns a negative error code or zero. |
892311f6 EP |
743 | * @set_rxfh: Set the contents of the RX flow hash indirection table, hash |
744 | * key, and/or hash function. Arguments which are set to %NULL or zero | |
745 | * will remain unchanged. | |
746 | * Returns a negative error code or zero. An error code must be returned | |
747 | * if at least one unsupported change was requested. | |
8b5933c3 | 748 | * @get_channels: Get number of channels. |
749 | * @set_channels: Set number of channels. Returns a negative error code or | |
750 | * zero. | |
29dd54b7 AC |
751 | * @get_dump_flag: Get dump flag indicating current dump length, version, |
752 | * and flag of the device. | |
753 | * @get_dump_data: Get dump data. | |
754 | * @set_dump: Set dump specific flags to the device. | |
c8f3a8c3 | 755 | * @get_ts_info: Get the time stamping and PTP hardware clock capabilities. |
980f0799 | 756 | * It may be called with RCU, or rtnl or reference on the device. |
c8f3a8c3 RC |
757 | * Drivers supporting transmit time stamps in software should set this to |
758 | * ethtool_op_get_ts_info(). | |
41c3cb6d SH |
759 | * @get_module_info: Get the size and type of the eeprom contained within |
760 | * a plug-in module. | |
761 | * @get_module_eeprom: Get the eeprom information from the plug-in module | |
80f12ecc YM |
762 | * @get_eee: Get Energy-Efficient (EEE) supported and status. |
763 | * @set_eee: Set EEE status (enable/disable) as well as LPI timers. | |
d9c65de0 JK |
764 | * @get_tunable: Read the value of a driver / device tunable. |
765 | * @set_tunable: Set the value of a driver / device tunable. | |
421797b1 KL |
766 | * @get_per_queue_coalesce: Get interrupt coalescing parameters per queue. |
767 | * It must check that the given queue number is valid. If neither a RX nor | |
768 | * a TX queue has this number, return -EINVAL. If only a RX queue or a TX | |
769 | * queue has this number, set the inapplicable fields to ~0 and return 0. | |
770 | * Returns a negative error code or zero. | |
f38d138a KL |
771 | * @set_per_queue_coalesce: Set interrupt coalescing parameters per queue. |
772 | * It must check that the given queue number is valid. If neither a RX nor | |
773 | * a TX queue has this number, return -EINVAL. If only a RX queue or a TX | |
95cddcb5 JK |
774 | * queue has this number, ignore the inapplicable fields. Supported |
775 | * coalescing types should be set in @supported_coalesce_params. | |
f38d138a | 776 | * Returns a negative error code or zero. |
9b300495 MK |
777 | * @get_link_ksettings: Get various device settings including Ethernet link |
778 | * settings. The %cmd and %link_mode_masks_nwords fields should be | |
779 | * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), | |
780 | * any change to them will be overwritten by kernel. Returns a negative | |
781 | * error code or zero. | |
782 | * @set_link_ksettings: Set various device settings including Ethernet link | |
783 | * settings. The %cmd and %link_mode_masks_nwords fields should be | |
784 | * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), | |
785 | * any change to them will be overwritten by kernel. Returns a negative | |
786 | * error code or zero. | |
be85dbfe JK |
787 | * @get_fec_stats: Report FEC statistics. |
788 | * Core will sum up per-lane stats to get the total. | |
789 | * Drivers must not zero statistics which they don't report. The stats | |
790 | * structure is initialized to ETHTOOL_STAT_NOT_SET indicating driver does | |
791 | * not report statistics. | |
d805c520 FF |
792 | * @get_fecparam: Get the network device Forward Error Correction parameters. |
793 | * @set_fecparam: Set the network device Forward Error Correction parameters. | |
99943382 FF |
794 | * @get_ethtool_phy_stats: Return extended statistics about the PHY device. |
795 | * This is only useful if the device maintains PHY statistics and | |
796 | * cannot use the standard PHY library helpers. | |
56f15e2c JK |
797 | * @get_phy_tunable: Read the value of a PHY tunable. |
798 | * @set_phy_tunable: Set the value of a PHY tunable. | |
c781ff12 VT |
799 | * @get_module_eeprom_by_page: Get a region of plug-in module EEPROM data from |
800 | * specified page. Returns a negative error code or the amount of bytes | |
801 | * read. | |
f09ea6fb | 802 | * @get_eth_phy_stats: Query some of the IEEE 802.3 PHY statistics. |
ca224454 | 803 | * @get_eth_mac_stats: Query some of the IEEE 802.3 MAC statistics. |
bfad2b97 | 804 | * @get_eth_ctrl_stats: Query some of the IEEE 802.3 MAC Ctrl statistics. |
a8b06e9d JK |
805 | * @get_rmon_stats: Query some of the RMON (RFC 2819) statistics. |
806 | * Set %ranges to a pointer to zero-terminated array of byte ranges. | |
353407d9 IS |
807 | * @get_module_power_mode: Get the power mode policy for the plug-in module |
808 | * used by the network device and its operational power mode, if | |
809 | * plugged-in. | |
810 | * @set_module_power_mode: Set the power mode policy for the plug-in module | |
811 | * used by the network device. | |
2b30f829 VO |
812 | * @get_mm: Query the 802.3 MAC Merge layer state. |
813 | * @set_mm: Set the 802.3 MAC Merge layer parameters. | |
814 | * @get_mm_stats: Query the 802.3 MAC Merge layer statistics. | |
8717d07b BH |
815 | * |
816 | * All operations are optional (i.e. the function pointer may be set | |
817 | * to %NULL) and callers must take this into account. Callers must | |
b4f79e5c | 818 | * hold the RTNL lock. |
8717d07b BH |
819 | * |
820 | * See the structures used by these operations for further documentation. | |
6e201c85 BH |
821 | * Note that for all operations using a structure ending with a zero- |
822 | * length array, the array is allocated separately in the kernel and | |
823 | * is passed to the driver as an additional parameter. | |
8717d07b BH |
824 | * |
825 | * See &struct net_device and &struct net_device_ops for documentation | |
826 | * of the generic netdev features interface. | |
1da177e4 LT |
827 | */ |
828 | struct ethtool_ops { | |
012ce4dd | 829 | u32 cap_link_lanes_supported:1; |
dcd8dbf9 | 830 | u32 cap_rss_ctx_supported:1; |
13e59344 | 831 | u32 cap_rss_sym_xor_supported:1; |
95cddcb5 | 832 | u32 supported_coalesce_params; |
0b70c256 | 833 | u32 supported_ring_params; |
1da177e4 LT |
834 | void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *); |
835 | int (*get_regs_len)(struct net_device *); | |
836 | void (*get_regs)(struct net_device *, struct ethtool_regs *, void *); | |
837 | void (*get_wol)(struct net_device *, struct ethtool_wolinfo *); | |
838 | int (*set_wol)(struct net_device *, struct ethtool_wolinfo *); | |
839 | u32 (*get_msglevel)(struct net_device *); | |
840 | void (*set_msglevel)(struct net_device *, u32); | |
841 | int (*nway_reset)(struct net_device *); | |
842 | u32 (*get_link)(struct net_device *); | |
ecc31c60 AC |
843 | int (*get_link_ext_state)(struct net_device *, |
844 | struct ethtool_link_ext_state_info *); | |
9a0f830f JK |
845 | void (*get_link_ext_stats)(struct net_device *dev, |
846 | struct ethtool_link_ext_stats *stats); | |
1da177e4 | 847 | int (*get_eeprom_len)(struct net_device *); |
97f8aefb | 848 | int (*get_eeprom)(struct net_device *, |
849 | struct ethtool_eeprom *, u8 *); | |
850 | int (*set_eeprom)(struct net_device *, | |
851 | struct ethtool_eeprom *, u8 *); | |
f3ccfda1 YM |
852 | int (*get_coalesce)(struct net_device *, |
853 | struct ethtool_coalesce *, | |
854 | struct kernel_ethtool_coalesce *, | |
855 | struct netlink_ext_ack *); | |
856 | int (*set_coalesce)(struct net_device *, | |
857 | struct ethtool_coalesce *, | |
858 | struct kernel_ethtool_coalesce *, | |
859 | struct netlink_ext_ack *); | |
97f8aefb | 860 | void (*get_ringparam)(struct net_device *, |
74624944 HC |
861 | struct ethtool_ringparam *, |
862 | struct kernel_ethtool_ringparam *, | |
863 | struct netlink_ext_ack *); | |
97f8aefb | 864 | int (*set_ringparam)(struct net_device *, |
74624944 HC |
865 | struct ethtool_ringparam *, |
866 | struct kernel_ethtool_ringparam *, | |
867 | struct netlink_ext_ack *); | |
9a27a330 JK |
868 | void (*get_pause_stats)(struct net_device *dev, |
869 | struct ethtool_pause_stats *pause_stats); | |
97f8aefb | 870 | void (*get_pauseparam)(struct net_device *, |
871 | struct ethtool_pauseparam*); | |
872 | int (*set_pauseparam)(struct net_device *, | |
873 | struct ethtool_pauseparam*); | |
1da177e4 LT |
874 | void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); |
875 | void (*get_strings)(struct net_device *, u32 stringset, u8 *); | |
68f512f2 | 876 | int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state); |
97f8aefb | 877 | void (*get_ethtool_stats)(struct net_device *, |
878 | struct ethtool_stats *, u64 *); | |
1da177e4 LT |
879 | int (*begin)(struct net_device *); |
880 | void (*complete)(struct net_device *); | |
97f8aefb | 881 | u32 (*get_priv_flags)(struct net_device *); |
882 | int (*set_priv_flags)(struct net_device *, u32); | |
ff03d49f | 883 | int (*get_sset_count)(struct net_device *, int); |
97f8aefb | 884 | int (*get_rxnfc)(struct net_device *, |
815c7db5 | 885 | struct ethtool_rxnfc *, u32 *rule_locs); |
59089d8d | 886 | int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *); |
97f8aefb | 887 | int (*flash_device)(struct net_device *, struct ethtool_flash *); |
d73d3a8c | 888 | int (*reset)(struct net_device *, u32 *); |
3de0b592 | 889 | u32 (*get_rxfh_key_size)(struct net_device *); |
7850f63f | 890 | u32 (*get_rxfh_indir_size)(struct net_device *); |
fb6e30a7 AZ |
891 | int (*get_rxfh)(struct net_device *, struct ethtool_rxfh_param *); |
892 | int (*set_rxfh)(struct net_device *, struct ethtool_rxfh_param *, | |
893 | struct netlink_ext_ack *extack); | |
8b5933c3 | 894 | void (*get_channels)(struct net_device *, struct ethtool_channels *); |
895 | int (*set_channels)(struct net_device *, struct ethtool_channels *); | |
29dd54b7 AC |
896 | int (*get_dump_flag)(struct net_device *, struct ethtool_dump *); |
897 | int (*get_dump_data)(struct net_device *, | |
898 | struct ethtool_dump *, void *); | |
899 | int (*set_dump)(struct net_device *, struct ethtool_dump *); | |
c8f3a8c3 | 900 | int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *); |
41c3cb6d SH |
901 | int (*get_module_info)(struct net_device *, |
902 | struct ethtool_modinfo *); | |
903 | int (*get_module_eeprom)(struct net_device *, | |
904 | struct ethtool_eeprom *, u8 *); | |
d80a5233 HK |
905 | int (*get_eee)(struct net_device *dev, struct ethtool_keee *eee); |
906 | int (*set_eee)(struct net_device *dev, struct ethtool_keee *eee); | |
f0db9b07 GV |
907 | int (*get_tunable)(struct net_device *, |
908 | const struct ethtool_tunable *, void *); | |
909 | int (*set_tunable)(struct net_device *, | |
910 | const struct ethtool_tunable *, const void *); | |
421797b1 KL |
911 | int (*get_per_queue_coalesce)(struct net_device *, u32, |
912 | struct ethtool_coalesce *); | |
f38d138a KL |
913 | int (*set_per_queue_coalesce)(struct net_device *, u32, |
914 | struct ethtool_coalesce *); | |
3f1ac7a7 DD |
915 | int (*get_link_ksettings)(struct net_device *, |
916 | struct ethtool_link_ksettings *); | |
917 | int (*set_link_ksettings)(struct net_device *, | |
918 | const struct ethtool_link_ksettings *); | |
be85dbfe JK |
919 | void (*get_fec_stats)(struct net_device *dev, |
920 | struct ethtool_fec_stats *fec_stats); | |
1a5f3da2 VSR |
921 | int (*get_fecparam)(struct net_device *, |
922 | struct ethtool_fecparam *); | |
923 | int (*set_fecparam)(struct net_device *, | |
924 | struct ethtool_fecparam *); | |
99943382 FF |
925 | void (*get_ethtool_phy_stats)(struct net_device *, |
926 | struct ethtool_stats *, u64 *); | |
c6db31ff IR |
927 | int (*get_phy_tunable)(struct net_device *, |
928 | const struct ethtool_tunable *, void *); | |
929 | int (*set_phy_tunable)(struct net_device *, | |
930 | const struct ethtool_tunable *, const void *); | |
c781ff12 VT |
931 | int (*get_module_eeprom_by_page)(struct net_device *dev, |
932 | const struct ethtool_module_eeprom *page, | |
933 | struct netlink_ext_ack *extack); | |
f09ea6fb JK |
934 | void (*get_eth_phy_stats)(struct net_device *dev, |
935 | struct ethtool_eth_phy_stats *phy_stats); | |
ca224454 JK |
936 | void (*get_eth_mac_stats)(struct net_device *dev, |
937 | struct ethtool_eth_mac_stats *mac_stats); | |
bfad2b97 JK |
938 | void (*get_eth_ctrl_stats)(struct net_device *dev, |
939 | struct ethtool_eth_ctrl_stats *ctrl_stats); | |
a8b06e9d JK |
940 | void (*get_rmon_stats)(struct net_device *dev, |
941 | struct ethtool_rmon_stats *rmon_stats, | |
942 | const struct ethtool_rmon_hist_range **ranges); | |
353407d9 IS |
943 | int (*get_module_power_mode)(struct net_device *dev, |
944 | struct ethtool_module_power_mode_params *params, | |
945 | struct netlink_ext_ack *extack); | |
946 | int (*set_module_power_mode)(struct net_device *dev, | |
947 | const struct ethtool_module_power_mode_params *params, | |
948 | struct netlink_ext_ack *extack); | |
2b30f829 VO |
949 | int (*get_mm)(struct net_device *dev, struct ethtool_mm_state *state); |
950 | int (*set_mm)(struct net_device *dev, struct ethtool_mm_cfg *cfg, | |
951 | struct netlink_ext_ack *extack); | |
952 | void (*get_mm_stats)(struct net_device *dev, struct ethtool_mm_stats *stats); | |
1da177e4 | 953 | }; |
eca4205f | 954 | |
9000edb7 JK |
955 | int ethtool_check_ops(const struct ethtool_ops *ops); |
956 | ||
eca4205f PNA |
957 | struct ethtool_rx_flow_rule { |
958 | struct flow_rule *rule; | |
5299a11a | 959 | unsigned long priv[]; |
eca4205f PNA |
960 | }; |
961 | ||
962 | struct ethtool_rx_flow_spec_input { | |
963 | const struct ethtool_rx_flow_spec *fs; | |
964 | u32 rss_ctx; | |
965 | }; | |
966 | ||
967 | struct ethtool_rx_flow_rule * | |
968 | ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input); | |
969 | void ethtool_rx_flow_rule_destroy(struct ethtool_rx_flow_rule *rule); | |
970 | ||
70ae1e12 CF |
971 | bool ethtool_virtdev_validate_cmd(const struct ethtool_link_ksettings *cmd); |
972 | int ethtool_virtdev_set_link_ksettings(struct net_device *dev, | |
973 | const struct ethtool_link_ksettings *cmd, | |
974 | u32 *dev_speed, u8 *dev_duplex); | |
975 | ||
4895d780 FF |
976 | struct phy_device; |
977 | struct phy_tdr_config; | |
8580e16c PB |
978 | struct phy_plca_cfg; |
979 | struct phy_plca_status; | |
4895d780 FF |
980 | |
981 | /** | |
982 | * struct ethtool_phy_ops - Optional PHY device options | |
bd36ed1c FF |
983 | * @get_sset_count: Get number of strings that @get_strings will write. |
984 | * @get_strings: Return a set of strings that describe the requested objects | |
985 | * @get_stats: Return extended statistics about the PHY device. | |
8580e16c PB |
986 | * @get_plca_cfg: Return PLCA configuration. |
987 | * @set_plca_cfg: Set PLCA configuration. | |
988 | * @get_plca_status: Get PLCA configuration. | |
d9c65de0 JK |
989 | * @start_cable_test: Start a cable test |
990 | * @start_cable_test_tdr: Start a Time Domain Reflectometry cable test | |
4895d780 FF |
991 | * |
992 | * All operations are optional (i.e. the function pointer may be set to %NULL) | |
993 | * and callers must take this into account. Callers must hold the RTNL lock. | |
994 | */ | |
995 | struct ethtool_phy_ops { | |
bd36ed1c FF |
996 | int (*get_sset_count)(struct phy_device *dev); |
997 | int (*get_strings)(struct phy_device *dev, u8 *data); | |
998 | int (*get_stats)(struct phy_device *dev, | |
999 | struct ethtool_stats *stats, u64 *data); | |
8580e16c PB |
1000 | int (*get_plca_cfg)(struct phy_device *dev, |
1001 | struct phy_plca_cfg *plca_cfg); | |
1002 | int (*set_plca_cfg)(struct phy_device *dev, | |
1003 | const struct phy_plca_cfg *plca_cfg, | |
1004 | struct netlink_ext_ack *extack); | |
1005 | int (*get_plca_status)(struct phy_device *dev, | |
1006 | struct phy_plca_status *plca_st); | |
4895d780 FF |
1007 | int (*start_cable_test)(struct phy_device *phydev, |
1008 | struct netlink_ext_ack *extack); | |
1009 | int (*start_cable_test_tdr)(struct phy_device *phydev, | |
1010 | struct netlink_ext_ack *extack, | |
1011 | const struct phy_tdr_config *config); | |
1012 | }; | |
1013 | ||
1014 | /** | |
1015 | * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton | |
1016 | * @ops: Ethtool PHY operations to set | |
1017 | */ | |
1018 | void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops); | |
70ae1e12 | 1019 | |
8859a44e | 1020 | /** |
a975d7d8 DR |
1021 | * ethtool_params_from_link_mode - Derive link parameters from a given link mode |
1022 | * @link_ksettings: Link parameters to be derived from the link mode | |
1023 | * @link_mode: Link mode | |
1024 | */ | |
1025 | void | |
1026 | ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings, | |
1027 | enum ethtool_link_mode_bit_indices link_mode); | |
8859a44e | 1028 | |
c156174a YL |
1029 | /** |
1030 | * ethtool_get_phc_vclocks - Derive phc vclocks information, and caller | |
1031 | * is responsible to free memory of vclock_index | |
1032 | * @dev: pointer to net_device structure | |
1033 | * @vclock_index: pointer to pointer of vclock index | |
1034 | * | |
1035 | * Return number of phc vclocks | |
1036 | */ | |
1037 | int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index); | |
1038 | ||
449c5459 VO |
1039 | /* Some generic methods drivers may use in their ethtool_ops */ |
1040 | u32 ethtool_op_get_link(struct net_device *dev); | |
1041 | int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti); | |
1042 | ||
dd1c4164 VO |
1043 | /** |
1044 | * ethtool_mm_frag_size_add_to_min - Translate (standard) additional fragment | |
1045 | * size expressed as multiplier into (absolute) minimum fragment size | |
1046 | * value expressed in octets | |
1047 | * @val_add: Value of addFragSize multiplier | |
1048 | */ | |
1049 | static inline u32 ethtool_mm_frag_size_add_to_min(u32 val_add) | |
1050 | { | |
1051 | return (ETH_ZLEN + ETH_FCS_LEN) * (1 + val_add) - ETH_FCS_LEN; | |
1052 | } | |
1053 | ||
1054 | /** | |
1055 | * ethtool_mm_frag_size_min_to_add - Translate (absolute) minimum fragment size | |
1056 | * expressed in octets into (standard) additional fragment size expressed | |
1057 | * as multiplier | |
1058 | * @val_min: Value of addFragSize variable in octets | |
1059 | * @val_add: Pointer where the standard addFragSize value is to be returned | |
1060 | * @extack: Netlink extended ack | |
1061 | * | |
1062 | * Translate a value in octets to one of 0, 1, 2, 3 according to the reverse | |
1063 | * application of the 802.3 formula 64 * (1 + addFragSize) - 4. To be called | |
1064 | * by drivers which do not support programming the minimum fragment size to a | |
1065 | * continuous range. Returns error on other fragment length values. | |
1066 | */ | |
1067 | static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add, | |
1068 | struct netlink_ext_ack *extack) | |
1069 | { | |
1070 | u32 add_frag_size; | |
1071 | ||
1072 | for (add_frag_size = 0; add_frag_size < 4; add_frag_size++) { | |
1073 | if (ethtool_mm_frag_size_add_to_min(add_frag_size) == val_min) { | |
1074 | *val_add = add_frag_size; | |
1075 | return 0; | |
1076 | } | |
1077 | } | |
1078 | ||
1079 | NL_SET_ERR_MSG_MOD(extack, | |
1080 | "minFragSize required to be one of 60, 124, 188 or 252"); | |
1081 | return -EINVAL; | |
1082 | } | |
1083 | ||
b8768dc4 RC |
1084 | /** |
1085 | * ethtool_get_ts_info_by_layer - Obtains time stamping capabilities from the MAC or PHY layer. | |
1086 | * @dev: pointer to net_device structure | |
1087 | * @info: buffer to hold the result | |
1088 | * Returns zero on success, non-zero otherwise. | |
1089 | */ | |
1090 | int ethtool_get_ts_info_by_layer(struct net_device *dev, struct ethtool_ts_info *info); | |
1091 | ||
7888fe53 AD |
1092 | /** |
1093 | * ethtool_sprintf - Write formatted string to ethtool string data | |
f55d8e60 | 1094 | * @data: Pointer to a pointer to the start of string to update |
7888fe53 AD |
1095 | * @fmt: Format of string to write |
1096 | * | |
f55d8e60 | 1097 | * Write formatted string to *data. Update *data to point at start of |
7888fe53 AD |
1098 | * next string. |
1099 | */ | |
1100 | extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...); | |
26c5334d | 1101 | |
2a48c635 | 1102 | /** |
1103 | * ethtool_puts - Write string to ethtool string data | |
1104 | * @data: Pointer to a pointer to the start of string to update | |
1105 | * @str: String to write | |
1106 | * | |
1107 | * Write string to *data without a trailing newline. Update *data | |
1108 | * to point at start of next string. | |
1109 | * | |
1110 | * Prefer this function to ethtool_sprintf() when given only | |
1111 | * two arguments or if @fmt is just "%s". | |
1112 | */ | |
1113 | extern void ethtool_puts(u8 **data, const char *str); | |
1114 | ||
26c5334d PG |
1115 | /* Link mode to forced speed capabilities maps */ |
1116 | struct ethtool_forced_speed_map { | |
1117 | u32 speed; | |
1118 | __ETHTOOL_DECLARE_LINK_MODE_MASK(caps); | |
1119 | ||
1120 | const u32 *cap_arr; | |
1121 | u32 arr_size; | |
1122 | }; | |
1123 | ||
1124 | #define ETHTOOL_FORCED_SPEED_MAP(prefix, value) \ | |
1125 | { \ | |
1126 | .speed = SPEED_##value, \ | |
1127 | .cap_arr = prefix##_##value, \ | |
1128 | .arr_size = ARRAY_SIZE(prefix##_##value), \ | |
1129 | } | |
1130 | ||
20c6e05b JK |
1131 | void |
1132 | ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size); | |
1da177e4 | 1133 | #endif /* _LINUX_ETHTOOL_H */ |