]> Git Repo - linux.git/blame - include/linux/ethtool.h
net: ethtool: Add new power limit get and set features
[linux.git] / include / linux / ethtool.h
CommitLineData
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 ([email protected])
6 * Copyright 2001 Jeff Garzik <[email protected]>
7 * Portions Copyright 2001 Sun Microsystems ([email protected])
8 * Portions Copyright 2002 Intel ([email protected],
9 * [email protected],
10 * [email protected])
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
22struct 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
32struct 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 */
52enum ethtool_phys_id_state {
53 ETHTOOL_ID_INACTIVE,
54 ETHTOOL_ID_ACTIVE,
55 ETHTOOL_ID_ON,
56 ETHTOOL_ID_OFF
57};
58
892311f6
EP
59enum {
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 */
81struct 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 */
100enum 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 119struct net_device;
c781ff12 120struct netlink_ext_ack;
1da177e4 121
f0ebc2b6 122/* Link extended state and substate. */
ecc31c60
AC
123struct 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
136struct 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 */
157static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
158{
159 return index % n_rx_rings;
160}
161
6ad2962f
EC
162/**
163 * struct ethtool_rxfh_context - a custom RSS context configuration
164 * @indir_size: Number of u32 entries in indirection table
165 * @key_size: Size of hash key, in bytes
166 * @priv_size: Size of driver private data, in bytes
167 * @hfunc: RSS hash function identifier. One of the %ETH_RSS_HASH_*
168 * @input_xfrm: Defines how the input data is transformed. Valid values are one
169 * of %RXH_XFRM_*.
170 * @indir_configured: indir has been specified (at create time or subsequently)
171 * @key_configured: hkey has been specified (at create time or subsequently)
172 */
173struct ethtool_rxfh_context {
174 u32 indir_size;
175 u32 key_size;
176 u16 priv_size;
177 u8 hfunc;
178 u8 input_xfrm;
179 u8 indir_configured:1;
180 u8 key_configured:1;
181 /* private: driver private data, indirection table, and hash key are
182 * stored sequentially in @data area. Use below helpers to access.
183 */
184 u8 data[] __aligned(sizeof(void *));
185};
186
187static inline void *ethtool_rxfh_context_priv(struct ethtool_rxfh_context *ctx)
188{
189 return ctx->data;
190}
191
192static inline u32 *ethtool_rxfh_context_indir(struct ethtool_rxfh_context *ctx)
193{
194 return (u32 *)(ctx->data + ALIGN(ctx->priv_size, sizeof(u32)));
195}
196
197static inline u8 *ethtool_rxfh_context_key(struct ethtool_rxfh_context *ctx)
198{
199 return (u8 *)(ethtool_rxfh_context_indir(ctx) + ctx->indir_size);
200}
201
eac9122f
EC
202static inline size_t ethtool_rxfh_context_size(u32 indir_size, u32 key_size,
203 u16 priv_size)
204{
205 size_t indir_bytes = array_size(indir_size, sizeof(u32));
206 size_t flex_len;
207
208 flex_len = size_add(size_add(indir_bytes, key_size),
209 ALIGN(priv_size, sizeof(u32)));
210 return struct_size_t(struct ethtool_rxfh_context, data, flex_len);
211}
212
3f1ac7a7
DD
213/* declare a link mode bitmap */
214#define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \
215 DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS)
216
217/* drivers must ignore base.cmd and base.link_mode_masks_nwords
218 * fields, but they are allowed to overwrite them (will be ignored).
219 */
220struct ethtool_link_ksettings {
221 struct ethtool_link_settings base;
222 struct {
223 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
224 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
225 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising);
226 } link_modes;
012ce4dd 227 u32 lanes;
3f1ac7a7
DD
228};
229
230/**
231 * ethtool_link_ksettings_zero_link_mode - clear link_ksettings link mode mask
232 * @ptr : pointer to struct ethtool_link_ksettings
233 * @name : one of supported/advertising/lp_advertising
234 */
235#define ethtool_link_ksettings_zero_link_mode(ptr, name) \
236 bitmap_zero((ptr)->link_modes.name, __ETHTOOL_LINK_MODE_MASK_NBITS)
237
238/**
239 * ethtool_link_ksettings_add_link_mode - set bit in link_ksettings
240 * link mode mask
241 * @ptr : pointer to struct ethtool_link_ksettings
242 * @name : one of supported/advertising/lp_advertising
243 * @mode : one of the ETHTOOL_LINK_MODE_*_BIT
244 * (not atomic, no bound checking)
245 */
246#define ethtool_link_ksettings_add_link_mode(ptr, name, mode) \
247 __set_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
248
606c07f3
LT
249/**
250 * ethtool_link_ksettings_del_link_mode - clear bit in link_ksettings
251 * link mode mask
252 * @ptr : pointer to struct ethtool_link_ksettings
253 * @name : one of supported/advertising/lp_advertising
254 * @mode : one of the ETHTOOL_LINK_MODE_*_BIT
255 * (not atomic, no bound checking)
256 */
257#define ethtool_link_ksettings_del_link_mode(ptr, name, mode) \
258 __clear_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
259
3f1ac7a7
DD
260/**
261 * ethtool_link_ksettings_test_link_mode - test bit in ksettings link mode mask
262 * @ptr : pointer to struct ethtool_link_ksettings
263 * @name : one of supported/advertising/lp_advertising
264 * @mode : one of the ETHTOOL_LINK_MODE_*_BIT
265 * (not atomic, no bound checking)
266 *
267 * Returns true/false.
268 */
269#define ethtool_link_ksettings_test_link_mode(ptr, name, mode) \
270 test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
271
272extern int
273__ethtool_get_link_ksettings(struct net_device *dev,
274 struct ethtool_link_ksettings *link_ksettings);
275
d80a5233 276struct ethtool_keee {
1f069de6
HK
277 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
278 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertised);
279 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertised);
d80a5233 280 u32 tx_lpi_timer;
285cc15c
HK
281 bool tx_lpi_enabled;
282 bool eee_active;
283 bool eee_enabled;
d80a5233
HK
284};
285
029ee6b1
YM
286struct kernel_ethtool_coalesce {
287 u8 use_cqe_mode_tx;
288 u8 use_cqe_mode_rx;
31de2842
DP
289 u32 tx_aggr_max_bytes;
290 u32 tx_aggr_max_frames;
291 u32 tx_aggr_time_usecs;
029ee6b1
YM
292};
293
5a6cd6de
AB
294/**
295 * ethtool_intersect_link_masks - Given two link masks, AND them together
296 * @dst: first mask and where result is stored
297 * @src: second mask to intersect with
298 *
299 * Given two link mode masks, AND them together and save the result in dst.
300 */
301void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst,
302 struct ethtool_link_ksettings *src);
303
6d62b4d5
PR
304void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst,
305 u32 legacy_u32);
306
307/* return false if src had higher bits set. lower bits always updated. */
308bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
309 const unsigned long *src);
310
95cddcb5
JK
311#define ETHTOOL_COALESCE_RX_USECS BIT(0)
312#define ETHTOOL_COALESCE_RX_MAX_FRAMES BIT(1)
313#define ETHTOOL_COALESCE_RX_USECS_IRQ BIT(2)
314#define ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ BIT(3)
315#define ETHTOOL_COALESCE_TX_USECS BIT(4)
316#define ETHTOOL_COALESCE_TX_MAX_FRAMES BIT(5)
317#define ETHTOOL_COALESCE_TX_USECS_IRQ BIT(6)
318#define ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ BIT(7)
319#define ETHTOOL_COALESCE_STATS_BLOCK_USECS BIT(8)
320#define ETHTOOL_COALESCE_USE_ADAPTIVE_RX BIT(9)
321#define ETHTOOL_COALESCE_USE_ADAPTIVE_TX BIT(10)
322#define ETHTOOL_COALESCE_PKT_RATE_LOW BIT(11)
323#define ETHTOOL_COALESCE_RX_USECS_LOW BIT(12)
324#define ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW BIT(13)
325#define ETHTOOL_COALESCE_TX_USECS_LOW BIT(14)
326#define ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW BIT(15)
327#define ETHTOOL_COALESCE_PKT_RATE_HIGH BIT(16)
328#define ETHTOOL_COALESCE_RX_USECS_HIGH BIT(17)
329#define ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH BIT(18)
330#define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19)
331#define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH BIT(20)
332#define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21)
029ee6b1
YM
333#define ETHTOOL_COALESCE_USE_CQE_RX BIT(22)
334#define ETHTOOL_COALESCE_USE_CQE_TX BIT(23)
31de2842
DP
335#define ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES BIT(24)
336#define ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES BIT(25)
337#define ETHTOOL_COALESCE_TX_AGGR_TIME_USECS BIT(26)
f750dfe8
HQ
338#define ETHTOOL_COALESCE_RX_PROFILE BIT(27)
339#define ETHTOOL_COALESCE_TX_PROFILE BIT(28)
340#define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(28, 0)
95cddcb5
JK
341
342#define ETHTOOL_COALESCE_USECS \
343 (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)
344#define ETHTOOL_COALESCE_MAX_FRAMES \
345 (ETHTOOL_COALESCE_RX_MAX_FRAMES | ETHTOOL_COALESCE_TX_MAX_FRAMES)
346#define ETHTOOL_COALESCE_USECS_IRQ \
347 (ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ)
348#define ETHTOOL_COALESCE_MAX_FRAMES_IRQ \
349 (ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | \
350 ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ)
351#define ETHTOOL_COALESCE_USE_ADAPTIVE \
352 (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_ADAPTIVE_TX)
8213f6c9
JK
353#define ETHTOOL_COALESCE_USECS_LOW_HIGH \
354 (ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_TX_USECS_LOW | \
355 ETHTOOL_COALESCE_RX_USECS_HIGH | ETHTOOL_COALESCE_TX_USECS_HIGH)
4f9546d2
JK
356#define ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH \
357 (ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW | \
358 ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW | \
359 ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH | \
360 ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH)
812df69b
JK
361#define ETHTOOL_COALESCE_PKT_RATE_RX_USECS \
362 (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | \
363 ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_RX_USECS_HIGH | \
364 ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \
365 ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL)
029ee6b1
YM
366#define ETHTOOL_COALESCE_USE_CQE \
367 (ETHTOOL_COALESCE_USE_CQE_RX | ETHTOOL_COALESCE_USE_CQE_TX)
31de2842
DP
368#define ETHTOOL_COALESCE_TX_AGGR \
369 (ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES | \
370 ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES | \
371 ETHTOOL_COALESCE_TX_AGGR_TIME_USECS)
95cddcb5 372
9a27a330
JK
373#define ETHTOOL_STAT_NOT_SET (~0ULL)
374
c5797f8a
JK
375static inline void ethtool_stats_init(u64 *stats, unsigned int n)
376{
377 while (n--)
378 stats[n] = ETHTOOL_STAT_NOT_SET;
379}
380
ca224454
JK
381/* Basic IEEE 802.3 MAC statistics (30.3.1.1.*), not otherwise exposed
382 * via a more targeted API.
383 */
384struct ethtool_eth_mac_stats {
04692c90 385 enum ethtool_mac_stats_src src;
449c5459
VO
386 struct_group(stats,
387 u64 FramesTransmittedOK;
388 u64 SingleCollisionFrames;
389 u64 MultipleCollisionFrames;
390 u64 FramesReceivedOK;
391 u64 FrameCheckSequenceErrors;
392 u64 AlignmentErrors;
393 u64 OctetsTransmittedOK;
394 u64 FramesWithDeferredXmissions;
395 u64 LateCollisions;
396 u64 FramesAbortedDueToXSColls;
397 u64 FramesLostDueToIntMACXmitError;
398 u64 CarrierSenseErrors;
399 u64 OctetsReceivedOK;
400 u64 FramesLostDueToIntMACRcvError;
401 u64 MulticastFramesXmittedOK;
402 u64 BroadcastFramesXmittedOK;
403 u64 FramesWithExcessiveDeferral;
404 u64 MulticastFramesReceivedOK;
405 u64 BroadcastFramesReceivedOK;
406 u64 InRangeLengthErrors;
407 u64 OutOfRangeLengthField;
408 u64 FrameTooLongErrors;
409 );
ca224454
JK
410};
411
f09ea6fb
JK
412/* Basic IEEE 802.3 PHY statistics (30.3.2.1.*), not otherwise exposed
413 * via a more targeted API.
414 */
415struct ethtool_eth_phy_stats {
04692c90 416 enum ethtool_mac_stats_src src;
449c5459
VO
417 struct_group(stats,
418 u64 SymbolErrorDuringCarrier;
419 );
f09ea6fb
JK
420};
421
bfad2b97
JK
422/* Basic IEEE 802.3 MAC Ctrl statistics (30.3.3.*), not otherwise exposed
423 * via a more targeted API.
424 */
425struct ethtool_eth_ctrl_stats {
04692c90 426 enum ethtool_mac_stats_src src;
449c5459
VO
427 struct_group(stats,
428 u64 MACControlFramesTransmitted;
429 u64 MACControlFramesReceived;
430 u64 UnsupportedOpcodesReceived;
431 );
bfad2b97
JK
432};
433
9a27a330
JK
434/**
435 * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames
04692c90
VO
436 * @src: input field denoting whether stats should be queried from the eMAC or
437 * pMAC (if the MM layer is supported). To be ignored otherwise.
9a27a330
JK
438 * @tx_pause_frames: transmitted pause frame count. Reported to user space
439 * as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES.
440 *
441 * Equivalent to `30.3.4.2 aPAUSEMACCtrlFramesTransmitted`
442 * from the standard.
443 *
444 * @rx_pause_frames: received pause frame count. Reported to user space
445 * as %ETHTOOL_A_PAUSE_STAT_RX_FRAMES. Equivalent to:
446 *
447 * Equivalent to `30.3.4.3 aPAUSEMACCtrlFramesReceived`
448 * from the standard.
449 */
450struct ethtool_pause_stats {
04692c90 451 enum ethtool_mac_stats_src src;
449c5459
VO
452 struct_group(stats,
453 u64 tx_pause_frames;
454 u64 rx_pause_frames;
455 );
9a27a330
JK
456};
457
be85dbfe
JK
458#define ETHTOOL_MAX_LANES 8
459
460/**
461 * struct ethtool_fec_stats - statistics for IEEE 802.3 FEC
462 * @corrected_blocks: number of received blocks corrected by FEC
463 * Reported to user space as %ETHTOOL_A_FEC_STAT_CORRECTED.
464 *
465 * Equivalent to `30.5.1.1.17 aFECCorrectedBlocks` from the standard.
466 *
467 * @uncorrectable_blocks: number of received blocks FEC was not able to correct
468 * Reported to user space as %ETHTOOL_A_FEC_STAT_UNCORR.
469 *
470 * Equivalent to `30.5.1.1.18 aFECUncorrectableBlocks` from the standard.
471 *
472 * @corrected_bits: number of bits corrected by FEC
473 * Similar to @corrected_blocks but counts individual bit changes,
474 * not entire FEC data blocks. This is a non-standard statistic.
475 * Reported to user space as %ETHTOOL_A_FEC_STAT_CORR_BITS.
476 *
1271ca00
JC
477 * For each of the above fields, the two substructure members are:
478 *
479 * - @lanes: per-lane/PCS-instance counts as defined by the standard
480 * - @total: error counts for the entire port, for drivers incapable of reporting
be85dbfe
JK
481 * per-lane stats
482 *
483 * Drivers should fill in either only total or per-lane statistics, core
484 * will take care of adding lane values up to produce the total.
485 */
486struct ethtool_fec_stats {
487 struct ethtool_fec_stat {
488 u64 total;
489 u64 lanes[ETHTOOL_MAX_LANES];
490 } corrected_blocks, uncorrectable_blocks, corrected_bits;
491};
492
a8b06e9d
JK
493/**
494 * struct ethtool_rmon_hist_range - byte range for histogram statistics
495 * @low: low bound of the bucket (inclusive)
496 * @high: high bound of the bucket (inclusive)
497 */
498struct ethtool_rmon_hist_range {
499 u16 low;
500 u16 high;
501};
502
503#define ETHTOOL_RMON_HIST_MAX 10
504
505/**
506 * struct ethtool_rmon_stats - selected RMON (RFC 2819) statistics
04692c90
VO
507 * @src: input field denoting whether stats should be queried from the eMAC or
508 * pMAC (if the MM layer is supported). To be ignored otherwise.
a8b06e9d
JK
509 * @undersize_pkts: Equivalent to `etherStatsUndersizePkts` from the RFC.
510 * @oversize_pkts: Equivalent to `etherStatsOversizePkts` from the RFC.
511 * @fragments: Equivalent to `etherStatsFragments` from the RFC.
512 * @jabbers: Equivalent to `etherStatsJabbers` from the RFC.
513 * @hist: Packet counter for packet length buckets (e.g.
514 * `etherStatsPkts128to255Octets` from the RFC).
515 * @hist_tx: Tx counters in similar form to @hist, not defined in the RFC.
516 *
517 * Selection of RMON (RFC 2819) statistics which are not exposed via different
518 * APIs, primarily the packet-length-based counters.
519 * Unfortunately different designs choose different buckets beyond
520 * the 1024B mark (jumbo frame teritory), so the definition of the bucket
521 * ranges is left to the driver.
522 */
523struct ethtool_rmon_stats {
04692c90 524 enum ethtool_mac_stats_src src;
449c5459
VO
525 struct_group(stats,
526 u64 undersize_pkts;
527 u64 oversize_pkts;
528 u64 fragments;
529 u64 jabbers;
530
531 u64 hist[ETHTOOL_RMON_HIST_MAX];
532 u64 hist_tx[ETHTOOL_RMON_HIST_MAX];
533 );
a8b06e9d
JK
534};
535
0e9c1277
RR
536/**
537 * struct ethtool_ts_stats - HW timestamping statistics
538 * @pkts: Number of packets successfully timestamped by the hardware.
539 * @lost: Number of hardware timestamping requests where the timestamping
540 * information from the hardware never arrived for submission with
541 * the skb.
542 * @err: Number of arbitrary timestamp generation error events that the
543 * hardware encountered, exclusive of @lost statistics. Cases such
544 * as resource exhaustion, unavailability, firmware errors, and
545 * detected illogical timestamp values not submitted with the skb
546 * are inclusive to this counter.
547 */
548struct ethtool_ts_stats {
549 struct_group(tx_stats,
550 u64 pkts;
551 u64 lost;
552 u64 err;
553 );
554};
555
c781ff12
VT
556#define ETH_MODULE_EEPROM_PAGE_LEN 128
557#define ETH_MODULE_MAX_I2C_ADDRESS 0x7f
558
559/**
69540b79
IS
560 * struct ethtool_module_eeprom - plug-in module EEPROM read / write parameters
561 * @offset: When @offset is 0-127, it is used as an address to the Lower Memory
562 * (@page must be 0). Otherwise, it is used as an address to the
563 * Upper Memory.
564 * @length: Number of bytes to read / write.
565 * @page: Page number.
566 * @bank: Bank number, if supported by EEPROM spec.
c781ff12
VT
567 * @i2c_address: I2C address of a page. Value less than 0x7f expected. Most
568 * EEPROMs use 0x50 or 0x51.
569 * @data: Pointer to buffer with EEPROM data of @length size.
c781ff12
VT
570 */
571struct ethtool_module_eeprom {
b8c48be2
IS
572 u32 offset;
573 u32 length;
574 u8 page;
575 u8 bank;
576 u8 i2c_address;
577 u8 *data;
c781ff12
VT
578};
579
353407d9
IS
580/**
581 * struct ethtool_module_power_mode_params - module power mode parameters
582 * @policy: The power mode policy enforced by the host for the plug-in module.
583 * @mode: The operational power mode of the plug-in module. Should be filled by
584 * device drivers on get operations.
585 */
586struct ethtool_module_power_mode_params {
587 enum ethtool_module_power_mode_policy policy;
588 enum ethtool_module_power_mode mode;
589};
590
2b30f829
VO
591/**
592 * struct ethtool_mm_state - 802.3 MAC merge layer state
593 * @verify_time:
594 * wait time between verification attempts in ms (according to clause
595 * 30.14.1.6 aMACMergeVerifyTime)
596 * @max_verify_time:
597 * maximum accepted value for the @verify_time variable in set requests
598 * @verify_status:
599 * state of the verification state machine of the MM layer (according to
600 * clause 30.14.1.2 aMACMergeStatusVerify)
601 * @tx_enabled:
602 * set if the MM layer is administratively enabled in the TX direction
603 * (according to clause 30.14.1.3 aMACMergeEnableTx)
604 * @tx_active:
605 * set if the MM layer is enabled in the TX direction, which makes FP
606 * possible (according to 30.14.1.5 aMACMergeStatusTx). This should be
607 * true if MM is enabled, and the verification status is either verified,
608 * or disabled.
609 * @pmac_enabled:
610 * set if the preemptible MAC is powered on and is able to receive
611 * preemptible packets and respond to verification frames.
612 * @verify_enabled:
613 * set if the Verify function of the MM layer (which sends SMD-V
614 * verification requests) is administratively enabled (regardless of
615 * whether it is currently in the ETHTOOL_MM_VERIFY_STATUS_DISABLED state
616 * or not), according to clause 30.14.1.4 aMACMergeVerifyDisableTx (but
617 * using positive rather than negative logic). The device should always
618 * respond to received SMD-V requests as long as @pmac_enabled is set.
619 * @tx_min_frag_size:
620 * the minimum size of non-final mPacket fragments that the link partner
621 * supports receiving, expressed in octets. Compared to the definition
622 * from clause 30.14.1.7 aMACMergeAddFragSize which is expressed in the
623 * range 0 to 3 (requiring a translation to the size in octets according
624 * to the formula 64 * (1 + addFragSize) - 4), a value in a continuous and
625 * unbounded range can be specified here.
626 * @rx_min_frag_size:
627 * the minimum size of non-final mPacket fragments that this device
628 * supports receiving, expressed in octets.
629 */
630struct ethtool_mm_state {
631 u32 verify_time;
632 u32 max_verify_time;
633 enum ethtool_mm_verify_status verify_status;
634 bool tx_enabled;
635 bool tx_active;
636 bool pmac_enabled;
637 bool verify_enabled;
638 u32 tx_min_frag_size;
639 u32 rx_min_frag_size;
640};
641
642/**
643 * struct ethtool_mm_cfg - 802.3 MAC merge layer configuration
644 * @verify_time: see struct ethtool_mm_state
645 * @verify_enabled: see struct ethtool_mm_state
646 * @tx_enabled: see struct ethtool_mm_state
647 * @pmac_enabled: see struct ethtool_mm_state
648 * @tx_min_frag_size: see struct ethtool_mm_state
649 */
650struct ethtool_mm_cfg {
651 u32 verify_time;
652 bool verify_enabled;
653 bool tx_enabled;
654 bool pmac_enabled;
655 u32 tx_min_frag_size;
656};
657
658/**
659 * struct ethtool_mm_stats - 802.3 MAC merge layer statistics
660 * @MACMergeFrameAssErrorCount:
661 * received MAC frames with reassembly errors
662 * @MACMergeFrameSmdErrorCount:
663 * received MAC frames/fragments rejected due to unknown or incorrect SMD
664 * @MACMergeFrameAssOkCount:
665 * received MAC frames that were successfully reassembled and passed up
666 * @MACMergeFragCountRx:
667 * number of additional correct SMD-C mPackets received due to preemption
668 * @MACMergeFragCountTx:
669 * number of additional mPackets sent due to preemption
670 * @MACMergeHoldCount:
671 * number of times the MM layer entered the HOLD state, which blocks
672 * transmission of preemptible traffic
673 */
674struct ethtool_mm_stats {
675 u64 MACMergeFrameAssErrorCount;
676 u64 MACMergeFrameSmdErrorCount;
677 u64 MACMergeFrameAssOkCount;
678 u64 MACMergeFragCountRx;
679 u64 MACMergeFragCountTx;
680 u64 MACMergeHoldCount;
681};
682
fb6e30a7
AZ
683/**
684 * struct ethtool_rxfh_param - RXFH (RSS) parameters
685 * @hfunc: Defines the current RSS hash function used by HW (or to be set to).
686 * Valid values are one of the %ETH_RSS_HASH_*.
687 * @indir_size: On SET, the array size of the user buffer for the
688 * indirection table, which may be zero, or
689 * %ETH_RXFH_INDIR_NO_CHANGE. On GET (read from the driver),
690 * the array size of the hardware indirection table.
691 * @indir: The indirection table of size @indir_size entries.
692 * @key_size: On SET, the array size of the user buffer for the hash key,
693 * which may be zero. On GET (read from the driver), the size of the
694 * hardware hash key.
695 * @key: The hash key of size @key_size bytes.
dcd8dbf9
AZ
696 * @rss_context: RSS context identifier. Context 0 is the default for normal
697 * traffic; other contexts can be referenced as the destination for RX flow
698 * classification rules. On SET, %ETH_RXFH_CONTEXT_ALLOC is used
699 * to allocate a new RSS context; on return this field will
700 * contain the ID of the newly allocated context.
701 * @rss_delete: Set to non-ZERO to remove the @rss_context context.
13e59344
AZ
702 * @input_xfrm: Defines how the input data is transformed. Valid values are one
703 * of %RXH_XFRM_*.
fb6e30a7
AZ
704 */
705struct ethtool_rxfh_param {
706 u8 hfunc;
707 u32 indir_size;
708 u32 *indir;
709 u32 key_size;
710 u8 *key;
dcd8dbf9
AZ
711 u32 rss_context;
712 u8 rss_delete;
13e59344 713 u8 input_xfrm;
fb6e30a7
AZ
714};
715
1da177e4 716/**
8717d07b 717 * struct ethtool_ops - optional netdev operations
012ce4dd
DR
718 * @cap_link_lanes_supported: indicates if the driver supports lanes
719 * parameter.
dcd8dbf9
AZ
720 * @cap_rss_ctx_supported: indicates if the driver supports RSS
721 * contexts.
13e59344
AZ
722 * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor
723 * RSS.
eac9122f
EC
724 * @rxfh_priv_size: size of the driver private data area the core should
725 * allocate for an RSS context (in &struct ethtool_rxfh_context).
847a8ab1
EC
726 * @rxfh_max_context_id: maximum (exclusive) supported RSS context ID. If this
727 * is zero then the core may choose any (nonzero) ID, otherwise the core
728 * will only use IDs strictly less than this value, as the @rss_context
729 * argument to @create_rxfh_context and friends.
95cddcb5 730 * @supported_coalesce_params: supported types of interrupt coalescing.
0b70c256 731 * @supported_ring_params: supported ring params.
f20a0a05
VM
732 * @get_drvinfo: Report driver/device information. Modern drivers no
733 * longer have to implement this callback. Most fields are
734 * correctly filled in by the core using system information, or
735 * populated using other driver operations.
8717d07b 736 * @get_regs_len: Get buffer length required for @get_regs
e20b5b61
BH
737 * @get_regs: Get device registers
738 * @get_wol: Report whether Wake-on-Lan is enabled
8717d07b
BH
739 * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code
740 * or zero.
741 * @get_msglevel: Report driver message level. This should be the value
742 * of the @msg_enable field used by netif logging functions.
e20b5b61 743 * @set_msglevel: Set driver message level
8717d07b
BH
744 * @nway_reset: Restart autonegotiation. Returns a negative error code
745 * or zero.
746 * @get_link: Report whether physical link is up. Will only be called if
747 * the netdev is up. Should usually be set to ethtool_op_get_link(),
748 * which uses netif_carrier_ok().
ecc31c60
AC
749 * @get_link_ext_state: Report link extended state. Should set link_ext_state and
750 * link_ext_substate (link_ext_substate of 0 means link_ext_substate is unknown,
751 * do not attach ext_substate attribute to netlink message). If link_ext_state
752 * and link_ext_substate are unknown, return -ENODATA. If not implemented,
753 * link_ext_state and link_ext_substate will not be sent to userspace.
9a0f830f 754 * @get_link_ext_stats: Read extra link-related counters.
d9c65de0
JK
755 * @get_eeprom_len: Read range of EEPROM addresses for validation of
756 * @get_eeprom and @set_eeprom requests.
757 * Returns 0 if device does not support EEPROM access.
e20b5b61 758 * @get_eeprom: Read data from the device EEPROM.
1da177e4
LT
759 * Should fill in the magic field. Don't need to check len for zero
760 * or wraparound. Fill in the data argument with the eeprom values
761 * from offset to offset + len. Update len to the amount read.
762 * Returns an error or zero.
e20b5b61 763 * @set_eeprom: Write data to the device EEPROM.
1da177e4
LT
764 * Should validate the magic field. Don't need to check len for zero
765 * or wraparound. Update len to the amount written. Returns an error
766 * or zero.
8717d07b
BH
767 * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
768 * error code or zero.
95cddcb5
JK
769 * @set_coalesce: Set interrupt coalescing parameters. Supported coalescing
770 * types should be set in @supported_coalesce_params.
771 * Returns a negative error code or zero.
e20b5b61 772 * @get_ringparam: Report ring sizes
8717d07b 773 * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
9a27a330
JK
774 * @get_pause_stats: Report pause frame statistics. Drivers must not zero
775 * statistics which they don't report. The stats structure is initialized
776 * to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics.
e20b5b61 777 * @get_pauseparam: Report pause parameters
8717d07b
BH
778 * @set_pauseparam: Set pause parameters. Returns a negative error code
779 * or zero.
e20b5b61
BH
780 * @self_test: Run specified self-tests
781 * @get_strings: Return a set of strings that describe the requested objects
68f512f2
BH
782 * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
783 * attached to it. The implementation may update the indicator
784 * asynchronously or synchronously, but in either case it must return
785 * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE,
fce55922
AB
786 * and must either activate asynchronous updates and return zero, return
787 * a negative error or return a positive frequency for synchronous
788 * indication (e.g. 1 for one on/off cycle per second). If it returns
789 * a frequency then it will be called again at intervals with the
68f512f2
BH
790 * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
791 * the indicator accordingly. Finally, it is called with the argument
792 * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a
793 * negative error code or zero.
8717d07b
BH
794 * @get_ethtool_stats: Return extended statistics about the device.
795 * This is only useful if the device maintains statistics not
796 * included in &struct rtnl_link_stats64.
797 * @begin: Function to be called before any other operation. Returns a
798 * negative error code or zero.
799 * @complete: Function to be called after any other operation except
800 * @begin. Will be called even if the other operation failed.
8717d07b
BH
801 * @get_priv_flags: Report driver-specific feature flags.
802 * @set_priv_flags: Set driver-specific feature flags. Returns a negative
803 * error code or zero.
804 * @get_sset_count: Get number of strings that @get_strings will write.
805 * @get_rxnfc: Get RX flow classification rules. Returns a negative
806 * error code or zero.
807 * @set_rxnfc: Set RX flow classification rules. Returns a negative
808 * error code or zero.
809 * @flash_device: Write a firmware image to device's flash memory.
810 * Returns a negative error code or zero.
811 * @reset: Reset (part of) the device, as specified by a bitmask of
812 * flags from &enum ethtool_reset_flags. Returns a negative
813 * error code or zero.
3de0b592
VD
814 * @get_rxfh_key_size: Get the size of the RX flow hash key.
815 * Returns zero if not supported for this specific device.
7850f63f
BH
816 * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
817 * Returns zero if not supported for this specific device.
892311f6
EP
818 * @get_rxfh: Get the contents of the RX flow hash indirection table, hash key
819 * and/or hash function.
8717d07b 820 * Returns a negative error code or zero.
892311f6
EP
821 * @set_rxfh: Set the contents of the RX flow hash indirection table, hash
822 * key, and/or hash function. Arguments which are set to %NULL or zero
823 * will remain unchanged.
824 * Returns a negative error code or zero. An error code must be returned
825 * if at least one unsupported change was requested.
847a8ab1
EC
826 * @create_rxfh_context: Create a new RSS context with the specified RX flow
827 * hash indirection table, hash key, and hash function.
828 * The &struct ethtool_rxfh_context for this context is passed in @ctx;
829 * note that the indir table, hkey and hfunc are not yet populated as
830 * of this call. The driver does not need to update these; the core
831 * will do so if this op succeeds.
832 * However, if @rxfh.indir is set to %NULL, the driver must update the
833 * indir table in @ctx with the (default or inherited) table actually in
834 * use; similarly, if @rxfh.key is %NULL, @rxfh.hfunc is
835 * %ETH_RSS_HASH_NO_CHANGE, or @rxfh.input_xfrm is %RXH_XFRM_NO_CHANGE,
836 * the driver should update the corresponding information in @ctx.
837 * If the driver provides this method, it must also provide
838 * @modify_rxfh_context and @remove_rxfh_context.
839 * Returns a negative error code or zero.
840 * @modify_rxfh_context: Reconfigure the specified RSS context. Allows setting
841 * the contents of the RX flow hash indirection table, hash key, and/or
842 * hash function associated with the given context.
843 * Parameters which are set to %NULL or zero will remain unchanged.
844 * The &struct ethtool_rxfh_context for this context is passed in @ctx;
845 * note that it will still contain the *old* settings. The driver does
846 * not need to update these; the core will do so if this op succeeds.
847 * Returns a negative error code or zero. An error code must be returned
848 * if at least one unsupported change was requested.
849 * @remove_rxfh_context: Remove the specified RSS context.
850 * The &struct ethtool_rxfh_context for this context is passed in @ctx.
851 * Returns a negative error code or zero.
8b5933c3 852 * @get_channels: Get number of channels.
853 * @set_channels: Set number of channels. Returns a negative error code or
854 * zero.
29dd54b7
AC
855 * @get_dump_flag: Get dump flag indicating current dump length, version,
856 * and flag of the device.
857 * @get_dump_data: Get dump data.
858 * @set_dump: Set dump specific flags to the device.
c8f3a8c3 859 * @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
980f0799 860 * It may be called with RCU, or rtnl or reference on the device.
c8f3a8c3 861 * Drivers supporting transmit time stamps in software should set this to
0e9c1277
RR
862 * ethtool_op_get_ts_info(). Drivers must not zero statistics which they
863 * don't report. The stats structure is initialized to ETHTOOL_STAT_NOT_SET
864 * indicating driver does not report statistics.
865 * @get_ts_stats: Query the device hardware timestamping statistics.
41c3cb6d
SH
866 * @get_module_info: Get the size and type of the eeprom contained within
867 * a plug-in module.
868 * @get_module_eeprom: Get the eeprom information from the plug-in module
80f12ecc
YM
869 * @get_eee: Get Energy-Efficient (EEE) supported and status.
870 * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
d9c65de0
JK
871 * @get_tunable: Read the value of a driver / device tunable.
872 * @set_tunable: Set the value of a driver / device tunable.
421797b1
KL
873 * @get_per_queue_coalesce: Get interrupt coalescing parameters per queue.
874 * It must check that the given queue number is valid. If neither a RX nor
875 * a TX queue has this number, return -EINVAL. If only a RX queue or a TX
876 * queue has this number, set the inapplicable fields to ~0 and return 0.
877 * Returns a negative error code or zero.
f38d138a
KL
878 * @set_per_queue_coalesce: Set interrupt coalescing parameters per queue.
879 * It must check that the given queue number is valid. If neither a RX nor
880 * a TX queue has this number, return -EINVAL. If only a RX queue or a TX
95cddcb5
JK
881 * queue has this number, ignore the inapplicable fields. Supported
882 * coalescing types should be set in @supported_coalesce_params.
f38d138a 883 * Returns a negative error code or zero.
9b300495
MK
884 * @get_link_ksettings: Get various device settings including Ethernet link
885 * settings. The %cmd and %link_mode_masks_nwords fields should be
886 * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter),
887 * any change to them will be overwritten by kernel. Returns a negative
888 * error code or zero.
889 * @set_link_ksettings: Set various device settings including Ethernet link
890 * settings. The %cmd and %link_mode_masks_nwords fields should be
891 * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter),
892 * any change to them will be overwritten by kernel. Returns a negative
893 * error code or zero.
be85dbfe
JK
894 * @get_fec_stats: Report FEC statistics.
895 * Core will sum up per-lane stats to get the total.
896 * Drivers must not zero statistics which they don't report. The stats
897 * structure is initialized to ETHTOOL_STAT_NOT_SET indicating driver does
898 * not report statistics.
d805c520
FF
899 * @get_fecparam: Get the network device Forward Error Correction parameters.
900 * @set_fecparam: Set the network device Forward Error Correction parameters.
99943382
FF
901 * @get_ethtool_phy_stats: Return extended statistics about the PHY device.
902 * This is only useful if the device maintains PHY statistics and
903 * cannot use the standard PHY library helpers.
56f15e2c
JK
904 * @get_phy_tunable: Read the value of a PHY tunable.
905 * @set_phy_tunable: Set the value of a PHY tunable.
c781ff12
VT
906 * @get_module_eeprom_by_page: Get a region of plug-in module EEPROM data from
907 * specified page. Returns a negative error code or the amount of bytes
908 * read.
69540b79
IS
909 * @set_module_eeprom_by_page: Write to a region of plug-in module EEPROM,
910 * from kernel space only. Returns a negative error code or zero.
f09ea6fb 911 * @get_eth_phy_stats: Query some of the IEEE 802.3 PHY statistics.
ca224454 912 * @get_eth_mac_stats: Query some of the IEEE 802.3 MAC statistics.
bfad2b97 913 * @get_eth_ctrl_stats: Query some of the IEEE 802.3 MAC Ctrl statistics.
a8b06e9d
JK
914 * @get_rmon_stats: Query some of the RMON (RFC 2819) statistics.
915 * Set %ranges to a pointer to zero-terminated array of byte ranges.
353407d9
IS
916 * @get_module_power_mode: Get the power mode policy for the plug-in module
917 * used by the network device and its operational power mode, if
918 * plugged-in.
919 * @set_module_power_mode: Set the power mode policy for the plug-in module
920 * used by the network device.
2b30f829
VO
921 * @get_mm: Query the 802.3 MAC Merge layer state.
922 * @set_mm: Set the 802.3 MAC Merge layer parameters.
923 * @get_mm_stats: Query the 802.3 MAC Merge layer statistics.
8717d07b
BH
924 *
925 * All operations are optional (i.e. the function pointer may be set
926 * to %NULL) and callers must take this into account. Callers must
b4f79e5c 927 * hold the RTNL lock.
8717d07b
BH
928 *
929 * See the structures used by these operations for further documentation.
6e201c85
BH
930 * Note that for all operations using a structure ending with a zero-
931 * length array, the array is allocated separately in the kernel and
932 * is passed to the driver as an additional parameter.
8717d07b
BH
933 *
934 * See &struct net_device and &struct net_device_ops for documentation
935 * of the generic netdev features interface.
1da177e4
LT
936 */
937struct ethtool_ops {
012ce4dd 938 u32 cap_link_lanes_supported:1;
dcd8dbf9 939 u32 cap_rss_ctx_supported:1;
13e59344 940 u32 cap_rss_sym_xor_supported:1;
eac9122f 941 u16 rxfh_priv_size;
847a8ab1 942 u32 rxfh_max_context_id;
95cddcb5 943 u32 supported_coalesce_params;
0b70c256 944 u32 supported_ring_params;
1da177e4
LT
945 void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
946 int (*get_regs_len)(struct net_device *);
947 void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
948 void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
949 int (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
950 u32 (*get_msglevel)(struct net_device *);
951 void (*set_msglevel)(struct net_device *, u32);
952 int (*nway_reset)(struct net_device *);
953 u32 (*get_link)(struct net_device *);
ecc31c60
AC
954 int (*get_link_ext_state)(struct net_device *,
955 struct ethtool_link_ext_state_info *);
9a0f830f
JK
956 void (*get_link_ext_stats)(struct net_device *dev,
957 struct ethtool_link_ext_stats *stats);
1da177e4 958 int (*get_eeprom_len)(struct net_device *);
97f8aefb 959 int (*get_eeprom)(struct net_device *,
960 struct ethtool_eeprom *, u8 *);
961 int (*set_eeprom)(struct net_device *,
962 struct ethtool_eeprom *, u8 *);
f3ccfda1
YM
963 int (*get_coalesce)(struct net_device *,
964 struct ethtool_coalesce *,
965 struct kernel_ethtool_coalesce *,
966 struct netlink_ext_ack *);
967 int (*set_coalesce)(struct net_device *,
968 struct ethtool_coalesce *,
969 struct kernel_ethtool_coalesce *,
970 struct netlink_ext_ack *);
97f8aefb 971 void (*get_ringparam)(struct net_device *,
74624944
HC
972 struct ethtool_ringparam *,
973 struct kernel_ethtool_ringparam *,
974 struct netlink_ext_ack *);
97f8aefb 975 int (*set_ringparam)(struct net_device *,
74624944
HC
976 struct ethtool_ringparam *,
977 struct kernel_ethtool_ringparam *,
978 struct netlink_ext_ack *);
9a27a330
JK
979 void (*get_pause_stats)(struct net_device *dev,
980 struct ethtool_pause_stats *pause_stats);
97f8aefb 981 void (*get_pauseparam)(struct net_device *,
982 struct ethtool_pauseparam*);
983 int (*set_pauseparam)(struct net_device *,
984 struct ethtool_pauseparam*);
1da177e4
LT
985 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
986 void (*get_strings)(struct net_device *, u32 stringset, u8 *);
68f512f2 987 int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
97f8aefb 988 void (*get_ethtool_stats)(struct net_device *,
989 struct ethtool_stats *, u64 *);
1da177e4
LT
990 int (*begin)(struct net_device *);
991 void (*complete)(struct net_device *);
97f8aefb 992 u32 (*get_priv_flags)(struct net_device *);
993 int (*set_priv_flags)(struct net_device *, u32);
ff03d49f 994 int (*get_sset_count)(struct net_device *, int);
97f8aefb 995 int (*get_rxnfc)(struct net_device *,
815c7db5 996 struct ethtool_rxnfc *, u32 *rule_locs);
59089d8d 997 int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
97f8aefb 998 int (*flash_device)(struct net_device *, struct ethtool_flash *);
d73d3a8c 999 int (*reset)(struct net_device *, u32 *);
3de0b592 1000 u32 (*get_rxfh_key_size)(struct net_device *);
7850f63f 1001 u32 (*get_rxfh_indir_size)(struct net_device *);
fb6e30a7
AZ
1002 int (*get_rxfh)(struct net_device *, struct ethtool_rxfh_param *);
1003 int (*set_rxfh)(struct net_device *, struct ethtool_rxfh_param *,
1004 struct netlink_ext_ack *extack);
847a8ab1
EC
1005 int (*create_rxfh_context)(struct net_device *,
1006 struct ethtool_rxfh_context *ctx,
30a32cdf
EC
1007 const struct ethtool_rxfh_param *rxfh,
1008 struct netlink_ext_ack *extack);
847a8ab1
EC
1009 int (*modify_rxfh_context)(struct net_device *,
1010 struct ethtool_rxfh_context *ctx,
30a32cdf
EC
1011 const struct ethtool_rxfh_param *rxfh,
1012 struct netlink_ext_ack *extack);
847a8ab1
EC
1013 int (*remove_rxfh_context)(struct net_device *,
1014 struct ethtool_rxfh_context *ctx,
30a32cdf
EC
1015 u32 rss_context,
1016 struct netlink_ext_ack *extack);
8b5933c3 1017 void (*get_channels)(struct net_device *, struct ethtool_channels *);
1018 int (*set_channels)(struct net_device *, struct ethtool_channels *);
29dd54b7
AC
1019 int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
1020 int (*get_dump_data)(struct net_device *,
1021 struct ethtool_dump *, void *);
1022 int (*set_dump)(struct net_device *, struct ethtool_dump *);
c8f3a8c3 1023 int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *);
0e9c1277
RR
1024 void (*get_ts_stats)(struct net_device *dev,
1025 struct ethtool_ts_stats *ts_stats);
41c3cb6d
SH
1026 int (*get_module_info)(struct net_device *,
1027 struct ethtool_modinfo *);
1028 int (*get_module_eeprom)(struct net_device *,
1029 struct ethtool_eeprom *, u8 *);
d80a5233
HK
1030 int (*get_eee)(struct net_device *dev, struct ethtool_keee *eee);
1031 int (*set_eee)(struct net_device *dev, struct ethtool_keee *eee);
f0db9b07
GV
1032 int (*get_tunable)(struct net_device *,
1033 const struct ethtool_tunable *, void *);
1034 int (*set_tunable)(struct net_device *,
1035 const struct ethtool_tunable *, const void *);
421797b1
KL
1036 int (*get_per_queue_coalesce)(struct net_device *, u32,
1037 struct ethtool_coalesce *);
f38d138a
KL
1038 int (*set_per_queue_coalesce)(struct net_device *, u32,
1039 struct ethtool_coalesce *);
3f1ac7a7
DD
1040 int (*get_link_ksettings)(struct net_device *,
1041 struct ethtool_link_ksettings *);
1042 int (*set_link_ksettings)(struct net_device *,
1043 const struct ethtool_link_ksettings *);
be85dbfe
JK
1044 void (*get_fec_stats)(struct net_device *dev,
1045 struct ethtool_fec_stats *fec_stats);
1a5f3da2
VSR
1046 int (*get_fecparam)(struct net_device *,
1047 struct ethtool_fecparam *);
1048 int (*set_fecparam)(struct net_device *,
1049 struct ethtool_fecparam *);
99943382
FF
1050 void (*get_ethtool_phy_stats)(struct net_device *,
1051 struct ethtool_stats *, u64 *);
c6db31ff
IR
1052 int (*get_phy_tunable)(struct net_device *,
1053 const struct ethtool_tunable *, void *);
1054 int (*set_phy_tunable)(struct net_device *,
1055 const struct ethtool_tunable *, const void *);
c781ff12
VT
1056 int (*get_module_eeprom_by_page)(struct net_device *dev,
1057 const struct ethtool_module_eeprom *page,
1058 struct netlink_ext_ack *extack);
69540b79
IS
1059 int (*set_module_eeprom_by_page)(struct net_device *dev,
1060 const struct ethtool_module_eeprom *page,
1061 struct netlink_ext_ack *extack);
f09ea6fb
JK
1062 void (*get_eth_phy_stats)(struct net_device *dev,
1063 struct ethtool_eth_phy_stats *phy_stats);
ca224454
JK
1064 void (*get_eth_mac_stats)(struct net_device *dev,
1065 struct ethtool_eth_mac_stats *mac_stats);
bfad2b97
JK
1066 void (*get_eth_ctrl_stats)(struct net_device *dev,
1067 struct ethtool_eth_ctrl_stats *ctrl_stats);
a8b06e9d
JK
1068 void (*get_rmon_stats)(struct net_device *dev,
1069 struct ethtool_rmon_stats *rmon_stats,
1070 const struct ethtool_rmon_hist_range **ranges);
353407d9
IS
1071 int (*get_module_power_mode)(struct net_device *dev,
1072 struct ethtool_module_power_mode_params *params,
1073 struct netlink_ext_ack *extack);
1074 int (*set_module_power_mode)(struct net_device *dev,
1075 const struct ethtool_module_power_mode_params *params,
1076 struct netlink_ext_ack *extack);
2b30f829
VO
1077 int (*get_mm)(struct net_device *dev, struct ethtool_mm_state *state);
1078 int (*set_mm)(struct net_device *dev, struct ethtool_mm_cfg *cfg,
1079 struct netlink_ext_ack *extack);
1080 void (*get_mm_stats)(struct net_device *dev, struct ethtool_mm_stats *stats);
1da177e4 1081};
eca4205f 1082
9000edb7
JK
1083int ethtool_check_ops(const struct ethtool_ops *ops);
1084
eca4205f
PNA
1085struct ethtool_rx_flow_rule {
1086 struct flow_rule *rule;
5299a11a 1087 unsigned long priv[];
eca4205f
PNA
1088};
1089
1090struct ethtool_rx_flow_spec_input {
1091 const struct ethtool_rx_flow_spec *fs;
1092 u32 rss_ctx;
1093};
1094
1095struct ethtool_rx_flow_rule *
1096ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input);
1097void ethtool_rx_flow_rule_destroy(struct ethtool_rx_flow_rule *rule);
1098
70ae1e12
CF
1099bool ethtool_virtdev_validate_cmd(const struct ethtool_link_ksettings *cmd);
1100int ethtool_virtdev_set_link_ksettings(struct net_device *dev,
1101 const struct ethtool_link_ksettings *cmd,
1102 u32 *dev_speed, u8 *dev_duplex);
1103
3ebbd9f6
EC
1104/**
1105 * struct ethtool_netdev_state - per-netdevice state for ethtool features
6ad2962f 1106 * @rss_ctx: XArray of custom RSS contexts
87925151
EC
1107 * @rss_lock: Protects entries in @rss_ctx. May be taken from
1108 * within RTNL.
3ebbd9f6 1109 * @wol_enabled: Wake-on-LAN is enabled
caa93b7c 1110 * @module_fw_flash_in_progress: Module firmware flashing is in progress.
3ebbd9f6
EC
1111 */
1112struct ethtool_netdev_state {
6ad2962f 1113 struct xarray rss_ctx;
87925151 1114 struct mutex rss_lock;
3ebbd9f6 1115 unsigned wol_enabled:1;
caa93b7c 1116 unsigned module_fw_flash_in_progress:1;
3ebbd9f6
EC
1117};
1118
4895d780
FF
1119struct phy_device;
1120struct phy_tdr_config;
8580e16c
PB
1121struct phy_plca_cfg;
1122struct phy_plca_status;
4895d780
FF
1123
1124/**
1125 * struct ethtool_phy_ops - Optional PHY device options
bd36ed1c
FF
1126 * @get_sset_count: Get number of strings that @get_strings will write.
1127 * @get_strings: Return a set of strings that describe the requested objects
1128 * @get_stats: Return extended statistics about the PHY device.
8580e16c
PB
1129 * @get_plca_cfg: Return PLCA configuration.
1130 * @set_plca_cfg: Set PLCA configuration.
1131 * @get_plca_status: Get PLCA configuration.
d9c65de0
JK
1132 * @start_cable_test: Start a cable test
1133 * @start_cable_test_tdr: Start a Time Domain Reflectometry cable test
4895d780
FF
1134 *
1135 * All operations are optional (i.e. the function pointer may be set to %NULL)
1136 * and callers must take this into account. Callers must hold the RTNL lock.
1137 */
1138struct ethtool_phy_ops {
bd36ed1c
FF
1139 int (*get_sset_count)(struct phy_device *dev);
1140 int (*get_strings)(struct phy_device *dev, u8 *data);
1141 int (*get_stats)(struct phy_device *dev,
1142 struct ethtool_stats *stats, u64 *data);
8580e16c
PB
1143 int (*get_plca_cfg)(struct phy_device *dev,
1144 struct phy_plca_cfg *plca_cfg);
1145 int (*set_plca_cfg)(struct phy_device *dev,
1146 const struct phy_plca_cfg *plca_cfg,
1147 struct netlink_ext_ack *extack);
1148 int (*get_plca_status)(struct phy_device *dev,
1149 struct phy_plca_status *plca_st);
4895d780
FF
1150 int (*start_cable_test)(struct phy_device *phydev,
1151 struct netlink_ext_ack *extack);
1152 int (*start_cable_test_tdr)(struct phy_device *phydev,
1153 struct netlink_ext_ack *extack,
1154 const struct phy_tdr_config *config);
1155};
1156
1157/**
1158 * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton
1159 * @ops: Ethtool PHY operations to set
1160 */
1161void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops);
70ae1e12 1162
8859a44e 1163/**
a975d7d8
DR
1164 * ethtool_params_from_link_mode - Derive link parameters from a given link mode
1165 * @link_ksettings: Link parameters to be derived from the link mode
1166 * @link_mode: Link mode
1167 */
1168void
1169ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings,
1170 enum ethtool_link_mode_bit_indices link_mode);
8859a44e 1171
c156174a
YL
1172/**
1173 * ethtool_get_phc_vclocks - Derive phc vclocks information, and caller
1174 * is responsible to free memory of vclock_index
1175 * @dev: pointer to net_device structure
1176 * @vclock_index: pointer to pointer of vclock index
1177 *
1178 * Return number of phc vclocks
1179 */
1180int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index);
1181
449c5459
VO
1182/* Some generic methods drivers may use in their ethtool_ops */
1183u32 ethtool_op_get_link(struct net_device *dev);
1184int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
1185
dd1c4164
VO
1186/**
1187 * ethtool_mm_frag_size_add_to_min - Translate (standard) additional fragment
1188 * size expressed as multiplier into (absolute) minimum fragment size
1189 * value expressed in octets
1190 * @val_add: Value of addFragSize multiplier
1191 */
1192static inline u32 ethtool_mm_frag_size_add_to_min(u32 val_add)
1193{
1194 return (ETH_ZLEN + ETH_FCS_LEN) * (1 + val_add) - ETH_FCS_LEN;
1195}
1196
1197/**
1198 * ethtool_mm_frag_size_min_to_add - Translate (absolute) minimum fragment size
1199 * expressed in octets into (standard) additional fragment size expressed
1200 * as multiplier
1201 * @val_min: Value of addFragSize variable in octets
1202 * @val_add: Pointer where the standard addFragSize value is to be returned
1203 * @extack: Netlink extended ack
1204 *
1205 * Translate a value in octets to one of 0, 1, 2, 3 according to the reverse
1206 * application of the 802.3 formula 64 * (1 + addFragSize) - 4. To be called
1207 * by drivers which do not support programming the minimum fragment size to a
1208 * continuous range. Returns error on other fragment length values.
1209 */
1210static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add,
1211 struct netlink_ext_ack *extack)
1212{
1213 u32 add_frag_size;
1214
1215 for (add_frag_size = 0; add_frag_size < 4; add_frag_size++) {
1216 if (ethtool_mm_frag_size_add_to_min(add_frag_size) == val_min) {
1217 *val_add = add_frag_size;
1218 return 0;
1219 }
1220 }
1221
1222 NL_SET_ERR_MSG_MOD(extack,
1223 "minFragSize required to be one of 60, 124, 188 or 252");
1224 return -EINVAL;
1225}
1226
b8768dc4
RC
1227/**
1228 * ethtool_get_ts_info_by_layer - Obtains time stamping capabilities from the MAC or PHY layer.
1229 * @dev: pointer to net_device structure
1230 * @info: buffer to hold the result
1231 * Returns zero on success, non-zero otherwise.
1232 */
1233int ethtool_get_ts_info_by_layer(struct net_device *dev, struct ethtool_ts_info *info);
1234
7888fe53
AD
1235/**
1236 * ethtool_sprintf - Write formatted string to ethtool string data
f55d8e60 1237 * @data: Pointer to a pointer to the start of string to update
7888fe53
AD
1238 * @fmt: Format of string to write
1239 *
f55d8e60 1240 * Write formatted string to *data. Update *data to point at start of
7888fe53
AD
1241 * next string.
1242 */
1243extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...);
26c5334d 1244
2a48c635 1245/**
1246 * ethtool_puts - Write string to ethtool string data
1247 * @data: Pointer to a pointer to the start of string to update
1248 * @str: String to write
1249 *
1250 * Write string to *data without a trailing newline. Update *data
1251 * to point at start of next string.
1252 *
1253 * Prefer this function to ethtool_sprintf() when given only
1254 * two arguments or if @fmt is just "%s".
1255 */
1256extern void ethtool_puts(u8 **data, const char *str);
1257
26c5334d
PG
1258/* Link mode to forced speed capabilities maps */
1259struct ethtool_forced_speed_map {
1260 u32 speed;
1261 __ETHTOOL_DECLARE_LINK_MODE_MASK(caps);
1262
1263 const u32 *cap_arr;
1264 u32 arr_size;
1265};
1266
1267#define ETHTOOL_FORCED_SPEED_MAP(prefix, value) \
1268{ \
1269 .speed = SPEED_##value, \
1270 .cap_arr = prefix##_##value, \
1271 .arr_size = ARRAY_SIZE(prefix##_##value), \
1272}
1273
20c6e05b
JK
1274void
1275ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size);
e4629600
KMDP
1276
1277/* C33 PSE extended state and substate. */
1278struct ethtool_c33_pse_ext_state_info {
1279 enum ethtool_c33_pse_ext_state c33_pse_ext_state;
1280 union {
1281 enum ethtool_c33_pse_ext_substate_error_condition error_condition;
1282 enum ethtool_c33_pse_ext_substate_mr_pse_enable mr_pse_enable;
1283 enum ethtool_c33_pse_ext_substate_option_detect_ted option_detect_ted;
1284 enum ethtool_c33_pse_ext_substate_option_vport_lim option_vport_lim;
1285 enum ethtool_c33_pse_ext_substate_ovld_detected ovld_detected;
1286 enum ethtool_c33_pse_ext_substate_power_not_available power_not_available;
1287 enum ethtool_c33_pse_ext_substate_short_detected short_detected;
1288 u32 __c33_pse_ext_substate;
1289 };
1290};
30d7b672
KMDP
1291
1292struct ethtool_c33_pse_pw_limit_range {
1293 u32 min;
1294 u32 max;
1295};
1da177e4 1296#endif /* _LINUX_ETHTOOL_H */
This page took 2.607389 seconds and 4 git commands to generate.