1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * ethtool.h: Defines for Linux ethtool.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (C) 1998 David S. Miller (davem@redhat.com)
6*4882a593Smuzhiyun * Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
7*4882a593Smuzhiyun * Portions Copyright 2001 Sun Microsystems (thockin@sun.com)
8*4882a593Smuzhiyun * Portions Copyright 2002 Intel (eli.kupermann@intel.com,
9*4882a593Smuzhiyun * christopher.leech@intel.com,
10*4882a593Smuzhiyun * scott.feldman@intel.com)
11*4882a593Smuzhiyun * Portions Copyright (C) Sun Microsystems 2008
12*4882a593Smuzhiyun */
13*4882a593Smuzhiyun #ifndef _LINUX_ETHTOOL_H
14*4882a593Smuzhiyun #define _LINUX_ETHTOOL_H
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun #include <linux/bitmap.h>
17*4882a593Smuzhiyun #include <linux/compat.h>
18*4882a593Smuzhiyun #include <linux/android_kabi.h>
19*4882a593Smuzhiyun #include <uapi/linux/ethtool.h>
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun struct compat_ethtool_rx_flow_spec {
22*4882a593Smuzhiyun u32 flow_type;
23*4882a593Smuzhiyun union ethtool_flow_union h_u;
24*4882a593Smuzhiyun struct ethtool_flow_ext h_ext;
25*4882a593Smuzhiyun union ethtool_flow_union m_u;
26*4882a593Smuzhiyun struct ethtool_flow_ext m_ext;
27*4882a593Smuzhiyun compat_u64 ring_cookie;
28*4882a593Smuzhiyun u32 location;
29*4882a593Smuzhiyun };
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun struct compat_ethtool_rxnfc {
32*4882a593Smuzhiyun u32 cmd;
33*4882a593Smuzhiyun u32 flow_type;
34*4882a593Smuzhiyun compat_u64 data;
35*4882a593Smuzhiyun struct compat_ethtool_rx_flow_spec fs;
36*4882a593Smuzhiyun u32 rule_cnt;
37*4882a593Smuzhiyun u32 rule_locs[];
38*4882a593Smuzhiyun };
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun #include <linux/rculist.h>
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun /**
43*4882a593Smuzhiyun * enum ethtool_phys_id_state - indicator state for physical identification
44*4882a593Smuzhiyun * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
45*4882a593Smuzhiyun * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
46*4882a593Smuzhiyun * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
47*4882a593Smuzhiyun * is not supported)
48*4882a593Smuzhiyun * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
49*4882a593Smuzhiyun * is not supported)
50*4882a593Smuzhiyun */
51*4882a593Smuzhiyun enum ethtool_phys_id_state {
52*4882a593Smuzhiyun ETHTOOL_ID_INACTIVE,
53*4882a593Smuzhiyun ETHTOOL_ID_ACTIVE,
54*4882a593Smuzhiyun ETHTOOL_ID_ON,
55*4882a593Smuzhiyun ETHTOOL_ID_OFF
56*4882a593Smuzhiyun };
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun enum {
59*4882a593Smuzhiyun ETH_RSS_HASH_TOP_BIT, /* Configurable RSS hash function - Toeplitz */
60*4882a593Smuzhiyun ETH_RSS_HASH_XOR_BIT, /* Configurable RSS hash function - Xor */
61*4882a593Smuzhiyun ETH_RSS_HASH_CRC32_BIT, /* Configurable RSS hash function - Crc32 */
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun /*
64*4882a593Smuzhiyun * Add your fresh new hash function bits above and remember to update
65*4882a593Smuzhiyun * rss_hash_func_strings[] in ethtool.c
66*4882a593Smuzhiyun */
67*4882a593Smuzhiyun ETH_RSS_HASH_FUNCS_COUNT
68*4882a593Smuzhiyun };
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit))
71*4882a593Smuzhiyun #define __ETH_RSS_HASH(name) __ETH_RSS_HASH_BIT(ETH_RSS_HASH_##name##_BIT)
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun #define ETH_RSS_HASH_TOP __ETH_RSS_HASH(TOP)
74*4882a593Smuzhiyun #define ETH_RSS_HASH_XOR __ETH_RSS_HASH(XOR)
75*4882a593Smuzhiyun #define ETH_RSS_HASH_CRC32 __ETH_RSS_HASH(CRC32)
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun #define ETH_RSS_HASH_UNKNOWN 0
78*4882a593Smuzhiyun #define ETH_RSS_HASH_NO_CHANGE 0
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun struct net_device;
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun /* Some generic methods drivers may use in their ethtool_ops */
83*4882a593Smuzhiyun u32 ethtool_op_get_link(struct net_device *dev);
84*4882a593Smuzhiyun int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun /**
88*4882a593Smuzhiyun * struct ethtool_link_ext_state_info - link extended state and substate.
89*4882a593Smuzhiyun */
90*4882a593Smuzhiyun struct ethtool_link_ext_state_info {
91*4882a593Smuzhiyun enum ethtool_link_ext_state link_ext_state;
92*4882a593Smuzhiyun union {
93*4882a593Smuzhiyun enum ethtool_link_ext_substate_autoneg autoneg;
94*4882a593Smuzhiyun enum ethtool_link_ext_substate_link_training link_training;
95*4882a593Smuzhiyun enum ethtool_link_ext_substate_link_logical_mismatch link_logical_mismatch;
96*4882a593Smuzhiyun enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity;
97*4882a593Smuzhiyun enum ethtool_link_ext_substate_cable_issue cable_issue;
98*4882a593Smuzhiyun u8 __link_ext_substate;
99*4882a593Smuzhiyun };
100*4882a593Smuzhiyun };
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun /**
103*4882a593Smuzhiyun * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
104*4882a593Smuzhiyun * @index: Index in RX flow hash indirection table
105*4882a593Smuzhiyun * @n_rx_rings: Number of RX rings to use
106*4882a593Smuzhiyun *
107*4882a593Smuzhiyun * This function provides the default policy for RX flow hash indirection.
108*4882a593Smuzhiyun */
ethtool_rxfh_indir_default(u32 index,u32 n_rx_rings)109*4882a593Smuzhiyun static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
110*4882a593Smuzhiyun {
111*4882a593Smuzhiyun return index % n_rx_rings;
112*4882a593Smuzhiyun }
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun /* declare a link mode bitmap */
115*4882a593Smuzhiyun #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \
116*4882a593Smuzhiyun DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS)
117*4882a593Smuzhiyun
118*4882a593Smuzhiyun /* drivers must ignore base.cmd and base.link_mode_masks_nwords
119*4882a593Smuzhiyun * fields, but they are allowed to overwrite them (will be ignored).
120*4882a593Smuzhiyun */
121*4882a593Smuzhiyun struct ethtool_link_ksettings {
122*4882a593Smuzhiyun struct ethtool_link_settings base;
123*4882a593Smuzhiyun struct {
124*4882a593Smuzhiyun __ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
125*4882a593Smuzhiyun __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
126*4882a593Smuzhiyun __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising);
127*4882a593Smuzhiyun } link_modes;
128*4882a593Smuzhiyun };
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun /**
131*4882a593Smuzhiyun * ethtool_link_ksettings_zero_link_mode - clear link_ksettings link mode mask
132*4882a593Smuzhiyun * @ptr : pointer to struct ethtool_link_ksettings
133*4882a593Smuzhiyun * @name : one of supported/advertising/lp_advertising
134*4882a593Smuzhiyun */
135*4882a593Smuzhiyun #define ethtool_link_ksettings_zero_link_mode(ptr, name) \
136*4882a593Smuzhiyun bitmap_zero((ptr)->link_modes.name, __ETHTOOL_LINK_MODE_MASK_NBITS)
137*4882a593Smuzhiyun
138*4882a593Smuzhiyun /**
139*4882a593Smuzhiyun * ethtool_link_ksettings_add_link_mode - set bit in link_ksettings
140*4882a593Smuzhiyun * link mode mask
141*4882a593Smuzhiyun * @ptr : pointer to struct ethtool_link_ksettings
142*4882a593Smuzhiyun * @name : one of supported/advertising/lp_advertising
143*4882a593Smuzhiyun * @mode : one of the ETHTOOL_LINK_MODE_*_BIT
144*4882a593Smuzhiyun * (not atomic, no bound checking)
145*4882a593Smuzhiyun */
146*4882a593Smuzhiyun #define ethtool_link_ksettings_add_link_mode(ptr, name, mode) \
147*4882a593Smuzhiyun __set_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun /**
150*4882a593Smuzhiyun * ethtool_link_ksettings_del_link_mode - clear bit in link_ksettings
151*4882a593Smuzhiyun * link mode mask
152*4882a593Smuzhiyun * @ptr : pointer to struct ethtool_link_ksettings
153*4882a593Smuzhiyun * @name : one of supported/advertising/lp_advertising
154*4882a593Smuzhiyun * @mode : one of the ETHTOOL_LINK_MODE_*_BIT
155*4882a593Smuzhiyun * (not atomic, no bound checking)
156*4882a593Smuzhiyun */
157*4882a593Smuzhiyun #define ethtool_link_ksettings_del_link_mode(ptr, name, mode) \
158*4882a593Smuzhiyun __clear_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun /**
161*4882a593Smuzhiyun * ethtool_link_ksettings_test_link_mode - test bit in ksettings link mode mask
162*4882a593Smuzhiyun * @ptr : pointer to struct ethtool_link_ksettings
163*4882a593Smuzhiyun * @name : one of supported/advertising/lp_advertising
164*4882a593Smuzhiyun * @mode : one of the ETHTOOL_LINK_MODE_*_BIT
165*4882a593Smuzhiyun * (not atomic, no bound checking)
166*4882a593Smuzhiyun *
167*4882a593Smuzhiyun * Returns true/false.
168*4882a593Smuzhiyun */
169*4882a593Smuzhiyun #define ethtool_link_ksettings_test_link_mode(ptr, name, mode) \
170*4882a593Smuzhiyun test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun extern int
173*4882a593Smuzhiyun __ethtool_get_link_ksettings(struct net_device *dev,
174*4882a593Smuzhiyun struct ethtool_link_ksettings *link_ksettings);
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun /**
177*4882a593Smuzhiyun * ethtool_intersect_link_masks - Given two link masks, AND them together
178*4882a593Smuzhiyun * @dst: first mask and where result is stored
179*4882a593Smuzhiyun * @src: second mask to intersect with
180*4882a593Smuzhiyun *
181*4882a593Smuzhiyun * Given two link mode masks, AND them together and save the result in dst.
182*4882a593Smuzhiyun */
183*4882a593Smuzhiyun void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst,
184*4882a593Smuzhiyun struct ethtool_link_ksettings *src);
185*4882a593Smuzhiyun
186*4882a593Smuzhiyun void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst,
187*4882a593Smuzhiyun u32 legacy_u32);
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun /* return false if src had higher bits set. lower bits always updated. */
190*4882a593Smuzhiyun bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
191*4882a593Smuzhiyun const unsigned long *src);
192*4882a593Smuzhiyun
193*4882a593Smuzhiyun #define ETHTOOL_COALESCE_RX_USECS BIT(0)
194*4882a593Smuzhiyun #define ETHTOOL_COALESCE_RX_MAX_FRAMES BIT(1)
195*4882a593Smuzhiyun #define ETHTOOL_COALESCE_RX_USECS_IRQ BIT(2)
196*4882a593Smuzhiyun #define ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ BIT(3)
197*4882a593Smuzhiyun #define ETHTOOL_COALESCE_TX_USECS BIT(4)
198*4882a593Smuzhiyun #define ETHTOOL_COALESCE_TX_MAX_FRAMES BIT(5)
199*4882a593Smuzhiyun #define ETHTOOL_COALESCE_TX_USECS_IRQ BIT(6)
200*4882a593Smuzhiyun #define ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ BIT(7)
201*4882a593Smuzhiyun #define ETHTOOL_COALESCE_STATS_BLOCK_USECS BIT(8)
202*4882a593Smuzhiyun #define ETHTOOL_COALESCE_USE_ADAPTIVE_RX BIT(9)
203*4882a593Smuzhiyun #define ETHTOOL_COALESCE_USE_ADAPTIVE_TX BIT(10)
204*4882a593Smuzhiyun #define ETHTOOL_COALESCE_PKT_RATE_LOW BIT(11)
205*4882a593Smuzhiyun #define ETHTOOL_COALESCE_RX_USECS_LOW BIT(12)
206*4882a593Smuzhiyun #define ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW BIT(13)
207*4882a593Smuzhiyun #define ETHTOOL_COALESCE_TX_USECS_LOW BIT(14)
208*4882a593Smuzhiyun #define ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW BIT(15)
209*4882a593Smuzhiyun #define ETHTOOL_COALESCE_PKT_RATE_HIGH BIT(16)
210*4882a593Smuzhiyun #define ETHTOOL_COALESCE_RX_USECS_HIGH BIT(17)
211*4882a593Smuzhiyun #define ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH BIT(18)
212*4882a593Smuzhiyun #define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19)
213*4882a593Smuzhiyun #define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH BIT(20)
214*4882a593Smuzhiyun #define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21)
215*4882a593Smuzhiyun
216*4882a593Smuzhiyun #define ETHTOOL_COALESCE_USECS \
217*4882a593Smuzhiyun (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)
218*4882a593Smuzhiyun #define ETHTOOL_COALESCE_MAX_FRAMES \
219*4882a593Smuzhiyun (ETHTOOL_COALESCE_RX_MAX_FRAMES | ETHTOOL_COALESCE_TX_MAX_FRAMES)
220*4882a593Smuzhiyun #define ETHTOOL_COALESCE_USECS_IRQ \
221*4882a593Smuzhiyun (ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ)
222*4882a593Smuzhiyun #define ETHTOOL_COALESCE_MAX_FRAMES_IRQ \
223*4882a593Smuzhiyun (ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | \
224*4882a593Smuzhiyun ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ)
225*4882a593Smuzhiyun #define ETHTOOL_COALESCE_USE_ADAPTIVE \
226*4882a593Smuzhiyun (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_ADAPTIVE_TX)
227*4882a593Smuzhiyun #define ETHTOOL_COALESCE_USECS_LOW_HIGH \
228*4882a593Smuzhiyun (ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_TX_USECS_LOW | \
229*4882a593Smuzhiyun ETHTOOL_COALESCE_RX_USECS_HIGH | ETHTOOL_COALESCE_TX_USECS_HIGH)
230*4882a593Smuzhiyun #define ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH \
231*4882a593Smuzhiyun (ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW | \
232*4882a593Smuzhiyun ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW | \
233*4882a593Smuzhiyun ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH | \
234*4882a593Smuzhiyun ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH)
235*4882a593Smuzhiyun #define ETHTOOL_COALESCE_PKT_RATE_RX_USECS \
236*4882a593Smuzhiyun (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | \
237*4882a593Smuzhiyun ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_RX_USECS_HIGH | \
238*4882a593Smuzhiyun ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \
239*4882a593Smuzhiyun ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL)
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun #define ETHTOOL_STAT_NOT_SET (~0ULL)
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun /**
244*4882a593Smuzhiyun * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames
245*4882a593Smuzhiyun * @tx_pause_frames: transmitted pause frame count. Reported to user space
246*4882a593Smuzhiyun * as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES.
247*4882a593Smuzhiyun *
248*4882a593Smuzhiyun * Equivalent to `30.3.4.2 aPAUSEMACCtrlFramesTransmitted`
249*4882a593Smuzhiyun * from the standard.
250*4882a593Smuzhiyun *
251*4882a593Smuzhiyun * @rx_pause_frames: received pause frame count. Reported to user space
252*4882a593Smuzhiyun * as %ETHTOOL_A_PAUSE_STAT_RX_FRAMES. Equivalent to:
253*4882a593Smuzhiyun *
254*4882a593Smuzhiyun * Equivalent to `30.3.4.3 aPAUSEMACCtrlFramesReceived`
255*4882a593Smuzhiyun * from the standard.
256*4882a593Smuzhiyun */
257*4882a593Smuzhiyun struct ethtool_pause_stats {
258*4882a593Smuzhiyun u64 tx_pause_frames;
259*4882a593Smuzhiyun u64 rx_pause_frames;
260*4882a593Smuzhiyun };
261*4882a593Smuzhiyun
262*4882a593Smuzhiyun /**
263*4882a593Smuzhiyun * struct ethtool_ops - optional netdev operations
264*4882a593Smuzhiyun * @supported_coalesce_params: supported types of interrupt coalescing.
265*4882a593Smuzhiyun * @get_drvinfo: Report driver/device information. Should only set the
266*4882a593Smuzhiyun * @driver, @version, @fw_version and @bus_info fields. If not
267*4882a593Smuzhiyun * implemented, the @driver and @bus_info fields will be filled in
268*4882a593Smuzhiyun * according to the netdev's parent device.
269*4882a593Smuzhiyun * @get_regs_len: Get buffer length required for @get_regs
270*4882a593Smuzhiyun * @get_regs: Get device registers
271*4882a593Smuzhiyun * @get_wol: Report whether Wake-on-Lan is enabled
272*4882a593Smuzhiyun * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code
273*4882a593Smuzhiyun * or zero.
274*4882a593Smuzhiyun * @get_msglevel: Report driver message level. This should be the value
275*4882a593Smuzhiyun * of the @msg_enable field used by netif logging functions.
276*4882a593Smuzhiyun * @set_msglevel: Set driver message level
277*4882a593Smuzhiyun * @nway_reset: Restart autonegotiation. Returns a negative error code
278*4882a593Smuzhiyun * or zero.
279*4882a593Smuzhiyun * @get_link: Report whether physical link is up. Will only be called if
280*4882a593Smuzhiyun * the netdev is up. Should usually be set to ethtool_op_get_link(),
281*4882a593Smuzhiyun * which uses netif_carrier_ok().
282*4882a593Smuzhiyun * @get_link_ext_state: Report link extended state. Should set link_ext_state and
283*4882a593Smuzhiyun * link_ext_substate (link_ext_substate of 0 means link_ext_substate is unknown,
284*4882a593Smuzhiyun * do not attach ext_substate attribute to netlink message). If link_ext_state
285*4882a593Smuzhiyun * and link_ext_substate are unknown, return -ENODATA. If not implemented,
286*4882a593Smuzhiyun * link_ext_state and link_ext_substate will not be sent to userspace.
287*4882a593Smuzhiyun * @get_eeprom: Read data from the device EEPROM.
288*4882a593Smuzhiyun * Should fill in the magic field. Don't need to check len for zero
289*4882a593Smuzhiyun * or wraparound. Fill in the data argument with the eeprom values
290*4882a593Smuzhiyun * from offset to offset + len. Update len to the amount read.
291*4882a593Smuzhiyun * Returns an error or zero.
292*4882a593Smuzhiyun * @set_eeprom: Write data to the device EEPROM.
293*4882a593Smuzhiyun * Should validate the magic field. Don't need to check len for zero
294*4882a593Smuzhiyun * or wraparound. Update len to the amount written. Returns an error
295*4882a593Smuzhiyun * or zero.
296*4882a593Smuzhiyun * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
297*4882a593Smuzhiyun * error code or zero.
298*4882a593Smuzhiyun * @set_coalesce: Set interrupt coalescing parameters. Supported coalescing
299*4882a593Smuzhiyun * types should be set in @supported_coalesce_params.
300*4882a593Smuzhiyun * Returns a negative error code or zero.
301*4882a593Smuzhiyun * @get_ringparam: Report ring sizes
302*4882a593Smuzhiyun * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
303*4882a593Smuzhiyun * @get_pause_stats: Report pause frame statistics. Drivers must not zero
304*4882a593Smuzhiyun * statistics which they don't report. The stats structure is initialized
305*4882a593Smuzhiyun * to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics.
306*4882a593Smuzhiyun * @get_pauseparam: Report pause parameters
307*4882a593Smuzhiyun * @set_pauseparam: Set pause parameters. Returns a negative error code
308*4882a593Smuzhiyun * or zero.
309*4882a593Smuzhiyun * @self_test: Run specified self-tests
310*4882a593Smuzhiyun * @get_strings: Return a set of strings that describe the requested objects
311*4882a593Smuzhiyun * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
312*4882a593Smuzhiyun * attached to it. The implementation may update the indicator
313*4882a593Smuzhiyun * asynchronously or synchronously, but in either case it must return
314*4882a593Smuzhiyun * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE,
315*4882a593Smuzhiyun * and must either activate asynchronous updates and return zero, return
316*4882a593Smuzhiyun * a negative error or return a positive frequency for synchronous
317*4882a593Smuzhiyun * indication (e.g. 1 for one on/off cycle per second). If it returns
318*4882a593Smuzhiyun * a frequency then it will be called again at intervals with the
319*4882a593Smuzhiyun * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
320*4882a593Smuzhiyun * the indicator accordingly. Finally, it is called with the argument
321*4882a593Smuzhiyun * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a
322*4882a593Smuzhiyun * negative error code or zero.
323*4882a593Smuzhiyun * @get_ethtool_stats: Return extended statistics about the device.
324*4882a593Smuzhiyun * This is only useful if the device maintains statistics not
325*4882a593Smuzhiyun * included in &struct rtnl_link_stats64.
326*4882a593Smuzhiyun * @begin: Function to be called before any other operation. Returns a
327*4882a593Smuzhiyun * negative error code or zero.
328*4882a593Smuzhiyun * @complete: Function to be called after any other operation except
329*4882a593Smuzhiyun * @begin. Will be called even if the other operation failed.
330*4882a593Smuzhiyun * @get_priv_flags: Report driver-specific feature flags.
331*4882a593Smuzhiyun * @set_priv_flags: Set driver-specific feature flags. Returns a negative
332*4882a593Smuzhiyun * error code or zero.
333*4882a593Smuzhiyun * @get_sset_count: Get number of strings that @get_strings will write.
334*4882a593Smuzhiyun * @get_rxnfc: Get RX flow classification rules. Returns a negative
335*4882a593Smuzhiyun * error code or zero.
336*4882a593Smuzhiyun * @set_rxnfc: Set RX flow classification rules. Returns a negative
337*4882a593Smuzhiyun * error code or zero.
338*4882a593Smuzhiyun * @flash_device: Write a firmware image to device's flash memory.
339*4882a593Smuzhiyun * Returns a negative error code or zero.
340*4882a593Smuzhiyun * @reset: Reset (part of) the device, as specified by a bitmask of
341*4882a593Smuzhiyun * flags from &enum ethtool_reset_flags. Returns a negative
342*4882a593Smuzhiyun * error code or zero.
343*4882a593Smuzhiyun * @get_rxfh_key_size: Get the size of the RX flow hash key.
344*4882a593Smuzhiyun * Returns zero if not supported for this specific device.
345*4882a593Smuzhiyun * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
346*4882a593Smuzhiyun * Returns zero if not supported for this specific device.
347*4882a593Smuzhiyun * @get_rxfh: Get the contents of the RX flow hash indirection table, hash key
348*4882a593Smuzhiyun * and/or hash function.
349*4882a593Smuzhiyun * Returns a negative error code or zero.
350*4882a593Smuzhiyun * @set_rxfh: Set the contents of the RX flow hash indirection table, hash
351*4882a593Smuzhiyun * key, and/or hash function. Arguments which are set to %NULL or zero
352*4882a593Smuzhiyun * will remain unchanged.
353*4882a593Smuzhiyun * Returns a negative error code or zero. An error code must be returned
354*4882a593Smuzhiyun * if at least one unsupported change was requested.
355*4882a593Smuzhiyun * @get_rxfh_context: Get the contents of the RX flow hash indirection table,
356*4882a593Smuzhiyun * hash key, and/or hash function assiciated to the given rss context.
357*4882a593Smuzhiyun * Returns a negative error code or zero.
358*4882a593Smuzhiyun * @set_rxfh_context: Create, remove and configure RSS contexts. Allows setting
359*4882a593Smuzhiyun * the contents of the RX flow hash indirection table, hash key, and/or
360*4882a593Smuzhiyun * hash function associated to the given context. Arguments which are set
361*4882a593Smuzhiyun * to %NULL or zero will remain unchanged.
362*4882a593Smuzhiyun * Returns a negative error code or zero. An error code must be returned
363*4882a593Smuzhiyun * if at least one unsupported change was requested.
364*4882a593Smuzhiyun * @get_channels: Get number of channels.
365*4882a593Smuzhiyun * @set_channels: Set number of channels. Returns a negative error code or
366*4882a593Smuzhiyun * zero.
367*4882a593Smuzhiyun * @get_dump_flag: Get dump flag indicating current dump length, version,
368*4882a593Smuzhiyun * and flag of the device.
369*4882a593Smuzhiyun * @get_dump_data: Get dump data.
370*4882a593Smuzhiyun * @set_dump: Set dump specific flags to the device.
371*4882a593Smuzhiyun * @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
372*4882a593Smuzhiyun * Drivers supporting transmit time stamps in software should set this to
373*4882a593Smuzhiyun * ethtool_op_get_ts_info().
374*4882a593Smuzhiyun * @get_module_info: Get the size and type of the eeprom contained within
375*4882a593Smuzhiyun * a plug-in module.
376*4882a593Smuzhiyun * @get_module_eeprom: Get the eeprom information from the plug-in module
377*4882a593Smuzhiyun * @get_eee: Get Energy-Efficient (EEE) supported and status.
378*4882a593Smuzhiyun * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
379*4882a593Smuzhiyun * @get_per_queue_coalesce: Get interrupt coalescing parameters per queue.
380*4882a593Smuzhiyun * It must check that the given queue number is valid. If neither a RX nor
381*4882a593Smuzhiyun * a TX queue has this number, return -EINVAL. If only a RX queue or a TX
382*4882a593Smuzhiyun * queue has this number, set the inapplicable fields to ~0 and return 0.
383*4882a593Smuzhiyun * Returns a negative error code or zero.
384*4882a593Smuzhiyun * @set_per_queue_coalesce: Set interrupt coalescing parameters per queue.
385*4882a593Smuzhiyun * It must check that the given queue number is valid. If neither a RX nor
386*4882a593Smuzhiyun * a TX queue has this number, return -EINVAL. If only a RX queue or a TX
387*4882a593Smuzhiyun * queue has this number, ignore the inapplicable fields. Supported
388*4882a593Smuzhiyun * coalescing types should be set in @supported_coalesce_params.
389*4882a593Smuzhiyun * Returns a negative error code or zero.
390*4882a593Smuzhiyun * @get_link_ksettings: Get various device settings including Ethernet link
391*4882a593Smuzhiyun * settings. The %cmd and %link_mode_masks_nwords fields should be
392*4882a593Smuzhiyun * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter),
393*4882a593Smuzhiyun * any change to them will be overwritten by kernel. Returns a negative
394*4882a593Smuzhiyun * error code or zero.
395*4882a593Smuzhiyun * @set_link_ksettings: Set various device settings including Ethernet link
396*4882a593Smuzhiyun * settings. The %cmd and %link_mode_masks_nwords fields should be
397*4882a593Smuzhiyun * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter),
398*4882a593Smuzhiyun * any change to them will be overwritten by kernel. Returns a negative
399*4882a593Smuzhiyun * error code or zero.
400*4882a593Smuzhiyun * @get_fecparam: Get the network device Forward Error Correction parameters.
401*4882a593Smuzhiyun * @set_fecparam: Set the network device Forward Error Correction parameters.
402*4882a593Smuzhiyun * @get_ethtool_phy_stats: Return extended statistics about the PHY device.
403*4882a593Smuzhiyun * This is only useful if the device maintains PHY statistics and
404*4882a593Smuzhiyun * cannot use the standard PHY library helpers.
405*4882a593Smuzhiyun *
406*4882a593Smuzhiyun * All operations are optional (i.e. the function pointer may be set
407*4882a593Smuzhiyun * to %NULL) and callers must take this into account. Callers must
408*4882a593Smuzhiyun * hold the RTNL lock.
409*4882a593Smuzhiyun *
410*4882a593Smuzhiyun * See the structures used by these operations for further documentation.
411*4882a593Smuzhiyun * Note that for all operations using a structure ending with a zero-
412*4882a593Smuzhiyun * length array, the array is allocated separately in the kernel and
413*4882a593Smuzhiyun * is passed to the driver as an additional parameter.
414*4882a593Smuzhiyun *
415*4882a593Smuzhiyun * See &struct net_device and &struct net_device_ops for documentation
416*4882a593Smuzhiyun * of the generic netdev features interface.
417*4882a593Smuzhiyun */
418*4882a593Smuzhiyun struct ethtool_ops {
419*4882a593Smuzhiyun u32 supported_coalesce_params;
420*4882a593Smuzhiyun void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
421*4882a593Smuzhiyun int (*get_regs_len)(struct net_device *);
422*4882a593Smuzhiyun void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
423*4882a593Smuzhiyun void (*get_wol)(struct net_device *, struct ethtool_wolinfo *);
424*4882a593Smuzhiyun int (*set_wol)(struct net_device *, struct ethtool_wolinfo *);
425*4882a593Smuzhiyun u32 (*get_msglevel)(struct net_device *);
426*4882a593Smuzhiyun void (*set_msglevel)(struct net_device *, u32);
427*4882a593Smuzhiyun int (*nway_reset)(struct net_device *);
428*4882a593Smuzhiyun u32 (*get_link)(struct net_device *);
429*4882a593Smuzhiyun int (*get_link_ext_state)(struct net_device *,
430*4882a593Smuzhiyun struct ethtool_link_ext_state_info *);
431*4882a593Smuzhiyun int (*get_eeprom_len)(struct net_device *);
432*4882a593Smuzhiyun int (*get_eeprom)(struct net_device *,
433*4882a593Smuzhiyun struct ethtool_eeprom *, u8 *);
434*4882a593Smuzhiyun int (*set_eeprom)(struct net_device *,
435*4882a593Smuzhiyun struct ethtool_eeprom *, u8 *);
436*4882a593Smuzhiyun int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
437*4882a593Smuzhiyun int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
438*4882a593Smuzhiyun void (*get_ringparam)(struct net_device *,
439*4882a593Smuzhiyun struct ethtool_ringparam *);
440*4882a593Smuzhiyun int (*set_ringparam)(struct net_device *,
441*4882a593Smuzhiyun struct ethtool_ringparam *);
442*4882a593Smuzhiyun void (*get_pause_stats)(struct net_device *dev,
443*4882a593Smuzhiyun struct ethtool_pause_stats *pause_stats);
444*4882a593Smuzhiyun void (*get_pauseparam)(struct net_device *,
445*4882a593Smuzhiyun struct ethtool_pauseparam*);
446*4882a593Smuzhiyun int (*set_pauseparam)(struct net_device *,
447*4882a593Smuzhiyun struct ethtool_pauseparam*);
448*4882a593Smuzhiyun void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
449*4882a593Smuzhiyun void (*get_strings)(struct net_device *, u32 stringset, u8 *);
450*4882a593Smuzhiyun int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
451*4882a593Smuzhiyun void (*get_ethtool_stats)(struct net_device *,
452*4882a593Smuzhiyun struct ethtool_stats *, u64 *);
453*4882a593Smuzhiyun int (*begin)(struct net_device *);
454*4882a593Smuzhiyun void (*complete)(struct net_device *);
455*4882a593Smuzhiyun u32 (*get_priv_flags)(struct net_device *);
456*4882a593Smuzhiyun int (*set_priv_flags)(struct net_device *, u32);
457*4882a593Smuzhiyun int (*get_sset_count)(struct net_device *, int);
458*4882a593Smuzhiyun int (*get_rxnfc)(struct net_device *,
459*4882a593Smuzhiyun struct ethtool_rxnfc *, u32 *rule_locs);
460*4882a593Smuzhiyun int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
461*4882a593Smuzhiyun int (*flash_device)(struct net_device *, struct ethtool_flash *);
462*4882a593Smuzhiyun int (*reset)(struct net_device *, u32 *);
463*4882a593Smuzhiyun u32 (*get_rxfh_key_size)(struct net_device *);
464*4882a593Smuzhiyun u32 (*get_rxfh_indir_size)(struct net_device *);
465*4882a593Smuzhiyun int (*get_rxfh)(struct net_device *, u32 *indir, u8 *key,
466*4882a593Smuzhiyun u8 *hfunc);
467*4882a593Smuzhiyun int (*set_rxfh)(struct net_device *, const u32 *indir,
468*4882a593Smuzhiyun const u8 *key, const u8 hfunc);
469*4882a593Smuzhiyun int (*get_rxfh_context)(struct net_device *, u32 *indir, u8 *key,
470*4882a593Smuzhiyun u8 *hfunc, u32 rss_context);
471*4882a593Smuzhiyun int (*set_rxfh_context)(struct net_device *, const u32 *indir,
472*4882a593Smuzhiyun const u8 *key, const u8 hfunc,
473*4882a593Smuzhiyun u32 *rss_context, bool delete);
474*4882a593Smuzhiyun void (*get_channels)(struct net_device *, struct ethtool_channels *);
475*4882a593Smuzhiyun int (*set_channels)(struct net_device *, struct ethtool_channels *);
476*4882a593Smuzhiyun int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
477*4882a593Smuzhiyun int (*get_dump_data)(struct net_device *,
478*4882a593Smuzhiyun struct ethtool_dump *, void *);
479*4882a593Smuzhiyun int (*set_dump)(struct net_device *, struct ethtool_dump *);
480*4882a593Smuzhiyun int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *);
481*4882a593Smuzhiyun int (*get_module_info)(struct net_device *,
482*4882a593Smuzhiyun struct ethtool_modinfo *);
483*4882a593Smuzhiyun int (*get_module_eeprom)(struct net_device *,
484*4882a593Smuzhiyun struct ethtool_eeprom *, u8 *);
485*4882a593Smuzhiyun int (*get_eee)(struct net_device *, struct ethtool_eee *);
486*4882a593Smuzhiyun int (*set_eee)(struct net_device *, struct ethtool_eee *);
487*4882a593Smuzhiyun int (*get_tunable)(struct net_device *,
488*4882a593Smuzhiyun const struct ethtool_tunable *, void *);
489*4882a593Smuzhiyun int (*set_tunable)(struct net_device *,
490*4882a593Smuzhiyun const struct ethtool_tunable *, const void *);
491*4882a593Smuzhiyun int (*get_per_queue_coalesce)(struct net_device *, u32,
492*4882a593Smuzhiyun struct ethtool_coalesce *);
493*4882a593Smuzhiyun int (*set_per_queue_coalesce)(struct net_device *, u32,
494*4882a593Smuzhiyun struct ethtool_coalesce *);
495*4882a593Smuzhiyun int (*get_link_ksettings)(struct net_device *,
496*4882a593Smuzhiyun struct ethtool_link_ksettings *);
497*4882a593Smuzhiyun int (*set_link_ksettings)(struct net_device *,
498*4882a593Smuzhiyun const struct ethtool_link_ksettings *);
499*4882a593Smuzhiyun int (*get_fecparam)(struct net_device *,
500*4882a593Smuzhiyun struct ethtool_fecparam *);
501*4882a593Smuzhiyun int (*set_fecparam)(struct net_device *,
502*4882a593Smuzhiyun struct ethtool_fecparam *);
503*4882a593Smuzhiyun void (*get_ethtool_phy_stats)(struct net_device *,
504*4882a593Smuzhiyun struct ethtool_stats *, u64 *);
505*4882a593Smuzhiyun int (*get_phy_tunable)(struct net_device *,
506*4882a593Smuzhiyun const struct ethtool_tunable *, void *);
507*4882a593Smuzhiyun int (*set_phy_tunable)(struct net_device *,
508*4882a593Smuzhiyun const struct ethtool_tunable *, const void *);
509*4882a593Smuzhiyun
510*4882a593Smuzhiyun ANDROID_KABI_RESERVE(1);
511*4882a593Smuzhiyun ANDROID_KABI_RESERVE(2);
512*4882a593Smuzhiyun ANDROID_KABI_RESERVE(3);
513*4882a593Smuzhiyun ANDROID_KABI_RESERVE(4);
514*4882a593Smuzhiyun };
515*4882a593Smuzhiyun
516*4882a593Smuzhiyun int ethtool_check_ops(const struct ethtool_ops *ops);
517*4882a593Smuzhiyun
518*4882a593Smuzhiyun struct ethtool_rx_flow_rule {
519*4882a593Smuzhiyun struct flow_rule *rule;
520*4882a593Smuzhiyun unsigned long priv[];
521*4882a593Smuzhiyun };
522*4882a593Smuzhiyun
523*4882a593Smuzhiyun struct ethtool_rx_flow_spec_input {
524*4882a593Smuzhiyun const struct ethtool_rx_flow_spec *fs;
525*4882a593Smuzhiyun u32 rss_ctx;
526*4882a593Smuzhiyun };
527*4882a593Smuzhiyun
528*4882a593Smuzhiyun struct ethtool_rx_flow_rule *
529*4882a593Smuzhiyun ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input);
530*4882a593Smuzhiyun void ethtool_rx_flow_rule_destroy(struct ethtool_rx_flow_rule *rule);
531*4882a593Smuzhiyun
532*4882a593Smuzhiyun bool ethtool_virtdev_validate_cmd(const struct ethtool_link_ksettings *cmd);
533*4882a593Smuzhiyun int ethtool_virtdev_set_link_ksettings(struct net_device *dev,
534*4882a593Smuzhiyun const struct ethtool_link_ksettings *cmd,
535*4882a593Smuzhiyun u32 *dev_speed, u8 *dev_duplex);
536*4882a593Smuzhiyun
537*4882a593Smuzhiyun struct netlink_ext_ack;
538*4882a593Smuzhiyun struct phy_device;
539*4882a593Smuzhiyun struct phy_tdr_config;
540*4882a593Smuzhiyun
541*4882a593Smuzhiyun /**
542*4882a593Smuzhiyun * struct ethtool_phy_ops - Optional PHY device options
543*4882a593Smuzhiyun * @get_sset_count: Get number of strings that @get_strings will write.
544*4882a593Smuzhiyun * @get_strings: Return a set of strings that describe the requested objects
545*4882a593Smuzhiyun * @get_stats: Return extended statistics about the PHY device.
546*4882a593Smuzhiyun * @start_cable_test - Start a cable test
547*4882a593Smuzhiyun * @start_cable_test_tdr - Start a Time Domain Reflectometry cable test
548*4882a593Smuzhiyun *
549*4882a593Smuzhiyun * All operations are optional (i.e. the function pointer may be set to %NULL)
550*4882a593Smuzhiyun * and callers must take this into account. Callers must hold the RTNL lock.
551*4882a593Smuzhiyun */
552*4882a593Smuzhiyun struct ethtool_phy_ops {
553*4882a593Smuzhiyun int (*get_sset_count)(struct phy_device *dev);
554*4882a593Smuzhiyun int (*get_strings)(struct phy_device *dev, u8 *data);
555*4882a593Smuzhiyun int (*get_stats)(struct phy_device *dev,
556*4882a593Smuzhiyun struct ethtool_stats *stats, u64 *data);
557*4882a593Smuzhiyun int (*start_cable_test)(struct phy_device *phydev,
558*4882a593Smuzhiyun struct netlink_ext_ack *extack);
559*4882a593Smuzhiyun int (*start_cable_test_tdr)(struct phy_device *phydev,
560*4882a593Smuzhiyun struct netlink_ext_ack *extack,
561*4882a593Smuzhiyun const struct phy_tdr_config *config);
562*4882a593Smuzhiyun };
563*4882a593Smuzhiyun
564*4882a593Smuzhiyun /**
565*4882a593Smuzhiyun * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton
566*4882a593Smuzhiyun * @ops: Ethtool PHY operations to set
567*4882a593Smuzhiyun */
568*4882a593Smuzhiyun void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops);
569*4882a593Smuzhiyun
570*4882a593Smuzhiyun #endif /* _LINUX_ETHTOOL_H */
571