xref: /linux/include/uapi/linux/ethtool.h (revision e1577c1c881b09e9f15a743a4a1907815b74d0f7)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * ethtool.h: Defines for Linux ethtool.
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * Copyright (C) 1998 David S. Miller (davem@redhat.com)
6607ca46eSDavid Howells  * Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
7607ca46eSDavid Howells  * Portions Copyright 2001 Sun Microsystems (thockin@sun.com)
8607ca46eSDavid Howells  * Portions Copyright 2002 Intel (eli.kupermann@intel.com,
9607ca46eSDavid Howells  *                                christopher.leech@intel.com,
10607ca46eSDavid Howells  *                                scott.feldman@intel.com)
11607ca46eSDavid Howells  * Portions Copyright (C) Sun Microsystems 2008
12607ca46eSDavid Howells  */
13607ca46eSDavid Howells 
14607ca46eSDavid Howells #ifndef _UAPI_LINUX_ETHTOOL_H
15607ca46eSDavid Howells #define _UAPI_LINUX_ETHTOOL_H
16607ca46eSDavid Howells 
17b5d3755aSNicolas Dichtel #include <linux/kernel.h>
18607ca46eSDavid Howells #include <linux/types.h>
19607ca46eSDavid Howells #include <linux/if_ether.h>
20607ca46eSDavid Howells 
2114e20379SNicolas Dichtel #ifndef __KERNEL__
2214e20379SNicolas Dichtel #include <limits.h> /* for INT_MAX */
2314e20379SNicolas Dichtel #endif
2414e20379SNicolas Dichtel 
25bf8fc60aSBen Hutchings /* All structures exposed to userland should be defined such that they
26bf8fc60aSBen Hutchings  * have the same layout for 32-bit and 64-bit userland.
27bf8fc60aSBen Hutchings  */
28bf8fc60aSBen Hutchings 
29bf8fc60aSBen Hutchings /**
303f1ac7a7SDavid Decotigny  * struct ethtool_cmd - DEPRECATED, link control and status
313f1ac7a7SDavid Decotigny  * This structure is DEPRECATED, please use struct ethtool_link_settings.
32bf8fc60aSBen Hutchings  * @cmd: Command number = %ETHTOOL_GSET or %ETHTOOL_SSET
33bf8fc60aSBen Hutchings  * @supported: Bitmask of %SUPPORTED_* flags for the link modes,
34bf8fc60aSBen Hutchings  *	physical connectors and other link features for which the
35bf8fc60aSBen Hutchings  *	interface supports autonegotiation or auto-detection.
36bf8fc60aSBen Hutchings  *	Read-only.
37bf8fc60aSBen Hutchings  * @advertising: Bitmask of %ADVERTISED_* flags for the link modes,
38bf8fc60aSBen Hutchings  *	physical connectors and other link features that are
39bf8fc60aSBen Hutchings  *	advertised through autonegotiation or enabled for
40bf8fc60aSBen Hutchings  *	auto-detection.
414456ed04SMichael S. Tsirkin  * @speed: Low bits of the speed, 1Mb units, 0 to INT_MAX or SPEED_UNKNOWN
42bf8fc60aSBen Hutchings  * @duplex: Duplex mode; one of %DUPLEX_*
43bf8fc60aSBen Hutchings  * @port: Physical connector type; one of %PORT_*
44bf8fc60aSBen Hutchings  * @phy_address: MDIO address of PHY (transceiver); 0 or 255 if not
45bf8fc60aSBen Hutchings  *	applicable.  For clause 45 PHYs this is the PRTAD.
46bf8fc60aSBen Hutchings  * @transceiver: Historically used to distinguish different possible
47bf8fc60aSBen Hutchings  *	PHY types, but not in a consistent way.  Deprecated.
48bf8fc60aSBen Hutchings  * @autoneg: Enable/disable autonegotiation and auto-detection;
49bf8fc60aSBen Hutchings  *	either %AUTONEG_DISABLE or %AUTONEG_ENABLE
50bf8fc60aSBen Hutchings  * @mdio_support: Bitmask of %ETH_MDIO_SUPPORTS_* flags for the MDIO
51bf8fc60aSBen Hutchings  *	protocols supported by the interface; 0 if unknown.
52bf8fc60aSBen Hutchings  *	Read-only.
53bf8fc60aSBen Hutchings  * @maxtxpkt: Historically used to report TX IRQ coalescing; now
54bf8fc60aSBen Hutchings  *	obsoleted by &struct ethtool_coalesce.  Read-only; deprecated.
55bf8fc60aSBen Hutchings  * @maxrxpkt: Historically used to report RX IRQ coalescing; now
56bf8fc60aSBen Hutchings  *	obsoleted by &struct ethtool_coalesce.  Read-only; deprecated.
574456ed04SMichael S. Tsirkin  * @speed_hi: High bits of the speed, 1Mb units, 0 to INT_MAX or SPEED_UNKNOWN
58bf8fc60aSBen Hutchings  * @eth_tp_mdix: Ethernet twisted-pair MDI(-X) status; one of
59bf8fc60aSBen Hutchings  *	%ETH_TP_MDI_*.  If the status is unknown or not applicable, the
60bf8fc60aSBen Hutchings  *	value will be %ETH_TP_MDI_INVALID.  Read-only.
61bf8fc60aSBen Hutchings  * @eth_tp_mdix_ctrl: Ethernet twisted pair MDI(-X) control; one of
62bf8fc60aSBen Hutchings  *	%ETH_TP_MDI_*.  If MDI(-X) control is not implemented, reads
63bf8fc60aSBen Hutchings  *	yield %ETH_TP_MDI_INVALID and writes may be ignored or rejected.
64bf8fc60aSBen Hutchings  *	When written successfully, the link should be renegotiated if
65bf8fc60aSBen Hutchings  *	necessary.
66bf8fc60aSBen Hutchings  * @lp_advertising: Bitmask of %ADVERTISED_* flags for the link modes
67bf8fc60aSBen Hutchings  *	and other link features that the link partner advertised
68bf8fc60aSBen Hutchings  *	through autonegotiation; 0 if unknown or not applicable.
69bf8fc60aSBen Hutchings  *	Read-only.
70bf8fc60aSBen Hutchings  *
71bf8fc60aSBen Hutchings  * The link speed in Mbps is split between @speed and @speed_hi.  Use
72bf8fc60aSBen Hutchings  * the ethtool_cmd_speed() and ethtool_cmd_speed_set() functions to
73bf8fc60aSBen Hutchings  * access it.
74bf8fc60aSBen Hutchings  *
75bf8fc60aSBen Hutchings  * If autonegotiation is disabled, the speed and @duplex represent the
76bf8fc60aSBen Hutchings  * fixed link mode and are writable if the driver supports multiple
77bf8fc60aSBen Hutchings  * link modes.  If it is enabled then they are read-only; if the link
78bf8fc60aSBen Hutchings  * is up they represent the negotiated link mode; if the link is down,
79bf8fc60aSBen Hutchings  * the speed is 0, %SPEED_UNKNOWN or the highest enabled speed and
80bf8fc60aSBen Hutchings  * @duplex is %DUPLEX_UNKNOWN or the best enabled duplex mode.
81bf8fc60aSBen Hutchings  *
82bf8fc60aSBen Hutchings  * Some hardware interfaces may have multiple PHYs and/or physical
83bf8fc60aSBen Hutchings  * connectors fitted or do not allow the driver to detect which are
84bf8fc60aSBen Hutchings  * fitted.  For these interfaces @port and/or @phy_address may be
85bf8fc60aSBen Hutchings  * writable, possibly dependent on @autoneg being %AUTONEG_DISABLE.
86bf8fc60aSBen Hutchings  * Otherwise, attempts to write different values may be ignored or
87bf8fc60aSBen Hutchings  * rejected.
88bf8fc60aSBen Hutchings  *
89bf8fc60aSBen Hutchings  * Users should assume that all fields not marked read-only are
90bf8fc60aSBen Hutchings  * writable and subject to validation by the driver.  They should use
91bf8fc60aSBen Hutchings  * %ETHTOOL_GSET to get the current values before making specific
92bf8fc60aSBen Hutchings  * changes and then applying them with %ETHTOOL_SSET.
93bf8fc60aSBen Hutchings  *
94bf8fc60aSBen Hutchings  * Drivers that implement set_settings() should validate all fields
95bf8fc60aSBen Hutchings  * other than @cmd that are not described as read-only or deprecated,
96bf8fc60aSBen Hutchings  * and must ignore all fields described as read-only.
97bf8fc60aSBen Hutchings  *
98bf8fc60aSBen Hutchings  * Deprecated fields should be ignored by both users and drivers.
99bf8fc60aSBen Hutchings  */
100607ca46eSDavid Howells struct ethtool_cmd {
101607ca46eSDavid Howells 	__u32	cmd;
102bf8fc60aSBen Hutchings 	__u32	supported;
103bf8fc60aSBen Hutchings 	__u32	advertising;
104bf8fc60aSBen Hutchings 	__u16	speed;
105bf8fc60aSBen Hutchings 	__u8	duplex;
106bf8fc60aSBen Hutchings 	__u8	port;
107bf8fc60aSBen Hutchings 	__u8	phy_address;
108bf8fc60aSBen Hutchings 	__u8	transceiver;
109bf8fc60aSBen Hutchings 	__u8	autoneg;
110bf8fc60aSBen Hutchings 	__u8	mdio_support;
111bf8fc60aSBen Hutchings 	__u32	maxtxpkt;
112bf8fc60aSBen Hutchings 	__u32	maxrxpkt;
113bf8fc60aSBen Hutchings 	__u16	speed_hi;
114bf8fc60aSBen Hutchings 	__u8	eth_tp_mdix;
115bf8fc60aSBen Hutchings 	__u8	eth_tp_mdix_ctrl;
116bf8fc60aSBen Hutchings 	__u32	lp_advertising;
117607ca46eSDavid Howells 	__u32	reserved[2];
118607ca46eSDavid Howells };
119607ca46eSDavid Howells 
120607ca46eSDavid Howells static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
121607ca46eSDavid Howells 					 __u32 speed)
122607ca46eSDavid Howells {
12385a62440SJesse Brandeburg 	ep->speed = (__u16)(speed & 0xFFFF);
124607ca46eSDavid Howells 	ep->speed_hi = (__u16)(speed >> 16);
125607ca46eSDavid Howells }
126607ca46eSDavid Howells 
127607ca46eSDavid Howells static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
128607ca46eSDavid Howells {
129607ca46eSDavid Howells 	return (ep->speed_hi << 16) | ep->speed;
130607ca46eSDavid Howells }
131607ca46eSDavid Howells 
132607ca46eSDavid Howells /* Device supports clause 22 register access to PHY or peripherals
133607ca46eSDavid Howells  * using the interface defined in <linux/mii.h>.  This should not be
134607ca46eSDavid Howells  * set if there are known to be no such peripherals present or if
135607ca46eSDavid Howells  * the driver only emulates clause 22 registers for compatibility.
136607ca46eSDavid Howells  */
137607ca46eSDavid Howells #define ETH_MDIO_SUPPORTS_C22	1
138607ca46eSDavid Howells 
139607ca46eSDavid Howells /* Device supports clause 45 register access to PHY or peripherals
140607ca46eSDavid Howells  * using the interface defined in <linux/mii.h> and <linux/mdio.h>.
141607ca46eSDavid Howells  * This should not be set if there are known to be no such peripherals
142607ca46eSDavid Howells  * present.
143607ca46eSDavid Howells  */
144607ca46eSDavid Howells #define ETH_MDIO_SUPPORTS_C45	2
145607ca46eSDavid Howells 
146607ca46eSDavid Howells #define ETHTOOL_FWVERS_LEN	32
147607ca46eSDavid Howells #define ETHTOOL_BUSINFO_LEN	32
148a4505152SHariprasad Shenai #define ETHTOOL_EROMVERS_LEN	32
149daba1b6bSBen Hutchings 
150daba1b6bSBen Hutchings /**
151daba1b6bSBen Hutchings  * struct ethtool_drvinfo - general driver and device information
152daba1b6bSBen Hutchings  * @cmd: Command number = %ETHTOOL_GDRVINFO
153daba1b6bSBen Hutchings  * @driver: Driver short name.  This should normally match the name
154daba1b6bSBen Hutchings  *	in its bus driver structure (e.g. pci_driver::name).  Must
155daba1b6bSBen Hutchings  *	not be an empty string.
156daba1b6bSBen Hutchings  * @version: Driver version string; may be an empty string
157daba1b6bSBen Hutchings  * @fw_version: Firmware version string; may be an empty string
158a4505152SHariprasad Shenai  * @erom_version: Expansion ROM version string; may be an empty string
159daba1b6bSBen Hutchings  * @bus_info: Device bus address.  This should match the dev_name()
160daba1b6bSBen Hutchings  *	string for the underlying bus device, if there is one.  May be
161daba1b6bSBen Hutchings  *	an empty string.
162daba1b6bSBen Hutchings  * @n_priv_flags: Number of flags valid for %ETHTOOL_GPFLAGS and
163daba1b6bSBen Hutchings  *	%ETHTOOL_SPFLAGS commands; also the number of strings in the
164daba1b6bSBen Hutchings  *	%ETH_SS_PRIV_FLAGS set
165daba1b6bSBen Hutchings  * @n_stats: Number of u64 statistics returned by the %ETHTOOL_GSTATS
166daba1b6bSBen Hutchings  *	command; also the number of strings in the %ETH_SS_STATS set
167daba1b6bSBen Hutchings  * @testinfo_len: Number of results returned by the %ETHTOOL_TEST
168daba1b6bSBen Hutchings  *	command; also the number of strings in the %ETH_SS_TEST set
169daba1b6bSBen Hutchings  * @eedump_len: Size of EEPROM accessible through the %ETHTOOL_GEEPROM
170daba1b6bSBen Hutchings  *	and %ETHTOOL_SEEPROM commands, in bytes
171daba1b6bSBen Hutchings  * @regdump_len: Size of register dump returned by the %ETHTOOL_GREGS
172daba1b6bSBen Hutchings  *	command, in bytes
173daba1b6bSBen Hutchings  *
174daba1b6bSBen Hutchings  * Users can use the %ETHTOOL_GSSET_INFO command to get the number of
175daba1b6bSBen Hutchings  * strings in any string set (from Linux 2.6.34).
176daba1b6bSBen Hutchings  *
177daba1b6bSBen Hutchings  * Drivers should set at most @driver, @version, @fw_version and
178daba1b6bSBen Hutchings  * @bus_info in their get_drvinfo() implementation.  The ethtool
179daba1b6bSBen Hutchings  * core fills in the other fields using other driver operations.
180daba1b6bSBen Hutchings  */
181607ca46eSDavid Howells struct ethtool_drvinfo {
182607ca46eSDavid Howells 	__u32	cmd;
183daba1b6bSBen Hutchings 	char	driver[32];
184daba1b6bSBen Hutchings 	char	version[32];
185daba1b6bSBen Hutchings 	char	fw_version[ETHTOOL_FWVERS_LEN];
186daba1b6bSBen Hutchings 	char	bus_info[ETHTOOL_BUSINFO_LEN];
187a4505152SHariprasad Shenai 	char	erom_version[ETHTOOL_EROMVERS_LEN];
188607ca46eSDavid Howells 	char	reserved2[12];
189daba1b6bSBen Hutchings 	__u32	n_priv_flags;
190daba1b6bSBen Hutchings 	__u32	n_stats;
191607ca46eSDavid Howells 	__u32	testinfo_len;
192daba1b6bSBen Hutchings 	__u32	eedump_len;
193daba1b6bSBen Hutchings 	__u32	regdump_len;
194607ca46eSDavid Howells };
195607ca46eSDavid Howells 
196607ca46eSDavid Howells #define SOPASS_MAX	6
19702d59f3fSBen Hutchings 
19802d59f3fSBen Hutchings /**
19902d59f3fSBen Hutchings  * struct ethtool_wolinfo - Wake-On-Lan configuration
20002d59f3fSBen Hutchings  * @cmd: Command number = %ETHTOOL_GWOL or %ETHTOOL_SWOL
20102d59f3fSBen Hutchings  * @supported: Bitmask of %WAKE_* flags for supported Wake-On-Lan modes.
20202d59f3fSBen Hutchings  *	Read-only.
20302d59f3fSBen Hutchings  * @wolopts: Bitmask of %WAKE_* flags for enabled Wake-On-Lan modes.
20402d59f3fSBen Hutchings  * @sopass: SecureOn(tm) password; meaningful only if %WAKE_MAGICSECURE
20502d59f3fSBen Hutchings  *	is set in @wolopts.
20602d59f3fSBen Hutchings  */
207607ca46eSDavid Howells struct ethtool_wolinfo {
208607ca46eSDavid Howells 	__u32	cmd;
209607ca46eSDavid Howells 	__u32	supported;
210607ca46eSDavid Howells 	__u32	wolopts;
21102d59f3fSBen Hutchings 	__u8	sopass[SOPASS_MAX];
212607ca46eSDavid Howells };
213607ca46eSDavid Howells 
214607ca46eSDavid Howells /* for passing single values */
215607ca46eSDavid Howells struct ethtool_value {
216607ca46eSDavid Howells 	__u32	cmd;
217607ca46eSDavid Howells 	__u32	data;
218607ca46eSDavid Howells };
219607ca46eSDavid Howells 
220*e1577c1cSInbar Karmy #define PFC_STORM_PREVENTION_AUTO	0xffff
221*e1577c1cSInbar Karmy #define PFC_STORM_PREVENTION_DISABLE	0
222*e1577c1cSInbar Karmy 
223f0db9b07SGovindarajulu Varadarajan enum tunable_id {
224f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_ID_UNSPEC,
225f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_RX_COPYBREAK,
2261255a505SEric Dumazet 	ETHTOOL_TX_COPYBREAK,
227*e1577c1cSInbar Karmy 	ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */
228a4244b0cSHadar Hen Zion 	/*
229a4244b0cSHadar Hen Zion 	 * Add your fresh new tubale attribute above and remember to update
230a4244b0cSHadar Hen Zion 	 * tunable_strings[] in net/core/ethtool.c
231a4244b0cSHadar Hen Zion 	 */
232a4244b0cSHadar Hen Zion 	__ETHTOOL_TUNABLE_COUNT,
233f0db9b07SGovindarajulu Varadarajan };
234f0db9b07SGovindarajulu Varadarajan 
235f0db9b07SGovindarajulu Varadarajan enum tunable_type_id {
236f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_UNSPEC,
237f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_U8,
238f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_U16,
239f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_U32,
240f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_U64,
241f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_STRING,
242f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_S8,
243f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_S16,
244f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_S32,
245f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_S64,
246f0db9b07SGovindarajulu Varadarajan };
247f0db9b07SGovindarajulu Varadarajan 
248f0db9b07SGovindarajulu Varadarajan struct ethtool_tunable {
249f0db9b07SGovindarajulu Varadarajan 	__u32	cmd;
250f0db9b07SGovindarajulu Varadarajan 	__u32	id;
251f0db9b07SGovindarajulu Varadarajan 	__u32	type_id;
252f0db9b07SGovindarajulu Varadarajan 	__u32	len;
253f0db9b07SGovindarajulu Varadarajan 	void	*data[0];
254f0db9b07SGovindarajulu Varadarajan };
255f0db9b07SGovindarajulu Varadarajan 
256607c7029SRaju Lakkaraju #define DOWNSHIFT_DEV_DEFAULT_COUNT	0xff
257607c7029SRaju Lakkaraju #define DOWNSHIFT_DEV_DISABLE		0
258607c7029SRaju Lakkaraju 
2590d27f4e4SRaju Lakkaraju enum phy_tunable_id {
2600d27f4e4SRaju Lakkaraju 	ETHTOOL_PHY_ID_UNSPEC,
261607c7029SRaju Lakkaraju 	ETHTOOL_PHY_DOWNSHIFT,
2620d27f4e4SRaju Lakkaraju 	/*
2630d27f4e4SRaju Lakkaraju 	 * Add your fresh new phy tunable attribute above and remember to update
2640d27f4e4SRaju Lakkaraju 	 * phy_tunable_strings[] in net/core/ethtool.c
2650d27f4e4SRaju Lakkaraju 	 */
2660d27f4e4SRaju Lakkaraju 	__ETHTOOL_PHY_TUNABLE_COUNT,
2670d27f4e4SRaju Lakkaraju };
2680d27f4e4SRaju Lakkaraju 
26909fb8bb0SBen Hutchings /**
27009fb8bb0SBen Hutchings  * struct ethtool_regs - hardware register dump
27109fb8bb0SBen Hutchings  * @cmd: Command number = %ETHTOOL_GREGS
27209fb8bb0SBen Hutchings  * @version: Dump format version.  This is driver-specific and may
27309fb8bb0SBen Hutchings  *	distinguish different chips/revisions.  Drivers must use new
27409fb8bb0SBen Hutchings  *	version numbers whenever the dump format changes in an
27509fb8bb0SBen Hutchings  *	incompatible way.
27609fb8bb0SBen Hutchings  * @len: On entry, the real length of @data.  On return, the number of
27709fb8bb0SBen Hutchings  *	bytes used.
27809fb8bb0SBen Hutchings  * @data: Buffer for the register dump
27909fb8bb0SBen Hutchings  *
28009fb8bb0SBen Hutchings  * Users should use %ETHTOOL_GDRVINFO to find the maximum length of
28109fb8bb0SBen Hutchings  * a register dump for the interface.  They must allocate the buffer
28209fb8bb0SBen Hutchings  * immediately following this structure.
28309fb8bb0SBen Hutchings  */
284607ca46eSDavid Howells struct ethtool_regs {
285607ca46eSDavid Howells 	__u32	cmd;
28609fb8bb0SBen Hutchings 	__u32	version;
28709fb8bb0SBen Hutchings 	__u32	len;
288607ca46eSDavid Howells 	__u8	data[0];
289607ca46eSDavid Howells };
290607ca46eSDavid Howells 
291c8364a63SBen Hutchings /**
292c8364a63SBen Hutchings  * struct ethtool_eeprom - EEPROM dump
293c8364a63SBen Hutchings  * @cmd: Command number = %ETHTOOL_GEEPROM, %ETHTOOL_GMODULEEEPROM or
294c8364a63SBen Hutchings  *	%ETHTOOL_SEEPROM
295c8364a63SBen Hutchings  * @magic: A 'magic cookie' value to guard against accidental changes.
296c8364a63SBen Hutchings  *	The value passed in to %ETHTOOL_SEEPROM must match the value
297c8364a63SBen Hutchings  *	returned by %ETHTOOL_GEEPROM for the same device.  This is
298c8364a63SBen Hutchings  *	unused when @cmd is %ETHTOOL_GMODULEEEPROM.
299c8364a63SBen Hutchings  * @offset: Offset within the EEPROM to begin reading/writing, in bytes
300c8364a63SBen Hutchings  * @len: On entry, number of bytes to read/write.  On successful
301c8364a63SBen Hutchings  *	return, number of bytes actually read/written.  In case of
302c8364a63SBen Hutchings  *	error, this may indicate at what point the error occurred.
303c8364a63SBen Hutchings  * @data: Buffer to read/write from
304c8364a63SBen Hutchings  *
305c8364a63SBen Hutchings  * Users may use %ETHTOOL_GDRVINFO or %ETHTOOL_GMODULEINFO to find
306c8364a63SBen Hutchings  * the length of an on-board or module EEPROM, respectively.  They
307c8364a63SBen Hutchings  * must allocate the buffer immediately following this structure.
308c8364a63SBen Hutchings  */
309607ca46eSDavid Howells struct ethtool_eeprom {
310607ca46eSDavid Howells 	__u32	cmd;
311607ca46eSDavid Howells 	__u32	magic;
312c8364a63SBen Hutchings 	__u32	offset;
313c8364a63SBen Hutchings 	__u32	len;
314607ca46eSDavid Howells 	__u8	data[0];
315607ca46eSDavid Howells };
316607ca46eSDavid Howells 
317607ca46eSDavid Howells /**
318607ca46eSDavid Howells  * struct ethtool_eee - Energy Efficient Ethernet information
319607ca46eSDavid Howells  * @cmd: ETHTOOL_{G,S}EEE
320607ca46eSDavid Howells  * @supported: Mask of %SUPPORTED_* flags for the speed/duplex combinations
321607ca46eSDavid Howells  *	for which there is EEE support.
322607ca46eSDavid Howells  * @advertised: Mask of %ADVERTISED_* flags for the speed/duplex combinations
323607ca46eSDavid Howells  *	advertised as eee capable.
324607ca46eSDavid Howells  * @lp_advertised: Mask of %ADVERTISED_* flags for the speed/duplex
325607ca46eSDavid Howells  *	combinations advertised by the link partner as eee capable.
326607ca46eSDavid Howells  * @eee_active: Result of the eee auto negotiation.
327607ca46eSDavid Howells  * @eee_enabled: EEE configured mode (enabled/disabled).
328607ca46eSDavid Howells  * @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
329607ca46eSDavid Howells  *	that eee was negotiated.
330607ca46eSDavid Howells  * @tx_lpi_timer: Time in microseconds the interface delays prior to asserting
331607ca46eSDavid Howells  *	its tx lpi (after reaching 'idle' state). Effective only when eee
332607ca46eSDavid Howells  *	was negotiated and tx_lpi_enabled was set.
333607ca46eSDavid Howells  */
334607ca46eSDavid Howells struct ethtool_eee {
335607ca46eSDavid Howells 	__u32	cmd;
336607ca46eSDavid Howells 	__u32	supported;
337607ca46eSDavid Howells 	__u32	advertised;
338607ca46eSDavid Howells 	__u32	lp_advertised;
339607ca46eSDavid Howells 	__u32	eee_active;
340607ca46eSDavid Howells 	__u32	eee_enabled;
341607ca46eSDavid Howells 	__u32	tx_lpi_enabled;
342607ca46eSDavid Howells 	__u32	tx_lpi_timer;
343607ca46eSDavid Howells 	__u32	reserved[2];
344607ca46eSDavid Howells };
345607ca46eSDavid Howells 
346607ca46eSDavid Howells /**
347607ca46eSDavid Howells  * struct ethtool_modinfo - plugin module eeprom information
348607ca46eSDavid Howells  * @cmd: %ETHTOOL_GMODULEINFO
349607ca46eSDavid Howells  * @type: Standard the module information conforms to %ETH_MODULE_SFF_xxxx
350607ca46eSDavid Howells  * @eeprom_len: Length of the eeprom
351607ca46eSDavid Howells  *
352607ca46eSDavid Howells  * This structure is used to return the information to
353607ca46eSDavid Howells  * properly size memory for a subsequent call to %ETHTOOL_GMODULEEEPROM.
354607ca46eSDavid Howells  * The type code indicates the eeprom data format
355607ca46eSDavid Howells  */
356607ca46eSDavid Howells struct ethtool_modinfo {
357607ca46eSDavid Howells 	__u32   cmd;
358607ca46eSDavid Howells 	__u32   type;
359607ca46eSDavid Howells 	__u32   eeprom_len;
360607ca46eSDavid Howells 	__u32   reserved[8];
361607ca46eSDavid Howells };
362607ca46eSDavid Howells 
363607ca46eSDavid Howells /**
364607ca46eSDavid Howells  * struct ethtool_coalesce - coalescing parameters for IRQs and stats updates
365607ca46eSDavid Howells  * @cmd: ETHTOOL_{G,S}COALESCE
366607ca46eSDavid Howells  * @rx_coalesce_usecs: How many usecs to delay an RX interrupt after
367607ca46eSDavid Howells  *	a packet arrives.
368607ca46eSDavid Howells  * @rx_max_coalesced_frames: Maximum number of packets to receive
369607ca46eSDavid Howells  *	before an RX interrupt.
370607ca46eSDavid Howells  * @rx_coalesce_usecs_irq: Same as @rx_coalesce_usecs, except that
371607ca46eSDavid Howells  *	this value applies while an IRQ is being serviced by the host.
372607ca46eSDavid Howells  * @rx_max_coalesced_frames_irq: Same as @rx_max_coalesced_frames,
373607ca46eSDavid Howells  *	except that this value applies while an IRQ is being serviced
374607ca46eSDavid Howells  *	by the host.
375607ca46eSDavid Howells  * @tx_coalesce_usecs: How many usecs to delay a TX interrupt after
376607ca46eSDavid Howells  *	a packet is sent.
377607ca46eSDavid Howells  * @tx_max_coalesced_frames: Maximum number of packets to be sent
378607ca46eSDavid Howells  *	before a TX interrupt.
379607ca46eSDavid Howells  * @tx_coalesce_usecs_irq: Same as @tx_coalesce_usecs, except that
380607ca46eSDavid Howells  *	this value applies while an IRQ is being serviced by the host.
381607ca46eSDavid Howells  * @tx_max_coalesced_frames_irq: Same as @tx_max_coalesced_frames,
382607ca46eSDavid Howells  *	except that this value applies while an IRQ is being serviced
383607ca46eSDavid Howells  *	by the host.
384607ca46eSDavid Howells  * @stats_block_coalesce_usecs: How many usecs to delay in-memory
385607ca46eSDavid Howells  *	statistics block updates.  Some drivers do not have an
386607ca46eSDavid Howells  *	in-memory statistic block, and in such cases this value is
387607ca46eSDavid Howells  *	ignored.  This value must not be zero.
388607ca46eSDavid Howells  * @use_adaptive_rx_coalesce: Enable adaptive RX coalescing.
389607ca46eSDavid Howells  * @use_adaptive_tx_coalesce: Enable adaptive TX coalescing.
390607ca46eSDavid Howells  * @pkt_rate_low: Threshold for low packet rate (packets per second).
391607ca46eSDavid Howells  * @rx_coalesce_usecs_low: How many usecs to delay an RX interrupt after
392607ca46eSDavid Howells  *	a packet arrives, when the packet rate is below @pkt_rate_low.
393607ca46eSDavid Howells  * @rx_max_coalesced_frames_low: Maximum number of packets to be received
394607ca46eSDavid Howells  *	before an RX interrupt, when the packet rate is below @pkt_rate_low.
395607ca46eSDavid Howells  * @tx_coalesce_usecs_low: How many usecs to delay a TX interrupt after
396607ca46eSDavid Howells  *	a packet is sent, when the packet rate is below @pkt_rate_low.
397607ca46eSDavid Howells  * @tx_max_coalesced_frames_low: Maximum nuumber of packets to be sent before
398607ca46eSDavid Howells  *	a TX interrupt, when the packet rate is below @pkt_rate_low.
399607ca46eSDavid Howells  * @pkt_rate_high: Threshold for high packet rate (packets per second).
400607ca46eSDavid Howells  * @rx_coalesce_usecs_high: How many usecs to delay an RX interrupt after
401607ca46eSDavid Howells  *	a packet arrives, when the packet rate is above @pkt_rate_high.
402607ca46eSDavid Howells  * @rx_max_coalesced_frames_high: Maximum number of packets to be received
403607ca46eSDavid Howells  *	before an RX interrupt, when the packet rate is above @pkt_rate_high.
404607ca46eSDavid Howells  * @tx_coalesce_usecs_high: How many usecs to delay a TX interrupt after
405607ca46eSDavid Howells  *	a packet is sent, when the packet rate is above @pkt_rate_high.
406607ca46eSDavid Howells  * @tx_max_coalesced_frames_high: Maximum number of packets to be sent before
407607ca46eSDavid Howells  *	a TX interrupt, when the packet rate is above @pkt_rate_high.
408607ca46eSDavid Howells  * @rate_sample_interval: How often to do adaptive coalescing packet rate
409607ca46eSDavid Howells  *	sampling, measured in seconds.  Must not be zero.
410607ca46eSDavid Howells  *
411073e3cf2SBen Hutchings  * Each pair of (usecs, max_frames) fields specifies that interrupts
412073e3cf2SBen Hutchings  * should be coalesced until
413607ca46eSDavid Howells  *	(usecs > 0 && time_since_first_completion >= usecs) ||
414607ca46eSDavid Howells  *	(max_frames > 0 && completed_frames >= max_frames)
415073e3cf2SBen Hutchings  *
416607ca46eSDavid Howells  * It is illegal to set both usecs and max_frames to zero as this
417607ca46eSDavid Howells  * would cause interrupts to never be generated.  To disable
418607ca46eSDavid Howells  * coalescing, set usecs = 0 and max_frames = 1.
419607ca46eSDavid Howells  *
420607ca46eSDavid Howells  * Some implementations ignore the value of max_frames and use the
421073e3cf2SBen Hutchings  * condition time_since_first_completion >= usecs
422073e3cf2SBen Hutchings  *
423607ca46eSDavid Howells  * This is deprecated.  Drivers for hardware that does not support
424607ca46eSDavid Howells  * counting completions should validate that max_frames == !rx_usecs.
425607ca46eSDavid Howells  *
426607ca46eSDavid Howells  * Adaptive RX/TX coalescing is an algorithm implemented by some
427607ca46eSDavid Howells  * drivers to improve latency under low packet rates and improve
428607ca46eSDavid Howells  * throughput under high packet rates.  Some drivers only implement
429607ca46eSDavid Howells  * one of RX or TX adaptive coalescing.  Anything not implemented by
430607ca46eSDavid Howells  * the driver causes these values to be silently ignored.
431607ca46eSDavid Howells  *
432607ca46eSDavid Howells  * When the packet rate is below @pkt_rate_high but above
433607ca46eSDavid Howells  * @pkt_rate_low (both measured in packets per second) the
434607ca46eSDavid Howells  * normal {rx,tx}_* coalescing parameters are used.
435607ca46eSDavid Howells  */
436607ca46eSDavid Howells struct ethtool_coalesce {
437607ca46eSDavid Howells 	__u32	cmd;
438607ca46eSDavid Howells 	__u32	rx_coalesce_usecs;
439607ca46eSDavid Howells 	__u32	rx_max_coalesced_frames;
440607ca46eSDavid Howells 	__u32	rx_coalesce_usecs_irq;
441607ca46eSDavid Howells 	__u32	rx_max_coalesced_frames_irq;
442607ca46eSDavid Howells 	__u32	tx_coalesce_usecs;
443607ca46eSDavid Howells 	__u32	tx_max_coalesced_frames;
444607ca46eSDavid Howells 	__u32	tx_coalesce_usecs_irq;
445607ca46eSDavid Howells 	__u32	tx_max_coalesced_frames_irq;
446607ca46eSDavid Howells 	__u32	stats_block_coalesce_usecs;
447607ca46eSDavid Howells 	__u32	use_adaptive_rx_coalesce;
448607ca46eSDavid Howells 	__u32	use_adaptive_tx_coalesce;
449607ca46eSDavid Howells 	__u32	pkt_rate_low;
450607ca46eSDavid Howells 	__u32	rx_coalesce_usecs_low;
451607ca46eSDavid Howells 	__u32	rx_max_coalesced_frames_low;
452607ca46eSDavid Howells 	__u32	tx_coalesce_usecs_low;
453607ca46eSDavid Howells 	__u32	tx_max_coalesced_frames_low;
454607ca46eSDavid Howells 	__u32	pkt_rate_high;
455607ca46eSDavid Howells 	__u32	rx_coalesce_usecs_high;
456607ca46eSDavid Howells 	__u32	rx_max_coalesced_frames_high;
457607ca46eSDavid Howells 	__u32	tx_coalesce_usecs_high;
458607ca46eSDavid Howells 	__u32	tx_max_coalesced_frames_high;
459607ca46eSDavid Howells 	__u32	rate_sample_interval;
460607ca46eSDavid Howells };
461607ca46eSDavid Howells 
462af440a8aSBen Hutchings /**
463af440a8aSBen Hutchings  * struct ethtool_ringparam - RX/TX ring parameters
464af440a8aSBen Hutchings  * @cmd: Command number = %ETHTOOL_GRINGPARAM or %ETHTOOL_SRINGPARAM
465af440a8aSBen Hutchings  * @rx_max_pending: Maximum supported number of pending entries per
466af440a8aSBen Hutchings  *	RX ring.  Read-only.
467af440a8aSBen Hutchings  * @rx_mini_max_pending: Maximum supported number of pending entries
468af440a8aSBen Hutchings  *	per RX mini ring.  Read-only.
469af440a8aSBen Hutchings  * @rx_jumbo_max_pending: Maximum supported number of pending entries
470af440a8aSBen Hutchings  *	per RX jumbo ring.  Read-only.
471af440a8aSBen Hutchings  * @tx_max_pending: Maximum supported number of pending entries per
472af440a8aSBen Hutchings  *	TX ring.  Read-only.
473af440a8aSBen Hutchings  * @rx_pending: Current maximum number of pending entries per RX ring
474af440a8aSBen Hutchings  * @rx_mini_pending: Current maximum number of pending entries per RX
475af440a8aSBen Hutchings  *	mini ring
476af440a8aSBen Hutchings  * @rx_jumbo_pending: Current maximum number of pending entries per RX
477af440a8aSBen Hutchings  *	jumbo ring
478af440a8aSBen Hutchings  * @tx_pending: Current maximum supported number of pending entries
479af440a8aSBen Hutchings  *	per TX ring
480af440a8aSBen Hutchings  *
481af440a8aSBen Hutchings  * If the interface does not have separate RX mini and/or jumbo rings,
482af440a8aSBen Hutchings  * @rx_mini_max_pending and/or @rx_jumbo_max_pending will be 0.
483af440a8aSBen Hutchings  *
484af440a8aSBen Hutchings  * There may also be driver-dependent minimum values for the number
485af440a8aSBen Hutchings  * of entries per ring.
486607ca46eSDavid Howells  */
487af440a8aSBen Hutchings struct ethtool_ringparam {
488af440a8aSBen Hutchings 	__u32	cmd;
489607ca46eSDavid Howells 	__u32	rx_max_pending;
490607ca46eSDavid Howells 	__u32	rx_mini_max_pending;
491607ca46eSDavid Howells 	__u32	rx_jumbo_max_pending;
492607ca46eSDavid Howells 	__u32	tx_max_pending;
493607ca46eSDavid Howells 	__u32	rx_pending;
494607ca46eSDavid Howells 	__u32	rx_mini_pending;
495607ca46eSDavid Howells 	__u32	rx_jumbo_pending;
496607ca46eSDavid Howells 	__u32	tx_pending;
497607ca46eSDavid Howells };
498607ca46eSDavid Howells 
499607ca46eSDavid Howells /**
500607ca46eSDavid Howells  * struct ethtool_channels - configuring number of network channel
501607ca46eSDavid Howells  * @cmd: ETHTOOL_{G,S}CHANNELS
502607ca46eSDavid Howells  * @max_rx: Read only. Maximum number of receive channel the driver support.
503607ca46eSDavid Howells  * @max_tx: Read only. Maximum number of transmit channel the driver support.
504607ca46eSDavid Howells  * @max_other: Read only. Maximum number of other channel the driver support.
505607ca46eSDavid Howells  * @max_combined: Read only. Maximum number of combined channel the driver
506607ca46eSDavid Howells  *	support. Set of queues RX, TX or other.
507607ca46eSDavid Howells  * @rx_count: Valid values are in the range 1 to the max_rx.
508607ca46eSDavid Howells  * @tx_count: Valid values are in the range 1 to the max_tx.
509607ca46eSDavid Howells  * @other_count: Valid values are in the range 1 to the max_other.
510607ca46eSDavid Howells  * @combined_count: Valid values are in the range 1 to the max_combined.
511607ca46eSDavid Howells  *
512607ca46eSDavid Howells  * This can be used to configure RX, TX and other channels.
513607ca46eSDavid Howells  */
514607ca46eSDavid Howells 
515607ca46eSDavid Howells struct ethtool_channels {
516607ca46eSDavid Howells 	__u32	cmd;
517607ca46eSDavid Howells 	__u32	max_rx;
518607ca46eSDavid Howells 	__u32	max_tx;
519607ca46eSDavid Howells 	__u32	max_other;
520607ca46eSDavid Howells 	__u32	max_combined;
521607ca46eSDavid Howells 	__u32	rx_count;
522607ca46eSDavid Howells 	__u32	tx_count;
523607ca46eSDavid Howells 	__u32	other_count;
524607ca46eSDavid Howells 	__u32	combined_count;
525607ca46eSDavid Howells };
526607ca46eSDavid Howells 
5276a7a1081SBen Hutchings /**
5286a7a1081SBen Hutchings  * struct ethtool_pauseparam - Ethernet pause (flow control) parameters
5296a7a1081SBen Hutchings  * @cmd: Command number = %ETHTOOL_GPAUSEPARAM or %ETHTOOL_SPAUSEPARAM
5306a7a1081SBen Hutchings  * @autoneg: Flag to enable autonegotiation of pause frame use
5316a7a1081SBen Hutchings  * @rx_pause: Flag to enable reception of pause frames
5326a7a1081SBen Hutchings  * @tx_pause: Flag to enable transmission of pause frames
533607ca46eSDavid Howells  *
5346a7a1081SBen Hutchings  * Drivers should reject a non-zero setting of @autoneg when
5356a7a1081SBen Hutchings  * autoneogotiation is disabled (or not supported) for the link.
5366a7a1081SBen Hutchings  *
5376a7a1081SBen Hutchings  * If the link is autonegotiated, drivers should use
5386a7a1081SBen Hutchings  * mii_advertise_flowctrl() or similar code to set the advertised
5396a7a1081SBen Hutchings  * pause frame capabilities based on the @rx_pause and @tx_pause flags,
5406a7a1081SBen Hutchings  * even if @autoneg is zero.  They should also allow the advertised
5416a7a1081SBen Hutchings  * pause frame capabilities to be controlled directly through the
5426a7a1081SBen Hutchings  * advertising field of &struct ethtool_cmd.
5436a7a1081SBen Hutchings  *
5446a7a1081SBen Hutchings  * If @autoneg is non-zero, the MAC is configured to send and/or
5456a7a1081SBen Hutchings  * receive pause frames according to the result of autonegotiation.
5466a7a1081SBen Hutchings  * Otherwise, it is configured directly based on the @rx_pause and
5476a7a1081SBen Hutchings  * @tx_pause flags.
548607ca46eSDavid Howells  */
5496a7a1081SBen Hutchings struct ethtool_pauseparam {
5506a7a1081SBen Hutchings 	__u32	cmd;
551607ca46eSDavid Howells 	__u32	autoneg;
552607ca46eSDavid Howells 	__u32	rx_pause;
553607ca46eSDavid Howells 	__u32	tx_pause;
554607ca46eSDavid Howells };
555607ca46eSDavid Howells 
556607ca46eSDavid Howells #define ETH_GSTRING_LEN		32
557fe5df1b9SBen Hutchings 
558fe5df1b9SBen Hutchings /**
559fe5df1b9SBen Hutchings  * enum ethtool_stringset - string set ID
560fe5df1b9SBen Hutchings  * @ETH_SS_TEST: Self-test result names, for use with %ETHTOOL_TEST
561fe5df1b9SBen Hutchings  * @ETH_SS_STATS: Statistic names, for use with %ETHTOOL_GSTATS
562fe5df1b9SBen Hutchings  * @ETH_SS_PRIV_FLAGS: Driver private flag names, for use with
563fe5df1b9SBen Hutchings  *	%ETHTOOL_GPFLAGS and %ETHTOOL_SPFLAGS
564fe5df1b9SBen Hutchings  * @ETH_SS_NTUPLE_FILTERS: Previously used with %ETHTOOL_GRXNTUPLE;
565fe5df1b9SBen Hutchings  *	now deprecated
566fe5df1b9SBen Hutchings  * @ETH_SS_FEATURES: Device feature names
567892311f6SEyal Perry  * @ETH_SS_RSS_HASH_FUNCS: RSS hush function names
568f3a40945SAndrew Lunn  * @ETH_SS_PHY_STATS: Statistic names, for use with %ETHTOOL_GPHYSTATS
5690d27f4e4SRaju Lakkaraju  * @ETH_SS_PHY_TUNABLES: PHY tunable names
570fe5df1b9SBen Hutchings  */
571607ca46eSDavid Howells enum ethtool_stringset {
572607ca46eSDavid Howells 	ETH_SS_TEST		= 0,
573607ca46eSDavid Howells 	ETH_SS_STATS,
574607ca46eSDavid Howells 	ETH_SS_PRIV_FLAGS,
575fe5df1b9SBen Hutchings 	ETH_SS_NTUPLE_FILTERS,
576607ca46eSDavid Howells 	ETH_SS_FEATURES,
577892311f6SEyal Perry 	ETH_SS_RSS_HASH_FUNCS,
578a4244b0cSHadar Hen Zion 	ETH_SS_TUNABLES,
579f3a40945SAndrew Lunn 	ETH_SS_PHY_STATS,
5800d27f4e4SRaju Lakkaraju 	ETH_SS_PHY_TUNABLES,
581607ca46eSDavid Howells };
582607ca46eSDavid Howells 
583fe5df1b9SBen Hutchings /**
584fe5df1b9SBen Hutchings  * struct ethtool_gstrings - string set for data tagging
585fe5df1b9SBen Hutchings  * @cmd: Command number = %ETHTOOL_GSTRINGS
586fe5df1b9SBen Hutchings  * @string_set: String set ID; one of &enum ethtool_stringset
587fe5df1b9SBen Hutchings  * @len: On return, the number of strings in the string set
588fe5df1b9SBen Hutchings  * @data: Buffer for strings.  Each string is null-padded to a size of
589fe5df1b9SBen Hutchings  *	%ETH_GSTRING_LEN.
590fe5df1b9SBen Hutchings  *
591fe5df1b9SBen Hutchings  * Users must use %ETHTOOL_GSSET_INFO to find the number of strings in
592fe5df1b9SBen Hutchings  * the string set.  They must allocate a buffer of the appropriate
593fe5df1b9SBen Hutchings  * size immediately following this structure.
594fe5df1b9SBen Hutchings  */
595607ca46eSDavid Howells struct ethtool_gstrings {
596fe5df1b9SBen Hutchings 	__u32	cmd;
597fe5df1b9SBen Hutchings 	__u32	string_set;
598fe5df1b9SBen Hutchings 	__u32	len;
599607ca46eSDavid Howells 	__u8	data[0];
600607ca46eSDavid Howells };
601607ca46eSDavid Howells 
602fe5df1b9SBen Hutchings /**
603fe5df1b9SBen Hutchings  * struct ethtool_sset_info - string set information
604fe5df1b9SBen Hutchings  * @cmd: Command number = %ETHTOOL_GSSET_INFO
605fe5df1b9SBen Hutchings  * @sset_mask: On entry, a bitmask of string sets to query, with bits
606fe5df1b9SBen Hutchings  *	numbered according to &enum ethtool_stringset.  On return, a
607fe5df1b9SBen Hutchings  *	bitmask of those string sets queried that are supported.
608fe5df1b9SBen Hutchings  * @data: Buffer for string set sizes.  On return, this contains the
609fe5df1b9SBen Hutchings  *	size of each string set that was queried and supported, in
610fe5df1b9SBen Hutchings  *	order of ID.
611fe5df1b9SBen Hutchings  *
612fe5df1b9SBen Hutchings  * Example: The user passes in @sset_mask = 0x7 (sets 0, 1, 2) and on
613fe5df1b9SBen Hutchings  * return @sset_mask == 0x6 (sets 1, 2).  Then @data[0] contains the
614fe5df1b9SBen Hutchings  * size of set 1 and @data[1] contains the size of set 2.
615fe5df1b9SBen Hutchings  *
616fe5df1b9SBen Hutchings  * Users must allocate a buffer of the appropriate size (4 * number of
617fe5df1b9SBen Hutchings  * sets queried) immediately following this structure.
618fe5df1b9SBen Hutchings  */
619607ca46eSDavid Howells struct ethtool_sset_info {
620fe5df1b9SBen Hutchings 	__u32	cmd;
621607ca46eSDavid Howells 	__u32	reserved;
622fe5df1b9SBen Hutchings 	__u64	sset_mask;
623fe5df1b9SBen Hutchings 	__u32	data[0];
624607ca46eSDavid Howells };
625607ca46eSDavid Howells 
626607ca46eSDavid Howells /**
627607ca46eSDavid Howells  * enum ethtool_test_flags - flags definition of ethtool_test
628607ca46eSDavid Howells  * @ETH_TEST_FL_OFFLINE: if set perform online and offline tests, otherwise
629607ca46eSDavid Howells  *	only online tests.
630607ca46eSDavid Howells  * @ETH_TEST_FL_FAILED: Driver set this flag if test fails.
631607ca46eSDavid Howells  * @ETH_TEST_FL_EXTERNAL_LB: Application request to perform external loopback
632607ca46eSDavid Howells  *	test.
633607ca46eSDavid Howells  * @ETH_TEST_FL_EXTERNAL_LB_DONE: Driver performed the external loopback test
634607ca46eSDavid Howells  */
635607ca46eSDavid Howells 
636607ca46eSDavid Howells enum ethtool_test_flags {
637607ca46eSDavid Howells 	ETH_TEST_FL_OFFLINE	= (1 << 0),
638607ca46eSDavid Howells 	ETH_TEST_FL_FAILED	= (1 << 1),
639607ca46eSDavid Howells 	ETH_TEST_FL_EXTERNAL_LB	= (1 << 2),
640607ca46eSDavid Howells 	ETH_TEST_FL_EXTERNAL_LB_DONE	= (1 << 3),
641607ca46eSDavid Howells };
642607ca46eSDavid Howells 
6434e5a62dbSBen Hutchings /**
6444e5a62dbSBen Hutchings  * struct ethtool_test - device self-test invocation
6454e5a62dbSBen Hutchings  * @cmd: Command number = %ETHTOOL_TEST
6464e5a62dbSBen Hutchings  * @flags: A bitmask of flags from &enum ethtool_test_flags.  Some
6474e5a62dbSBen Hutchings  *	flags may be set by the user on entry; others may be set by
6484e5a62dbSBen Hutchings  *	the driver on return.
6494e5a62dbSBen Hutchings  * @len: On return, the number of test results
6504e5a62dbSBen Hutchings  * @data: Array of test results
6514e5a62dbSBen Hutchings  *
6524e5a62dbSBen Hutchings  * Users must use %ETHTOOL_GSSET_INFO or %ETHTOOL_GDRVINFO to find the
6534e5a62dbSBen Hutchings  * number of test results that will be returned.  They must allocate a
6544e5a62dbSBen Hutchings  * buffer of the appropriate size (8 * number of results) immediately
6554e5a62dbSBen Hutchings  * following this structure.
6564e5a62dbSBen Hutchings  */
657607ca46eSDavid Howells struct ethtool_test {
6584e5a62dbSBen Hutchings 	__u32	cmd;
6594e5a62dbSBen Hutchings 	__u32	flags;
660607ca46eSDavid Howells 	__u32	reserved;
6614e5a62dbSBen Hutchings 	__u32	len;
662607ca46eSDavid Howells 	__u64	data[0];
663607ca46eSDavid Howells };
664607ca46eSDavid Howells 
66559091229SBen Hutchings /**
66659091229SBen Hutchings  * struct ethtool_stats - device-specific statistics
66759091229SBen Hutchings  * @cmd: Command number = %ETHTOOL_GSTATS
66859091229SBen Hutchings  * @n_stats: On return, the number of statistics
66959091229SBen Hutchings  * @data: Array of statistics
67059091229SBen Hutchings  *
67159091229SBen Hutchings  * Users must use %ETHTOOL_GSSET_INFO or %ETHTOOL_GDRVINFO to find the
67259091229SBen Hutchings  * number of statistics that will be returned.  They must allocate a
67359091229SBen Hutchings  * buffer of the appropriate size (8 * number of statistics)
67459091229SBen Hutchings  * immediately following this structure.
67559091229SBen Hutchings  */
676607ca46eSDavid Howells struct ethtool_stats {
67759091229SBen Hutchings 	__u32	cmd;
67859091229SBen Hutchings 	__u32	n_stats;
679607ca46eSDavid Howells 	__u64	data[0];
680607ca46eSDavid Howells };
681607ca46eSDavid Howells 
682f432c095SBen Hutchings /**
683f432c095SBen Hutchings  * struct ethtool_perm_addr - permanent hardware address
684f432c095SBen Hutchings  * @cmd: Command number = %ETHTOOL_GPERMADDR
685f432c095SBen Hutchings  * @size: On entry, the size of the buffer.  On return, the size of the
686f432c095SBen Hutchings  *	address.  The command fails if the buffer is too small.
687f432c095SBen Hutchings  * @data: Buffer for the address
688f432c095SBen Hutchings  *
689f432c095SBen Hutchings  * Users must allocate the buffer immediately following this structure.
690f432c095SBen Hutchings  * A buffer size of %MAX_ADDR_LEN should be sufficient for any address
691f432c095SBen Hutchings  * type.
692f432c095SBen Hutchings  */
693607ca46eSDavid Howells struct ethtool_perm_addr {
694f432c095SBen Hutchings 	__u32	cmd;
695607ca46eSDavid Howells 	__u32	size;
696607ca46eSDavid Howells 	__u8	data[0];
697607ca46eSDavid Howells };
698607ca46eSDavid Howells 
699607ca46eSDavid Howells /* boolean flags controlling per-interface behavior characteristics.
700607ca46eSDavid Howells  * When reading, the flag indicates whether or not a certain behavior
701607ca46eSDavid Howells  * is enabled/present.  When writing, the flag indicates whether
702607ca46eSDavid Howells  * or not the driver should turn on (set) or off (clear) a behavior.
703607ca46eSDavid Howells  *
704607ca46eSDavid Howells  * Some behaviors may read-only (unconditionally absent or present).
705607ca46eSDavid Howells  * If such is the case, return EINVAL in the set-flags operation if the
706607ca46eSDavid Howells  * flag differs from the read-only value.
707607ca46eSDavid Howells  */
708607ca46eSDavid Howells enum ethtool_flags {
709607ca46eSDavid Howells 	ETH_FLAG_TXVLAN		= (1 << 7),	/* TX VLAN offload enabled */
710607ca46eSDavid Howells 	ETH_FLAG_RXVLAN		= (1 << 8),	/* RX VLAN offload enabled */
711607ca46eSDavid Howells 	ETH_FLAG_LRO		= (1 << 15),	/* LRO is enabled */
712607ca46eSDavid Howells 	ETH_FLAG_NTUPLE		= (1 << 27),	/* N-tuple filters enabled */
713607ca46eSDavid Howells 	ETH_FLAG_RXHASH		= (1 << 28),
714607ca46eSDavid Howells };
715607ca46eSDavid Howells 
716607ca46eSDavid Howells /* The following structures are for supporting RX network flow
717607ca46eSDavid Howells  * classification and RX n-tuple configuration. Note, all multibyte
718607ca46eSDavid Howells  * fields, e.g., ip4src, ip4dst, psrc, pdst, spi, etc. are expected to
719607ca46eSDavid Howells  * be in network byte order.
720607ca46eSDavid Howells  */
721607ca46eSDavid Howells 
722607ca46eSDavid Howells /**
723607ca46eSDavid Howells  * struct ethtool_tcpip4_spec - flow specification for TCP/IPv4 etc.
724607ca46eSDavid Howells  * @ip4src: Source host
725607ca46eSDavid Howells  * @ip4dst: Destination host
726607ca46eSDavid Howells  * @psrc: Source port
727607ca46eSDavid Howells  * @pdst: Destination port
728607ca46eSDavid Howells  * @tos: Type-of-service
729607ca46eSDavid Howells  *
730607ca46eSDavid Howells  * This can be used to specify a TCP/IPv4, UDP/IPv4 or SCTP/IPv4 flow.
731607ca46eSDavid Howells  */
732607ca46eSDavid Howells struct ethtool_tcpip4_spec {
733607ca46eSDavid Howells 	__be32	ip4src;
734607ca46eSDavid Howells 	__be32	ip4dst;
735607ca46eSDavid Howells 	__be16	psrc;
736607ca46eSDavid Howells 	__be16	pdst;
737607ca46eSDavid Howells 	__u8    tos;
738607ca46eSDavid Howells };
739607ca46eSDavid Howells 
740607ca46eSDavid Howells /**
741607ca46eSDavid Howells  * struct ethtool_ah_espip4_spec - flow specification for IPsec/IPv4
742607ca46eSDavid Howells  * @ip4src: Source host
743607ca46eSDavid Howells  * @ip4dst: Destination host
744607ca46eSDavid Howells  * @spi: Security parameters index
745607ca46eSDavid Howells  * @tos: Type-of-service
746607ca46eSDavid Howells  *
747607ca46eSDavid Howells  * This can be used to specify an IPsec transport or tunnel over IPv4.
748607ca46eSDavid Howells  */
749607ca46eSDavid Howells struct ethtool_ah_espip4_spec {
750607ca46eSDavid Howells 	__be32	ip4src;
751607ca46eSDavid Howells 	__be32	ip4dst;
752607ca46eSDavid Howells 	__be32	spi;
753607ca46eSDavid Howells 	__u8    tos;
754607ca46eSDavid Howells };
755607ca46eSDavid Howells 
756607ca46eSDavid Howells #define	ETH_RX_NFC_IP4	1
757607ca46eSDavid Howells 
758607ca46eSDavid Howells /**
759607ca46eSDavid Howells  * struct ethtool_usrip4_spec - general flow specification for IPv4
760607ca46eSDavid Howells  * @ip4src: Source host
761607ca46eSDavid Howells  * @ip4dst: Destination host
762607ca46eSDavid Howells  * @l4_4_bytes: First 4 bytes of transport (layer 4) header
763607ca46eSDavid Howells  * @tos: Type-of-service
764607ca46eSDavid Howells  * @ip_ver: Value must be %ETH_RX_NFC_IP4; mask must be 0
765607ca46eSDavid Howells  * @proto: Transport protocol number; mask must be 0
766607ca46eSDavid Howells  */
767607ca46eSDavid Howells struct ethtool_usrip4_spec {
768607ca46eSDavid Howells 	__be32	ip4src;
769607ca46eSDavid Howells 	__be32	ip4dst;
770607ca46eSDavid Howells 	__be32	l4_4_bytes;
771607ca46eSDavid Howells 	__u8    tos;
772607ca46eSDavid Howells 	__u8    ip_ver;
773607ca46eSDavid Howells 	__u8    proto;
774607ca46eSDavid Howells };
775607ca46eSDavid Howells 
77672bb6872SEdward Cree /**
77772bb6872SEdward Cree  * struct ethtool_tcpip6_spec - flow specification for TCP/IPv6 etc.
77872bb6872SEdward Cree  * @ip6src: Source host
77972bb6872SEdward Cree  * @ip6dst: Destination host
78072bb6872SEdward Cree  * @psrc: Source port
78172bb6872SEdward Cree  * @pdst: Destination port
78272bb6872SEdward Cree  * @tclass: Traffic Class
78372bb6872SEdward Cree  *
78472bb6872SEdward Cree  * This can be used to specify a TCP/IPv6, UDP/IPv6 or SCTP/IPv6 flow.
78572bb6872SEdward Cree  */
78672bb6872SEdward Cree struct ethtool_tcpip6_spec {
78772bb6872SEdward Cree 	__be32	ip6src[4];
78872bb6872SEdward Cree 	__be32	ip6dst[4];
78972bb6872SEdward Cree 	__be16	psrc;
79072bb6872SEdward Cree 	__be16	pdst;
79172bb6872SEdward Cree 	__u8    tclass;
79272bb6872SEdward Cree };
79372bb6872SEdward Cree 
79472bb6872SEdward Cree /**
79572bb6872SEdward Cree  * struct ethtool_ah_espip6_spec - flow specification for IPsec/IPv6
79672bb6872SEdward Cree  * @ip6src: Source host
79772bb6872SEdward Cree  * @ip6dst: Destination host
79872bb6872SEdward Cree  * @spi: Security parameters index
79972bb6872SEdward Cree  * @tclass: Traffic Class
80072bb6872SEdward Cree  *
80172bb6872SEdward Cree  * This can be used to specify an IPsec transport or tunnel over IPv6.
80272bb6872SEdward Cree  */
80372bb6872SEdward Cree struct ethtool_ah_espip6_spec {
80472bb6872SEdward Cree 	__be32	ip6src[4];
80572bb6872SEdward Cree 	__be32	ip6dst[4];
80672bb6872SEdward Cree 	__be32	spi;
80772bb6872SEdward Cree 	__u8    tclass;
80872bb6872SEdward Cree };
80972bb6872SEdward Cree 
81072bb6872SEdward Cree /**
81172bb6872SEdward Cree  * struct ethtool_usrip6_spec - general flow specification for IPv6
81272bb6872SEdward Cree  * @ip6src: Source host
81372bb6872SEdward Cree  * @ip6dst: Destination host
81472bb6872SEdward Cree  * @l4_4_bytes: First 4 bytes of transport (layer 4) header
81572bb6872SEdward Cree  * @tclass: Traffic Class
81672bb6872SEdward Cree  * @l4_proto: Transport protocol number (nexthdr after any Extension Headers)
81772bb6872SEdward Cree  */
81872bb6872SEdward Cree struct ethtool_usrip6_spec {
81972bb6872SEdward Cree 	__be32	ip6src[4];
82072bb6872SEdward Cree 	__be32	ip6dst[4];
82172bb6872SEdward Cree 	__be32	l4_4_bytes;
82272bb6872SEdward Cree 	__u8    tclass;
82372bb6872SEdward Cree 	__u8    l4_proto;
82472bb6872SEdward Cree };
82572bb6872SEdward Cree 
826607ca46eSDavid Howells union ethtool_flow_union {
827607ca46eSDavid Howells 	struct ethtool_tcpip4_spec		tcp_ip4_spec;
828607ca46eSDavid Howells 	struct ethtool_tcpip4_spec		udp_ip4_spec;
829607ca46eSDavid Howells 	struct ethtool_tcpip4_spec		sctp_ip4_spec;
830607ca46eSDavid Howells 	struct ethtool_ah_espip4_spec		ah_ip4_spec;
831607ca46eSDavid Howells 	struct ethtool_ah_espip4_spec		esp_ip4_spec;
832607ca46eSDavid Howells 	struct ethtool_usrip4_spec		usr_ip4_spec;
83372bb6872SEdward Cree 	struct ethtool_tcpip6_spec		tcp_ip6_spec;
83472bb6872SEdward Cree 	struct ethtool_tcpip6_spec		udp_ip6_spec;
83572bb6872SEdward Cree 	struct ethtool_tcpip6_spec		sctp_ip6_spec;
83672bb6872SEdward Cree 	struct ethtool_ah_espip6_spec		ah_ip6_spec;
83772bb6872SEdward Cree 	struct ethtool_ah_espip6_spec		esp_ip6_spec;
83872bb6872SEdward Cree 	struct ethtool_usrip6_spec		usr_ip6_spec;
839607ca46eSDavid Howells 	struct ethhdr				ether_spec;
840d4676eacSYan Burman 	__u8					hdata[52];
841607ca46eSDavid Howells };
842607ca46eSDavid Howells 
843dc2e5734SYan Burman /**
844dc2e5734SYan Burman  * struct ethtool_flow_ext - additional RX flow fields
845dc2e5734SYan Burman  * @h_dest: destination MAC address
846dc2e5734SYan Burman  * @vlan_etype: VLAN EtherType
847dc2e5734SYan Burman  * @vlan_tci: VLAN tag control information
848dc2e5734SYan Burman  * @data: user defined data
849dc2e5734SYan Burman  *
850dc2e5734SYan Burman  * Note, @vlan_etype, @vlan_tci, and @data are only valid if %FLOW_EXT
851dc2e5734SYan Burman  * is set in &struct ethtool_rx_flow_spec @flow_type.
852dc2e5734SYan Burman  * @h_dest is valid if %FLOW_MAC_EXT is set.
853dc2e5734SYan Burman  */
854607ca46eSDavid Howells struct ethtool_flow_ext {
855d4676eacSYan Burman 	__u8		padding[2];
856dc2e5734SYan Burman 	unsigned char	h_dest[ETH_ALEN];
857607ca46eSDavid Howells 	__be16		vlan_etype;
858607ca46eSDavid Howells 	__be16		vlan_tci;
859607ca46eSDavid Howells 	__be32		data[2];
860607ca46eSDavid Howells };
861607ca46eSDavid Howells 
862607ca46eSDavid Howells /**
863607ca46eSDavid Howells  * struct ethtool_rx_flow_spec - classification rule for RX flows
864607ca46eSDavid Howells  * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
865607ca46eSDavid Howells  * @h_u: Flow fields to match (dependent on @flow_type)
866607ca46eSDavid Howells  * @h_ext: Additional fields to match
867607ca46eSDavid Howells  * @m_u: Masks for flow field bits to be matched
868607ca46eSDavid Howells  * @m_ext: Masks for additional field bits to be matched
869607ca46eSDavid Howells  *	Note, all additional fields must be ignored unless @flow_type
870dc2e5734SYan Burman  *	includes the %FLOW_EXT or %FLOW_MAC_EXT flag
871dc2e5734SYan Burman  *	(see &struct ethtool_flow_ext description).
872607ca46eSDavid Howells  * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC
873607ca46eSDavid Howells  *	if packets should be discarded
874607ca46eSDavid Howells  * @location: Location of rule in the table.  Locations must be
875607ca46eSDavid Howells  *	numbered such that a flow matching multiple rules will be
876607ca46eSDavid Howells  *	classified according to the first (lowest numbered) rule.
877607ca46eSDavid Howells  */
878607ca46eSDavid Howells struct ethtool_rx_flow_spec {
879607ca46eSDavid Howells 	__u32		flow_type;
880607ca46eSDavid Howells 	union ethtool_flow_union h_u;
881607ca46eSDavid Howells 	struct ethtool_flow_ext h_ext;
882607ca46eSDavid Howells 	union ethtool_flow_union m_u;
883607ca46eSDavid Howells 	struct ethtool_flow_ext m_ext;
884607ca46eSDavid Howells 	__u64		ring_cookie;
885607ca46eSDavid Howells 	__u32		location;
886607ca46eSDavid Howells };
887607ca46eSDavid Howells 
8888cf6f497SJohn Fastabend /* How rings are layed out when accessing virtual functions or
8898cf6f497SJohn Fastabend  * offloaded queues is device specific. To allow users to do flow
8908cf6f497SJohn Fastabend  * steering and specify these queues the ring cookie is partitioned
8918cf6f497SJohn Fastabend  * into a 32bit queue index with an 8 bit virtual function id.
8928cf6f497SJohn Fastabend  * This also leaves the 3bytes for further specifiers. It is possible
8938cf6f497SJohn Fastabend  * future devices may support more than 256 virtual functions if
8948cf6f497SJohn Fastabend  * devices start supporting PCIe w/ARI. However at the moment I
8958cf6f497SJohn Fastabend  * do not know of any devices that support this so I do not reserve
8968cf6f497SJohn Fastabend  * space for this at this time. If a future patch consumes the next
8978cf6f497SJohn Fastabend  * byte it should be aware of this possiblity.
8988cf6f497SJohn Fastabend  */
8998cf6f497SJohn Fastabend #define ETHTOOL_RX_FLOW_SPEC_RING	0x00000000FFFFFFFFLL
9008cf6f497SJohn Fastabend #define ETHTOOL_RX_FLOW_SPEC_RING_VF	0x000000FF00000000LL
9018cf6f497SJohn Fastabend #define ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF 32
9028cf6f497SJohn Fastabend static inline __u64 ethtool_get_flow_spec_ring(__u64 ring_cookie)
9038cf6f497SJohn Fastabend {
9048cf6f497SJohn Fastabend 	return ETHTOOL_RX_FLOW_SPEC_RING & ring_cookie;
9058cf6f497SJohn Fastabend };
9068cf6f497SJohn Fastabend 
9078cf6f497SJohn Fastabend static inline __u64 ethtool_get_flow_spec_ring_vf(__u64 ring_cookie)
9088cf6f497SJohn Fastabend {
9098cf6f497SJohn Fastabend 	return (ETHTOOL_RX_FLOW_SPEC_RING_VF & ring_cookie) >>
9108cf6f497SJohn Fastabend 				ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF;
9118cf6f497SJohn Fastabend };
9128cf6f497SJohn Fastabend 
913607ca46eSDavid Howells /**
914607ca46eSDavid Howells  * struct ethtool_rxnfc - command to get or set RX flow classification rules
915607ca46eSDavid Howells  * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,
916607ca46eSDavid Howells  *	%ETHTOOL_GRXRINGS, %ETHTOOL_GRXCLSRLCNT, %ETHTOOL_GRXCLSRULE,
917607ca46eSDavid Howells  *	%ETHTOOL_GRXCLSRLALL, %ETHTOOL_SRXCLSRLDEL or %ETHTOOL_SRXCLSRLINS
918607ca46eSDavid Howells  * @flow_type: Type of flow to be affected, e.g. %TCP_V4_FLOW
919607ca46eSDavid Howells  * @data: Command-dependent value
920607ca46eSDavid Howells  * @fs: Flow classification rule
92184a1d9c4SEdward Cree  * @rss_context: RSS context to be affected
922607ca46eSDavid Howells  * @rule_cnt: Number of rules to be affected
923607ca46eSDavid Howells  * @rule_locs: Array of used rule locations
924607ca46eSDavid Howells  *
925607ca46eSDavid Howells  * For %ETHTOOL_GRXFH and %ETHTOOL_SRXFH, @data is a bitmask indicating
926607ca46eSDavid Howells  * the fields included in the flow hash, e.g. %RXH_IP_SRC.  The following
92784a1d9c4SEdward Cree  * structure fields must not be used, except that if @flow_type includes
92884a1d9c4SEdward Cree  * the %FLOW_RSS flag, then @rss_context determines which RSS context to
92984a1d9c4SEdward Cree  * act on.
930607ca46eSDavid Howells  *
931607ca46eSDavid Howells  * For %ETHTOOL_GRXRINGS, @data is set to the number of RX rings/queues
932607ca46eSDavid Howells  * on return.
933607ca46eSDavid Howells  *
934607ca46eSDavid Howells  * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined
935607ca46eSDavid Howells  * rules on return.  If @data is non-zero on return then it is the
936607ca46eSDavid Howells  * size of the rule table, plus the flag %RX_CLS_LOC_SPECIAL if the
937607ca46eSDavid Howells  * driver supports any special location values.  If that flag is not
938607ca46eSDavid Howells  * set in @data then special location values should not be used.
939607ca46eSDavid Howells  *
940607ca46eSDavid Howells  * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the location of an
94184a1d9c4SEdward Cree  * existing rule on entry and @fs contains the rule on return; if
94284a1d9c4SEdward Cree  * @fs.@flow_type includes the %FLOW_RSS flag, then @rss_context is
94384a1d9c4SEdward Cree  * filled with the RSS context ID associated with the rule.
944607ca46eSDavid Howells  *
945607ca46eSDavid Howells  * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the
946607ca46eSDavid Howells  * user buffer for @rule_locs on entry.  On return, @data is the size
947607ca46eSDavid Howells  * of the rule table, @rule_cnt is the number of defined rules, and
948607ca46eSDavid Howells  * @rule_locs contains the locations of the defined rules.  Drivers
949607ca46eSDavid Howells  * must use the second parameter to get_rxnfc() instead of @rule_locs.
950607ca46eSDavid Howells  *
951607ca46eSDavid Howells  * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update.
952607ca46eSDavid Howells  * @fs.@location either specifies the location to use or is a special
953607ca46eSDavid Howells  * location value with %RX_CLS_LOC_SPECIAL flag set.  On return,
95484a1d9c4SEdward Cree  * @fs.@location is the actual rule location.  If @fs.@flow_type
95584a1d9c4SEdward Cree  * includes the %FLOW_RSS flag, @rss_context is the RSS context ID to
95684a1d9c4SEdward Cree  * use for flow spreading traffic which matches this rule.  The value
95784a1d9c4SEdward Cree  * from the rxfh indirection table will be added to @fs.@ring_cookie
95884a1d9c4SEdward Cree  * to choose which ring to deliver to.
959607ca46eSDavid Howells  *
960607ca46eSDavid Howells  * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the location of an
961607ca46eSDavid Howells  * existing rule on entry.
962607ca46eSDavid Howells  *
963607ca46eSDavid Howells  * A driver supporting the special location values for
964607ca46eSDavid Howells  * %ETHTOOL_SRXCLSRLINS may add the rule at any suitable unused
965607ca46eSDavid Howells  * location, and may remove a rule at a later location (lower
966607ca46eSDavid Howells  * priority) that matches exactly the same set of flows.  The special
967073e3cf2SBen Hutchings  * values are %RX_CLS_LOC_ANY, selecting any location;
968607ca46eSDavid Howells  * %RX_CLS_LOC_FIRST, selecting the first suitable location (maximum
969607ca46eSDavid Howells  * priority); and %RX_CLS_LOC_LAST, selecting the last suitable
970607ca46eSDavid Howells  * location (minimum priority).  Additional special values may be
971607ca46eSDavid Howells  * defined in future and drivers must return -%EINVAL for any
972607ca46eSDavid Howells  * unrecognised value.
973607ca46eSDavid Howells  */
974607ca46eSDavid Howells struct ethtool_rxnfc {
975607ca46eSDavid Howells 	__u32				cmd;
976607ca46eSDavid Howells 	__u32				flow_type;
977607ca46eSDavid Howells 	__u64				data;
978607ca46eSDavid Howells 	struct ethtool_rx_flow_spec	fs;
97984a1d9c4SEdward Cree 	union {
980607ca46eSDavid Howells 		__u32			rule_cnt;
98184a1d9c4SEdward Cree 		__u32			rss_context;
98284a1d9c4SEdward Cree 	};
983607ca46eSDavid Howells 	__u32				rule_locs[0];
984607ca46eSDavid Howells };
985607ca46eSDavid Howells 
986607ca46eSDavid Howells 
987607ca46eSDavid Howells /**
988607ca46eSDavid Howells  * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection
989607ca46eSDavid Howells  * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR
990607ca46eSDavid Howells  * @size: On entry, the array size of the user buffer, which may be zero.
991607ca46eSDavid Howells  *	On return from %ETHTOOL_GRXFHINDIR, the array size of the hardware
992607ca46eSDavid Howells  *	indirection table.
993607ca46eSDavid Howells  * @ring_index: RX ring/queue index for each hash value
994607ca46eSDavid Howells  *
995607ca46eSDavid Howells  * For %ETHTOOL_GRXFHINDIR, a @size of zero means that only the size
996607ca46eSDavid Howells  * should be returned.  For %ETHTOOL_SRXFHINDIR, a @size of zero means
997607ca46eSDavid Howells  * the table should be reset to default values.  This last feature
998607ca46eSDavid Howells  * is not supported by the original implementations.
999607ca46eSDavid Howells  */
1000607ca46eSDavid Howells struct ethtool_rxfh_indir {
1001607ca46eSDavid Howells 	__u32	cmd;
1002607ca46eSDavid Howells 	__u32	size;
1003607ca46eSDavid Howells 	__u32	ring_index[0];
1004607ca46eSDavid Howells };
1005607ca46eSDavid Howells 
1006607ca46eSDavid Howells /**
10073de0b592SVenkata Duvvuru  * struct ethtool_rxfh - command to get/set RX flow hash indir or/and hash key.
10083de0b592SVenkata Duvvuru  * @cmd: Specific command number - %ETHTOOL_GRSSH or %ETHTOOL_SRSSH
100984a1d9c4SEdward Cree  * @rss_context: RSS context identifier.  Context 0 is the default for normal
101084a1d9c4SEdward Cree  *	traffic; other contexts can be referenced as the destination for RX flow
101184a1d9c4SEdward Cree  *	classification rules.  %ETH_RXFH_CONTEXT_ALLOC is used with command
101284a1d9c4SEdward Cree  *	%ETHTOOL_SRSSH to allocate a new RSS context; on return this field will
101384a1d9c4SEdward Cree  *	contain the ID of the newly allocated context.
101438c891a4SBen Hutchings  * @indir_size: On entry, the array size of the user buffer for the
101538c891a4SBen Hutchings  *	indirection table, which may be zero, or (for %ETHTOOL_SRSSH),
101638c891a4SBen Hutchings  *	%ETH_RXFH_INDIR_NO_CHANGE.  On return from %ETHTOOL_GRSSH,
101738c891a4SBen Hutchings  *	the array size of the hardware indirection table.
101838c891a4SBen Hutchings  * @key_size: On entry, the array size of the user buffer for the hash key,
101938c891a4SBen Hutchings  *	which may be zero.  On return from %ETHTOOL_GRSSH, the size of the
102038c891a4SBen Hutchings  *	hardware hash key.
1021892311f6SEyal Perry  * @hfunc: Defines the current RSS hash function used by HW (or to be set to).
1022892311f6SEyal Perry  *	Valid values are one of the %ETH_RSS_HASH_*.
10233de0b592SVenkata Duvvuru  * @rsvd:	Reserved for future extensions.
10243de0b592SVenkata Duvvuru  * @rss_config: RX ring/queue index for each hash value i.e., indirection table
102538c891a4SBen Hutchings  *	of @indir_size __u32 elements, followed by hash key of @key_size
102638c891a4SBen Hutchings  *	bytes.
10273de0b592SVenkata Duvvuru  *
10283de0b592SVenkata Duvvuru  * For %ETHTOOL_GRSSH, a @indir_size and key_size of zero means that only the
10297455fa24SBen Hutchings  * size should be returned.  For %ETHTOOL_SRSSH, an @indir_size of
10307455fa24SBen Hutchings  * %ETH_RXFH_INDIR_NO_CHANGE means that indir table setting is not requested
10317455fa24SBen Hutchings  * and a @indir_size of zero means the indir table should be reset to default
103284a1d9c4SEdward Cree  * values (if @rss_context == 0) or that the RSS context should be deleted.
103384a1d9c4SEdward Cree  * An hfunc of zero means that hash function setting is not requested.
10343de0b592SVenkata Duvvuru  */
10353de0b592SVenkata Duvvuru struct ethtool_rxfh {
10363de0b592SVenkata Duvvuru 	__u32   cmd;
10373de0b592SVenkata Duvvuru 	__u32	rss_context;
10383de0b592SVenkata Duvvuru 	__u32   indir_size;
10393de0b592SVenkata Duvvuru 	__u32   key_size;
1040892311f6SEyal Perry 	__u8	hfunc;
1041892311f6SEyal Perry 	__u8	rsvd8[3];
1042892311f6SEyal Perry 	__u32	rsvd32;
10433de0b592SVenkata Duvvuru 	__u32   rss_config[0];
10443de0b592SVenkata Duvvuru };
104584a1d9c4SEdward Cree #define ETH_RXFH_CONTEXT_ALLOC		0xffffffff
10467455fa24SBen Hutchings #define ETH_RXFH_INDIR_NO_CHANGE	0xffffffff
10473de0b592SVenkata Duvvuru 
10483de0b592SVenkata Duvvuru /**
1049607ca46eSDavid Howells  * struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter
1050607ca46eSDavid Howells  * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
1051607ca46eSDavid Howells  * @h_u: Flow field values to match (dependent on @flow_type)
1052607ca46eSDavid Howells  * @m_u: Masks for flow field value bits to be ignored
1053607ca46eSDavid Howells  * @vlan_tag: VLAN tag to match
1054607ca46eSDavid Howells  * @vlan_tag_mask: Mask for VLAN tag bits to be ignored
1055607ca46eSDavid Howells  * @data: Driver-dependent data to match
1056607ca46eSDavid Howells  * @data_mask: Mask for driver-dependent data bits to be ignored
1057607ca46eSDavid Howells  * @action: RX ring/queue index to deliver to (non-negative) or other action
1058607ca46eSDavid Howells  *	(negative, e.g. %ETHTOOL_RXNTUPLE_ACTION_DROP)
1059607ca46eSDavid Howells  *
1060607ca46eSDavid Howells  * For flow types %TCP_V4_FLOW, %UDP_V4_FLOW and %SCTP_V4_FLOW, where
1061607ca46eSDavid Howells  * a field value and mask are both zero this is treated as if all mask
1062607ca46eSDavid Howells  * bits are set i.e. the field is ignored.
1063607ca46eSDavid Howells  */
1064607ca46eSDavid Howells struct ethtool_rx_ntuple_flow_spec {
1065607ca46eSDavid Howells 	__u32		 flow_type;
1066607ca46eSDavid Howells 	union {
1067607ca46eSDavid Howells 		struct ethtool_tcpip4_spec		tcp_ip4_spec;
1068607ca46eSDavid Howells 		struct ethtool_tcpip4_spec		udp_ip4_spec;
1069607ca46eSDavid Howells 		struct ethtool_tcpip4_spec		sctp_ip4_spec;
1070607ca46eSDavid Howells 		struct ethtool_ah_espip4_spec		ah_ip4_spec;
1071607ca46eSDavid Howells 		struct ethtool_ah_espip4_spec		esp_ip4_spec;
1072607ca46eSDavid Howells 		struct ethtool_usrip4_spec		usr_ip4_spec;
1073607ca46eSDavid Howells 		struct ethhdr				ether_spec;
1074607ca46eSDavid Howells 		__u8					hdata[72];
1075607ca46eSDavid Howells 	} h_u, m_u;
1076607ca46eSDavid Howells 
1077607ca46eSDavid Howells 	__u16	        vlan_tag;
1078607ca46eSDavid Howells 	__u16	        vlan_tag_mask;
1079607ca46eSDavid Howells 	__u64		data;
1080607ca46eSDavid Howells 	__u64		data_mask;
1081607ca46eSDavid Howells 
1082607ca46eSDavid Howells 	__s32		action;
1083607ca46eSDavid Howells #define ETHTOOL_RXNTUPLE_ACTION_DROP	(-1)	/* drop packet */
1084607ca46eSDavid Howells #define ETHTOOL_RXNTUPLE_ACTION_CLEAR	(-2)	/* clear filter */
1085607ca46eSDavid Howells };
1086607ca46eSDavid Howells 
1087607ca46eSDavid Howells /**
1088607ca46eSDavid Howells  * struct ethtool_rx_ntuple - command to set or clear RX flow filter
1089607ca46eSDavid Howells  * @cmd: Command number - %ETHTOOL_SRXNTUPLE
1090607ca46eSDavid Howells  * @fs: Flow filter specification
1091607ca46eSDavid Howells  */
1092607ca46eSDavid Howells struct ethtool_rx_ntuple {
1093607ca46eSDavid Howells 	__u32					cmd;
1094607ca46eSDavid Howells 	struct ethtool_rx_ntuple_flow_spec	fs;
1095607ca46eSDavid Howells };
1096607ca46eSDavid Howells 
1097607ca46eSDavid Howells #define ETHTOOL_FLASH_MAX_FILENAME	128
1098607ca46eSDavid Howells enum ethtool_flash_op_type {
1099607ca46eSDavid Howells 	ETHTOOL_FLASH_ALL_REGIONS	= 0,
1100607ca46eSDavid Howells };
1101607ca46eSDavid Howells 
1102607ca46eSDavid Howells /* for passing firmware flashing related parameters */
1103607ca46eSDavid Howells struct ethtool_flash {
1104607ca46eSDavid Howells 	__u32	cmd;
1105607ca46eSDavid Howells 	__u32	region;
1106607ca46eSDavid Howells 	char	data[ETHTOOL_FLASH_MAX_FILENAME];
1107607ca46eSDavid Howells };
1108607ca46eSDavid Howells 
1109607ca46eSDavid Howells /**
1110607ca46eSDavid Howells  * struct ethtool_dump - used for retrieving, setting device dump
1111607ca46eSDavid Howells  * @cmd: Command number - %ETHTOOL_GET_DUMP_FLAG, %ETHTOOL_GET_DUMP_DATA, or
1112607ca46eSDavid Howells  * 	%ETHTOOL_SET_DUMP
1113607ca46eSDavid Howells  * @version: FW version of the dump, filled in by driver
1114607ca46eSDavid Howells  * @flag: driver dependent flag for dump setting, filled in by driver during
1115607ca46eSDavid Howells  *        get and filled in by ethtool for set operation.
1116607ca46eSDavid Howells  *        flag must be initialized by macro ETH_FW_DUMP_DISABLE value when
1117607ca46eSDavid Howells  *        firmware dump is disabled.
1118607ca46eSDavid Howells  * @len: length of dump data, used as the length of the user buffer on entry to
1119607ca46eSDavid Howells  * 	 %ETHTOOL_GET_DUMP_DATA and this is returned as dump length by driver
1120607ca46eSDavid Howells  * 	 for %ETHTOOL_GET_DUMP_FLAG command
1121607ca46eSDavid Howells  * @data: data collected for get dump data operation
1122607ca46eSDavid Howells  */
1123607ca46eSDavid Howells struct ethtool_dump {
1124607ca46eSDavid Howells 	__u32	cmd;
1125607ca46eSDavid Howells 	__u32	version;
1126607ca46eSDavid Howells 	__u32	flag;
1127607ca46eSDavid Howells 	__u32	len;
1128607ca46eSDavid Howells 	__u8	data[0];
1129607ca46eSDavid Howells };
1130607ca46eSDavid Howells 
1131ba569dc3SBen Hutchings #define ETH_FW_DUMP_DISABLE 0
1132ba569dc3SBen Hutchings 
1133607ca46eSDavid Howells /* for returning and changing feature sets */
1134607ca46eSDavid Howells 
1135607ca46eSDavid Howells /**
1136607ca46eSDavid Howells  * struct ethtool_get_features_block - block with state of 32 features
1137607ca46eSDavid Howells  * @available: mask of changeable features
1138607ca46eSDavid Howells  * @requested: mask of features requested to be enabled if possible
1139607ca46eSDavid Howells  * @active: mask of currently enabled features
1140607ca46eSDavid Howells  * @never_changed: mask of features not changeable for any device
1141607ca46eSDavid Howells  */
1142607ca46eSDavid Howells struct ethtool_get_features_block {
1143607ca46eSDavid Howells 	__u32	available;
1144607ca46eSDavid Howells 	__u32	requested;
1145607ca46eSDavid Howells 	__u32	active;
1146607ca46eSDavid Howells 	__u32	never_changed;
1147607ca46eSDavid Howells };
1148607ca46eSDavid Howells 
1149607ca46eSDavid Howells /**
1150607ca46eSDavid Howells  * struct ethtool_gfeatures - command to get state of device's features
1151607ca46eSDavid Howells  * @cmd: command number = %ETHTOOL_GFEATURES
1152073e3cf2SBen Hutchings  * @size: On entry, the number of elements in the features[] array;
1153073e3cf2SBen Hutchings  *	on return, the number of elements in features[] needed to hold
1154073e3cf2SBen Hutchings  *	all features
1155607ca46eSDavid Howells  * @features: state of features
1156607ca46eSDavid Howells  */
1157607ca46eSDavid Howells struct ethtool_gfeatures {
1158607ca46eSDavid Howells 	__u32	cmd;
1159607ca46eSDavid Howells 	__u32	size;
1160607ca46eSDavid Howells 	struct ethtool_get_features_block features[0];
1161607ca46eSDavid Howells };
1162607ca46eSDavid Howells 
1163607ca46eSDavid Howells /**
1164607ca46eSDavid Howells  * struct ethtool_set_features_block - block with request for 32 features
1165607ca46eSDavid Howells  * @valid: mask of features to be changed
1166607ca46eSDavid Howells  * @requested: values of features to be changed
1167607ca46eSDavid Howells  */
1168607ca46eSDavid Howells struct ethtool_set_features_block {
1169607ca46eSDavid Howells 	__u32	valid;
1170607ca46eSDavid Howells 	__u32	requested;
1171607ca46eSDavid Howells };
1172607ca46eSDavid Howells 
1173607ca46eSDavid Howells /**
1174607ca46eSDavid Howells  * struct ethtool_sfeatures - command to request change in device's features
1175607ca46eSDavid Howells  * @cmd: command number = %ETHTOOL_SFEATURES
1176607ca46eSDavid Howells  * @size: array size of the features[] array
1177607ca46eSDavid Howells  * @features: feature change masks
1178607ca46eSDavid Howells  */
1179607ca46eSDavid Howells struct ethtool_sfeatures {
1180607ca46eSDavid Howells 	__u32	cmd;
1181607ca46eSDavid Howells 	__u32	size;
1182607ca46eSDavid Howells 	struct ethtool_set_features_block features[0];
1183607ca46eSDavid Howells };
1184607ca46eSDavid Howells 
1185607ca46eSDavid Howells /**
1186607ca46eSDavid Howells  * struct ethtool_ts_info - holds a device's timestamping and PHC association
1187607ca46eSDavid Howells  * @cmd: command number = %ETHTOOL_GET_TS_INFO
1188607ca46eSDavid Howells  * @so_timestamping: bit mask of the sum of the supported SO_TIMESTAMPING flags
1189607ca46eSDavid Howells  * @phc_index: device index of the associated PHC, or -1 if there is none
1190607ca46eSDavid Howells  * @tx_types: bit mask of the supported hwtstamp_tx_types enumeration values
1191607ca46eSDavid Howells  * @rx_filters: bit mask of the supported hwtstamp_rx_filters enumeration values
1192607ca46eSDavid Howells  *
1193607ca46eSDavid Howells  * The bits in the 'tx_types' and 'rx_filters' fields correspond to
1194607ca46eSDavid Howells  * the 'hwtstamp_tx_types' and 'hwtstamp_rx_filters' enumeration values,
1195607ca46eSDavid Howells  * respectively.  For example, if the device supports HWTSTAMP_TX_ON,
1196607ca46eSDavid Howells  * then (1 << HWTSTAMP_TX_ON) in 'tx_types' will be set.
1197eff3cddcSJacob Keller  *
1198eff3cddcSJacob Keller  * Drivers should only report the filters they actually support without
1199eff3cddcSJacob Keller  * upscaling in the SIOCSHWTSTAMP ioctl. If the SIOCSHWSTAMP request for
1200eff3cddcSJacob Keller  * HWTSTAMP_FILTER_V1_SYNC is supported by HWTSTAMP_FILTER_V1_EVENT, then the
1201eff3cddcSJacob Keller  * driver should only report HWTSTAMP_FILTER_V1_EVENT in this op.
1202607ca46eSDavid Howells  */
1203607ca46eSDavid Howells struct ethtool_ts_info {
1204607ca46eSDavid Howells 	__u32	cmd;
1205607ca46eSDavid Howells 	__u32	so_timestamping;
1206607ca46eSDavid Howells 	__s32	phc_index;
1207607ca46eSDavid Howells 	__u32	tx_types;
1208607ca46eSDavid Howells 	__u32	tx_reserved[3];
1209607ca46eSDavid Howells 	__u32	rx_filters;
1210607ca46eSDavid Howells 	__u32	rx_reserved[3];
1211607ca46eSDavid Howells };
1212607ca46eSDavid Howells 
1213607ca46eSDavid Howells /*
1214607ca46eSDavid Howells  * %ETHTOOL_SFEATURES changes features present in features[].valid to the
1215607ca46eSDavid Howells  * values of corresponding bits in features[].requested. Bits in .requested
1216607ca46eSDavid Howells  * not set in .valid or not changeable are ignored.
1217607ca46eSDavid Howells  *
1218607ca46eSDavid Howells  * Returns %EINVAL when .valid contains undefined or never-changeable bits
1219607ca46eSDavid Howells  * or size is not equal to required number of features words (32-bit blocks).
1220607ca46eSDavid Howells  * Returns >= 0 if request was completed; bits set in the value mean:
1221607ca46eSDavid Howells  *   %ETHTOOL_F_UNSUPPORTED - there were bits set in .valid that are not
1222607ca46eSDavid Howells  *	changeable (not present in %ETHTOOL_GFEATURES' features[].available)
1223607ca46eSDavid Howells  *	those bits were ignored.
1224607ca46eSDavid Howells  *   %ETHTOOL_F_WISH - some or all changes requested were recorded but the
1225607ca46eSDavid Howells  *      resulting state of bits masked by .valid is not equal to .requested.
1226607ca46eSDavid Howells  *      Probably there are other device-specific constraints on some features
1227607ca46eSDavid Howells  *      in the set. When %ETHTOOL_F_UNSUPPORTED is set, .valid is considered
1228607ca46eSDavid Howells  *      here as though ignored bits were cleared.
1229607ca46eSDavid Howells  *   %ETHTOOL_F_COMPAT - some or all changes requested were made by calling
1230607ca46eSDavid Howells  *      compatibility functions. Requested offload state cannot be properly
1231607ca46eSDavid Howells  *      managed by kernel.
1232607ca46eSDavid Howells  *
1233607ca46eSDavid Howells  * Meaning of bits in the masks are obtained by %ETHTOOL_GSSET_INFO (number of
1234607ca46eSDavid Howells  * bits in the arrays - always multiple of 32) and %ETHTOOL_GSTRINGS commands
1235607ca46eSDavid Howells  * for ETH_SS_FEATURES string set. First entry in the table corresponds to least
1236607ca46eSDavid Howells  * significant bit in features[0] fields. Empty strings mark undefined features.
1237607ca46eSDavid Howells  */
1238607ca46eSDavid Howells enum ethtool_sfeatures_retval_bits {
1239607ca46eSDavid Howells 	ETHTOOL_F_UNSUPPORTED__BIT,
1240607ca46eSDavid Howells 	ETHTOOL_F_WISH__BIT,
1241607ca46eSDavid Howells 	ETHTOOL_F_COMPAT__BIT,
1242607ca46eSDavid Howells };
1243607ca46eSDavid Howells 
1244607ca46eSDavid Howells #define ETHTOOL_F_UNSUPPORTED   (1 << ETHTOOL_F_UNSUPPORTED__BIT)
1245607ca46eSDavid Howells #define ETHTOOL_F_WISH          (1 << ETHTOOL_F_WISH__BIT)
1246607ca46eSDavid Howells #define ETHTOOL_F_COMPAT        (1 << ETHTOOL_F_COMPAT__BIT)
1247607ca46eSDavid Howells 
1248ac2c7ad0SKan Liang #define MAX_NUM_QUEUE		4096
1249ac2c7ad0SKan Liang 
1250ac2c7ad0SKan Liang /**
1251ac2c7ad0SKan Liang  * struct ethtool_per_queue_op - apply sub command to the queues in mask.
1252ac2c7ad0SKan Liang  * @cmd: ETHTOOL_PERQUEUE
1253ac2c7ad0SKan Liang  * @sub_command: the sub command which apply to each queues
1254ac2c7ad0SKan Liang  * @queue_mask: Bitmap of the queues which sub command apply to
1255ac2c7ad0SKan Liang  * @data: A complete command structure following for each of the queues addressed
1256ac2c7ad0SKan Liang  */
1257ac2c7ad0SKan Liang struct ethtool_per_queue_op {
1258ac2c7ad0SKan Liang 	__u32	cmd;
1259ac2c7ad0SKan Liang 	__u32	sub_command;
1260b5d3755aSNicolas Dichtel 	__u32	queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)];
1261ac2c7ad0SKan Liang 	char	data[];
1262ac2c7ad0SKan Liang };
1263607ca46eSDavid Howells 
12641a5f3da2SVidya Sagar Ravipati /**
12651a5f3da2SVidya Sagar Ravipati  * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters
12661a5f3da2SVidya Sagar Ravipati  * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM
12671a5f3da2SVidya Sagar Ravipati  * @active_fec: FEC mode which is active on porte
12681a5f3da2SVidya Sagar Ravipati  * @fec: Bitmask of supported/configured FEC modes
12691a5f3da2SVidya Sagar Ravipati  * @rsvd: Reserved for future extensions. i.e FEC bypass feature.
12701a5f3da2SVidya Sagar Ravipati  *
12711a5f3da2SVidya Sagar Ravipati  * Drivers should reject a non-zero setting of @autoneg when
12721a5f3da2SVidya Sagar Ravipati  * autoneogotiation is disabled (or not supported) for the link.
12731a5f3da2SVidya Sagar Ravipati  *
12741a5f3da2SVidya Sagar Ravipati  */
12751a5f3da2SVidya Sagar Ravipati struct ethtool_fecparam {
12761a5f3da2SVidya Sagar Ravipati 	__u32   cmd;
12771a5f3da2SVidya Sagar Ravipati 	/* bitmask of FEC modes */
12781a5f3da2SVidya Sagar Ravipati 	__u32   active_fec;
12791a5f3da2SVidya Sagar Ravipati 	__u32   fec;
12801a5f3da2SVidya Sagar Ravipati 	__u32   reserved;
12811a5f3da2SVidya Sagar Ravipati };
12821a5f3da2SVidya Sagar Ravipati 
12831a5f3da2SVidya Sagar Ravipati /**
12841a5f3da2SVidya Sagar Ravipati  * enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration
12851a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_NONE: FEC mode configuration is not supported
12861a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_AUTO: Default/Best FEC mode provided by driver
12871a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_OFF: No FEC Mode
12881a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_RS: Reed-Solomon Forward Error Detection mode
12891a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon Forward Error Detection mode
12901a5f3da2SVidya Sagar Ravipati  */
12911a5f3da2SVidya Sagar Ravipati enum ethtool_fec_config_bits {
12921a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_NONE_BIT,
12931a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_AUTO_BIT,
12941a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_OFF_BIT,
12951a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_RS_BIT,
12961a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_BASER_BIT,
12971a5f3da2SVidya Sagar Ravipati };
12981a5f3da2SVidya Sagar Ravipati 
12991a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_NONE		(1 << ETHTOOL_FEC_NONE_BIT)
13001a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_AUTO		(1 << ETHTOOL_FEC_AUTO_BIT)
13011a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_OFF			(1 << ETHTOOL_FEC_OFF_BIT)
13021a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_RS			(1 << ETHTOOL_FEC_RS_BIT)
13031a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_BASER		(1 << ETHTOOL_FEC_BASER_BIT)
13041a5f3da2SVidya Sagar Ravipati 
1305607ca46eSDavid Howells /* CMDs currently supported */
13063f1ac7a7SDavid Decotigny #define ETHTOOL_GSET		0x00000001 /* DEPRECATED, Get settings.
13073f1ac7a7SDavid Decotigny 					    * Please use ETHTOOL_GLINKSETTINGS
13083f1ac7a7SDavid Decotigny 					    */
13093f1ac7a7SDavid Decotigny #define ETHTOOL_SSET		0x00000002 /* DEPRECATED, Set settings.
13103f1ac7a7SDavid Decotigny 					    * Please use ETHTOOL_SLINKSETTINGS
13113f1ac7a7SDavid Decotigny 					    */
1312607ca46eSDavid Howells #define ETHTOOL_GDRVINFO	0x00000003 /* Get driver info. */
1313607ca46eSDavid Howells #define ETHTOOL_GREGS		0x00000004 /* Get NIC registers. */
1314607ca46eSDavid Howells #define ETHTOOL_GWOL		0x00000005 /* Get wake-on-lan options. */
1315607ca46eSDavid Howells #define ETHTOOL_SWOL		0x00000006 /* Set wake-on-lan options. */
1316607ca46eSDavid Howells #define ETHTOOL_GMSGLVL		0x00000007 /* Get driver message level */
1317607ca46eSDavid Howells #define ETHTOOL_SMSGLVL		0x00000008 /* Set driver msg level. */
1318607ca46eSDavid Howells #define ETHTOOL_NWAY_RST	0x00000009 /* Restart autonegotiation. */
1319607ca46eSDavid Howells /* Get link status for host, i.e. whether the interface *and* the
1320607ca46eSDavid Howells  * physical port (if there is one) are up (ethtool_value). */
1321607ca46eSDavid Howells #define ETHTOOL_GLINK		0x0000000a
1322607ca46eSDavid Howells #define ETHTOOL_GEEPROM		0x0000000b /* Get EEPROM data */
1323607ca46eSDavid Howells #define ETHTOOL_SEEPROM		0x0000000c /* Set EEPROM data. */
1324607ca46eSDavid Howells #define ETHTOOL_GCOALESCE	0x0000000e /* Get coalesce config */
1325607ca46eSDavid Howells #define ETHTOOL_SCOALESCE	0x0000000f /* Set coalesce config. */
1326607ca46eSDavid Howells #define ETHTOOL_GRINGPARAM	0x00000010 /* Get ring parameters */
1327607ca46eSDavid Howells #define ETHTOOL_SRINGPARAM	0x00000011 /* Set ring parameters. */
1328607ca46eSDavid Howells #define ETHTOOL_GPAUSEPARAM	0x00000012 /* Get pause parameters */
1329607ca46eSDavid Howells #define ETHTOOL_SPAUSEPARAM	0x00000013 /* Set pause parameters. */
1330607ca46eSDavid Howells #define ETHTOOL_GRXCSUM		0x00000014 /* Get RX hw csum enable (ethtool_value) */
1331607ca46eSDavid Howells #define ETHTOOL_SRXCSUM		0x00000015 /* Set RX hw csum enable (ethtool_value) */
1332607ca46eSDavid Howells #define ETHTOOL_GTXCSUM		0x00000016 /* Get TX hw csum enable (ethtool_value) */
1333607ca46eSDavid Howells #define ETHTOOL_STXCSUM		0x00000017 /* Set TX hw csum enable (ethtool_value) */
1334607ca46eSDavid Howells #define ETHTOOL_GSG		0x00000018 /* Get scatter-gather enable
1335607ca46eSDavid Howells 					    * (ethtool_value) */
1336607ca46eSDavid Howells #define ETHTOOL_SSG		0x00000019 /* Set scatter-gather enable
1337607ca46eSDavid Howells 					    * (ethtool_value). */
1338607ca46eSDavid Howells #define ETHTOOL_TEST		0x0000001a /* execute NIC self-test. */
1339607ca46eSDavid Howells #define ETHTOOL_GSTRINGS	0x0000001b /* get specified string set */
1340607ca46eSDavid Howells #define ETHTOOL_PHYS_ID		0x0000001c /* identify the NIC */
1341607ca46eSDavid Howells #define ETHTOOL_GSTATS		0x0000001d /* get NIC-specific statistics */
1342607ca46eSDavid Howells #define ETHTOOL_GTSO		0x0000001e /* Get TSO enable (ethtool_value) */
1343607ca46eSDavid Howells #define ETHTOOL_STSO		0x0000001f /* Set TSO enable (ethtool_value) */
1344607ca46eSDavid Howells #define ETHTOOL_GPERMADDR	0x00000020 /* Get permanent hardware address */
1345607ca46eSDavid Howells #define ETHTOOL_GUFO		0x00000021 /* Get UFO enable (ethtool_value) */
1346607ca46eSDavid Howells #define ETHTOOL_SUFO		0x00000022 /* Set UFO enable (ethtool_value) */
1347607ca46eSDavid Howells #define ETHTOOL_GGSO		0x00000023 /* Get GSO enable (ethtool_value) */
1348607ca46eSDavid Howells #define ETHTOOL_SGSO		0x00000024 /* Set GSO enable (ethtool_value) */
1349607ca46eSDavid Howells #define ETHTOOL_GFLAGS		0x00000025 /* Get flags bitmap(ethtool_value) */
1350607ca46eSDavid Howells #define ETHTOOL_SFLAGS		0x00000026 /* Set flags bitmap(ethtool_value) */
1351607ca46eSDavid Howells #define ETHTOOL_GPFLAGS		0x00000027 /* Get driver-private flags bitmap */
1352607ca46eSDavid Howells #define ETHTOOL_SPFLAGS		0x00000028 /* Set driver-private flags bitmap */
1353607ca46eSDavid Howells 
1354607ca46eSDavid Howells #define ETHTOOL_GRXFH		0x00000029 /* Get RX flow hash configuration */
1355607ca46eSDavid Howells #define ETHTOOL_SRXFH		0x0000002a /* Set RX flow hash configuration */
1356607ca46eSDavid Howells #define ETHTOOL_GGRO		0x0000002b /* Get GRO enable (ethtool_value) */
1357607ca46eSDavid Howells #define ETHTOOL_SGRO		0x0000002c /* Set GRO enable (ethtool_value) */
1358607ca46eSDavid Howells #define ETHTOOL_GRXRINGS	0x0000002d /* Get RX rings available for LB */
1359607ca46eSDavid Howells #define ETHTOOL_GRXCLSRLCNT	0x0000002e /* Get RX class rule count */
1360607ca46eSDavid Howells #define ETHTOOL_GRXCLSRULE	0x0000002f /* Get RX classification rule */
1361607ca46eSDavid Howells #define ETHTOOL_GRXCLSRLALL	0x00000030 /* Get all RX classification rule */
1362607ca46eSDavid Howells #define ETHTOOL_SRXCLSRLDEL	0x00000031 /* Delete RX classification rule */
1363607ca46eSDavid Howells #define ETHTOOL_SRXCLSRLINS	0x00000032 /* Insert RX classification rule */
1364607ca46eSDavid Howells #define ETHTOOL_FLASHDEV	0x00000033 /* Flash firmware to device */
1365607ca46eSDavid Howells #define ETHTOOL_RESET		0x00000034 /* Reset hardware */
1366607ca46eSDavid Howells #define ETHTOOL_SRXNTUPLE	0x00000035 /* Add an n-tuple filter to device */
1367607ca46eSDavid Howells #define ETHTOOL_GRXNTUPLE	0x00000036 /* deprecated */
1368607ca46eSDavid Howells #define ETHTOOL_GSSET_INFO	0x00000037 /* Get string set info */
1369607ca46eSDavid Howells #define ETHTOOL_GRXFHINDIR	0x00000038 /* Get RX flow hash indir'n table */
1370607ca46eSDavid Howells #define ETHTOOL_SRXFHINDIR	0x00000039 /* Set RX flow hash indir'n table */
1371607ca46eSDavid Howells 
1372607ca46eSDavid Howells #define ETHTOOL_GFEATURES	0x0000003a /* Get device offload settings */
1373607ca46eSDavid Howells #define ETHTOOL_SFEATURES	0x0000003b /* Change device offload settings */
1374607ca46eSDavid Howells #define ETHTOOL_GCHANNELS	0x0000003c /* Get no of channels */
1375607ca46eSDavid Howells #define ETHTOOL_SCHANNELS	0x0000003d /* Set no of channels */
1376607ca46eSDavid Howells #define ETHTOOL_SET_DUMP	0x0000003e /* Set dump settings */
1377607ca46eSDavid Howells #define ETHTOOL_GET_DUMP_FLAG	0x0000003f /* Get dump settings */
1378607ca46eSDavid Howells #define ETHTOOL_GET_DUMP_DATA	0x00000040 /* Get dump data */
1379607ca46eSDavid Howells #define ETHTOOL_GET_TS_INFO	0x00000041 /* Get time stamping and PHC info */
1380607ca46eSDavid Howells #define ETHTOOL_GMODULEINFO	0x00000042 /* Get plug-in module information */
1381607ca46eSDavid Howells #define ETHTOOL_GMODULEEEPROM	0x00000043 /* Get plug-in module eeprom */
1382607ca46eSDavid Howells #define ETHTOOL_GEEE		0x00000044 /* Get EEE settings */
1383607ca46eSDavid Howells #define ETHTOOL_SEEE		0x00000045 /* Set EEE settings */
1384607ca46eSDavid Howells 
13853de0b592SVenkata Duvvuru #define ETHTOOL_GRSSH		0x00000046 /* Get RX flow hash configuration */
13863de0b592SVenkata Duvvuru #define ETHTOOL_SRSSH		0x00000047 /* Set RX flow hash configuration */
1387f0db9b07SGovindarajulu Varadarajan #define ETHTOOL_GTUNABLE	0x00000048 /* Get tunable configuration */
1388f0db9b07SGovindarajulu Varadarajan #define ETHTOOL_STUNABLE	0x00000049 /* Set tunable configuration */
1389f3a40945SAndrew Lunn #define ETHTOOL_GPHYSTATS	0x0000004a /* get PHY-specific statistics */
13903de0b592SVenkata Duvvuru 
1391ac2c7ad0SKan Liang #define ETHTOOL_PERQUEUE	0x0000004b /* Set per queue options */
1392ac2c7ad0SKan Liang 
13933f1ac7a7SDavid Decotigny #define ETHTOOL_GLINKSETTINGS	0x0000004c /* Get ethtool_link_settings */
13943f1ac7a7SDavid Decotigny #define ETHTOOL_SLINKSETTINGS	0x0000004d /* Set ethtool_link_settings */
13950d27f4e4SRaju Lakkaraju #define ETHTOOL_PHY_GTUNABLE	0x0000004e /* Get PHY tunable configuration */
13960d27f4e4SRaju Lakkaraju #define ETHTOOL_PHY_STUNABLE	0x0000004f /* Set PHY tunable configuration */
13971a5f3da2SVidya Sagar Ravipati #define ETHTOOL_GFECPARAM	0x00000050 /* Get FEC settings */
13981a5f3da2SVidya Sagar Ravipati #define ETHTOOL_SFECPARAM	0x00000051 /* Set FEC settings */
13993f1ac7a7SDavid Decotigny 
1400607ca46eSDavid Howells /* compatibility with older code */
1401607ca46eSDavid Howells #define SPARC_ETH_GSET		ETHTOOL_GSET
1402607ca46eSDavid Howells #define SPARC_ETH_SSET		ETHTOOL_SSET
1403607ca46eSDavid Howells 
14043f1ac7a7SDavid Decotigny /* Link mode bit indices */
14053f1ac7a7SDavid Decotigny enum ethtool_link_mode_bit_indices {
14063f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10baseT_Half_BIT	= 0,
14073f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10baseT_Full_BIT	= 1,
14083f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_100baseT_Half_BIT	= 2,
14093f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_100baseT_Full_BIT	= 3,
14103f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_1000baseT_Half_BIT	= 4,
14113f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_1000baseT_Full_BIT	= 5,
14123f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_Autoneg_BIT		= 6,
14133f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_TP_BIT		= 7,
14143f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_AUI_BIT		= 8,
14153f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_MII_BIT		= 9,
14163f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_FIBRE_BIT		= 10,
14173f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_BNC_BIT		= 11,
14183f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10000baseT_Full_BIT	= 12,
14193f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_Pause_BIT		= 13,
14203f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_Asym_Pause_BIT	= 14,
14213f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_2500baseX_Full_BIT	= 15,
14223f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_Backplane_BIT		= 16,
14233f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_1000baseKX_Full_BIT	= 17,
14243f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT	= 18,
14253f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10000baseKR_Full_BIT	= 19,
14263f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10000baseR_FEC_BIT	= 20,
14273f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT = 21,
14283f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT	= 22,
14293f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT	= 23,
14303f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT	= 24,
14313f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT	= 25,
14323f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT	= 26,
14333f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT	= 27,
14343f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT	= 28,
14353f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT	= 29,
14363f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT	= 30,
14373851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_25000baseCR_Full_BIT	= 31,
14383851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_25000baseKR_Full_BIT	= 32,
14393851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_25000baseSR_Full_BIT	= 33,
14403851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT	= 34,
14413851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT	= 35,
14423851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT	= 36,
14433851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT	= 37,
14443851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT	= 38,
14453851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT	= 39,
144689da45b8SGal Pressman 	ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT		= 40,
14475711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_1000baseX_Full_BIT	= 41,
14485711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseCR_Full_BIT	= 42,
14495711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseSR_Full_BIT	= 43,
14505711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseLR_Full_BIT	= 44,
14515711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT	= 45,
14525711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseER_Full_BIT	= 46,
145394842b4fSPavel Belous 	ETHTOOL_LINK_MODE_2500baseT_Full_BIT	= 47,
145494842b4fSPavel Belous 	ETHTOOL_LINK_MODE_5000baseT_Full_BIT	= 48,
14555711a982SVidya Sagar Ravipati 
14561a5f3da2SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_FEC_NONE_BIT	= 49,
14571a5f3da2SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_FEC_RS_BIT	= 50,
14581a5f3da2SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_FEC_BASER_BIT	= 51,
1459607ca46eSDavid Howells 
14603f1ac7a7SDavid Decotigny 	/* Last allowed bit for __ETHTOOL_LINK_MODE_LEGACY_MASK is bit
14613f1ac7a7SDavid Decotigny 	 * 31. Please do NOT define any SUPPORTED_* or ADVERTISED_*
14623f1ac7a7SDavid Decotigny 	 * macro for bits > 31. The only way to use indices > 31 is to
14633f1ac7a7SDavid Decotigny 	 * use the new ETHTOOL_GLINKSETTINGS/ETHTOOL_SLINKSETTINGS API.
14643f1ac7a7SDavid Decotigny 	 */
14653f1ac7a7SDavid Decotigny 
14663f1ac7a7SDavid Decotigny 	__ETHTOOL_LINK_MODE_LAST
14671a5f3da2SVidya Sagar Ravipati 	  = ETHTOOL_LINK_MODE_FEC_BASER_BIT,
14683f1ac7a7SDavid Decotigny };
14693f1ac7a7SDavid Decotigny 
14703f1ac7a7SDavid Decotigny #define __ETHTOOL_LINK_MODE_LEGACY_MASK(base_name)	\
14713f1ac7a7SDavid Decotigny 	(1UL << (ETHTOOL_LINK_MODE_ ## base_name ## _BIT))
14723f1ac7a7SDavid Decotigny 
14733f1ac7a7SDavid Decotigny /* DEPRECATED macros. Please migrate to
14743f1ac7a7SDavid Decotigny  * ETHTOOL_GLINKSETTINGS/ETHTOOL_SLINKSETTINGS API. Please do NOT
14753f1ac7a7SDavid Decotigny  * define any new SUPPORTED_* macro for bits > 31.
14763f1ac7a7SDavid Decotigny  */
14773f1ac7a7SDavid Decotigny #define SUPPORTED_10baseT_Half		__ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Half)
14783f1ac7a7SDavid Decotigny #define SUPPORTED_10baseT_Full		__ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Full)
14793f1ac7a7SDavid Decotigny #define SUPPORTED_100baseT_Half		__ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Half)
14803f1ac7a7SDavid Decotigny #define SUPPORTED_100baseT_Full		__ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Full)
14813f1ac7a7SDavid Decotigny #define SUPPORTED_1000baseT_Half	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Half)
14823f1ac7a7SDavid Decotigny #define SUPPORTED_1000baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Full)
14833f1ac7a7SDavid Decotigny #define SUPPORTED_Autoneg		__ETHTOOL_LINK_MODE_LEGACY_MASK(Autoneg)
14843f1ac7a7SDavid Decotigny #define SUPPORTED_TP			__ETHTOOL_LINK_MODE_LEGACY_MASK(TP)
14853f1ac7a7SDavid Decotigny #define SUPPORTED_AUI			__ETHTOOL_LINK_MODE_LEGACY_MASK(AUI)
14863f1ac7a7SDavid Decotigny #define SUPPORTED_MII			__ETHTOOL_LINK_MODE_LEGACY_MASK(MII)
14873f1ac7a7SDavid Decotigny #define SUPPORTED_FIBRE			__ETHTOOL_LINK_MODE_LEGACY_MASK(FIBRE)
14883f1ac7a7SDavid Decotigny #define SUPPORTED_BNC			__ETHTOOL_LINK_MODE_LEGACY_MASK(BNC)
14893f1ac7a7SDavid Decotigny #define SUPPORTED_10000baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseT_Full)
14903f1ac7a7SDavid Decotigny #define SUPPORTED_Pause			__ETHTOOL_LINK_MODE_LEGACY_MASK(Pause)
14913f1ac7a7SDavid Decotigny #define SUPPORTED_Asym_Pause		__ETHTOOL_LINK_MODE_LEGACY_MASK(Asym_Pause)
14923f1ac7a7SDavid Decotigny #define SUPPORTED_2500baseX_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(2500baseX_Full)
14933f1ac7a7SDavid Decotigny #define SUPPORTED_Backplane		__ETHTOOL_LINK_MODE_LEGACY_MASK(Backplane)
14943f1ac7a7SDavid Decotigny #define SUPPORTED_1000baseKX_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseKX_Full)
14953f1ac7a7SDavid Decotigny #define SUPPORTED_10000baseKX4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKX4_Full)
14963f1ac7a7SDavid Decotigny #define SUPPORTED_10000baseKR_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKR_Full)
14973f1ac7a7SDavid Decotigny #define SUPPORTED_10000baseR_FEC	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseR_FEC)
14983f1ac7a7SDavid Decotigny #define SUPPORTED_20000baseMLD2_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseMLD2_Full)
14993f1ac7a7SDavid Decotigny #define SUPPORTED_20000baseKR2_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseKR2_Full)
15003f1ac7a7SDavid Decotigny #define SUPPORTED_40000baseKR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseKR4_Full)
15013f1ac7a7SDavid Decotigny #define SUPPORTED_40000baseCR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseCR4_Full)
15023f1ac7a7SDavid Decotigny #define SUPPORTED_40000baseSR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseSR4_Full)
15033f1ac7a7SDavid Decotigny #define SUPPORTED_40000baseLR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseLR4_Full)
15043f1ac7a7SDavid Decotigny #define SUPPORTED_56000baseKR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseKR4_Full)
15053f1ac7a7SDavid Decotigny #define SUPPORTED_56000baseCR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseCR4_Full)
15063f1ac7a7SDavid Decotigny #define SUPPORTED_56000baseSR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseSR4_Full)
15073f1ac7a7SDavid Decotigny #define SUPPORTED_56000baseLR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseLR4_Full)
15083f1ac7a7SDavid Decotigny /* Please do not define any new SUPPORTED_* macro for bits > 31, see
15093f1ac7a7SDavid Decotigny  * notice above.
15103f1ac7a7SDavid Decotigny  */
15113f1ac7a7SDavid Decotigny 
15123f1ac7a7SDavid Decotigny /*
15133f1ac7a7SDavid Decotigny  * DEPRECATED macros. Please migrate to
15143f1ac7a7SDavid Decotigny  * ETHTOOL_GLINKSETTINGS/ETHTOOL_SLINKSETTINGS API. Please do NOT
15153f1ac7a7SDavid Decotigny  * define any new ADERTISE_* macro for bits > 31.
15163f1ac7a7SDavid Decotigny  */
15173f1ac7a7SDavid Decotigny #define ADVERTISED_10baseT_Half		__ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Half)
15183f1ac7a7SDavid Decotigny #define ADVERTISED_10baseT_Full		__ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Full)
15193f1ac7a7SDavid Decotigny #define ADVERTISED_100baseT_Half	__ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Half)
15203f1ac7a7SDavid Decotigny #define ADVERTISED_100baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Full)
15213f1ac7a7SDavid Decotigny #define ADVERTISED_1000baseT_Half	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Half)
15223f1ac7a7SDavid Decotigny #define ADVERTISED_1000baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Full)
15233f1ac7a7SDavid Decotigny #define ADVERTISED_Autoneg		__ETHTOOL_LINK_MODE_LEGACY_MASK(Autoneg)
15243f1ac7a7SDavid Decotigny #define ADVERTISED_TP			__ETHTOOL_LINK_MODE_LEGACY_MASK(TP)
15253f1ac7a7SDavid Decotigny #define ADVERTISED_AUI			__ETHTOOL_LINK_MODE_LEGACY_MASK(AUI)
15263f1ac7a7SDavid Decotigny #define ADVERTISED_MII			__ETHTOOL_LINK_MODE_LEGACY_MASK(MII)
15273f1ac7a7SDavid Decotigny #define ADVERTISED_FIBRE		__ETHTOOL_LINK_MODE_LEGACY_MASK(FIBRE)
15283f1ac7a7SDavid Decotigny #define ADVERTISED_BNC			__ETHTOOL_LINK_MODE_LEGACY_MASK(BNC)
15293f1ac7a7SDavid Decotigny #define ADVERTISED_10000baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseT_Full)
15303f1ac7a7SDavid Decotigny #define ADVERTISED_Pause		__ETHTOOL_LINK_MODE_LEGACY_MASK(Pause)
15313f1ac7a7SDavid Decotigny #define ADVERTISED_Asym_Pause		__ETHTOOL_LINK_MODE_LEGACY_MASK(Asym_Pause)
15323f1ac7a7SDavid Decotigny #define ADVERTISED_2500baseX_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(2500baseX_Full)
15333f1ac7a7SDavid Decotigny #define ADVERTISED_Backplane		__ETHTOOL_LINK_MODE_LEGACY_MASK(Backplane)
15343f1ac7a7SDavid Decotigny #define ADVERTISED_1000baseKX_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseKX_Full)
15353f1ac7a7SDavid Decotigny #define ADVERTISED_10000baseKX4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKX4_Full)
15363f1ac7a7SDavid Decotigny #define ADVERTISED_10000baseKR_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKR_Full)
15373f1ac7a7SDavid Decotigny #define ADVERTISED_10000baseR_FEC	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseR_FEC)
15383f1ac7a7SDavid Decotigny #define ADVERTISED_20000baseMLD2_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseMLD2_Full)
15393f1ac7a7SDavid Decotigny #define ADVERTISED_20000baseKR2_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseKR2_Full)
15403f1ac7a7SDavid Decotigny #define ADVERTISED_40000baseKR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseKR4_Full)
15413f1ac7a7SDavid Decotigny #define ADVERTISED_40000baseCR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseCR4_Full)
15423f1ac7a7SDavid Decotigny #define ADVERTISED_40000baseSR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseSR4_Full)
15433f1ac7a7SDavid Decotigny #define ADVERTISED_40000baseLR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseLR4_Full)
15443f1ac7a7SDavid Decotigny #define ADVERTISED_56000baseKR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseKR4_Full)
15453f1ac7a7SDavid Decotigny #define ADVERTISED_56000baseCR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseCR4_Full)
15463f1ac7a7SDavid Decotigny #define ADVERTISED_56000baseSR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseSR4_Full)
15473f1ac7a7SDavid Decotigny #define ADVERTISED_56000baseLR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseLR4_Full)
15483f1ac7a7SDavid Decotigny /* Please do not define any new ADVERTISED_* macro for bits > 31, see
15493f1ac7a7SDavid Decotigny  * notice above.
15503f1ac7a7SDavid Decotigny  */
1551607ca46eSDavid Howells 
1552607ca46eSDavid Howells /* The following are all involved in forcing a particular link
1553607ca46eSDavid Howells  * mode for the device for setting things.  When getting the
1554607ca46eSDavid Howells  * devices settings, these indicate the current mode and whether
1555607ca46eSDavid Howells  * it was forced up into this mode or autonegotiated.
1556607ca46eSDavid Howells  */
1557607ca46eSDavid Howells 
1558297fb414SNicolas Dichtel /* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal.
1559297fb414SNicolas Dichtel  * Update drivers/net/phy/phy.c:phy_speed_to_str() and
1560297fb414SNicolas Dichtel  * drivers/net/bonding/bond_3ad.c:__get_link_speed() when adding new values.
1561297fb414SNicolas Dichtel  */
1562607ca46eSDavid Howells #define SPEED_10		10
1563607ca46eSDavid Howells #define SPEED_100		100
1564607ca46eSDavid Howells #define SPEED_1000		1000
1565607ca46eSDavid Howells #define SPEED_2500		2500
1566c9a70d43SParav Pandit #define SPEED_5000		5000
1567607ca46eSDavid Howells #define SPEED_10000		10000
15680d7e2d21SZhu Yanjun #define SPEED_14000		14000
1569dcf972a3SSaeed Mahameed #define SPEED_20000		20000
1570c9a70d43SParav Pandit #define SPEED_25000		25000
1571dcf972a3SSaeed Mahameed #define SPEED_40000		40000
1572c9a70d43SParav Pandit #define SPEED_50000		50000
1573dcf972a3SSaeed Mahameed #define SPEED_56000		56000
1574c9a70d43SParav Pandit #define SPEED_100000		100000
1575dcf972a3SSaeed Mahameed 
1576607ca46eSDavid Howells #define SPEED_UNKNOWN		-1
1577607ca46eSDavid Howells 
1578103a8ad1SNikolay Aleksandrov static inline int ethtool_validate_speed(__u32 speed)
1579103a8ad1SNikolay Aleksandrov {
1580e02564eeSNikolay Aleksandrov 	return speed <= INT_MAX || speed == SPEED_UNKNOWN;
1581103a8ad1SNikolay Aleksandrov }
1582103a8ad1SNikolay Aleksandrov 
1583607ca46eSDavid Howells /* Duplex, half or full. */
1584607ca46eSDavid Howells #define DUPLEX_HALF		0x00
1585607ca46eSDavid Howells #define DUPLEX_FULL		0x01
1586607ca46eSDavid Howells #define DUPLEX_UNKNOWN		0xff
1587607ca46eSDavid Howells 
1588103a8ad1SNikolay Aleksandrov static inline int ethtool_validate_duplex(__u8 duplex)
1589103a8ad1SNikolay Aleksandrov {
1590103a8ad1SNikolay Aleksandrov 	switch (duplex) {
1591103a8ad1SNikolay Aleksandrov 	case DUPLEX_HALF:
1592103a8ad1SNikolay Aleksandrov 	case DUPLEX_FULL:
1593103a8ad1SNikolay Aleksandrov 	case DUPLEX_UNKNOWN:
1594103a8ad1SNikolay Aleksandrov 		return 1;
1595103a8ad1SNikolay Aleksandrov 	}
1596103a8ad1SNikolay Aleksandrov 
1597103a8ad1SNikolay Aleksandrov 	return 0;
1598103a8ad1SNikolay Aleksandrov }
1599103a8ad1SNikolay Aleksandrov 
1600607ca46eSDavid Howells /* Which connector port. */
1601607ca46eSDavid Howells #define PORT_TP			0x00
1602607ca46eSDavid Howells #define PORT_AUI		0x01
1603607ca46eSDavid Howells #define PORT_MII		0x02
1604607ca46eSDavid Howells #define PORT_FIBRE		0x03
1605607ca46eSDavid Howells #define PORT_BNC		0x04
1606607ca46eSDavid Howells #define PORT_DA			0x05
1607607ca46eSDavid Howells #define PORT_NONE		0xef
1608607ca46eSDavid Howells #define PORT_OTHER		0xff
1609607ca46eSDavid Howells 
1610607ca46eSDavid Howells /* Which transceiver to use. */
16117ec87211SFlorian Fainelli #define XCVR_INTERNAL		0x00 /* PHY and MAC are in the same package */
16127ec87211SFlorian Fainelli #define XCVR_EXTERNAL		0x01 /* PHY and MAC are in different packages */
1613607ca46eSDavid Howells #define XCVR_DUMMY1		0x02
1614607ca46eSDavid Howells #define XCVR_DUMMY2		0x03
1615607ca46eSDavid Howells #define XCVR_DUMMY3		0x04
1616607ca46eSDavid Howells 
1617bf8fc60aSBen Hutchings /* Enable or disable autonegotiation. */
1618607ca46eSDavid Howells #define AUTONEG_DISABLE		0x00
1619607ca46eSDavid Howells #define AUTONEG_ENABLE		0x01
1620607ca46eSDavid Howells 
1621607ca46eSDavid Howells /* MDI or MDI-X status/control - if MDI/MDI_X/AUTO is set then
1622607ca46eSDavid Howells  * the driver is required to renegotiate link
1623607ca46eSDavid Howells  */
1624607ca46eSDavid Howells #define ETH_TP_MDI_INVALID	0x00 /* status: unknown; control: unsupported */
1625607ca46eSDavid Howells #define ETH_TP_MDI		0x01 /* status: MDI;     control: force MDI */
1626607ca46eSDavid Howells #define ETH_TP_MDI_X		0x02 /* status: MDI-X;   control: force MDI-X */
1627607ca46eSDavid Howells #define ETH_TP_MDI_AUTO		0x03 /*                  control: auto-select */
1628607ca46eSDavid Howells 
1629607ca46eSDavid Howells /* Wake-On-Lan options. */
1630607ca46eSDavid Howells #define WAKE_PHY		(1 << 0)
1631607ca46eSDavid Howells #define WAKE_UCAST		(1 << 1)
1632607ca46eSDavid Howells #define WAKE_MCAST		(1 << 2)
1633607ca46eSDavid Howells #define WAKE_BCAST		(1 << 3)
1634607ca46eSDavid Howells #define WAKE_ARP		(1 << 4)
1635607ca46eSDavid Howells #define WAKE_MAGIC		(1 << 5)
1636607ca46eSDavid Howells #define WAKE_MAGICSECURE	(1 << 6) /* only meaningful if WAKE_MAGIC */
1637607ca46eSDavid Howells 
1638607ca46eSDavid Howells /* L2-L4 network traffic flow types */
1639607ca46eSDavid Howells #define	TCP_V4_FLOW	0x01	/* hash or spec (tcp_ip4_spec) */
1640607ca46eSDavid Howells #define	UDP_V4_FLOW	0x02	/* hash or spec (udp_ip4_spec) */
1641607ca46eSDavid Howells #define	SCTP_V4_FLOW	0x03	/* hash or spec (sctp_ip4_spec) */
1642607ca46eSDavid Howells #define	AH_ESP_V4_FLOW	0x04	/* hash only */
164372bb6872SEdward Cree #define	TCP_V6_FLOW	0x05	/* hash or spec (tcp_ip6_spec; nfc only) */
164472bb6872SEdward Cree #define	UDP_V6_FLOW	0x06	/* hash or spec (udp_ip6_spec; nfc only) */
164572bb6872SEdward Cree #define	SCTP_V6_FLOW	0x07	/* hash or spec (sctp_ip6_spec; nfc only) */
1646607ca46eSDavid Howells #define	AH_ESP_V6_FLOW	0x08	/* hash only */
1647607ca46eSDavid Howells #define	AH_V4_FLOW	0x09	/* hash or spec (ah_ip4_spec) */
1648607ca46eSDavid Howells #define	ESP_V4_FLOW	0x0a	/* hash or spec (esp_ip4_spec) */
164972bb6872SEdward Cree #define	AH_V6_FLOW	0x0b	/* hash or spec (ah_ip6_spec; nfc only) */
165072bb6872SEdward Cree #define	ESP_V6_FLOW	0x0c	/* hash or spec (esp_ip6_spec; nfc only) */
165172bb6872SEdward Cree #define	IPV4_USER_FLOW	0x0d	/* spec only (usr_ip4_spec) */
165272bb6872SEdward Cree #define	IP_USER_FLOW	IPV4_USER_FLOW
165372bb6872SEdward Cree #define	IPV6_USER_FLOW	0x0e	/* spec only (usr_ip6_spec; nfc only) */
1654607ca46eSDavid Howells #define	IPV4_FLOW	0x10	/* hash only */
1655607ca46eSDavid Howells #define	IPV6_FLOW	0x11	/* hash only */
1656607ca46eSDavid Howells #define	ETHER_FLOW	0x12	/* spec only (ether_spec) */
1657607ca46eSDavid Howells /* Flag to enable additional fields in struct ethtool_rx_flow_spec */
1658607ca46eSDavid Howells #define	FLOW_EXT	0x80000000
1659d4676eacSYan Burman #define	FLOW_MAC_EXT	0x40000000
166084a1d9c4SEdward Cree /* Flag to enable RSS spreading of traffic matching rule (nfc only) */
166184a1d9c4SEdward Cree #define	FLOW_RSS	0x20000000
1662607ca46eSDavid Howells 
1663607ca46eSDavid Howells /* L3-L4 network traffic flow hash options */
1664607ca46eSDavid Howells #define	RXH_L2DA	(1 << 1)
1665607ca46eSDavid Howells #define	RXH_VLAN	(1 << 2)
1666607ca46eSDavid Howells #define	RXH_L3_PROTO	(1 << 3)
1667607ca46eSDavid Howells #define	RXH_IP_SRC	(1 << 4)
1668607ca46eSDavid Howells #define	RXH_IP_DST	(1 << 5)
1669607ca46eSDavid Howells #define	RXH_L4_B_0_1	(1 << 6) /* src port in case of TCP/UDP/SCTP */
1670607ca46eSDavid Howells #define	RXH_L4_B_2_3	(1 << 7) /* dst port in case of TCP/UDP/SCTP */
1671607ca46eSDavid Howells #define	RXH_DISCARD	(1 << 31)
1672607ca46eSDavid Howells 
1673607ca46eSDavid Howells #define	RX_CLS_FLOW_DISC	0xffffffffffffffffULL
1674607ca46eSDavid Howells 
1675607ca46eSDavid Howells /* Special RX classification rule insert location values */
1676607ca46eSDavid Howells #define RX_CLS_LOC_SPECIAL	0x80000000	/* flag */
1677607ca46eSDavid Howells #define RX_CLS_LOC_ANY		0xffffffff
1678607ca46eSDavid Howells #define RX_CLS_LOC_FIRST	0xfffffffe
1679607ca46eSDavid Howells #define RX_CLS_LOC_LAST		0xfffffffd
1680607ca46eSDavid Howells 
1681607ca46eSDavid Howells /* EEPROM Standards for plug in modules */
1682607ca46eSDavid Howells #define ETH_MODULE_SFF_8079		0x1
1683607ca46eSDavid Howells #define ETH_MODULE_SFF_8079_LEN		256
1684607ca46eSDavid Howells #define ETH_MODULE_SFF_8472		0x2
1685607ca46eSDavid Howells #define ETH_MODULE_SFF_8472_LEN		512
16867202da8bSSaeed Mahameed #define ETH_MODULE_SFF_8636		0x3
16877202da8bSSaeed Mahameed #define ETH_MODULE_SFF_8636_LEN		256
16887202da8bSSaeed Mahameed #define ETH_MODULE_SFF_8436		0x4
16897202da8bSSaeed Mahameed #define ETH_MODULE_SFF_8436_LEN		256
1690607ca46eSDavid Howells 
1691607ca46eSDavid Howells /* Reset flags */
1692607ca46eSDavid Howells /* The reset() operation must clear the flags for the components which
1693607ca46eSDavid Howells  * were actually reset.  On successful return, the flags indicate the
1694607ca46eSDavid Howells  * components which were not reset, either because they do not exist
1695607ca46eSDavid Howells  * in the hardware or because they cannot be reset independently.  The
1696607ca46eSDavid Howells  * driver must never reset any components that were not requested.
1697607ca46eSDavid Howells  */
1698607ca46eSDavid Howells enum ethtool_reset_flags {
1699607ca46eSDavid Howells 	/* These flags represent components dedicated to the interface
1700607ca46eSDavid Howells 	 * the command is addressed to.  Shift any flag left by
1701607ca46eSDavid Howells 	 * ETH_RESET_SHARED_SHIFT to reset a shared component of the
1702607ca46eSDavid Howells 	 * same type.
1703607ca46eSDavid Howells 	 */
1704607ca46eSDavid Howells 	ETH_RESET_MGMT		= 1 << 0,	/* Management processor */
1705607ca46eSDavid Howells 	ETH_RESET_IRQ		= 1 << 1,	/* Interrupt requester */
1706607ca46eSDavid Howells 	ETH_RESET_DMA		= 1 << 2,	/* DMA engine */
1707607ca46eSDavid Howells 	ETH_RESET_FILTER	= 1 << 3,	/* Filtering/flow direction */
1708607ca46eSDavid Howells 	ETH_RESET_OFFLOAD	= 1 << 4,	/* Protocol offload */
1709607ca46eSDavid Howells 	ETH_RESET_MAC		= 1 << 5,	/* Media access controller */
1710607ca46eSDavid Howells 	ETH_RESET_PHY		= 1 << 6,	/* Transceiver/PHY */
1711607ca46eSDavid Howells 	ETH_RESET_RAM		= 1 << 7,	/* RAM shared between
1712607ca46eSDavid Howells 						 * multiple components */
171340e44a1eSScott Branden 	ETH_RESET_AP		= 1 << 8,	/* Application processor */
1714607ca46eSDavid Howells 
1715607ca46eSDavid Howells 	ETH_RESET_DEDICATED	= 0x0000ffff,	/* All components dedicated to
1716607ca46eSDavid Howells 						 * this interface */
1717607ca46eSDavid Howells 	ETH_RESET_ALL		= 0xffffffff,	/* All components used by this
1718607ca46eSDavid Howells 						 * interface, even if shared */
1719607ca46eSDavid Howells };
1720607ca46eSDavid Howells #define ETH_RESET_SHARED_SHIFT	16
1721607ca46eSDavid Howells 
17223f1ac7a7SDavid Decotigny 
17233f1ac7a7SDavid Decotigny /**
17243f1ac7a7SDavid Decotigny  * struct ethtool_link_settings - link control and status
17253f1ac7a7SDavid Decotigny  *
17263f1ac7a7SDavid Decotigny  * IMPORTANT, Backward compatibility notice: When implementing new
17273f1ac7a7SDavid Decotigny  *	user-space tools, please first try %ETHTOOL_GLINKSETTINGS, and
17283f1ac7a7SDavid Decotigny  *	if it succeeds use %ETHTOOL_SLINKSETTINGS to change link
17293f1ac7a7SDavid Decotigny  *	settings; do not use %ETHTOOL_SSET if %ETHTOOL_GLINKSETTINGS
17303f1ac7a7SDavid Decotigny  *	succeeded: stick to %ETHTOOL_GLINKSETTINGS/%SLINKSETTINGS in
17313f1ac7a7SDavid Decotigny  *	that case.  Conversely, if %ETHTOOL_GLINKSETTINGS fails, use
17323f1ac7a7SDavid Decotigny  *	%ETHTOOL_GSET to query and %ETHTOOL_SSET to change link
17333f1ac7a7SDavid Decotigny  *	settings; do not use %ETHTOOL_SLINKSETTINGS if
17343f1ac7a7SDavid Decotigny  *	%ETHTOOL_GLINKSETTINGS failed: stick to
17353f1ac7a7SDavid Decotigny  *	%ETHTOOL_GSET/%ETHTOOL_SSET in that case.
17363f1ac7a7SDavid Decotigny  *
17373f1ac7a7SDavid Decotigny  * @cmd: Command number = %ETHTOOL_GLINKSETTINGS or %ETHTOOL_SLINKSETTINGS
17383f1ac7a7SDavid Decotigny  * @speed: Link speed (Mbps)
17393f1ac7a7SDavid Decotigny  * @duplex: Duplex mode; one of %DUPLEX_*
17403f1ac7a7SDavid Decotigny  * @port: Physical connector type; one of %PORT_*
17413f1ac7a7SDavid Decotigny  * @phy_address: MDIO address of PHY (transceiver); 0 or 255 if not
17423f1ac7a7SDavid Decotigny  *	applicable.  For clause 45 PHYs this is the PRTAD.
17433f1ac7a7SDavid Decotigny  * @autoneg: Enable/disable autonegotiation and auto-detection;
17443f1ac7a7SDavid Decotigny  *	either %AUTONEG_DISABLE or %AUTONEG_ENABLE
17453f1ac7a7SDavid Decotigny  * @mdio_support: Bitmask of %ETH_MDIO_SUPPORTS_* flags for the MDIO
17463f1ac7a7SDavid Decotigny  *	protocols supported by the interface; 0 if unknown.
17473f1ac7a7SDavid Decotigny  *	Read-only.
17483f1ac7a7SDavid Decotigny  * @eth_tp_mdix: Ethernet twisted-pair MDI(-X) status; one of
17493f1ac7a7SDavid Decotigny  *	%ETH_TP_MDI_*.  If the status is unknown or not applicable, the
17503f1ac7a7SDavid Decotigny  *	value will be %ETH_TP_MDI_INVALID.  Read-only.
17513f1ac7a7SDavid Decotigny  * @eth_tp_mdix_ctrl: Ethernet twisted pair MDI(-X) control; one of
17523f1ac7a7SDavid Decotigny  *	%ETH_TP_MDI_*.  If MDI(-X) control is not implemented, reads
17533f1ac7a7SDavid Decotigny  *	yield %ETH_TP_MDI_INVALID and writes may be ignored or rejected.
17543f1ac7a7SDavid Decotigny  *	When written successfully, the link should be renegotiated if
17553f1ac7a7SDavid Decotigny  *	necessary.
17563f1ac7a7SDavid Decotigny  * @link_mode_masks_nwords: Number of 32-bit words for each of the
17573f1ac7a7SDavid Decotigny  *	supported, advertising, lp_advertising link mode bitmaps. For
17583f1ac7a7SDavid Decotigny  *	%ETHTOOL_GLINKSETTINGS: on entry, number of words passed by user
17593f1ac7a7SDavid Decotigny  *	(>= 0); on return, if handshake in progress, negative if
17603f1ac7a7SDavid Decotigny  *	request size unsupported by kernel: absolute value indicates
17615f2d4724SDavid Decotigny  *	kernel expected size and all the other fields but cmd
17625f2d4724SDavid Decotigny  *	are 0; otherwise (handshake completed), strictly positive
17635f2d4724SDavid Decotigny  *	to indicate size used by kernel and cmd field stays
17643f1ac7a7SDavid Decotigny  *	%ETHTOOL_GLINKSETTINGS, all other fields populated by driver. For
17653f1ac7a7SDavid Decotigny  *	%ETHTOOL_SLINKSETTINGS: must be valid on entry, ie. a positive
17663f1ac7a7SDavid Decotigny  *	value returned previously by %ETHTOOL_GLINKSETTINGS, otherwise
17673f1ac7a7SDavid Decotigny  *	refused. For drivers: ignore this field (use kernel's
17683f1ac7a7SDavid Decotigny  *	__ETHTOOL_LINK_MODE_MASK_NBITS instead), any change to it will
17693f1ac7a7SDavid Decotigny  *	be overwritten by kernel.
17703f1ac7a7SDavid Decotigny  * @supported: Bitmap with each bit meaning given by
17713f1ac7a7SDavid Decotigny  *	%ethtool_link_mode_bit_indices for the link modes, physical
17723f1ac7a7SDavid Decotigny  *	connectors and other link features for which the interface
17733f1ac7a7SDavid Decotigny  *	supports autonegotiation or auto-detection.  Read-only.
17743f1ac7a7SDavid Decotigny  * @advertising: Bitmap with each bit meaning given by
17753f1ac7a7SDavid Decotigny  *	%ethtool_link_mode_bit_indices for the link modes, physical
17763f1ac7a7SDavid Decotigny  *	connectors and other link features that are advertised through
17773f1ac7a7SDavid Decotigny  *	autonegotiation or enabled for auto-detection.
17783f1ac7a7SDavid Decotigny  * @lp_advertising: Bitmap with each bit meaning given by
17793f1ac7a7SDavid Decotigny  *	%ethtool_link_mode_bit_indices for the link modes, and other
17803f1ac7a7SDavid Decotigny  *	link features that the link partner advertised through
17813f1ac7a7SDavid Decotigny  *	autonegotiation; 0 if unknown or not applicable.  Read-only.
178219cab887SFlorian Fainelli  * @transceiver: Used to distinguish different possible PHY types,
178319cab887SFlorian Fainelli  *	reported consistently by PHYLIB.  Read-only.
17843f1ac7a7SDavid Decotigny  *
17853f1ac7a7SDavid Decotigny  * If autonegotiation is disabled, the speed and @duplex represent the
17863f1ac7a7SDavid Decotigny  * fixed link mode and are writable if the driver supports multiple
17873f1ac7a7SDavid Decotigny  * link modes.  If it is enabled then they are read-only; if the link
17883f1ac7a7SDavid Decotigny  * is up they represent the negotiated link mode; if the link is down,
17893f1ac7a7SDavid Decotigny  * the speed is 0, %SPEED_UNKNOWN or the highest enabled speed and
17903f1ac7a7SDavid Decotigny  * @duplex is %DUPLEX_UNKNOWN or the best enabled duplex mode.
17913f1ac7a7SDavid Decotigny  *
17923f1ac7a7SDavid Decotigny  * Some hardware interfaces may have multiple PHYs and/or physical
17933f1ac7a7SDavid Decotigny  * connectors fitted or do not allow the driver to detect which are
17943f1ac7a7SDavid Decotigny  * fitted.  For these interfaces @port and/or @phy_address may be
17953f1ac7a7SDavid Decotigny  * writable, possibly dependent on @autoneg being %AUTONEG_DISABLE.
17963f1ac7a7SDavid Decotigny  * Otherwise, attempts to write different values may be ignored or
17973f1ac7a7SDavid Decotigny  * rejected.
17983f1ac7a7SDavid Decotigny  *
17993f1ac7a7SDavid Decotigny  * Deprecated %ethtool_cmd fields transceiver, maxtxpkt and maxrxpkt
18003f1ac7a7SDavid Decotigny  * are not available in %ethtool_link_settings. Until all drivers are
18013f1ac7a7SDavid Decotigny  * converted to ignore them or to the new %ethtool_link_settings API,
18023f1ac7a7SDavid Decotigny  * for both queries and changes, users should always try
18033f1ac7a7SDavid Decotigny  * %ETHTOOL_GLINKSETTINGS first, and if it fails with -ENOTSUPP stick
18043f1ac7a7SDavid Decotigny  * only to %ETHTOOL_GSET and %ETHTOOL_SSET consistently. If it
18053f1ac7a7SDavid Decotigny  * succeeds, then users should stick to %ETHTOOL_GLINKSETTINGS and
18063f1ac7a7SDavid Decotigny  * %ETHTOOL_SLINKSETTINGS (which would support drivers implementing
18073f1ac7a7SDavid Decotigny  * either %ethtool_cmd or %ethtool_link_settings).
18083f1ac7a7SDavid Decotigny  *
18093f1ac7a7SDavid Decotigny  * Users should assume that all fields not marked read-only are
18103f1ac7a7SDavid Decotigny  * writable and subject to validation by the driver.  They should use
18113f1ac7a7SDavid Decotigny  * %ETHTOOL_GLINKSETTINGS to get the current values before making specific
18123f1ac7a7SDavid Decotigny  * changes and then applying them with %ETHTOOL_SLINKSETTINGS.
18133f1ac7a7SDavid Decotigny  *
18143f1ac7a7SDavid Decotigny  * Drivers that implement %get_link_ksettings and/or
18153f1ac7a7SDavid Decotigny  * %set_link_ksettings should ignore the @cmd
18163f1ac7a7SDavid Decotigny  * and @link_mode_masks_nwords fields (any change to them overwritten
18173f1ac7a7SDavid Decotigny  * by kernel), and rely only on kernel's internal
18183f1ac7a7SDavid Decotigny  * %__ETHTOOL_LINK_MODE_MASK_NBITS and
18193f1ac7a7SDavid Decotigny  * %ethtool_link_mode_mask_t. Drivers that implement
18203f1ac7a7SDavid Decotigny  * %set_link_ksettings() should validate all fields other than @cmd
18213f1ac7a7SDavid Decotigny  * and @link_mode_masks_nwords that are not described as read-only or
18223f1ac7a7SDavid Decotigny  * deprecated, and must ignore all fields described as read-only.
18233f1ac7a7SDavid Decotigny  */
18243f1ac7a7SDavid Decotigny struct ethtool_link_settings {
18253f1ac7a7SDavid Decotigny 	__u32	cmd;
18263f1ac7a7SDavid Decotigny 	__u32	speed;
18273f1ac7a7SDavid Decotigny 	__u8	duplex;
18283f1ac7a7SDavid Decotigny 	__u8	port;
18293f1ac7a7SDavid Decotigny 	__u8	phy_address;
18303f1ac7a7SDavid Decotigny 	__u8	autoneg;
18313f1ac7a7SDavid Decotigny 	__u8	mdio_support;
18323f1ac7a7SDavid Decotigny 	__u8	eth_tp_mdix;
18333f1ac7a7SDavid Decotigny 	__u8	eth_tp_mdix_ctrl;
18343f1ac7a7SDavid Decotigny 	__s8	link_mode_masks_nwords;
183519cab887SFlorian Fainelli 	__u8	transceiver;
183619cab887SFlorian Fainelli 	__u8	reserved1[3];
183719cab887SFlorian Fainelli 	__u32	reserved[7];
18383f1ac7a7SDavid Decotigny 	__u32	link_mode_masks[0];
18393f1ac7a7SDavid Decotigny 	/* layout of link_mode_masks fields:
18403f1ac7a7SDavid Decotigny 	 * __u32 map_supported[link_mode_masks_nwords];
18413f1ac7a7SDavid Decotigny 	 * __u32 map_advertising[link_mode_masks_nwords];
18423f1ac7a7SDavid Decotigny 	 * __u32 map_lp_advertising[link_mode_masks_nwords];
18433f1ac7a7SDavid Decotigny 	 */
18443f1ac7a7SDavid Decotigny };
1845607ca46eSDavid Howells #endif /* _UAPI_LINUX_ETHTOOL_H */
1846