xref: /linux/include/uapi/linux/ethtool.h (revision 0e1a2a3e6e7d37cea9f8586f6d7745b539147d9f)
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  * Deprecated fields should be ignored by both users and drivers.
95bf8fc60aSBen Hutchings  */
96607ca46eSDavid Howells struct ethtool_cmd {
97607ca46eSDavid Howells 	__u32	cmd;
98bf8fc60aSBen Hutchings 	__u32	supported;
99bf8fc60aSBen Hutchings 	__u32	advertising;
100bf8fc60aSBen Hutchings 	__u16	speed;
101bf8fc60aSBen Hutchings 	__u8	duplex;
102bf8fc60aSBen Hutchings 	__u8	port;
103bf8fc60aSBen Hutchings 	__u8	phy_address;
104bf8fc60aSBen Hutchings 	__u8	transceiver;
105bf8fc60aSBen Hutchings 	__u8	autoneg;
106bf8fc60aSBen Hutchings 	__u8	mdio_support;
107bf8fc60aSBen Hutchings 	__u32	maxtxpkt;
108bf8fc60aSBen Hutchings 	__u32	maxrxpkt;
109bf8fc60aSBen Hutchings 	__u16	speed_hi;
110bf8fc60aSBen Hutchings 	__u8	eth_tp_mdix;
111bf8fc60aSBen Hutchings 	__u8	eth_tp_mdix_ctrl;
112bf8fc60aSBen Hutchings 	__u32	lp_advertising;
113607ca46eSDavid Howells 	__u32	reserved[2];
114607ca46eSDavid Howells };
115607ca46eSDavid Howells 
116607ca46eSDavid Howells static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
117607ca46eSDavid Howells 					 __u32 speed)
118607ca46eSDavid Howells {
11985a62440SJesse Brandeburg 	ep->speed = (__u16)(speed & 0xFFFF);
120607ca46eSDavid Howells 	ep->speed_hi = (__u16)(speed >> 16);
121607ca46eSDavid Howells }
122607ca46eSDavid Howells 
123607ca46eSDavid Howells static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
124607ca46eSDavid Howells {
125607ca46eSDavid Howells 	return (ep->speed_hi << 16) | ep->speed;
126607ca46eSDavid Howells }
127607ca46eSDavid Howells 
128607ca46eSDavid Howells /* Device supports clause 22 register access to PHY or peripherals
129607ca46eSDavid Howells  * using the interface defined in <linux/mii.h>.  This should not be
130607ca46eSDavid Howells  * set if there are known to be no such peripherals present or if
131607ca46eSDavid Howells  * the driver only emulates clause 22 registers for compatibility.
132607ca46eSDavid Howells  */
133607ca46eSDavid Howells #define ETH_MDIO_SUPPORTS_C22	1
134607ca46eSDavid Howells 
135607ca46eSDavid Howells /* Device supports clause 45 register access to PHY or peripherals
136607ca46eSDavid Howells  * using the interface defined in <linux/mii.h> and <linux/mdio.h>.
137607ca46eSDavid Howells  * This should not be set if there are known to be no such peripherals
138607ca46eSDavid Howells  * present.
139607ca46eSDavid Howells  */
140607ca46eSDavid Howells #define ETH_MDIO_SUPPORTS_C45	2
141607ca46eSDavid Howells 
142607ca46eSDavid Howells #define ETHTOOL_FWVERS_LEN	32
143607ca46eSDavid Howells #define ETHTOOL_BUSINFO_LEN	32
144a4505152SHariprasad Shenai #define ETHTOOL_EROMVERS_LEN	32
145daba1b6bSBen Hutchings 
146daba1b6bSBen Hutchings /**
147daba1b6bSBen Hutchings  * struct ethtool_drvinfo - general driver and device information
148daba1b6bSBen Hutchings  * @cmd: Command number = %ETHTOOL_GDRVINFO
149daba1b6bSBen Hutchings  * @driver: Driver short name.  This should normally match the name
150daba1b6bSBen Hutchings  *	in its bus driver structure (e.g. pci_driver::name).  Must
151daba1b6bSBen Hutchings  *	not be an empty string.
152daba1b6bSBen Hutchings  * @version: Driver version string; may be an empty string
153daba1b6bSBen Hutchings  * @fw_version: Firmware version string; may be an empty string
154a4505152SHariprasad Shenai  * @erom_version: Expansion ROM version string; may be an empty string
155daba1b6bSBen Hutchings  * @bus_info: Device bus address.  This should match the dev_name()
156daba1b6bSBen Hutchings  *	string for the underlying bus device, if there is one.  May be
157daba1b6bSBen Hutchings  *	an empty string.
158daba1b6bSBen Hutchings  * @n_priv_flags: Number of flags valid for %ETHTOOL_GPFLAGS and
159daba1b6bSBen Hutchings  *	%ETHTOOL_SPFLAGS commands; also the number of strings in the
160daba1b6bSBen Hutchings  *	%ETH_SS_PRIV_FLAGS set
161daba1b6bSBen Hutchings  * @n_stats: Number of u64 statistics returned by the %ETHTOOL_GSTATS
162daba1b6bSBen Hutchings  *	command; also the number of strings in the %ETH_SS_STATS set
163daba1b6bSBen Hutchings  * @testinfo_len: Number of results returned by the %ETHTOOL_TEST
164daba1b6bSBen Hutchings  *	command; also the number of strings in the %ETH_SS_TEST set
165daba1b6bSBen Hutchings  * @eedump_len: Size of EEPROM accessible through the %ETHTOOL_GEEPROM
166daba1b6bSBen Hutchings  *	and %ETHTOOL_SEEPROM commands, in bytes
167daba1b6bSBen Hutchings  * @regdump_len: Size of register dump returned by the %ETHTOOL_GREGS
168daba1b6bSBen Hutchings  *	command, in bytes
169daba1b6bSBen Hutchings  *
170daba1b6bSBen Hutchings  * Users can use the %ETHTOOL_GSSET_INFO command to get the number of
171daba1b6bSBen Hutchings  * strings in any string set (from Linux 2.6.34).
172daba1b6bSBen Hutchings  *
173daba1b6bSBen Hutchings  * Drivers should set at most @driver, @version, @fw_version and
174daba1b6bSBen Hutchings  * @bus_info in their get_drvinfo() implementation.  The ethtool
175daba1b6bSBen Hutchings  * core fills in the other fields using other driver operations.
176daba1b6bSBen Hutchings  */
177607ca46eSDavid Howells struct ethtool_drvinfo {
178607ca46eSDavid Howells 	__u32	cmd;
179daba1b6bSBen Hutchings 	char	driver[32];
180daba1b6bSBen Hutchings 	char	version[32];
181daba1b6bSBen Hutchings 	char	fw_version[ETHTOOL_FWVERS_LEN];
182daba1b6bSBen Hutchings 	char	bus_info[ETHTOOL_BUSINFO_LEN];
183a4505152SHariprasad Shenai 	char	erom_version[ETHTOOL_EROMVERS_LEN];
184607ca46eSDavid Howells 	char	reserved2[12];
185daba1b6bSBen Hutchings 	__u32	n_priv_flags;
186daba1b6bSBen Hutchings 	__u32	n_stats;
187607ca46eSDavid Howells 	__u32	testinfo_len;
188daba1b6bSBen Hutchings 	__u32	eedump_len;
189daba1b6bSBen Hutchings 	__u32	regdump_len;
190607ca46eSDavid Howells };
191607ca46eSDavid Howells 
192607ca46eSDavid Howells #define SOPASS_MAX	6
19302d59f3fSBen Hutchings 
19402d59f3fSBen Hutchings /**
19502d59f3fSBen Hutchings  * struct ethtool_wolinfo - Wake-On-Lan configuration
19602d59f3fSBen Hutchings  * @cmd: Command number = %ETHTOOL_GWOL or %ETHTOOL_SWOL
19702d59f3fSBen Hutchings  * @supported: Bitmask of %WAKE_* flags for supported Wake-On-Lan modes.
19802d59f3fSBen Hutchings  *	Read-only.
19902d59f3fSBen Hutchings  * @wolopts: Bitmask of %WAKE_* flags for enabled Wake-On-Lan modes.
20002d59f3fSBen Hutchings  * @sopass: SecureOn(tm) password; meaningful only if %WAKE_MAGICSECURE
20102d59f3fSBen Hutchings  *	is set in @wolopts.
20202d59f3fSBen Hutchings  */
203607ca46eSDavid Howells struct ethtool_wolinfo {
204607ca46eSDavid Howells 	__u32	cmd;
205607ca46eSDavid Howells 	__u32	supported;
206607ca46eSDavid Howells 	__u32	wolopts;
20702d59f3fSBen Hutchings 	__u8	sopass[SOPASS_MAX];
208607ca46eSDavid Howells };
209607ca46eSDavid Howells 
210607ca46eSDavid Howells /* for passing single values */
211607ca46eSDavid Howells struct ethtool_value {
212607ca46eSDavid Howells 	__u32	cmd;
213607ca46eSDavid Howells 	__u32	data;
214607ca46eSDavid Howells };
215607ca46eSDavid Howells 
216e1577c1cSInbar Karmy #define PFC_STORM_PREVENTION_AUTO	0xffff
217e1577c1cSInbar Karmy #define PFC_STORM_PREVENTION_DISABLE	0
218e1577c1cSInbar Karmy 
219f0db9b07SGovindarajulu Varadarajan enum tunable_id {
220f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_ID_UNSPEC,
221f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_RX_COPYBREAK,
2221255a505SEric Dumazet 	ETHTOOL_TX_COPYBREAK,
223e1577c1cSInbar Karmy 	ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */
224a4244b0cSHadar Hen Zion 	/*
225c3086637SMichael Heimpold 	 * Add your fresh new tunable attribute above and remember to update
226a4244b0cSHadar Hen Zion 	 * tunable_strings[] in net/core/ethtool.c
227a4244b0cSHadar Hen Zion 	 */
228a4244b0cSHadar Hen Zion 	__ETHTOOL_TUNABLE_COUNT,
229f0db9b07SGovindarajulu Varadarajan };
230f0db9b07SGovindarajulu Varadarajan 
231f0db9b07SGovindarajulu Varadarajan enum tunable_type_id {
232f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_UNSPEC,
233f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_U8,
234f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_U16,
235f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_U32,
236f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_U64,
237f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_STRING,
238f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_S8,
239f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_S16,
240f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_S32,
241f0db9b07SGovindarajulu Varadarajan 	ETHTOOL_TUNABLE_S64,
242f0db9b07SGovindarajulu Varadarajan };
243f0db9b07SGovindarajulu Varadarajan 
244f0db9b07SGovindarajulu Varadarajan struct ethtool_tunable {
245f0db9b07SGovindarajulu Varadarajan 	__u32	cmd;
246f0db9b07SGovindarajulu Varadarajan 	__u32	id;
247f0db9b07SGovindarajulu Varadarajan 	__u32	type_id;
248f0db9b07SGovindarajulu Varadarajan 	__u32	len;
249f0db9b07SGovindarajulu Varadarajan 	void	*data[0];
250f0db9b07SGovindarajulu Varadarajan };
251f0db9b07SGovindarajulu Varadarajan 
252607c7029SRaju Lakkaraju #define DOWNSHIFT_DEV_DEFAULT_COUNT	0xff
253607c7029SRaju Lakkaraju #define DOWNSHIFT_DEV_DISABLE		0
254607c7029SRaju Lakkaraju 
2553aeb0803SHeiner Kallweit /* Time in msecs after which link is reported as down
2563aeb0803SHeiner Kallweit  * 0 = lowest time supported by the PHY
2573aeb0803SHeiner Kallweit  * 0xff = off, link down detection according to standard
2583aeb0803SHeiner Kallweit  */
2593aeb0803SHeiner Kallweit #define ETHTOOL_PHY_FAST_LINK_DOWN_ON	0
2603aeb0803SHeiner Kallweit #define ETHTOOL_PHY_FAST_LINK_DOWN_OFF	0xff
2613aeb0803SHeiner Kallweit 
2620d27f4e4SRaju Lakkaraju enum phy_tunable_id {
2630d27f4e4SRaju Lakkaraju 	ETHTOOL_PHY_ID_UNSPEC,
264607c7029SRaju Lakkaraju 	ETHTOOL_PHY_DOWNSHIFT,
2653aeb0803SHeiner Kallweit 	ETHTOOL_PHY_FAST_LINK_DOWN,
2660d27f4e4SRaju Lakkaraju 	/*
2670d27f4e4SRaju Lakkaraju 	 * Add your fresh new phy tunable attribute above and remember to update
2680d27f4e4SRaju Lakkaraju 	 * phy_tunable_strings[] in net/core/ethtool.c
2690d27f4e4SRaju Lakkaraju 	 */
2700d27f4e4SRaju Lakkaraju 	__ETHTOOL_PHY_TUNABLE_COUNT,
2710d27f4e4SRaju Lakkaraju };
2720d27f4e4SRaju Lakkaraju 
27309fb8bb0SBen Hutchings /**
27409fb8bb0SBen Hutchings  * struct ethtool_regs - hardware register dump
27509fb8bb0SBen Hutchings  * @cmd: Command number = %ETHTOOL_GREGS
27609fb8bb0SBen Hutchings  * @version: Dump format version.  This is driver-specific and may
27709fb8bb0SBen Hutchings  *	distinguish different chips/revisions.  Drivers must use new
27809fb8bb0SBen Hutchings  *	version numbers whenever the dump format changes in an
27909fb8bb0SBen Hutchings  *	incompatible way.
28009fb8bb0SBen Hutchings  * @len: On entry, the real length of @data.  On return, the number of
28109fb8bb0SBen Hutchings  *	bytes used.
28209fb8bb0SBen Hutchings  * @data: Buffer for the register dump
28309fb8bb0SBen Hutchings  *
28409fb8bb0SBen Hutchings  * Users should use %ETHTOOL_GDRVINFO to find the maximum length of
28509fb8bb0SBen Hutchings  * a register dump for the interface.  They must allocate the buffer
28609fb8bb0SBen Hutchings  * immediately following this structure.
28709fb8bb0SBen Hutchings  */
288607ca46eSDavid Howells struct ethtool_regs {
289607ca46eSDavid Howells 	__u32	cmd;
29009fb8bb0SBen Hutchings 	__u32	version;
29109fb8bb0SBen Hutchings 	__u32	len;
292607ca46eSDavid Howells 	__u8	data[0];
293607ca46eSDavid Howells };
294607ca46eSDavid Howells 
295c8364a63SBen Hutchings /**
296c8364a63SBen Hutchings  * struct ethtool_eeprom - EEPROM dump
297c8364a63SBen Hutchings  * @cmd: Command number = %ETHTOOL_GEEPROM, %ETHTOOL_GMODULEEEPROM or
298c8364a63SBen Hutchings  *	%ETHTOOL_SEEPROM
299c8364a63SBen Hutchings  * @magic: A 'magic cookie' value to guard against accidental changes.
300c8364a63SBen Hutchings  *	The value passed in to %ETHTOOL_SEEPROM must match the value
301c8364a63SBen Hutchings  *	returned by %ETHTOOL_GEEPROM for the same device.  This is
302c8364a63SBen Hutchings  *	unused when @cmd is %ETHTOOL_GMODULEEEPROM.
303c8364a63SBen Hutchings  * @offset: Offset within the EEPROM to begin reading/writing, in bytes
304c8364a63SBen Hutchings  * @len: On entry, number of bytes to read/write.  On successful
305c8364a63SBen Hutchings  *	return, number of bytes actually read/written.  In case of
306c8364a63SBen Hutchings  *	error, this may indicate at what point the error occurred.
307c8364a63SBen Hutchings  * @data: Buffer to read/write from
308c8364a63SBen Hutchings  *
309c8364a63SBen Hutchings  * Users may use %ETHTOOL_GDRVINFO or %ETHTOOL_GMODULEINFO to find
310c8364a63SBen Hutchings  * the length of an on-board or module EEPROM, respectively.  They
311c8364a63SBen Hutchings  * must allocate the buffer immediately following this structure.
312c8364a63SBen Hutchings  */
313607ca46eSDavid Howells struct ethtool_eeprom {
314607ca46eSDavid Howells 	__u32	cmd;
315607ca46eSDavid Howells 	__u32	magic;
316c8364a63SBen Hutchings 	__u32	offset;
317c8364a63SBen Hutchings 	__u32	len;
318607ca46eSDavid Howells 	__u8	data[0];
319607ca46eSDavid Howells };
320607ca46eSDavid Howells 
321607ca46eSDavid Howells /**
322607ca46eSDavid Howells  * struct ethtool_eee - Energy Efficient Ethernet information
323607ca46eSDavid Howells  * @cmd: ETHTOOL_{G,S}EEE
324607ca46eSDavid Howells  * @supported: Mask of %SUPPORTED_* flags for the speed/duplex combinations
325607ca46eSDavid Howells  *	for which there is EEE support.
326607ca46eSDavid Howells  * @advertised: Mask of %ADVERTISED_* flags for the speed/duplex combinations
327607ca46eSDavid Howells  *	advertised as eee capable.
328607ca46eSDavid Howells  * @lp_advertised: Mask of %ADVERTISED_* flags for the speed/duplex
329607ca46eSDavid Howells  *	combinations advertised by the link partner as eee capable.
330607ca46eSDavid Howells  * @eee_active: Result of the eee auto negotiation.
331607ca46eSDavid Howells  * @eee_enabled: EEE configured mode (enabled/disabled).
332607ca46eSDavid Howells  * @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
333607ca46eSDavid Howells  *	that eee was negotiated.
334607ca46eSDavid Howells  * @tx_lpi_timer: Time in microseconds the interface delays prior to asserting
335607ca46eSDavid Howells  *	its tx lpi (after reaching 'idle' state). Effective only when eee
336607ca46eSDavid Howells  *	was negotiated and tx_lpi_enabled was set.
337607ca46eSDavid Howells  */
338607ca46eSDavid Howells struct ethtool_eee {
339607ca46eSDavid Howells 	__u32	cmd;
340607ca46eSDavid Howells 	__u32	supported;
341607ca46eSDavid Howells 	__u32	advertised;
342607ca46eSDavid Howells 	__u32	lp_advertised;
343607ca46eSDavid Howells 	__u32	eee_active;
344607ca46eSDavid Howells 	__u32	eee_enabled;
345607ca46eSDavid Howells 	__u32	tx_lpi_enabled;
346607ca46eSDavid Howells 	__u32	tx_lpi_timer;
347607ca46eSDavid Howells 	__u32	reserved[2];
348607ca46eSDavid Howells };
349607ca46eSDavid Howells 
350607ca46eSDavid Howells /**
351607ca46eSDavid Howells  * struct ethtool_modinfo - plugin module eeprom information
352607ca46eSDavid Howells  * @cmd: %ETHTOOL_GMODULEINFO
353607ca46eSDavid Howells  * @type: Standard the module information conforms to %ETH_MODULE_SFF_xxxx
354607ca46eSDavid Howells  * @eeprom_len: Length of the eeprom
355607ca46eSDavid Howells  *
356607ca46eSDavid Howells  * This structure is used to return the information to
357607ca46eSDavid Howells  * properly size memory for a subsequent call to %ETHTOOL_GMODULEEEPROM.
358607ca46eSDavid Howells  * The type code indicates the eeprom data format
359607ca46eSDavid Howells  */
360607ca46eSDavid Howells struct ethtool_modinfo {
361607ca46eSDavid Howells 	__u32   cmd;
362607ca46eSDavid Howells 	__u32   type;
363607ca46eSDavid Howells 	__u32   eeprom_len;
364607ca46eSDavid Howells 	__u32   reserved[8];
365607ca46eSDavid Howells };
366607ca46eSDavid Howells 
367607ca46eSDavid Howells /**
368607ca46eSDavid Howells  * struct ethtool_coalesce - coalescing parameters for IRQs and stats updates
369607ca46eSDavid Howells  * @cmd: ETHTOOL_{G,S}COALESCE
370607ca46eSDavid Howells  * @rx_coalesce_usecs: How many usecs to delay an RX interrupt after
371607ca46eSDavid Howells  *	a packet arrives.
372607ca46eSDavid Howells  * @rx_max_coalesced_frames: Maximum number of packets to receive
373607ca46eSDavid Howells  *	before an RX interrupt.
374607ca46eSDavid Howells  * @rx_coalesce_usecs_irq: Same as @rx_coalesce_usecs, except that
375607ca46eSDavid Howells  *	this value applies while an IRQ is being serviced by the host.
376607ca46eSDavid Howells  * @rx_max_coalesced_frames_irq: Same as @rx_max_coalesced_frames,
377607ca46eSDavid Howells  *	except that this value applies while an IRQ is being serviced
378607ca46eSDavid Howells  *	by the host.
379607ca46eSDavid Howells  * @tx_coalesce_usecs: How many usecs to delay a TX interrupt after
380607ca46eSDavid Howells  *	a packet is sent.
381607ca46eSDavid Howells  * @tx_max_coalesced_frames: Maximum number of packets to be sent
382607ca46eSDavid Howells  *	before a TX interrupt.
383607ca46eSDavid Howells  * @tx_coalesce_usecs_irq: Same as @tx_coalesce_usecs, except that
384607ca46eSDavid Howells  *	this value applies while an IRQ is being serviced by the host.
385607ca46eSDavid Howells  * @tx_max_coalesced_frames_irq: Same as @tx_max_coalesced_frames,
386607ca46eSDavid Howells  *	except that this value applies while an IRQ is being serviced
387607ca46eSDavid Howells  *	by the host.
388607ca46eSDavid Howells  * @stats_block_coalesce_usecs: How many usecs to delay in-memory
389607ca46eSDavid Howells  *	statistics block updates.  Some drivers do not have an
390607ca46eSDavid Howells  *	in-memory statistic block, and in such cases this value is
391607ca46eSDavid Howells  *	ignored.  This value must not be zero.
392607ca46eSDavid Howells  * @use_adaptive_rx_coalesce: Enable adaptive RX coalescing.
393607ca46eSDavid Howells  * @use_adaptive_tx_coalesce: Enable adaptive TX coalescing.
394607ca46eSDavid Howells  * @pkt_rate_low: Threshold for low packet rate (packets per second).
395607ca46eSDavid Howells  * @rx_coalesce_usecs_low: How many usecs to delay an RX interrupt after
396607ca46eSDavid Howells  *	a packet arrives, when the packet rate is below @pkt_rate_low.
397607ca46eSDavid Howells  * @rx_max_coalesced_frames_low: Maximum number of packets to be received
398607ca46eSDavid Howells  *	before an RX interrupt, when the packet rate is below @pkt_rate_low.
399607ca46eSDavid Howells  * @tx_coalesce_usecs_low: How many usecs to delay a TX interrupt after
400607ca46eSDavid Howells  *	a packet is sent, when the packet rate is below @pkt_rate_low.
401607ca46eSDavid Howells  * @tx_max_coalesced_frames_low: Maximum nuumber of packets to be sent before
402607ca46eSDavid Howells  *	a TX interrupt, when the packet rate is below @pkt_rate_low.
403607ca46eSDavid Howells  * @pkt_rate_high: Threshold for high packet rate (packets per second).
404607ca46eSDavid Howells  * @rx_coalesce_usecs_high: How many usecs to delay an RX interrupt after
405607ca46eSDavid Howells  *	a packet arrives, when the packet rate is above @pkt_rate_high.
406607ca46eSDavid Howells  * @rx_max_coalesced_frames_high: Maximum number of packets to be received
407607ca46eSDavid Howells  *	before an RX interrupt, when the packet rate is above @pkt_rate_high.
408607ca46eSDavid Howells  * @tx_coalesce_usecs_high: How many usecs to delay a TX interrupt after
409607ca46eSDavid Howells  *	a packet is sent, when the packet rate is above @pkt_rate_high.
410607ca46eSDavid Howells  * @tx_max_coalesced_frames_high: Maximum number of packets to be sent before
411607ca46eSDavid Howells  *	a TX interrupt, when the packet rate is above @pkt_rate_high.
412607ca46eSDavid Howells  * @rate_sample_interval: How often to do adaptive coalescing packet rate
413607ca46eSDavid Howells  *	sampling, measured in seconds.  Must not be zero.
414607ca46eSDavid Howells  *
415073e3cf2SBen Hutchings  * Each pair of (usecs, max_frames) fields specifies that interrupts
416073e3cf2SBen Hutchings  * should be coalesced until
417607ca46eSDavid Howells  *	(usecs > 0 && time_since_first_completion >= usecs) ||
418607ca46eSDavid Howells  *	(max_frames > 0 && completed_frames >= max_frames)
419073e3cf2SBen Hutchings  *
420607ca46eSDavid Howells  * It is illegal to set both usecs and max_frames to zero as this
421607ca46eSDavid Howells  * would cause interrupts to never be generated.  To disable
422607ca46eSDavid Howells  * coalescing, set usecs = 0 and max_frames = 1.
423607ca46eSDavid Howells  *
424607ca46eSDavid Howells  * Some implementations ignore the value of max_frames and use the
425073e3cf2SBen Hutchings  * condition time_since_first_completion >= usecs
426073e3cf2SBen Hutchings  *
427607ca46eSDavid Howells  * This is deprecated.  Drivers for hardware that does not support
428607ca46eSDavid Howells  * counting completions should validate that max_frames == !rx_usecs.
429607ca46eSDavid Howells  *
430607ca46eSDavid Howells  * Adaptive RX/TX coalescing is an algorithm implemented by some
431607ca46eSDavid Howells  * drivers to improve latency under low packet rates and improve
432607ca46eSDavid Howells  * throughput under high packet rates.  Some drivers only implement
433607ca46eSDavid Howells  * one of RX or TX adaptive coalescing.  Anything not implemented by
434607ca46eSDavid Howells  * the driver causes these values to be silently ignored.
435607ca46eSDavid Howells  *
436607ca46eSDavid Howells  * When the packet rate is below @pkt_rate_high but above
437607ca46eSDavid Howells  * @pkt_rate_low (both measured in packets per second) the
438607ca46eSDavid Howells  * normal {rx,tx}_* coalescing parameters are used.
439607ca46eSDavid Howells  */
440607ca46eSDavid Howells struct ethtool_coalesce {
441607ca46eSDavid Howells 	__u32	cmd;
442607ca46eSDavid Howells 	__u32	rx_coalesce_usecs;
443607ca46eSDavid Howells 	__u32	rx_max_coalesced_frames;
444607ca46eSDavid Howells 	__u32	rx_coalesce_usecs_irq;
445607ca46eSDavid Howells 	__u32	rx_max_coalesced_frames_irq;
446607ca46eSDavid Howells 	__u32	tx_coalesce_usecs;
447607ca46eSDavid Howells 	__u32	tx_max_coalesced_frames;
448607ca46eSDavid Howells 	__u32	tx_coalesce_usecs_irq;
449607ca46eSDavid Howells 	__u32	tx_max_coalesced_frames_irq;
450607ca46eSDavid Howells 	__u32	stats_block_coalesce_usecs;
451607ca46eSDavid Howells 	__u32	use_adaptive_rx_coalesce;
452607ca46eSDavid Howells 	__u32	use_adaptive_tx_coalesce;
453607ca46eSDavid Howells 	__u32	pkt_rate_low;
454607ca46eSDavid Howells 	__u32	rx_coalesce_usecs_low;
455607ca46eSDavid Howells 	__u32	rx_max_coalesced_frames_low;
456607ca46eSDavid Howells 	__u32	tx_coalesce_usecs_low;
457607ca46eSDavid Howells 	__u32	tx_max_coalesced_frames_low;
458607ca46eSDavid Howells 	__u32	pkt_rate_high;
459607ca46eSDavid Howells 	__u32	rx_coalesce_usecs_high;
460607ca46eSDavid Howells 	__u32	rx_max_coalesced_frames_high;
461607ca46eSDavid Howells 	__u32	tx_coalesce_usecs_high;
462607ca46eSDavid Howells 	__u32	tx_max_coalesced_frames_high;
463607ca46eSDavid Howells 	__u32	rate_sample_interval;
464607ca46eSDavid Howells };
465607ca46eSDavid Howells 
466af440a8aSBen Hutchings /**
467af440a8aSBen Hutchings  * struct ethtool_ringparam - RX/TX ring parameters
468af440a8aSBen Hutchings  * @cmd: Command number = %ETHTOOL_GRINGPARAM or %ETHTOOL_SRINGPARAM
469af440a8aSBen Hutchings  * @rx_max_pending: Maximum supported number of pending entries per
470af440a8aSBen Hutchings  *	RX ring.  Read-only.
471af440a8aSBen Hutchings  * @rx_mini_max_pending: Maximum supported number of pending entries
472af440a8aSBen Hutchings  *	per RX mini ring.  Read-only.
473af440a8aSBen Hutchings  * @rx_jumbo_max_pending: Maximum supported number of pending entries
474af440a8aSBen Hutchings  *	per RX jumbo ring.  Read-only.
475af440a8aSBen Hutchings  * @tx_max_pending: Maximum supported number of pending entries per
476af440a8aSBen Hutchings  *	TX ring.  Read-only.
477af440a8aSBen Hutchings  * @rx_pending: Current maximum number of pending entries per RX ring
478af440a8aSBen Hutchings  * @rx_mini_pending: Current maximum number of pending entries per RX
479af440a8aSBen Hutchings  *	mini ring
480af440a8aSBen Hutchings  * @rx_jumbo_pending: Current maximum number of pending entries per RX
481af440a8aSBen Hutchings  *	jumbo ring
482af440a8aSBen Hutchings  * @tx_pending: Current maximum supported number of pending entries
483af440a8aSBen Hutchings  *	per TX ring
484af440a8aSBen Hutchings  *
485af440a8aSBen Hutchings  * If the interface does not have separate RX mini and/or jumbo rings,
486af440a8aSBen Hutchings  * @rx_mini_max_pending and/or @rx_jumbo_max_pending will be 0.
487af440a8aSBen Hutchings  *
488af440a8aSBen Hutchings  * There may also be driver-dependent minimum values for the number
489af440a8aSBen Hutchings  * of entries per ring.
490607ca46eSDavid Howells  */
491af440a8aSBen Hutchings struct ethtool_ringparam {
492af440a8aSBen Hutchings 	__u32	cmd;
493607ca46eSDavid Howells 	__u32	rx_max_pending;
494607ca46eSDavid Howells 	__u32	rx_mini_max_pending;
495607ca46eSDavid Howells 	__u32	rx_jumbo_max_pending;
496607ca46eSDavid Howells 	__u32	tx_max_pending;
497607ca46eSDavid Howells 	__u32	rx_pending;
498607ca46eSDavid Howells 	__u32	rx_mini_pending;
499607ca46eSDavid Howells 	__u32	rx_jumbo_pending;
500607ca46eSDavid Howells 	__u32	tx_pending;
501607ca46eSDavid Howells };
502607ca46eSDavid Howells 
503607ca46eSDavid Howells /**
504607ca46eSDavid Howells  * struct ethtool_channels - configuring number of network channel
505607ca46eSDavid Howells  * @cmd: ETHTOOL_{G,S}CHANNELS
506607ca46eSDavid Howells  * @max_rx: Read only. Maximum number of receive channel the driver support.
507607ca46eSDavid Howells  * @max_tx: Read only. Maximum number of transmit channel the driver support.
508607ca46eSDavid Howells  * @max_other: Read only. Maximum number of other channel the driver support.
509607ca46eSDavid Howells  * @max_combined: Read only. Maximum number of combined channel the driver
510607ca46eSDavid Howells  *	support. Set of queues RX, TX or other.
511607ca46eSDavid Howells  * @rx_count: Valid values are in the range 1 to the max_rx.
512607ca46eSDavid Howells  * @tx_count: Valid values are in the range 1 to the max_tx.
513607ca46eSDavid Howells  * @other_count: Valid values are in the range 1 to the max_other.
514607ca46eSDavid Howells  * @combined_count: Valid values are in the range 1 to the max_combined.
515607ca46eSDavid Howells  *
516607ca46eSDavid Howells  * This can be used to configure RX, TX and other channels.
517607ca46eSDavid Howells  */
518607ca46eSDavid Howells 
519607ca46eSDavid Howells struct ethtool_channels {
520607ca46eSDavid Howells 	__u32	cmd;
521607ca46eSDavid Howells 	__u32	max_rx;
522607ca46eSDavid Howells 	__u32	max_tx;
523607ca46eSDavid Howells 	__u32	max_other;
524607ca46eSDavid Howells 	__u32	max_combined;
525607ca46eSDavid Howells 	__u32	rx_count;
526607ca46eSDavid Howells 	__u32	tx_count;
527607ca46eSDavid Howells 	__u32	other_count;
528607ca46eSDavid Howells 	__u32	combined_count;
529607ca46eSDavid Howells };
530607ca46eSDavid Howells 
5316a7a1081SBen Hutchings /**
5326a7a1081SBen Hutchings  * struct ethtool_pauseparam - Ethernet pause (flow control) parameters
5336a7a1081SBen Hutchings  * @cmd: Command number = %ETHTOOL_GPAUSEPARAM or %ETHTOOL_SPAUSEPARAM
5346a7a1081SBen Hutchings  * @autoneg: Flag to enable autonegotiation of pause frame use
5356a7a1081SBen Hutchings  * @rx_pause: Flag to enable reception of pause frames
5366a7a1081SBen Hutchings  * @tx_pause: Flag to enable transmission of pause frames
537607ca46eSDavid Howells  *
5386a7a1081SBen Hutchings  * Drivers should reject a non-zero setting of @autoneg when
5396a7a1081SBen Hutchings  * autoneogotiation is disabled (or not supported) for the link.
5406a7a1081SBen Hutchings  *
5416a7a1081SBen Hutchings  * If the link is autonegotiated, drivers should use
5426a7a1081SBen Hutchings  * mii_advertise_flowctrl() or similar code to set the advertised
5436a7a1081SBen Hutchings  * pause frame capabilities based on the @rx_pause and @tx_pause flags,
5446a7a1081SBen Hutchings  * even if @autoneg is zero.  They should also allow the advertised
5456a7a1081SBen Hutchings  * pause frame capabilities to be controlled directly through the
5466a7a1081SBen Hutchings  * advertising field of &struct ethtool_cmd.
5476a7a1081SBen Hutchings  *
5486a7a1081SBen Hutchings  * If @autoneg is non-zero, the MAC is configured to send and/or
5496a7a1081SBen Hutchings  * receive pause frames according to the result of autonegotiation.
5506a7a1081SBen Hutchings  * Otherwise, it is configured directly based on the @rx_pause and
5516a7a1081SBen Hutchings  * @tx_pause flags.
552607ca46eSDavid Howells  */
5536a7a1081SBen Hutchings struct ethtool_pauseparam {
5546a7a1081SBen Hutchings 	__u32	cmd;
555607ca46eSDavid Howells 	__u32	autoneg;
556607ca46eSDavid Howells 	__u32	rx_pause;
557607ca46eSDavid Howells 	__u32	tx_pause;
558607ca46eSDavid Howells };
559607ca46eSDavid Howells 
560607ca46eSDavid Howells #define ETH_GSTRING_LEN		32
561fe5df1b9SBen Hutchings 
562fe5df1b9SBen Hutchings /**
563fe5df1b9SBen Hutchings  * enum ethtool_stringset - string set ID
564fe5df1b9SBen Hutchings  * @ETH_SS_TEST: Self-test result names, for use with %ETHTOOL_TEST
565fe5df1b9SBen Hutchings  * @ETH_SS_STATS: Statistic names, for use with %ETHTOOL_GSTATS
566fe5df1b9SBen Hutchings  * @ETH_SS_PRIV_FLAGS: Driver private flag names, for use with
567fe5df1b9SBen Hutchings  *	%ETHTOOL_GPFLAGS and %ETHTOOL_SPFLAGS
568fe5df1b9SBen Hutchings  * @ETH_SS_NTUPLE_FILTERS: Previously used with %ETHTOOL_GRXNTUPLE;
569fe5df1b9SBen Hutchings  *	now deprecated
570fe5df1b9SBen Hutchings  * @ETH_SS_FEATURES: Device feature names
571892311f6SEyal Perry  * @ETH_SS_RSS_HASH_FUNCS: RSS hush function names
572f3a40945SAndrew Lunn  * @ETH_SS_PHY_STATS: Statistic names, for use with %ETHTOOL_GPHYSTATS
5730d27f4e4SRaju Lakkaraju  * @ETH_SS_PHY_TUNABLES: PHY tunable names
574fe5df1b9SBen Hutchings  */
575607ca46eSDavid Howells enum ethtool_stringset {
576607ca46eSDavid Howells 	ETH_SS_TEST		= 0,
577607ca46eSDavid Howells 	ETH_SS_STATS,
578607ca46eSDavid Howells 	ETH_SS_PRIV_FLAGS,
579fe5df1b9SBen Hutchings 	ETH_SS_NTUPLE_FILTERS,
580607ca46eSDavid Howells 	ETH_SS_FEATURES,
581892311f6SEyal Perry 	ETH_SS_RSS_HASH_FUNCS,
582a4244b0cSHadar Hen Zion 	ETH_SS_TUNABLES,
583f3a40945SAndrew Lunn 	ETH_SS_PHY_STATS,
5840d27f4e4SRaju Lakkaraju 	ETH_SS_PHY_TUNABLES,
585607ca46eSDavid Howells };
586607ca46eSDavid Howells 
587fe5df1b9SBen Hutchings /**
588fe5df1b9SBen Hutchings  * struct ethtool_gstrings - string set for data tagging
589fe5df1b9SBen Hutchings  * @cmd: Command number = %ETHTOOL_GSTRINGS
590fe5df1b9SBen Hutchings  * @string_set: String set ID; one of &enum ethtool_stringset
591fe5df1b9SBen Hutchings  * @len: On return, the number of strings in the string set
592fe5df1b9SBen Hutchings  * @data: Buffer for strings.  Each string is null-padded to a size of
593fe5df1b9SBen Hutchings  *	%ETH_GSTRING_LEN.
594fe5df1b9SBen Hutchings  *
595fe5df1b9SBen Hutchings  * Users must use %ETHTOOL_GSSET_INFO to find the number of strings in
596fe5df1b9SBen Hutchings  * the string set.  They must allocate a buffer of the appropriate
597fe5df1b9SBen Hutchings  * size immediately following this structure.
598fe5df1b9SBen Hutchings  */
599607ca46eSDavid Howells struct ethtool_gstrings {
600fe5df1b9SBen Hutchings 	__u32	cmd;
601fe5df1b9SBen Hutchings 	__u32	string_set;
602fe5df1b9SBen Hutchings 	__u32	len;
603607ca46eSDavid Howells 	__u8	data[0];
604607ca46eSDavid Howells };
605607ca46eSDavid Howells 
606fe5df1b9SBen Hutchings /**
607fe5df1b9SBen Hutchings  * struct ethtool_sset_info - string set information
608fe5df1b9SBen Hutchings  * @cmd: Command number = %ETHTOOL_GSSET_INFO
609fe5df1b9SBen Hutchings  * @sset_mask: On entry, a bitmask of string sets to query, with bits
610fe5df1b9SBen Hutchings  *	numbered according to &enum ethtool_stringset.  On return, a
611fe5df1b9SBen Hutchings  *	bitmask of those string sets queried that are supported.
612fe5df1b9SBen Hutchings  * @data: Buffer for string set sizes.  On return, this contains the
613fe5df1b9SBen Hutchings  *	size of each string set that was queried and supported, in
614fe5df1b9SBen Hutchings  *	order of ID.
615fe5df1b9SBen Hutchings  *
616fe5df1b9SBen Hutchings  * Example: The user passes in @sset_mask = 0x7 (sets 0, 1, 2) and on
617fe5df1b9SBen Hutchings  * return @sset_mask == 0x6 (sets 1, 2).  Then @data[0] contains the
618fe5df1b9SBen Hutchings  * size of set 1 and @data[1] contains the size of set 2.
619fe5df1b9SBen Hutchings  *
620fe5df1b9SBen Hutchings  * Users must allocate a buffer of the appropriate size (4 * number of
621fe5df1b9SBen Hutchings  * sets queried) immediately following this structure.
622fe5df1b9SBen Hutchings  */
623607ca46eSDavid Howells struct ethtool_sset_info {
624fe5df1b9SBen Hutchings 	__u32	cmd;
625607ca46eSDavid Howells 	__u32	reserved;
626fe5df1b9SBen Hutchings 	__u64	sset_mask;
627fe5df1b9SBen Hutchings 	__u32	data[0];
628607ca46eSDavid Howells };
629607ca46eSDavid Howells 
630607ca46eSDavid Howells /**
631607ca46eSDavid Howells  * enum ethtool_test_flags - flags definition of ethtool_test
632607ca46eSDavid Howells  * @ETH_TEST_FL_OFFLINE: if set perform online and offline tests, otherwise
633607ca46eSDavid Howells  *	only online tests.
634607ca46eSDavid Howells  * @ETH_TEST_FL_FAILED: Driver set this flag if test fails.
635607ca46eSDavid Howells  * @ETH_TEST_FL_EXTERNAL_LB: Application request to perform external loopback
636607ca46eSDavid Howells  *	test.
637607ca46eSDavid Howells  * @ETH_TEST_FL_EXTERNAL_LB_DONE: Driver performed the external loopback test
638607ca46eSDavid Howells  */
639607ca46eSDavid Howells 
640607ca46eSDavid Howells enum ethtool_test_flags {
641607ca46eSDavid Howells 	ETH_TEST_FL_OFFLINE	= (1 << 0),
642607ca46eSDavid Howells 	ETH_TEST_FL_FAILED	= (1 << 1),
643607ca46eSDavid Howells 	ETH_TEST_FL_EXTERNAL_LB	= (1 << 2),
644607ca46eSDavid Howells 	ETH_TEST_FL_EXTERNAL_LB_DONE	= (1 << 3),
645607ca46eSDavid Howells };
646607ca46eSDavid Howells 
6474e5a62dbSBen Hutchings /**
6484e5a62dbSBen Hutchings  * struct ethtool_test - device self-test invocation
6494e5a62dbSBen Hutchings  * @cmd: Command number = %ETHTOOL_TEST
6504e5a62dbSBen Hutchings  * @flags: A bitmask of flags from &enum ethtool_test_flags.  Some
6514e5a62dbSBen Hutchings  *	flags may be set by the user on entry; others may be set by
6524e5a62dbSBen Hutchings  *	the driver on return.
6534e5a62dbSBen Hutchings  * @len: On return, the number of test results
6544e5a62dbSBen Hutchings  * @data: Array of test results
6554e5a62dbSBen Hutchings  *
6564e5a62dbSBen Hutchings  * Users must use %ETHTOOL_GSSET_INFO or %ETHTOOL_GDRVINFO to find the
6574e5a62dbSBen Hutchings  * number of test results that will be returned.  They must allocate a
6584e5a62dbSBen Hutchings  * buffer of the appropriate size (8 * number of results) immediately
6594e5a62dbSBen Hutchings  * following this structure.
6604e5a62dbSBen Hutchings  */
661607ca46eSDavid Howells struct ethtool_test {
6624e5a62dbSBen Hutchings 	__u32	cmd;
6634e5a62dbSBen Hutchings 	__u32	flags;
664607ca46eSDavid Howells 	__u32	reserved;
6654e5a62dbSBen Hutchings 	__u32	len;
666607ca46eSDavid Howells 	__u64	data[0];
667607ca46eSDavid Howells };
668607ca46eSDavid Howells 
66959091229SBen Hutchings /**
67059091229SBen Hutchings  * struct ethtool_stats - device-specific statistics
67159091229SBen Hutchings  * @cmd: Command number = %ETHTOOL_GSTATS
67259091229SBen Hutchings  * @n_stats: On return, the number of statistics
67359091229SBen Hutchings  * @data: Array of statistics
67459091229SBen Hutchings  *
67559091229SBen Hutchings  * Users must use %ETHTOOL_GSSET_INFO or %ETHTOOL_GDRVINFO to find the
67659091229SBen Hutchings  * number of statistics that will be returned.  They must allocate a
67759091229SBen Hutchings  * buffer of the appropriate size (8 * number of statistics)
67859091229SBen Hutchings  * immediately following this structure.
67959091229SBen Hutchings  */
680607ca46eSDavid Howells struct ethtool_stats {
68159091229SBen Hutchings 	__u32	cmd;
68259091229SBen Hutchings 	__u32	n_stats;
683607ca46eSDavid Howells 	__u64	data[0];
684607ca46eSDavid Howells };
685607ca46eSDavid Howells 
686f432c095SBen Hutchings /**
687f432c095SBen Hutchings  * struct ethtool_perm_addr - permanent hardware address
688f432c095SBen Hutchings  * @cmd: Command number = %ETHTOOL_GPERMADDR
689f432c095SBen Hutchings  * @size: On entry, the size of the buffer.  On return, the size of the
690f432c095SBen Hutchings  *	address.  The command fails if the buffer is too small.
691f432c095SBen Hutchings  * @data: Buffer for the address
692f432c095SBen Hutchings  *
693f432c095SBen Hutchings  * Users must allocate the buffer immediately following this structure.
694f432c095SBen Hutchings  * A buffer size of %MAX_ADDR_LEN should be sufficient for any address
695f432c095SBen Hutchings  * type.
696f432c095SBen Hutchings  */
697607ca46eSDavid Howells struct ethtool_perm_addr {
698f432c095SBen Hutchings 	__u32	cmd;
699607ca46eSDavid Howells 	__u32	size;
700607ca46eSDavid Howells 	__u8	data[0];
701607ca46eSDavid Howells };
702607ca46eSDavid Howells 
703607ca46eSDavid Howells /* boolean flags controlling per-interface behavior characteristics.
704607ca46eSDavid Howells  * When reading, the flag indicates whether or not a certain behavior
705607ca46eSDavid Howells  * is enabled/present.  When writing, the flag indicates whether
706607ca46eSDavid Howells  * or not the driver should turn on (set) or off (clear) a behavior.
707607ca46eSDavid Howells  *
708607ca46eSDavid Howells  * Some behaviors may read-only (unconditionally absent or present).
709607ca46eSDavid Howells  * If such is the case, return EINVAL in the set-flags operation if the
710607ca46eSDavid Howells  * flag differs from the read-only value.
711607ca46eSDavid Howells  */
712607ca46eSDavid Howells enum ethtool_flags {
713607ca46eSDavid Howells 	ETH_FLAG_TXVLAN		= (1 << 7),	/* TX VLAN offload enabled */
714607ca46eSDavid Howells 	ETH_FLAG_RXVLAN		= (1 << 8),	/* RX VLAN offload enabled */
715607ca46eSDavid Howells 	ETH_FLAG_LRO		= (1 << 15),	/* LRO is enabled */
716607ca46eSDavid Howells 	ETH_FLAG_NTUPLE		= (1 << 27),	/* N-tuple filters enabled */
717607ca46eSDavid Howells 	ETH_FLAG_RXHASH		= (1 << 28),
718607ca46eSDavid Howells };
719607ca46eSDavid Howells 
720607ca46eSDavid Howells /* The following structures are for supporting RX network flow
721607ca46eSDavid Howells  * classification and RX n-tuple configuration. Note, all multibyte
722607ca46eSDavid Howells  * fields, e.g., ip4src, ip4dst, psrc, pdst, spi, etc. are expected to
723607ca46eSDavid Howells  * be in network byte order.
724607ca46eSDavid Howells  */
725607ca46eSDavid Howells 
726607ca46eSDavid Howells /**
727607ca46eSDavid Howells  * struct ethtool_tcpip4_spec - flow specification for TCP/IPv4 etc.
728607ca46eSDavid Howells  * @ip4src: Source host
729607ca46eSDavid Howells  * @ip4dst: Destination host
730607ca46eSDavid Howells  * @psrc: Source port
731607ca46eSDavid Howells  * @pdst: Destination port
732607ca46eSDavid Howells  * @tos: Type-of-service
733607ca46eSDavid Howells  *
734607ca46eSDavid Howells  * This can be used to specify a TCP/IPv4, UDP/IPv4 or SCTP/IPv4 flow.
735607ca46eSDavid Howells  */
736607ca46eSDavid Howells struct ethtool_tcpip4_spec {
737607ca46eSDavid Howells 	__be32	ip4src;
738607ca46eSDavid Howells 	__be32	ip4dst;
739607ca46eSDavid Howells 	__be16	psrc;
740607ca46eSDavid Howells 	__be16	pdst;
741607ca46eSDavid Howells 	__u8    tos;
742607ca46eSDavid Howells };
743607ca46eSDavid Howells 
744607ca46eSDavid Howells /**
745607ca46eSDavid Howells  * struct ethtool_ah_espip4_spec - flow specification for IPsec/IPv4
746607ca46eSDavid Howells  * @ip4src: Source host
747607ca46eSDavid Howells  * @ip4dst: Destination host
748607ca46eSDavid Howells  * @spi: Security parameters index
749607ca46eSDavid Howells  * @tos: Type-of-service
750607ca46eSDavid Howells  *
751607ca46eSDavid Howells  * This can be used to specify an IPsec transport or tunnel over IPv4.
752607ca46eSDavid Howells  */
753607ca46eSDavid Howells struct ethtool_ah_espip4_spec {
754607ca46eSDavid Howells 	__be32	ip4src;
755607ca46eSDavid Howells 	__be32	ip4dst;
756607ca46eSDavid Howells 	__be32	spi;
757607ca46eSDavid Howells 	__u8    tos;
758607ca46eSDavid Howells };
759607ca46eSDavid Howells 
760607ca46eSDavid Howells #define	ETH_RX_NFC_IP4	1
761607ca46eSDavid Howells 
762607ca46eSDavid Howells /**
763607ca46eSDavid Howells  * struct ethtool_usrip4_spec - general flow specification for IPv4
764607ca46eSDavid Howells  * @ip4src: Source host
765607ca46eSDavid Howells  * @ip4dst: Destination host
766607ca46eSDavid Howells  * @l4_4_bytes: First 4 bytes of transport (layer 4) header
767607ca46eSDavid Howells  * @tos: Type-of-service
768607ca46eSDavid Howells  * @ip_ver: Value must be %ETH_RX_NFC_IP4; mask must be 0
769607ca46eSDavid Howells  * @proto: Transport protocol number; mask must be 0
770607ca46eSDavid Howells  */
771607ca46eSDavid Howells struct ethtool_usrip4_spec {
772607ca46eSDavid Howells 	__be32	ip4src;
773607ca46eSDavid Howells 	__be32	ip4dst;
774607ca46eSDavid Howells 	__be32	l4_4_bytes;
775607ca46eSDavid Howells 	__u8    tos;
776607ca46eSDavid Howells 	__u8    ip_ver;
777607ca46eSDavid Howells 	__u8    proto;
778607ca46eSDavid Howells };
779607ca46eSDavid Howells 
78072bb6872SEdward Cree /**
78172bb6872SEdward Cree  * struct ethtool_tcpip6_spec - flow specification for TCP/IPv6 etc.
78272bb6872SEdward Cree  * @ip6src: Source host
78372bb6872SEdward Cree  * @ip6dst: Destination host
78472bb6872SEdward Cree  * @psrc: Source port
78572bb6872SEdward Cree  * @pdst: Destination port
78672bb6872SEdward Cree  * @tclass: Traffic Class
78772bb6872SEdward Cree  *
78872bb6872SEdward Cree  * This can be used to specify a TCP/IPv6, UDP/IPv6 or SCTP/IPv6 flow.
78972bb6872SEdward Cree  */
79072bb6872SEdward Cree struct ethtool_tcpip6_spec {
79172bb6872SEdward Cree 	__be32	ip6src[4];
79272bb6872SEdward Cree 	__be32	ip6dst[4];
79372bb6872SEdward Cree 	__be16	psrc;
79472bb6872SEdward Cree 	__be16	pdst;
79572bb6872SEdward Cree 	__u8    tclass;
79672bb6872SEdward Cree };
79772bb6872SEdward Cree 
79872bb6872SEdward Cree /**
79972bb6872SEdward Cree  * struct ethtool_ah_espip6_spec - flow specification for IPsec/IPv6
80072bb6872SEdward Cree  * @ip6src: Source host
80172bb6872SEdward Cree  * @ip6dst: Destination host
80272bb6872SEdward Cree  * @spi: Security parameters index
80372bb6872SEdward Cree  * @tclass: Traffic Class
80472bb6872SEdward Cree  *
80572bb6872SEdward Cree  * This can be used to specify an IPsec transport or tunnel over IPv6.
80672bb6872SEdward Cree  */
80772bb6872SEdward Cree struct ethtool_ah_espip6_spec {
80872bb6872SEdward Cree 	__be32	ip6src[4];
80972bb6872SEdward Cree 	__be32	ip6dst[4];
81072bb6872SEdward Cree 	__be32	spi;
81172bb6872SEdward Cree 	__u8    tclass;
81272bb6872SEdward Cree };
81372bb6872SEdward Cree 
81472bb6872SEdward Cree /**
81572bb6872SEdward Cree  * struct ethtool_usrip6_spec - general flow specification for IPv6
81672bb6872SEdward Cree  * @ip6src: Source host
81772bb6872SEdward Cree  * @ip6dst: Destination host
81872bb6872SEdward Cree  * @l4_4_bytes: First 4 bytes of transport (layer 4) header
81972bb6872SEdward Cree  * @tclass: Traffic Class
82072bb6872SEdward Cree  * @l4_proto: Transport protocol number (nexthdr after any Extension Headers)
82172bb6872SEdward Cree  */
82272bb6872SEdward Cree struct ethtool_usrip6_spec {
82372bb6872SEdward Cree 	__be32	ip6src[4];
82472bb6872SEdward Cree 	__be32	ip6dst[4];
82572bb6872SEdward Cree 	__be32	l4_4_bytes;
82672bb6872SEdward Cree 	__u8    tclass;
82772bb6872SEdward Cree 	__u8    l4_proto;
82872bb6872SEdward Cree };
82972bb6872SEdward Cree 
830607ca46eSDavid Howells union ethtool_flow_union {
831607ca46eSDavid Howells 	struct ethtool_tcpip4_spec		tcp_ip4_spec;
832607ca46eSDavid Howells 	struct ethtool_tcpip4_spec		udp_ip4_spec;
833607ca46eSDavid Howells 	struct ethtool_tcpip4_spec		sctp_ip4_spec;
834607ca46eSDavid Howells 	struct ethtool_ah_espip4_spec		ah_ip4_spec;
835607ca46eSDavid Howells 	struct ethtool_ah_espip4_spec		esp_ip4_spec;
836607ca46eSDavid Howells 	struct ethtool_usrip4_spec		usr_ip4_spec;
83772bb6872SEdward Cree 	struct ethtool_tcpip6_spec		tcp_ip6_spec;
83872bb6872SEdward Cree 	struct ethtool_tcpip6_spec		udp_ip6_spec;
83972bb6872SEdward Cree 	struct ethtool_tcpip6_spec		sctp_ip6_spec;
84072bb6872SEdward Cree 	struct ethtool_ah_espip6_spec		ah_ip6_spec;
84172bb6872SEdward Cree 	struct ethtool_ah_espip6_spec		esp_ip6_spec;
84272bb6872SEdward Cree 	struct ethtool_usrip6_spec		usr_ip6_spec;
843607ca46eSDavid Howells 	struct ethhdr				ether_spec;
844d4676eacSYan Burman 	__u8					hdata[52];
845607ca46eSDavid Howells };
846607ca46eSDavid Howells 
847dc2e5734SYan Burman /**
848dc2e5734SYan Burman  * struct ethtool_flow_ext - additional RX flow fields
849dc2e5734SYan Burman  * @h_dest: destination MAC address
850dc2e5734SYan Burman  * @vlan_etype: VLAN EtherType
851dc2e5734SYan Burman  * @vlan_tci: VLAN tag control information
852dc2e5734SYan Burman  * @data: user defined data
853dc2e5734SYan Burman  *
854dc2e5734SYan Burman  * Note, @vlan_etype, @vlan_tci, and @data are only valid if %FLOW_EXT
855dc2e5734SYan Burman  * is set in &struct ethtool_rx_flow_spec @flow_type.
856dc2e5734SYan Burman  * @h_dest is valid if %FLOW_MAC_EXT is set.
857dc2e5734SYan Burman  */
858607ca46eSDavid Howells struct ethtool_flow_ext {
859d4676eacSYan Burman 	__u8		padding[2];
860dc2e5734SYan Burman 	unsigned char	h_dest[ETH_ALEN];
861607ca46eSDavid Howells 	__be16		vlan_etype;
862607ca46eSDavid Howells 	__be16		vlan_tci;
863607ca46eSDavid Howells 	__be32		data[2];
864607ca46eSDavid Howells };
865607ca46eSDavid Howells 
866607ca46eSDavid Howells /**
867607ca46eSDavid Howells  * struct ethtool_rx_flow_spec - classification rule for RX flows
868607ca46eSDavid Howells  * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
869607ca46eSDavid Howells  * @h_u: Flow fields to match (dependent on @flow_type)
870607ca46eSDavid Howells  * @h_ext: Additional fields to match
871607ca46eSDavid Howells  * @m_u: Masks for flow field bits to be matched
872607ca46eSDavid Howells  * @m_ext: Masks for additional field bits to be matched
873607ca46eSDavid Howells  *	Note, all additional fields must be ignored unless @flow_type
874dc2e5734SYan Burman  *	includes the %FLOW_EXT or %FLOW_MAC_EXT flag
875dc2e5734SYan Burman  *	(see &struct ethtool_flow_ext description).
876607ca46eSDavid Howells  * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC
8776cfef793SFlorian Fainelli  *	if packets should be discarded, or %RX_CLS_FLOW_WAKE if the
8786cfef793SFlorian Fainelli  *	packets should be used for Wake-on-LAN with %WAKE_FILTER
879607ca46eSDavid Howells  * @location: Location of rule in the table.  Locations must be
880607ca46eSDavid Howells  *	numbered such that a flow matching multiple rules will be
881607ca46eSDavid Howells  *	classified according to the first (lowest numbered) rule.
882607ca46eSDavid Howells  */
883607ca46eSDavid Howells struct ethtool_rx_flow_spec {
884607ca46eSDavid Howells 	__u32		flow_type;
885607ca46eSDavid Howells 	union ethtool_flow_union h_u;
886607ca46eSDavid Howells 	struct ethtool_flow_ext h_ext;
887607ca46eSDavid Howells 	union ethtool_flow_union m_u;
888607ca46eSDavid Howells 	struct ethtool_flow_ext m_ext;
889607ca46eSDavid Howells 	__u64		ring_cookie;
890607ca46eSDavid Howells 	__u32		location;
891607ca46eSDavid Howells };
892607ca46eSDavid Howells 
89354e8cb78SStephen Hemminger /* How rings are laid out when accessing virtual functions or
8948cf6f497SJohn Fastabend  * offloaded queues is device specific. To allow users to do flow
8958cf6f497SJohn Fastabend  * steering and specify these queues the ring cookie is partitioned
8968cf6f497SJohn Fastabend  * into a 32bit queue index with an 8 bit virtual function id.
8978cf6f497SJohn Fastabend  * This also leaves the 3bytes for further specifiers. It is possible
8988cf6f497SJohn Fastabend  * future devices may support more than 256 virtual functions if
8998cf6f497SJohn Fastabend  * devices start supporting PCIe w/ARI. However at the moment I
9008cf6f497SJohn Fastabend  * do not know of any devices that support this so I do not reserve
9018cf6f497SJohn Fastabend  * space for this at this time. If a future patch consumes the next
90254e8cb78SStephen Hemminger  * byte it should be aware of this possibility.
9038cf6f497SJohn Fastabend  */
9048cf6f497SJohn Fastabend #define ETHTOOL_RX_FLOW_SPEC_RING	0x00000000FFFFFFFFLL
9058cf6f497SJohn Fastabend #define ETHTOOL_RX_FLOW_SPEC_RING_VF	0x000000FF00000000LL
9068cf6f497SJohn Fastabend #define ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF 32
9078cf6f497SJohn Fastabend static inline __u64 ethtool_get_flow_spec_ring(__u64 ring_cookie)
9088cf6f497SJohn Fastabend {
9098cf6f497SJohn Fastabend 	return ETHTOOL_RX_FLOW_SPEC_RING & ring_cookie;
910d89d4155SFlorian Fainelli }
9118cf6f497SJohn Fastabend 
9128cf6f497SJohn Fastabend static inline __u64 ethtool_get_flow_spec_ring_vf(__u64 ring_cookie)
9138cf6f497SJohn Fastabend {
9148cf6f497SJohn Fastabend 	return (ETHTOOL_RX_FLOW_SPEC_RING_VF & ring_cookie) >>
9158cf6f497SJohn Fastabend 				ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF;
916d89d4155SFlorian Fainelli }
9178cf6f497SJohn Fastabend 
918607ca46eSDavid Howells /**
919607ca46eSDavid Howells  * struct ethtool_rxnfc - command to get or set RX flow classification rules
920607ca46eSDavid Howells  * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,
921607ca46eSDavid Howells  *	%ETHTOOL_GRXRINGS, %ETHTOOL_GRXCLSRLCNT, %ETHTOOL_GRXCLSRULE,
922607ca46eSDavid Howells  *	%ETHTOOL_GRXCLSRLALL, %ETHTOOL_SRXCLSRLDEL or %ETHTOOL_SRXCLSRLINS
923607ca46eSDavid Howells  * @flow_type: Type of flow to be affected, e.g. %TCP_V4_FLOW
924607ca46eSDavid Howells  * @data: Command-dependent value
925607ca46eSDavid Howells  * @fs: Flow classification rule
92684a1d9c4SEdward Cree  * @rss_context: RSS context to be affected
927607ca46eSDavid Howells  * @rule_cnt: Number of rules to be affected
928607ca46eSDavid Howells  * @rule_locs: Array of used rule locations
929607ca46eSDavid Howells  *
930607ca46eSDavid Howells  * For %ETHTOOL_GRXFH and %ETHTOOL_SRXFH, @data is a bitmask indicating
931607ca46eSDavid Howells  * the fields included in the flow hash, e.g. %RXH_IP_SRC.  The following
93284a1d9c4SEdward Cree  * structure fields must not be used, except that if @flow_type includes
93384a1d9c4SEdward Cree  * the %FLOW_RSS flag, then @rss_context determines which RSS context to
93484a1d9c4SEdward Cree  * act on.
935607ca46eSDavid Howells  *
936607ca46eSDavid Howells  * For %ETHTOOL_GRXRINGS, @data is set to the number of RX rings/queues
937607ca46eSDavid Howells  * on return.
938607ca46eSDavid Howells  *
939607ca46eSDavid Howells  * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined
940607ca46eSDavid Howells  * rules on return.  If @data is non-zero on return then it is the
941607ca46eSDavid Howells  * size of the rule table, plus the flag %RX_CLS_LOC_SPECIAL if the
942607ca46eSDavid Howells  * driver supports any special location values.  If that flag is not
943607ca46eSDavid Howells  * set in @data then special location values should not be used.
944607ca46eSDavid Howells  *
945607ca46eSDavid Howells  * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the location of an
94684a1d9c4SEdward Cree  * existing rule on entry and @fs contains the rule on return; if
94784a1d9c4SEdward Cree  * @fs.@flow_type includes the %FLOW_RSS flag, then @rss_context is
94884a1d9c4SEdward Cree  * filled with the RSS context ID associated with the rule.
949607ca46eSDavid Howells  *
950607ca46eSDavid Howells  * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the
951607ca46eSDavid Howells  * user buffer for @rule_locs on entry.  On return, @data is the size
952607ca46eSDavid Howells  * of the rule table, @rule_cnt is the number of defined rules, and
953607ca46eSDavid Howells  * @rule_locs contains the locations of the defined rules.  Drivers
954607ca46eSDavid Howells  * must use the second parameter to get_rxnfc() instead of @rule_locs.
955607ca46eSDavid Howells  *
956607ca46eSDavid Howells  * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update.
957607ca46eSDavid Howells  * @fs.@location either specifies the location to use or is a special
958607ca46eSDavid Howells  * location value with %RX_CLS_LOC_SPECIAL flag set.  On return,
95984a1d9c4SEdward Cree  * @fs.@location is the actual rule location.  If @fs.@flow_type
96084a1d9c4SEdward Cree  * includes the %FLOW_RSS flag, @rss_context is the RSS context ID to
96184a1d9c4SEdward Cree  * use for flow spreading traffic which matches this rule.  The value
96284a1d9c4SEdward Cree  * from the rxfh indirection table will be added to @fs.@ring_cookie
96384a1d9c4SEdward Cree  * to choose which ring to deliver to.
964607ca46eSDavid Howells  *
965607ca46eSDavid Howells  * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the location of an
966607ca46eSDavid Howells  * existing rule on entry.
967607ca46eSDavid Howells  *
968607ca46eSDavid Howells  * A driver supporting the special location values for
969607ca46eSDavid Howells  * %ETHTOOL_SRXCLSRLINS may add the rule at any suitable unused
970607ca46eSDavid Howells  * location, and may remove a rule at a later location (lower
971607ca46eSDavid Howells  * priority) that matches exactly the same set of flows.  The special
972073e3cf2SBen Hutchings  * values are %RX_CLS_LOC_ANY, selecting any location;
973607ca46eSDavid Howells  * %RX_CLS_LOC_FIRST, selecting the first suitable location (maximum
974607ca46eSDavid Howells  * priority); and %RX_CLS_LOC_LAST, selecting the last suitable
975607ca46eSDavid Howells  * location (minimum priority).  Additional special values may be
976607ca46eSDavid Howells  * defined in future and drivers must return -%EINVAL for any
977607ca46eSDavid Howells  * unrecognised value.
978607ca46eSDavid Howells  */
979607ca46eSDavid Howells struct ethtool_rxnfc {
980607ca46eSDavid Howells 	__u32				cmd;
981607ca46eSDavid Howells 	__u32				flow_type;
982607ca46eSDavid Howells 	__u64				data;
983607ca46eSDavid Howells 	struct ethtool_rx_flow_spec	fs;
98484a1d9c4SEdward Cree 	union {
985607ca46eSDavid Howells 		__u32			rule_cnt;
98684a1d9c4SEdward Cree 		__u32			rss_context;
98784a1d9c4SEdward Cree 	};
988607ca46eSDavid Howells 	__u32				rule_locs[0];
989607ca46eSDavid Howells };
990607ca46eSDavid Howells 
991607ca46eSDavid Howells 
992607ca46eSDavid Howells /**
993607ca46eSDavid Howells  * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection
994607ca46eSDavid Howells  * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR
995607ca46eSDavid Howells  * @size: On entry, the array size of the user buffer, which may be zero.
996607ca46eSDavid Howells  *	On return from %ETHTOOL_GRXFHINDIR, the array size of the hardware
997607ca46eSDavid Howells  *	indirection table.
998607ca46eSDavid Howells  * @ring_index: RX ring/queue index for each hash value
999607ca46eSDavid Howells  *
1000607ca46eSDavid Howells  * For %ETHTOOL_GRXFHINDIR, a @size of zero means that only the size
1001607ca46eSDavid Howells  * should be returned.  For %ETHTOOL_SRXFHINDIR, a @size of zero means
1002607ca46eSDavid Howells  * the table should be reset to default values.  This last feature
1003607ca46eSDavid Howells  * is not supported by the original implementations.
1004607ca46eSDavid Howells  */
1005607ca46eSDavid Howells struct ethtool_rxfh_indir {
1006607ca46eSDavid Howells 	__u32	cmd;
1007607ca46eSDavid Howells 	__u32	size;
1008607ca46eSDavid Howells 	__u32	ring_index[0];
1009607ca46eSDavid Howells };
1010607ca46eSDavid Howells 
1011607ca46eSDavid Howells /**
10123de0b592SVenkata Duvvuru  * struct ethtool_rxfh - command to get/set RX flow hash indir or/and hash key.
10133de0b592SVenkata Duvvuru  * @cmd: Specific command number - %ETHTOOL_GRSSH or %ETHTOOL_SRSSH
101484a1d9c4SEdward Cree  * @rss_context: RSS context identifier.  Context 0 is the default for normal
101584a1d9c4SEdward Cree  *	traffic; other contexts can be referenced as the destination for RX flow
101684a1d9c4SEdward Cree  *	classification rules.  %ETH_RXFH_CONTEXT_ALLOC is used with command
101784a1d9c4SEdward Cree  *	%ETHTOOL_SRSSH to allocate a new RSS context; on return this field will
101884a1d9c4SEdward Cree  *	contain the ID of the newly allocated context.
101938c891a4SBen Hutchings  * @indir_size: On entry, the array size of the user buffer for the
102038c891a4SBen Hutchings  *	indirection table, which may be zero, or (for %ETHTOOL_SRSSH),
102138c891a4SBen Hutchings  *	%ETH_RXFH_INDIR_NO_CHANGE.  On return from %ETHTOOL_GRSSH,
102238c891a4SBen Hutchings  *	the array size of the hardware indirection table.
102338c891a4SBen Hutchings  * @key_size: On entry, the array size of the user buffer for the hash key,
102438c891a4SBen Hutchings  *	which may be zero.  On return from %ETHTOOL_GRSSH, the size of the
102538c891a4SBen Hutchings  *	hardware hash key.
1026892311f6SEyal Perry  * @hfunc: Defines the current RSS hash function used by HW (or to be set to).
1027892311f6SEyal Perry  *	Valid values are one of the %ETH_RSS_HASH_*.
10283de0b592SVenkata Duvvuru  * @rsvd:	Reserved for future extensions.
10293de0b592SVenkata Duvvuru  * @rss_config: RX ring/queue index for each hash value i.e., indirection table
103038c891a4SBen Hutchings  *	of @indir_size __u32 elements, followed by hash key of @key_size
103138c891a4SBen Hutchings  *	bytes.
10323de0b592SVenkata Duvvuru  *
10333de0b592SVenkata Duvvuru  * For %ETHTOOL_GRSSH, a @indir_size and key_size of zero means that only the
10347455fa24SBen Hutchings  * size should be returned.  For %ETHTOOL_SRSSH, an @indir_size of
10357455fa24SBen Hutchings  * %ETH_RXFH_INDIR_NO_CHANGE means that indir table setting is not requested
10367455fa24SBen Hutchings  * and a @indir_size of zero means the indir table should be reset to default
103784a1d9c4SEdward Cree  * values (if @rss_context == 0) or that the RSS context should be deleted.
103884a1d9c4SEdward Cree  * An hfunc of zero means that hash function setting is not requested.
10393de0b592SVenkata Duvvuru  */
10403de0b592SVenkata Duvvuru struct ethtool_rxfh {
10413de0b592SVenkata Duvvuru 	__u32   cmd;
10423de0b592SVenkata Duvvuru 	__u32	rss_context;
10433de0b592SVenkata Duvvuru 	__u32   indir_size;
10443de0b592SVenkata Duvvuru 	__u32   key_size;
1045892311f6SEyal Perry 	__u8	hfunc;
1046892311f6SEyal Perry 	__u8	rsvd8[3];
1047892311f6SEyal Perry 	__u32	rsvd32;
10483de0b592SVenkata Duvvuru 	__u32   rss_config[0];
10493de0b592SVenkata Duvvuru };
105084a1d9c4SEdward Cree #define ETH_RXFH_CONTEXT_ALLOC		0xffffffff
10517455fa24SBen Hutchings #define ETH_RXFH_INDIR_NO_CHANGE	0xffffffff
10523de0b592SVenkata Duvvuru 
10533de0b592SVenkata Duvvuru /**
1054607ca46eSDavid Howells  * struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter
1055607ca46eSDavid Howells  * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
1056607ca46eSDavid Howells  * @h_u: Flow field values to match (dependent on @flow_type)
1057607ca46eSDavid Howells  * @m_u: Masks for flow field value bits to be ignored
1058607ca46eSDavid Howells  * @vlan_tag: VLAN tag to match
1059607ca46eSDavid Howells  * @vlan_tag_mask: Mask for VLAN tag bits to be ignored
1060607ca46eSDavid Howells  * @data: Driver-dependent data to match
1061607ca46eSDavid Howells  * @data_mask: Mask for driver-dependent data bits to be ignored
1062607ca46eSDavid Howells  * @action: RX ring/queue index to deliver to (non-negative) or other action
1063607ca46eSDavid Howells  *	(negative, e.g. %ETHTOOL_RXNTUPLE_ACTION_DROP)
1064607ca46eSDavid Howells  *
1065607ca46eSDavid Howells  * For flow types %TCP_V4_FLOW, %UDP_V4_FLOW and %SCTP_V4_FLOW, where
1066607ca46eSDavid Howells  * a field value and mask are both zero this is treated as if all mask
1067607ca46eSDavid Howells  * bits are set i.e. the field is ignored.
1068607ca46eSDavid Howells  */
1069607ca46eSDavid Howells struct ethtool_rx_ntuple_flow_spec {
1070607ca46eSDavid Howells 	__u32		 flow_type;
1071607ca46eSDavid Howells 	union {
1072607ca46eSDavid Howells 		struct ethtool_tcpip4_spec		tcp_ip4_spec;
1073607ca46eSDavid Howells 		struct ethtool_tcpip4_spec		udp_ip4_spec;
1074607ca46eSDavid Howells 		struct ethtool_tcpip4_spec		sctp_ip4_spec;
1075607ca46eSDavid Howells 		struct ethtool_ah_espip4_spec		ah_ip4_spec;
1076607ca46eSDavid Howells 		struct ethtool_ah_espip4_spec		esp_ip4_spec;
1077607ca46eSDavid Howells 		struct ethtool_usrip4_spec		usr_ip4_spec;
1078607ca46eSDavid Howells 		struct ethhdr				ether_spec;
1079607ca46eSDavid Howells 		__u8					hdata[72];
1080607ca46eSDavid Howells 	} h_u, m_u;
1081607ca46eSDavid Howells 
1082607ca46eSDavid Howells 	__u16	        vlan_tag;
1083607ca46eSDavid Howells 	__u16	        vlan_tag_mask;
1084607ca46eSDavid Howells 	__u64		data;
1085607ca46eSDavid Howells 	__u64		data_mask;
1086607ca46eSDavid Howells 
1087607ca46eSDavid Howells 	__s32		action;
1088607ca46eSDavid Howells #define ETHTOOL_RXNTUPLE_ACTION_DROP	(-1)	/* drop packet */
1089607ca46eSDavid Howells #define ETHTOOL_RXNTUPLE_ACTION_CLEAR	(-2)	/* clear filter */
1090607ca46eSDavid Howells };
1091607ca46eSDavid Howells 
1092607ca46eSDavid Howells /**
1093607ca46eSDavid Howells  * struct ethtool_rx_ntuple - command to set or clear RX flow filter
1094607ca46eSDavid Howells  * @cmd: Command number - %ETHTOOL_SRXNTUPLE
1095607ca46eSDavid Howells  * @fs: Flow filter specification
1096607ca46eSDavid Howells  */
1097607ca46eSDavid Howells struct ethtool_rx_ntuple {
1098607ca46eSDavid Howells 	__u32					cmd;
1099607ca46eSDavid Howells 	struct ethtool_rx_ntuple_flow_spec	fs;
1100607ca46eSDavid Howells };
1101607ca46eSDavid Howells 
1102607ca46eSDavid Howells #define ETHTOOL_FLASH_MAX_FILENAME	128
1103607ca46eSDavid Howells enum ethtool_flash_op_type {
1104607ca46eSDavid Howells 	ETHTOOL_FLASH_ALL_REGIONS	= 0,
1105607ca46eSDavid Howells };
1106607ca46eSDavid Howells 
1107607ca46eSDavid Howells /* for passing firmware flashing related parameters */
1108607ca46eSDavid Howells struct ethtool_flash {
1109607ca46eSDavid Howells 	__u32	cmd;
1110607ca46eSDavid Howells 	__u32	region;
1111607ca46eSDavid Howells 	char	data[ETHTOOL_FLASH_MAX_FILENAME];
1112607ca46eSDavid Howells };
1113607ca46eSDavid Howells 
1114607ca46eSDavid Howells /**
1115607ca46eSDavid Howells  * struct ethtool_dump - used for retrieving, setting device dump
1116607ca46eSDavid Howells  * @cmd: Command number - %ETHTOOL_GET_DUMP_FLAG, %ETHTOOL_GET_DUMP_DATA, or
1117607ca46eSDavid Howells  * 	%ETHTOOL_SET_DUMP
1118607ca46eSDavid Howells  * @version: FW version of the dump, filled in by driver
1119607ca46eSDavid Howells  * @flag: driver dependent flag for dump setting, filled in by driver during
1120607ca46eSDavid Howells  *        get and filled in by ethtool for set operation.
1121607ca46eSDavid Howells  *        flag must be initialized by macro ETH_FW_DUMP_DISABLE value when
1122607ca46eSDavid Howells  *        firmware dump is disabled.
1123607ca46eSDavid Howells  * @len: length of dump data, used as the length of the user buffer on entry to
1124607ca46eSDavid Howells  * 	 %ETHTOOL_GET_DUMP_DATA and this is returned as dump length by driver
1125607ca46eSDavid Howells  * 	 for %ETHTOOL_GET_DUMP_FLAG command
1126607ca46eSDavid Howells  * @data: data collected for get dump data operation
1127607ca46eSDavid Howells  */
1128607ca46eSDavid Howells struct ethtool_dump {
1129607ca46eSDavid Howells 	__u32	cmd;
1130607ca46eSDavid Howells 	__u32	version;
1131607ca46eSDavid Howells 	__u32	flag;
1132607ca46eSDavid Howells 	__u32	len;
1133607ca46eSDavid Howells 	__u8	data[0];
1134607ca46eSDavid Howells };
1135607ca46eSDavid Howells 
1136ba569dc3SBen Hutchings #define ETH_FW_DUMP_DISABLE 0
1137ba569dc3SBen Hutchings 
1138607ca46eSDavid Howells /* for returning and changing feature sets */
1139607ca46eSDavid Howells 
1140607ca46eSDavid Howells /**
1141607ca46eSDavid Howells  * struct ethtool_get_features_block - block with state of 32 features
1142607ca46eSDavid Howells  * @available: mask of changeable features
1143607ca46eSDavid Howells  * @requested: mask of features requested to be enabled if possible
1144607ca46eSDavid Howells  * @active: mask of currently enabled features
1145607ca46eSDavid Howells  * @never_changed: mask of features not changeable for any device
1146607ca46eSDavid Howells  */
1147607ca46eSDavid Howells struct ethtool_get_features_block {
1148607ca46eSDavid Howells 	__u32	available;
1149607ca46eSDavid Howells 	__u32	requested;
1150607ca46eSDavid Howells 	__u32	active;
1151607ca46eSDavid Howells 	__u32	never_changed;
1152607ca46eSDavid Howells };
1153607ca46eSDavid Howells 
1154607ca46eSDavid Howells /**
1155607ca46eSDavid Howells  * struct ethtool_gfeatures - command to get state of device's features
1156607ca46eSDavid Howells  * @cmd: command number = %ETHTOOL_GFEATURES
1157073e3cf2SBen Hutchings  * @size: On entry, the number of elements in the features[] array;
1158073e3cf2SBen Hutchings  *	on return, the number of elements in features[] needed to hold
1159073e3cf2SBen Hutchings  *	all features
1160607ca46eSDavid Howells  * @features: state of features
1161607ca46eSDavid Howells  */
1162607ca46eSDavid Howells struct ethtool_gfeatures {
1163607ca46eSDavid Howells 	__u32	cmd;
1164607ca46eSDavid Howells 	__u32	size;
1165607ca46eSDavid Howells 	struct ethtool_get_features_block features[0];
1166607ca46eSDavid Howells };
1167607ca46eSDavid Howells 
1168607ca46eSDavid Howells /**
1169607ca46eSDavid Howells  * struct ethtool_set_features_block - block with request for 32 features
1170607ca46eSDavid Howells  * @valid: mask of features to be changed
1171607ca46eSDavid Howells  * @requested: values of features to be changed
1172607ca46eSDavid Howells  */
1173607ca46eSDavid Howells struct ethtool_set_features_block {
1174607ca46eSDavid Howells 	__u32	valid;
1175607ca46eSDavid Howells 	__u32	requested;
1176607ca46eSDavid Howells };
1177607ca46eSDavid Howells 
1178607ca46eSDavid Howells /**
1179607ca46eSDavid Howells  * struct ethtool_sfeatures - command to request change in device's features
1180607ca46eSDavid Howells  * @cmd: command number = %ETHTOOL_SFEATURES
1181607ca46eSDavid Howells  * @size: array size of the features[] array
1182607ca46eSDavid Howells  * @features: feature change masks
1183607ca46eSDavid Howells  */
1184607ca46eSDavid Howells struct ethtool_sfeatures {
1185607ca46eSDavid Howells 	__u32	cmd;
1186607ca46eSDavid Howells 	__u32	size;
1187607ca46eSDavid Howells 	struct ethtool_set_features_block features[0];
1188607ca46eSDavid Howells };
1189607ca46eSDavid Howells 
1190607ca46eSDavid Howells /**
1191607ca46eSDavid Howells  * struct ethtool_ts_info - holds a device's timestamping and PHC association
1192607ca46eSDavid Howells  * @cmd: command number = %ETHTOOL_GET_TS_INFO
1193607ca46eSDavid Howells  * @so_timestamping: bit mask of the sum of the supported SO_TIMESTAMPING flags
1194607ca46eSDavid Howells  * @phc_index: device index of the associated PHC, or -1 if there is none
1195607ca46eSDavid Howells  * @tx_types: bit mask of the supported hwtstamp_tx_types enumeration values
1196607ca46eSDavid Howells  * @rx_filters: bit mask of the supported hwtstamp_rx_filters enumeration values
1197607ca46eSDavid Howells  *
1198607ca46eSDavid Howells  * The bits in the 'tx_types' and 'rx_filters' fields correspond to
1199607ca46eSDavid Howells  * the 'hwtstamp_tx_types' and 'hwtstamp_rx_filters' enumeration values,
1200607ca46eSDavid Howells  * respectively.  For example, if the device supports HWTSTAMP_TX_ON,
1201607ca46eSDavid Howells  * then (1 << HWTSTAMP_TX_ON) in 'tx_types' will be set.
1202eff3cddcSJacob Keller  *
1203eff3cddcSJacob Keller  * Drivers should only report the filters they actually support without
1204eff3cddcSJacob Keller  * upscaling in the SIOCSHWTSTAMP ioctl. If the SIOCSHWSTAMP request for
1205eff3cddcSJacob Keller  * HWTSTAMP_FILTER_V1_SYNC is supported by HWTSTAMP_FILTER_V1_EVENT, then the
1206eff3cddcSJacob Keller  * driver should only report HWTSTAMP_FILTER_V1_EVENT in this op.
1207607ca46eSDavid Howells  */
1208607ca46eSDavid Howells struct ethtool_ts_info {
1209607ca46eSDavid Howells 	__u32	cmd;
1210607ca46eSDavid Howells 	__u32	so_timestamping;
1211607ca46eSDavid Howells 	__s32	phc_index;
1212607ca46eSDavid Howells 	__u32	tx_types;
1213607ca46eSDavid Howells 	__u32	tx_reserved[3];
1214607ca46eSDavid Howells 	__u32	rx_filters;
1215607ca46eSDavid Howells 	__u32	rx_reserved[3];
1216607ca46eSDavid Howells };
1217607ca46eSDavid Howells 
1218607ca46eSDavid Howells /*
1219607ca46eSDavid Howells  * %ETHTOOL_SFEATURES changes features present in features[].valid to the
1220607ca46eSDavid Howells  * values of corresponding bits in features[].requested. Bits in .requested
1221607ca46eSDavid Howells  * not set in .valid or not changeable are ignored.
1222607ca46eSDavid Howells  *
1223607ca46eSDavid Howells  * Returns %EINVAL when .valid contains undefined or never-changeable bits
1224607ca46eSDavid Howells  * or size is not equal to required number of features words (32-bit blocks).
1225607ca46eSDavid Howells  * Returns >= 0 if request was completed; bits set in the value mean:
1226607ca46eSDavid Howells  *   %ETHTOOL_F_UNSUPPORTED - there were bits set in .valid that are not
1227607ca46eSDavid Howells  *	changeable (not present in %ETHTOOL_GFEATURES' features[].available)
1228607ca46eSDavid Howells  *	those bits were ignored.
1229607ca46eSDavid Howells  *   %ETHTOOL_F_WISH - some or all changes requested were recorded but the
1230607ca46eSDavid Howells  *      resulting state of bits masked by .valid is not equal to .requested.
1231607ca46eSDavid Howells  *      Probably there are other device-specific constraints on some features
1232607ca46eSDavid Howells  *      in the set. When %ETHTOOL_F_UNSUPPORTED is set, .valid is considered
1233607ca46eSDavid Howells  *      here as though ignored bits were cleared.
1234607ca46eSDavid Howells  *   %ETHTOOL_F_COMPAT - some or all changes requested were made by calling
1235607ca46eSDavid Howells  *      compatibility functions. Requested offload state cannot be properly
1236607ca46eSDavid Howells  *      managed by kernel.
1237607ca46eSDavid Howells  *
1238607ca46eSDavid Howells  * Meaning of bits in the masks are obtained by %ETHTOOL_GSSET_INFO (number of
1239607ca46eSDavid Howells  * bits in the arrays - always multiple of 32) and %ETHTOOL_GSTRINGS commands
1240607ca46eSDavid Howells  * for ETH_SS_FEATURES string set. First entry in the table corresponds to least
1241607ca46eSDavid Howells  * significant bit in features[0] fields. Empty strings mark undefined features.
1242607ca46eSDavid Howells  */
1243607ca46eSDavid Howells enum ethtool_sfeatures_retval_bits {
1244607ca46eSDavid Howells 	ETHTOOL_F_UNSUPPORTED__BIT,
1245607ca46eSDavid Howells 	ETHTOOL_F_WISH__BIT,
1246607ca46eSDavid Howells 	ETHTOOL_F_COMPAT__BIT,
1247607ca46eSDavid Howells };
1248607ca46eSDavid Howells 
1249607ca46eSDavid Howells #define ETHTOOL_F_UNSUPPORTED   (1 << ETHTOOL_F_UNSUPPORTED__BIT)
1250607ca46eSDavid Howells #define ETHTOOL_F_WISH          (1 << ETHTOOL_F_WISH__BIT)
1251607ca46eSDavid Howells #define ETHTOOL_F_COMPAT        (1 << ETHTOOL_F_COMPAT__BIT)
1252607ca46eSDavid Howells 
1253ac2c7ad0SKan Liang #define MAX_NUM_QUEUE		4096
1254ac2c7ad0SKan Liang 
1255ac2c7ad0SKan Liang /**
1256ac2c7ad0SKan Liang  * struct ethtool_per_queue_op - apply sub command to the queues in mask.
1257ac2c7ad0SKan Liang  * @cmd: ETHTOOL_PERQUEUE
1258ac2c7ad0SKan Liang  * @sub_command: the sub command which apply to each queues
1259ac2c7ad0SKan Liang  * @queue_mask: Bitmap of the queues which sub command apply to
1260ac2c7ad0SKan Liang  * @data: A complete command structure following for each of the queues addressed
1261ac2c7ad0SKan Liang  */
1262ac2c7ad0SKan Liang struct ethtool_per_queue_op {
1263ac2c7ad0SKan Liang 	__u32	cmd;
1264ac2c7ad0SKan Liang 	__u32	sub_command;
1265b5d3755aSNicolas Dichtel 	__u32	queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)];
1266ac2c7ad0SKan Liang 	char	data[];
1267ac2c7ad0SKan Liang };
1268607ca46eSDavid Howells 
12691a5f3da2SVidya Sagar Ravipati /**
12701a5f3da2SVidya Sagar Ravipati  * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters
12711a5f3da2SVidya Sagar Ravipati  * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM
12721a5f3da2SVidya Sagar Ravipati  * @active_fec: FEC mode which is active on porte
12731a5f3da2SVidya Sagar Ravipati  * @fec: Bitmask of supported/configured FEC modes
12741a5f3da2SVidya Sagar Ravipati  * @rsvd: Reserved for future extensions. i.e FEC bypass feature.
12751a5f3da2SVidya Sagar Ravipati  *
12761a5f3da2SVidya Sagar Ravipati  * Drivers should reject a non-zero setting of @autoneg when
12771a5f3da2SVidya Sagar Ravipati  * autoneogotiation is disabled (or not supported) for the link.
12781a5f3da2SVidya Sagar Ravipati  *
12791a5f3da2SVidya Sagar Ravipati  */
12801a5f3da2SVidya Sagar Ravipati struct ethtool_fecparam {
12811a5f3da2SVidya Sagar Ravipati 	__u32   cmd;
12821a5f3da2SVidya Sagar Ravipati 	/* bitmask of FEC modes */
12831a5f3da2SVidya Sagar Ravipati 	__u32   active_fec;
12841a5f3da2SVidya Sagar Ravipati 	__u32   fec;
12851a5f3da2SVidya Sagar Ravipati 	__u32   reserved;
12861a5f3da2SVidya Sagar Ravipati };
12871a5f3da2SVidya Sagar Ravipati 
12881a5f3da2SVidya Sagar Ravipati /**
12891a5f3da2SVidya Sagar Ravipati  * enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration
12901a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_NONE: FEC mode configuration is not supported
12911a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_AUTO: Default/Best FEC mode provided by driver
12921a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_OFF: No FEC Mode
12931a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_RS: Reed-Solomon Forward Error Detection mode
12941a5f3da2SVidya Sagar Ravipati  * @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon Forward Error Detection mode
12951a5f3da2SVidya Sagar Ravipati  */
12961a5f3da2SVidya Sagar Ravipati enum ethtool_fec_config_bits {
12971a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_NONE_BIT,
12981a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_AUTO_BIT,
12991a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_OFF_BIT,
13001a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_RS_BIT,
13011a5f3da2SVidya Sagar Ravipati 	ETHTOOL_FEC_BASER_BIT,
13021a5f3da2SVidya Sagar Ravipati };
13031a5f3da2SVidya Sagar Ravipati 
13041a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_NONE		(1 << ETHTOOL_FEC_NONE_BIT)
13051a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_AUTO		(1 << ETHTOOL_FEC_AUTO_BIT)
13061a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_OFF			(1 << ETHTOOL_FEC_OFF_BIT)
13071a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_RS			(1 << ETHTOOL_FEC_RS_BIT)
13081a5f3da2SVidya Sagar Ravipati #define ETHTOOL_FEC_BASER		(1 << ETHTOOL_FEC_BASER_BIT)
13091a5f3da2SVidya Sagar Ravipati 
1310607ca46eSDavid Howells /* CMDs currently supported */
13113f1ac7a7SDavid Decotigny #define ETHTOOL_GSET		0x00000001 /* DEPRECATED, Get settings.
13123f1ac7a7SDavid Decotigny 					    * Please use ETHTOOL_GLINKSETTINGS
13133f1ac7a7SDavid Decotigny 					    */
13143f1ac7a7SDavid Decotigny #define ETHTOOL_SSET		0x00000002 /* DEPRECATED, Set settings.
13153f1ac7a7SDavid Decotigny 					    * Please use ETHTOOL_SLINKSETTINGS
13163f1ac7a7SDavid Decotigny 					    */
1317607ca46eSDavid Howells #define ETHTOOL_GDRVINFO	0x00000003 /* Get driver info. */
1318607ca46eSDavid Howells #define ETHTOOL_GREGS		0x00000004 /* Get NIC registers. */
1319607ca46eSDavid Howells #define ETHTOOL_GWOL		0x00000005 /* Get wake-on-lan options. */
1320607ca46eSDavid Howells #define ETHTOOL_SWOL		0x00000006 /* Set wake-on-lan options. */
1321607ca46eSDavid Howells #define ETHTOOL_GMSGLVL		0x00000007 /* Get driver message level */
1322607ca46eSDavid Howells #define ETHTOOL_SMSGLVL		0x00000008 /* Set driver msg level. */
1323607ca46eSDavid Howells #define ETHTOOL_NWAY_RST	0x00000009 /* Restart autonegotiation. */
1324607ca46eSDavid Howells /* Get link status for host, i.e. whether the interface *and* the
1325607ca46eSDavid Howells  * physical port (if there is one) are up (ethtool_value). */
1326607ca46eSDavid Howells #define ETHTOOL_GLINK		0x0000000a
1327607ca46eSDavid Howells #define ETHTOOL_GEEPROM		0x0000000b /* Get EEPROM data */
1328607ca46eSDavid Howells #define ETHTOOL_SEEPROM		0x0000000c /* Set EEPROM data. */
1329607ca46eSDavid Howells #define ETHTOOL_GCOALESCE	0x0000000e /* Get coalesce config */
1330607ca46eSDavid Howells #define ETHTOOL_SCOALESCE	0x0000000f /* Set coalesce config. */
1331607ca46eSDavid Howells #define ETHTOOL_GRINGPARAM	0x00000010 /* Get ring parameters */
1332607ca46eSDavid Howells #define ETHTOOL_SRINGPARAM	0x00000011 /* Set ring parameters. */
1333607ca46eSDavid Howells #define ETHTOOL_GPAUSEPARAM	0x00000012 /* Get pause parameters */
1334607ca46eSDavid Howells #define ETHTOOL_SPAUSEPARAM	0x00000013 /* Set pause parameters. */
1335607ca46eSDavid Howells #define ETHTOOL_GRXCSUM		0x00000014 /* Get RX hw csum enable (ethtool_value) */
1336607ca46eSDavid Howells #define ETHTOOL_SRXCSUM		0x00000015 /* Set RX hw csum enable (ethtool_value) */
1337607ca46eSDavid Howells #define ETHTOOL_GTXCSUM		0x00000016 /* Get TX hw csum enable (ethtool_value) */
1338607ca46eSDavid Howells #define ETHTOOL_STXCSUM		0x00000017 /* Set TX hw csum enable (ethtool_value) */
1339607ca46eSDavid Howells #define ETHTOOL_GSG		0x00000018 /* Get scatter-gather enable
1340607ca46eSDavid Howells 					    * (ethtool_value) */
1341607ca46eSDavid Howells #define ETHTOOL_SSG		0x00000019 /* Set scatter-gather enable
1342607ca46eSDavid Howells 					    * (ethtool_value). */
1343607ca46eSDavid Howells #define ETHTOOL_TEST		0x0000001a /* execute NIC self-test. */
1344607ca46eSDavid Howells #define ETHTOOL_GSTRINGS	0x0000001b /* get specified string set */
1345607ca46eSDavid Howells #define ETHTOOL_PHYS_ID		0x0000001c /* identify the NIC */
1346607ca46eSDavid Howells #define ETHTOOL_GSTATS		0x0000001d /* get NIC-specific statistics */
1347607ca46eSDavid Howells #define ETHTOOL_GTSO		0x0000001e /* Get TSO enable (ethtool_value) */
1348607ca46eSDavid Howells #define ETHTOOL_STSO		0x0000001f /* Set TSO enable (ethtool_value) */
1349607ca46eSDavid Howells #define ETHTOOL_GPERMADDR	0x00000020 /* Get permanent hardware address */
1350607ca46eSDavid Howells #define ETHTOOL_GUFO		0x00000021 /* Get UFO enable (ethtool_value) */
1351607ca46eSDavid Howells #define ETHTOOL_SUFO		0x00000022 /* Set UFO enable (ethtool_value) */
1352607ca46eSDavid Howells #define ETHTOOL_GGSO		0x00000023 /* Get GSO enable (ethtool_value) */
1353607ca46eSDavid Howells #define ETHTOOL_SGSO		0x00000024 /* Set GSO enable (ethtool_value) */
1354607ca46eSDavid Howells #define ETHTOOL_GFLAGS		0x00000025 /* Get flags bitmap(ethtool_value) */
1355607ca46eSDavid Howells #define ETHTOOL_SFLAGS		0x00000026 /* Set flags bitmap(ethtool_value) */
1356607ca46eSDavid Howells #define ETHTOOL_GPFLAGS		0x00000027 /* Get driver-private flags bitmap */
1357607ca46eSDavid Howells #define ETHTOOL_SPFLAGS		0x00000028 /* Set driver-private flags bitmap */
1358607ca46eSDavid Howells 
1359607ca46eSDavid Howells #define ETHTOOL_GRXFH		0x00000029 /* Get RX flow hash configuration */
1360607ca46eSDavid Howells #define ETHTOOL_SRXFH		0x0000002a /* Set RX flow hash configuration */
1361607ca46eSDavid Howells #define ETHTOOL_GGRO		0x0000002b /* Get GRO enable (ethtool_value) */
1362607ca46eSDavid Howells #define ETHTOOL_SGRO		0x0000002c /* Set GRO enable (ethtool_value) */
1363607ca46eSDavid Howells #define ETHTOOL_GRXRINGS	0x0000002d /* Get RX rings available for LB */
1364607ca46eSDavid Howells #define ETHTOOL_GRXCLSRLCNT	0x0000002e /* Get RX class rule count */
1365607ca46eSDavid Howells #define ETHTOOL_GRXCLSRULE	0x0000002f /* Get RX classification rule */
1366607ca46eSDavid Howells #define ETHTOOL_GRXCLSRLALL	0x00000030 /* Get all RX classification rule */
1367607ca46eSDavid Howells #define ETHTOOL_SRXCLSRLDEL	0x00000031 /* Delete RX classification rule */
1368607ca46eSDavid Howells #define ETHTOOL_SRXCLSRLINS	0x00000032 /* Insert RX classification rule */
1369607ca46eSDavid Howells #define ETHTOOL_FLASHDEV	0x00000033 /* Flash firmware to device */
1370607ca46eSDavid Howells #define ETHTOOL_RESET		0x00000034 /* Reset hardware */
1371607ca46eSDavid Howells #define ETHTOOL_SRXNTUPLE	0x00000035 /* Add an n-tuple filter to device */
1372607ca46eSDavid Howells #define ETHTOOL_GRXNTUPLE	0x00000036 /* deprecated */
1373607ca46eSDavid Howells #define ETHTOOL_GSSET_INFO	0x00000037 /* Get string set info */
1374607ca46eSDavid Howells #define ETHTOOL_GRXFHINDIR	0x00000038 /* Get RX flow hash indir'n table */
1375607ca46eSDavid Howells #define ETHTOOL_SRXFHINDIR	0x00000039 /* Set RX flow hash indir'n table */
1376607ca46eSDavid Howells 
1377607ca46eSDavid Howells #define ETHTOOL_GFEATURES	0x0000003a /* Get device offload settings */
1378607ca46eSDavid Howells #define ETHTOOL_SFEATURES	0x0000003b /* Change device offload settings */
1379607ca46eSDavid Howells #define ETHTOOL_GCHANNELS	0x0000003c /* Get no of channels */
1380607ca46eSDavid Howells #define ETHTOOL_SCHANNELS	0x0000003d /* Set no of channels */
1381607ca46eSDavid Howells #define ETHTOOL_SET_DUMP	0x0000003e /* Set dump settings */
1382607ca46eSDavid Howells #define ETHTOOL_GET_DUMP_FLAG	0x0000003f /* Get dump settings */
1383607ca46eSDavid Howells #define ETHTOOL_GET_DUMP_DATA	0x00000040 /* Get dump data */
1384607ca46eSDavid Howells #define ETHTOOL_GET_TS_INFO	0x00000041 /* Get time stamping and PHC info */
1385607ca46eSDavid Howells #define ETHTOOL_GMODULEINFO	0x00000042 /* Get plug-in module information */
1386607ca46eSDavid Howells #define ETHTOOL_GMODULEEEPROM	0x00000043 /* Get plug-in module eeprom */
1387607ca46eSDavid Howells #define ETHTOOL_GEEE		0x00000044 /* Get EEE settings */
1388607ca46eSDavid Howells #define ETHTOOL_SEEE		0x00000045 /* Set EEE settings */
1389607ca46eSDavid Howells 
13903de0b592SVenkata Duvvuru #define ETHTOOL_GRSSH		0x00000046 /* Get RX flow hash configuration */
13913de0b592SVenkata Duvvuru #define ETHTOOL_SRSSH		0x00000047 /* Set RX flow hash configuration */
1392f0db9b07SGovindarajulu Varadarajan #define ETHTOOL_GTUNABLE	0x00000048 /* Get tunable configuration */
1393f0db9b07SGovindarajulu Varadarajan #define ETHTOOL_STUNABLE	0x00000049 /* Set tunable configuration */
1394f3a40945SAndrew Lunn #define ETHTOOL_GPHYSTATS	0x0000004a /* get PHY-specific statistics */
13953de0b592SVenkata Duvvuru 
1396ac2c7ad0SKan Liang #define ETHTOOL_PERQUEUE	0x0000004b /* Set per queue options */
1397ac2c7ad0SKan Liang 
13983f1ac7a7SDavid Decotigny #define ETHTOOL_GLINKSETTINGS	0x0000004c /* Get ethtool_link_settings */
13993f1ac7a7SDavid Decotigny #define ETHTOOL_SLINKSETTINGS	0x0000004d /* Set ethtool_link_settings */
14000d27f4e4SRaju Lakkaraju #define ETHTOOL_PHY_GTUNABLE	0x0000004e /* Get PHY tunable configuration */
14010d27f4e4SRaju Lakkaraju #define ETHTOOL_PHY_STUNABLE	0x0000004f /* Set PHY tunable configuration */
14021a5f3da2SVidya Sagar Ravipati #define ETHTOOL_GFECPARAM	0x00000050 /* Get FEC settings */
14031a5f3da2SVidya Sagar Ravipati #define ETHTOOL_SFECPARAM	0x00000051 /* Set FEC settings */
14043f1ac7a7SDavid Decotigny 
1405607ca46eSDavid Howells /* compatibility with older code */
1406607ca46eSDavid Howells #define SPARC_ETH_GSET		ETHTOOL_GSET
1407607ca46eSDavid Howells #define SPARC_ETH_SSET		ETHTOOL_SSET
1408607ca46eSDavid Howells 
14093f1ac7a7SDavid Decotigny /* Link mode bit indices */
14103f1ac7a7SDavid Decotigny enum ethtool_link_mode_bit_indices {
14113f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10baseT_Half_BIT	= 0,
14123f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10baseT_Full_BIT	= 1,
14133f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_100baseT_Half_BIT	= 2,
14143f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_100baseT_Full_BIT	= 3,
14153f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_1000baseT_Half_BIT	= 4,
14163f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_1000baseT_Full_BIT	= 5,
14173f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_Autoneg_BIT		= 6,
14183f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_TP_BIT		= 7,
14193f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_AUI_BIT		= 8,
14203f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_MII_BIT		= 9,
14213f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_FIBRE_BIT		= 10,
14223f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_BNC_BIT		= 11,
14233f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10000baseT_Full_BIT	= 12,
14243f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_Pause_BIT		= 13,
14253f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_Asym_Pause_BIT	= 14,
14263f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_2500baseX_Full_BIT	= 15,
14273f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_Backplane_BIT		= 16,
14283f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_1000baseKX_Full_BIT	= 17,
14293f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT	= 18,
14303f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10000baseKR_Full_BIT	= 19,
14313f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_10000baseR_FEC_BIT	= 20,
14323f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT = 21,
14333f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT	= 22,
14343f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT	= 23,
14353f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT	= 24,
14363f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT	= 25,
14373f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT	= 26,
14383f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT	= 27,
14393f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT	= 28,
14403f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT	= 29,
14413f1ac7a7SDavid Decotigny 	ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT	= 30,
14423851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_25000baseCR_Full_BIT	= 31,
1443e728fdf0SHeiner Kallweit 
1444e728fdf0SHeiner Kallweit 	/* Last allowed bit for __ETHTOOL_LINK_MODE_LEGACY_MASK is bit
1445e728fdf0SHeiner Kallweit 	 * 31. Please do NOT define any SUPPORTED_* or ADVERTISED_*
1446e728fdf0SHeiner Kallweit 	 * macro for bits > 31. The only way to use indices > 31 is to
1447e728fdf0SHeiner Kallweit 	 * use the new ETHTOOL_GLINKSETTINGS/ETHTOOL_SLINKSETTINGS API.
1448e728fdf0SHeiner Kallweit 	 */
1449e728fdf0SHeiner Kallweit 
14503851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_25000baseKR_Full_BIT	= 32,
14513851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_25000baseSR_Full_BIT	= 33,
14523851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT	= 34,
14533851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT	= 35,
14543851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT	= 36,
14553851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT	= 37,
14563851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT	= 38,
14573851112eSVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT	= 39,
145889da45b8SGal Pressman 	ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT		= 40,
14595711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_1000baseX_Full_BIT	= 41,
14605711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseCR_Full_BIT	= 42,
14615711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseSR_Full_BIT	= 43,
14625711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseLR_Full_BIT	= 44,
14635711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT	= 45,
14645711a982SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_10000baseER_Full_BIT	= 46,
146594842b4fSPavel Belous 	ETHTOOL_LINK_MODE_2500baseT_Full_BIT	= 47,
146694842b4fSPavel Belous 	ETHTOOL_LINK_MODE_5000baseT_Full_BIT	= 48,
14675711a982SVidya Sagar Ravipati 
14681a5f3da2SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_FEC_NONE_BIT	= 49,
14691a5f3da2SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_FEC_RS_BIT	= 50,
14701a5f3da2SVidya Sagar Ravipati 	ETHTOOL_LINK_MODE_FEC_BASER_BIT	= 51,
14712736d94fSAya Levin 	ETHTOOL_LINK_MODE_50000baseKR_Full_BIT		 = 52,
14722736d94fSAya Levin 	ETHTOOL_LINK_MODE_50000baseSR_Full_BIT		 = 53,
14732736d94fSAya Levin 	ETHTOOL_LINK_MODE_50000baseCR_Full_BIT		 = 54,
14742736d94fSAya Levin 	ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT	 = 55,
14752736d94fSAya Levin 	ETHTOOL_LINK_MODE_50000baseDR_Full_BIT		 = 56,
14762736d94fSAya Levin 	ETHTOOL_LINK_MODE_100000baseKR2_Full_BIT	 = 57,
14772736d94fSAya Levin 	ETHTOOL_LINK_MODE_100000baseSR2_Full_BIT	 = 58,
14782736d94fSAya Levin 	ETHTOOL_LINK_MODE_100000baseCR2_Full_BIT	 = 59,
14792736d94fSAya Levin 	ETHTOOL_LINK_MODE_100000baseLR2_ER2_FR2_Full_BIT = 60,
14802736d94fSAya Levin 	ETHTOOL_LINK_MODE_100000baseDR2_Full_BIT	 = 61,
14812736d94fSAya Levin 	ETHTOOL_LINK_MODE_200000baseKR4_Full_BIT	 = 62,
14822736d94fSAya Levin 	ETHTOOL_LINK_MODE_200000baseSR4_Full_BIT	 = 63,
14832736d94fSAya Levin 	ETHTOOL_LINK_MODE_200000baseLR4_ER4_FR4_Full_BIT = 64,
14842736d94fSAya Levin 	ETHTOOL_LINK_MODE_200000baseDR4_Full_BIT	 = 65,
14852736d94fSAya Levin 	ETHTOOL_LINK_MODE_200000baseCR4_Full_BIT	 = 66,
1486607ca46eSDavid Howells 
1487e728fdf0SHeiner Kallweit 	/* must be last entry */
1488e728fdf0SHeiner Kallweit 	__ETHTOOL_LINK_MODE_MASK_NBITS
14893f1ac7a7SDavid Decotigny };
14903f1ac7a7SDavid Decotigny 
14913f1ac7a7SDavid Decotigny #define __ETHTOOL_LINK_MODE_LEGACY_MASK(base_name)	\
14923f1ac7a7SDavid Decotigny 	(1UL << (ETHTOOL_LINK_MODE_ ## base_name ## _BIT))
14933f1ac7a7SDavid Decotigny 
14943f1ac7a7SDavid Decotigny /* DEPRECATED macros. Please migrate to
14953f1ac7a7SDavid Decotigny  * ETHTOOL_GLINKSETTINGS/ETHTOOL_SLINKSETTINGS API. Please do NOT
14963f1ac7a7SDavid Decotigny  * define any new SUPPORTED_* macro for bits > 31.
14973f1ac7a7SDavid Decotigny  */
14983f1ac7a7SDavid Decotigny #define SUPPORTED_10baseT_Half		__ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Half)
14993f1ac7a7SDavid Decotigny #define SUPPORTED_10baseT_Full		__ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Full)
15003f1ac7a7SDavid Decotigny #define SUPPORTED_100baseT_Half		__ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Half)
15013f1ac7a7SDavid Decotigny #define SUPPORTED_100baseT_Full		__ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Full)
15023f1ac7a7SDavid Decotigny #define SUPPORTED_1000baseT_Half	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Half)
15033f1ac7a7SDavid Decotigny #define SUPPORTED_1000baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Full)
15043f1ac7a7SDavid Decotigny #define SUPPORTED_Autoneg		__ETHTOOL_LINK_MODE_LEGACY_MASK(Autoneg)
15053f1ac7a7SDavid Decotigny #define SUPPORTED_TP			__ETHTOOL_LINK_MODE_LEGACY_MASK(TP)
15063f1ac7a7SDavid Decotigny #define SUPPORTED_AUI			__ETHTOOL_LINK_MODE_LEGACY_MASK(AUI)
15073f1ac7a7SDavid Decotigny #define SUPPORTED_MII			__ETHTOOL_LINK_MODE_LEGACY_MASK(MII)
15083f1ac7a7SDavid Decotigny #define SUPPORTED_FIBRE			__ETHTOOL_LINK_MODE_LEGACY_MASK(FIBRE)
15093f1ac7a7SDavid Decotigny #define SUPPORTED_BNC			__ETHTOOL_LINK_MODE_LEGACY_MASK(BNC)
15103f1ac7a7SDavid Decotigny #define SUPPORTED_10000baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseT_Full)
15113f1ac7a7SDavid Decotigny #define SUPPORTED_Pause			__ETHTOOL_LINK_MODE_LEGACY_MASK(Pause)
15123f1ac7a7SDavid Decotigny #define SUPPORTED_Asym_Pause		__ETHTOOL_LINK_MODE_LEGACY_MASK(Asym_Pause)
15133f1ac7a7SDavid Decotigny #define SUPPORTED_2500baseX_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(2500baseX_Full)
15143f1ac7a7SDavid Decotigny #define SUPPORTED_Backplane		__ETHTOOL_LINK_MODE_LEGACY_MASK(Backplane)
15153f1ac7a7SDavid Decotigny #define SUPPORTED_1000baseKX_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseKX_Full)
15163f1ac7a7SDavid Decotigny #define SUPPORTED_10000baseKX4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKX4_Full)
15173f1ac7a7SDavid Decotigny #define SUPPORTED_10000baseKR_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKR_Full)
15183f1ac7a7SDavid Decotigny #define SUPPORTED_10000baseR_FEC	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseR_FEC)
15193f1ac7a7SDavid Decotigny #define SUPPORTED_20000baseMLD2_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseMLD2_Full)
15203f1ac7a7SDavid Decotigny #define SUPPORTED_20000baseKR2_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseKR2_Full)
15213f1ac7a7SDavid Decotigny #define SUPPORTED_40000baseKR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseKR4_Full)
15223f1ac7a7SDavid Decotigny #define SUPPORTED_40000baseCR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseCR4_Full)
15233f1ac7a7SDavid Decotigny #define SUPPORTED_40000baseSR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseSR4_Full)
15243f1ac7a7SDavid Decotigny #define SUPPORTED_40000baseLR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseLR4_Full)
15253f1ac7a7SDavid Decotigny #define SUPPORTED_56000baseKR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseKR4_Full)
15263f1ac7a7SDavid Decotigny #define SUPPORTED_56000baseCR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseCR4_Full)
15273f1ac7a7SDavid Decotigny #define SUPPORTED_56000baseSR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseSR4_Full)
15283f1ac7a7SDavid Decotigny #define SUPPORTED_56000baseLR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseLR4_Full)
15293f1ac7a7SDavid Decotigny /* Please do not define any new SUPPORTED_* macro for bits > 31, see
15303f1ac7a7SDavid Decotigny  * notice above.
15313f1ac7a7SDavid Decotigny  */
15323f1ac7a7SDavid Decotigny 
15333f1ac7a7SDavid Decotigny /*
15343f1ac7a7SDavid Decotigny  * DEPRECATED macros. Please migrate to
15353f1ac7a7SDavid Decotigny  * ETHTOOL_GLINKSETTINGS/ETHTOOL_SLINKSETTINGS API. Please do NOT
15363f1ac7a7SDavid Decotigny  * define any new ADERTISE_* macro for bits > 31.
15373f1ac7a7SDavid Decotigny  */
15383f1ac7a7SDavid Decotigny #define ADVERTISED_10baseT_Half		__ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Half)
15393f1ac7a7SDavid Decotigny #define ADVERTISED_10baseT_Full		__ETHTOOL_LINK_MODE_LEGACY_MASK(10baseT_Full)
15403f1ac7a7SDavid Decotigny #define ADVERTISED_100baseT_Half	__ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Half)
15413f1ac7a7SDavid Decotigny #define ADVERTISED_100baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(100baseT_Full)
15423f1ac7a7SDavid Decotigny #define ADVERTISED_1000baseT_Half	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Half)
15433f1ac7a7SDavid Decotigny #define ADVERTISED_1000baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseT_Full)
15443f1ac7a7SDavid Decotigny #define ADVERTISED_Autoneg		__ETHTOOL_LINK_MODE_LEGACY_MASK(Autoneg)
15453f1ac7a7SDavid Decotigny #define ADVERTISED_TP			__ETHTOOL_LINK_MODE_LEGACY_MASK(TP)
15463f1ac7a7SDavid Decotigny #define ADVERTISED_AUI			__ETHTOOL_LINK_MODE_LEGACY_MASK(AUI)
15473f1ac7a7SDavid Decotigny #define ADVERTISED_MII			__ETHTOOL_LINK_MODE_LEGACY_MASK(MII)
15483f1ac7a7SDavid Decotigny #define ADVERTISED_FIBRE		__ETHTOOL_LINK_MODE_LEGACY_MASK(FIBRE)
15493f1ac7a7SDavid Decotigny #define ADVERTISED_BNC			__ETHTOOL_LINK_MODE_LEGACY_MASK(BNC)
15503f1ac7a7SDavid Decotigny #define ADVERTISED_10000baseT_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseT_Full)
15513f1ac7a7SDavid Decotigny #define ADVERTISED_Pause		__ETHTOOL_LINK_MODE_LEGACY_MASK(Pause)
15523f1ac7a7SDavid Decotigny #define ADVERTISED_Asym_Pause		__ETHTOOL_LINK_MODE_LEGACY_MASK(Asym_Pause)
15533f1ac7a7SDavid Decotigny #define ADVERTISED_2500baseX_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(2500baseX_Full)
15543f1ac7a7SDavid Decotigny #define ADVERTISED_Backplane		__ETHTOOL_LINK_MODE_LEGACY_MASK(Backplane)
15553f1ac7a7SDavid Decotigny #define ADVERTISED_1000baseKX_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(1000baseKX_Full)
15563f1ac7a7SDavid Decotigny #define ADVERTISED_10000baseKX4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKX4_Full)
15573f1ac7a7SDavid Decotigny #define ADVERTISED_10000baseKR_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseKR_Full)
15583f1ac7a7SDavid Decotigny #define ADVERTISED_10000baseR_FEC	__ETHTOOL_LINK_MODE_LEGACY_MASK(10000baseR_FEC)
15593f1ac7a7SDavid Decotigny #define ADVERTISED_20000baseMLD2_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseMLD2_Full)
15603f1ac7a7SDavid Decotigny #define ADVERTISED_20000baseKR2_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(20000baseKR2_Full)
15613f1ac7a7SDavid Decotigny #define ADVERTISED_40000baseKR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseKR4_Full)
15623f1ac7a7SDavid Decotigny #define ADVERTISED_40000baseCR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseCR4_Full)
15633f1ac7a7SDavid Decotigny #define ADVERTISED_40000baseSR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseSR4_Full)
15643f1ac7a7SDavid Decotigny #define ADVERTISED_40000baseLR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(40000baseLR4_Full)
15653f1ac7a7SDavid Decotigny #define ADVERTISED_56000baseKR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseKR4_Full)
15663f1ac7a7SDavid Decotigny #define ADVERTISED_56000baseCR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseCR4_Full)
15673f1ac7a7SDavid Decotigny #define ADVERTISED_56000baseSR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseSR4_Full)
15683f1ac7a7SDavid Decotigny #define ADVERTISED_56000baseLR4_Full	__ETHTOOL_LINK_MODE_LEGACY_MASK(56000baseLR4_Full)
15693f1ac7a7SDavid Decotigny /* Please do not define any new ADVERTISED_* macro for bits > 31, see
15703f1ac7a7SDavid Decotigny  * notice above.
15713f1ac7a7SDavid Decotigny  */
1572607ca46eSDavid Howells 
1573607ca46eSDavid Howells /* The following are all involved in forcing a particular link
1574607ca46eSDavid Howells  * mode for the device for setting things.  When getting the
1575607ca46eSDavid Howells  * devices settings, these indicate the current mode and whether
1576607ca46eSDavid Howells  * it was forced up into this mode or autonegotiated.
1577607ca46eSDavid Howells  */
1578607ca46eSDavid Howells 
1579297fb414SNicolas Dichtel /* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal.
1580297fb414SNicolas Dichtel  * Update drivers/net/phy/phy.c:phy_speed_to_str() and
1581297fb414SNicolas Dichtel  * drivers/net/bonding/bond_3ad.c:__get_link_speed() when adding new values.
1582297fb414SNicolas Dichtel  */
1583607ca46eSDavid Howells #define SPEED_10		10
1584607ca46eSDavid Howells #define SPEED_100		100
1585607ca46eSDavid Howells #define SPEED_1000		1000
1586607ca46eSDavid Howells #define SPEED_2500		2500
1587c9a70d43SParav Pandit #define SPEED_5000		5000
1588607ca46eSDavid Howells #define SPEED_10000		10000
15890d7e2d21SZhu Yanjun #define SPEED_14000		14000
1590dcf972a3SSaeed Mahameed #define SPEED_20000		20000
1591c9a70d43SParav Pandit #define SPEED_25000		25000
1592dcf972a3SSaeed Mahameed #define SPEED_40000		40000
1593c9a70d43SParav Pandit #define SPEED_50000		50000
1594dcf972a3SSaeed Mahameed #define SPEED_56000		56000
1595c9a70d43SParav Pandit #define SPEED_100000		100000
15962736d94fSAya Levin #define SPEED_200000		200000
1597dcf972a3SSaeed Mahameed 
1598607ca46eSDavid Howells #define SPEED_UNKNOWN		-1
1599607ca46eSDavid Howells 
1600103a8ad1SNikolay Aleksandrov static inline int ethtool_validate_speed(__u32 speed)
1601103a8ad1SNikolay Aleksandrov {
1602afe64245SMichael Zhivich 	return speed <= INT_MAX || speed == (__u32)SPEED_UNKNOWN;
1603103a8ad1SNikolay Aleksandrov }
1604103a8ad1SNikolay Aleksandrov 
1605607ca46eSDavid Howells /* Duplex, half or full. */
1606607ca46eSDavid Howells #define DUPLEX_HALF		0x00
1607607ca46eSDavid Howells #define DUPLEX_FULL		0x01
1608607ca46eSDavid Howells #define DUPLEX_UNKNOWN		0xff
1609607ca46eSDavid Howells 
1610103a8ad1SNikolay Aleksandrov static inline int ethtool_validate_duplex(__u8 duplex)
1611103a8ad1SNikolay Aleksandrov {
1612103a8ad1SNikolay Aleksandrov 	switch (duplex) {
1613103a8ad1SNikolay Aleksandrov 	case DUPLEX_HALF:
1614103a8ad1SNikolay Aleksandrov 	case DUPLEX_FULL:
1615103a8ad1SNikolay Aleksandrov 	case DUPLEX_UNKNOWN:
1616103a8ad1SNikolay Aleksandrov 		return 1;
1617103a8ad1SNikolay Aleksandrov 	}
1618103a8ad1SNikolay Aleksandrov 
1619103a8ad1SNikolay Aleksandrov 	return 0;
1620103a8ad1SNikolay Aleksandrov }
1621103a8ad1SNikolay Aleksandrov 
1622607ca46eSDavid Howells /* Which connector port. */
1623607ca46eSDavid Howells #define PORT_TP			0x00
1624607ca46eSDavid Howells #define PORT_AUI		0x01
1625607ca46eSDavid Howells #define PORT_MII		0x02
1626607ca46eSDavid Howells #define PORT_FIBRE		0x03
1627607ca46eSDavid Howells #define PORT_BNC		0x04
1628607ca46eSDavid Howells #define PORT_DA			0x05
1629607ca46eSDavid Howells #define PORT_NONE		0xef
1630607ca46eSDavid Howells #define PORT_OTHER		0xff
1631607ca46eSDavid Howells 
1632607ca46eSDavid Howells /* Which transceiver to use. */
16337ec87211SFlorian Fainelli #define XCVR_INTERNAL		0x00 /* PHY and MAC are in the same package */
16347ec87211SFlorian Fainelli #define XCVR_EXTERNAL		0x01 /* PHY and MAC are in different packages */
1635607ca46eSDavid Howells #define XCVR_DUMMY1		0x02
1636607ca46eSDavid Howells #define XCVR_DUMMY2		0x03
1637607ca46eSDavid Howells #define XCVR_DUMMY3		0x04
1638607ca46eSDavid Howells 
1639bf8fc60aSBen Hutchings /* Enable or disable autonegotiation. */
1640607ca46eSDavid Howells #define AUTONEG_DISABLE		0x00
1641607ca46eSDavid Howells #define AUTONEG_ENABLE		0x01
1642607ca46eSDavid Howells 
1643607ca46eSDavid Howells /* MDI or MDI-X status/control - if MDI/MDI_X/AUTO is set then
1644607ca46eSDavid Howells  * the driver is required to renegotiate link
1645607ca46eSDavid Howells  */
1646607ca46eSDavid Howells #define ETH_TP_MDI_INVALID	0x00 /* status: unknown; control: unsupported */
1647607ca46eSDavid Howells #define ETH_TP_MDI		0x01 /* status: MDI;     control: force MDI */
1648607ca46eSDavid Howells #define ETH_TP_MDI_X		0x02 /* status: MDI-X;   control: force MDI-X */
1649607ca46eSDavid Howells #define ETH_TP_MDI_AUTO		0x03 /*                  control: auto-select */
1650607ca46eSDavid Howells 
1651607ca46eSDavid Howells /* Wake-On-Lan options. */
1652607ca46eSDavid Howells #define WAKE_PHY		(1 << 0)
1653607ca46eSDavid Howells #define WAKE_UCAST		(1 << 1)
1654607ca46eSDavid Howells #define WAKE_MCAST		(1 << 2)
1655607ca46eSDavid Howells #define WAKE_BCAST		(1 << 3)
1656607ca46eSDavid Howells #define WAKE_ARP		(1 << 4)
1657607ca46eSDavid Howells #define WAKE_MAGIC		(1 << 5)
1658607ca46eSDavid Howells #define WAKE_MAGICSECURE	(1 << 6) /* only meaningful if WAKE_MAGIC */
16596cfef793SFlorian Fainelli #define WAKE_FILTER		(1 << 7)
1660607ca46eSDavid Howells 
1661607ca46eSDavid Howells /* L2-L4 network traffic flow types */
1662607ca46eSDavid Howells #define	TCP_V4_FLOW	0x01	/* hash or spec (tcp_ip4_spec) */
1663607ca46eSDavid Howells #define	UDP_V4_FLOW	0x02	/* hash or spec (udp_ip4_spec) */
1664607ca46eSDavid Howells #define	SCTP_V4_FLOW	0x03	/* hash or spec (sctp_ip4_spec) */
1665607ca46eSDavid Howells #define	AH_ESP_V4_FLOW	0x04	/* hash only */
166672bb6872SEdward Cree #define	TCP_V6_FLOW	0x05	/* hash or spec (tcp_ip6_spec; nfc only) */
166772bb6872SEdward Cree #define	UDP_V6_FLOW	0x06	/* hash or spec (udp_ip6_spec; nfc only) */
166872bb6872SEdward Cree #define	SCTP_V6_FLOW	0x07	/* hash or spec (sctp_ip6_spec; nfc only) */
1669607ca46eSDavid Howells #define	AH_ESP_V6_FLOW	0x08	/* hash only */
1670607ca46eSDavid Howells #define	AH_V4_FLOW	0x09	/* hash or spec (ah_ip4_spec) */
1671607ca46eSDavid Howells #define	ESP_V4_FLOW	0x0a	/* hash or spec (esp_ip4_spec) */
167272bb6872SEdward Cree #define	AH_V6_FLOW	0x0b	/* hash or spec (ah_ip6_spec; nfc only) */
167372bb6872SEdward Cree #define	ESP_V6_FLOW	0x0c	/* hash or spec (esp_ip6_spec; nfc only) */
167472bb6872SEdward Cree #define	IPV4_USER_FLOW	0x0d	/* spec only (usr_ip4_spec) */
167572bb6872SEdward Cree #define	IP_USER_FLOW	IPV4_USER_FLOW
167672bb6872SEdward Cree #define	IPV6_USER_FLOW	0x0e	/* spec only (usr_ip6_spec; nfc only) */
1677607ca46eSDavid Howells #define	IPV4_FLOW	0x10	/* hash only */
1678607ca46eSDavid Howells #define	IPV6_FLOW	0x11	/* hash only */
1679607ca46eSDavid Howells #define	ETHER_FLOW	0x12	/* spec only (ether_spec) */
1680607ca46eSDavid Howells /* Flag to enable additional fields in struct ethtool_rx_flow_spec */
1681607ca46eSDavid Howells #define	FLOW_EXT	0x80000000
1682d4676eacSYan Burman #define	FLOW_MAC_EXT	0x40000000
168384a1d9c4SEdward Cree /* Flag to enable RSS spreading of traffic matching rule (nfc only) */
168484a1d9c4SEdward Cree #define	FLOW_RSS	0x20000000
1685607ca46eSDavid Howells 
1686607ca46eSDavid Howells /* L3-L4 network traffic flow hash options */
1687607ca46eSDavid Howells #define	RXH_L2DA	(1 << 1)
1688607ca46eSDavid Howells #define	RXH_VLAN	(1 << 2)
1689607ca46eSDavid Howells #define	RXH_L3_PROTO	(1 << 3)
1690607ca46eSDavid Howells #define	RXH_IP_SRC	(1 << 4)
1691607ca46eSDavid Howells #define	RXH_IP_DST	(1 << 5)
1692607ca46eSDavid Howells #define	RXH_L4_B_0_1	(1 << 6) /* src port in case of TCP/UDP/SCTP */
1693607ca46eSDavid Howells #define	RXH_L4_B_2_3	(1 << 7) /* dst port in case of TCP/UDP/SCTP */
1694607ca46eSDavid Howells #define	RXH_DISCARD	(1 << 31)
1695607ca46eSDavid Howells 
1696607ca46eSDavid Howells #define	RX_CLS_FLOW_DISC	0xffffffffffffffffULL
16976cfef793SFlorian Fainelli #define RX_CLS_FLOW_WAKE	0xfffffffffffffffeULL
1698607ca46eSDavid Howells 
1699607ca46eSDavid Howells /* Special RX classification rule insert location values */
1700607ca46eSDavid Howells #define RX_CLS_LOC_SPECIAL	0x80000000	/* flag */
1701607ca46eSDavid Howells #define RX_CLS_LOC_ANY		0xffffffff
1702607ca46eSDavid Howells #define RX_CLS_LOC_FIRST	0xfffffffe
1703607ca46eSDavid Howells #define RX_CLS_LOC_LAST		0xfffffffd
1704607ca46eSDavid Howells 
1705607ca46eSDavid Howells /* EEPROM Standards for plug in modules */
1706607ca46eSDavid Howells #define ETH_MODULE_SFF_8079		0x1
1707607ca46eSDavid Howells #define ETH_MODULE_SFF_8079_LEN		256
1708607ca46eSDavid Howells #define ETH_MODULE_SFF_8472		0x2
1709607ca46eSDavid Howells #define ETH_MODULE_SFF_8472_LEN		512
17107202da8bSSaeed Mahameed #define ETH_MODULE_SFF_8636		0x3
17117202da8bSSaeed Mahameed #define ETH_MODULE_SFF_8636_LEN		256
17127202da8bSSaeed Mahameed #define ETH_MODULE_SFF_8436		0x4
17137202da8bSSaeed Mahameed #define ETH_MODULE_SFF_8436_LEN		256
1714607ca46eSDavid Howells 
1715*0e1a2a3eSErez Alfasi #define ETH_MODULE_SFF_8636_MAX_LEN     640
1716*0e1a2a3eSErez Alfasi #define ETH_MODULE_SFF_8436_MAX_LEN     640
1717*0e1a2a3eSErez Alfasi 
1718607ca46eSDavid Howells /* Reset flags */
1719607ca46eSDavid Howells /* The reset() operation must clear the flags for the components which
1720607ca46eSDavid Howells  * were actually reset.  On successful return, the flags indicate the
1721607ca46eSDavid Howells  * components which were not reset, either because they do not exist
1722607ca46eSDavid Howells  * in the hardware or because they cannot be reset independently.  The
1723607ca46eSDavid Howells  * driver must never reset any components that were not requested.
1724607ca46eSDavid Howells  */
1725607ca46eSDavid Howells enum ethtool_reset_flags {
1726607ca46eSDavid Howells 	/* These flags represent components dedicated to the interface
1727607ca46eSDavid Howells 	 * the command is addressed to.  Shift any flag left by
1728607ca46eSDavid Howells 	 * ETH_RESET_SHARED_SHIFT to reset a shared component of the
1729607ca46eSDavid Howells 	 * same type.
1730607ca46eSDavid Howells 	 */
1731607ca46eSDavid Howells 	ETH_RESET_MGMT		= 1 << 0,	/* Management processor */
1732607ca46eSDavid Howells 	ETH_RESET_IRQ		= 1 << 1,	/* Interrupt requester */
1733607ca46eSDavid Howells 	ETH_RESET_DMA		= 1 << 2,	/* DMA engine */
1734607ca46eSDavid Howells 	ETH_RESET_FILTER	= 1 << 3,	/* Filtering/flow direction */
1735607ca46eSDavid Howells 	ETH_RESET_OFFLOAD	= 1 << 4,	/* Protocol offload */
1736607ca46eSDavid Howells 	ETH_RESET_MAC		= 1 << 5,	/* Media access controller */
1737607ca46eSDavid Howells 	ETH_RESET_PHY		= 1 << 6,	/* Transceiver/PHY */
1738607ca46eSDavid Howells 	ETH_RESET_RAM		= 1 << 7,	/* RAM shared between
1739607ca46eSDavid Howells 						 * multiple components */
174040e44a1eSScott Branden 	ETH_RESET_AP		= 1 << 8,	/* Application processor */
1741607ca46eSDavid Howells 
1742607ca46eSDavid Howells 	ETH_RESET_DEDICATED	= 0x0000ffff,	/* All components dedicated to
1743607ca46eSDavid Howells 						 * this interface */
1744607ca46eSDavid Howells 	ETH_RESET_ALL		= 0xffffffff,	/* All components used by this
1745607ca46eSDavid Howells 						 * interface, even if shared */
1746607ca46eSDavid Howells };
1747607ca46eSDavid Howells #define ETH_RESET_SHARED_SHIFT	16
1748607ca46eSDavid Howells 
17493f1ac7a7SDavid Decotigny 
17503f1ac7a7SDavid Decotigny /**
17513f1ac7a7SDavid Decotigny  * struct ethtool_link_settings - link control and status
17523f1ac7a7SDavid Decotigny  *
17533f1ac7a7SDavid Decotigny  * IMPORTANT, Backward compatibility notice: When implementing new
17543f1ac7a7SDavid Decotigny  *	user-space tools, please first try %ETHTOOL_GLINKSETTINGS, and
17553f1ac7a7SDavid Decotigny  *	if it succeeds use %ETHTOOL_SLINKSETTINGS to change link
17563f1ac7a7SDavid Decotigny  *	settings; do not use %ETHTOOL_SSET if %ETHTOOL_GLINKSETTINGS
17573f1ac7a7SDavid Decotigny  *	succeeded: stick to %ETHTOOL_GLINKSETTINGS/%SLINKSETTINGS in
17583f1ac7a7SDavid Decotigny  *	that case.  Conversely, if %ETHTOOL_GLINKSETTINGS fails, use
17593f1ac7a7SDavid Decotigny  *	%ETHTOOL_GSET to query and %ETHTOOL_SSET to change link
17603f1ac7a7SDavid Decotigny  *	settings; do not use %ETHTOOL_SLINKSETTINGS if
17613f1ac7a7SDavid Decotigny  *	%ETHTOOL_GLINKSETTINGS failed: stick to
17623f1ac7a7SDavid Decotigny  *	%ETHTOOL_GSET/%ETHTOOL_SSET in that case.
17633f1ac7a7SDavid Decotigny  *
17643f1ac7a7SDavid Decotigny  * @cmd: Command number = %ETHTOOL_GLINKSETTINGS or %ETHTOOL_SLINKSETTINGS
17653f1ac7a7SDavid Decotigny  * @speed: Link speed (Mbps)
17663f1ac7a7SDavid Decotigny  * @duplex: Duplex mode; one of %DUPLEX_*
17673f1ac7a7SDavid Decotigny  * @port: Physical connector type; one of %PORT_*
17683f1ac7a7SDavid Decotigny  * @phy_address: MDIO address of PHY (transceiver); 0 or 255 if not
17693f1ac7a7SDavid Decotigny  *	applicable.  For clause 45 PHYs this is the PRTAD.
17703f1ac7a7SDavid Decotigny  * @autoneg: Enable/disable autonegotiation and auto-detection;
17713f1ac7a7SDavid Decotigny  *	either %AUTONEG_DISABLE or %AUTONEG_ENABLE
17723f1ac7a7SDavid Decotigny  * @mdio_support: Bitmask of %ETH_MDIO_SUPPORTS_* flags for the MDIO
17733f1ac7a7SDavid Decotigny  *	protocols supported by the interface; 0 if unknown.
17743f1ac7a7SDavid Decotigny  *	Read-only.
17753f1ac7a7SDavid Decotigny  * @eth_tp_mdix: Ethernet twisted-pair MDI(-X) status; one of
17763f1ac7a7SDavid Decotigny  *	%ETH_TP_MDI_*.  If the status is unknown or not applicable, the
17773f1ac7a7SDavid Decotigny  *	value will be %ETH_TP_MDI_INVALID.  Read-only.
17783f1ac7a7SDavid Decotigny  * @eth_tp_mdix_ctrl: Ethernet twisted pair MDI(-X) control; one of
17793f1ac7a7SDavid Decotigny  *	%ETH_TP_MDI_*.  If MDI(-X) control is not implemented, reads
17803f1ac7a7SDavid Decotigny  *	yield %ETH_TP_MDI_INVALID and writes may be ignored or rejected.
17813f1ac7a7SDavid Decotigny  *	When written successfully, the link should be renegotiated if
17823f1ac7a7SDavid Decotigny  *	necessary.
17833f1ac7a7SDavid Decotigny  * @link_mode_masks_nwords: Number of 32-bit words for each of the
17843f1ac7a7SDavid Decotigny  *	supported, advertising, lp_advertising link mode bitmaps. For
17853f1ac7a7SDavid Decotigny  *	%ETHTOOL_GLINKSETTINGS: on entry, number of words passed by user
17863f1ac7a7SDavid Decotigny  *	(>= 0); on return, if handshake in progress, negative if
17873f1ac7a7SDavid Decotigny  *	request size unsupported by kernel: absolute value indicates
17885f2d4724SDavid Decotigny  *	kernel expected size and all the other fields but cmd
17895f2d4724SDavid Decotigny  *	are 0; otherwise (handshake completed), strictly positive
17905f2d4724SDavid Decotigny  *	to indicate size used by kernel and cmd field stays
17913f1ac7a7SDavid Decotigny  *	%ETHTOOL_GLINKSETTINGS, all other fields populated by driver. For
17923f1ac7a7SDavid Decotigny  *	%ETHTOOL_SLINKSETTINGS: must be valid on entry, ie. a positive
17933f1ac7a7SDavid Decotigny  *	value returned previously by %ETHTOOL_GLINKSETTINGS, otherwise
17943f1ac7a7SDavid Decotigny  *	refused. For drivers: ignore this field (use kernel's
17953f1ac7a7SDavid Decotigny  *	__ETHTOOL_LINK_MODE_MASK_NBITS instead), any change to it will
17963f1ac7a7SDavid Decotigny  *	be overwritten by kernel.
17973f1ac7a7SDavid Decotigny  * @supported: Bitmap with each bit meaning given by
17983f1ac7a7SDavid Decotigny  *	%ethtool_link_mode_bit_indices for the link modes, physical
17993f1ac7a7SDavid Decotigny  *	connectors and other link features for which the interface
18003f1ac7a7SDavid Decotigny  *	supports autonegotiation or auto-detection.  Read-only.
18013f1ac7a7SDavid Decotigny  * @advertising: Bitmap with each bit meaning given by
18023f1ac7a7SDavid Decotigny  *	%ethtool_link_mode_bit_indices for the link modes, physical
18033f1ac7a7SDavid Decotigny  *	connectors and other link features that are advertised through
18043f1ac7a7SDavid Decotigny  *	autonegotiation or enabled for auto-detection.
18053f1ac7a7SDavid Decotigny  * @lp_advertising: Bitmap with each bit meaning given by
18063f1ac7a7SDavid Decotigny  *	%ethtool_link_mode_bit_indices for the link modes, and other
18073f1ac7a7SDavid Decotigny  *	link features that the link partner advertised through
18083f1ac7a7SDavid Decotigny  *	autonegotiation; 0 if unknown or not applicable.  Read-only.
180919cab887SFlorian Fainelli  * @transceiver: Used to distinguish different possible PHY types,
181019cab887SFlorian Fainelli  *	reported consistently by PHYLIB.  Read-only.
18113f1ac7a7SDavid Decotigny  *
18123f1ac7a7SDavid Decotigny  * If autonegotiation is disabled, the speed and @duplex represent the
18133f1ac7a7SDavid Decotigny  * fixed link mode and are writable if the driver supports multiple
18143f1ac7a7SDavid Decotigny  * link modes.  If it is enabled then they are read-only; if the link
18153f1ac7a7SDavid Decotigny  * is up they represent the negotiated link mode; if the link is down,
18163f1ac7a7SDavid Decotigny  * the speed is 0, %SPEED_UNKNOWN or the highest enabled speed and
18173f1ac7a7SDavid Decotigny  * @duplex is %DUPLEX_UNKNOWN or the best enabled duplex mode.
18183f1ac7a7SDavid Decotigny  *
18193f1ac7a7SDavid Decotigny  * Some hardware interfaces may have multiple PHYs and/or physical
18203f1ac7a7SDavid Decotigny  * connectors fitted or do not allow the driver to detect which are
18213f1ac7a7SDavid Decotigny  * fitted.  For these interfaces @port and/or @phy_address may be
18223f1ac7a7SDavid Decotigny  * writable, possibly dependent on @autoneg being %AUTONEG_DISABLE.
18233f1ac7a7SDavid Decotigny  * Otherwise, attempts to write different values may be ignored or
18243f1ac7a7SDavid Decotigny  * rejected.
18253f1ac7a7SDavid Decotigny  *
18263f1ac7a7SDavid Decotigny  * Deprecated %ethtool_cmd fields transceiver, maxtxpkt and maxrxpkt
18279b300495SMichal Kubecek  * are not available in %ethtool_link_settings. These fields will be
18289b300495SMichal Kubecek  * always set to zero in %ETHTOOL_GSET reply and %ETHTOOL_SSET will
18299b300495SMichal Kubecek  * fail if any of them is set to non-zero value.
18303f1ac7a7SDavid Decotigny  *
18313f1ac7a7SDavid Decotigny  * Users should assume that all fields not marked read-only are
18323f1ac7a7SDavid Decotigny  * writable and subject to validation by the driver.  They should use
18333f1ac7a7SDavid Decotigny  * %ETHTOOL_GLINKSETTINGS to get the current values before making specific
18343f1ac7a7SDavid Decotigny  * changes and then applying them with %ETHTOOL_SLINKSETTINGS.
18353f1ac7a7SDavid Decotigny  *
18363f1ac7a7SDavid Decotigny  * Drivers that implement %get_link_ksettings and/or
18373f1ac7a7SDavid Decotigny  * %set_link_ksettings should ignore the @cmd
18383f1ac7a7SDavid Decotigny  * and @link_mode_masks_nwords fields (any change to them overwritten
18393f1ac7a7SDavid Decotigny  * by kernel), and rely only on kernel's internal
18403f1ac7a7SDavid Decotigny  * %__ETHTOOL_LINK_MODE_MASK_NBITS and
18413f1ac7a7SDavid Decotigny  * %ethtool_link_mode_mask_t. Drivers that implement
18423f1ac7a7SDavid Decotigny  * %set_link_ksettings() should validate all fields other than @cmd
18433f1ac7a7SDavid Decotigny  * and @link_mode_masks_nwords that are not described as read-only or
18443f1ac7a7SDavid Decotigny  * deprecated, and must ignore all fields described as read-only.
18453f1ac7a7SDavid Decotigny  */
18463f1ac7a7SDavid Decotigny struct ethtool_link_settings {
18473f1ac7a7SDavid Decotigny 	__u32	cmd;
18483f1ac7a7SDavid Decotigny 	__u32	speed;
18493f1ac7a7SDavid Decotigny 	__u8	duplex;
18503f1ac7a7SDavid Decotigny 	__u8	port;
18513f1ac7a7SDavid Decotigny 	__u8	phy_address;
18523f1ac7a7SDavid Decotigny 	__u8	autoneg;
18533f1ac7a7SDavid Decotigny 	__u8	mdio_support;
18543f1ac7a7SDavid Decotigny 	__u8	eth_tp_mdix;
18553f1ac7a7SDavid Decotigny 	__u8	eth_tp_mdix_ctrl;
18563f1ac7a7SDavid Decotigny 	__s8	link_mode_masks_nwords;
185719cab887SFlorian Fainelli 	__u8	transceiver;
185819cab887SFlorian Fainelli 	__u8	reserved1[3];
185919cab887SFlorian Fainelli 	__u32	reserved[7];
18603f1ac7a7SDavid Decotigny 	__u32	link_mode_masks[0];
18613f1ac7a7SDavid Decotigny 	/* layout of link_mode_masks fields:
18623f1ac7a7SDavid Decotigny 	 * __u32 map_supported[link_mode_masks_nwords];
18633f1ac7a7SDavid Decotigny 	 * __u32 map_advertising[link_mode_masks_nwords];
18643f1ac7a7SDavid Decotigny 	 * __u32 map_lp_advertising[link_mode_masks_nwords];
18653f1ac7a7SDavid Decotigny 	 */
18663f1ac7a7SDavid Decotigny };
1867607ca46eSDavid Howells #endif /* _UAPI_LINUX_ETHTOOL_H */
1868