Home | History | Annotate | Download | only in linux
      1 /*
      2  * ethtool.h: Defines for Linux ethtool.
      3  *
      4  * Copyright (C) 1998 David S. Miller (davem (at) redhat.com)
      5  * Copyright 2001 Jeff Garzik <jgarzik (at) pobox.com>
      6  * Portions Copyright 2001 Sun Microsystems (thockin (at) sun.com)
      7  * Portions Copyright 2002 Intel (eli.kupermann (at) intel.com,
      8  *                                christopher.leech (at) intel.com,
      9  *                                scott.feldman (at) intel.com)
     10  * Portions Copyright (C) Sun Microsystems 2008
     11  */
     12 
     13 #ifndef _LINUX_ETHTOOL_H
     14 #define _LINUX_ETHTOOL_H
     15 
     16 #include <linux/types.h>
     17 #include <linux/if_ether.h>
     18 
     19 /* This should work for both 32 and 64 bit userland. */
     20 struct ethtool_cmd {
     21 	__u32	cmd;
     22 	__u32	supported;	/* Features this interface supports */
     23 	__u32	advertising;	/* Features this interface advertises */
     24 	__u16	speed;	        /* The forced speed (lower bits) in
     25 				 * Mbps. Please use
     26 				 * ethtool_cmd_speed()/_set() to
     27 				 * access it */
     28 	__u8	duplex;		/* Duplex, half or full */
     29 	__u8	port;		/* Which connector port */
     30 	__u8	phy_address;
     31 	__u8	transceiver;	/* Which transceiver to use */
     32 	__u8	autoneg;	/* Enable or disable autonegotiation */
     33 	__u8	mdio_support;
     34 	__u32	maxtxpkt;	/* Tx pkts before generating tx int */
     35 	__u32	maxrxpkt;	/* Rx pkts before generating rx int */
     36 	__u16	speed_hi;       /* The forced speed (upper
     37 				 * bits) in Mbps. Please use
     38 				 * ethtool_cmd_speed()/_set() to
     39 				 * access it */
     40 	__u8	eth_tp_mdix;
     41 	__u8	reserved2;
     42 	__u32	lp_advertising;	/* Features the link partner advertises */
     43 	__u32	reserved[2];
     44 };
     45 
     46 static __inline__ void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
     47 					 __u32 speed)
     48 {
     49 
     50 	ep->speed = (__u16)speed;
     51 	ep->speed_hi = (__u16)(speed >> 16);
     52 }
     53 
     54 static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
     55 {
     56 	return (ep->speed_hi << 16) | ep->speed;
     57 }
     58 
     59 #define ETHTOOL_FWVERS_LEN	32
     60 #define ETHTOOL_BUSINFO_LEN	32
     61 /* these strings are set to whatever the driver author decides... */
     62 struct ethtool_drvinfo {
     63 	__u32	cmd;
     64 	char	driver[32];	/* driver short name, "tulip", "eepro100" */
     65 	char	version[32];	/* driver version string */
     66 	char	fw_version[ETHTOOL_FWVERS_LEN];	/* firmware version string */
     67 	char	bus_info[ETHTOOL_BUSINFO_LEN];	/* Bus info for this IF. */
     68 				/* For PCI devices, use pci_name(pci_dev). */
     69 	char	reserved1[32];
     70 	char	reserved2[12];
     71 				/*
     72 				 * Some struct members below are filled in
     73 				 * using ops->get_sset_count().  Obtaining
     74 				 * this info from ethtool_drvinfo is now
     75 				 * deprecated; Use ETHTOOL_GSSET_INFO
     76 				 * instead.
     77 				 */
     78 	__u32	n_priv_flags;	/* number of flags valid in ETHTOOL_GPFLAGS */
     79 	__u32	n_stats;	/* number of u64's from ETHTOOL_GSTATS */
     80 	__u32	testinfo_len;
     81 	__u32	eedump_len;	/* Size of data from ETHTOOL_GEEPROM (bytes) */
     82 	__u32	regdump_len;	/* Size of data from ETHTOOL_GREGS (bytes) */
     83 };
     84 
     85 #define SOPASS_MAX	6
     86 /* wake-on-lan settings */
     87 struct ethtool_wolinfo {
     88 	__u32	cmd;
     89 	__u32	supported;
     90 	__u32	wolopts;
     91 	__u8	sopass[SOPASS_MAX]; /* SecureOn(tm) password */
     92 };
     93 
     94 /* for passing single values */
     95 struct ethtool_value {
     96 	__u32	cmd;
     97 	__u32	data;
     98 };
     99 
    100 /* for passing big chunks of data */
    101 struct ethtool_regs {
    102 	__u32	cmd;
    103 	__u32	version; /* driver-specific, indicates different chips/revs */
    104 	__u32	len; /* bytes */
    105 	__u8	data[0];
    106 };
    107 
    108 /* for passing EEPROM chunks */
    109 struct ethtool_eeprom {
    110 	__u32	cmd;
    111 	__u32	magic;
    112 	__u32	offset; /* in bytes */
    113 	__u32	len; /* in bytes */
    114 	__u8	data[0];
    115 };
    116 
    117 /**
    118  * struct ethtool_coalesce - coalescing parameters for IRQs and stats updates
    119  * @cmd: ETHTOOL_{G,S}COALESCE
    120  * @rx_coalesce_usecs: How many usecs to delay an RX interrupt after
    121  *	a packet arrives.
    122  * @rx_max_coalesced_frames: Maximum number of packets to receive
    123  *	before an RX interrupt.
    124  * @rx_coalesce_usecs_irq: Same as @rx_coalesce_usecs, except that
    125  *	this value applies while an IRQ is being serviced by the host.
    126  * @rx_max_coalesced_frames_irq: Same as @rx_max_coalesced_frames,
    127  *	except that this value applies while an IRQ is being serviced
    128  *	by the host.
    129  * @tx_coalesce_usecs: How many usecs to delay a TX interrupt after
    130  *	a packet is sent.
    131  * @tx_max_coalesced_frames: Maximum number of packets to be sent
    132  *	before a TX interrupt.
    133  * @tx_coalesce_usecs_irq: Same as @tx_coalesce_usecs, except that
    134  *	this value applies while an IRQ is being serviced by the host.
    135  * @tx_max_coalesced_frames_irq: Same as @tx_max_coalesced_frames,
    136  *	except that this value applies while an IRQ is being serviced
    137  *	by the host.
    138  * @stats_block_coalesce_usecs: How many usecs to delay in-memory
    139  *	statistics block updates.  Some drivers do not have an
    140  *	in-memory statistic block, and in such cases this value is
    141  *	ignored.  This value must not be zero.
    142  * @use_adaptive_rx_coalesce: Enable adaptive RX coalescing.
    143  * @use_adaptive_tx_coalesce: Enable adaptive TX coalescing.
    144  * @pkt_rate_low: Threshold for low packet rate (packets per second).
    145  * @rx_coalesce_usecs_low: How many usecs to delay an RX interrupt after
    146  *	a packet arrives, when the packet rate is below @pkt_rate_low.
    147  * @rx_max_coalesced_frames_low: Maximum number of packets to be received
    148  *	before an RX interrupt, when the packet rate is below @pkt_rate_low.
    149  * @tx_coalesce_usecs_low: How many usecs to delay a TX interrupt after
    150  *	a packet is sent, when the packet rate is below @pkt_rate_low.
    151  * @tx_max_coalesced_frames_low: Maximum nuumber of packets to be sent before
    152  *	a TX interrupt, when the packet rate is below @pkt_rate_low.
    153  * @pkt_rate_high: Threshold for high packet rate (packets per second).
    154  * @rx_coalesce_usecs_high: How many usecs to delay an RX interrupt after
    155  *	a packet arrives, when the packet rate is above @pkt_rate_high.
    156  * @rx_max_coalesced_frames_high: Maximum number of packets to be received
    157  *	before an RX interrupt, when the packet rate is above @pkt_rate_high.
    158  * @tx_coalesce_usecs_high: How many usecs to delay a TX interrupt after
    159  *	a packet is sent, when the packet rate is above @pkt_rate_high.
    160  * @tx_max_coalesced_frames_high: Maximum number of packets to be sent before
    161  *	a TX interrupt, when the packet rate is above @pkt_rate_high.
    162  * @rate_sample_interval: How often to do adaptive coalescing packet rate
    163  *	sampling, measured in seconds.  Must not be zero.
    164  *
    165  * Each pair of (usecs, max_frames) fields specifies this exit
    166  * condition for interrupt coalescing:
    167  *	(usecs > 0 && time_since_first_completion >= usecs) ||
    168  *	(max_frames > 0 && completed_frames >= max_frames)
    169  * It is illegal to set both usecs and max_frames to zero as this
    170  * would cause interrupts to never be generated.  To disable
    171  * coalescing, set usecs = 0 and max_frames = 1.
    172  *
    173  * Some implementations ignore the value of max_frames and use the
    174  * condition:
    175  *	time_since_first_completion >= usecs
    176  * This is deprecated.  Drivers for hardware that does not support
    177  * counting completions should validate that max_frames == !rx_usecs.
    178  *
    179  * Adaptive RX/TX coalescing is an algorithm implemented by some
    180  * drivers to improve latency under low packet rates and improve
    181  * throughput under high packet rates.  Some drivers only implement
    182  * one of RX or TX adaptive coalescing.  Anything not implemented by
    183  * the driver causes these values to be silently ignored.
    184  *
    185  * When the packet rate is below @pkt_rate_high but above
    186  * @pkt_rate_low (both measured in packets per second) the
    187  * normal {rx,tx}_* coalescing parameters are used.
    188  */
    189 struct ethtool_coalesce {
    190 	__u32	cmd;
    191 	__u32	rx_coalesce_usecs;
    192 	__u32	rx_max_coalesced_frames;
    193 	__u32	rx_coalesce_usecs_irq;
    194 	__u32	rx_max_coalesced_frames_irq;
    195 	__u32	tx_coalesce_usecs;
    196 	__u32	tx_max_coalesced_frames;
    197 	__u32	tx_coalesce_usecs_irq;
    198 	__u32	tx_max_coalesced_frames_irq;
    199 	__u32	stats_block_coalesce_usecs;
    200 	__u32	use_adaptive_rx_coalesce;
    201 	__u32	use_adaptive_tx_coalesce;
    202 	__u32	pkt_rate_low;
    203 	__u32	rx_coalesce_usecs_low;
    204 	__u32	rx_max_coalesced_frames_low;
    205 	__u32	tx_coalesce_usecs_low;
    206 	__u32	tx_max_coalesced_frames_low;
    207 	__u32	pkt_rate_high;
    208 	__u32	rx_coalesce_usecs_high;
    209 	__u32	rx_max_coalesced_frames_high;
    210 	__u32	tx_coalesce_usecs_high;
    211 	__u32	tx_max_coalesced_frames_high;
    212 	__u32	rate_sample_interval;
    213 };
    214 
    215 /* for configuring RX/TX ring parameters */
    216 struct ethtool_ringparam {
    217 	__u32	cmd;	/* ETHTOOL_{G,S}RINGPARAM */
    218 
    219 	/* Read only attributes.  These indicate the maximum number
    220 	 * of pending RX/TX ring entries the driver will allow the
    221 	 * user to set.
    222 	 */
    223 	__u32	rx_max_pending;
    224 	__u32	rx_mini_max_pending;
    225 	__u32	rx_jumbo_max_pending;
    226 	__u32	tx_max_pending;
    227 
    228 	/* Values changeable by the user.  The valid values are
    229 	 * in the range 1 to the "*_max_pending" counterpart above.
    230 	 */
    231 	__u32	rx_pending;
    232 	__u32	rx_mini_pending;
    233 	__u32	rx_jumbo_pending;
    234 	__u32	tx_pending;
    235 };
    236 
    237 /**
    238  * struct ethtool_channels - configuring number of network channel
    239  * @cmd: ETHTOOL_{G,S}CHANNELS
    240  * @max_rx: Read only. Maximum number of receive channel the driver support.
    241  * @max_tx: Read only. Maximum number of transmit channel the driver support.
    242  * @max_other: Read only. Maximum number of other channel the driver support.
    243  * @max_combined: Read only. Maximum number of combined channel the driver
    244  *	support. Set of queues RX, TX or other.
    245  * @rx_count: Valid values are in the range 1 to the max_rx.
    246  * @tx_count: Valid values are in the range 1 to the max_tx.
    247  * @other_count: Valid values are in the range 1 to the max_other.
    248  * @combined_count: Valid values are in the range 1 to the max_combined.
    249  *
    250  * This can be used to configure RX, TX and other channels.
    251  */
    252 
    253 struct ethtool_channels {
    254 	__u32	cmd;
    255 	__u32	max_rx;
    256 	__u32	max_tx;
    257 	__u32	max_other;
    258 	__u32	max_combined;
    259 	__u32	rx_count;
    260 	__u32	tx_count;
    261 	__u32	other_count;
    262 	__u32	combined_count;
    263 };
    264 
    265 /* for configuring link flow control parameters */
    266 struct ethtool_pauseparam {
    267 	__u32	cmd;	/* ETHTOOL_{G,S}PAUSEPARAM */
    268 
    269 	/* If the link is being auto-negotiated (via ethtool_cmd.autoneg
    270 	 * being true) the user may set 'autoneg' here non-zero to have the
    271 	 * pause parameters be auto-negotiated too.  In such a case, the
    272 	 * {rx,tx}_pause values below determine what capabilities are
    273 	 * advertised.
    274 	 *
    275 	 * If 'autoneg' is zero or the link is not being auto-negotiated,
    276 	 * then {rx,tx}_pause force the driver to use/not-use pause
    277 	 * flow control.
    278 	 */
    279 	__u32	autoneg;
    280 	__u32	rx_pause;
    281 	__u32	tx_pause;
    282 };
    283 
    284 #define ETH_GSTRING_LEN		32
    285 enum ethtool_stringset {
    286 	ETH_SS_TEST		= 0,
    287 	ETH_SS_STATS,
    288 	ETH_SS_PRIV_FLAGS,
    289 	ETH_SS_NTUPLE_FILTERS,	/* Do not use, GRXNTUPLE is now deprecated */
    290 	ETH_SS_FEATURES,
    291 };
    292 
    293 /* for passing string sets for data tagging */
    294 struct ethtool_gstrings {
    295 	__u32	cmd;		/* ETHTOOL_GSTRINGS */
    296 	__u32	string_set;	/* string set id e.c. ETH_SS_TEST, etc*/
    297 	__u32	len;		/* number of strings in the string set */
    298 	__u8	data[0];
    299 };
    300 
    301 struct ethtool_sset_info {
    302 	__u32	cmd;		/* ETHTOOL_GSSET_INFO */
    303 	__u32	reserved;
    304 	__u64	sset_mask;	/* input: each bit selects an sset to query */
    305 				/* output: each bit a returned sset */
    306 	__u32	data[0];	/* ETH_SS_xxx count, in order, based on bits
    307 				   in sset_mask.  One bit implies one
    308 				   __u32, two bits implies two
    309 				   __u32's, etc. */
    310 };
    311 
    312 /**
    313  * enum ethtool_test_flags - flags definition of ethtool_test
    314  * @ETH_TEST_FL_OFFLINE: if set perform online and offline tests, otherwise
    315  *	only online tests.
    316  * @ETH_TEST_FL_FAILED: Driver set this flag if test fails.
    317  * @ETH_TEST_FL_EXTERNAL_LB: Application request to perform external loopback
    318  *	test.
    319  * @ETH_TEST_FL_EXTERNAL_LB_DONE: Driver performed the external loopback test
    320  */
    321 
    322 enum ethtool_test_flags {
    323 	ETH_TEST_FL_OFFLINE	= (1 << 0),
    324 	ETH_TEST_FL_FAILED	= (1 << 1),
    325 	ETH_TEST_FL_EXTERNAL_LB	= (1 << 2),
    326 	ETH_TEST_FL_EXTERNAL_LB_DONE	= (1 << 3),
    327 };
    328 
    329 /* for requesting NIC test and getting results*/
    330 struct ethtool_test {
    331 	__u32	cmd;		/* ETHTOOL_TEST */
    332 	__u32	flags;		/* ETH_TEST_FL_xxx */
    333 	__u32	reserved;
    334 	__u32	len;		/* result length, in number of u64 elements */
    335 	__u64	data[0];
    336 };
    337 
    338 /* for dumping NIC-specific statistics */
    339 struct ethtool_stats {
    340 	__u32	cmd;		/* ETHTOOL_GSTATS */
    341 	__u32	n_stats;	/* number of u64's being returned */
    342 	__u64	data[0];
    343 };
    344 
    345 struct ethtool_perm_addr {
    346 	__u32	cmd;		/* ETHTOOL_GPERMADDR */
    347 	__u32	size;
    348 	__u8	data[0];
    349 };
    350 
    351 /* boolean flags controlling per-interface behavior characteristics.
    352  * When reading, the flag indicates whether or not a certain behavior
    353  * is enabled/present.  When writing, the flag indicates whether
    354  * or not the driver should turn on (set) or off (clear) a behavior.
    355  *
    356  * Some behaviors may read-only (unconditionally absent or present).
    357  * If such is the case, return EINVAL in the set-flags operation if the
    358  * flag differs from the read-only value.
    359  */
    360 enum ethtool_flags {
    361 	ETH_FLAG_TXVLAN		= (1 << 7),	/* TX VLAN offload enabled */
    362 	ETH_FLAG_RXVLAN		= (1 << 8),	/* RX VLAN offload enabled */
    363 	ETH_FLAG_LRO		= (1 << 15),	/* LRO is enabled */
    364 	ETH_FLAG_NTUPLE		= (1 << 27),	/* N-tuple filters enabled */
    365 	ETH_FLAG_RXHASH		= (1 << 28),
    366 };
    367 
    368 /* The following structures are for supporting RX network flow
    369  * classification and RX n-tuple configuration. Note, all multibyte
    370  * fields, e.g., ip4src, ip4dst, psrc, pdst, spi, etc. are expected to
    371  * be in network byte order.
    372  */
    373 
    374 /**
    375  * struct ethtool_tcpip4_spec - flow specification for TCP/IPv4 etc.
    376  * @ip4src: Source host
    377  * @ip4dst: Destination host
    378  * @psrc: Source port
    379  * @pdst: Destination port
    380  * @tos: Type-of-service
    381  *
    382  * This can be used to specify a TCP/IPv4, UDP/IPv4 or SCTP/IPv4 flow.
    383  */
    384 struct ethtool_tcpip4_spec {
    385 	__be32	ip4src;
    386 	__be32	ip4dst;
    387 	__be16	psrc;
    388 	__be16	pdst;
    389 	__u8    tos;
    390 };
    391 
    392 /**
    393  * struct ethtool_ah_espip4_spec - flow specification for IPsec/IPv4
    394  * @ip4src: Source host
    395  * @ip4dst: Destination host
    396  * @spi: Security parameters index
    397  * @tos: Type-of-service
    398  *
    399  * This can be used to specify an IPsec transport or tunnel over IPv4.
    400  */
    401 struct ethtool_ah_espip4_spec {
    402 	__be32	ip4src;
    403 	__be32	ip4dst;
    404 	__be32	spi;
    405 	__u8    tos;
    406 };
    407 
    408 #define	ETH_RX_NFC_IP4	1
    409 
    410 /**
    411  * struct ethtool_usrip4_spec - general flow specification for IPv4
    412  * @ip4src: Source host
    413  * @ip4dst: Destination host
    414  * @l4_4_bytes: First 4 bytes of transport (layer 4) header
    415  * @tos: Type-of-service
    416  * @ip_ver: Value must be %ETH_RX_NFC_IP4; mask must be 0
    417  * @proto: Transport protocol number; mask must be 0
    418  */
    419 struct ethtool_usrip4_spec {
    420 	__be32	ip4src;
    421 	__be32	ip4dst;
    422 	__be32	l4_4_bytes;
    423 	__u8    tos;
    424 	__u8    ip_ver;
    425 	__u8    proto;
    426 };
    427 
    428 union ethtool_flow_union {
    429 	struct ethtool_tcpip4_spec		tcp_ip4_spec;
    430 	struct ethtool_tcpip4_spec		udp_ip4_spec;
    431 	struct ethtool_tcpip4_spec		sctp_ip4_spec;
    432 	struct ethtool_ah_espip4_spec		ah_ip4_spec;
    433 	struct ethtool_ah_espip4_spec		esp_ip4_spec;
    434 	struct ethtool_usrip4_spec		usr_ip4_spec;
    435 	struct ethhdr				ether_spec;
    436 	__u8					hdata[60];
    437 };
    438 
    439 struct ethtool_flow_ext {
    440 	__be16	vlan_etype;
    441 	__be16	vlan_tci;
    442 	__be32	data[2];
    443 };
    444 
    445 /**
    446  * struct ethtool_rx_flow_spec - classification rule for RX flows
    447  * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
    448  * @h_u: Flow fields to match (dependent on @flow_type)
    449  * @h_ext: Additional fields to match
    450  * @m_u: Masks for flow field bits to be matched
    451  * @m_ext: Masks for additional field bits to be matched
    452  *	Note, all additional fields must be ignored unless @flow_type
    453  *	includes the %FLOW_EXT flag.
    454  * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC
    455  *	if packets should be discarded
    456  * @location: Location of rule in the table.  Locations must be
    457  *	numbered such that a flow matching multiple rules will be
    458  *	classified according to the first (lowest numbered) rule.
    459  */
    460 struct ethtool_rx_flow_spec {
    461 	__u32		flow_type;
    462 	union ethtool_flow_union h_u;
    463 	struct ethtool_flow_ext h_ext;
    464 	union ethtool_flow_union m_u;
    465 	struct ethtool_flow_ext m_ext;
    466 	__u64		ring_cookie;
    467 	__u32		location;
    468 };
    469 
    470 /**
    471  * struct ethtool_rxnfc - command to get or set RX flow classification rules
    472  * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,
    473  *	%ETHTOOL_GRXRINGS, %ETHTOOL_GRXCLSRLCNT, %ETHTOOL_GRXCLSRULE,
    474  *	%ETHTOOL_GRXCLSRLALL, %ETHTOOL_SRXCLSRLDEL or %ETHTOOL_SRXCLSRLINS
    475  * @flow_type: Type of flow to be affected, e.g. %TCP_V4_FLOW
    476  * @data: Command-dependent value
    477  * @fs: Flow classification rule
    478  * @rule_cnt: Number of rules to be affected
    479  * @rule_locs: Array of used rule locations
    480  *
    481  * For %ETHTOOL_GRXFH and %ETHTOOL_SRXFH, @data is a bitmask indicating
    482  * the fields included in the flow hash, e.g. %RXH_IP_SRC.  The following
    483  * structure fields must not be used.
    484  *
    485  * For %ETHTOOL_GRXRINGS, @data is set to the number of RX rings/queues
    486  * on return.
    487  *
    488  * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined
    489  * rules on return.
    490  *
    491  * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the location of an
    492  * existing rule on entry and @fs contains the rule on return.
    493  *
    494  * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the
    495  * user buffer for @rule_locs on entry.  On return, @data is the size
    496  * of the rule table, @rule_cnt is the number of defined rules, and
    497  * @rule_locs contains the locations of the defined rules.  Drivers
    498  * must use the second parameter to get_rxnfc() instead of @rule_locs.
    499  *
    500  * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update.
    501  * @fs.@location specifies the location to use and must not be ignored.
    502  *
    503  * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the location of an
    504  * existing rule on entry.
    505  */
    506 struct ethtool_rxnfc {
    507 	__u32				cmd;
    508 	__u32				flow_type;
    509 	__u64				data;
    510 	struct ethtool_rx_flow_spec	fs;
    511 	__u32				rule_cnt;
    512 	__u32				rule_locs[0];
    513 };
    514 
    515 
    516 /**
    517  * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection
    518  * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR
    519  * @size: On entry, the array size of the user buffer.  On return from
    520  *	%ETHTOOL_GRXFHINDIR, the array size of the hardware indirection table.
    521  * @ring_index: RX ring/queue index for each hash value
    522  */
    523 struct ethtool_rxfh_indir {
    524 	__u32	cmd;
    525 	__u32	size;
    526 	__u32	ring_index[0];
    527 };
    528 
    529 /**
    530  * struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter
    531  * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
    532  * @h_u: Flow field values to match (dependent on @flow_type)
    533  * @m_u: Masks for flow field value bits to be ignored
    534  * @vlan_tag: VLAN tag to match
    535  * @vlan_tag_mask: Mask for VLAN tag bits to be ignored
    536  * @data: Driver-dependent data to match
    537  * @data_mask: Mask for driver-dependent data bits to be ignored
    538  * @action: RX ring/queue index to deliver to (non-negative) or other action
    539  *	(negative, e.g. %ETHTOOL_RXNTUPLE_ACTION_DROP)
    540  *
    541  * For flow types %TCP_V4_FLOW, %UDP_V4_FLOW and %SCTP_V4_FLOW, where
    542  * a field value and mask are both zero this is treated as if all mask
    543  * bits are set i.e. the field is ignored.
    544  */
    545 struct ethtool_rx_ntuple_flow_spec {
    546 	__u32		 flow_type;
    547 	union {
    548 		struct ethtool_tcpip4_spec		tcp_ip4_spec;
    549 		struct ethtool_tcpip4_spec		udp_ip4_spec;
    550 		struct ethtool_tcpip4_spec		sctp_ip4_spec;
    551 		struct ethtool_ah_espip4_spec		ah_ip4_spec;
    552 		struct ethtool_ah_espip4_spec		esp_ip4_spec;
    553 		struct ethtool_usrip4_spec		usr_ip4_spec;
    554 		struct ethhdr				ether_spec;
    555 		__u8					hdata[72];
    556 	} h_u, m_u;
    557 
    558 	__u16	        vlan_tag;
    559 	__u16	        vlan_tag_mask;
    560 	__u64		data;
    561 	__u64		data_mask;
    562 
    563 	__s32		action;
    564 #define ETHTOOL_RXNTUPLE_ACTION_DROP	(-1)	/* drop packet */
    565 #define ETHTOOL_RXNTUPLE_ACTION_CLEAR	(-2)	/* clear filter */
    566 };
    567 
    568 /**
    569  * struct ethtool_rx_ntuple - command to set or clear RX flow filter
    570  * @cmd: Command number - %ETHTOOL_SRXNTUPLE
    571  * @fs: Flow filter specification
    572  */
    573 struct ethtool_rx_ntuple {
    574 	__u32					cmd;
    575 	struct ethtool_rx_ntuple_flow_spec	fs;
    576 };
    577 
    578 #define ETHTOOL_FLASH_MAX_FILENAME	128
    579 enum ethtool_flash_op_type {
    580 	ETHTOOL_FLASH_ALL_REGIONS	= 0,
    581 };
    582 
    583 /* for passing firmware flashing related parameters */
    584 struct ethtool_flash {
    585 	__u32	cmd;
    586 	__u32	region;
    587 	char	data[ETHTOOL_FLASH_MAX_FILENAME];
    588 };
    589 
    590 /**
    591  * struct ethtool_dump - used for retrieving, setting device dump
    592  * @cmd: Command number - %ETHTOOL_GET_DUMP_FLAG, %ETHTOOL_GET_DUMP_DATA, or
    593  * 	%ETHTOOL_SET_DUMP
    594  * @version: FW version of the dump, filled in by driver
    595  * @flag: driver dependent flag for dump setting, filled in by driver during
    596  * 	  get and filled in by ethtool for set operation
    597  * @len: length of dump data, used as the length of the user buffer on entry to
    598  * 	 %ETHTOOL_GET_DUMP_DATA and this is returned as dump length by driver
    599  * 	 for %ETHTOOL_GET_DUMP_FLAG command
    600  * @data: data collected for get dump data operation
    601  */
    602 struct ethtool_dump {
    603 	__u32	cmd;
    604 	__u32	version;
    605 	__u32	flag;
    606 	__u32	len;
    607 	__u8	data[0];
    608 };
    609 
    610 /* for returning and changing feature sets */
    611 
    612 /**
    613  * struct ethtool_get_features_block - block with state of 32 features
    614  * @available: mask of changeable features
    615  * @requested: mask of features requested to be enabled if possible
    616  * @active: mask of currently enabled features
    617  * @never_changed: mask of features not changeable for any device
    618  */
    619 struct ethtool_get_features_block {
    620 	__u32	available;
    621 	__u32	requested;
    622 	__u32	active;
    623 	__u32	never_changed;
    624 };
    625 
    626 /**
    627  * struct ethtool_gfeatures - command to get state of device's features
    628  * @cmd: command number = %ETHTOOL_GFEATURES
    629  * @size: in: number of elements in the features[] array;
    630  *       out: number of elements in features[] needed to hold all features
    631  * @features: state of features
    632  */
    633 struct ethtool_gfeatures {
    634 	__u32	cmd;
    635 	__u32	size;
    636 	struct ethtool_get_features_block features[0];
    637 };
    638 
    639 /**
    640  * struct ethtool_set_features_block - block with request for 32 features
    641  * @valid: mask of features to be changed
    642  * @requested: values of features to be changed
    643  */
    644 struct ethtool_set_features_block {
    645 	__u32	valid;
    646 	__u32	requested;
    647 };
    648 
    649 /**
    650  * struct ethtool_sfeatures - command to request change in device's features
    651  * @cmd: command number = %ETHTOOL_SFEATURES
    652  * @size: array size of the features[] array
    653  * @features: feature change masks
    654  */
    655 struct ethtool_sfeatures {
    656 	__u32	cmd;
    657 	__u32	size;
    658 	struct ethtool_set_features_block features[0];
    659 };
    660 
    661 /*
    662  * %ETHTOOL_SFEATURES changes features present in features[].valid to the
    663  * values of corresponding bits in features[].requested. Bits in .requested
    664  * not set in .valid or not changeable are ignored.
    665  *
    666  * Returns %EINVAL when .valid contains undefined or never-changeable bits
    667  * or size is not equal to required number of features words (32-bit blocks).
    668  * Returns >= 0 if request was completed; bits set in the value mean:
    669  *   %ETHTOOL_F_UNSUPPORTED - there were bits set in .valid that are not
    670  *	changeable (not present in %ETHTOOL_GFEATURES' features[].available)
    671  *	those bits were ignored.
    672  *   %ETHTOOL_F_WISH - some or all changes requested were recorded but the
    673  *      resulting state of bits masked by .valid is not equal to .requested.
    674  *      Probably there are other device-specific constraints on some features
    675  *      in the set. When %ETHTOOL_F_UNSUPPORTED is set, .valid is considered
    676  *      here as though ignored bits were cleared.
    677  *   %ETHTOOL_F_COMPAT - some or all changes requested were made by calling
    678  *      compatibility functions. Requested offload state cannot be properly
    679  *      managed by kernel.
    680  *
    681  * Meaning of bits in the masks are obtained by %ETHTOOL_GSSET_INFO (number of
    682  * bits in the arrays - always multiple of 32) and %ETHTOOL_GSTRINGS commands
    683  * for ETH_SS_FEATURES string set. First entry in the table corresponds to least
    684  * significant bit in features[0] fields. Empty strings mark undefined features.
    685  */
    686 enum ethtool_sfeatures_retval_bits {
    687 	ETHTOOL_F_UNSUPPORTED__BIT,
    688 	ETHTOOL_F_WISH__BIT,
    689 	ETHTOOL_F_COMPAT__BIT,
    690 };
    691 
    692 #define ETHTOOL_F_UNSUPPORTED   (1 << ETHTOOL_F_UNSUPPORTED__BIT)
    693 #define ETHTOOL_F_WISH          (1 << ETHTOOL_F_WISH__BIT)
    694 #define ETHTOOL_F_COMPAT        (1 << ETHTOOL_F_COMPAT__BIT)
    695 
    696 
    697 /* CMDs currently supported */
    698 #define ETHTOOL_GSET		0x00000001 /* Get settings. */
    699 #define ETHTOOL_SSET		0x00000002 /* Set settings. */
    700 #define ETHTOOL_GDRVINFO	0x00000003 /* Get driver info. */
    701 #define ETHTOOL_GREGS		0x00000004 /* Get NIC registers. */
    702 #define ETHTOOL_GWOL		0x00000005 /* Get wake-on-lan options. */
    703 #define ETHTOOL_SWOL		0x00000006 /* Set wake-on-lan options. */
    704 #define ETHTOOL_GMSGLVL		0x00000007 /* Get driver message level */
    705 #define ETHTOOL_SMSGLVL		0x00000008 /* Set driver msg level. */
    706 #define ETHTOOL_NWAY_RST	0x00000009 /* Restart autonegotiation. */
    707 /* Get link status for host, i.e. whether the interface *and* the
    708  * physical port (if there is one) are up (ethtool_value). */
    709 #define ETHTOOL_GLINK		0x0000000a
    710 #define ETHTOOL_GEEPROM		0x0000000b /* Get EEPROM data */
    711 #define ETHTOOL_SEEPROM		0x0000000c /* Set EEPROM data. */
    712 #define ETHTOOL_GCOALESCE	0x0000000e /* Get coalesce config */
    713 #define ETHTOOL_SCOALESCE	0x0000000f /* Set coalesce config. */
    714 #define ETHTOOL_GRINGPARAM	0x00000010 /* Get ring parameters */
    715 #define ETHTOOL_SRINGPARAM	0x00000011 /* Set ring parameters. */
    716 #define ETHTOOL_GPAUSEPARAM	0x00000012 /* Get pause parameters */
    717 #define ETHTOOL_SPAUSEPARAM	0x00000013 /* Set pause parameters. */
    718 #define ETHTOOL_GRXCSUM		0x00000014 /* Get RX hw csum enable (ethtool_value) */
    719 #define ETHTOOL_SRXCSUM		0x00000015 /* Set RX hw csum enable (ethtool_value) */
    720 #define ETHTOOL_GTXCSUM		0x00000016 /* Get TX hw csum enable (ethtool_value) */
    721 #define ETHTOOL_STXCSUM		0x00000017 /* Set TX hw csum enable (ethtool_value) */
    722 #define ETHTOOL_GSG		0x00000018 /* Get scatter-gather enable
    723 					    * (ethtool_value) */
    724 #define ETHTOOL_SSG		0x00000019 /* Set scatter-gather enable
    725 					    * (ethtool_value). */
    726 #define ETHTOOL_TEST		0x0000001a /* execute NIC self-test. */
    727 #define ETHTOOL_GSTRINGS	0x0000001b /* get specified string set */
    728 #define ETHTOOL_PHYS_ID		0x0000001c /* identify the NIC */
    729 #define ETHTOOL_GSTATS		0x0000001d /* get NIC-specific statistics */
    730 #define ETHTOOL_GTSO		0x0000001e /* Get TSO enable (ethtool_value) */
    731 #define ETHTOOL_STSO		0x0000001f /* Set TSO enable (ethtool_value) */
    732 #define ETHTOOL_GPERMADDR	0x00000020 /* Get permanent hardware address */
    733 #define ETHTOOL_GUFO		0x00000021 /* Get UFO enable (ethtool_value) */
    734 #define ETHTOOL_SUFO		0x00000022 /* Set UFO enable (ethtool_value) */
    735 #define ETHTOOL_GGSO		0x00000023 /* Get GSO enable (ethtool_value) */
    736 #define ETHTOOL_SGSO		0x00000024 /* Set GSO enable (ethtool_value) */
    737 #define ETHTOOL_GFLAGS		0x00000025 /* Get flags bitmap(ethtool_value) */
    738 #define ETHTOOL_SFLAGS		0x00000026 /* Set flags bitmap(ethtool_value) */
    739 #define ETHTOOL_GPFLAGS		0x00000027 /* Get driver-private flags bitmap */
    740 #define ETHTOOL_SPFLAGS		0x00000028 /* Set driver-private flags bitmap */
    741 
    742 #define ETHTOOL_GRXFH		0x00000029 /* Get RX flow hash configuration */
    743 #define ETHTOOL_SRXFH		0x0000002a /* Set RX flow hash configuration */
    744 #define ETHTOOL_GGRO		0x0000002b /* Get GRO enable (ethtool_value) */
    745 #define ETHTOOL_SGRO		0x0000002c /* Set GRO enable (ethtool_value) */
    746 #define ETHTOOL_GRXRINGS	0x0000002d /* Get RX rings available for LB */
    747 #define ETHTOOL_GRXCLSRLCNT	0x0000002e /* Get RX class rule count */
    748 #define ETHTOOL_GRXCLSRULE	0x0000002f /* Get RX classification rule */
    749 #define ETHTOOL_GRXCLSRLALL	0x00000030 /* Get all RX classification rule */
    750 #define ETHTOOL_SRXCLSRLDEL	0x00000031 /* Delete RX classification rule */
    751 #define ETHTOOL_SRXCLSRLINS	0x00000032 /* Insert RX classification rule */
    752 #define ETHTOOL_FLASHDEV	0x00000033 /* Flash firmware to device */
    753 #define ETHTOOL_RESET		0x00000034 /* Reset hardware */
    754 #define ETHTOOL_SRXNTUPLE	0x00000035 /* Add an n-tuple filter to device */
    755 #define ETHTOOL_GRXNTUPLE	0x00000036 /* deprecated */
    756 #define ETHTOOL_GSSET_INFO	0x00000037 /* Get string set info */
    757 #define ETHTOOL_GRXFHINDIR	0x00000038 /* Get RX flow hash indir'n table */
    758 #define ETHTOOL_SRXFHINDIR	0x00000039 /* Set RX flow hash indir'n table */
    759 
    760 #define ETHTOOL_GFEATURES	0x0000003a /* Get device offload settings */
    761 #define ETHTOOL_SFEATURES	0x0000003b /* Change device offload settings */
    762 #define ETHTOOL_GCHANNELS	0x0000003c /* Get no of channels */
    763 #define ETHTOOL_SCHANNELS	0x0000003d /* Set no of channels */
    764 #define ETHTOOL_SET_DUMP	0x0000003e /* Set dump settings */
    765 #define ETHTOOL_GET_DUMP_FLAG	0x0000003f /* Get dump settings */
    766 #define ETHTOOL_GET_DUMP_DATA	0x00000040 /* Get dump data */
    767 
    768 /* compatibility with older code */
    769 #define SPARC_ETH_GSET		ETHTOOL_GSET
    770 #define SPARC_ETH_SSET		ETHTOOL_SSET
    771 
    772 /* Indicates what features are supported by the interface. */
    773 #define SUPPORTED_10baseT_Half		(1 << 0)
    774 #define SUPPORTED_10baseT_Full		(1 << 1)
    775 #define SUPPORTED_100baseT_Half		(1 << 2)
    776 #define SUPPORTED_100baseT_Full		(1 << 3)
    777 #define SUPPORTED_1000baseT_Half	(1 << 4)
    778 #define SUPPORTED_1000baseT_Full	(1 << 5)
    779 #define SUPPORTED_Autoneg		(1 << 6)
    780 #define SUPPORTED_TP			(1 << 7)
    781 #define SUPPORTED_AUI			(1 << 8)
    782 #define SUPPORTED_MII			(1 << 9)
    783 #define SUPPORTED_FIBRE			(1 << 10)
    784 #define SUPPORTED_BNC			(1 << 11)
    785 #define SUPPORTED_10000baseT_Full	(1 << 12)
    786 #define SUPPORTED_Pause			(1 << 13)
    787 #define SUPPORTED_Asym_Pause		(1 << 14)
    788 #define SUPPORTED_2500baseX_Full	(1 << 15)
    789 #define SUPPORTED_Backplane		(1 << 16)
    790 #define SUPPORTED_1000baseKX_Full	(1 << 17)
    791 #define SUPPORTED_10000baseKX4_Full	(1 << 18)
    792 #define SUPPORTED_10000baseKR_Full	(1 << 19)
    793 #define SUPPORTED_10000baseR_FEC	(1 << 20)
    794 #define SUPPORTED_20000baseMLD2_Full	(1 << 21)
    795 #define SUPPORTED_20000baseKR2_Full	(1 << 22)
    796 
    797 /* Indicates what features are advertised by the interface. */
    798 #define ADVERTISED_10baseT_Half		(1 << 0)
    799 #define ADVERTISED_10baseT_Full		(1 << 1)
    800 #define ADVERTISED_100baseT_Half	(1 << 2)
    801 #define ADVERTISED_100baseT_Full	(1 << 3)
    802 #define ADVERTISED_1000baseT_Half	(1 << 4)
    803 #define ADVERTISED_1000baseT_Full	(1 << 5)
    804 #define ADVERTISED_Autoneg		(1 << 6)
    805 #define ADVERTISED_TP			(1 << 7)
    806 #define ADVERTISED_AUI			(1 << 8)
    807 #define ADVERTISED_MII			(1 << 9)
    808 #define ADVERTISED_FIBRE		(1 << 10)
    809 #define ADVERTISED_BNC			(1 << 11)
    810 #define ADVERTISED_10000baseT_Full	(1 << 12)
    811 #define ADVERTISED_Pause		(1 << 13)
    812 #define ADVERTISED_Asym_Pause		(1 << 14)
    813 #define ADVERTISED_2500baseX_Full	(1 << 15)
    814 #define ADVERTISED_Backplane		(1 << 16)
    815 #define ADVERTISED_1000baseKX_Full	(1 << 17)
    816 #define ADVERTISED_10000baseKX4_Full	(1 << 18)
    817 #define ADVERTISED_10000baseKR_Full	(1 << 19)
    818 #define ADVERTISED_10000baseR_FEC	(1 << 20)
    819 #define ADVERTISED_20000baseMLD2_Full	(1 << 21)
    820 #define ADVERTISED_20000baseKR2_Full	(1 << 22)
    821 
    822 /* The following are all involved in forcing a particular link
    823  * mode for the device for setting things.  When getting the
    824  * devices settings, these indicate the current mode and whether
    825  * it was forced up into this mode or autonegotiated.
    826  */
    827 
    828 /* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */
    829 #define SPEED_10		10
    830 #define SPEED_100		100
    831 #define SPEED_1000		1000
    832 #define SPEED_2500		2500
    833 #define SPEED_10000		10000
    834 #define SPEED_UNKNOWN		-1
    835 
    836 /* Duplex, half or full. */
    837 #define DUPLEX_HALF		0x00
    838 #define DUPLEX_FULL		0x01
    839 #define DUPLEX_UNKNOWN		0xff
    840 
    841 /* Which connector port. */
    842 #define PORT_TP			0x00
    843 #define PORT_AUI		0x01
    844 #define PORT_MII		0x02
    845 #define PORT_FIBRE		0x03
    846 #define PORT_BNC		0x04
    847 #define PORT_DA			0x05
    848 #define PORT_NONE		0xef
    849 #define PORT_OTHER		0xff
    850 
    851 /* Which transceiver to use. */
    852 #define XCVR_INTERNAL		0x00
    853 #define XCVR_EXTERNAL		0x01
    854 #define XCVR_DUMMY1		0x02
    855 #define XCVR_DUMMY2		0x03
    856 #define XCVR_DUMMY3		0x04
    857 
    858 /* Enable or disable autonegotiation.  If this is set to enable,
    859  * the forced link modes above are completely ignored.
    860  */
    861 #define AUTONEG_DISABLE		0x00
    862 #define AUTONEG_ENABLE		0x01
    863 
    864 /* Mode MDI or MDI-X */
    865 #define ETH_TP_MDI_INVALID	0x00
    866 #define ETH_TP_MDI		0x01
    867 #define ETH_TP_MDI_X		0x02
    868 
    869 /* Wake-On-Lan options. */
    870 #define WAKE_PHY		(1 << 0)
    871 #define WAKE_UCAST		(1 << 1)
    872 #define WAKE_MCAST		(1 << 2)
    873 #define WAKE_BCAST		(1 << 3)
    874 #define WAKE_ARP		(1 << 4)
    875 #define WAKE_MAGIC		(1 << 5)
    876 #define WAKE_MAGICSECURE	(1 << 6) /* only meaningful if WAKE_MAGIC */
    877 
    878 /* L2-L4 network traffic flow types */
    879 #define	TCP_V4_FLOW	0x01	/* hash or spec (tcp_ip4_spec) */
    880 #define	UDP_V4_FLOW	0x02	/* hash or spec (udp_ip4_spec) */
    881 #define	SCTP_V4_FLOW	0x03	/* hash or spec (sctp_ip4_spec) */
    882 #define	AH_ESP_V4_FLOW	0x04	/* hash only */
    883 #define	TCP_V6_FLOW	0x05	/* hash only */
    884 #define	UDP_V6_FLOW	0x06	/* hash only */
    885 #define	SCTP_V6_FLOW	0x07	/* hash only */
    886 #define	AH_ESP_V6_FLOW	0x08	/* hash only */
    887 #define	AH_V4_FLOW	0x09	/* hash or spec (ah_ip4_spec) */
    888 #define	ESP_V4_FLOW	0x0a	/* hash or spec (esp_ip4_spec) */
    889 #define	AH_V6_FLOW	0x0b	/* hash only */
    890 #define	ESP_V6_FLOW	0x0c	/* hash only */
    891 #define	IP_USER_FLOW	0x0d	/* spec only (usr_ip4_spec) */
    892 #define	IPV4_FLOW	0x10	/* hash only */
    893 #define	IPV6_FLOW	0x11	/* hash only */
    894 #define	ETHER_FLOW	0x12	/* spec only (ether_spec) */
    895 /* Flag to enable additional fields in struct ethtool_rx_flow_spec */
    896 #define	FLOW_EXT	0x80000000
    897 
    898 /* L3-L4 network traffic flow hash options */
    899 #define	RXH_L2DA	(1 << 1)
    900 #define	RXH_VLAN	(1 << 2)
    901 #define	RXH_L3_PROTO	(1 << 3)
    902 #define	RXH_IP_SRC	(1 << 4)
    903 #define	RXH_IP_DST	(1 << 5)
    904 #define	RXH_L4_B_0_1	(1 << 6) /* src port in case of TCP/UDP/SCTP */
    905 #define	RXH_L4_B_2_3	(1 << 7) /* dst port in case of TCP/UDP/SCTP */
    906 #define	RXH_DISCARD	(1 << 31)
    907 
    908 #define	RX_CLS_FLOW_DISC	0xffffffffffffffffULL
    909 
    910 /* Reset flags */
    911 /* The reset() operation must clear the flags for the components which
    912  * were actually reset.  On successful return, the flags indicate the
    913  * components which were not reset, either because they do not exist
    914  * in the hardware or because they cannot be reset independently.  The
    915  * driver must never reset any components that were not requested.
    916  */
    917 enum ethtool_reset_flags {
    918 	/* These flags represent components dedicated to the interface
    919 	 * the command is addressed to.  Shift any flag left by
    920 	 * ETH_RESET_SHARED_SHIFT to reset a shared component of the
    921 	 * same type.
    922 	 */
    923 	ETH_RESET_MGMT		= 1 << 0,	/* Management processor */
    924 	ETH_RESET_IRQ		= 1 << 1,	/* Interrupt requester */
    925 	ETH_RESET_DMA		= 1 << 2,	/* DMA engine */
    926 	ETH_RESET_FILTER	= 1 << 3,	/* Filtering/flow direction */
    927 	ETH_RESET_OFFLOAD	= 1 << 4,	/* Protocol offload */
    928 	ETH_RESET_MAC		= 1 << 5,	/* Media access controller */
    929 	ETH_RESET_PHY		= 1 << 6,	/* Transceiver/PHY */
    930 	ETH_RESET_RAM		= 1 << 7,	/* RAM shared between
    931 						 * multiple components */
    932 
    933 	ETH_RESET_DEDICATED	= 0x0000ffff,	/* All components dedicated to
    934 						 * this interface */
    935 	ETH_RESET_ALL		= 0xffffffff,	/* All components used by this
    936 						 * interface, even if shared */
    937 };
    938 #define ETH_RESET_SHARED_SHIFT	16
    939 
    940 #endif /* _LINUX_ETHTOOL_H */
    941