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> 18607ca46eSDavid Howells #include <uapi/linux/ethtool.h> 191da177e4SLinus Torvalds 203a7da39dSBen Hutchings #ifdef CONFIG_COMPAT 213a7da39dSBen Hutchings 223a7da39dSBen Hutchings struct compat_ethtool_rx_flow_spec { 233a7da39dSBen Hutchings u32 flow_type; 24127fe533SAlexander Duyck union ethtool_flow_union h_u; 25127fe533SAlexander Duyck struct ethtool_flow_ext h_ext; 26127fe533SAlexander Duyck union ethtool_flow_union m_u; 27127fe533SAlexander Duyck struct ethtool_flow_ext m_ext; 283a7da39dSBen Hutchings compat_u64 ring_cookie; 293a7da39dSBen Hutchings u32 location; 303a7da39dSBen Hutchings }; 313a7da39dSBen Hutchings 323a7da39dSBen Hutchings struct compat_ethtool_rxnfc { 333a7da39dSBen Hutchings u32 cmd; 343a7da39dSBen Hutchings u32 flow_type; 353a7da39dSBen Hutchings compat_u64 data; 363a7da39dSBen Hutchings struct compat_ethtool_rx_flow_spec fs; 373a7da39dSBen Hutchings u32 rule_cnt; 385299a11aSGustavo A. R. Silva u32 rule_locs[]; 393a7da39dSBen Hutchings }; 403a7da39dSBen Hutchings 413a7da39dSBen Hutchings #endif /* CONFIG_COMPAT */ 42c3ce7e20SDavid Woodhouse 43a1467085SDavid S. Miller #include <linux/rculist.h> 44a1467085SDavid S. Miller 4568f512f2SBen Hutchings /** 4668f512f2SBen Hutchings * enum ethtool_phys_id_state - indicator state for physical identification 4768f512f2SBen Hutchings * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated 4868f512f2SBen Hutchings * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated 4968f512f2SBen Hutchings * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE 5068f512f2SBen Hutchings * is not supported) 5168f512f2SBen Hutchings * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE 5268f512f2SBen Hutchings * is not supported) 5368f512f2SBen Hutchings */ 5468f512f2SBen Hutchings enum ethtool_phys_id_state { 5568f512f2SBen Hutchings ETHTOOL_ID_INACTIVE, 5668f512f2SBen Hutchings ETHTOOL_ID_ACTIVE, 5768f512f2SBen Hutchings ETHTOOL_ID_ON, 5868f512f2SBen Hutchings ETHTOOL_ID_OFF 5968f512f2SBen Hutchings }; 6068f512f2SBen Hutchings 61892311f6SEyal Perry enum { 62892311f6SEyal Perry ETH_RSS_HASH_TOP_BIT, /* Configurable RSS hash function - Toeplitz */ 63892311f6SEyal Perry ETH_RSS_HASH_XOR_BIT, /* Configurable RSS hash function - Xor */ 64abb521e3SJakub Kicinski ETH_RSS_HASH_CRC32_BIT, /* Configurable RSS hash function - Crc32 */ 65892311f6SEyal Perry 66892311f6SEyal Perry /* 67892311f6SEyal Perry * Add your fresh new hash function bits above and remember to update 68892311f6SEyal Perry * rss_hash_func_strings[] in ethtool.c 69892311f6SEyal Perry */ 70892311f6SEyal Perry ETH_RSS_HASH_FUNCS_COUNT 71892311f6SEyal Perry }; 72892311f6SEyal Perry 73892311f6SEyal Perry #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit)) 74892311f6SEyal Perry #define __ETH_RSS_HASH(name) __ETH_RSS_HASH_BIT(ETH_RSS_HASH_##name##_BIT) 75892311f6SEyal Perry 76892311f6SEyal Perry #define ETH_RSS_HASH_TOP __ETH_RSS_HASH(TOP) 77892311f6SEyal Perry #define ETH_RSS_HASH_XOR __ETH_RSS_HASH(XOR) 78abb521e3SJakub Kicinski #define ETH_RSS_HASH_CRC32 __ETH_RSS_HASH(CRC32) 79892311f6SEyal Perry 80892311f6SEyal Perry #define ETH_RSS_HASH_UNKNOWN 0 81892311f6SEyal Perry #define ETH_RSS_HASH_NO_CHANGE 0 82892311f6SEyal Perry 831da177e4SLinus Torvalds struct net_device; 841da177e4SLinus Torvalds 851da177e4SLinus Torvalds /* Some generic methods drivers may use in their ethtool_ops */ 861da177e4SLinus Torvalds u32 ethtool_op_get_link(struct net_device *dev); 8702eacbd0SRichard Cochran int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti); 881da177e4SLinus Torvalds 89ecc31c60SAmit Cohen 90ecc31c60SAmit Cohen /** 91ecc31c60SAmit Cohen * struct ethtool_link_ext_state_info - link extended state and substate. 92ecc31c60SAmit Cohen */ 93ecc31c60SAmit Cohen struct ethtool_link_ext_state_info { 94ecc31c60SAmit Cohen enum ethtool_link_ext_state link_ext_state; 95ecc31c60SAmit Cohen union { 96ecc31c60SAmit Cohen enum ethtool_link_ext_substate_autoneg autoneg; 97ecc31c60SAmit Cohen enum ethtool_link_ext_substate_link_training link_training; 98ecc31c60SAmit Cohen enum ethtool_link_ext_substate_link_logical_mismatch link_logical_mismatch; 99ecc31c60SAmit Cohen enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity; 100ecc31c60SAmit Cohen enum ethtool_link_ext_substate_cable_issue cable_issue; 101ecc31c60SAmit Cohen u8 __link_ext_substate; 102ecc31c60SAmit Cohen }; 103ecc31c60SAmit Cohen }; 104ecc31c60SAmit Cohen 1051da177e4SLinus Torvalds /** 106278bc429SBen Hutchings * ethtool_rxfh_indir_default - get default value for RX flow hash indirection 107278bc429SBen Hutchings * @index: Index in RX flow hash indirection table 108278bc429SBen Hutchings * @n_rx_rings: Number of RX rings to use 109278bc429SBen Hutchings * 110278bc429SBen Hutchings * This function provides the default policy for RX flow hash indirection. 111278bc429SBen Hutchings */ 112278bc429SBen Hutchings static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings) 113278bc429SBen Hutchings { 114278bc429SBen Hutchings return index % n_rx_rings; 115278bc429SBen Hutchings } 116278bc429SBen Hutchings 1173f1ac7a7SDavid Decotigny /* declare a link mode bitmap */ 1183f1ac7a7SDavid Decotigny #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \ 1193f1ac7a7SDavid Decotigny DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS) 1203f1ac7a7SDavid Decotigny 1213f1ac7a7SDavid Decotigny /* drivers must ignore base.cmd and base.link_mode_masks_nwords 1223f1ac7a7SDavid Decotigny * fields, but they are allowed to overwrite them (will be ignored). 1233f1ac7a7SDavid Decotigny */ 1243f1ac7a7SDavid Decotigny struct ethtool_link_ksettings { 1253f1ac7a7SDavid Decotigny struct ethtool_link_settings base; 1263f1ac7a7SDavid Decotigny struct { 1273f1ac7a7SDavid Decotigny __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); 1283f1ac7a7SDavid Decotigny __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); 1293f1ac7a7SDavid Decotigny __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); 1303f1ac7a7SDavid Decotigny } link_modes; 131012ce4ddSDanielle Ratson u32 lanes; 132c8907043SDanielle Ratson enum ethtool_link_mode_bit_indices link_mode; 1333f1ac7a7SDavid Decotigny }; 1343f1ac7a7SDavid Decotigny 1353f1ac7a7SDavid Decotigny /** 1363f1ac7a7SDavid Decotigny * ethtool_link_ksettings_zero_link_mode - clear link_ksettings link mode mask 1373f1ac7a7SDavid Decotigny * @ptr : pointer to struct ethtool_link_ksettings 1383f1ac7a7SDavid Decotigny * @name : one of supported/advertising/lp_advertising 1393f1ac7a7SDavid Decotigny */ 1403f1ac7a7SDavid Decotigny #define ethtool_link_ksettings_zero_link_mode(ptr, name) \ 1413f1ac7a7SDavid Decotigny bitmap_zero((ptr)->link_modes.name, __ETHTOOL_LINK_MODE_MASK_NBITS) 1423f1ac7a7SDavid Decotigny 1433f1ac7a7SDavid Decotigny /** 1443f1ac7a7SDavid Decotigny * ethtool_link_ksettings_add_link_mode - set bit in link_ksettings 1453f1ac7a7SDavid Decotigny * link mode mask 1463f1ac7a7SDavid Decotigny * @ptr : pointer to struct ethtool_link_ksettings 1473f1ac7a7SDavid Decotigny * @name : one of supported/advertising/lp_advertising 1483f1ac7a7SDavid Decotigny * @mode : one of the ETHTOOL_LINK_MODE_*_BIT 1493f1ac7a7SDavid Decotigny * (not atomic, no bound checking) 1503f1ac7a7SDavid Decotigny */ 1513f1ac7a7SDavid Decotigny #define ethtool_link_ksettings_add_link_mode(ptr, name, mode) \ 1523f1ac7a7SDavid Decotigny __set_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) 1533f1ac7a7SDavid Decotigny 1543f1ac7a7SDavid Decotigny /** 155606c07f3SLendacky, Thomas * ethtool_link_ksettings_del_link_mode - clear bit in link_ksettings 156606c07f3SLendacky, Thomas * link mode mask 157606c07f3SLendacky, Thomas * @ptr : pointer to struct ethtool_link_ksettings 158606c07f3SLendacky, Thomas * @name : one of supported/advertising/lp_advertising 159606c07f3SLendacky, Thomas * @mode : one of the ETHTOOL_LINK_MODE_*_BIT 160606c07f3SLendacky, Thomas * (not atomic, no bound checking) 161606c07f3SLendacky, Thomas */ 162606c07f3SLendacky, Thomas #define ethtool_link_ksettings_del_link_mode(ptr, name, mode) \ 163606c07f3SLendacky, Thomas __clear_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) 164606c07f3SLendacky, Thomas 165606c07f3SLendacky, Thomas /** 1663f1ac7a7SDavid Decotigny * ethtool_link_ksettings_test_link_mode - test bit in ksettings link mode mask 1673f1ac7a7SDavid Decotigny * @ptr : pointer to struct ethtool_link_ksettings 1683f1ac7a7SDavid Decotigny * @name : one of supported/advertising/lp_advertising 1693f1ac7a7SDavid Decotigny * @mode : one of the ETHTOOL_LINK_MODE_*_BIT 1703f1ac7a7SDavid Decotigny * (not atomic, no bound checking) 1713f1ac7a7SDavid Decotigny * 1723f1ac7a7SDavid Decotigny * Returns true/false. 1733f1ac7a7SDavid Decotigny */ 1743f1ac7a7SDavid Decotigny #define ethtool_link_ksettings_test_link_mode(ptr, name, mode) \ 1753f1ac7a7SDavid Decotigny test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) 1763f1ac7a7SDavid Decotigny 1773f1ac7a7SDavid Decotigny extern int 1783f1ac7a7SDavid Decotigny __ethtool_get_link_ksettings(struct net_device *dev, 1793f1ac7a7SDavid Decotigny struct ethtool_link_ksettings *link_ksettings); 1803f1ac7a7SDavid Decotigny 1815a6cd6deSAlan Brady /** 1825a6cd6deSAlan Brady * ethtool_intersect_link_masks - Given two link masks, AND them together 1835a6cd6deSAlan Brady * @dst: first mask and where result is stored 1845a6cd6deSAlan Brady * @src: second mask to intersect with 1855a6cd6deSAlan Brady * 1865a6cd6deSAlan Brady * Given two link mode masks, AND them together and save the result in dst. 1875a6cd6deSAlan Brady */ 1885a6cd6deSAlan Brady void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst, 1895a6cd6deSAlan Brady struct ethtool_link_ksettings *src); 1905a6cd6deSAlan Brady 1916d62b4d5SPhilippe Reynes void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst, 1926d62b4d5SPhilippe Reynes u32 legacy_u32); 1936d62b4d5SPhilippe Reynes 1946d62b4d5SPhilippe Reynes /* return false if src had higher bits set. lower bits always updated. */ 1956d62b4d5SPhilippe Reynes bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, 1966d62b4d5SPhilippe Reynes const unsigned long *src); 1976d62b4d5SPhilippe Reynes 19895cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_USECS BIT(0) 19995cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_MAX_FRAMES BIT(1) 20095cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_USECS_IRQ BIT(2) 20195cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ BIT(3) 20295cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_USECS BIT(4) 20395cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_MAX_FRAMES BIT(5) 20495cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_USECS_IRQ BIT(6) 20595cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ BIT(7) 20695cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_STATS_BLOCK_USECS BIT(8) 20795cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USE_ADAPTIVE_RX BIT(9) 20895cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USE_ADAPTIVE_TX BIT(10) 20995cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_PKT_RATE_LOW BIT(11) 21095cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_USECS_LOW BIT(12) 21195cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW BIT(13) 21295cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_USECS_LOW BIT(14) 21395cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW BIT(15) 21495cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_PKT_RATE_HIGH BIT(16) 21595cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_USECS_HIGH BIT(17) 21695cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH BIT(18) 21795cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19) 21895cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH BIT(20) 21995cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21) 2204ae21993SAntonio Cardace #define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(21, 0) 22195cddcb5SJakub Kicinski 22295cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USECS \ 22395cddcb5SJakub Kicinski (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS) 22495cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_MAX_FRAMES \ 22595cddcb5SJakub Kicinski (ETHTOOL_COALESCE_RX_MAX_FRAMES | ETHTOOL_COALESCE_TX_MAX_FRAMES) 22695cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USECS_IRQ \ 22795cddcb5SJakub Kicinski (ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ) 22895cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_MAX_FRAMES_IRQ \ 22995cddcb5SJakub Kicinski (ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | \ 23095cddcb5SJakub Kicinski ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ) 23195cddcb5SJakub Kicinski #define ETHTOOL_COALESCE_USE_ADAPTIVE \ 23295cddcb5SJakub Kicinski (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_ADAPTIVE_TX) 2338213f6c9SJakub Kicinski #define ETHTOOL_COALESCE_USECS_LOW_HIGH \ 2348213f6c9SJakub Kicinski (ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_TX_USECS_LOW | \ 2358213f6c9SJakub Kicinski ETHTOOL_COALESCE_RX_USECS_HIGH | ETHTOOL_COALESCE_TX_USECS_HIGH) 2364f9546d2SJakub Kicinski #define ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH \ 2374f9546d2SJakub Kicinski (ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW | \ 2384f9546d2SJakub Kicinski ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW | \ 2394f9546d2SJakub Kicinski ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH | \ 2404f9546d2SJakub Kicinski ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH) 241812df69bSJakub Kicinski #define ETHTOOL_COALESCE_PKT_RATE_RX_USECS \ 242812df69bSJakub Kicinski (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | \ 243812df69bSJakub Kicinski ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_RX_USECS_HIGH | \ 244812df69bSJakub Kicinski ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \ 245812df69bSJakub Kicinski ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL) 24695cddcb5SJakub Kicinski 2479a27a330SJakub Kicinski #define ETHTOOL_STAT_NOT_SET (~0ULL) 2489a27a330SJakub Kicinski 2499a27a330SJakub Kicinski /** 2509a27a330SJakub Kicinski * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames 2519a27a330SJakub Kicinski * @tx_pause_frames: transmitted pause frame count. Reported to user space 2529a27a330SJakub Kicinski * as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES. 2539a27a330SJakub Kicinski * 2549a27a330SJakub Kicinski * Equivalent to `30.3.4.2 aPAUSEMACCtrlFramesTransmitted` 2559a27a330SJakub Kicinski * from the standard. 2569a27a330SJakub Kicinski * 2579a27a330SJakub Kicinski * @rx_pause_frames: received pause frame count. Reported to user space 2589a27a330SJakub Kicinski * as %ETHTOOL_A_PAUSE_STAT_RX_FRAMES. Equivalent to: 2599a27a330SJakub Kicinski * 2609a27a330SJakub Kicinski * Equivalent to `30.3.4.3 aPAUSEMACCtrlFramesReceived` 2619a27a330SJakub Kicinski * from the standard. 2629a27a330SJakub Kicinski */ 2639a27a330SJakub Kicinski struct ethtool_pause_stats { 2649a27a330SJakub Kicinski u64 tx_pause_frames; 2659a27a330SJakub Kicinski u64 rx_pause_frames; 2669a27a330SJakub Kicinski }; 2679a27a330SJakub Kicinski 268278bc429SBen Hutchings /** 2698717d07bSBen Hutchings * struct ethtool_ops - optional netdev operations 270012ce4ddSDanielle Ratson * @cap_link_lanes_supported: indicates if the driver supports lanes 271012ce4ddSDanielle Ratson * parameter. 27295cddcb5SJakub Kicinski * @supported_coalesce_params: supported types of interrupt coalescing. 2738717d07bSBen Hutchings * @get_drvinfo: Report driver/device information. Should only set the 2748717d07bSBen Hutchings * @driver, @version, @fw_version and @bus_info fields. If not 2758717d07bSBen Hutchings * implemented, the @driver and @bus_info fields will be filled in 2768717d07bSBen Hutchings * according to the netdev's parent device. 2778717d07bSBen Hutchings * @get_regs_len: Get buffer length required for @get_regs 278e20b5b61SBen Hutchings * @get_regs: Get device registers 279e20b5b61SBen Hutchings * @get_wol: Report whether Wake-on-Lan is enabled 2808717d07bSBen Hutchings * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code 2818717d07bSBen Hutchings * or zero. 2828717d07bSBen Hutchings * @get_msglevel: Report driver message level. This should be the value 2838717d07bSBen Hutchings * of the @msg_enable field used by netif logging functions. 284e20b5b61SBen Hutchings * @set_msglevel: Set driver message level 2858717d07bSBen Hutchings * @nway_reset: Restart autonegotiation. Returns a negative error code 2868717d07bSBen Hutchings * or zero. 2878717d07bSBen Hutchings * @get_link: Report whether physical link is up. Will only be called if 2888717d07bSBen Hutchings * the netdev is up. Should usually be set to ethtool_op_get_link(), 2898717d07bSBen Hutchings * which uses netif_carrier_ok(). 290ecc31c60SAmit Cohen * @get_link_ext_state: Report link extended state. Should set link_ext_state and 291ecc31c60SAmit Cohen * link_ext_substate (link_ext_substate of 0 means link_ext_substate is unknown, 292ecc31c60SAmit Cohen * do not attach ext_substate attribute to netlink message). If link_ext_state 293ecc31c60SAmit Cohen * and link_ext_substate are unknown, return -ENODATA. If not implemented, 294ecc31c60SAmit Cohen * link_ext_state and link_ext_substate will not be sent to userspace. 295e20b5b61SBen Hutchings * @get_eeprom: Read data from the device EEPROM. 2961da177e4SLinus Torvalds * Should fill in the magic field. Don't need to check len for zero 2971da177e4SLinus Torvalds * or wraparound. Fill in the data argument with the eeprom values 2981da177e4SLinus Torvalds * from offset to offset + len. Update len to the amount read. 2991da177e4SLinus Torvalds * Returns an error or zero. 300e20b5b61SBen Hutchings * @set_eeprom: Write data to the device EEPROM. 3011da177e4SLinus Torvalds * Should validate the magic field. Don't need to check len for zero 3021da177e4SLinus Torvalds * or wraparound. Update len to the amount written. Returns an error 3031da177e4SLinus Torvalds * or zero. 3048717d07bSBen Hutchings * @get_coalesce: Get interrupt coalescing parameters. Returns a negative 3058717d07bSBen Hutchings * error code or zero. 30695cddcb5SJakub Kicinski * @set_coalesce: Set interrupt coalescing parameters. Supported coalescing 30795cddcb5SJakub Kicinski * types should be set in @supported_coalesce_params. 30895cddcb5SJakub Kicinski * Returns a negative error code or zero. 309e20b5b61SBen Hutchings * @get_ringparam: Report ring sizes 3108717d07bSBen Hutchings * @set_ringparam: Set ring sizes. Returns a negative error code or zero. 3119a27a330SJakub Kicinski * @get_pause_stats: Report pause frame statistics. Drivers must not zero 3129a27a330SJakub Kicinski * statistics which they don't report. The stats structure is initialized 3139a27a330SJakub Kicinski * to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics. 314e20b5b61SBen Hutchings * @get_pauseparam: Report pause parameters 3158717d07bSBen Hutchings * @set_pauseparam: Set pause parameters. Returns a negative error code 3168717d07bSBen Hutchings * or zero. 317e20b5b61SBen Hutchings * @self_test: Run specified self-tests 318e20b5b61SBen Hutchings * @get_strings: Return a set of strings that describe the requested objects 31968f512f2SBen Hutchings * @set_phys_id: Identify the physical devices, e.g. by flashing an LED 32068f512f2SBen Hutchings * attached to it. The implementation may update the indicator 32168f512f2SBen Hutchings * asynchronously or synchronously, but in either case it must return 32268f512f2SBen Hutchings * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE, 323fce55922SAllan, Bruce W * and must either activate asynchronous updates and return zero, return 324fce55922SAllan, Bruce W * a negative error or return a positive frequency for synchronous 325fce55922SAllan, Bruce W * indication (e.g. 1 for one on/off cycle per second). If it returns 326fce55922SAllan, Bruce W * a frequency then it will be called again at intervals with the 32768f512f2SBen Hutchings * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of 32868f512f2SBen Hutchings * the indicator accordingly. Finally, it is called with the argument 32968f512f2SBen Hutchings * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a 33068f512f2SBen Hutchings * negative error code or zero. 3318717d07bSBen Hutchings * @get_ethtool_stats: Return extended statistics about the device. 3328717d07bSBen Hutchings * This is only useful if the device maintains statistics not 3338717d07bSBen Hutchings * included in &struct rtnl_link_stats64. 3348717d07bSBen Hutchings * @begin: Function to be called before any other operation. Returns a 3358717d07bSBen Hutchings * negative error code or zero. 3368717d07bSBen Hutchings * @complete: Function to be called after any other operation except 3378717d07bSBen Hutchings * @begin. Will be called even if the other operation failed. 3388717d07bSBen Hutchings * @get_priv_flags: Report driver-specific feature flags. 3398717d07bSBen Hutchings * @set_priv_flags: Set driver-specific feature flags. Returns a negative 3408717d07bSBen Hutchings * error code or zero. 3418717d07bSBen Hutchings * @get_sset_count: Get number of strings that @get_strings will write. 3428717d07bSBen Hutchings * @get_rxnfc: Get RX flow classification rules. Returns a negative 3438717d07bSBen Hutchings * error code or zero. 3448717d07bSBen Hutchings * @set_rxnfc: Set RX flow classification rules. Returns a negative 3458717d07bSBen Hutchings * error code or zero. 3468717d07bSBen Hutchings * @flash_device: Write a firmware image to device's flash memory. 3478717d07bSBen Hutchings * Returns a negative error code or zero. 3488717d07bSBen Hutchings * @reset: Reset (part of) the device, as specified by a bitmask of 3498717d07bSBen Hutchings * flags from &enum ethtool_reset_flags. Returns a negative 3508717d07bSBen Hutchings * error code or zero. 3513de0b592SVenkata Duvvuru * @get_rxfh_key_size: Get the size of the RX flow hash key. 3523de0b592SVenkata Duvvuru * Returns zero if not supported for this specific device. 3537850f63fSBen Hutchings * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table. 3547850f63fSBen Hutchings * Returns zero if not supported for this specific device. 355892311f6SEyal Perry * @get_rxfh: Get the contents of the RX flow hash indirection table, hash key 356892311f6SEyal Perry * and/or hash function. 3578717d07bSBen Hutchings * Returns a negative error code or zero. 358892311f6SEyal Perry * @set_rxfh: Set the contents of the RX flow hash indirection table, hash 359892311f6SEyal Perry * key, and/or hash function. Arguments which are set to %NULL or zero 360892311f6SEyal Perry * will remain unchanged. 361892311f6SEyal Perry * Returns a negative error code or zero. An error code must be returned 362892311f6SEyal Perry * if at least one unsupported change was requested. 363f4bcf14eSMaxime Chevallier * @get_rxfh_context: Get the contents of the RX flow hash indirection table, 364f4bcf14eSMaxime Chevallier * hash key, and/or hash function assiciated to the given rss context. 365f4bcf14eSMaxime Chevallier * Returns a negative error code or zero. 366f4bcf14eSMaxime Chevallier * @set_rxfh_context: Create, remove and configure RSS contexts. Allows setting 367f4bcf14eSMaxime Chevallier * the contents of the RX flow hash indirection table, hash key, and/or 368f4bcf14eSMaxime Chevallier * hash function associated to the given context. Arguments which are set 369f4bcf14eSMaxime Chevallier * to %NULL or zero will remain unchanged. 370f4bcf14eSMaxime Chevallier * Returns a negative error code or zero. An error code must be returned 371f4bcf14eSMaxime Chevallier * if at least one unsupported change was requested. 3728b5933c3Samit salecha * @get_channels: Get number of channels. 3738b5933c3Samit salecha * @set_channels: Set number of channels. Returns a negative error code or 3748b5933c3Samit salecha * zero. 37529dd54b7SAnirban Chakraborty * @get_dump_flag: Get dump flag indicating current dump length, version, 37629dd54b7SAnirban Chakraborty * and flag of the device. 37729dd54b7SAnirban Chakraborty * @get_dump_data: Get dump data. 37829dd54b7SAnirban Chakraborty * @set_dump: Set dump specific flags to the device. 379c8f3a8c3SRichard Cochran * @get_ts_info: Get the time stamping and PTP hardware clock capabilities. 380c8f3a8c3SRichard Cochran * Drivers supporting transmit time stamps in software should set this to 381c8f3a8c3SRichard Cochran * ethtool_op_get_ts_info(). 38241c3cb6dSStuart Hodgson * @get_module_info: Get the size and type of the eeprom contained within 38341c3cb6dSStuart Hodgson * a plug-in module. 38441c3cb6dSStuart Hodgson * @get_module_eeprom: Get the eeprom information from the plug-in module 38580f12eccSYuval Mintz * @get_eee: Get Energy-Efficient (EEE) supported and status. 38680f12eccSYuval Mintz * @set_eee: Set EEE status (enable/disable) as well as LPI timers. 387421797b1SKan Liang * @get_per_queue_coalesce: Get interrupt coalescing parameters per queue. 388421797b1SKan Liang * It must check that the given queue number is valid. If neither a RX nor 389421797b1SKan Liang * a TX queue has this number, return -EINVAL. If only a RX queue or a TX 390421797b1SKan Liang * queue has this number, set the inapplicable fields to ~0 and return 0. 391421797b1SKan Liang * Returns a negative error code or zero. 392f38d138aSKan Liang * @set_per_queue_coalesce: Set interrupt coalescing parameters per queue. 393f38d138aSKan Liang * It must check that the given queue number is valid. If neither a RX nor 394f38d138aSKan Liang * a TX queue has this number, return -EINVAL. If only a RX queue or a TX 39595cddcb5SJakub Kicinski * queue has this number, ignore the inapplicable fields. Supported 39695cddcb5SJakub Kicinski * coalescing types should be set in @supported_coalesce_params. 397f38d138aSKan Liang * Returns a negative error code or zero. 3989b300495SMichal Kubecek * @get_link_ksettings: Get various device settings including Ethernet link 3999b300495SMichal Kubecek * settings. The %cmd and %link_mode_masks_nwords fields should be 4009b300495SMichal Kubecek * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), 4019b300495SMichal Kubecek * any change to them will be overwritten by kernel. Returns a negative 4029b300495SMichal Kubecek * error code or zero. 4039b300495SMichal Kubecek * @set_link_ksettings: Set various device settings including Ethernet link 4049b300495SMichal Kubecek * settings. The %cmd and %link_mode_masks_nwords fields should be 4059b300495SMichal Kubecek * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), 4069b300495SMichal Kubecek * any change to them will be overwritten by kernel. Returns a negative 4079b300495SMichal Kubecek * error code or zero. 408d805c520SFlorian Fainelli * @get_fecparam: Get the network device Forward Error Correction parameters. 409d805c520SFlorian Fainelli * @set_fecparam: Set the network device Forward Error Correction parameters. 41099943382SFlorian Fainelli * @get_ethtool_phy_stats: Return extended statistics about the PHY device. 41199943382SFlorian Fainelli * This is only useful if the device maintains PHY statistics and 41299943382SFlorian Fainelli * cannot use the standard PHY library helpers. 4138717d07bSBen Hutchings * 4148717d07bSBen Hutchings * All operations are optional (i.e. the function pointer may be set 4158717d07bSBen Hutchings * to %NULL) and callers must take this into account. Callers must 416b4f79e5cSBen Hutchings * hold the RTNL lock. 4178717d07bSBen Hutchings * 4188717d07bSBen Hutchings * See the structures used by these operations for further documentation. 4196e201c85SBen Hutchings * Note that for all operations using a structure ending with a zero- 4206e201c85SBen Hutchings * length array, the array is allocated separately in the kernel and 4216e201c85SBen Hutchings * is passed to the driver as an additional parameter. 4228717d07bSBen Hutchings * 4238717d07bSBen Hutchings * See &struct net_device and &struct net_device_ops for documentation 4248717d07bSBen Hutchings * of the generic netdev features interface. 4251da177e4SLinus Torvalds */ 4261da177e4SLinus Torvalds struct ethtool_ops { 427012ce4ddSDanielle Ratson u32 cap_link_lanes_supported:1; 42895cddcb5SJakub Kicinski u32 supported_coalesce_params; 4291da177e4SLinus Torvalds void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *); 4301da177e4SLinus Torvalds int (*get_regs_len)(struct net_device *); 4311da177e4SLinus Torvalds void (*get_regs)(struct net_device *, struct ethtool_regs *, void *); 4321da177e4SLinus Torvalds void (*get_wol)(struct net_device *, struct ethtool_wolinfo *); 4331da177e4SLinus Torvalds int (*set_wol)(struct net_device *, struct ethtool_wolinfo *); 4341da177e4SLinus Torvalds u32 (*get_msglevel)(struct net_device *); 4351da177e4SLinus Torvalds void (*set_msglevel)(struct net_device *, u32); 4361da177e4SLinus Torvalds int (*nway_reset)(struct net_device *); 4371da177e4SLinus Torvalds u32 (*get_link)(struct net_device *); 438ecc31c60SAmit Cohen int (*get_link_ext_state)(struct net_device *, 439ecc31c60SAmit Cohen struct ethtool_link_ext_state_info *); 4401da177e4SLinus Torvalds int (*get_eeprom_len)(struct net_device *); 44197f8aefbSchavey int (*get_eeprom)(struct net_device *, 44297f8aefbSchavey struct ethtool_eeprom *, u8 *); 44397f8aefbSchavey int (*set_eeprom)(struct net_device *, 44497f8aefbSchavey struct ethtool_eeprom *, u8 *); 4451da177e4SLinus Torvalds int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *); 4461da177e4SLinus Torvalds int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *); 44797f8aefbSchavey void (*get_ringparam)(struct net_device *, 44897f8aefbSchavey struct ethtool_ringparam *); 44997f8aefbSchavey int (*set_ringparam)(struct net_device *, 45097f8aefbSchavey struct ethtool_ringparam *); 4519a27a330SJakub Kicinski void (*get_pause_stats)(struct net_device *dev, 4529a27a330SJakub Kicinski struct ethtool_pause_stats *pause_stats); 45397f8aefbSchavey void (*get_pauseparam)(struct net_device *, 45497f8aefbSchavey struct ethtool_pauseparam*); 45597f8aefbSchavey int (*set_pauseparam)(struct net_device *, 45697f8aefbSchavey struct ethtool_pauseparam*); 4571da177e4SLinus Torvalds void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); 4581da177e4SLinus Torvalds void (*get_strings)(struct net_device *, u32 stringset, u8 *); 45968f512f2SBen Hutchings int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state); 46097f8aefbSchavey void (*get_ethtool_stats)(struct net_device *, 46197f8aefbSchavey struct ethtool_stats *, u64 *); 4621da177e4SLinus Torvalds int (*begin)(struct net_device *); 4631da177e4SLinus Torvalds void (*complete)(struct net_device *); 464339bf024SJeff Garzik u32 (*get_priv_flags)(struct net_device *); 465339bf024SJeff Garzik int (*set_priv_flags)(struct net_device *, u32); 466ff03d49fSJeff Garzik int (*get_sset_count)(struct net_device *, int); 46797f8aefbSchavey int (*get_rxnfc)(struct net_device *, 468815c7db5SBen Hutchings struct ethtool_rxnfc *, u32 *rule_locs); 46959089d8dSSantwona Behera int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *); 47005c6a8d7SAjit Khaparde int (*flash_device)(struct net_device *, struct ethtool_flash *); 471d73d3a8cSBen Hutchings int (*reset)(struct net_device *, u32 *); 4723de0b592SVenkata Duvvuru u32 (*get_rxfh_key_size)(struct net_device *); 4737850f63fSBen Hutchings u32 (*get_rxfh_indir_size)(struct net_device *); 474892311f6SEyal Perry int (*get_rxfh)(struct net_device *, u32 *indir, u8 *key, 475892311f6SEyal Perry u8 *hfunc); 47633cb0fa7SBen Hutchings int (*set_rxfh)(struct net_device *, const u32 *indir, 477892311f6SEyal Perry const u8 *key, const u8 hfunc); 47884a1d9c4SEdward Cree int (*get_rxfh_context)(struct net_device *, u32 *indir, u8 *key, 47984a1d9c4SEdward Cree u8 *hfunc, u32 rss_context); 48084a1d9c4SEdward Cree int (*set_rxfh_context)(struct net_device *, const u32 *indir, 48184a1d9c4SEdward Cree const u8 *key, const u8 hfunc, 48284a1d9c4SEdward Cree u32 *rss_context, bool delete); 4838b5933c3Samit salecha void (*get_channels)(struct net_device *, struct ethtool_channels *); 4848b5933c3Samit salecha int (*set_channels)(struct net_device *, struct ethtool_channels *); 48529dd54b7SAnirban Chakraborty int (*get_dump_flag)(struct net_device *, struct ethtool_dump *); 48629dd54b7SAnirban Chakraborty int (*get_dump_data)(struct net_device *, 48729dd54b7SAnirban Chakraborty struct ethtool_dump *, void *); 48829dd54b7SAnirban Chakraborty int (*set_dump)(struct net_device *, struct ethtool_dump *); 489c8f3a8c3SRichard Cochran int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *); 49041c3cb6dSStuart Hodgson int (*get_module_info)(struct net_device *, 49141c3cb6dSStuart Hodgson struct ethtool_modinfo *); 49241c3cb6dSStuart Hodgson int (*get_module_eeprom)(struct net_device *, 49341c3cb6dSStuart Hodgson struct ethtool_eeprom *, u8 *); 49480f12eccSYuval Mintz int (*get_eee)(struct net_device *, struct ethtool_eee *); 49580f12eccSYuval Mintz int (*set_eee)(struct net_device *, struct ethtool_eee *); 496f0db9b07SGovindarajulu Varadarajan int (*get_tunable)(struct net_device *, 497f0db9b07SGovindarajulu Varadarajan const struct ethtool_tunable *, void *); 498f0db9b07SGovindarajulu Varadarajan int (*set_tunable)(struct net_device *, 499f0db9b07SGovindarajulu Varadarajan const struct ethtool_tunable *, const void *); 500421797b1SKan Liang int (*get_per_queue_coalesce)(struct net_device *, u32, 501421797b1SKan Liang struct ethtool_coalesce *); 502f38d138aSKan Liang int (*set_per_queue_coalesce)(struct net_device *, u32, 503f38d138aSKan Liang struct ethtool_coalesce *); 5043f1ac7a7SDavid Decotigny int (*get_link_ksettings)(struct net_device *, 5053f1ac7a7SDavid Decotigny struct ethtool_link_ksettings *); 5063f1ac7a7SDavid Decotigny int (*set_link_ksettings)(struct net_device *, 5073f1ac7a7SDavid Decotigny const struct ethtool_link_ksettings *); 5081a5f3da2SVidya Sagar Ravipati int (*get_fecparam)(struct net_device *, 5091a5f3da2SVidya Sagar Ravipati struct ethtool_fecparam *); 5101a5f3da2SVidya Sagar Ravipati int (*set_fecparam)(struct net_device *, 5111a5f3da2SVidya Sagar Ravipati struct ethtool_fecparam *); 51299943382SFlorian Fainelli void (*get_ethtool_phy_stats)(struct net_device *, 51399943382SFlorian Fainelli struct ethtool_stats *, u64 *); 514c6db31ffSIgor Russkikh int (*get_phy_tunable)(struct net_device *, 515c6db31ffSIgor Russkikh const struct ethtool_tunable *, void *); 516c6db31ffSIgor Russkikh int (*set_phy_tunable)(struct net_device *, 517c6db31ffSIgor Russkikh const struct ethtool_tunable *, const void *); 5181da177e4SLinus Torvalds }; 519eca4205fSPablo Neira Ayuso 5209000edb7SJakub Kicinski int ethtool_check_ops(const struct ethtool_ops *ops); 5219000edb7SJakub Kicinski 522eca4205fSPablo Neira Ayuso struct ethtool_rx_flow_rule { 523eca4205fSPablo Neira Ayuso struct flow_rule *rule; 5245299a11aSGustavo A. R. Silva unsigned long priv[]; 525eca4205fSPablo Neira Ayuso }; 526eca4205fSPablo Neira Ayuso 527eca4205fSPablo Neira Ayuso struct ethtool_rx_flow_spec_input { 528eca4205fSPablo Neira Ayuso const struct ethtool_rx_flow_spec *fs; 529eca4205fSPablo Neira Ayuso u32 rss_ctx; 530eca4205fSPablo Neira Ayuso }; 531eca4205fSPablo Neira Ayuso 532eca4205fSPablo Neira Ayuso struct ethtool_rx_flow_rule * 533eca4205fSPablo Neira Ayuso ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input); 534eca4205fSPablo Neira Ayuso void ethtool_rx_flow_rule_destroy(struct ethtool_rx_flow_rule *rule); 535eca4205fSPablo Neira Ayuso 53670ae1e12SCris Forno bool ethtool_virtdev_validate_cmd(const struct ethtool_link_ksettings *cmd); 53770ae1e12SCris Forno int ethtool_virtdev_set_link_ksettings(struct net_device *dev, 53870ae1e12SCris Forno const struct ethtool_link_ksettings *cmd, 53970ae1e12SCris Forno u32 *dev_speed, u8 *dev_duplex); 54070ae1e12SCris Forno 5414895d780SFlorian Fainelli struct netlink_ext_ack; 5424895d780SFlorian Fainelli struct phy_device; 5434895d780SFlorian Fainelli struct phy_tdr_config; 5444895d780SFlorian Fainelli 5454895d780SFlorian Fainelli /** 5464895d780SFlorian Fainelli * struct ethtool_phy_ops - Optional PHY device options 547bd36ed1cSFlorian Fainelli * @get_sset_count: Get number of strings that @get_strings will write. 548bd36ed1cSFlorian Fainelli * @get_strings: Return a set of strings that describe the requested objects 549bd36ed1cSFlorian Fainelli * @get_stats: Return extended statistics about the PHY device. 5504895d780SFlorian Fainelli * @start_cable_test - Start a cable test 5514895d780SFlorian Fainelli * @start_cable_test_tdr - Start a Time Domain Reflectometry cable test 5524895d780SFlorian Fainelli * 5534895d780SFlorian Fainelli * All operations are optional (i.e. the function pointer may be set to %NULL) 5544895d780SFlorian Fainelli * and callers must take this into account. Callers must hold the RTNL lock. 5554895d780SFlorian Fainelli */ 5564895d780SFlorian Fainelli struct ethtool_phy_ops { 557bd36ed1cSFlorian Fainelli int (*get_sset_count)(struct phy_device *dev); 558bd36ed1cSFlorian Fainelli int (*get_strings)(struct phy_device *dev, u8 *data); 559bd36ed1cSFlorian Fainelli int (*get_stats)(struct phy_device *dev, 560bd36ed1cSFlorian Fainelli struct ethtool_stats *stats, u64 *data); 5614895d780SFlorian Fainelli int (*start_cable_test)(struct phy_device *phydev, 5624895d780SFlorian Fainelli struct netlink_ext_ack *extack); 5634895d780SFlorian Fainelli int (*start_cable_test_tdr)(struct phy_device *phydev, 5644895d780SFlorian Fainelli struct netlink_ext_ack *extack, 5654895d780SFlorian Fainelli const struct phy_tdr_config *config); 5664895d780SFlorian Fainelli }; 5674895d780SFlorian Fainelli 5684895d780SFlorian Fainelli /** 5694895d780SFlorian Fainelli * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton 5704895d780SFlorian Fainelli * @ops: Ethtool PHY operations to set 5714895d780SFlorian Fainelli */ 5724895d780SFlorian Fainelli void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops); 57370ae1e12SCris Forno 574*7888fe53SAlexander Duyck /** 575*7888fe53SAlexander Duyck * ethtool_sprintf - Write formatted string to ethtool string data 576*7888fe53SAlexander Duyck * @data: Pointer to start of string to update 577*7888fe53SAlexander Duyck * @fmt: Format of string to write 578*7888fe53SAlexander Duyck * 579*7888fe53SAlexander Duyck * Write formatted string to data. Update data to point at start of 580*7888fe53SAlexander Duyck * next string. 581*7888fe53SAlexander Duyck */ 582*7888fe53SAlexander Duyck extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...); 5831da177e4SLinus Torvalds #endif /* _LINUX_ETHTOOL_H */ 584