/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
* ethtool.h: Defines for Linux ethtool.
* Copyright (C) 1998 David S. Miller (davem@redhat.com)
* Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
* Portions Copyright 2001 Sun Microsystems (thockin@sun.com)
* Portions Copyright 2002 Intel (eli.kupermann@intel.com,
* christopher.leech@intel.com,
* scott.feldman@intel.com)
* Portions Copyright (C) Sun Microsystems 2008
#include <linux/kernel.h>
#include <linux/if_ether.h>
#include <limits.h> /* for INT_MAX */
/* All structures exposed to userland should be defined such that they
* have the same layout for 32-bit and 64-bit userland.
/* Note on reserved space.
* Reserved fields must not be accessed directly by user space because
* they may be replaced by a different field in the future. They must
* be initialized to zero before making the request, e.g. via memset
* of the entire structure or implicitly by not being set in a structure
* struct ethtool_cmd - DEPRECATED, link control and status
* This structure is DEPRECATED, please use struct ethtool_link_settings.
* @cmd: Command number = %ETHTOOL_GSET or %ETHTOOL_SSET
* @supported: Bitmask of %SUPPORTED_* flags for the link modes,
* physical connectors and other link features for which the
* interface supports autonegotiation or auto-detection.
* @advertising: Bitmask of %ADVERTISED_* flags for the link modes,
* physical connectors and other link features that are
* advertised through autonegotiation or enabled for
* @speed: Low bits of the speed, 1Mb units, 0 to INT_MAX or SPEED_UNKNOWN
* @duplex: Duplex mode; one of %DUPLEX_*
* @port: Physical connector type; one of %PORT_*
* @phy_address: MDIO address of PHY (transceiver); 0 or 255 if not
* applicable. For clause 45 PHYs this is the PRTAD.
* @transceiver: Historically used to distinguish different possible
* PHY types, but not in a consistent way. Deprecated.
* @autoneg: Enable/disable autonegotiation and auto-detection;
* either %AUTONEG_DISABLE or %AUTONEG_ENABLE
* @mdio_support: Bitmask of %ETH_MDIO_SUPPORTS_* flags for the MDIO
* protocols supported by the interface; 0 if unknown.
* @maxtxpkt: Historically used to report TX IRQ coalescing; now
* obsoleted by &struct ethtool_coalesce. Read-only; deprecated.
* @maxrxpkt: Historically used to report RX IRQ coalescing; now
* obsoleted by &struct ethtool_coalesce. Read-only; deprecated.
* @speed_hi: High bits of the speed, 1Mb units, 0 to INT_MAX or SPEED_UNKNOWN
* @eth_tp_mdix: Ethernet twisted-pair MDI(-X) status; one of
* %ETH_TP_MDI_*. If the status is unknown or not applicable, the
* value will be %ETH_TP_MDI_INVALID. Read-only.
* @eth_tp_mdix_ctrl: Ethernet twisted pair MDI(-X) control; one of
* %ETH_TP_MDI_*. If MDI(-X) control is not implemented, reads
* yield %ETH_TP_MDI_INVALID and writes may be ignored or rejected.
* When written successfully, the link should be renegotiated if
* @lp_advertising: Bitmask of %ADVERTISED_* flags for the link modes
* and other link features that the link partner advertised
* through autonegotiation; 0 if unknown or not applicable.
* @reserved: Reserved for future use; see the note on reserved space.
* The link speed in Mbps is split between @speed and @speed_hi. Use
* the ethtool_cmd_speed() and ethtool_cmd_speed_set() functions to
* If autonegotiation is disabled, the speed and @duplex represent the
* fixed link mode and are writable if the driver supports multiple
* link modes. If it is enabled then they are read-only; if the link
* is up they represent the negotiated link mode; if the link is down,
* the speed is 0, %SPEED_UNKNOWN or the highest enabled speed and
* @duplex is %DUPLEX_UNKNOWN or the best enabled duplex mode.
* Some hardware interfaces may have multiple PHYs and/or physical
* connectors fitted or do not allow the driver to detect which are
* fitted. For these interfaces @port and/or @phy_address may be
* writable, possibly dependent on @autoneg being %AUTONEG_DISABLE.
* Otherwise, attempts to write different values may be ignored or
* Users should assume that all fields not marked read-only are
* writable and subject to validation by the driver. They should use
* %ETHTOOL_GSET to get the current values before making specific
* changes and then applying them with %ETHTOOL_SSET.
* Drivers that implement set_settings() should validate all fields
* other than @cmd that are not described as read-only or deprecated,
* and must ignore all fields described as read-only.
* Deprecated fields should be ignored by both users and drivers.
static __inline__ void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
ep->speed = (__u16)(speed & 0xFFFF);
ep->speed_hi = (__u16)(speed >> 16);
static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
return (ep->speed_hi << 16) | ep->speed;
/* Device supports clause 22 register access to PHY or peripherals
* using the interface defined in <linux/mii.h>. This should not be
* set if there are known to be no such peripherals present or if
* the driver only emulates clause 22 registers for compatibility.
#define ETH_MDIO_SUPPORTS_C22 1
/* Device supports clause 45 register access to PHY or peripherals
* using the interface defined in <linux/mii.h> and <linux/mdio.h>.
* This should not be set if there are known to be no such peripherals
#define ETH_MDIO_SUPPORTS_C45 2
#define ETHTOOL_FWVERS_LEN 32
#define ETHTOOL_BUSINFO_LEN 32
#define ETHTOOL_EROMVERS_LEN 32
* struct ethtool_drvinfo - general driver and device information
* @cmd: Command number = %ETHTOOL_GDRVINFO
* @driver: Driver short name. This should normally match the name
* in its bus driver structure (e.g. pci_driver::name). Must
* not be an empty string.
* @version: Driver version string; may be an empty string
* @fw_version: Firmware version string; may be an empty string
* @erom_version: Expansion ROM version string; may be an empty string
* @bus_info: Device bus address. This should match the dev_name()
* string for the underlying bus device, if there is one. May be
* @reserved2: Reserved for future use; see the note on reserved space.
* @n_priv_flags: Number of flags valid for %ETHTOOL_GPFLAGS and
* %ETHTOOL_SPFLAGS commands; also the number of strings in the
* @n_stats: Number of u64 statistics returned by the %ETHTOOL_GSTATS
* command; also the number of strings in the %ETH_SS_STATS set
* @testinfo_len: Number of results returned by the %ETHTOOL_TEST
* command; also the number of strings in the %ETH_SS_TEST set
* @eedump_len: Size of EEPROM accessible through the %ETHTOOL_GEEPROM
* and %ETHTOOL_SEEPROM commands, in bytes
* @regdump_len: Size of register dump returned by the %ETHTOOL_GREGS
* Users can use the %ETHTOOL_GSSET_INFO command to get the number of
* strings in any string set (from Linux 2.6.34).
* Drivers should set at most @driver, @version, @fw_version and
* @bus_info in their get_drvinfo() implementation. The ethtool
* core fills in the other fields using other driver operations.
char fw_version[ETHTOOL_FWVERS_LEN];
char bus_info[ETHTOOL_BUSINFO_LEN];
char erom_version[ETHTOOL_EROMVERS_LEN];
* struct ethtool_wolinfo - Wake-On-Lan configuration
* @cmd: Command number = %ETHTOOL_GWOL or %ETHTOOL_SWOL
* @supported: Bitmask of %WAKE_* flags for supported Wake-On-Lan modes.
* @wolopts: Bitmask of %WAKE_* flags for enabled Wake-On-Lan modes.
* @sopass: SecureOn(tm) password; meaningful only if %WAKE_MAGICSECURE
/* for passing single values */
#define PFC_STORM_PREVENTION_AUTO 0xffff
#define PFC_STORM_PREVENTION_DISABLE 0
ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */
ETHTOOL_TX_COPYBREAK_BUF_SIZE,
* Add your fresh new tunable attribute above and remember to update
* tunable_strings[] in net/ethtool/common.c
#define DOWNSHIFT_DEV_DEFAULT_COUNT 0xff
#define DOWNSHIFT_DEV_DISABLE 0
/* Time in msecs after which link is reported as down
* 0 = lowest time supported by the PHY
* 0xff = off, link down detection according to standard
#define ETHTOOL_PHY_FAST_LINK_DOWN_ON 0
#define ETHTOOL_PHY_FAST_LINK_DOWN_OFF 0xff
/* Energy Detect Power Down (EDPD) is a feature supported by some PHYs, where
* the PHY's RX & TX blocks are put into a low-power mode when there is no
* link detected (typically cable is un-plugged). For RX, only a minimal
* link-detection is available, and for TX the PHY wakes up to send link pulses
* to avoid any lock-ups in case the peer PHY may also be running in EDPD mode.
* Some PHYs may support configuration of the wake-up interval for TX pulses,
* and some PHYs may support only disabling TX pulses entirely. For the latter
* a special value is required (ETHTOOL_PHY_EDPD_NO_TX) so that this can be
* configured from userspace (should the user want it).
* The interval units for TX wake-up are in milliseconds, since this should
* cover a reasonable range of intervals:
* - from 1 millisecond, which does not sound like much of a power-saver
* - to ~65 seconds which is quite a lot to wait for a link to come up when
#define ETHTOOL_PHY_EDPD_DFLT_TX_MSECS 0xffff
#define ETHTOOL_PHY_EDPD_NO_TX 0xfffe
#define ETHTOOL_PHY_EDPD_DISABLE 0
ETHTOOL_PHY_FAST_LINK_DOWN,
* Add your fresh new phy tunable attribute above and remember to update
* phy_tunable_strings[] in net/ethtool/common.c
__ETHTOOL_PHY_TUNABLE_COUNT,
* struct ethtool_regs - hardware register dump
* @cmd: Command number = %ETHTOOL_GREGS
* @version: Dump format version. This is driver-specific and may
* distinguish different chips/revisions. Drivers must use new
* version numbers whenever the dump format changes in an
* @len: On entry, the real length of @data. On return, the number of
* @data: Buffer for the register dump
* Users should use %ETHTOOL_GDRVINFO to find the maximum length of
* a register dump for the interface. They must allocate the buffer
* immediately following this structure.
* struct ethtool_eeprom - EEPROM dump
* @cmd: Command number = %ETHTOOL_GEEPROM, %ETHTOOL_GMODULEEEPROM or
* @magic: A 'magic cookie' value to guard against accidental changes.
* The value passed in to %ETHTOOL_SEEPROM must match the value
* returned by %ETHTOOL_GEEPROM for the same device. This is
* unused when @cmd is %ETHTOOL_GMODULEEEPROM.
* @offset: Offset within the EEPROM to begin reading/writing, in bytes
* @len: On entry, number of bytes to read/write. On successful
* return, number of bytes actually read/written. In case of
* error, this may indicate at what point the error occurred.
* @data: Buffer to read/write from
* Users may use %ETHTOOL_GDRVINFO or %ETHTOOL_GMODULEINFO to find
* the length of an on-board or module EEPROM, respectively. They
* must allocate the buffer immediately following this structure.
* struct ethtool_eee - Energy Efficient Ethernet information
* @supported: Mask of %SUPPORTED_* flags for the speed/duplex combinations
* for which there is EEE support.
* @advertised: Mask of %ADVERTISED_* flags for the speed/duplex combinations
* advertised as eee capable.
* @lp_advertised: Mask of %ADVERTISED_* flags for the speed/duplex
* combinations advertised by the link partner as eee capable.
* @eee_active: Result of the eee auto negotiation.
* @eee_enabled: EEE configured mode (enabled/disabled).
* @tx_lpi_enabled: Whether the interface should assert its tx lpi, given
* that eee was negotiated.
* @tx_lpi_timer: Time in microseconds the interface delays prior to asserting
* its tx lpi (after reaching 'idle' state). Effective only when eee
* was negotiated and tx_lpi_enabled was set.
* @reserved: Reserved for future use; see the note on reserved space.
* struct ethtool_modinfo - plugin module eeprom information
* @cmd: %ETHTOOL_GMODULEINFO
* @type: Standard the module information conforms to %ETH_MODULE_SFF_xxxx
* @eeprom_len: Length of the eeprom
* @reserved: Reserved for future use; see the note on reserved space.
* This structure is used to return the information to
* properly size memory for a subsequent call to %ETHTOOL_GMODULEEEPROM.
* The type code indicates the eeprom data format
* struct ethtool_coalesce - coalescing parameters for IRQs and stats updates
* @cmd: ETHTOOL_{G,S}COALESCE
* @rx_coalesce_usecs: How many usecs to delay an RX interrupt after
* @rx_max_coalesced_frames: Maximum number of packets to receive
* before an RX interrupt.
* @rx_coalesce_usecs_irq: Same as @rx_coalesce_usecs, except that
* this value applies while an IRQ is being serviced by the host.
* @rx_max_coalesced_frames_irq: Same as @rx_max_coalesced_frames,
* except that this value applies while an IRQ is being serviced
* @tx_coalesce_usecs: How many usecs to delay a TX interrupt after
* @tx_max_coalesced_frames: Maximum number of packets to be sent
* @tx_coalesce_usecs_irq: Same as @tx_coalesce_usecs, except that
* this value applies while an IRQ is being serviced by the host.
* @tx_max_coalesced_frames_irq: Same as @tx_max_coalesced_frames,
* except that this value applies while an IRQ is being serviced
* @stats_block_coalesce_usecs: How many usecs to delay in-memory
* statistics block updates. Some drivers do not have an
* in-memory statistic block, and in such cases this value is
* ignored. This value must not be zero.
* @use_adaptive_rx_coalesce: Enable adaptive RX coalescing.
* @use_adaptive_tx_coalesce: Enable adaptive TX coalescing.
* @pkt_rate_low: Threshold for low packet rate (packets per second).
* @rx_coalesce_usecs_low: How many usecs to delay an RX interrupt after
* a packet arrives, when the packet rate is below @pkt_rate_low.
* @rx_max_coalesced_frames_low: Maximum number of packets to be received
* before an RX interrupt, when the packet rate is below @pkt_rate_low.
* @tx_coalesce_usecs_low: How many usecs to delay a TX interrupt after
* a packet is sent, when the packet rate is below @pkt_rate_low.
* @tx_max_coalesced_frames_low: Maximum nuumber of packets to be sent before
* a TX interrupt, when the packet rate is below @pkt_rate_low.
* @pkt_rate_high: Threshold for high packet rate (packets per second).
* @rx_coalesce_usecs_high: How many usecs to delay an RX interrupt after
* a packet arrives, when the packet rate is above @pkt_rate_high.
* @rx_max_coalesced_frames_high: Maximum number of packets to be received
* before an RX interrupt, when the packet rate is above @pkt_rate_high.
* @tx_coalesce_usecs_high: How many usecs to delay a TX interrupt after
* a packet is sent, when the packet rate is above @pkt_rate_high.
* @tx_max_coalesced_frames_high: Maximum number of packets to be sent before
* a TX interrupt, when the packet rate is above @pkt_rate_high.
* @rate_sample_interval: How often to do adaptive coalescing packet rate
* sampling, measured in seconds. Must not be zero.
* Each pair of (usecs, max_frames) fields specifies that interrupts
* should be coalesced until
* (usecs > 0 && time_since_first_completion >= usecs) ||
* (max_frames > 0 && completed_frames >= max_frames)
* It is illegal to set both usecs and max_frames to zero as this
* would cause interrupts to never be generated. To disable
* coalescing, set usecs = 0 and max_frames = 1.
* Some implementations ignore the value of max_frames and use the
* condition time_since_first_completion >= usecs
* This is deprecated. Drivers for hardware that does not support
* counting completions should validate that max_frames == !rx_usecs.
* Adaptive RX/TX coalescing is an algorithm implemented by some
* drivers to improve latency under low packet rates and improve
* throughput under high packet rates. Some drivers only implement
* one of RX or TX adaptive coalescing. Anything not implemented by
* the driver causes these values to be silently ignored.
* When the packet rate is below @pkt_rate_high but above
* @pkt_rate_low (both measured in packets per second) the
* normal {rx,tx}_* coalescing parameters are used.
struct ethtool_coalesce {
__u32 rx_max_coalesced_frames;
__u32 rx_coalesce_usecs_irq;
__u32 rx_max_coalesced_frames_irq;
__u32 tx_max_coalesced_frames;
__u32 tx_coalesce_usecs_irq;
__u32 tx_max_coalesced_frames_irq;
__u32 stats_block_coalesce_usecs;
__u32 use_adaptive_rx_coalesce;
__u32 use_adaptive_tx_coalesce;
__u32 rx_coalesce_usecs_low;
__u32 rx_max_coalesced_frames_low;
__u32 tx_coalesce_usecs_low;
__u32 tx_max_coalesced_frames_low;
__u32 rx_coalesce_usecs_high;
__u32 rx_max_coalesced_frames_high;
__u32 tx_coalesce_usecs_high;
__u32 tx_max_coalesced_frames_high;
__u32 rate_sample_interval;