![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 /* 0003 * ethtool.h: Defines for Linux ethtool. 0004 * 0005 * Copyright (C) 1998 David S. Miller (davem@redhat.com) 0006 * Copyright 2001 Jeff Garzik <jgarzik@pobox.com> 0007 * Portions Copyright 2001 Sun Microsystems (thockin@sun.com) 0008 * Portions Copyright 2002 Intel (eli.kupermann@intel.com, 0009 * christopher.leech@intel.com, 0010 * scott.feldman@intel.com) 0011 * Portions Copyright (C) Sun Microsystems 2008 0012 */ 0013 #ifndef _LINUX_ETHTOOL_H 0014 #define _LINUX_ETHTOOL_H 0015 0016 #include <linux/bitmap.h> 0017 #include <linux/compat.h> 0018 #include <linux/netlink.h> 0019 #include <uapi/linux/ethtool.h> 0020 0021 struct compat_ethtool_rx_flow_spec { 0022 u32 flow_type; 0023 union ethtool_flow_union h_u; 0024 struct ethtool_flow_ext h_ext; 0025 union ethtool_flow_union m_u; 0026 struct ethtool_flow_ext m_ext; 0027 compat_u64 ring_cookie; 0028 u32 location; 0029 }; 0030 0031 struct compat_ethtool_rxnfc { 0032 u32 cmd; 0033 u32 flow_type; 0034 compat_u64 data; 0035 struct compat_ethtool_rx_flow_spec fs; 0036 u32 rule_cnt; 0037 u32 rule_locs[]; 0038 }; 0039 0040 #include <linux/rculist.h> 0041 0042 /** 0043 * enum ethtool_phys_id_state - indicator state for physical identification 0044 * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated 0045 * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated 0046 * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE 0047 * is not supported) 0048 * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE 0049 * is not supported) 0050 */ 0051 enum ethtool_phys_id_state { 0052 ETHTOOL_ID_INACTIVE, 0053 ETHTOOL_ID_ACTIVE, 0054 ETHTOOL_ID_ON, 0055 ETHTOOL_ID_OFF 0056 }; 0057 0058 enum { 0059 ETH_RSS_HASH_TOP_BIT, /* Configurable RSS hash function - Toeplitz */ 0060 ETH_RSS_HASH_XOR_BIT, /* Configurable RSS hash function - Xor */ 0061 ETH_RSS_HASH_CRC32_BIT, /* Configurable RSS hash function - Crc32 */ 0062 0063 /* 0064 * Add your fresh new hash function bits above and remember to update 0065 * rss_hash_func_strings[] in ethtool.c 0066 */ 0067 ETH_RSS_HASH_FUNCS_COUNT 0068 }; 0069 0070 /** 0071 * struct kernel_ethtool_ringparam - RX/TX ring configuration 0072 * @rx_buf_len: Current length of buffers on the rx ring. 0073 * @tcp_data_split: Scatter packet headers and data to separate buffers 0074 * @tx_push: The flag of tx push mode 0075 * @cqe_size: Size of TX/RX completion queue event 0076 */ 0077 struct kernel_ethtool_ringparam { 0078 u32 rx_buf_len; 0079 u8 tcp_data_split; 0080 u8 tx_push; 0081 u32 cqe_size; 0082 }; 0083 0084 /** 0085 * enum ethtool_supported_ring_param - indicator caps for setting ring params 0086 * @ETHTOOL_RING_USE_RX_BUF_LEN: capture for setting rx_buf_len 0087 * @ETHTOOL_RING_USE_CQE_SIZE: capture for setting cqe_size 0088 * @ETHTOOL_RING_USE_TX_PUSH: capture for setting tx_push 0089 */ 0090 enum ethtool_supported_ring_param { 0091 ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0), 0092 ETHTOOL_RING_USE_CQE_SIZE = BIT(1), 0093 ETHTOOL_RING_USE_TX_PUSH = BIT(2), 0094 }; 0095 0096 #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit)) 0097 #define __ETH_RSS_HASH(name) __ETH_RSS_HASH_BIT(ETH_RSS_HASH_##name##_BIT) 0098 0099 #define ETH_RSS_HASH_TOP __ETH_RSS_HASH(TOP) 0100 #define ETH_RSS_HASH_XOR __ETH_RSS_HASH(XOR) 0101 #define ETH_RSS_HASH_CRC32 __ETH_RSS_HASH(CRC32) 0102 0103 #define ETH_RSS_HASH_UNKNOWN 0 0104 #define ETH_RSS_HASH_NO_CHANGE 0 0105 0106 struct net_device; 0107 struct netlink_ext_ack; 0108 0109 /* Some generic methods drivers may use in their ethtool_ops */ 0110 u32 ethtool_op_get_link(struct net_device *dev); 0111 int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti); 0112 0113 0114 /* Link extended state and substate. */ 0115 struct ethtool_link_ext_state_info { 0116 enum ethtool_link_ext_state link_ext_state; 0117 union { 0118 enum ethtool_link_ext_substate_autoneg autoneg; 0119 enum ethtool_link_ext_substate_link_training link_training; 0120 enum ethtool_link_ext_substate_link_logical_mismatch link_logical_mismatch; 0121 enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity; 0122 enum ethtool_link_ext_substate_cable_issue cable_issue; 0123 enum ethtool_link_ext_substate_module module; 0124 u32 __link_ext_substate; 0125 }; 0126 }; 0127 0128 /** 0129 * ethtool_rxfh_indir_default - get default value for RX flow hash indirection 0130 * @index: Index in RX flow hash indirection table 0131 * @n_rx_rings: Number of RX rings to use 0132 * 0133 * This function provides the default policy for RX flow hash indirection. 0134 */ 0135 static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings) 0136 { 0137 return index % n_rx_rings; 0138 } 0139 0140 /* declare a link mode bitmap */ 0141 #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \ 0142 DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS) 0143 0144 /* drivers must ignore base.cmd and base.link_mode_masks_nwords 0145 * fields, but they are allowed to overwrite them (will be ignored). 0146 */ 0147 struct ethtool_link_ksettings { 0148 struct ethtool_link_settings base; 0149 struct { 0150 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); 0151 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); 0152 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); 0153 } link_modes; 0154 u32 lanes; 0155 }; 0156 0157 /** 0158 * ethtool_link_ksettings_zero_link_mode - clear link_ksettings link mode mask 0159 * @ptr : pointer to struct ethtool_link_ksettings 0160 * @name : one of supported/advertising/lp_advertising 0161 */ 0162 #define ethtool_link_ksettings_zero_link_mode(ptr, name) \ 0163 bitmap_zero((ptr)->link_modes.name, __ETHTOOL_LINK_MODE_MASK_NBITS) 0164 0165 /** 0166 * ethtool_link_ksettings_add_link_mode - set bit in link_ksettings 0167 * link mode mask 0168 * @ptr : pointer to struct ethtool_link_ksettings 0169 * @name : one of supported/advertising/lp_advertising 0170 * @mode : one of the ETHTOOL_LINK_MODE_*_BIT 0171 * (not atomic, no bound checking) 0172 */ 0173 #define ethtool_link_ksettings_add_link_mode(ptr, name, mode) \ 0174 __set_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) 0175 0176 /** 0177 * ethtool_link_ksettings_del_link_mode - clear bit in link_ksettings 0178 * link mode mask 0179 * @ptr : pointer to struct ethtool_link_ksettings 0180 * @name : one of supported/advertising/lp_advertising 0181 * @mode : one of the ETHTOOL_LINK_MODE_*_BIT 0182 * (not atomic, no bound checking) 0183 */ 0184 #define ethtool_link_ksettings_del_link_mode(ptr, name, mode) \ 0185 __clear_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) 0186 0187 /** 0188 * ethtool_link_ksettings_test_link_mode - test bit in ksettings link mode mask 0189 * @ptr : pointer to struct ethtool_link_ksettings 0190 * @name : one of supported/advertising/lp_advertising 0191 * @mode : one of the ETHTOOL_LINK_MODE_*_BIT 0192 * (not atomic, no bound checking) 0193 * 0194 * Returns true/false. 0195 */ 0196 #define ethtool_link_ksettings_test_link_mode(ptr, name, mode) \ 0197 test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) 0198 0199 extern int 0200 __ethtool_get_link_ksettings(struct net_device *dev, 0201 struct ethtool_link_ksettings *link_ksettings); 0202 0203 struct kernel_ethtool_coalesce { 0204 u8 use_cqe_mode_tx; 0205 u8 use_cqe_mode_rx; 0206 }; 0207 0208 /** 0209 * ethtool_intersect_link_masks - Given two link masks, AND them together 0210 * @dst: first mask and where result is stored 0211 * @src: second mask to intersect with 0212 * 0213 * Given two link mode masks, AND them together and save the result in dst. 0214 */ 0215 void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst, 0216 struct ethtool_link_ksettings *src); 0217 0218 void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst, 0219 u32 legacy_u32); 0220 0221 /* return false if src had higher bits set. lower bits always updated. */ 0222 bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, 0223 const unsigned long *src); 0224 0225 #define ETHTOOL_COALESCE_RX_USECS BIT(0) 0226 #define ETHTOOL_COALESCE_RX_MAX_FRAMES BIT(1) 0227 #define ETHTOOL_COALESCE_RX_USECS_IRQ BIT(2) 0228 #define ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ BIT(3) 0229 #define ETHTOOL_COALESCE_TX_USECS BIT(4) 0230 #define ETHTOOL_COALESCE_TX_MAX_FRAMES BIT(5) 0231 #define ETHTOOL_COALESCE_TX_USECS_IRQ BIT(6) 0232 #define ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ BIT(7) 0233 #define ETHTOOL_COALESCE_STATS_BLOCK_USECS BIT(8) 0234 #define ETHTOOL_COALESCE_USE_ADAPTIVE_RX BIT(9) 0235 #define ETHTOOL_COALESCE_USE_ADAPTIVE_TX BIT(10) 0236 #define ETHTOOL_COALESCE_PKT_RATE_LOW BIT(11) 0237 #define ETHTOOL_COALESCE_RX_USECS_LOW BIT(12) 0238 #define ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW BIT(13) 0239 #define ETHTOOL_COALESCE_TX_USECS_LOW BIT(14) 0240 #define ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW BIT(15) 0241 #define ETHTOOL_COALESCE_PKT_RATE_HIGH BIT(16) 0242 #define ETHTOOL_COALESCE_RX_USECS_HIGH BIT(17) 0243 #define ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH BIT(18) 0244 #define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19) 0245 #define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH BIT(20) 0246 #define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21) 0247 #define ETHTOOL_COALESCE_USE_CQE_RX BIT(22) 0248 #define ETHTOOL_COALESCE_USE_CQE_TX BIT(23) 0249 #define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(23, 0) 0250 0251 #define ETHTOOL_COALESCE_USECS \ 0252 (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS) 0253 #define ETHTOOL_COALESCE_MAX_FRAMES \ 0254 (ETHTOOL_COALESCE_RX_MAX_FRAMES | ETHTOOL_COALESCE_TX_MAX_FRAMES) 0255 #define ETHTOOL_COALESCE_USECS_IRQ \ 0256 (ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ) 0257 #define ETHTOOL_COALESCE_MAX_FRAMES_IRQ \ 0258 (ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | \ 0259 ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ) 0260 #define ETHTOOL_COALESCE_USE_ADAPTIVE \ 0261 (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_ADAPTIVE_TX) 0262 #define ETHTOOL_COALESCE_USECS_LOW_HIGH \ 0263 (ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_TX_USECS_LOW | \ 0264 ETHTOOL_COALESCE_RX_USECS_HIGH | ETHTOOL_COALESCE_TX_USECS_HIGH) 0265 #define ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH \ 0266 (ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW | \ 0267 ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW | \ 0268 ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH | \ 0269 ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH) 0270 #define ETHTOOL_COALESCE_PKT_RATE_RX_USECS \ 0271 (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | \ 0272 ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_RX_USECS_HIGH | \ 0273 ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \ 0274 ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL) 0275 #define ETHTOOL_COALESCE_USE_CQE \ 0276 (ETHTOOL_COALESCE_USE_CQE_RX | ETHTOOL_COALESCE_USE_CQE_TX) 0277 0278 #define ETHTOOL_STAT_NOT_SET (~0ULL) 0279 0280 static inline void ethtool_stats_init(u64 *stats, unsigned int n) 0281 { 0282 while (n--) 0283 stats[n] = ETHTOOL_STAT_NOT_SET; 0284 } 0285 0286 /* Basic IEEE 802.3 MAC statistics (30.3.1.1.*), not otherwise exposed 0287 * via a more targeted API. 0288 */ 0289 struct ethtool_eth_mac_stats { 0290 u64 FramesTransmittedOK; 0291 u64 SingleCollisionFrames; 0292 u64 MultipleCollisionFrames; 0293 u64 FramesReceivedOK; 0294 u64 FrameCheckSequenceErrors; 0295 u64 AlignmentErrors; 0296 u64 OctetsTransmittedOK; 0297 u64 FramesWithDeferredXmissions; 0298 u64 LateCollisions; 0299 u64 FramesAbortedDueToXSColls; 0300 u64 FramesLostDueToIntMACXmitError; 0301 u64 CarrierSenseErrors; 0302 u64 OctetsReceivedOK; 0303 u64 FramesLostDueToIntMACRcvError; 0304 u64 MulticastFramesXmittedOK; 0305 u64 BroadcastFramesXmittedOK; 0306 u64 FramesWithExcessiveDeferral; 0307 u64 MulticastFramesReceivedOK; 0308 u64 BroadcastFramesReceivedOK; 0309 u64 InRangeLengthErrors; 0310 u64 OutOfRangeLengthField; 0311 u64 FrameTooLongErrors; 0312 }; 0313 0314 /* Basic IEEE 802.3 PHY statistics (30.3.2.1.*), not otherwise exposed 0315 * via a more targeted API. 0316 */ 0317 struct ethtool_eth_phy_stats { 0318 u64 SymbolErrorDuringCarrier; 0319 }; 0320 0321 /* Basic IEEE 802.3 MAC Ctrl statistics (30.3.3.*), not otherwise exposed 0322 * via a more targeted API. 0323 */ 0324 struct ethtool_eth_ctrl_stats { 0325 u64 MACControlFramesTransmitted; 0326 u64 MACControlFramesReceived; 0327 u64 UnsupportedOpcodesReceived; 0328 }; 0329 0330 /** 0331 * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames 0332 * @tx_pause_frames: transmitted pause frame count. Reported to user space 0333 * as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES. 0334 * 0335 * Equivalent to `30.3.4.2 aPAUSEMACCtrlFramesTransmitted` 0336 * from the standard. 0337 * 0338 * @rx_pause_frames: received pause frame count. Reported to user space 0339 * as %ETHTOOL_A_PAUSE_STAT_RX_FRAMES. Equivalent to: 0340 * 0341 * Equivalent to `30.3.4.3 aPAUSEMACCtrlFramesReceived` 0342 * from the standard. 0343 */ 0344 struct ethtool_pause_stats { 0345 u64 tx_pause_frames; 0346 u64 rx_pause_frames; 0347 }; 0348 0349 #define ETHTOOL_MAX_LANES 8 0350 0351 /** 0352 * struct ethtool_fec_stats - statistics for IEEE 802.3 FEC 0353 * @corrected_blocks: number of received blocks corrected by FEC 0354 * Reported to user space as %ETHTOOL_A_FEC_STAT_CORRECTED. 0355 * 0356 * Equivalent to `30.5.1.1.17 aFECCorrectedBlocks` from the standard. 0357 * 0358 * @uncorrectable_blocks: number of received blocks FEC was not able to correct 0359 * Reported to user space as %ETHTOOL_A_FEC_STAT_UNCORR. 0360 * 0361 * Equivalent to `30.5.1.1.18 aFECUncorrectableBlocks` from the standard. 0362 * 0363 * @corrected_bits: number of bits corrected by FEC 0364 * Similar to @corrected_blocks but counts individual bit changes, 0365 * not entire FEC data blocks. This is a non-standard statistic. 0366 * Reported to user space as %ETHTOOL_A_FEC_STAT_CORR_BITS. 0367 * 0368 * @lane: per-lane/PCS-instance counts as defined by the standard 0369 * @total: error counts for the entire port, for drivers incapable of reporting 0370 * per-lane stats 0371 * 0372 * Drivers should fill in either only total or per-lane statistics, core 0373 * will take care of adding lane values up to produce the total. 0374 */ 0375 struct ethtool_fec_stats { 0376 struct ethtool_fec_stat { 0377 u64 total; 0378 u64 lanes[ETHTOOL_MAX_LANES]; 0379 } corrected_blocks, uncorrectable_blocks, corrected_bits; 0380 }; 0381 0382 /** 0383 * struct ethtool_rmon_hist_range - byte range for histogram statistics 0384 * @low: low bound of the bucket (inclusive) 0385 * @high: high bound of the bucket (inclusive) 0386 */ 0387 struct ethtool_rmon_hist_range { 0388 u16 low; 0389 u16 high; 0390 }; 0391 0392 #define ETHTOOL_RMON_HIST_MAX 10 0393 0394 /** 0395 * struct ethtool_rmon_stats - selected RMON (RFC 2819) statistics 0396 * @undersize_pkts: Equivalent to `etherStatsUndersizePkts` from the RFC. 0397 * @oversize_pkts: Equivalent to `etherStatsOversizePkts` from the RFC. 0398 * @fragments: Equivalent to `etherStatsFragments` from the RFC. 0399 * @jabbers: Equivalent to `etherStatsJabbers` from the RFC. 0400 * @hist: Packet counter for packet length buckets (e.g. 0401 * `etherStatsPkts128to255Octets` from the RFC). 0402 * @hist_tx: Tx counters in similar form to @hist, not defined in the RFC. 0403 * 0404 * Selection of RMON (RFC 2819) statistics which are not exposed via different 0405 * APIs, primarily the packet-length-based counters. 0406 * Unfortunately different designs choose different buckets beyond 0407 * the 1024B mark (jumbo frame teritory), so the definition of the bucket 0408 * ranges is left to the driver. 0409 */ 0410 struct ethtool_rmon_stats { 0411 u64 undersize_pkts; 0412 u64 oversize_pkts; 0413 u64 fragments; 0414 u64 jabbers; 0415 0416 u64 hist[ETHTOOL_RMON_HIST_MAX]; 0417 u64 hist_tx[ETHTOOL_RMON_HIST_MAX]; 0418 }; 0419 0420 #define ETH_MODULE_EEPROM_PAGE_LEN 128 0421 #define ETH_MODULE_MAX_I2C_ADDRESS 0x7f 0422 0423 /** 0424 * struct ethtool_module_eeprom - EEPROM dump from specified page 0425 * @offset: Offset within the specified EEPROM page to begin read, in bytes. 0426 * @length: Number of bytes to read. 0427 * @page: Page number to read from. 0428 * @bank: Page bank number to read from, if applicable by EEPROM spec. 0429 * @i2c_address: I2C address of a page. Value less than 0x7f expected. Most 0430 * EEPROMs use 0x50 or 0x51. 0431 * @data: Pointer to buffer with EEPROM data of @length size. 0432 * 0433 * This can be used to manage pages during EEPROM dump in ethtool and pass 0434 * required information to the driver. 0435 */ 0436 struct ethtool_module_eeprom { 0437 u32 offset; 0438 u32 length; 0439 u8 page; 0440 u8 bank; 0441 u8 i2c_address; 0442 u8 *data; 0443 }; 0444 0445 /** 0446 * struct ethtool_module_power_mode_params - module power mode parameters 0447 * @policy: The power mode policy enforced by the host for the plug-in module. 0448 * @mode: The operational power mode of the plug-in module. Should be filled by 0449 * device drivers on get operations. 0450 */ 0451 struct ethtool_module_power_mode_params { 0452 enum ethtool_module_power_mode_policy policy; 0453 enum ethtool_module_power_mode mode; 0454 }; 0455 0456 /** 0457 * struct ethtool_ops - optional netdev operations 0458 * @cap_link_lanes_supported: indicates if the driver supports lanes 0459 * parameter. 0460 * @supported_coalesce_params: supported types of interrupt coalescing. 0461 * @supported_ring_params: supported ring params. 0462 * @get_drvinfo: Report driver/device information. Should only set the 0463 * @driver, @version, @fw_version and @bus_info fields. If not 0464 * implemented, the @driver and @bus_info fields will be filled in 0465 * according to the netdev's parent device. 0466 * @get_regs_len: Get buffer length required for @get_regs 0467 * @get_regs: Get device registers 0468 * @get_wol: Report whether Wake-on-Lan is enabled 0469 * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code 0470 * or zero. 0471 * @get_msglevel: Report driver message level. This should be the value 0472 * of the @msg_enable field used by netif logging functions. 0473 * @set_msglevel: Set driver message level 0474 * @nway_reset: Restart autonegotiation. Returns a negative error code 0475 * or zero. 0476 * @get_link: Report whether physical link is up. Will only be called if 0477 * the netdev is up. Should usually be set to ethtool_op_get_link(), 0478 * which uses netif_carrier_ok(). 0479 * @get_link_ext_state: Report link extended state. Should set link_ext_state and 0480 * link_ext_substate (link_ext_substate of 0 means link_ext_substate is unknown, 0481 * do not attach ext_substate attribute to netlink message). If link_ext_state 0482 * and link_ext_substate are unknown, return -ENODATA. If not implemented, 0483 * link_ext_state and link_ext_substate will not be sent to userspace. 0484 * @get_eeprom_len: Read range of EEPROM addresses for validation of 0485 * @get_eeprom and @set_eeprom requests. 0486 * Returns 0 if device does not support EEPROM access. 0487 * @get_eeprom: Read data from the device EEPROM. 0488 * Should fill in the magic field. Don't need to check len for zero 0489 * or wraparound. Fill in the data argument with the eeprom values 0490 * from offset to offset + len. Update len to the amount read. 0491 * Returns an error or zero. 0492 * @set_eeprom: Write data to the device EEPROM. 0493 * Should validate the magic field. Don't need to check len for zero 0494 * or wraparound. Update len to the amount written. Returns an error 0495 * or zero. 0496 * @get_coalesce: Get interrupt coalescing parameters. Returns a negative 0497 * error code or zero. 0498 * @set_coalesce: Set interrupt coalescing parameters. Supported coalescing 0499 * types should be set in @supported_coalesce_params. 0500 * Returns a negative error code or zero. 0501 * @get_ringparam: Report ring sizes 0502 * @set_ringparam: Set ring sizes. Returns a negative error code or zero. 0503 * @get_pause_stats: Report pause frame statistics. Drivers must not zero 0504 * statistics which they don't report. The stats structure is initialized 0505 * to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics. 0506 * @get_pauseparam: Report pause parameters 0507 * @set_pauseparam: Set pause parameters. Returns a negative error code 0508 * or zero. 0509 * @self_test: Run specified self-tests 0510 * @get_strings: Return a set of strings that describe the requested objects 0511 * @set_phys_id: Identify the physical devices, e.g. by flashing an LED 0512 * attached to it. The implementation may update the indicator 0513 * asynchronously or synchronously, but in either case it must return 0514 * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE, 0515 * and must either activate asynchronous updates and return zero, return 0516 * a negative error or return a positive frequency for synchronous 0517 * indication (e.g. 1 for one on/off cycle per second). If it returns 0518 * a frequency then it will be called again at intervals with the 0519 * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of 0520 * the indicator accordingly. Finally, it is called with the argument 0521 * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a 0522 * negative error code or zero. 0523 * @get_ethtool_stats: Return extended statistics about the device. 0524 * This is only useful if the device maintains statistics not 0525 * included in &struct rtnl_link_stats64. 0526 * @begin: Function to be called before any other operation. Returns a 0527 * negative error code or zero. 0528 * @complete: Function to be called after any other operation except 0529 * @begin. Will be called even if the other operation failed. 0530 * @get_priv_flags: Report driver-specific feature flags. 0531 * @set_priv_flags: Set driver-specific feature flags. Returns a negative 0532 * error code or zero. 0533 * @get_sset_count: Get number of strings that @get_strings will write. 0534 * @get_rxnfc: Get RX flow classification rules. Returns a negative 0535 * error code or zero. 0536 * @set_rxnfc: Set RX flow classification rules. Returns a negative 0537 * error code or zero. 0538 * @flash_device: Write a firmware image to device's flash memory. 0539 * Returns a negative error code or zero. 0540 * @reset: Reset (part of) the device, as specified by a bitmask of 0541 * flags from &enum ethtool_reset_flags. Returns a negative 0542 * error code or zero. 0543 * @get_rxfh_key_size: Get the size of the RX flow hash key. 0544 * Returns zero if not supported for this specific device. 0545 * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table. 0546 * Returns zero if not supported for this specific device. 0547 * @get_rxfh: Get the contents of the RX flow hash indirection table, hash key 0548 * and/or hash function. 0549 * Returns a negative error code or zero. 0550 * @set_rxfh: Set the contents of the RX flow hash indirection table, hash 0551 * key, and/or hash function. Arguments which are set to %NULL or zero 0552 * will remain unchanged. 0553 * Returns a negative error code or zero. An error code must be returned 0554 * if at least one unsupported change was requested. 0555 * @get_rxfh_context: Get the contents of the RX flow hash indirection table, 0556 * hash key, and/or hash function assiciated to the given rss context. 0557 * Returns a negative error code or zero. 0558 * @set_rxfh_context: Create, remove and configure RSS contexts. Allows setting 0559 * the contents of the RX flow hash indirection table, hash key, and/or 0560 * hash function associated to the given context. Arguments which are set 0561 * to %NULL or zero will remain unchanged. 0562 * Returns a negative error code or zero. An error code must be returned 0563 * if at least one unsupported change was requested. 0564 * @get_channels: Get number of channels. 0565 * @set_channels: Set number of channels. Returns a negative error code or 0566 * zero. 0567 * @get_dump_flag: Get dump flag indicating current dump length, version, 0568 * and flag of the device. 0569 * @get_dump_data: Get dump data. 0570 * @set_dump: Set dump specific flags to the device. 0571 * @get_ts_info: Get the time stamping and PTP hardware clock capabilities. 0572 * Drivers supporting transmit time stamps in software should set this to 0573 * ethtool_op_get_ts_info(). 0574 * @get_module_info: Get the size and type of the eeprom contained within 0575 * a plug-in module. 0576 * @get_module_eeprom: Get the eeprom information from the plug-in module 0577 * @get_eee: Get Energy-Efficient (EEE) supported and status. 0578 * @set_eee: Set EEE status (enable/disable) as well as LPI timers. 0579 * @get_tunable: Read the value of a driver / device tunable. 0580 * @set_tunable: Set the value of a driver / device tunable. 0581 * @get_per_queue_coalesce: Get interrupt coalescing parameters per queue. 0582 * It must check that the given queue number is valid. If neither a RX nor 0583 * a TX queue has this number, return -EINVAL. If only a RX queue or a TX 0584 * queue has this number, set the inapplicable fields to ~0 and return 0. 0585 * Returns a negative error code or zero. 0586 * @set_per_queue_coalesce: Set interrupt coalescing parameters per queue. 0587 * It must check that the given queue number is valid. If neither a RX nor 0588 * a TX queue has this number, return -EINVAL. If only a RX queue or a TX 0589 * queue has this number, ignore the inapplicable fields. Supported 0590 * coalescing types should be set in @supported_coalesce_params. 0591 * Returns a negative error code or zero. 0592 * @get_link_ksettings: Get various device settings including Ethernet link 0593 * settings. The %cmd and %link_mode_masks_nwords fields should be 0594 * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), 0595 * any change to them will be overwritten by kernel. Returns a negative 0596 * error code or zero. 0597 * @set_link_ksettings: Set various device settings including Ethernet link 0598 * settings. The %cmd and %link_mode_masks_nwords fields should be 0599 * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), 0600 * any change to them will be overwritten by kernel. Returns a negative 0601 * error code or zero. 0602 * @get_fec_stats: Report FEC statistics. 0603 * Core will sum up per-lane stats to get the total. 0604 * Drivers must not zero statistics which they don't report. The stats 0605 * structure is initialized to ETHTOOL_STAT_NOT_SET indicating driver does 0606 * not report statistics. 0607 * @get_fecparam: Get the network device Forward Error Correction parameters. 0608 * @set_fecparam: Set the network device Forward Error Correction parameters. 0609 * @get_ethtool_phy_stats: Return extended statistics about the PHY device. 0610 * This is only useful if the device maintains PHY statistics and 0611 * cannot use the standard PHY library helpers. 0612 * @get_phy_tunable: Read the value of a PHY tunable. 0613 * @set_phy_tunable: Set the value of a PHY tunable. 0614 * @get_module_eeprom_by_page: Get a region of plug-in module EEPROM data from 0615 * specified page. Returns a negative error code or the amount of bytes 0616 * read. 0617 * @get_eth_phy_stats: Query some of the IEEE 802.3 PHY statistics. 0618 * @get_eth_mac_stats: Query some of the IEEE 802.3 MAC statistics. 0619 * @get_eth_ctrl_stats: Query some of the IEEE 802.3 MAC Ctrl statistics. 0620 * @get_rmon_stats: Query some of the RMON (RFC 2819) statistics. 0621 * Set %ranges to a pointer to zero-terminated array of byte ranges. 0622 * @get_module_power_mode: Get the power mode policy for the plug-in module 0623 * used by the network device and its operational power mode, if 0624 * plugged-in. 0625 * @set_module_power_mode: Set the power mode policy for the plug-in module 0626 * used by the network device. 0627 * 0628 * All operations are optional (i.e. the function pointer may be set 0629 * to %NULL) and callers must take this into account. Callers must 0630 * hold the RTNL lock. 0631 * 0632 * See the structures used by these operations for further documentation. 0633 * Note that for all operations using a structure ending with a zero- 0634 * length array, the array is allocated separately in the kernel and 0635 * is passed to the driver as an additional parameter. 0636 * 0637 * See &struct net_device and &struct net_device_ops for documentation 0638 * of the generic netdev features interface. 0639 */ 0640 struct ethtool_ops { 0641 u32 cap_link_lanes_supported:1; 0642 u32 supported_coalesce_params; 0643 u32 supported_ring_params; 0644 void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *); 0645 int (*get_regs_len)(struct net_device *); 0646 void (*get_regs)(struct net_device *, struct ethtool_regs *, void *); 0647 void (*get_wol)(struct net_device *, struct ethtool_wolinfo *); 0648 int (*set_wol)(struct net_device *, struct ethtool_wolinfo *); 0649 u32 (*get_msglevel)(struct net_device *); 0650 void (*set_msglevel)(struct net_device *, u32); 0651 int (*nway_reset)(struct net_device *); 0652 u32 (*get_link)(struct net_device *); 0653 int (*get_link_ext_state)(struct net_device *, 0654 struct ethtool_link_ext_state_info *); 0655 int (*get_eeprom_len)(struct net_device *); 0656 int (*get_eeprom)(struct net_device *, 0657 struct ethtool_eeprom *, u8 *); 0658 int (*set_eeprom)(struct net_device *, 0659 struct ethtool_eeprom *, u8 *); 0660 int (*get_coalesce)(struct net_device *, 0661 struct ethtool_coalesce *, 0662 struct kernel_ethtool_coalesce *, 0663 struct netlink_ext_ack *); 0664 int (*set_coalesce)(struct net_device *, 0665 struct ethtool_coalesce *, 0666 struct kernel_ethtool_coalesce *, 0667 struct netlink_ext_ack *); 0668 void (*get_ringparam)(struct net_device *, 0669 struct ethtool_ringparam *, 0670 struct kernel_ethtool_ringparam *, 0671 struct netlink_ext_ack *); 0672 int (*set_ringparam)(struct net_device *, 0673 struct ethtool_ringparam *, 0674 struct kernel_ethtool_ringparam *, 0675 struct netlink_ext_ack *); 0676 void (*get_pause_stats)(struct net_device *dev, 0677 struct ethtool_pause_stats *pause_stats); 0678 void (*get_pauseparam)(struct net_device *, 0679 struct ethtool_pauseparam*); 0680 int (*set_pauseparam)(struct net_device *, 0681 struct ethtool_pauseparam*); 0682 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); 0683 void (*get_strings)(struct net_device *, u32 stringset, u8 *); 0684 int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state); 0685 void (*get_ethtool_stats)(struct net_device *, 0686 struct ethtool_stats *, u64 *); 0687 int (*begin)(struct net_device *); 0688 void (*complete)(struct net_device *); 0689 u32 (*get_priv_flags)(struct net_device *); 0690 int (*set_priv_flags)(struct net_device *, u32); 0691 int (*get_sset_count)(struct net_device *, int); 0692 int (*get_rxnfc)(struct net_device *, 0693 struct ethtool_rxnfc *, u32 *rule_locs); 0694 int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *); 0695 int (*flash_device)(struct net_device *, struct ethtool_flash *); 0696 int (*reset)(struct net_device *, u32 *); 0697 u32 (*get_rxfh_key_size)(struct net_device *); 0698 u32 (*get_rxfh_indir_size)(struct net_device *); 0699 int (*get_rxfh)(struct net_device *, u32 *indir, u8 *key, 0700 u8 *hfunc); 0701 int (*set_rxfh)(struct net_device *, const u32 *indir, 0702 const u8 *key, const u8 hfunc); 0703 int (*get_rxfh_context)(struct net_device *, u32 *indir, u8 *key, 0704 u8 *hfunc, u32 rss_context); 0705 int (*set_rxfh_context)(struct net_device *, const u32 *indir, 0706 const u8 *key, const u8 hfunc, 0707 u32 *rss_context, bool delete); 0708 void (*get_channels)(struct net_device *, struct ethtool_channels *); 0709 int (*set_channels)(struct net_device *, struct ethtool_channels *); 0710 int (*get_dump_flag)(struct net_device *, struct ethtool_dump *); 0711 int (*get_dump_data)(struct net_device *, 0712 struct ethtool_dump *, void *); 0713 int (*set_dump)(struct net_device *, struct ethtool_dump *); 0714 int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *); 0715 int (*get_module_info)(struct net_device *, 0716 struct ethtool_modinfo *); 0717 int (*get_module_eeprom)(struct net_device *, 0718 struct ethtool_eeprom *, u8 *); 0719 int (*get_eee)(struct net_device *, struct ethtool_eee *); 0720 int (*set_eee)(struct net_device *, struct ethtool_eee *); 0721 int (*get_tunable)(struct net_device *, 0722 const struct ethtool_tunable *, void *); 0723 int (*set_tunable)(struct net_device *, 0724 const struct ethtool_tunable *, const void *); 0725 int (*get_per_queue_coalesce)(struct net_device *, u32, 0726 struct ethtool_coalesce *); 0727 int (*set_per_queue_coalesce)(struct net_device *, u32, 0728 struct ethtool_coalesce *); 0729 int (*get_link_ksettings)(struct net_device *, 0730 struct ethtool_link_ksettings *); 0731 int (*set_link_ksettings)(struct net_device *, 0732 const struct ethtool_link_ksettings *); 0733 void (*get_fec_stats)(struct net_device *dev, 0734 struct ethtool_fec_stats *fec_stats); 0735 int (*get_fecparam)(struct net_device *, 0736 struct ethtool_fecparam *); 0737 int (*set_fecparam)(struct net_device *, 0738 struct ethtool_fecparam *); 0739 void (*get_ethtool_phy_stats)(struct net_device *, 0740 struct ethtool_stats *, u64 *); 0741 int (*get_phy_tunable)(struct net_device *, 0742 const struct ethtool_tunable *, void *); 0743 int (*set_phy_tunable)(struct net_device *, 0744 const struct ethtool_tunable *, const void *); 0745 int (*get_module_eeprom_by_page)(struct net_device *dev, 0746 const struct ethtool_module_eeprom *page, 0747 struct netlink_ext_ack *extack); 0748 void (*get_eth_phy_stats)(struct net_device *dev, 0749 struct ethtool_eth_phy_stats *phy_stats); 0750 void (*get_eth_mac_stats)(struct net_device *dev, 0751 struct ethtool_eth_mac_stats *mac_stats); 0752 void (*get_eth_ctrl_stats)(struct net_device *dev, 0753 struct ethtool_eth_ctrl_stats *ctrl_stats); 0754 void (*get_rmon_stats)(struct net_device *dev, 0755 struct ethtool_rmon_stats *rmon_stats, 0756 const struct ethtool_rmon_hist_range **ranges); 0757 int (*get_module_power_mode)(struct net_device *dev, 0758 struct ethtool_module_power_mode_params *params, 0759 struct netlink_ext_ack *extack); 0760 int (*set_module_power_mode)(struct net_device *dev, 0761 const struct ethtool_module_power_mode_params *params, 0762 struct netlink_ext_ack *extack); 0763 }; 0764 0765 int ethtool_check_ops(const struct ethtool_ops *ops); 0766 0767 struct ethtool_rx_flow_rule { 0768 struct flow_rule *rule; 0769 unsigned long priv[]; 0770 }; 0771 0772 struct ethtool_rx_flow_spec_input { 0773 const struct ethtool_rx_flow_spec *fs; 0774 u32 rss_ctx; 0775 }; 0776 0777 struct ethtool_rx_flow_rule * 0778 ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input); 0779 void ethtool_rx_flow_rule_destroy(struct ethtool_rx_flow_rule *rule); 0780 0781 bool ethtool_virtdev_validate_cmd(const struct ethtool_link_ksettings *cmd); 0782 int ethtool_virtdev_set_link_ksettings(struct net_device *dev, 0783 const struct ethtool_link_ksettings *cmd, 0784 u32 *dev_speed, u8 *dev_duplex); 0785 0786 struct phy_device; 0787 struct phy_tdr_config; 0788 0789 /** 0790 * struct ethtool_phy_ops - Optional PHY device options 0791 * @get_sset_count: Get number of strings that @get_strings will write. 0792 * @get_strings: Return a set of strings that describe the requested objects 0793 * @get_stats: Return extended statistics about the PHY device. 0794 * @start_cable_test: Start a cable test 0795 * @start_cable_test_tdr: Start a Time Domain Reflectometry cable test 0796 * 0797 * All operations are optional (i.e. the function pointer may be set to %NULL) 0798 * and callers must take this into account. Callers must hold the RTNL lock. 0799 */ 0800 struct ethtool_phy_ops { 0801 int (*get_sset_count)(struct phy_device *dev); 0802 int (*get_strings)(struct phy_device *dev, u8 *data); 0803 int (*get_stats)(struct phy_device *dev, 0804 struct ethtool_stats *stats, u64 *data); 0805 int (*start_cable_test)(struct phy_device *phydev, 0806 struct netlink_ext_ack *extack); 0807 int (*start_cable_test_tdr)(struct phy_device *phydev, 0808 struct netlink_ext_ack *extack, 0809 const struct phy_tdr_config *config); 0810 }; 0811 0812 /** 0813 * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton 0814 * @ops: Ethtool PHY operations to set 0815 */ 0816 void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops); 0817 0818 /** 0819 * ethtool_params_from_link_mode - Derive link parameters from a given link mode 0820 * @link_ksettings: Link parameters to be derived from the link mode 0821 * @link_mode: Link mode 0822 */ 0823 void 0824 ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings, 0825 enum ethtool_link_mode_bit_indices link_mode); 0826 0827 /** 0828 * ethtool_get_phc_vclocks - Derive phc vclocks information, and caller 0829 * is responsible to free memory of vclock_index 0830 * @dev: pointer to net_device structure 0831 * @vclock_index: pointer to pointer of vclock index 0832 * 0833 * Return number of phc vclocks 0834 */ 0835 int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index); 0836 0837 /** 0838 * ethtool_sprintf - Write formatted string to ethtool string data 0839 * @data: Pointer to start of string to update 0840 * @fmt: Format of string to write 0841 * 0842 * Write formatted string to data. Update data to point at start of 0843 * next string. 0844 */ 0845 extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...); 0846 #endif /* _LINUX_ETHTOOL_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |