xref: /linux-6.15/include/linux/ethtool.h (revision 79f88a58)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * ethtool.h: Defines for Linux ethtool.
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Copyright (C) 1998 David S. Miller ([email protected])
61da177e4SLinus Torvalds  * Copyright 2001 Jeff Garzik <[email protected]>
71da177e4SLinus Torvalds  * Portions Copyright 2001 Sun Microsystems ([email protected])
81da177e4SLinus Torvalds  * Portions Copyright 2002 Intel ([email protected],
91da177e4SLinus Torvalds  *                                [email protected],
101da177e4SLinus Torvalds  *                                [email protected])
1159089d8dSSantwona Behera  * Portions Copyright (C) Sun Microsystems 2008
121da177e4SLinus Torvalds  */
131da177e4SLinus Torvalds #ifndef _LINUX_ETHTOOL_H
141da177e4SLinus Torvalds #define _LINUX_ETHTOOL_H
151da177e4SLinus Torvalds 
163f1ac7a7SDavid Decotigny #include <linux/bitmap.h>
173a7da39dSBen Hutchings #include <linux/compat.h>
18dd1c4164SVladimir Oltean #include <linux/if_ether.h>
19f3ccfda1SYufeng Mo #include <linux/netlink.h>
20607ca46eSDavid Howells #include <uapi/linux/ethtool.h>
212111375bSKory Maincent #include <uapi/linux/net_tstamp.h>
221da177e4SLinus Torvalds 
233a7da39dSBen Hutchings struct compat_ethtool_rx_flow_spec {
243a7da39dSBen Hutchings 	u32		flow_type;
25127fe533SAlexander Duyck 	union ethtool_flow_union h_u;
26127fe533SAlexander Duyck 	struct ethtool_flow_ext h_ext;
27127fe533SAlexander Duyck 	union ethtool_flow_union m_u;
28127fe533SAlexander Duyck 	struct ethtool_flow_ext m_ext;
293a7da39dSBen Hutchings 	compat_u64	ring_cookie;
303a7da39dSBen Hutchings 	u32		location;
313a7da39dSBen Hutchings };
323a7da39dSBen Hutchings 
333a7da39dSBen Hutchings struct compat_ethtool_rxnfc {
343a7da39dSBen Hutchings 	u32				cmd;
353a7da39dSBen Hutchings 	u32				flow_type;
363a7da39dSBen Hutchings 	compat_u64			data;
373a7da39dSBen Hutchings 	struct compat_ethtool_rx_flow_spec fs;
383a7da39dSBen Hutchings 	u32				rule_cnt;
395299a11aSGustavo A. R. Silva 	u32				rule_locs[];
403a7da39dSBen Hutchings };
413a7da39dSBen Hutchings 
42a1467085SDavid S. Miller #include <linux/rculist.h>
43a1467085SDavid S. Miller 
4468f512f2SBen Hutchings /**
4568f512f2SBen Hutchings  * enum ethtool_phys_id_state - indicator state for physical identification
4668f512f2SBen Hutchings  * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
4768f512f2SBen Hutchings  * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
4868f512f2SBen Hutchings  * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
4968f512f2SBen Hutchings  *	is not supported)
5068f512f2SBen Hutchings  * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
5168f512f2SBen Hutchings  *	is not supported)
5268f512f2SBen Hutchings  */
5368f512f2SBen Hutchings enum ethtool_phys_id_state {
5468f512f2SBen Hutchings 	ETHTOOL_ID_INACTIVE,
5568f512f2SBen Hutchings 	ETHTOOL_ID_ACTIVE,
5668f512f2SBen Hutchings 	ETHTOOL_ID_ON,
5768f512f2SBen Hutchings 	ETHTOOL_ID_OFF
5868f512f2SBen Hutchings };
5968f512f2SBen Hutchings 
60892311f6SEyal Perry enum {
61892311f6SEyal Perry 	ETH_RSS_HASH_TOP_BIT, /* Configurable RSS hash function - Toeplitz */
62892311f6SEyal Perry 	ETH_RSS_HASH_XOR_BIT, /* Configurable RSS hash function - Xor */
63abb521e3SJakub Kicinski 	ETH_RSS_HASH_CRC32_BIT, /* Configurable RSS hash function - Crc32 */
64892311f6SEyal Perry 
65892311f6SEyal Perry 	/*
66892311f6SEyal Perry 	 * Add your fresh new hash function bits above and remember to update
67892311f6SEyal Perry 	 * rss_hash_func_strings[] in ethtool.c
68892311f6SEyal Perry 	 */
69892311f6SEyal Perry 	ETH_RSS_HASH_FUNCS_COUNT
70892311f6SEyal Perry };
71892311f6SEyal Perry 
720b70c256SHao Chen /**
730b70c256SHao Chen  * struct kernel_ethtool_ringparam - RX/TX ring configuration
740b70c256SHao Chen  * @rx_buf_len: Current length of buffers on the rx ring.
759690ae60SJakub Kicinski  * @tcp_data_split: Scatter packet headers and data to separate buffers
764dc84c06SJie Wang  * @tx_push: The flag of tx push mode
775b4e9a7aSShannon Nelson  * @rx_push: The flag of rx push mode
781241e329SSubbaraya Sundeep  * @cqe_size: Size of TX/RX completion queue event
79233eb4e7SShay Agroskin  * @tx_push_buf_len: Size of TX push buffer
80233eb4e7SShay Agroskin  * @tx_push_buf_max_len: Maximum allowed size of TX push buffer
81eec8359fSTaehee Yoo  * @hds_thresh: Packet size threshold for header data split (HDS)
82eec8359fSTaehee Yoo  * @hds_thresh_max: Maximum supported setting for @hds_threshold
83eec8359fSTaehee Yoo  *
840b70c256SHao Chen  */
850b70c256SHao Chen struct kernel_ethtool_ringparam {
860b70c256SHao Chen 	u32	rx_buf_len;
879690ae60SJakub Kicinski 	u8	tcp_data_split;
884dc84c06SJie Wang 	u8	tx_push;
895b4e9a7aSShannon Nelson 	u8	rx_push;
901241e329SSubbaraya Sundeep 	u32	cqe_size;
91233eb4e7SShay Agroskin 	u32	tx_push_buf_len;
92233eb4e7SShay Agroskin 	u32	tx_push_buf_max_len;
93eec8359fSTaehee Yoo 	u32	hds_thresh;
94eec8359fSTaehee Yoo 	u32	hds_thresh_max;
950b70c256SHao Chen };
960b70c256SHao Chen 
970b70c256SHao Chen /**
980b70c256SHao Chen  * enum ethtool_supported_ring_param - indicator caps for setting ring params
990b70c256SHao Chen  * @ETHTOOL_RING_USE_RX_BUF_LEN: capture for setting rx_buf_len
1001241e329SSubbaraya Sundeep  * @ETHTOOL_RING_USE_CQE_SIZE: capture for setting cqe_size
1014dc84c06SJie Wang  * @ETHTOOL_RING_USE_TX_PUSH: capture for setting tx_push
1025b4e9a7aSShannon Nelson  * @ETHTOOL_RING_USE_RX_PUSH: capture for setting rx_push
103233eb4e7SShay Agroskin  * @ETHTOOL_RING_USE_TX_PUSH_BUF_LEN: capture for setting tx_push_buf_len
10450d73710SAlexander Lobakin  * @ETHTOOL_RING_USE_TCP_DATA_SPLIT: capture for setting tcp_data_split
105eec8359fSTaehee Yoo  * @ETHTOOL_RING_USE_HDS_THRS: capture for setting header-data-split-thresh
1060b70c256SHao Chen  */
1070b70c256SHao Chen enum ethtool_supported_ring_param {
1080b70c256SHao Chen 	ETHTOOL_RING_USE_RX_BUF_LEN		= BIT(0),
1091241e329SSubbaraya Sundeep 	ETHTOOL_RING_USE_CQE_SIZE		= BIT(1),
1104dc84c06SJie Wang 	ETHTOOL_RING_USE_TX_PUSH		= BIT(2),
1115b4e9a7aSShannon Nelson 	ETHTOOL_RING_USE_RX_PUSH		= BIT(3),
112233eb4e7SShay Agroskin 	ETHTOOL_RING_USE_TX_PUSH_BUF_LEN	= BIT(4),
11350d73710SAlexander Lobakin 	ETHTOOL_RING_USE_TCP_DATA_SPLIT		= BIT(5),
114eec8359fSTaehee Yoo 	ETHTOOL_RING_USE_HDS_THRS		= BIT(6),
1150b70c256SHao Chen };
1160b70c256SHao Chen 
117892311f6SEyal Perry #define __ETH_RSS_HASH_BIT(bit)	((u32)1 << (bit))
118892311f6SEyal Perry #define __ETH_RSS_HASH(name)	__ETH_RSS_HASH_BIT(ETH_RSS_HASH_##name##_BIT)
119892311f6SEyal Perry 
120892311f6SEyal Perry #define ETH_RSS_HASH_TOP	__ETH_RSS_HASH(TOP)
121892311f6SEyal Perry #define ETH_RSS_HASH_XOR	__ETH_RSS_HASH(XOR)
122abb521e3SJakub Kicinski #define ETH_RSS_HASH_CRC32	__ETH_RSS_HASH(CRC32)
123892311f6SEyal Perry 
124892311f6SEyal Perry #define ETH_RSS_HASH_UNKNOWN	0
125892311f6SEyal Perry #define ETH_RSS_HASH_NO_CHANGE	0
126892311f6SEyal Perry 
1271da177e4SLinus Torvalds struct net_device;
128c781ff12SVladyslav Tarasiuk struct netlink_ext_ack;
1291da177e4SLinus Torvalds 
130f0ebc2b6SJakub Kicinski /* Link extended state and substate. */
131ecc31c60SAmit Cohen struct ethtool_link_ext_state_info {
132ecc31c60SAmit Cohen 	enum ethtool_link_ext_state link_ext_state;
133ecc31c60SAmit Cohen 	union {
134ecc31c60SAmit Cohen 		enum ethtool_link_ext_substate_autoneg autoneg;
135ecc31c60SAmit Cohen 		enum ethtool_link_ext_substate_link_training link_training;
136ecc31c60SAmit Cohen 		enum ethtool_link_ext_substate_link_logical_mismatch link_logical_mismatch;
137ecc31c60SAmit Cohen 		enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity;
138ecc31c60SAmit Cohen 		enum ethtool_link_ext_substate_cable_issue cable_issue;
1393dfb5112SIdo Schimmel 		enum ethtool_link_ext_substate_module module;
140e2f08207SMoshe Tal 		u32 __link_ext_substate;
141ecc31c60SAmit Cohen 	};
142ecc31c60SAmit Cohen };
143ecc31c60SAmit Cohen 
1449a0f830fSJakub Kicinski struct ethtool_link_ext_stats {
1459a0f830fSJakub Kicinski 	/* Custom Linux statistic for PHY level link down events.
1469a0f830fSJakub Kicinski 	 * In a simpler world it should be equal to netdev->carrier_down_count
1479a0f830fSJakub Kicinski 	 * unfortunately netdev also counts local reconfigurations which don't
1489a0f830fSJakub Kicinski 	 * actually take the physical link down, not to mention NC-SI which,
1499a0f830fSJakub Kicinski 	 * if present, keeps the link up regardless of host state.
1509a0f830fSJakub Kicinski 	 * This statistic counts when PHY _actually_ went down, or lost link.
1519a0f830fSJakub Kicinski 	 *
1529a0f830fSJakub Kicinski 	 * Note that we need u64 for ethtool_stats_init() and comparisons
1539a0f830fSJakub Kicinski 	 * to ETHTOOL_STAT_NOT_SET, but only u32 is exposed to the user.
1549a0f830fSJakub Kicinski 	 */
1559a0f830fSJakub Kicinski 	u64 link_down_events;
1569a0f830fSJakub Kicinski };
1579a0f830fSJakub Kicinski 
1581da177e4SLinus Torvalds /**
159278bc429SBen Hutchings  * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
160278bc429SBen Hutchings  * @index: Index in RX flow hash indirection table
161278bc429SBen Hutchings  * @n_rx_rings: Number of RX rings to use
162278bc429SBen Hutchings  *
163278bc429SBen Hutchings  * This function provides the default policy for RX flow hash indirection.
164278bc429SBen Hutchings  */
ethtool_rxfh_indir_default(u32 index,u32 n_rx_rings)165278bc429SBen Hutchings static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
166278bc429SBen Hutchings {
167278bc429SBen Hutchings 	return index % n_rx_rings;
168278bc429SBen Hutchings }
169278bc429SBen Hutchings 
1706ad2962fSEdward Cree /**
1716ad2962fSEdward Cree  * struct ethtool_rxfh_context - a custom RSS context configuration
1726ad2962fSEdward Cree  * @indir_size: Number of u32 entries in indirection table
1736ad2962fSEdward Cree  * @key_size: Size of hash key, in bytes
1746ad2962fSEdward Cree  * @priv_size: Size of driver private data, in bytes
1756ad2962fSEdward Cree  * @hfunc: RSS hash function identifier.  One of the %ETH_RSS_HASH_*
1766ad2962fSEdward Cree  * @input_xfrm: Defines how the input data is transformed. Valid values are one
1776ad2962fSEdward Cree  *	of %RXH_XFRM_*.
1786ad2962fSEdward Cree  * @indir_configured: indir has been specified (at create time or subsequently)
1796ad2962fSEdward Cree  * @key_configured: hkey has been specified (at create time or subsequently)
1806ad2962fSEdward Cree  */
1816ad2962fSEdward Cree struct ethtool_rxfh_context {
1826ad2962fSEdward Cree 	u32 indir_size;
1836ad2962fSEdward Cree 	u32 key_size;
1846ad2962fSEdward Cree 	u16 priv_size;
1856ad2962fSEdward Cree 	u8 hfunc;
1866ad2962fSEdward Cree 	u8 input_xfrm;
1876ad2962fSEdward Cree 	u8 indir_configured:1;
1886ad2962fSEdward Cree 	u8 key_configured:1;
1896ad2962fSEdward Cree 	/* private: driver private data, indirection table, and hash key are
1906ad2962fSEdward Cree 	 * stored sequentially in @data area.  Use below helpers to access.
1916ad2962fSEdward Cree 	 */
19228c8757aSJakub Kicinski 	u32 key_off;
1936ad2962fSEdward Cree 	u8 data[] __aligned(sizeof(void *));
1946ad2962fSEdward Cree };
1956ad2962fSEdward Cree 
ethtool_rxfh_context_priv(struct ethtool_rxfh_context * ctx)1966ad2962fSEdward Cree static inline void *ethtool_rxfh_context_priv(struct ethtool_rxfh_context *ctx)
1976ad2962fSEdward Cree {
1986ad2962fSEdward Cree 	return ctx->data;
1996ad2962fSEdward Cree }
2006ad2962fSEdward Cree 
ethtool_rxfh_context_indir(struct ethtool_rxfh_context * ctx)2016ad2962fSEdward Cree static inline u32 *ethtool_rxfh_context_indir(struct ethtool_rxfh_context *ctx)
2026ad2962fSEdward Cree {
2036ad2962fSEdward Cree 	return (u32 *)(ctx->data + ALIGN(ctx->priv_size, sizeof(u32)));
2046ad2962fSEdward Cree }
2056ad2962fSEdward Cree 
ethtool_rxfh_context_key(struct ethtool_rxfh_context * ctx)2066ad2962fSEdward Cree static inline u8 *ethtool_rxfh_context_key(struct ethtool_rxfh_context *ctx)
2076ad2962fSEdward Cree {
20828c8757aSJakub Kicinski 	return &ctx->data[ctx->key_off];
209eac9122fSEdward Cree }
210eac9122fSEdward Cree 
211d69ba6bbSJakub Kicinski void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id);
212d69ba6bbSJakub Kicinski 
213*79f88a58SMaxime Chevallier struct link_mode_info {
214*79f88a58SMaxime Chevallier 	int                             speed;
215*79f88a58SMaxime Chevallier 	u8                              lanes;
216*79f88a58SMaxime Chevallier 	u8                              duplex;
217*79f88a58SMaxime Chevallier };
218*79f88a58SMaxime Chevallier 
219*79f88a58SMaxime Chevallier extern const struct link_mode_info link_mode_params[];
220*79f88a58SMaxime Chevallier 
2213f1ac7a7SDavid Decotigny /* declare a link mode bitmap */
2223f1ac7a7SDavid Decotigny #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name)		\
2233f1ac7a7SDavid Decotigny 	DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS)
2243f1ac7a7SDavid Decotigny 
2253f1ac7a7SDavid Decotigny /* drivers must ignore base.cmd and base.link_mode_masks_nwords
2263f1ac7a7SDavid Decotigny  * fields, but they are allowed to overwrite them (will be ignored).
2273f1ac7a7SDavid Decotigny  */
2283f1ac7a7SDavid Decotigny struct ethtool_link_ksettings {
2291cfb5e57SKees Cook 	struct ethtool_link_settings base;
2303f1ac7a7SDavid Decotigny 	struct {
2313f1ac7a7SDavid Decotigny 		__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
2323f1ac7a7SDavid Decotigny 		__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
2333f1ac7a7SDavid Decotigny 		__ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising);
2343f1ac7a7SDavid Decotigny 	} link_modes;
235012ce4ddSDanielle Ratson 	u32	lanes;
2363f1ac7a7SDavid Decotigny };
2373f1ac7a7SDavid Decotigny 
2383f1ac7a7SDavid Decotigny /**
2393f1ac7a7SDavid Decotigny  * ethtool_link_ksettings_zero_link_mode - clear link_ksettings link mode mask
2403f1ac7a7SDavid Decotigny  *   @ptr : pointer to struct ethtool_link_ksettings
2413f1ac7a7SDavid Decotigny  *   @name : one of supported/advertising/lp_advertising
2423f1ac7a7SDavid Decotigny  */
2433f1ac7a7SDavid Decotigny #define ethtool_link_ksettings_zero_link_mode(ptr, name)		\
2443f1ac7a7SDavid Decotigny 	bitmap_zero((ptr)->link_modes.name, __ETHTOOL_LINK_MODE_MASK_NBITS)
2453f1ac7a7SDavid Decotigny 
2463f1ac7a7SDavid Decotigny /**
2473f1ac7a7SDavid Decotigny  * ethtool_link_ksettings_add_link_mode - set bit in link_ksettings
2483f1ac7a7SDavid Decotigny  * link mode mask
2493f1ac7a7SDavid Decotigny  *   @ptr : pointer to struct ethtool_link_ksettings
2503f1ac7a7SDavid Decotigny  *   @name : one of supported/advertising/lp_advertising
2513f1ac7a7SDavid Decotigny  *   @mode : one of the ETHTOOL_LINK_MODE_*_BIT
2523f1ac7a7SDavid Decotigny  * (not atomic, no bound checking)
2533f1ac7a7SDavid Decotigny  */
2543f1ac7a7SDavid Decotigny #define ethtool_link_ksettings_add_link_mode(ptr, name, mode)		\
2553f1ac7a7SDavid Decotigny 	__set_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
2563f1ac7a7SDavid Decotigny 
2573f1ac7a7SDavid Decotigny /**
258606c07f3SLendacky, Thomas  * ethtool_link_ksettings_del_link_mode - clear bit in link_ksettings
259606c07f3SLendacky, Thomas  * link mode mask
260606c07f3SLendacky, Thomas  *   @ptr : pointer to struct ethtool_link_ksettings
261606c07f3SLendacky, Thomas  *   @name : one of supported/advertising/lp_advertising
262606c07f3SLendacky, Thomas  *   @mode : one of the ETHTOOL_LINK_MODE_*_BIT
263606c07f3SLendacky, Thomas  * (not atomic, no bound checking)
264606c07f3SLendacky, Thomas  */
265606c07f3SLendacky, Thomas #define ethtool_link_ksettings_del_link_mode(ptr, name, mode)		\
266606c07f3SLendacky, Thomas 	__clear_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
267606c07f3SLendacky, Thomas 
268606c07f3SLendacky, Thomas /**
2693f1ac7a7SDavid Decotigny  * ethtool_link_ksettings_test_link_mode - test bit in ksettings link mode mask
2703f1ac7a7SDavid Decotigny  *   @ptr : pointer to struct ethtool_link_ksettings
2713f1ac7a7SDavid Decotigny  *   @name : one of supported/advertising/lp_advertising
2723f1ac7a7SDavid Decotigny  *   @mode : one of the ETHTOOL_LINK_MODE_*_BIT
2733f1ac7a7SDavid Decotigny  * (not atomic, no bound checking)
2743f1ac7a7SDavid Decotigny  *
2753f330db3SJakub Kicinski  * Returns: true/false.
2763f1ac7a7SDavid Decotigny  */
2773f1ac7a7SDavid Decotigny #define ethtool_link_ksettings_test_link_mode(ptr, name, mode)		\
2783f1ac7a7SDavid Decotigny 	test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
2793f1ac7a7SDavid Decotigny 
2803f1ac7a7SDavid Decotigny extern int
2813f1ac7a7SDavid Decotigny __ethtool_get_link_ksettings(struct net_device *dev,
2823f1ac7a7SDavid Decotigny 			     struct ethtool_link_ksettings *link_ksettings);
2833f1ac7a7SDavid Decotigny 
284d80a5233SHeiner Kallweit struct ethtool_keee {
2851f069de6SHeiner Kallweit 	__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
2861f069de6SHeiner Kallweit 	__ETHTOOL_DECLARE_LINK_MODE_MASK(advertised);
2871f069de6SHeiner Kallweit 	__ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertised);
288d80a5233SHeiner Kallweit 	u32	tx_lpi_timer;
289285cc15cSHeiner Kallweit 	bool	tx_lpi_enabled;
290285cc15cSHeiner Kallweit 	bool	eee_active;
291285cc15cSHeiner Kallweit 	bool	eee_enabled;
292d80a5233SHeiner Kallweit };
293d80a5233SHeiner Kallweit 
294029ee6b1SYufeng Mo struct kernel_ethtool_coalesce {
295029ee6b1SYufeng Mo 	u8 use_cqe_mode_tx;
296029ee6b1SYufeng Mo 	u8 use_cqe_mode_rx;
29731de2842SDaniele Palmas 	u32 tx_aggr_max_bytes;
29831de2842SDaniele Palmas 	u32 tx_aggr_max_frames;
29931de2842SDaniele Palmas 	u32 tx_aggr_time_usecs;
300029ee6b1SYufeng Mo };
301029ee6b1SYufeng Mo 
3025a6cd6deSAlan Brady /**
3035a6cd6deSAlan Brady  * ethtool_intersect_link_masks - Given two link masks, AND them together
3045a6cd6deSAlan Brady  * @dst: first mask and where result is stored
3055a6cd6deSAlan Brady  * @src: second mask to intersect with
3065a6cd6deSAlan Brady  *
3075a6cd6deSAlan Brady  * Given two link mode masks, AND them together and save the result in dst.
3085a6cd6deSAlan Brady  */
3095a6cd6deSAlan Brady void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst,
3105a6cd6deSAlan Brady 				  struct ethtool_link_ksettings *src);
3115a6cd6deSAlan Brady 
3126d62b4d5SPhilippe Reynes void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst,
3136d62b4d5SPhilippe Reynes 					     u32 legacy_u32);
3146d62b4d5SPhilippe Reynes 
3156d62b4d5SPhilippe Reynes /* return false if src had higher bits set. lower bits always updated. */
3166d62b4d5SPhilippe Reynes bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
3176d62b4d5SPhilippe Reynes 				     const unsigned long *src);
3186d62b4d5SPhilippe Reynes 
31995cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_USECS		BIT(0)
32095cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_MAX_FRAMES		BIT(1)
32195cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_USECS_IRQ		BIT(2)
32295cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ	BIT(3)
32395cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_USECS		BIT(4)
32495cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_MAX_FRAMES		BIT(5)
32595cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_USECS_IRQ		BIT(6)
32695cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ	BIT(7)
32795cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_STATS_BLOCK_USECS	BIT(8)
32895cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USE_ADAPTIVE_RX	BIT(9)
32995cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USE_ADAPTIVE_TX	BIT(10)
33095cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_PKT_RATE_LOW		BIT(11)
33195cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_USECS_LOW		BIT(12)
33295cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW	BIT(13)
33395cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_USECS_LOW		BIT(14)
33495cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW	BIT(15)
33595cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_PKT_RATE_HIGH		BIT(16)
33695cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_USECS_HIGH		BIT(17)
33795cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH	BIT(18)
33895cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_USECS_HIGH		BIT(19)
33995cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH	BIT(20)
34095cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL	BIT(21)
341029ee6b1SYufeng Mo #define ETHTOOL_COALESCE_USE_CQE_RX		BIT(22)
342029ee6b1SYufeng Mo #define ETHTOOL_COALESCE_USE_CQE_TX		BIT(23)
34331de2842SDaniele Palmas #define ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES	BIT(24)
34431de2842SDaniele Palmas #define ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES	BIT(25)
34531de2842SDaniele Palmas #define ETHTOOL_COALESCE_TX_AGGR_TIME_USECS	BIT(26)
346f750dfe8SHeng Qi #define ETHTOOL_COALESCE_RX_PROFILE		BIT(27)
347f750dfe8SHeng Qi #define ETHTOOL_COALESCE_TX_PROFILE		BIT(28)
348f750dfe8SHeng Qi #define ETHTOOL_COALESCE_ALL_PARAMS		GENMASK(28, 0)
34995cddcb5SJakub Kicinski 
35095cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USECS						\
35195cddcb5SJakub Kicinski 	(ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)
35295cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_MAX_FRAMES					\
35395cddcb5SJakub Kicinski 	(ETHTOOL_COALESCE_RX_MAX_FRAMES | ETHTOOL_COALESCE_TX_MAX_FRAMES)
35495cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USECS_IRQ					\
35595cddcb5SJakub Kicinski 	(ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ)
35695cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_MAX_FRAMES_IRQ		\
35795cddcb5SJakub Kicinski 	(ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ |	\
35895cddcb5SJakub Kicinski 	 ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ)
35995cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USE_ADAPTIVE					\
36095cddcb5SJakub Kicinski 	(ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_ADAPTIVE_TX)
3618213f6c9SJakub Kicinski #define ETHTOOL_COALESCE_USECS_LOW_HIGH					\
3628213f6c9SJakub Kicinski 	(ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_TX_USECS_LOW | \
3638213f6c9SJakub Kicinski 	 ETHTOOL_COALESCE_RX_USECS_HIGH | ETHTOOL_COALESCE_TX_USECS_HIGH)
3644f9546d2SJakub Kicinski #define ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH	\
3654f9546d2SJakub Kicinski 	(ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW |	\
3664f9546d2SJakub Kicinski 	 ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW |	\
3674f9546d2SJakub Kicinski 	 ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH |	\
3684f9546d2SJakub Kicinski 	 ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH)
369812df69bSJakub Kicinski #define ETHTOOL_COALESCE_PKT_RATE_RX_USECS				\
370812df69bSJakub Kicinski 	(ETHTOOL_COALESCE_USE_ADAPTIVE_RX |				\
371812df69bSJakub Kicinski 	 ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_RX_USECS_HIGH | \
372812df69bSJakub Kicinski 	 ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \
373812df69bSJakub Kicinski 	 ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL)
374029ee6b1SYufeng Mo #define ETHTOOL_COALESCE_USE_CQE					\
375029ee6b1SYufeng Mo 	(ETHTOOL_COALESCE_USE_CQE_RX | ETHTOOL_COALESCE_USE_CQE_TX)
37631de2842SDaniele Palmas #define ETHTOOL_COALESCE_TX_AGGR		\
37731de2842SDaniele Palmas 	(ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES |	\
37831de2842SDaniele Palmas 	 ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES |	\
37931de2842SDaniele Palmas 	 ETHTOOL_COALESCE_TX_AGGR_TIME_USECS)
38095cddcb5SJakub Kicinski 
3819a27a330SJakub Kicinski #define ETHTOOL_STAT_NOT_SET	(~0ULL)
3829a27a330SJakub Kicinski 
ethtool_stats_init(u64 * stats,unsigned int n)383c5797f8aSJakub Kicinski static inline void ethtool_stats_init(u64 *stats, unsigned int n)
384c5797f8aSJakub Kicinski {
385c5797f8aSJakub Kicinski 	while (n--)
386c5797f8aSJakub Kicinski 		stats[n] = ETHTOOL_STAT_NOT_SET;
387c5797f8aSJakub Kicinski }
388c5797f8aSJakub Kicinski 
389ca224454SJakub Kicinski /* Basic IEEE 802.3 MAC statistics (30.3.1.1.*), not otherwise exposed
390ca224454SJakub Kicinski  * via a more targeted API.
391ca224454SJakub Kicinski  */
392ca224454SJakub Kicinski struct ethtool_eth_mac_stats {
39304692c90SVladimir Oltean 	enum ethtool_mac_stats_src src;
394449c5459SVladimir Oltean 	struct_group(stats,
395ca224454SJakub Kicinski 		u64 FramesTransmittedOK;
396ca224454SJakub Kicinski 		u64 SingleCollisionFrames;
397ca224454SJakub Kicinski 		u64 MultipleCollisionFrames;
398ca224454SJakub Kicinski 		u64 FramesReceivedOK;
399ca224454SJakub Kicinski 		u64 FrameCheckSequenceErrors;
400ca224454SJakub Kicinski 		u64 AlignmentErrors;
401ca224454SJakub Kicinski 		u64 OctetsTransmittedOK;
402ca224454SJakub Kicinski 		u64 FramesWithDeferredXmissions;
403ca224454SJakub Kicinski 		u64 LateCollisions;
404ca224454SJakub Kicinski 		u64 FramesAbortedDueToXSColls;
405ca224454SJakub Kicinski 		u64 FramesLostDueToIntMACXmitError;
406ca224454SJakub Kicinski 		u64 CarrierSenseErrors;
407ca224454SJakub Kicinski 		u64 OctetsReceivedOK;
408ca224454SJakub Kicinski 		u64 FramesLostDueToIntMACRcvError;
409ca224454SJakub Kicinski 		u64 MulticastFramesXmittedOK;
410ca224454SJakub Kicinski 		u64 BroadcastFramesXmittedOK;
411ca224454SJakub Kicinski 		u64 FramesWithExcessiveDeferral;
412ca224454SJakub Kicinski 		u64 MulticastFramesReceivedOK;
413ca224454SJakub Kicinski 		u64 BroadcastFramesReceivedOK;
414ca224454SJakub Kicinski 		u64 InRangeLengthErrors;
415ca224454SJakub Kicinski 		u64 OutOfRangeLengthField;
416ca224454SJakub Kicinski 		u64 FrameTooLongErrors;
417449c5459SVladimir Oltean 	);
418ca224454SJakub Kicinski };
419ca224454SJakub Kicinski 
420f09ea6fbSJakub Kicinski /* Basic IEEE 802.3 PHY statistics (30.3.2.1.*), not otherwise exposed
421f09ea6fbSJakub Kicinski  * via a more targeted API.
422f09ea6fbSJakub Kicinski  */
423f09ea6fbSJakub Kicinski struct ethtool_eth_phy_stats {
42404692c90SVladimir Oltean 	enum ethtool_mac_stats_src src;
425449c5459SVladimir Oltean 	struct_group(stats,
426f09ea6fbSJakub Kicinski 		u64 SymbolErrorDuringCarrier;
427449c5459SVladimir Oltean 	);
428f09ea6fbSJakub Kicinski };
429f09ea6fbSJakub Kicinski 
430b7a2c1feSJakub Kicinski /**
431b7a2c1feSJakub Kicinski  * struct ethtool_phy_stats - PHY-level statistics counters
432b7a2c1feSJakub Kicinski  * @rx_packets: Total successfully received frames
433b7a2c1feSJakub Kicinski  * @rx_bytes: Total successfully received bytes
434b7a2c1feSJakub Kicinski  * @rx_errors: Total received frames with errors (e.g., CRC errors)
435b7a2c1feSJakub Kicinski  * @tx_packets: Total successfully transmitted frames
436b7a2c1feSJakub Kicinski  * @tx_bytes: Total successfully transmitted bytes
437b7a2c1feSJakub Kicinski  * @tx_errors: Total transmitted frames with errors
438b7a2c1feSJakub Kicinski  *
439b7a2c1feSJakub Kicinski  * This structure provides a standardized interface for reporting
440b7a2c1feSJakub Kicinski  * PHY-level statistics counters. It is designed to expose statistics
441b7a2c1feSJakub Kicinski  * commonly provided by PHYs but not explicitly defined in the IEEE
442b7a2c1feSJakub Kicinski  * 802.3 standard.
443b7a2c1feSJakub Kicinski  */
444b7a2c1feSJakub Kicinski struct ethtool_phy_stats {
445b7a2c1feSJakub Kicinski 	u64 rx_packets;
446b7a2c1feSJakub Kicinski 	u64 rx_bytes;
447b7a2c1feSJakub Kicinski 	u64 rx_errors;
448b7a2c1feSJakub Kicinski 	u64 tx_packets;
449b7a2c1feSJakub Kicinski 	u64 tx_bytes;
450b7a2c1feSJakub Kicinski 	u64 tx_errors;
451b7a2c1feSJakub Kicinski };
452b7a2c1feSJakub Kicinski 
453bfad2b97SJakub Kicinski /* Basic IEEE 802.3 MAC Ctrl statistics (30.3.3.*), not otherwise exposed
454bfad2b97SJakub Kicinski  * via a more targeted API.
455bfad2b97SJakub Kicinski  */
456bfad2b97SJakub Kicinski struct ethtool_eth_ctrl_stats {
45704692c90SVladimir Oltean 	enum ethtool_mac_stats_src src;
458449c5459SVladimir Oltean 	struct_group(stats,
459bfad2b97SJakub Kicinski 		u64 MACControlFramesTransmitted;
460bfad2b97SJakub Kicinski 		u64 MACControlFramesReceived;
461bfad2b97SJakub Kicinski 		u64 UnsupportedOpcodesReceived;
462449c5459SVladimir Oltean 	);
463bfad2b97SJakub Kicinski };
464bfad2b97SJakub Kicinski 
4659a27a330SJakub Kicinski /**
4669a27a330SJakub Kicinski  * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames
46704692c90SVladimir Oltean  * @src: input field denoting whether stats should be queried from the eMAC or
46804692c90SVladimir Oltean  *	pMAC (if the MM layer is supported). To be ignored otherwise.
4699a27a330SJakub Kicinski  * @tx_pause_frames: transmitted pause frame count. Reported to user space
4709a27a330SJakub Kicinski  *	as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES.
4719a27a330SJakub Kicinski  *
4729a27a330SJakub Kicinski  *	Equivalent to `30.3.4.2 aPAUSEMACCtrlFramesTransmitted`
4739a27a330SJakub Kicinski  *	from the standard.
4749a27a330SJakub Kicinski  *
4759a27a330SJakub Kicinski  * @rx_pause_frames: received pause frame count. Reported to user space
4769a27a330SJakub Kicinski  *	as %ETHTOOL_A_PAUSE_STAT_RX_FRAMES. Equivalent to:
4779a27a330SJakub Kicinski  *
4789a27a330SJakub Kicinski  *	Equivalent to `30.3.4.3 aPAUSEMACCtrlFramesReceived`
4799a27a330SJakub Kicinski  *	from the standard.
4809a27a330SJakub Kicinski  */
4819a27a330SJakub Kicinski struct ethtool_pause_stats {
48204692c90SVladimir Oltean 	enum ethtool_mac_stats_src src;
483449c5459SVladimir Oltean 	struct_group(stats,
4849a27a330SJakub Kicinski 		u64 tx_pause_frames;
4859a27a330SJakub Kicinski 		u64 rx_pause_frames;
486449c5459SVladimir Oltean 	);
4879a27a330SJakub Kicinski };
4889a27a330SJakub Kicinski 
489be85dbfeSJakub Kicinski #define ETHTOOL_MAX_LANES	8
490be85dbfeSJakub Kicinski 
491be85dbfeSJakub Kicinski /**
492be85dbfeSJakub Kicinski  * struct ethtool_fec_stats - statistics for IEEE 802.3 FEC
493be85dbfeSJakub Kicinski  * @corrected_blocks: number of received blocks corrected by FEC
494be85dbfeSJakub Kicinski  *	Reported to user space as %ETHTOOL_A_FEC_STAT_CORRECTED.
495be85dbfeSJakub Kicinski  *
496be85dbfeSJakub Kicinski  *	Equivalent to `30.5.1.1.17 aFECCorrectedBlocks` from the standard.
497be85dbfeSJakub Kicinski  *
498be85dbfeSJakub Kicinski  * @uncorrectable_blocks: number of received blocks FEC was not able to correct
499be85dbfeSJakub Kicinski  *	Reported to user space as %ETHTOOL_A_FEC_STAT_UNCORR.
500be85dbfeSJakub Kicinski  *
501be85dbfeSJakub Kicinski  *	Equivalent to `30.5.1.1.18 aFECUncorrectableBlocks` from the standard.
502be85dbfeSJakub Kicinski  *
503be85dbfeSJakub Kicinski  * @corrected_bits: number of bits corrected by FEC
504be85dbfeSJakub Kicinski  *	Similar to @corrected_blocks but counts individual bit changes,
505be85dbfeSJakub Kicinski  *	not entire FEC data blocks. This is a non-standard statistic.
506be85dbfeSJakub Kicinski  *	Reported to user space as %ETHTOOL_A_FEC_STAT_CORR_BITS.
507be85dbfeSJakub Kicinski  *
5081271ca00SJonathan Corbet  * For each of the above fields, the two substructure members are:
5091271ca00SJonathan Corbet  *
5101271ca00SJonathan Corbet  * - @lanes: per-lane/PCS-instance counts as defined by the standard
5111271ca00SJonathan Corbet  * - @total: error counts for the entire port, for drivers incapable of reporting
512be85dbfeSJakub Kicinski  *	per-lane stats
513be85dbfeSJakub Kicinski  *
514be85dbfeSJakub Kicinski  * Drivers should fill in either only total or per-lane statistics, core
515be85dbfeSJakub Kicinski  * will take care of adding lane values up to produce the total.
516be85dbfeSJakub Kicinski  */
517be85dbfeSJakub Kicinski struct ethtool_fec_stats {
518be85dbfeSJakub Kicinski 	struct ethtool_fec_stat {
519be85dbfeSJakub Kicinski 		u64 total;
520be85dbfeSJakub Kicinski 		u64 lanes[ETHTOOL_MAX_LANES];
521be85dbfeSJakub Kicinski 	} corrected_blocks, uncorrectable_blocks, corrected_bits;
522be85dbfeSJakub Kicinski };
523be85dbfeSJakub Kicinski 
524a8b06e9dSJakub Kicinski /**
525a8b06e9dSJakub Kicinski  * struct ethtool_rmon_hist_range - byte range for histogram statistics
526a8b06e9dSJakub Kicinski  * @low: low bound of the bucket (inclusive)
527a8b06e9dSJakub Kicinski  * @high: high bound of the bucket (inclusive)
528a8b06e9dSJakub Kicinski  */
529a8b06e9dSJakub Kicinski struct ethtool_rmon_hist_range {
530a8b06e9dSJakub Kicinski 	u16 low;
531a8b06e9dSJakub Kicinski 	u16 high;
532a8b06e9dSJakub Kicinski };
533a8b06e9dSJakub Kicinski 
534a8b06e9dSJakub Kicinski #define ETHTOOL_RMON_HIST_MAX	10
535a8b06e9dSJakub Kicinski 
536a8b06e9dSJakub Kicinski /**
537a8b06e9dSJakub Kicinski  * struct ethtool_rmon_stats - selected RMON (RFC 2819) statistics
53804692c90SVladimir Oltean  * @src: input field denoting whether stats should be queried from the eMAC or
53904692c90SVladimir Oltean  *	pMAC (if the MM layer is supported). To be ignored otherwise.
540a8b06e9dSJakub Kicinski  * @undersize_pkts: Equivalent to `etherStatsUndersizePkts` from the RFC.
541a8b06e9dSJakub Kicinski  * @oversize_pkts: Equivalent to `etherStatsOversizePkts` from the RFC.
542a8b06e9dSJakub Kicinski  * @fragments: Equivalent to `etherStatsFragments` from the RFC.
543a8b06e9dSJakub Kicinski  * @jabbers: Equivalent to `etherStatsJabbers` from the RFC.
544a8b06e9dSJakub Kicinski  * @hist: Packet counter for packet length buckets (e.g.
545a8b06e9dSJakub Kicinski  *	`etherStatsPkts128to255Octets` from the RFC).
546a8b06e9dSJakub Kicinski  * @hist_tx: Tx counters in similar form to @hist, not defined in the RFC.
547a8b06e9dSJakub Kicinski  *
548a8b06e9dSJakub Kicinski  * Selection of RMON (RFC 2819) statistics which are not exposed via different
549a8b06e9dSJakub Kicinski  * APIs, primarily the packet-length-based counters.
550a8b06e9dSJakub Kicinski  * Unfortunately different designs choose different buckets beyond
551a8b06e9dSJakub Kicinski  * the 1024B mark (jumbo frame teritory), so the definition of the bucket
552a8b06e9dSJakub Kicinski  * ranges is left to the driver.
553a8b06e9dSJakub Kicinski  */
554a8b06e9dSJakub Kicinski struct ethtool_rmon_stats {
55504692c90SVladimir Oltean 	enum ethtool_mac_stats_src src;
556449c5459SVladimir Oltean 	struct_group(stats,
557a8b06e9dSJakub Kicinski 		u64 undersize_pkts;
558a8b06e9dSJakub Kicinski 		u64 oversize_pkts;
559a8b06e9dSJakub Kicinski 		u64 fragments;
560a8b06e9dSJakub Kicinski 		u64 jabbers;
561a8b06e9dSJakub Kicinski 
562a8b06e9dSJakub Kicinski 		u64 hist[ETHTOOL_RMON_HIST_MAX];
563a8b06e9dSJakub Kicinski 		u64 hist_tx[ETHTOOL_RMON_HIST_MAX];
564449c5459SVladimir Oltean 	);
565a8b06e9dSJakub Kicinski };
566a8b06e9dSJakub Kicinski 
5670e9c1277SRahul Rameshbabu /**
5680e9c1277SRahul Rameshbabu  * struct ethtool_ts_stats - HW timestamping statistics
5690e9c1277SRahul Rameshbabu  * @pkts: Number of packets successfully timestamped by the hardware.
5706a128cdfSVladimir Oltean  * @onestep_pkts_unconfirmed: Number of PTP packets with one-step TX
5716a128cdfSVladimir Oltean  *			      timestamping that were sent, but for which the
5726a128cdfSVladimir Oltean  *			      device offers no confirmation whether they made
5736a128cdfSVladimir Oltean  *			      it onto the wire and the timestamp was inserted
5746a128cdfSVladimir Oltean  *			      in the originTimestamp or correctionField, or
5756a128cdfSVladimir Oltean  *			      not.
5760e9c1277SRahul Rameshbabu  * @lost: Number of hardware timestamping requests where the timestamping
5770e9c1277SRahul Rameshbabu  *	information from the hardware never arrived for submission with
5780e9c1277SRahul Rameshbabu  *	the skb.
5790e9c1277SRahul Rameshbabu  * @err: Number of arbitrary timestamp generation error events that the
5800e9c1277SRahul Rameshbabu  *	hardware encountered, exclusive of @lost statistics. Cases such
5810e9c1277SRahul Rameshbabu  *	as resource exhaustion, unavailability, firmware errors, and
5820e9c1277SRahul Rameshbabu  *	detected illogical timestamp values not submitted with the skb
5830e9c1277SRahul Rameshbabu  *	are inclusive to this counter.
5840e9c1277SRahul Rameshbabu  */
5850e9c1277SRahul Rameshbabu struct ethtool_ts_stats {
5860e9c1277SRahul Rameshbabu 	struct_group(tx_stats,
5870e9c1277SRahul Rameshbabu 		u64 pkts;
5886a128cdfSVladimir Oltean 		u64 onestep_pkts_unconfirmed;
5890e9c1277SRahul Rameshbabu 		u64 lost;
5900e9c1277SRahul Rameshbabu 		u64 err;
5910e9c1277SRahul Rameshbabu 	);
5920e9c1277SRahul Rameshbabu };
5930e9c1277SRahul Rameshbabu 
594c781ff12SVladyslav Tarasiuk #define ETH_MODULE_EEPROM_PAGE_LEN	128
595c781ff12SVladyslav Tarasiuk #define ETH_MODULE_MAX_I2C_ADDRESS	0x7f
596c781ff12SVladyslav Tarasiuk 
597c781ff12SVladyslav Tarasiuk /**
59869540b79SIdo Schimmel  * struct ethtool_module_eeprom - plug-in module EEPROM read / write parameters
59969540b79SIdo Schimmel  * @offset: When @offset is 0-127, it is used as an address to the Lower Memory
60069540b79SIdo Schimmel  *	(@page must be 0). Otherwise, it is used as an address to the
60169540b79SIdo Schimmel  *	Upper Memory.
60269540b79SIdo Schimmel  * @length: Number of bytes to read / write.
60369540b79SIdo Schimmel  * @page: Page number.
60469540b79SIdo Schimmel  * @bank: Bank number, if supported by EEPROM spec.
605c781ff12SVladyslav Tarasiuk  * @i2c_address: I2C address of a page. Value less than 0x7f expected. Most
606c781ff12SVladyslav Tarasiuk  *	EEPROMs use 0x50 or 0x51.
607c781ff12SVladyslav Tarasiuk  * @data: Pointer to buffer with EEPROM data of @length size.
608c781ff12SVladyslav Tarasiuk  */
609c781ff12SVladyslav Tarasiuk struct ethtool_module_eeprom {
610b8c48be2SIdo Schimmel 	u32	offset;
611b8c48be2SIdo Schimmel 	u32	length;
612b8c48be2SIdo Schimmel 	u8	page;
613b8c48be2SIdo Schimmel 	u8	bank;
614b8c48be2SIdo Schimmel 	u8	i2c_address;
615b8c48be2SIdo Schimmel 	u8	*data;
616c781ff12SVladyslav Tarasiuk };
617c781ff12SVladyslav Tarasiuk 
618278bc429SBen Hutchings /**
619353407d9SIdo Schimmel  * struct ethtool_module_power_mode_params - module power mode parameters
620353407d9SIdo Schimmel  * @policy: The power mode policy enforced by the host for the plug-in module.
621353407d9SIdo Schimmel  * @mode: The operational power mode of the plug-in module. Should be filled by
622353407d9SIdo Schimmel  *	device drivers on get operations.
623353407d9SIdo Schimmel  */
624353407d9SIdo Schimmel struct ethtool_module_power_mode_params {
625353407d9SIdo Schimmel 	enum ethtool_module_power_mode_policy policy;
626353407d9SIdo Schimmel 	enum ethtool_module_power_mode mode;
627353407d9SIdo Schimmel };
628353407d9SIdo Schimmel 
629353407d9SIdo Schimmel /**
6302b30f829SVladimir Oltean  * struct ethtool_mm_state - 802.3 MAC merge layer state
6312b30f829SVladimir Oltean  * @verify_time:
6322b30f829SVladimir Oltean  *	wait time between verification attempts in ms (according to clause
6332b30f829SVladimir Oltean  *	30.14.1.6 aMACMergeVerifyTime)
6342b30f829SVladimir Oltean  * @max_verify_time:
6352b30f829SVladimir Oltean  *	maximum accepted value for the @verify_time variable in set requests
6362b30f829SVladimir Oltean  * @verify_status:
6372b30f829SVladimir Oltean  *	state of the verification state machine of the MM layer (according to
6382b30f829SVladimir Oltean  *	clause 30.14.1.2 aMACMergeStatusVerify)
6392b30f829SVladimir Oltean  * @tx_enabled:
6402b30f829SVladimir Oltean  *	set if the MM layer is administratively enabled in the TX direction
6412b30f829SVladimir Oltean  *	(according to clause 30.14.1.3 aMACMergeEnableTx)
6422b30f829SVladimir Oltean  * @tx_active:
6432b30f829SVladimir Oltean  *	set if the MM layer is enabled in the TX direction, which makes FP
6442b30f829SVladimir Oltean  *	possible (according to 30.14.1.5 aMACMergeStatusTx). This should be
6452b30f829SVladimir Oltean  *	true if MM is enabled, and the verification status is either verified,
6462b30f829SVladimir Oltean  *	or disabled.
6472b30f829SVladimir Oltean  * @pmac_enabled:
6482b30f829SVladimir Oltean  *	set if the preemptible MAC is powered on and is able to receive
6492b30f829SVladimir Oltean  *	preemptible packets and respond to verification frames.
6502b30f829SVladimir Oltean  * @verify_enabled:
6512b30f829SVladimir Oltean  *	set if the Verify function of the MM layer (which sends SMD-V
6522b30f829SVladimir Oltean  *	verification requests) is administratively enabled (regardless of
6532b30f829SVladimir Oltean  *	whether it is currently in the ETHTOOL_MM_VERIFY_STATUS_DISABLED state
6542b30f829SVladimir Oltean  *	or not), according to clause 30.14.1.4 aMACMergeVerifyDisableTx (but
6552b30f829SVladimir Oltean  *	using positive rather than negative logic). The device should always
6562b30f829SVladimir Oltean  *	respond to received SMD-V requests as long as @pmac_enabled is set.
6572b30f829SVladimir Oltean  * @tx_min_frag_size:
6582b30f829SVladimir Oltean  *	the minimum size of non-final mPacket fragments that the link partner
6592b30f829SVladimir Oltean  *	supports receiving, expressed in octets. Compared to the definition
6602b30f829SVladimir Oltean  *	from clause 30.14.1.7 aMACMergeAddFragSize which is expressed in the
6612b30f829SVladimir Oltean  *	range 0 to 3 (requiring a translation to the size in octets according
6622b30f829SVladimir Oltean  *	to the formula 64 * (1 + addFragSize) - 4), a value in a continuous and
6632b30f829SVladimir Oltean  *	unbounded range can be specified here.
6642b30f829SVladimir Oltean  * @rx_min_frag_size:
6652b30f829SVladimir Oltean  *	the minimum size of non-final mPacket fragments that this device
6662b30f829SVladimir Oltean  *	supports receiving, expressed in octets.
6672b30f829SVladimir Oltean  */
6682b30f829SVladimir Oltean struct ethtool_mm_state {
6692b30f829SVladimir Oltean 	u32 verify_time;
6702b30f829SVladimir Oltean 	u32 max_verify_time;
6712b30f829SVladimir Oltean 	enum ethtool_mm_verify_status verify_status;
6722b30f829SVladimir Oltean 	bool tx_enabled;
6732b30f829SVladimir Oltean 	bool tx_active;
6742b30f829SVladimir Oltean 	bool pmac_enabled;
6752b30f829SVladimir Oltean 	bool verify_enabled;
6762b30f829SVladimir Oltean 	u32 tx_min_frag_size;
6772b30f829SVladimir Oltean 	u32 rx_min_frag_size;
6782b30f829SVladimir Oltean };
6792b30f829SVladimir Oltean 
6802b30f829SVladimir Oltean /**
6812b30f829SVladimir Oltean  * struct ethtool_mm_cfg - 802.3 MAC merge layer configuration
6822b30f829SVladimir Oltean  * @verify_time: see struct ethtool_mm_state
6832b30f829SVladimir Oltean  * @verify_enabled: see struct ethtool_mm_state
6842b30f829SVladimir Oltean  * @tx_enabled: see struct ethtool_mm_state
6852b30f829SVladimir Oltean  * @pmac_enabled: see struct ethtool_mm_state
6862b30f829SVladimir Oltean  * @tx_min_frag_size: see struct ethtool_mm_state
6872b30f829SVladimir Oltean  */
6882b30f829SVladimir Oltean struct ethtool_mm_cfg {
6892b30f829SVladimir Oltean 	u32 verify_time;
6902b30f829SVladimir Oltean 	bool verify_enabled;
6912b30f829SVladimir Oltean 	bool tx_enabled;
6922b30f829SVladimir Oltean 	bool pmac_enabled;
6932b30f829SVladimir Oltean 	u32 tx_min_frag_size;
6942b30f829SVladimir Oltean };
6952b30f829SVladimir Oltean 
6962b30f829SVladimir Oltean /**
6972b30f829SVladimir Oltean  * struct ethtool_mm_stats - 802.3 MAC merge layer statistics
6982b30f829SVladimir Oltean  * @MACMergeFrameAssErrorCount:
6992b30f829SVladimir Oltean  *	received MAC frames with reassembly errors
7002b30f829SVladimir Oltean  * @MACMergeFrameSmdErrorCount:
7012b30f829SVladimir Oltean  *	received MAC frames/fragments rejected due to unknown or incorrect SMD
7022b30f829SVladimir Oltean  * @MACMergeFrameAssOkCount:
7032b30f829SVladimir Oltean  *	received MAC frames that were successfully reassembled and passed up
7042b30f829SVladimir Oltean  * @MACMergeFragCountRx:
7052b30f829SVladimir Oltean  *	number of additional correct SMD-C mPackets received due to preemption
7062b30f829SVladimir Oltean  * @MACMergeFragCountTx:
7072b30f829SVladimir Oltean  *	number of additional mPackets sent due to preemption
7082b30f829SVladimir Oltean  * @MACMergeHoldCount:
7092b30f829SVladimir Oltean  *	number of times the MM layer entered the HOLD state, which blocks
7102b30f829SVladimir Oltean  *	transmission of preemptible traffic
7112b30f829SVladimir Oltean  */
7122b30f829SVladimir Oltean struct ethtool_mm_stats {
7132b30f829SVladimir Oltean 	u64 MACMergeFrameAssErrorCount;
7142b30f829SVladimir Oltean 	u64 MACMergeFrameSmdErrorCount;
7152b30f829SVladimir Oltean 	u64 MACMergeFrameAssOkCount;
7162b30f829SVladimir Oltean 	u64 MACMergeFragCountRx;
7172b30f829SVladimir Oltean 	u64 MACMergeFragCountTx;
7182b30f829SVladimir Oltean 	u64 MACMergeHoldCount;
7192b30f829SVladimir Oltean };
7202b30f829SVladimir Oltean 
7212b30f829SVladimir Oltean /**
722fb6e30a7SAhmed Zaki  * struct ethtool_rxfh_param - RXFH (RSS) parameters
723fb6e30a7SAhmed Zaki  * @hfunc: Defines the current RSS hash function used by HW (or to be set to).
724fb6e30a7SAhmed Zaki  *	Valid values are one of the %ETH_RSS_HASH_*.
725fb6e30a7SAhmed Zaki  * @indir_size: On SET, the array size of the user buffer for the
726fb6e30a7SAhmed Zaki  *	indirection table, which may be zero, or
727fb6e30a7SAhmed Zaki  *	%ETH_RXFH_INDIR_NO_CHANGE.  On GET (read from the driver),
728fb6e30a7SAhmed Zaki  *	the array size of the hardware indirection table.
729fb6e30a7SAhmed Zaki  * @indir: The indirection table of size @indir_size entries.
730fb6e30a7SAhmed Zaki  * @key_size: On SET, the array size of the user buffer for the hash key,
731fb6e30a7SAhmed Zaki  *	which may be zero.  On GET (read from the driver), the size of the
732fb6e30a7SAhmed Zaki  *	hardware hash key.
733fb6e30a7SAhmed Zaki  * @key: The hash key of size @key_size bytes.
734dcd8dbf9SAhmed Zaki  * @rss_context: RSS context identifier.  Context 0 is the default for normal
735dcd8dbf9SAhmed Zaki  *	traffic; other contexts can be referenced as the destination for RX flow
736dcd8dbf9SAhmed Zaki  *	classification rules.  On SET, %ETH_RXFH_CONTEXT_ALLOC is used
737dcd8dbf9SAhmed Zaki  *	to allocate a new RSS context; on return this field will
738dcd8dbf9SAhmed Zaki  *	contain the ID of the newly allocated context.
739dcd8dbf9SAhmed Zaki  * @rss_delete: Set to non-ZERO to remove the @rss_context context.
74013e59344SAhmed Zaki  * @input_xfrm: Defines how the input data is transformed. Valid values are one
74113e59344SAhmed Zaki  *	of %RXH_XFRM_*.
742fb6e30a7SAhmed Zaki  */
743fb6e30a7SAhmed Zaki struct ethtool_rxfh_param {
744fb6e30a7SAhmed Zaki 	u8	hfunc;
745fb6e30a7SAhmed Zaki 	u32	indir_size;
746fb6e30a7SAhmed Zaki 	u32	*indir;
747fb6e30a7SAhmed Zaki 	u32	key_size;
748fb6e30a7SAhmed Zaki 	u8	*key;
749dcd8dbf9SAhmed Zaki 	u32	rss_context;
750dcd8dbf9SAhmed Zaki 	u8	rss_delete;
75113e59344SAhmed Zaki 	u8	input_xfrm;
752fb6e30a7SAhmed Zaki };
753fb6e30a7SAhmed Zaki 
754fb6e30a7SAhmed Zaki /**
7552111375bSKory Maincent  * struct kernel_ethtool_ts_info - kernel copy of struct ethtool_ts_info
7562111375bSKory Maincent  * @cmd: command number = %ETHTOOL_GET_TS_INFO
7572111375bSKory Maincent  * @so_timestamping: bit mask of the sum of the supported SO_TIMESTAMPING flags
7582111375bSKory Maincent  * @phc_index: device index of the associated PHC, or -1 if there is none
759b9e3f7dcSKory Maincent  * @phc_qualifier: qualifier of the associated PHC
7602111375bSKory Maincent  * @tx_types: bit mask of the supported hwtstamp_tx_types enumeration values
7612111375bSKory Maincent  * @rx_filters: bit mask of the supported hwtstamp_rx_filters enumeration values
7622111375bSKory Maincent  */
7632111375bSKory Maincent struct kernel_ethtool_ts_info {
7642111375bSKory Maincent 	u32 cmd;
7652111375bSKory Maincent 	u32 so_timestamping;
7662111375bSKory Maincent 	int phc_index;
767b9e3f7dcSKory Maincent 	enum hwtstamp_provider_qualifier phc_qualifier;
7682111375bSKory Maincent 	enum hwtstamp_tx_types tx_types;
7692111375bSKory Maincent 	enum hwtstamp_rx_filters rx_filters;
7702111375bSKory Maincent };
7712111375bSKory Maincent 
7722111375bSKory Maincent /**
7738717d07bSBen Hutchings  * struct ethtool_ops - optional netdev operations
774ecdff893SGal Pressman  * @supported_input_xfrm: supported types of input xfrm from %RXH_XFRM_*.
775012ce4ddSDanielle Ratson  * @cap_link_lanes_supported: indicates if the driver supports lanes
776012ce4ddSDanielle Ratson  *	parameter.
777dcd8dbf9SAhmed Zaki  * @cap_rss_ctx_supported: indicates if the driver supports RSS
778ce056504SJakub Kicinski  *	contexts via legacy API, drivers implementing @create_rxfh_context
779ce056504SJakub Kicinski  *	do not have to set this bit.
780ec6e57beSJakub Kicinski  * @rxfh_per_ctx_key: device supports setting different RSS key for each
781ec6e57beSJakub Kicinski  *	additional context. Netlink API should report hfunc, key, and input_xfrm
782ec6e57beSJakub Kicinski  *	for every context, not just context 0.
7839e43ad7aSEdward Cree  * @cap_rss_rxnfc_adds: device supports nonzero ring_cookie in filters with
7849e43ad7aSEdward Cree  *	%FLOW_RSS flag; the queue ID from the filter is added to the value from
7859e43ad7aSEdward Cree  *	the indirection table to determine the delivery queue.
78628c8757aSJakub Kicinski  * @rxfh_indir_space: max size of RSS indirection tables, if indirection table
78728c8757aSJakub Kicinski  *	size as returned by @get_rxfh_indir_size may change during lifetime
78828c8757aSJakub Kicinski  *	of the device. Leave as 0 if the table size is constant.
78928c8757aSJakub Kicinski  * @rxfh_key_space: same as @rxfh_indir_space, but for the key.
790eac9122fSEdward Cree  * @rxfh_priv_size: size of the driver private data area the core should
791eac9122fSEdward Cree  *	allocate for an RSS context (in &struct ethtool_rxfh_context).
792b54de559SEdward Cree  * @rxfh_max_num_contexts: maximum (exclusive) supported RSS context ID.
793b54de559SEdward Cree  *	If this is zero then the core may choose any (nonzero) ID, otherwise
794b54de559SEdward Cree  *	the core will only use IDs strictly less than this value, as the
795b54de559SEdward Cree  *	@rss_context argument to @create_rxfh_context and friends.
79695cddcb5SJakub Kicinski  * @supported_coalesce_params: supported types of interrupt coalescing.
7970b70c256SHao Chen  * @supported_ring_params: supported ring params.
798b9e3f7dcSKory Maincent  * @supported_hwtstamp_qualifiers: bitfield of supported hwtstamp qualifier.
799f20a0a05SVincent Mailhol  * @get_drvinfo: Report driver/device information. Modern drivers no
800f20a0a05SVincent Mailhol  *	longer have to implement this callback. Most fields are
801f20a0a05SVincent Mailhol  *	correctly filled in by the core using system information, or
802f20a0a05SVincent Mailhol  *	populated using other driver operations.
8038717d07bSBen Hutchings  * @get_regs_len: Get buffer length required for @get_regs
804e20b5b61SBen Hutchings  * @get_regs: Get device registers
805e20b5b61SBen Hutchings  * @get_wol: Report whether Wake-on-Lan is enabled
8068717d07bSBen Hutchings  * @set_wol: Turn Wake-on-Lan on or off.  Returns a negative error code
8078717d07bSBen Hutchings  *	or zero.
8088717d07bSBen Hutchings  * @get_msglevel: Report driver message level.  This should be the value
8098717d07bSBen Hutchings  *	of the @msg_enable field used by netif logging functions.
810e20b5b61SBen Hutchings  * @set_msglevel: Set driver message level
8118717d07bSBen Hutchings  * @nway_reset: Restart autonegotiation.  Returns a negative error code
8128717d07bSBen Hutchings  *	or zero.
8138717d07bSBen Hutchings  * @get_link: Report whether physical link is up.  Will only be called if
8148717d07bSBen Hutchings  *	the netdev is up.  Should usually be set to ethtool_op_get_link(),
8158717d07bSBen Hutchings  *	which uses netif_carrier_ok().
816ecc31c60SAmit Cohen  * @get_link_ext_state: Report link extended state. Should set link_ext_state and
817ecc31c60SAmit Cohen  *	link_ext_substate (link_ext_substate of 0 means link_ext_substate is unknown,
818ecc31c60SAmit Cohen  *	do not attach ext_substate attribute to netlink message). If link_ext_state
819ecc31c60SAmit Cohen  *	and link_ext_substate are unknown, return -ENODATA. If not implemented,
820ecc31c60SAmit Cohen  *	link_ext_state and link_ext_substate will not be sent to userspace.
8219a0f830fSJakub Kicinski  * @get_link_ext_stats: Read extra link-related counters.
822d9c65de0SJakub Kicinski  * @get_eeprom_len: Read range of EEPROM addresses for validation of
823d9c65de0SJakub Kicinski  *	@get_eeprom and @set_eeprom requests.
824d9c65de0SJakub Kicinski  *	Returns 0 if device does not support EEPROM access.
825e20b5b61SBen Hutchings  * @get_eeprom: Read data from the device EEPROM.
8261da177e4SLinus Torvalds  *	Should fill in the magic field.  Don't need to check len for zero
8271da177e4SLinus Torvalds  *	or wraparound.  Fill in the data argument with the eeprom values
8281da177e4SLinus Torvalds  *	from offset to offset + len.  Update len to the amount read.
8291da177e4SLinus Torvalds  *	Returns an error or zero.
830e20b5b61SBen Hutchings  * @set_eeprom: Write data to the device EEPROM.
8311da177e4SLinus Torvalds  *	Should validate the magic field.  Don't need to check len for zero
8321da177e4SLinus Torvalds  *	or wraparound.  Update len to the amount written.  Returns an error
8331da177e4SLinus Torvalds  *	or zero.
8348717d07bSBen Hutchings  * @get_coalesce: Get interrupt coalescing parameters.  Returns a negative
8358717d07bSBen Hutchings  *	error code or zero.
83695cddcb5SJakub Kicinski  * @set_coalesce: Set interrupt coalescing parameters.  Supported coalescing
83795cddcb5SJakub Kicinski  *	types should be set in @supported_coalesce_params.
83895cddcb5SJakub Kicinski  *	Returns a negative error code or zero.
839e20b5b61SBen Hutchings  * @get_ringparam: Report ring sizes
8408717d07bSBen Hutchings  * @set_ringparam: Set ring sizes.  Returns a negative error code or zero.
8419a27a330SJakub Kicinski  * @get_pause_stats: Report pause frame statistics. Drivers must not zero
8429a27a330SJakub Kicinski  *	statistics which they don't report. The stats structure is initialized
8439a27a330SJakub Kicinski  *	to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics.
844e20b5b61SBen Hutchings  * @get_pauseparam: Report pause parameters
8458717d07bSBen Hutchings  * @set_pauseparam: Set pause parameters.  Returns a negative error code
8468717d07bSBen Hutchings  *	or zero.
847e20b5b61SBen Hutchings  * @self_test: Run specified self-tests
848e20b5b61SBen Hutchings  * @get_strings: Return a set of strings that describe the requested objects
84968f512f2SBen Hutchings  * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
85068f512f2SBen Hutchings  *	attached to it.  The implementation may update the indicator
85168f512f2SBen Hutchings  *	asynchronously or synchronously, but in either case it must return
85268f512f2SBen Hutchings  *	quickly.  It is initially called with the argument %ETHTOOL_ID_ACTIVE,
853fce55922SAllan, Bruce W  *	and must either activate asynchronous updates and return zero, return
854fce55922SAllan, Bruce W  *	a negative error or return a positive frequency for synchronous
855fce55922SAllan, Bruce W  *	indication (e.g. 1 for one on/off cycle per second).  If it returns
856fce55922SAllan, Bruce W  *	a frequency then it will be called again at intervals with the
85768f512f2SBen Hutchings  *	argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
85868f512f2SBen Hutchings  *	the indicator accordingly.  Finally, it is called with the argument
85968f512f2SBen Hutchings  *	%ETHTOOL_ID_INACTIVE and must deactivate the indicator.  Returns a
86068f512f2SBen Hutchings  *	negative error code or zero.
8618717d07bSBen Hutchings  * @get_ethtool_stats: Return extended statistics about the device.
8628717d07bSBen Hutchings  *	This is only useful if the device maintains statistics not
8638717d07bSBen Hutchings  *	included in &struct rtnl_link_stats64.
8648717d07bSBen Hutchings  * @begin: Function to be called before any other operation.  Returns a
8658717d07bSBen Hutchings  *	negative error code or zero.
8668717d07bSBen Hutchings  * @complete: Function to be called after any other operation except
8678717d07bSBen Hutchings  *	@begin.  Will be called even if the other operation failed.
8688717d07bSBen Hutchings  * @get_priv_flags: Report driver-specific feature flags.
8698717d07bSBen Hutchings  * @set_priv_flags: Set driver-specific feature flags.  Returns a negative
8708717d07bSBen Hutchings  *	error code or zero.
8718717d07bSBen Hutchings  * @get_sset_count: Get number of strings that @get_strings will write.
8728717d07bSBen Hutchings  * @get_rxnfc: Get RX flow classification rules.  Returns a negative
8738717d07bSBen Hutchings  *	error code or zero.
8748717d07bSBen Hutchings  * @set_rxnfc: Set RX flow classification rules.  Returns a negative
8758717d07bSBen Hutchings  *	error code or zero.
8768717d07bSBen Hutchings  * @flash_device: Write a firmware image to device's flash memory.
8778717d07bSBen Hutchings  *	Returns a negative error code or zero.
8788717d07bSBen Hutchings  * @reset: Reset (part of) the device, as specified by a bitmask of
8798717d07bSBen Hutchings  *	flags from &enum ethtool_reset_flags.  Returns a negative
8808717d07bSBen Hutchings  *	error code or zero.
8813de0b592SVenkata Duvvuru  * @get_rxfh_key_size: Get the size of the RX flow hash key.
8823de0b592SVenkata Duvvuru  *	Returns zero if not supported for this specific device.
8837850f63fSBen Hutchings  * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
8847850f63fSBen Hutchings  *	Returns zero if not supported for this specific device.
885892311f6SEyal Perry  * @get_rxfh: Get the contents of the RX flow hash indirection table, hash key
886892311f6SEyal Perry  *	and/or hash function.
8878717d07bSBen Hutchings  *	Returns a negative error code or zero.
888892311f6SEyal Perry  * @set_rxfh: Set the contents of the RX flow hash indirection table, hash
889892311f6SEyal Perry  *	key, and/or hash function.  Arguments which are set to %NULL or zero
890892311f6SEyal Perry  *	will remain unchanged.
891892311f6SEyal Perry  *	Returns a negative error code or zero. An error code must be returned
892892311f6SEyal Perry  *	if at least one unsupported change was requested.
893847a8ab1SEdward Cree  * @create_rxfh_context: Create a new RSS context with the specified RX flow
894847a8ab1SEdward Cree  *	hash indirection table, hash key, and hash function.
895847a8ab1SEdward Cree  *	The &struct ethtool_rxfh_context for this context is passed in @ctx;
896847a8ab1SEdward Cree  *	note that the indir table, hkey and hfunc are not yet populated as
897847a8ab1SEdward Cree  *	of this call.  The driver does not need to update these; the core
898847a8ab1SEdward Cree  *	will do so if this op succeeds.
899847a8ab1SEdward Cree  *	However, if @rxfh.indir is set to %NULL, the driver must update the
900847a8ab1SEdward Cree  *	indir table in @ctx with the (default or inherited) table actually in
901847a8ab1SEdward Cree  *	use; similarly, if @rxfh.key is %NULL, @rxfh.hfunc is
902847a8ab1SEdward Cree  *	%ETH_RSS_HASH_NO_CHANGE, or @rxfh.input_xfrm is %RXH_XFRM_NO_CHANGE,
903847a8ab1SEdward Cree  *	the driver should update the corresponding information in @ctx.
904847a8ab1SEdward Cree  *	If the driver provides this method, it must also provide
905847a8ab1SEdward Cree  *	@modify_rxfh_context and @remove_rxfh_context.
906847a8ab1SEdward Cree  *	Returns a negative error code or zero.
907847a8ab1SEdward Cree  * @modify_rxfh_context: Reconfigure the specified RSS context.  Allows setting
908847a8ab1SEdward Cree  *	the contents of the RX flow hash indirection table, hash key, and/or
909847a8ab1SEdward Cree  *	hash function associated with the given context.
910847a8ab1SEdward Cree  *	Parameters which are set to %NULL or zero will remain unchanged.
911847a8ab1SEdward Cree  *	The &struct ethtool_rxfh_context for this context is passed in @ctx;
912847a8ab1SEdward Cree  *	note that it will still contain the *old* settings.  The driver does
913847a8ab1SEdward Cree  *	not need to update these; the core will do so if this op succeeds.
914847a8ab1SEdward Cree  *	Returns a negative error code or zero. An error code must be returned
915847a8ab1SEdward Cree  *	if at least one unsupported change was requested.
916847a8ab1SEdward Cree  * @remove_rxfh_context: Remove the specified RSS context.
917847a8ab1SEdward Cree  *	The &struct ethtool_rxfh_context for this context is passed in @ctx.
918847a8ab1SEdward Cree  *	Returns a negative error code or zero.
9198b5933c3Samit salecha  * @get_channels: Get number of channels.
9208b5933c3Samit salecha  * @set_channels: Set number of channels.  Returns a negative error code or
9218b5933c3Samit salecha  *	zero.
92229dd54b7SAnirban Chakraborty  * @get_dump_flag: Get dump flag indicating current dump length, version,
92329dd54b7SAnirban Chakraborty  * 		   and flag of the device.
92429dd54b7SAnirban Chakraborty  * @get_dump_data: Get dump data.
92529dd54b7SAnirban Chakraborty  * @set_dump: Set dump specific flags to the device.
926c8f3a8c3SRichard Cochran  * @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
927980f0799SHangbin Liu  *	It may be called with RCU, or rtnl or reference on the device.
928c8f3a8c3SRichard Cochran  *	Drivers supporting transmit time stamps in software should set this to
9290e9c1277SRahul Rameshbabu  *	ethtool_op_get_ts_info(). Drivers must not zero statistics which they
9300e9c1277SRahul Rameshbabu  *	don't report. The stats	structure is initialized to ETHTOOL_STAT_NOT_SET
9310e9c1277SRahul Rameshbabu  *	indicating driver does not report statistics.
9320e9c1277SRahul Rameshbabu  * @get_ts_stats: Query the device hardware timestamping statistics.
93341c3cb6dSStuart Hodgson  * @get_module_info: Get the size and type of the eeprom contained within
93441c3cb6dSStuart Hodgson  *	a plug-in module.
93541c3cb6dSStuart Hodgson  * @get_module_eeprom: Get the eeprom information from the plug-in module
93680f12eccSYuval Mintz  * @get_eee: Get Energy-Efficient (EEE) supported and status.
93780f12eccSYuval Mintz  * @set_eee: Set EEE status (enable/disable) as well as LPI timers.
938d9c65de0SJakub Kicinski  * @get_tunable: Read the value of a driver / device tunable.
939d9c65de0SJakub Kicinski  * @set_tunable: Set the value of a driver / device tunable.
940421797b1SKan Liang  * @get_per_queue_coalesce: Get interrupt coalescing parameters per queue.
941421797b1SKan Liang  *	It must check that the given queue number is valid. If neither a RX nor
942421797b1SKan Liang  *	a TX queue has this number, return -EINVAL. If only a RX queue or a TX
943421797b1SKan Liang  *	queue has this number, set the inapplicable fields to ~0 and return 0.
944421797b1SKan Liang  *	Returns a negative error code or zero.
945f38d138aSKan Liang  * @set_per_queue_coalesce: Set interrupt coalescing parameters per queue.
946f38d138aSKan Liang  *	It must check that the given queue number is valid. If neither a RX nor
947f38d138aSKan Liang  *	a TX queue has this number, return -EINVAL. If only a RX queue or a TX
94895cddcb5SJakub Kicinski  *	queue has this number, ignore the inapplicable fields. Supported
94995cddcb5SJakub Kicinski  *	coalescing types should be set in @supported_coalesce_params.
950f38d138aSKan Liang  *	Returns a negative error code or zero.
9519b300495SMichal Kubecek  * @get_link_ksettings: Get various device settings including Ethernet link
9529b300495SMichal Kubecek  *	settings. The %cmd and %link_mode_masks_nwords fields should be
9539b300495SMichal Kubecek  *	ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter),
9549b300495SMichal Kubecek  *	any change to them will be overwritten by kernel. Returns a negative
9559b300495SMichal Kubecek  *	error code or zero.
9569b300495SMichal Kubecek  * @set_link_ksettings: Set various device settings including Ethernet link
9579b300495SMichal Kubecek  *	settings. The %cmd and %link_mode_masks_nwords fields should be
9589b300495SMichal Kubecek  *	ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter),
9599b300495SMichal Kubecek  *	any change to them will be overwritten by kernel. Returns a negative
9609b300495SMichal Kubecek  *	error code or zero.
961be85dbfeSJakub Kicinski  * @get_fec_stats: Report FEC statistics.
962be85dbfeSJakub Kicinski  *	Core will sum up per-lane stats to get the total.
963be85dbfeSJakub Kicinski  *	Drivers must not zero statistics which they don't report. The stats
964be85dbfeSJakub Kicinski  *	structure is initialized to ETHTOOL_STAT_NOT_SET indicating driver does
965be85dbfeSJakub Kicinski  *	not report statistics.
966d805c520SFlorian Fainelli  * @get_fecparam: Get the network device Forward Error Correction parameters.
967d805c520SFlorian Fainelli  * @set_fecparam: Set the network device Forward Error Correction parameters.
96899943382SFlorian Fainelli  * @get_ethtool_phy_stats: Return extended statistics about the PHY device.
96999943382SFlorian Fainelli  *	This is only useful if the device maintains PHY statistics and
97099943382SFlorian Fainelli  *	cannot use the standard PHY library helpers.
97156f15e2cSJakub Kicinski  * @get_phy_tunable: Read the value of a PHY tunable.
97256f15e2cSJakub Kicinski  * @set_phy_tunable: Set the value of a PHY tunable.
973c781ff12SVladyslav Tarasiuk  * @get_module_eeprom_by_page: Get a region of plug-in module EEPROM data from
974c781ff12SVladyslav Tarasiuk  *	specified page. Returns a negative error code or the amount of bytes
975c781ff12SVladyslav Tarasiuk  *	read.
97669540b79SIdo Schimmel  * @set_module_eeprom_by_page: Write to a region of plug-in module EEPROM,
97769540b79SIdo Schimmel  *	from kernel space only. Returns a negative error code or zero.
978f09ea6fbSJakub Kicinski  * @get_eth_phy_stats: Query some of the IEEE 802.3 PHY statistics.
979ca224454SJakub Kicinski  * @get_eth_mac_stats: Query some of the IEEE 802.3 MAC statistics.
980bfad2b97SJakub Kicinski  * @get_eth_ctrl_stats: Query some of the IEEE 802.3 MAC Ctrl statistics.
981a8b06e9dSJakub Kicinski  * @get_rmon_stats: Query some of the RMON (RFC 2819) statistics.
982a8b06e9dSJakub Kicinski  *	Set %ranges to a pointer to zero-terminated array of byte ranges.
983353407d9SIdo Schimmel  * @get_module_power_mode: Get the power mode policy for the plug-in module
984353407d9SIdo Schimmel  *	used by the network device and its operational power mode, if
985353407d9SIdo Schimmel  *	plugged-in.
986353407d9SIdo Schimmel  * @set_module_power_mode: Set the power mode policy for the plug-in module
987353407d9SIdo Schimmel  *	used by the network device.
9882b30f829SVladimir Oltean  * @get_mm: Query the 802.3 MAC Merge layer state.
9892b30f829SVladimir Oltean  * @set_mm: Set the 802.3 MAC Merge layer parameters.
9902b30f829SVladimir Oltean  * @get_mm_stats: Query the 802.3 MAC Merge layer statistics.
9918717d07bSBen Hutchings  *
9928717d07bSBen Hutchings  * All operations are optional (i.e. the function pointer may be set
9938717d07bSBen Hutchings  * to %NULL) and callers must take this into account.  Callers must
994b4f79e5cSBen Hutchings  * hold the RTNL lock.
9958717d07bSBen Hutchings  *
9968717d07bSBen Hutchings  * See the structures used by these operations for further documentation.
9976e201c85SBen Hutchings  * Note that for all operations using a structure ending with a zero-
9986e201c85SBen Hutchings  * length array, the array is allocated separately in the kernel and
9996e201c85SBen Hutchings  * is passed to the driver as an additional parameter.
10008717d07bSBen Hutchings  *
10018717d07bSBen Hutchings  * See &struct net_device and &struct net_device_ops for documentation
10028717d07bSBen Hutchings  * of the generic netdev features interface.
10031da177e4SLinus Torvalds  */
10041da177e4SLinus Torvalds struct ethtool_ops {
1005ecdff893SGal Pressman 	u32     supported_input_xfrm:8;
1006012ce4ddSDanielle Ratson 	u32     cap_link_lanes_supported:1;
1007dcd8dbf9SAhmed Zaki 	u32     cap_rss_ctx_supported:1;
1008ec6e57beSJakub Kicinski 	u32	rxfh_per_ctx_key:1;
10099e43ad7aSEdward Cree 	u32	cap_rss_rxnfc_adds:1;
101028c8757aSJakub Kicinski 	u32	rxfh_indir_space;
101128c8757aSJakub Kicinski 	u16	rxfh_key_space;
1012eac9122fSEdward Cree 	u16	rxfh_priv_size;
1013b54de559SEdward Cree 	u32	rxfh_max_num_contexts;
101495cddcb5SJakub Kicinski 	u32	supported_coalesce_params;
10150b70c256SHao Chen 	u32	supported_ring_params;
1016b9e3f7dcSKory Maincent 	u32	supported_hwtstamp_qualifiers;
10171da177e4SLinus Torvalds 	void	(*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
10181da177e4SLinus Torvalds 	int	(*get_regs_len)(struct net_device *);
10191da177e4SLinus Torvalds 	void	(*get_regs)(struct net_device *, struct ethtool_regs *, void *);
10201da177e4SLinus Torvalds 	void	(*get_wol)(struct net_device *, struct ethtool_wolinfo *);
10211da177e4SLinus Torvalds 	int	(*set_wol)(struct net_device *, struct ethtool_wolinfo *);
10221da177e4SLinus Torvalds 	u32	(*get_msglevel)(struct net_device *);
10231da177e4SLinus Torvalds 	void	(*set_msglevel)(struct net_device *, u32);
10241da177e4SLinus Torvalds 	int	(*nway_reset)(struct net_device *);
10251da177e4SLinus Torvalds 	u32	(*get_link)(struct net_device *);
1026ecc31c60SAmit Cohen 	int	(*get_link_ext_state)(struct net_device *,
1027ecc31c60SAmit Cohen 				      struct ethtool_link_ext_state_info *);
10289a0f830fSJakub Kicinski 	void	(*get_link_ext_stats)(struct net_device *dev,
10299a0f830fSJakub Kicinski 				      struct ethtool_link_ext_stats *stats);
10301da177e4SLinus Torvalds 	int	(*get_eeprom_len)(struct net_device *);
103197f8aefbSchavey 	int	(*get_eeprom)(struct net_device *,
103297f8aefbSchavey 			      struct ethtool_eeprom *, u8 *);
103397f8aefbSchavey 	int	(*set_eeprom)(struct net_device *,
103497f8aefbSchavey 			      struct ethtool_eeprom *, u8 *);
1035f3ccfda1SYufeng Mo 	int	(*get_coalesce)(struct net_device *,
1036f3ccfda1SYufeng Mo 				struct ethtool_coalesce *,
1037f3ccfda1SYufeng Mo 				struct kernel_ethtool_coalesce *,
1038f3ccfda1SYufeng Mo 				struct netlink_ext_ack *);
1039f3ccfda1SYufeng Mo 	int	(*set_coalesce)(struct net_device *,
1040f3ccfda1SYufeng Mo 				struct ethtool_coalesce *,
1041f3ccfda1SYufeng Mo 				struct kernel_ethtool_coalesce *,
1042f3ccfda1SYufeng Mo 				struct netlink_ext_ack *);
104397f8aefbSchavey 	void	(*get_ringparam)(struct net_device *,
104474624944SHao Chen 				 struct ethtool_ringparam *,
104574624944SHao Chen 				 struct kernel_ethtool_ringparam *,
104674624944SHao Chen 				 struct netlink_ext_ack *);
104797f8aefbSchavey 	int	(*set_ringparam)(struct net_device *,
104874624944SHao Chen 				 struct ethtool_ringparam *,
104974624944SHao Chen 				 struct kernel_ethtool_ringparam *,
105074624944SHao Chen 				 struct netlink_ext_ack *);
10519a27a330SJakub Kicinski 	void	(*get_pause_stats)(struct net_device *dev,
10529a27a330SJakub Kicinski 				   struct ethtool_pause_stats *pause_stats);
105397f8aefbSchavey 	void	(*get_pauseparam)(struct net_device *,
105497f8aefbSchavey 				  struct ethtool_pauseparam*);
105597f8aefbSchavey 	int	(*set_pauseparam)(struct net_device *,
105697f8aefbSchavey 				  struct ethtool_pauseparam*);
10571da177e4SLinus Torvalds 	void	(*self_test)(struct net_device *, struct ethtool_test *, u64 *);
10581da177e4SLinus Torvalds 	void	(*get_strings)(struct net_device *, u32 stringset, u8 *);
105968f512f2SBen Hutchings 	int	(*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
106097f8aefbSchavey 	void	(*get_ethtool_stats)(struct net_device *,
106197f8aefbSchavey 				     struct ethtool_stats *, u64 *);
10621da177e4SLinus Torvalds 	int	(*begin)(struct net_device *);
10631da177e4SLinus Torvalds 	void	(*complete)(struct net_device *);
1064339bf024SJeff Garzik 	u32	(*get_priv_flags)(struct net_device *);
1065339bf024SJeff Garzik 	int	(*set_priv_flags)(struct net_device *, u32);
1066ff03d49fSJeff Garzik 	int	(*get_sset_count)(struct net_device *, int);
106797f8aefbSchavey 	int	(*get_rxnfc)(struct net_device *,
1068815c7db5SBen Hutchings 			     struct ethtool_rxnfc *, u32 *rule_locs);
106959089d8dSSantwona Behera 	int	(*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *);
107005c6a8d7SAjit Khaparde 	int	(*flash_device)(struct net_device *, struct ethtool_flash *);
1071d73d3a8cSBen Hutchings 	int	(*reset)(struct net_device *, u32 *);
10723de0b592SVenkata Duvvuru 	u32	(*get_rxfh_key_size)(struct net_device *);
10737850f63fSBen Hutchings 	u32	(*get_rxfh_indir_size)(struct net_device *);
1074fb6e30a7SAhmed Zaki 	int	(*get_rxfh)(struct net_device *, struct ethtool_rxfh_param *);
1075fb6e30a7SAhmed Zaki 	int	(*set_rxfh)(struct net_device *, struct ethtool_rxfh_param *,
1076fb6e30a7SAhmed Zaki 			    struct netlink_ext_ack *extack);
1077847a8ab1SEdward Cree 	int	(*create_rxfh_context)(struct net_device *,
1078847a8ab1SEdward Cree 				       struct ethtool_rxfh_context *ctx,
107930a32cdfSEdward Cree 				       const struct ethtool_rxfh_param *rxfh,
108030a32cdfSEdward Cree 				       struct netlink_ext_ack *extack);
1081847a8ab1SEdward Cree 	int	(*modify_rxfh_context)(struct net_device *,
1082847a8ab1SEdward Cree 				       struct ethtool_rxfh_context *ctx,
108330a32cdfSEdward Cree 				       const struct ethtool_rxfh_param *rxfh,
108430a32cdfSEdward Cree 				       struct netlink_ext_ack *extack);
1085847a8ab1SEdward Cree 	int	(*remove_rxfh_context)(struct net_device *,
1086847a8ab1SEdward Cree 				       struct ethtool_rxfh_context *ctx,
108730a32cdfSEdward Cree 				       u32 rss_context,
108830a32cdfSEdward Cree 				       struct netlink_ext_ack *extack);
10898b5933c3Samit salecha 	void	(*get_channels)(struct net_device *, struct ethtool_channels *);
10908b5933c3Samit salecha 	int	(*set_channels)(struct net_device *, struct ethtool_channels *);
109129dd54b7SAnirban Chakraborty 	int	(*get_dump_flag)(struct net_device *, struct ethtool_dump *);
109229dd54b7SAnirban Chakraborty 	int	(*get_dump_data)(struct net_device *,
109329dd54b7SAnirban Chakraborty 				 struct ethtool_dump *, void *);
109429dd54b7SAnirban Chakraborty 	int	(*set_dump)(struct net_device *, struct ethtool_dump *);
10952111375bSKory Maincent 	int	(*get_ts_info)(struct net_device *, struct kernel_ethtool_ts_info *);
10960e9c1277SRahul Rameshbabu 	void	(*get_ts_stats)(struct net_device *dev,
10970e9c1277SRahul Rameshbabu 				struct ethtool_ts_stats *ts_stats);
109841c3cb6dSStuart Hodgson 	int     (*get_module_info)(struct net_device *,
109941c3cb6dSStuart Hodgson 				   struct ethtool_modinfo *);
110041c3cb6dSStuart Hodgson 	int     (*get_module_eeprom)(struct net_device *,
110141c3cb6dSStuart Hodgson 				     struct ethtool_eeprom *, u8 *);
1102d80a5233SHeiner Kallweit 	int	(*get_eee)(struct net_device *dev, struct ethtool_keee *eee);
1103d80a5233SHeiner Kallweit 	int	(*set_eee)(struct net_device *dev, struct ethtool_keee *eee);
1104f0db9b07SGovindarajulu Varadarajan 	int	(*get_tunable)(struct net_device *,
1105f0db9b07SGovindarajulu Varadarajan 			       const struct ethtool_tunable *, void *);
1106f0db9b07SGovindarajulu Varadarajan 	int	(*set_tunable)(struct net_device *,
1107f0db9b07SGovindarajulu Varadarajan 			       const struct ethtool_tunable *, const void *);
1108421797b1SKan Liang 	int	(*get_per_queue_coalesce)(struct net_device *, u32,
1109421797b1SKan Liang 					  struct ethtool_coalesce *);
1110f38d138aSKan Liang 	int	(*set_per_queue_coalesce)(struct net_device *, u32,
1111f38d138aSKan Liang 					  struct ethtool_coalesce *);
11123f1ac7a7SDavid Decotigny 	int	(*get_link_ksettings)(struct net_device *,
11133f1ac7a7SDavid Decotigny 				      struct ethtool_link_ksettings *);
11143f1ac7a7SDavid Decotigny 	int	(*set_link_ksettings)(struct net_device *,
11153f1ac7a7SDavid Decotigny 				      const struct ethtool_link_ksettings *);
1116be85dbfeSJakub Kicinski 	void	(*get_fec_stats)(struct net_device *dev,
1117be85dbfeSJakub Kicinski 				 struct ethtool_fec_stats *fec_stats);
11181a5f3da2SVidya Sagar Ravipati 	int	(*get_fecparam)(struct net_device *,
11191a5f3da2SVidya Sagar Ravipati 				      struct ethtool_fecparam *);
11201a5f3da2SVidya Sagar Ravipati 	int	(*set_fecparam)(struct net_device *,
11211a5f3da2SVidya Sagar Ravipati 				      struct ethtool_fecparam *);
112299943382SFlorian Fainelli 	void	(*get_ethtool_phy_stats)(struct net_device *,
112399943382SFlorian Fainelli 					 struct ethtool_stats *, u64 *);
1124c6db31ffSIgor Russkikh 	int	(*get_phy_tunable)(struct net_device *,
1125c6db31ffSIgor Russkikh 				   const struct ethtool_tunable *, void *);
1126c6db31ffSIgor Russkikh 	int	(*set_phy_tunable)(struct net_device *,
1127c6db31ffSIgor Russkikh 				   const struct ethtool_tunable *, const void *);
1128c781ff12SVladyslav Tarasiuk 	int	(*get_module_eeprom_by_page)(struct net_device *dev,
1129c781ff12SVladyslav Tarasiuk 					     const struct ethtool_module_eeprom *page,
1130c781ff12SVladyslav Tarasiuk 					     struct netlink_ext_ack *extack);
113169540b79SIdo Schimmel 	int	(*set_module_eeprom_by_page)(struct net_device *dev,
113269540b79SIdo Schimmel 					     const struct ethtool_module_eeprom *page,
113369540b79SIdo Schimmel 					     struct netlink_ext_ack *extack);
1134f09ea6fbSJakub Kicinski 	void	(*get_eth_phy_stats)(struct net_device *dev,
1135f09ea6fbSJakub Kicinski 				     struct ethtool_eth_phy_stats *phy_stats);
1136ca224454SJakub Kicinski 	void	(*get_eth_mac_stats)(struct net_device *dev,
1137ca224454SJakub Kicinski 				     struct ethtool_eth_mac_stats *mac_stats);
1138bfad2b97SJakub Kicinski 	void	(*get_eth_ctrl_stats)(struct net_device *dev,
1139bfad2b97SJakub Kicinski 				      struct ethtool_eth_ctrl_stats *ctrl_stats);
1140a8b06e9dSJakub Kicinski 	void	(*get_rmon_stats)(struct net_device *dev,
1141a8b06e9dSJakub Kicinski 				  struct ethtool_rmon_stats *rmon_stats,
1142a8b06e9dSJakub Kicinski 				  const struct ethtool_rmon_hist_range **ranges);
1143353407d9SIdo Schimmel 	int	(*get_module_power_mode)(struct net_device *dev,
1144353407d9SIdo Schimmel 					 struct ethtool_module_power_mode_params *params,
1145353407d9SIdo Schimmel 					 struct netlink_ext_ack *extack);
1146353407d9SIdo Schimmel 	int	(*set_module_power_mode)(struct net_device *dev,
1147353407d9SIdo Schimmel 					 const struct ethtool_module_power_mode_params *params,
1148353407d9SIdo Schimmel 					 struct netlink_ext_ack *extack);
11492b30f829SVladimir Oltean 	int	(*get_mm)(struct net_device *dev, struct ethtool_mm_state *state);
11502b30f829SVladimir Oltean 	int	(*set_mm)(struct net_device *dev, struct ethtool_mm_cfg *cfg,
11512b30f829SVladimir Oltean 			  struct netlink_ext_ack *extack);
11522b30f829SVladimir Oltean 	void	(*get_mm_stats)(struct net_device *dev, struct ethtool_mm_stats *stats);
11531da177e4SLinus Torvalds };
1154eca4205fSPablo Neira Ayuso 
11559000edb7SJakub Kicinski int ethtool_check_ops(const struct ethtool_ops *ops);
11569000edb7SJakub Kicinski 
1157eca4205fSPablo Neira Ayuso struct ethtool_rx_flow_rule {
1158eca4205fSPablo Neira Ayuso 	struct flow_rule	*rule;
11595299a11aSGustavo A. R. Silva 	unsigned long		priv[];
1160eca4205fSPablo Neira Ayuso };
1161eca4205fSPablo Neira Ayuso 
1162eca4205fSPablo Neira Ayuso struct ethtool_rx_flow_spec_input {
1163eca4205fSPablo Neira Ayuso 	const struct ethtool_rx_flow_spec	*fs;
1164eca4205fSPablo Neira Ayuso 	u32					rss_ctx;
1165eca4205fSPablo Neira Ayuso };
1166eca4205fSPablo Neira Ayuso 
1167eca4205fSPablo Neira Ayuso struct ethtool_rx_flow_rule *
1168eca4205fSPablo Neira Ayuso ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input);
1169eca4205fSPablo Neira Ayuso void ethtool_rx_flow_rule_destroy(struct ethtool_rx_flow_rule *rule);
1170eca4205fSPablo Neira Ayuso 
117170ae1e12SCris Forno bool ethtool_virtdev_validate_cmd(const struct ethtool_link_ksettings *cmd);
117270ae1e12SCris Forno int ethtool_virtdev_set_link_ksettings(struct net_device *dev,
117370ae1e12SCris Forno 				       const struct ethtool_link_ksettings *cmd,
117470ae1e12SCris Forno 				       u32 *dev_speed, u8 *dev_duplex);
117570ae1e12SCris Forno 
11763ebbd9f6SEdward Cree /**
11773ebbd9f6SEdward Cree  * struct ethtool_netdev_state - per-netdevice state for ethtool features
11786ad2962fSEdward Cree  * @rss_ctx:		XArray of custom RSS contexts
117987925151SEdward Cree  * @rss_lock:		Protects entries in @rss_ctx.  May be taken from
118087925151SEdward Cree  *			within RTNL.
11813ebbd9f6SEdward Cree  * @wol_enabled:	Wake-on-LAN is enabled
1182caa93b7cSEdward Cree  * @module_fw_flash_in_progress: Module firmware flashing is in progress.
11833ebbd9f6SEdward Cree  */
11843ebbd9f6SEdward Cree struct ethtool_netdev_state {
11856ad2962fSEdward Cree 	struct xarray		rss_ctx;
118687925151SEdward Cree 	struct mutex		rss_lock;
11873ebbd9f6SEdward Cree 	unsigned		wol_enabled:1;
1188caa93b7cSEdward Cree 	unsigned		module_fw_flash_in_progress:1;
11893ebbd9f6SEdward Cree };
11903ebbd9f6SEdward Cree 
11914895d780SFlorian Fainelli struct phy_device;
11924895d780SFlorian Fainelli struct phy_tdr_config;
11938580e16cSPiergiorgio Beruto struct phy_plca_cfg;
11948580e16cSPiergiorgio Beruto struct phy_plca_status;
11954895d780SFlorian Fainelli 
11964895d780SFlorian Fainelli /**
11974895d780SFlorian Fainelli  * struct ethtool_phy_ops - Optional PHY device options
1198bd36ed1cSFlorian Fainelli  * @get_sset_count: Get number of strings that @get_strings will write.
1199bd36ed1cSFlorian Fainelli  * @get_strings: Return a set of strings that describe the requested objects
1200bd36ed1cSFlorian Fainelli  * @get_stats: Return extended statistics about the PHY device.
12018580e16cSPiergiorgio Beruto  * @get_plca_cfg: Return PLCA configuration.
12028580e16cSPiergiorgio Beruto  * @set_plca_cfg: Set PLCA configuration.
12038580e16cSPiergiorgio Beruto  * @get_plca_status: Get PLCA configuration.
1204d9c65de0SJakub Kicinski  * @start_cable_test: Start a cable test
1205d9c65de0SJakub Kicinski  * @start_cable_test_tdr: Start a Time Domain Reflectometry cable test
12064895d780SFlorian Fainelli  *
12074895d780SFlorian Fainelli  * All operations are optional (i.e. the function pointer may be set to %NULL)
12084895d780SFlorian Fainelli  * and callers must take this into account. Callers must hold the RTNL lock.
12094895d780SFlorian Fainelli  */
12104895d780SFlorian Fainelli struct ethtool_phy_ops {
1211bd36ed1cSFlorian Fainelli 	int (*get_sset_count)(struct phy_device *dev);
1212bd36ed1cSFlorian Fainelli 	int (*get_strings)(struct phy_device *dev, u8 *data);
1213bd36ed1cSFlorian Fainelli 	int (*get_stats)(struct phy_device *dev,
1214bd36ed1cSFlorian Fainelli 			 struct ethtool_stats *stats, u64 *data);
12158580e16cSPiergiorgio Beruto 	int (*get_plca_cfg)(struct phy_device *dev,
12168580e16cSPiergiorgio Beruto 			    struct phy_plca_cfg *plca_cfg);
12178580e16cSPiergiorgio Beruto 	int (*set_plca_cfg)(struct phy_device *dev,
12188580e16cSPiergiorgio Beruto 			    const struct phy_plca_cfg *plca_cfg,
12198580e16cSPiergiorgio Beruto 			    struct netlink_ext_ack *extack);
12208580e16cSPiergiorgio Beruto 	int (*get_plca_status)(struct phy_device *dev,
12218580e16cSPiergiorgio Beruto 			       struct phy_plca_status *plca_st);
12224895d780SFlorian Fainelli 	int (*start_cable_test)(struct phy_device *phydev,
12234895d780SFlorian Fainelli 				struct netlink_ext_ack *extack);
12244895d780SFlorian Fainelli 	int (*start_cable_test_tdr)(struct phy_device *phydev,
12254895d780SFlorian Fainelli 				    struct netlink_ext_ack *extack,
12264895d780SFlorian Fainelli 				    const struct phy_tdr_config *config);
12274895d780SFlorian Fainelli };
12284895d780SFlorian Fainelli 
12294895d780SFlorian Fainelli /**
12304895d780SFlorian Fainelli  * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton
12314895d780SFlorian Fainelli  * @ops: Ethtool PHY operations to set
12324895d780SFlorian Fainelli  */
12334895d780SFlorian Fainelli void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops);
123470ae1e12SCris Forno 
12357888fe53SAlexander Duyck /**
1236a975d7d8SDanielle Ratson  * ethtool_params_from_link_mode - Derive link parameters from a given link mode
1237a975d7d8SDanielle Ratson  * @link_ksettings: Link parameters to be derived from the link mode
1238a975d7d8SDanielle Ratson  * @link_mode: Link mode
1239a975d7d8SDanielle Ratson  */
1240a975d7d8SDanielle Ratson void
1241a975d7d8SDanielle Ratson ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings,
1242a975d7d8SDanielle Ratson 			      enum ethtool_link_mode_bit_indices link_mode);
12438859a44eSJakub Kicinski 
12448859a44eSJakub Kicinski /**
1245c156174aSYangbo Lu  * ethtool_get_phc_vclocks - Derive phc vclocks information, and caller
1246c156174aSYangbo Lu  *                           is responsible to free memory of vclock_index
1247c156174aSYangbo Lu  * @dev: pointer to net_device structure
1248c156174aSYangbo Lu  * @vclock_index: pointer to pointer of vclock index
1249c156174aSYangbo Lu  *
12503f330db3SJakub Kicinski  * Return: number of phc vclocks
1251c156174aSYangbo Lu  */
1252c156174aSYangbo Lu int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index);
1253c156174aSYangbo Lu 
1254449c5459SVladimir Oltean /* Some generic methods drivers may use in their ethtool_ops */
1255449c5459SVladimir Oltean u32 ethtool_op_get_link(struct net_device *dev);
12562111375bSKory Maincent int ethtool_op_get_ts_info(struct net_device *dev,
12572111375bSKory Maincent 			   struct kernel_ethtool_ts_info *eti);
1258449c5459SVladimir Oltean 
1259c156174aSYangbo Lu /**
1260dd1c4164SVladimir Oltean  * ethtool_mm_frag_size_add_to_min - Translate (standard) additional fragment
1261dd1c4164SVladimir Oltean  *	size expressed as multiplier into (absolute) minimum fragment size
1262dd1c4164SVladimir Oltean  *	value expressed in octets
1263dd1c4164SVladimir Oltean  * @val_add: Value of addFragSize multiplier
1264dd1c4164SVladimir Oltean  */
ethtool_mm_frag_size_add_to_min(u32 val_add)1265dd1c4164SVladimir Oltean static inline u32 ethtool_mm_frag_size_add_to_min(u32 val_add)
1266dd1c4164SVladimir Oltean {
1267dd1c4164SVladimir Oltean 	return (ETH_ZLEN + ETH_FCS_LEN) * (1 + val_add) - ETH_FCS_LEN;
1268dd1c4164SVladimir Oltean }
1269dd1c4164SVladimir Oltean 
1270dd1c4164SVladimir Oltean /**
1271dd1c4164SVladimir Oltean  * ethtool_mm_frag_size_min_to_add - Translate (absolute) minimum fragment size
1272dd1c4164SVladimir Oltean  *	expressed in octets into (standard) additional fragment size expressed
1273dd1c4164SVladimir Oltean  *	as multiplier
1274dd1c4164SVladimir Oltean  * @val_min: Value of addFragSize variable in octets
1275dd1c4164SVladimir Oltean  * @val_add: Pointer where the standard addFragSize value is to be returned
1276dd1c4164SVladimir Oltean  * @extack: Netlink extended ack
1277dd1c4164SVladimir Oltean  *
1278dd1c4164SVladimir Oltean  * Translate a value in octets to one of 0, 1, 2, 3 according to the reverse
1279dd1c4164SVladimir Oltean  * application of the 802.3 formula 64 * (1 + addFragSize) - 4. To be called
1280dd1c4164SVladimir Oltean  * by drivers which do not support programming the minimum fragment size to a
1281dd1c4164SVladimir Oltean  * continuous range. Returns error on other fragment length values.
1282dd1c4164SVladimir Oltean  */
ethtool_mm_frag_size_min_to_add(u32 val_min,u32 * val_add,struct netlink_ext_ack * extack)1283dd1c4164SVladimir Oltean static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add,
1284dd1c4164SVladimir Oltean 						  struct netlink_ext_ack *extack)
1285dd1c4164SVladimir Oltean {
1286dd1c4164SVladimir Oltean 	u32 add_frag_size;
1287dd1c4164SVladimir Oltean 
1288dd1c4164SVladimir Oltean 	for (add_frag_size = 0; add_frag_size < 4; add_frag_size++) {
1289dd1c4164SVladimir Oltean 		if (ethtool_mm_frag_size_add_to_min(add_frag_size) == val_min) {
1290dd1c4164SVladimir Oltean 			*val_add = add_frag_size;
1291dd1c4164SVladimir Oltean 			return 0;
1292dd1c4164SVladimir Oltean 		}
1293dd1c4164SVladimir Oltean 	}
1294dd1c4164SVladimir Oltean 
1295dd1c4164SVladimir Oltean 	NL_SET_ERR_MSG_MOD(extack,
1296dd1c4164SVladimir Oltean 			   "minFragSize required to be one of 60, 124, 188 or 252");
1297dd1c4164SVladimir Oltean 	return -EINVAL;
1298dd1c4164SVladimir Oltean }
1299dd1c4164SVladimir Oltean 
1300dd1c4164SVladimir Oltean /**
1301b8768dc4SRichard Cochran  * ethtool_get_ts_info_by_layer - Obtains time stamping capabilities from the MAC or PHY layer.
1302b8768dc4SRichard Cochran  * @dev: pointer to net_device structure
1303b8768dc4SRichard Cochran  * @info: buffer to hold the result
13043f330db3SJakub Kicinski  * Returns: zero on success, non-zero otherwise.
1305b8768dc4SRichard Cochran  */
13062111375bSKory Maincent int ethtool_get_ts_info_by_layer(struct net_device *dev,
13072111375bSKory Maincent 				 struct kernel_ethtool_ts_info *info);
1308b8768dc4SRichard Cochran 
1309b8768dc4SRichard Cochran /**
13107888fe53SAlexander Duyck  * ethtool_sprintf - Write formatted string to ethtool string data
1311f55d8e60SAndrew Lunn  * @data: Pointer to a pointer to the start of string to update
13127888fe53SAlexander Duyck  * @fmt: Format of string to write
13137888fe53SAlexander Duyck  *
1314f55d8e60SAndrew Lunn  * Write formatted string to *data. Update *data to point at start of
13157888fe53SAlexander Duyck  * next string.
13167888fe53SAlexander Duyck  */
13177888fe53SAlexander Duyck extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...);
131826c5334dSPaul Greenwalt 
13192a48c635S[email protected] /**
13202a48c635S[email protected]  * ethtool_puts - Write string to ethtool string data
13212a48c635S[email protected]  * @data: Pointer to a pointer to the start of string to update
13222a48c635S[email protected]  * @str: String to write
13232a48c635S[email protected]  *
13242a48c635S[email protected]  * Write string to *data without a trailing newline. Update *data
13252a48c635S[email protected]  * to point at start of next string.
13262a48c635S[email protected]  *
13272a48c635S[email protected]  * Prefer this function to ethtool_sprintf() when given only
13282a48c635S[email protected]  * two arguments or if @fmt is just "%s".
13292a48c635S[email protected]  */
13302a48c635S[email protected] extern void ethtool_puts(u8 **data, const char *str);
13312a48c635S[email protected] 
133226c5334dSPaul Greenwalt /* Link mode to forced speed capabilities maps */
133326c5334dSPaul Greenwalt struct ethtool_forced_speed_map {
133426c5334dSPaul Greenwalt 	u32		speed;
133526c5334dSPaul Greenwalt 	__ETHTOOL_DECLARE_LINK_MODE_MASK(caps);
133626c5334dSPaul Greenwalt 
133726c5334dSPaul Greenwalt 	const u32	*cap_arr;
133826c5334dSPaul Greenwalt 	u32		arr_size;
133926c5334dSPaul Greenwalt };
134026c5334dSPaul Greenwalt 
134126c5334dSPaul Greenwalt #define ETHTOOL_FORCED_SPEED_MAP(prefix, value)				\
134226c5334dSPaul Greenwalt {									\
134326c5334dSPaul Greenwalt 	.speed		= SPEED_##value,				\
134426c5334dSPaul Greenwalt 	.cap_arr	= prefix##_##value,				\
134526c5334dSPaul Greenwalt 	.arr_size	= ARRAY_SIZE(prefix##_##value),			\
134626c5334dSPaul Greenwalt }
134726c5334dSPaul Greenwalt 
134820c6e05bSJakub Kicinski void
134920c6e05bSJakub Kicinski ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size);
13501da177e4SLinus Torvalds #endif /* _LINUX_ETHTOOL_H */
1351