1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * ethtool.h: Defines for Linux ethtool. 4 * 5 * Copyright (C) 1998 David S. Miller (davem@redhat.com) 6 * Copyright 2001 Jeff Garzik <jgarzik@pobox.com> 7 * Portions Copyright 2001 Sun Microsystems (thockin@sun.com) 8 * Portions Copyright 2002 Intel (eli.kupermann@intel.com, 9 * christopher.leech@intel.com, 10 * scott.feldman@intel.com) 11 * Portions Copyright (C) Sun Microsystems 2008 12 */ 13 #ifndef _LINUX_ETHTOOL_H 14 #define _LINUX_ETHTOOL_H 15 16 #include <linux/bitmap.h> 17 #include <linux/compat.h> 18 #include <linux/if_ether.h> 19 #include <linux/netlink.h> 20 #include <uapi/linux/ethtool.h> 21 #include <uapi/linux/net_tstamp.h> 22 23 struct compat_ethtool_rx_flow_spec { 24 u32 flow_type; 25 union ethtool_flow_union h_u; 26 struct ethtool_flow_ext h_ext; 27 union ethtool_flow_union m_u; 28 struct ethtool_flow_ext m_ext; 29 compat_u64 ring_cookie; 30 u32 location; 31 }; 32 33 struct compat_ethtool_rxnfc { 34 u32 cmd; 35 u32 flow_type; 36 compat_u64 data; 37 struct compat_ethtool_rx_flow_spec fs; 38 u32 rule_cnt; 39 u32 rule_locs[]; 40 }; 41 42 #include <linux/rculist.h> 43 44 /** 45 * enum ethtool_phys_id_state - indicator state for physical identification 46 * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated 47 * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated 48 * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE 49 * is not supported) 50 * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE 51 * is not supported) 52 */ 53 enum ethtool_phys_id_state { 54 ETHTOOL_ID_INACTIVE, 55 ETHTOOL_ID_ACTIVE, 56 ETHTOOL_ID_ON, 57 ETHTOOL_ID_OFF 58 }; 59 60 enum { 61 ETH_RSS_HASH_TOP_BIT, /* Configurable RSS hash function - Toeplitz */ 62 ETH_RSS_HASH_XOR_BIT, /* Configurable RSS hash function - Xor */ 63 ETH_RSS_HASH_CRC32_BIT, /* Configurable RSS hash function - Crc32 */ 64 65 /* 66 * Add your fresh new hash function bits above and remember to update 67 * rss_hash_func_strings[] in ethtool.c 68 */ 69 ETH_RSS_HASH_FUNCS_COUNT 70 }; 71 72 /** 73 * struct kernel_ethtool_ringparam - RX/TX ring configuration 74 * @rx_buf_len: Current length of buffers on the rx ring. 75 * @tcp_data_split: Scatter packet headers and data to separate buffers 76 * @tx_push: The flag of tx push mode 77 * @rx_push: The flag of rx push mode 78 * @cqe_size: Size of TX/RX completion queue event 79 * @tx_push_buf_len: Size of TX push buffer 80 * @tx_push_buf_max_len: Maximum allowed size of TX push buffer 81 */ 82 struct kernel_ethtool_ringparam { 83 u32 rx_buf_len; 84 u8 tcp_data_split; 85 u8 tx_push; 86 u8 rx_push; 87 u32 cqe_size; 88 u32 tx_push_buf_len; 89 u32 tx_push_buf_max_len; 90 }; 91 92 /** 93 * enum ethtool_supported_ring_param - indicator caps for setting ring params 94 * @ETHTOOL_RING_USE_RX_BUF_LEN: capture for setting rx_buf_len 95 * @ETHTOOL_RING_USE_CQE_SIZE: capture for setting cqe_size 96 * @ETHTOOL_RING_USE_TX_PUSH: capture for setting tx_push 97 * @ETHTOOL_RING_USE_RX_PUSH: capture for setting rx_push 98 * @ETHTOOL_RING_USE_TX_PUSH_BUF_LEN: capture for setting tx_push_buf_len 99 * @ETHTOOL_RING_USE_TCP_DATA_SPLIT: capture for setting tcp_data_split 100 */ 101 enum ethtool_supported_ring_param { 102 ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0), 103 ETHTOOL_RING_USE_CQE_SIZE = BIT(1), 104 ETHTOOL_RING_USE_TX_PUSH = BIT(2), 105 ETHTOOL_RING_USE_RX_PUSH = BIT(3), 106 ETHTOOL_RING_USE_TX_PUSH_BUF_LEN = BIT(4), 107 ETHTOOL_RING_USE_TCP_DATA_SPLIT = BIT(5), 108 }; 109 110 #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit)) 111 #define __ETH_RSS_HASH(name) __ETH_RSS_HASH_BIT(ETH_RSS_HASH_##name##_BIT) 112 113 #define ETH_RSS_HASH_TOP __ETH_RSS_HASH(TOP) 114 #define ETH_RSS_HASH_XOR __ETH_RSS_HASH(XOR) 115 #define ETH_RSS_HASH_CRC32 __ETH_RSS_HASH(CRC32) 116 117 #define ETH_RSS_HASH_UNKNOWN 0 118 #define ETH_RSS_HASH_NO_CHANGE 0 119 120 struct net_device; 121 struct netlink_ext_ack; 122 123 /* Link extended state and substate. */ 124 struct ethtool_link_ext_state_info { 125 enum ethtool_link_ext_state link_ext_state; 126 union { 127 enum ethtool_link_ext_substate_autoneg autoneg; 128 enum ethtool_link_ext_substate_link_training link_training; 129 enum ethtool_link_ext_substate_link_logical_mismatch link_logical_mismatch; 130 enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity; 131 enum ethtool_link_ext_substate_cable_issue cable_issue; 132 enum ethtool_link_ext_substate_module module; 133 u32 __link_ext_substate; 134 }; 135 }; 136 137 struct ethtool_link_ext_stats { 138 /* Custom Linux statistic for PHY level link down events. 139 * In a simpler world it should be equal to netdev->carrier_down_count 140 * unfortunately netdev also counts local reconfigurations which don't 141 * actually take the physical link down, not to mention NC-SI which, 142 * if present, keeps the link up regardless of host state. 143 * This statistic counts when PHY _actually_ went down, or lost link. 144 * 145 * Note that we need u64 for ethtool_stats_init() and comparisons 146 * to ETHTOOL_STAT_NOT_SET, but only u32 is exposed to the user. 147 */ 148 u64 link_down_events; 149 }; 150 151 /** 152 * ethtool_rxfh_indir_default - get default value for RX flow hash indirection 153 * @index: Index in RX flow hash indirection table 154 * @n_rx_rings: Number of RX rings to use 155 * 156 * This function provides the default policy for RX flow hash indirection. 157 */ 158 static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings) 159 { 160 return index % n_rx_rings; 161 } 162 163 /** 164 * struct ethtool_rxfh_context - a custom RSS context configuration 165 * @indir_size: Number of u32 entries in indirection table 166 * @key_size: Size of hash key, in bytes 167 * @priv_size: Size of driver private data, in bytes 168 * @hfunc: RSS hash function identifier. One of the %ETH_RSS_HASH_* 169 * @input_xfrm: Defines how the input data is transformed. Valid values are one 170 * of %RXH_XFRM_*. 171 * @indir_configured: indir has been specified (at create time or subsequently) 172 * @key_configured: hkey has been specified (at create time or subsequently) 173 */ 174 struct ethtool_rxfh_context { 175 u32 indir_size; 176 u32 key_size; 177 u16 priv_size; 178 u8 hfunc; 179 u8 input_xfrm; 180 u8 indir_configured:1; 181 u8 key_configured:1; 182 /* private: driver private data, indirection table, and hash key are 183 * stored sequentially in @data area. Use below helpers to access. 184 */ 185 u32 key_off; 186 u8 data[] __aligned(sizeof(void *)); 187 }; 188 189 static inline void *ethtool_rxfh_context_priv(struct ethtool_rxfh_context *ctx) 190 { 191 return ctx->data; 192 } 193 194 static inline u32 *ethtool_rxfh_context_indir(struct ethtool_rxfh_context *ctx) 195 { 196 return (u32 *)(ctx->data + ALIGN(ctx->priv_size, sizeof(u32))); 197 } 198 199 static inline u8 *ethtool_rxfh_context_key(struct ethtool_rxfh_context *ctx) 200 { 201 return &ctx->data[ctx->key_off]; 202 } 203 204 void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id); 205 206 /* declare a link mode bitmap */ 207 #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \ 208 DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS) 209 210 /* drivers must ignore base.cmd and base.link_mode_masks_nwords 211 * fields, but they are allowed to overwrite them (will be ignored). 212 */ 213 struct ethtool_link_ksettings { 214 struct ethtool_link_settings base; 215 struct { 216 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); 217 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); 218 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); 219 } link_modes; 220 u32 lanes; 221 }; 222 223 /** 224 * ethtool_link_ksettings_zero_link_mode - clear link_ksettings link mode mask 225 * @ptr : pointer to struct ethtool_link_ksettings 226 * @name : one of supported/advertising/lp_advertising 227 */ 228 #define ethtool_link_ksettings_zero_link_mode(ptr, name) \ 229 bitmap_zero((ptr)->link_modes.name, __ETHTOOL_LINK_MODE_MASK_NBITS) 230 231 /** 232 * ethtool_link_ksettings_add_link_mode - set bit in link_ksettings 233 * link mode mask 234 * @ptr : pointer to struct ethtool_link_ksettings 235 * @name : one of supported/advertising/lp_advertising 236 * @mode : one of the ETHTOOL_LINK_MODE_*_BIT 237 * (not atomic, no bound checking) 238 */ 239 #define ethtool_link_ksettings_add_link_mode(ptr, name, mode) \ 240 __set_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) 241 242 /** 243 * ethtool_link_ksettings_del_link_mode - clear bit in link_ksettings 244 * link mode mask 245 * @ptr : pointer to struct ethtool_link_ksettings 246 * @name : one of supported/advertising/lp_advertising 247 * @mode : one of the ETHTOOL_LINK_MODE_*_BIT 248 * (not atomic, no bound checking) 249 */ 250 #define ethtool_link_ksettings_del_link_mode(ptr, name, mode) \ 251 __clear_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) 252 253 /** 254 * ethtool_link_ksettings_test_link_mode - test bit in ksettings link mode mask 255 * @ptr : pointer to struct ethtool_link_ksettings 256 * @name : one of supported/advertising/lp_advertising 257 * @mode : one of the ETHTOOL_LINK_MODE_*_BIT 258 * (not atomic, no bound checking) 259 * 260 * Returns true/false. 261 */ 262 #define ethtool_link_ksettings_test_link_mode(ptr, name, mode) \ 263 test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name) 264 265 extern int 266 __ethtool_get_link_ksettings(struct net_device *dev, 267 struct ethtool_link_ksettings *link_ksettings); 268 269 struct ethtool_keee { 270 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); 271 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertised); 272 __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertised); 273 u32 tx_lpi_timer; 274 bool tx_lpi_enabled; 275 bool eee_active; 276 bool eee_enabled; 277 }; 278 279 struct kernel_ethtool_coalesce { 280 u8 use_cqe_mode_tx; 281 u8 use_cqe_mode_rx; 282 u32 tx_aggr_max_bytes; 283 u32 tx_aggr_max_frames; 284 u32 tx_aggr_time_usecs; 285 }; 286 287 /** 288 * ethtool_intersect_link_masks - Given two link masks, AND them together 289 * @dst: first mask and where result is stored 290 * @src: second mask to intersect with 291 * 292 * Given two link mode masks, AND them together and save the result in dst. 293 */ 294 void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst, 295 struct ethtool_link_ksettings *src); 296 297 void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst, 298 u32 legacy_u32); 299 300 /* return false if src had higher bits set. lower bits always updated. */ 301 bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, 302 const unsigned long *src); 303 304 #define ETHTOOL_COALESCE_RX_USECS BIT(0) 305 #define ETHTOOL_COALESCE_RX_MAX_FRAMES BIT(1) 306 #define ETHTOOL_COALESCE_RX_USECS_IRQ BIT(2) 307 #define ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ BIT(3) 308 #define ETHTOOL_COALESCE_TX_USECS BIT(4) 309 #define ETHTOOL_COALESCE_TX_MAX_FRAMES BIT(5) 310 #define ETHTOOL_COALESCE_TX_USECS_IRQ BIT(6) 311 #define ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ BIT(7) 312 #define ETHTOOL_COALESCE_STATS_BLOCK_USECS BIT(8) 313 #define ETHTOOL_COALESCE_USE_ADAPTIVE_RX BIT(9) 314 #define ETHTOOL_COALESCE_USE_ADAPTIVE_TX BIT(10) 315 #define ETHTOOL_COALESCE_PKT_RATE_LOW BIT(11) 316 #define ETHTOOL_COALESCE_RX_USECS_LOW BIT(12) 317 #define ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW BIT(13) 318 #define ETHTOOL_COALESCE_TX_USECS_LOW BIT(14) 319 #define ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW BIT(15) 320 #define ETHTOOL_COALESCE_PKT_RATE_HIGH BIT(16) 321 #define ETHTOOL_COALESCE_RX_USECS_HIGH BIT(17) 322 #define ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH BIT(18) 323 #define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19) 324 #define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH BIT(20) 325 #define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21) 326 #define ETHTOOL_COALESCE_USE_CQE_RX BIT(22) 327 #define ETHTOOL_COALESCE_USE_CQE_TX BIT(23) 328 #define ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES BIT(24) 329 #define ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES BIT(25) 330 #define ETHTOOL_COALESCE_TX_AGGR_TIME_USECS BIT(26) 331 #define ETHTOOL_COALESCE_RX_PROFILE BIT(27) 332 #define ETHTOOL_COALESCE_TX_PROFILE BIT(28) 333 #define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(28, 0) 334 335 #define ETHTOOL_COALESCE_USECS \ 336 (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS) 337 #define ETHTOOL_COALESCE_MAX_FRAMES \ 338 (ETHTOOL_COALESCE_RX_MAX_FRAMES | ETHTOOL_COALESCE_TX_MAX_FRAMES) 339 #define ETHTOOL_COALESCE_USECS_IRQ \ 340 (ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ) 341 #define ETHTOOL_COALESCE_MAX_FRAMES_IRQ \ 342 (ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | \ 343 ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ) 344 #define ETHTOOL_COALESCE_USE_ADAPTIVE \ 345 (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_ADAPTIVE_TX) 346 #define ETHTOOL_COALESCE_USECS_LOW_HIGH \ 347 (ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_TX_USECS_LOW | \ 348 ETHTOOL_COALESCE_RX_USECS_HIGH | ETHTOOL_COALESCE_TX_USECS_HIGH) 349 #define ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH \ 350 (ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW | \ 351 ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW | \ 352 ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH | \ 353 ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH) 354 #define ETHTOOL_COALESCE_PKT_RATE_RX_USECS \ 355 (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | \ 356 ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_RX_USECS_HIGH | \ 357 ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \ 358 ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL) 359 #define ETHTOOL_COALESCE_USE_CQE \ 360 (ETHTOOL_COALESCE_USE_CQE_RX | ETHTOOL_COALESCE_USE_CQE_TX) 361 #define ETHTOOL_COALESCE_TX_AGGR \ 362 (ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES | \ 363 ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES | \ 364 ETHTOOL_COALESCE_TX_AGGR_TIME_USECS) 365 366 #define ETHTOOL_STAT_NOT_SET (~0ULL) 367 368 static inline void ethtool_stats_init(u64 *stats, unsigned int n) 369 { 370 while (n--) 371 stats[n] = ETHTOOL_STAT_NOT_SET; 372 } 373 374 /* Basic IEEE 802.3 MAC statistics (30.3.1.1.*), not otherwise exposed 375 * via a more targeted API. 376 */ 377 struct ethtool_eth_mac_stats { 378 enum ethtool_mac_stats_src src; 379 struct_group(stats, 380 u64 FramesTransmittedOK; 381 u64 SingleCollisionFrames; 382 u64 MultipleCollisionFrames; 383 u64 FramesReceivedOK; 384 u64 FrameCheckSequenceErrors; 385 u64 AlignmentErrors; 386 u64 OctetsTransmittedOK; 387 u64 FramesWithDeferredXmissions; 388 u64 LateCollisions; 389 u64 FramesAbortedDueToXSColls; 390 u64 FramesLostDueToIntMACXmitError; 391 u64 CarrierSenseErrors; 392 u64 OctetsReceivedOK; 393 u64 FramesLostDueToIntMACRcvError; 394 u64 MulticastFramesXmittedOK; 395 u64 BroadcastFramesXmittedOK; 396 u64 FramesWithExcessiveDeferral; 397 u64 MulticastFramesReceivedOK; 398 u64 BroadcastFramesReceivedOK; 399 u64 InRangeLengthErrors; 400 u64 OutOfRangeLengthField; 401 u64 FrameTooLongErrors; 402 ); 403 }; 404 405 /* Basic IEEE 802.3 PHY statistics (30.3.2.1.*), not otherwise exposed 406 * via a more targeted API. 407 */ 408 struct ethtool_eth_phy_stats { 409 enum ethtool_mac_stats_src src; 410 struct_group(stats, 411 u64 SymbolErrorDuringCarrier; 412 ); 413 }; 414 415 /* Basic IEEE 802.3 MAC Ctrl statistics (30.3.3.*), not otherwise exposed 416 * via a more targeted API. 417 */ 418 struct ethtool_eth_ctrl_stats { 419 enum ethtool_mac_stats_src src; 420 struct_group(stats, 421 u64 MACControlFramesTransmitted; 422 u64 MACControlFramesReceived; 423 u64 UnsupportedOpcodesReceived; 424 ); 425 }; 426 427 /** 428 * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames 429 * @src: input field denoting whether stats should be queried from the eMAC or 430 * pMAC (if the MM layer is supported). To be ignored otherwise. 431 * @tx_pause_frames: transmitted pause frame count. Reported to user space 432 * as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES. 433 * 434 * Equivalent to `30.3.4.2 aPAUSEMACCtrlFramesTransmitted` 435 * from the standard. 436 * 437 * @rx_pause_frames: received pause frame count. Reported to user space 438 * as %ETHTOOL_A_PAUSE_STAT_RX_FRAMES. Equivalent to: 439 * 440 * Equivalent to `30.3.4.3 aPAUSEMACCtrlFramesReceived` 441 * from the standard. 442 */ 443 struct ethtool_pause_stats { 444 enum ethtool_mac_stats_src src; 445 struct_group(stats, 446 u64 tx_pause_frames; 447 u64 rx_pause_frames; 448 ); 449 }; 450 451 #define ETHTOOL_MAX_LANES 8 452 453 /** 454 * struct ethtool_fec_stats - statistics for IEEE 802.3 FEC 455 * @corrected_blocks: number of received blocks corrected by FEC 456 * Reported to user space as %ETHTOOL_A_FEC_STAT_CORRECTED. 457 * 458 * Equivalent to `30.5.1.1.17 aFECCorrectedBlocks` from the standard. 459 * 460 * @uncorrectable_blocks: number of received blocks FEC was not able to correct 461 * Reported to user space as %ETHTOOL_A_FEC_STAT_UNCORR. 462 * 463 * Equivalent to `30.5.1.1.18 aFECUncorrectableBlocks` from the standard. 464 * 465 * @corrected_bits: number of bits corrected by FEC 466 * Similar to @corrected_blocks but counts individual bit changes, 467 * not entire FEC data blocks. This is a non-standard statistic. 468 * Reported to user space as %ETHTOOL_A_FEC_STAT_CORR_BITS. 469 * 470 * For each of the above fields, the two substructure members are: 471 * 472 * - @lanes: per-lane/PCS-instance counts as defined by the standard 473 * - @total: error counts for the entire port, for drivers incapable of reporting 474 * per-lane stats 475 * 476 * Drivers should fill in either only total or per-lane statistics, core 477 * will take care of adding lane values up to produce the total. 478 */ 479 struct ethtool_fec_stats { 480 struct ethtool_fec_stat { 481 u64 total; 482 u64 lanes[ETHTOOL_MAX_LANES]; 483 } corrected_blocks, uncorrectable_blocks, corrected_bits; 484 }; 485 486 /** 487 * struct ethtool_rmon_hist_range - byte range for histogram statistics 488 * @low: low bound of the bucket (inclusive) 489 * @high: high bound of the bucket (inclusive) 490 */ 491 struct ethtool_rmon_hist_range { 492 u16 low; 493 u16 high; 494 }; 495 496 #define ETHTOOL_RMON_HIST_MAX 10 497 498 /** 499 * struct ethtool_rmon_stats - selected RMON (RFC 2819) statistics 500 * @src: input field denoting whether stats should be queried from the eMAC or 501 * pMAC (if the MM layer is supported). To be ignored otherwise. 502 * @undersize_pkts: Equivalent to `etherStatsUndersizePkts` from the RFC. 503 * @oversize_pkts: Equivalent to `etherStatsOversizePkts` from the RFC. 504 * @fragments: Equivalent to `etherStatsFragments` from the RFC. 505 * @jabbers: Equivalent to `etherStatsJabbers` from the RFC. 506 * @hist: Packet counter for packet length buckets (e.g. 507 * `etherStatsPkts128to255Octets` from the RFC). 508 * @hist_tx: Tx counters in similar form to @hist, not defined in the RFC. 509 * 510 * Selection of RMON (RFC 2819) statistics which are not exposed via different 511 * APIs, primarily the packet-length-based counters. 512 * Unfortunately different designs choose different buckets beyond 513 * the 1024B mark (jumbo frame teritory), so the definition of the bucket 514 * ranges is left to the driver. 515 */ 516 struct ethtool_rmon_stats { 517 enum ethtool_mac_stats_src src; 518 struct_group(stats, 519 u64 undersize_pkts; 520 u64 oversize_pkts; 521 u64 fragments; 522 u64 jabbers; 523 524 u64 hist[ETHTOOL_RMON_HIST_MAX]; 525 u64 hist_tx[ETHTOOL_RMON_HIST_MAX]; 526 ); 527 }; 528 529 /** 530 * struct ethtool_ts_stats - HW timestamping statistics 531 * @pkts: Number of packets successfully timestamped by the hardware. 532 * @lost: Number of hardware timestamping requests where the timestamping 533 * information from the hardware never arrived for submission with 534 * the skb. 535 * @err: Number of arbitrary timestamp generation error events that the 536 * hardware encountered, exclusive of @lost statistics. Cases such 537 * as resource exhaustion, unavailability, firmware errors, and 538 * detected illogical timestamp values not submitted with the skb 539 * are inclusive to this counter. 540 */ 541 struct ethtool_ts_stats { 542 struct_group(tx_stats, 543 u64 pkts; 544 u64 lost; 545 u64 err; 546 ); 547 }; 548 549 #define ETH_MODULE_EEPROM_PAGE_LEN 128 550 #define ETH_MODULE_MAX_I2C_ADDRESS 0x7f 551 552 /** 553 * struct ethtool_module_eeprom - plug-in module EEPROM read / write parameters 554 * @offset: When @offset is 0-127, it is used as an address to the Lower Memory 555 * (@page must be 0). Otherwise, it is used as an address to the 556 * Upper Memory. 557 * @length: Number of bytes to read / write. 558 * @page: Page number. 559 * @bank: Bank number, if supported by EEPROM spec. 560 * @i2c_address: I2C address of a page. Value less than 0x7f expected. Most 561 * EEPROMs use 0x50 or 0x51. 562 * @data: Pointer to buffer with EEPROM data of @length size. 563 */ 564 struct ethtool_module_eeprom { 565 u32 offset; 566 u32 length; 567 u8 page; 568 u8 bank; 569 u8 i2c_address; 570 u8 *data; 571 }; 572 573 /** 574 * struct ethtool_module_power_mode_params - module power mode parameters 575 * @policy: The power mode policy enforced by the host for the plug-in module. 576 * @mode: The operational power mode of the plug-in module. Should be filled by 577 * device drivers on get operations. 578 */ 579 struct ethtool_module_power_mode_params { 580 enum ethtool_module_power_mode_policy policy; 581 enum ethtool_module_power_mode mode; 582 }; 583 584 /** 585 * struct ethtool_mm_state - 802.3 MAC merge layer state 586 * @verify_time: 587 * wait time between verification attempts in ms (according to clause 588 * 30.14.1.6 aMACMergeVerifyTime) 589 * @max_verify_time: 590 * maximum accepted value for the @verify_time variable in set requests 591 * @verify_status: 592 * state of the verification state machine of the MM layer (according to 593 * clause 30.14.1.2 aMACMergeStatusVerify) 594 * @tx_enabled: 595 * set if the MM layer is administratively enabled in the TX direction 596 * (according to clause 30.14.1.3 aMACMergeEnableTx) 597 * @tx_active: 598 * set if the MM layer is enabled in the TX direction, which makes FP 599 * possible (according to 30.14.1.5 aMACMergeStatusTx). This should be 600 * true if MM is enabled, and the verification status is either verified, 601 * or disabled. 602 * @pmac_enabled: 603 * set if the preemptible MAC is powered on and is able to receive 604 * preemptible packets and respond to verification frames. 605 * @verify_enabled: 606 * set if the Verify function of the MM layer (which sends SMD-V 607 * verification requests) is administratively enabled (regardless of 608 * whether it is currently in the ETHTOOL_MM_VERIFY_STATUS_DISABLED state 609 * or not), according to clause 30.14.1.4 aMACMergeVerifyDisableTx (but 610 * using positive rather than negative logic). The device should always 611 * respond to received SMD-V requests as long as @pmac_enabled is set. 612 * @tx_min_frag_size: 613 * the minimum size of non-final mPacket fragments that the link partner 614 * supports receiving, expressed in octets. Compared to the definition 615 * from clause 30.14.1.7 aMACMergeAddFragSize which is expressed in the 616 * range 0 to 3 (requiring a translation to the size in octets according 617 * to the formula 64 * (1 + addFragSize) - 4), a value in a continuous and 618 * unbounded range can be specified here. 619 * @rx_min_frag_size: 620 * the minimum size of non-final mPacket fragments that this device 621 * supports receiving, expressed in octets. 622 */ 623 struct ethtool_mm_state { 624 u32 verify_time; 625 u32 max_verify_time; 626 enum ethtool_mm_verify_status verify_status; 627 bool tx_enabled; 628 bool tx_active; 629 bool pmac_enabled; 630 bool verify_enabled; 631 u32 tx_min_frag_size; 632 u32 rx_min_frag_size; 633 }; 634 635 /** 636 * struct ethtool_mm_cfg - 802.3 MAC merge layer configuration 637 * @verify_time: see struct ethtool_mm_state 638 * @verify_enabled: see struct ethtool_mm_state 639 * @tx_enabled: see struct ethtool_mm_state 640 * @pmac_enabled: see struct ethtool_mm_state 641 * @tx_min_frag_size: see struct ethtool_mm_state 642 */ 643 struct ethtool_mm_cfg { 644 u32 verify_time; 645 bool verify_enabled; 646 bool tx_enabled; 647 bool pmac_enabled; 648 u32 tx_min_frag_size; 649 }; 650 651 /** 652 * struct ethtool_mm_stats - 802.3 MAC merge layer statistics 653 * @MACMergeFrameAssErrorCount: 654 * received MAC frames with reassembly errors 655 * @MACMergeFrameSmdErrorCount: 656 * received MAC frames/fragments rejected due to unknown or incorrect SMD 657 * @MACMergeFrameAssOkCount: 658 * received MAC frames that were successfully reassembled and passed up 659 * @MACMergeFragCountRx: 660 * number of additional correct SMD-C mPackets received due to preemption 661 * @MACMergeFragCountTx: 662 * number of additional mPackets sent due to preemption 663 * @MACMergeHoldCount: 664 * number of times the MM layer entered the HOLD state, which blocks 665 * transmission of preemptible traffic 666 */ 667 struct ethtool_mm_stats { 668 u64 MACMergeFrameAssErrorCount; 669 u64 MACMergeFrameSmdErrorCount; 670 u64 MACMergeFrameAssOkCount; 671 u64 MACMergeFragCountRx; 672 u64 MACMergeFragCountTx; 673 u64 MACMergeHoldCount; 674 }; 675 676 /** 677 * struct ethtool_rxfh_param - RXFH (RSS) parameters 678 * @hfunc: Defines the current RSS hash function used by HW (or to be set to). 679 * Valid values are one of the %ETH_RSS_HASH_*. 680 * @indir_size: On SET, the array size of the user buffer for the 681 * indirection table, which may be zero, or 682 * %ETH_RXFH_INDIR_NO_CHANGE. On GET (read from the driver), 683 * the array size of the hardware indirection table. 684 * @indir: The indirection table of size @indir_size entries. 685 * @key_size: On SET, the array size of the user buffer for the hash key, 686 * which may be zero. On GET (read from the driver), the size of the 687 * hardware hash key. 688 * @key: The hash key of size @key_size bytes. 689 * @rss_context: RSS context identifier. Context 0 is the default for normal 690 * traffic; other contexts can be referenced as the destination for RX flow 691 * classification rules. On SET, %ETH_RXFH_CONTEXT_ALLOC is used 692 * to allocate a new RSS context; on return this field will 693 * contain the ID of the newly allocated context. 694 * @rss_delete: Set to non-ZERO to remove the @rss_context context. 695 * @input_xfrm: Defines how the input data is transformed. Valid values are one 696 * of %RXH_XFRM_*. 697 */ 698 struct ethtool_rxfh_param { 699 u8 hfunc; 700 u32 indir_size; 701 u32 *indir; 702 u32 key_size; 703 u8 *key; 704 u32 rss_context; 705 u8 rss_delete; 706 u8 input_xfrm; 707 }; 708 709 /** 710 * struct kernel_ethtool_ts_info - kernel copy of struct ethtool_ts_info 711 * @cmd: command number = %ETHTOOL_GET_TS_INFO 712 * @so_timestamping: bit mask of the sum of the supported SO_TIMESTAMPING flags 713 * @phc_index: device index of the associated PHC, or -1 if there is none 714 * @tx_types: bit mask of the supported hwtstamp_tx_types enumeration values 715 * @rx_filters: bit mask of the supported hwtstamp_rx_filters enumeration values 716 */ 717 struct kernel_ethtool_ts_info { 718 u32 cmd; 719 u32 so_timestamping; 720 int phc_index; 721 enum hwtstamp_tx_types tx_types; 722 enum hwtstamp_rx_filters rx_filters; 723 }; 724 725 /** 726 * struct ethtool_ops - optional netdev operations 727 * @cap_link_lanes_supported: indicates if the driver supports lanes 728 * parameter. 729 * @cap_rss_ctx_supported: indicates if the driver supports RSS 730 * contexts. 731 * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor 732 * RSS. 733 * @rxfh_indir_space: max size of RSS indirection tables, if indirection table 734 * size as returned by @get_rxfh_indir_size may change during lifetime 735 * of the device. Leave as 0 if the table size is constant. 736 * @rxfh_key_space: same as @rxfh_indir_space, but for the key. 737 * @rxfh_priv_size: size of the driver private data area the core should 738 * allocate for an RSS context (in &struct ethtool_rxfh_context). 739 * @rxfh_max_num_contexts: maximum (exclusive) supported RSS context ID. 740 * If this is zero then the core may choose any (nonzero) ID, otherwise 741 * the core will only use IDs strictly less than this value, as the 742 * @rss_context argument to @create_rxfh_context and friends. 743 * @supported_coalesce_params: supported types of interrupt coalescing. 744 * @supported_ring_params: supported ring params. 745 * @get_drvinfo: Report driver/device information. Modern drivers no 746 * longer have to implement this callback. Most fields are 747 * correctly filled in by the core using system information, or 748 * populated using other driver operations. 749 * @get_regs_len: Get buffer length required for @get_regs 750 * @get_regs: Get device registers 751 * @get_wol: Report whether Wake-on-Lan is enabled 752 * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code 753 * or zero. 754 * @get_msglevel: Report driver message level. This should be the value 755 * of the @msg_enable field used by netif logging functions. 756 * @set_msglevel: Set driver message level 757 * @nway_reset: Restart autonegotiation. Returns a negative error code 758 * or zero. 759 * @get_link: Report whether physical link is up. Will only be called if 760 * the netdev is up. Should usually be set to ethtool_op_get_link(), 761 * which uses netif_carrier_ok(). 762 * @get_link_ext_state: Report link extended state. Should set link_ext_state and 763 * link_ext_substate (link_ext_substate of 0 means link_ext_substate is unknown, 764 * do not attach ext_substate attribute to netlink message). If link_ext_state 765 * and link_ext_substate are unknown, return -ENODATA. If not implemented, 766 * link_ext_state and link_ext_substate will not be sent to userspace. 767 * @get_link_ext_stats: Read extra link-related counters. 768 * @get_eeprom_len: Read range of EEPROM addresses for validation of 769 * @get_eeprom and @set_eeprom requests. 770 * Returns 0 if device does not support EEPROM access. 771 * @get_eeprom: Read data from the device EEPROM. 772 * Should fill in the magic field. Don't need to check len for zero 773 * or wraparound. Fill in the data argument with the eeprom values 774 * from offset to offset + len. Update len to the amount read. 775 * Returns an error or zero. 776 * @set_eeprom: Write data to the device EEPROM. 777 * Should validate the magic field. Don't need to check len for zero 778 * or wraparound. Update len to the amount written. Returns an error 779 * or zero. 780 * @get_coalesce: Get interrupt coalescing parameters. Returns a negative 781 * error code or zero. 782 * @set_coalesce: Set interrupt coalescing parameters. Supported coalescing 783 * types should be set in @supported_coalesce_params. 784 * Returns a negative error code or zero. 785 * @get_ringparam: Report ring sizes 786 * @set_ringparam: Set ring sizes. Returns a negative error code or zero. 787 * @get_pause_stats: Report pause frame statistics. Drivers must not zero 788 * statistics which they don't report. The stats structure is initialized 789 * to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics. 790 * @get_pauseparam: Report pause parameters 791 * @set_pauseparam: Set pause parameters. Returns a negative error code 792 * or zero. 793 * @self_test: Run specified self-tests 794 * @get_strings: Return a set of strings that describe the requested objects 795 * @set_phys_id: Identify the physical devices, e.g. by flashing an LED 796 * attached to it. The implementation may update the indicator 797 * asynchronously or synchronously, but in either case it must return 798 * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE, 799 * and must either activate asynchronous updates and return zero, return 800 * a negative error or return a positive frequency for synchronous 801 * indication (e.g. 1 for one on/off cycle per second). If it returns 802 * a frequency then it will be called again at intervals with the 803 * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of 804 * the indicator accordingly. Finally, it is called with the argument 805 * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a 806 * negative error code or zero. 807 * @get_ethtool_stats: Return extended statistics about the device. 808 * This is only useful if the device maintains statistics not 809 * included in &struct rtnl_link_stats64. 810 * @begin: Function to be called before any other operation. Returns a 811 * negative error code or zero. 812 * @complete: Function to be called after any other operation except 813 * @begin. Will be called even if the other operation failed. 814 * @get_priv_flags: Report driver-specific feature flags. 815 * @set_priv_flags: Set driver-specific feature flags. Returns a negative 816 * error code or zero. 817 * @get_sset_count: Get number of strings that @get_strings will write. 818 * @get_rxnfc: Get RX flow classification rules. Returns a negative 819 * error code or zero. 820 * @set_rxnfc: Set RX flow classification rules. Returns a negative 821 * error code or zero. 822 * @flash_device: Write a firmware image to device's flash memory. 823 * Returns a negative error code or zero. 824 * @reset: Reset (part of) the device, as specified by a bitmask of 825 * flags from &enum ethtool_reset_flags. Returns a negative 826 * error code or zero. 827 * @get_rxfh_key_size: Get the size of the RX flow hash key. 828 * Returns zero if not supported for this specific device. 829 * @get_rxfh_indir_size: Get the size of the RX flow hash indirection table. 830 * Returns zero if not supported for this specific device. 831 * @get_rxfh: Get the contents of the RX flow hash indirection table, hash key 832 * and/or hash function. 833 * Returns a negative error code or zero. 834 * @set_rxfh: Set the contents of the RX flow hash indirection table, hash 835 * key, and/or hash function. Arguments which are set to %NULL or zero 836 * will remain unchanged. 837 * Returns a negative error code or zero. An error code must be returned 838 * if at least one unsupported change was requested. 839 * @create_rxfh_context: Create a new RSS context with the specified RX flow 840 * hash indirection table, hash key, and hash function. 841 * The &struct ethtool_rxfh_context for this context is passed in @ctx; 842 * note that the indir table, hkey and hfunc are not yet populated as 843 * of this call. The driver does not need to update these; the core 844 * will do so if this op succeeds. 845 * However, if @rxfh.indir is set to %NULL, the driver must update the 846 * indir table in @ctx with the (default or inherited) table actually in 847 * use; similarly, if @rxfh.key is %NULL, @rxfh.hfunc is 848 * %ETH_RSS_HASH_NO_CHANGE, or @rxfh.input_xfrm is %RXH_XFRM_NO_CHANGE, 849 * the driver should update the corresponding information in @ctx. 850 * If the driver provides this method, it must also provide 851 * @modify_rxfh_context and @remove_rxfh_context. 852 * Returns a negative error code or zero. 853 * @modify_rxfh_context: Reconfigure the specified RSS context. Allows setting 854 * the contents of the RX flow hash indirection table, hash key, and/or 855 * hash function associated with the given context. 856 * Parameters which are set to %NULL or zero will remain unchanged. 857 * The &struct ethtool_rxfh_context for this context is passed in @ctx; 858 * note that it will still contain the *old* settings. The driver does 859 * not need to update these; the core will do so if this op succeeds. 860 * Returns a negative error code or zero. An error code must be returned 861 * if at least one unsupported change was requested. 862 * @remove_rxfh_context: Remove the specified RSS context. 863 * The &struct ethtool_rxfh_context for this context is passed in @ctx. 864 * Returns a negative error code or zero. 865 * @get_channels: Get number of channels. 866 * @set_channels: Set number of channels. Returns a negative error code or 867 * zero. 868 * @get_dump_flag: Get dump flag indicating current dump length, version, 869 * and flag of the device. 870 * @get_dump_data: Get dump data. 871 * @set_dump: Set dump specific flags to the device. 872 * @get_ts_info: Get the time stamping and PTP hardware clock capabilities. 873 * It may be called with RCU, or rtnl or reference on the device. 874 * Drivers supporting transmit time stamps in software should set this to 875 * ethtool_op_get_ts_info(). Drivers must not zero statistics which they 876 * don't report. The stats structure is initialized to ETHTOOL_STAT_NOT_SET 877 * indicating driver does not report statistics. 878 * @get_ts_stats: Query the device hardware timestamping statistics. 879 * @get_module_info: Get the size and type of the eeprom contained within 880 * a plug-in module. 881 * @get_module_eeprom: Get the eeprom information from the plug-in module 882 * @get_eee: Get Energy-Efficient (EEE) supported and status. 883 * @set_eee: Set EEE status (enable/disable) as well as LPI timers. 884 * @get_tunable: Read the value of a driver / device tunable. 885 * @set_tunable: Set the value of a driver / device tunable. 886 * @get_per_queue_coalesce: Get interrupt coalescing parameters per queue. 887 * It must check that the given queue number is valid. If neither a RX nor 888 * a TX queue has this number, return -EINVAL. If only a RX queue or a TX 889 * queue has this number, set the inapplicable fields to ~0 and return 0. 890 * Returns a negative error code or zero. 891 * @set_per_queue_coalesce: Set interrupt coalescing parameters per queue. 892 * It must check that the given queue number is valid. If neither a RX nor 893 * a TX queue has this number, return -EINVAL. If only a RX queue or a TX 894 * queue has this number, ignore the inapplicable fields. Supported 895 * coalescing types should be set in @supported_coalesce_params. 896 * Returns a negative error code or zero. 897 * @get_link_ksettings: Get various device settings including Ethernet link 898 * settings. The %cmd and %link_mode_masks_nwords fields should be 899 * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), 900 * any change to them will be overwritten by kernel. Returns a negative 901 * error code or zero. 902 * @set_link_ksettings: Set various device settings including Ethernet link 903 * settings. The %cmd and %link_mode_masks_nwords fields should be 904 * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), 905 * any change to them will be overwritten by kernel. Returns a negative 906 * error code or zero. 907 * @get_fec_stats: Report FEC statistics. 908 * Core will sum up per-lane stats to get the total. 909 * Drivers must not zero statistics which they don't report. The stats 910 * structure is initialized to ETHTOOL_STAT_NOT_SET indicating driver does 911 * not report statistics. 912 * @get_fecparam: Get the network device Forward Error Correction parameters. 913 * @set_fecparam: Set the network device Forward Error Correction parameters. 914 * @get_ethtool_phy_stats: Return extended statistics about the PHY device. 915 * This is only useful if the device maintains PHY statistics and 916 * cannot use the standard PHY library helpers. 917 * @get_phy_tunable: Read the value of a PHY tunable. 918 * @set_phy_tunable: Set the value of a PHY tunable. 919 * @get_module_eeprom_by_page: Get a region of plug-in module EEPROM data from 920 * specified page. Returns a negative error code or the amount of bytes 921 * read. 922 * @set_module_eeprom_by_page: Write to a region of plug-in module EEPROM, 923 * from kernel space only. Returns a negative error code or zero. 924 * @get_eth_phy_stats: Query some of the IEEE 802.3 PHY statistics. 925 * @get_eth_mac_stats: Query some of the IEEE 802.3 MAC statistics. 926 * @get_eth_ctrl_stats: Query some of the IEEE 802.3 MAC Ctrl statistics. 927 * @get_rmon_stats: Query some of the RMON (RFC 2819) statistics. 928 * Set %ranges to a pointer to zero-terminated array of byte ranges. 929 * @get_module_power_mode: Get the power mode policy for the plug-in module 930 * used by the network device and its operational power mode, if 931 * plugged-in. 932 * @set_module_power_mode: Set the power mode policy for the plug-in module 933 * used by the network device. 934 * @get_mm: Query the 802.3 MAC Merge layer state. 935 * @set_mm: Set the 802.3 MAC Merge layer parameters. 936 * @get_mm_stats: Query the 802.3 MAC Merge layer statistics. 937 * 938 * All operations are optional (i.e. the function pointer may be set 939 * to %NULL) and callers must take this into account. Callers must 940 * hold the RTNL lock. 941 * 942 * See the structures used by these operations for further documentation. 943 * Note that for all operations using a structure ending with a zero- 944 * length array, the array is allocated separately in the kernel and 945 * is passed to the driver as an additional parameter. 946 * 947 * See &struct net_device and &struct net_device_ops for documentation 948 * of the generic netdev features interface. 949 */ 950 struct ethtool_ops { 951 u32 cap_link_lanes_supported:1; 952 u32 cap_rss_ctx_supported:1; 953 u32 cap_rss_sym_xor_supported:1; 954 u32 rxfh_indir_space; 955 u16 rxfh_key_space; 956 u16 rxfh_priv_size; 957 u32 rxfh_max_num_contexts; 958 u32 supported_coalesce_params; 959 u32 supported_ring_params; 960 void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *); 961 int (*get_regs_len)(struct net_device *); 962 void (*get_regs)(struct net_device *, struct ethtool_regs *, void *); 963 void (*get_wol)(struct net_device *, struct ethtool_wolinfo *); 964 int (*set_wol)(struct net_device *, struct ethtool_wolinfo *); 965 u32 (*get_msglevel)(struct net_device *); 966 void (*set_msglevel)(struct net_device *, u32); 967 int (*nway_reset)(struct net_device *); 968 u32 (*get_link)(struct net_device *); 969 int (*get_link_ext_state)(struct net_device *, 970 struct ethtool_link_ext_state_info *); 971 void (*get_link_ext_stats)(struct net_device *dev, 972 struct ethtool_link_ext_stats *stats); 973 int (*get_eeprom_len)(struct net_device *); 974 int (*get_eeprom)(struct net_device *, 975 struct ethtool_eeprom *, u8 *); 976 int (*set_eeprom)(struct net_device *, 977 struct ethtool_eeprom *, u8 *); 978 int (*get_coalesce)(struct net_device *, 979 struct ethtool_coalesce *, 980 struct kernel_ethtool_coalesce *, 981 struct netlink_ext_ack *); 982 int (*set_coalesce)(struct net_device *, 983 struct ethtool_coalesce *, 984 struct kernel_ethtool_coalesce *, 985 struct netlink_ext_ack *); 986 void (*get_ringparam)(struct net_device *, 987 struct ethtool_ringparam *, 988 struct kernel_ethtool_ringparam *, 989 struct netlink_ext_ack *); 990 int (*set_ringparam)(struct net_device *, 991 struct ethtool_ringparam *, 992 struct kernel_ethtool_ringparam *, 993 struct netlink_ext_ack *); 994 void (*get_pause_stats)(struct net_device *dev, 995 struct ethtool_pause_stats *pause_stats); 996 void (*get_pauseparam)(struct net_device *, 997 struct ethtool_pauseparam*); 998 int (*set_pauseparam)(struct net_device *, 999 struct ethtool_pauseparam*); 1000 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); 1001 void (*get_strings)(struct net_device *, u32 stringset, u8 *); 1002 int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state); 1003 void (*get_ethtool_stats)(struct net_device *, 1004 struct ethtool_stats *, u64 *); 1005 int (*begin)(struct net_device *); 1006 void (*complete)(struct net_device *); 1007 u32 (*get_priv_flags)(struct net_device *); 1008 int (*set_priv_flags)(struct net_device *, u32); 1009 int (*get_sset_count)(struct net_device *, int); 1010 int (*get_rxnfc)(struct net_device *, 1011 struct ethtool_rxnfc *, u32 *rule_locs); 1012 int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *); 1013 int (*flash_device)(struct net_device *, struct ethtool_flash *); 1014 int (*reset)(struct net_device *, u32 *); 1015 u32 (*get_rxfh_key_size)(struct net_device *); 1016 u32 (*get_rxfh_indir_size)(struct net_device *); 1017 int (*get_rxfh)(struct net_device *, struct ethtool_rxfh_param *); 1018 int (*set_rxfh)(struct net_device *, struct ethtool_rxfh_param *, 1019 struct netlink_ext_ack *extack); 1020 int (*create_rxfh_context)(struct net_device *, 1021 struct ethtool_rxfh_context *ctx, 1022 const struct ethtool_rxfh_param *rxfh, 1023 struct netlink_ext_ack *extack); 1024 int (*modify_rxfh_context)(struct net_device *, 1025 struct ethtool_rxfh_context *ctx, 1026 const struct ethtool_rxfh_param *rxfh, 1027 struct netlink_ext_ack *extack); 1028 int (*remove_rxfh_context)(struct net_device *, 1029 struct ethtool_rxfh_context *ctx, 1030 u32 rss_context, 1031 struct netlink_ext_ack *extack); 1032 void (*get_channels)(struct net_device *, struct ethtool_channels *); 1033 int (*set_channels)(struct net_device *, struct ethtool_channels *); 1034 int (*get_dump_flag)(struct net_device *, struct ethtool_dump *); 1035 int (*get_dump_data)(struct net_device *, 1036 struct ethtool_dump *, void *); 1037 int (*set_dump)(struct net_device *, struct ethtool_dump *); 1038 int (*get_ts_info)(struct net_device *, struct kernel_ethtool_ts_info *); 1039 void (*get_ts_stats)(struct net_device *dev, 1040 struct ethtool_ts_stats *ts_stats); 1041 int (*get_module_info)(struct net_device *, 1042 struct ethtool_modinfo *); 1043 int (*get_module_eeprom)(struct net_device *, 1044 struct ethtool_eeprom *, u8 *); 1045 int (*get_eee)(struct net_device *dev, struct ethtool_keee *eee); 1046 int (*set_eee)(struct net_device *dev, struct ethtool_keee *eee); 1047 int (*get_tunable)(struct net_device *, 1048 const struct ethtool_tunable *, void *); 1049 int (*set_tunable)(struct net_device *, 1050 const struct ethtool_tunable *, const void *); 1051 int (*get_per_queue_coalesce)(struct net_device *, u32, 1052 struct ethtool_coalesce *); 1053 int (*set_per_queue_coalesce)(struct net_device *, u32, 1054 struct ethtool_coalesce *); 1055 int (*get_link_ksettings)(struct net_device *, 1056 struct ethtool_link_ksettings *); 1057 int (*set_link_ksettings)(struct net_device *, 1058 const struct ethtool_link_ksettings *); 1059 void (*get_fec_stats)(struct net_device *dev, 1060 struct ethtool_fec_stats *fec_stats); 1061 int (*get_fecparam)(struct net_device *, 1062 struct ethtool_fecparam *); 1063 int (*set_fecparam)(struct net_device *, 1064 struct ethtool_fecparam *); 1065 void (*get_ethtool_phy_stats)(struct net_device *, 1066 struct ethtool_stats *, u64 *); 1067 int (*get_phy_tunable)(struct net_device *, 1068 const struct ethtool_tunable *, void *); 1069 int (*set_phy_tunable)(struct net_device *, 1070 const struct ethtool_tunable *, const void *); 1071 int (*get_module_eeprom_by_page)(struct net_device *dev, 1072 const struct ethtool_module_eeprom *page, 1073 struct netlink_ext_ack *extack); 1074 int (*set_module_eeprom_by_page)(struct net_device *dev, 1075 const struct ethtool_module_eeprom *page, 1076 struct netlink_ext_ack *extack); 1077 void (*get_eth_phy_stats)(struct net_device *dev, 1078 struct ethtool_eth_phy_stats *phy_stats); 1079 void (*get_eth_mac_stats)(struct net_device *dev, 1080 struct ethtool_eth_mac_stats *mac_stats); 1081 void (*get_eth_ctrl_stats)(struct net_device *dev, 1082 struct ethtool_eth_ctrl_stats *ctrl_stats); 1083 void (*get_rmon_stats)(struct net_device *dev, 1084 struct ethtool_rmon_stats *rmon_stats, 1085 const struct ethtool_rmon_hist_range **ranges); 1086 int (*get_module_power_mode)(struct net_device *dev, 1087 struct ethtool_module_power_mode_params *params, 1088 struct netlink_ext_ack *extack); 1089 int (*set_module_power_mode)(struct net_device *dev, 1090 const struct ethtool_module_power_mode_params *params, 1091 struct netlink_ext_ack *extack); 1092 int (*get_mm)(struct net_device *dev, struct ethtool_mm_state *state); 1093 int (*set_mm)(struct net_device *dev, struct ethtool_mm_cfg *cfg, 1094 struct netlink_ext_ack *extack); 1095 void (*get_mm_stats)(struct net_device *dev, struct ethtool_mm_stats *stats); 1096 }; 1097 1098 int ethtool_check_ops(const struct ethtool_ops *ops); 1099 1100 struct ethtool_rx_flow_rule { 1101 struct flow_rule *rule; 1102 unsigned long priv[]; 1103 }; 1104 1105 struct ethtool_rx_flow_spec_input { 1106 const struct ethtool_rx_flow_spec *fs; 1107 u32 rss_ctx; 1108 }; 1109 1110 struct ethtool_rx_flow_rule * 1111 ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input); 1112 void ethtool_rx_flow_rule_destroy(struct ethtool_rx_flow_rule *rule); 1113 1114 bool ethtool_virtdev_validate_cmd(const struct ethtool_link_ksettings *cmd); 1115 int ethtool_virtdev_set_link_ksettings(struct net_device *dev, 1116 const struct ethtool_link_ksettings *cmd, 1117 u32 *dev_speed, u8 *dev_duplex); 1118 1119 /** 1120 * struct ethtool_netdev_state - per-netdevice state for ethtool features 1121 * @rss_ctx: XArray of custom RSS contexts 1122 * @rss_lock: Protects entries in @rss_ctx. May be taken from 1123 * within RTNL. 1124 * @wol_enabled: Wake-on-LAN is enabled 1125 * @module_fw_flash_in_progress: Module firmware flashing is in progress. 1126 */ 1127 struct ethtool_netdev_state { 1128 struct xarray rss_ctx; 1129 struct mutex rss_lock; 1130 unsigned wol_enabled:1; 1131 unsigned module_fw_flash_in_progress:1; 1132 }; 1133 1134 struct phy_device; 1135 struct phy_tdr_config; 1136 struct phy_plca_cfg; 1137 struct phy_plca_status; 1138 1139 /** 1140 * struct ethtool_phy_ops - Optional PHY device options 1141 * @get_sset_count: Get number of strings that @get_strings will write. 1142 * @get_strings: Return a set of strings that describe the requested objects 1143 * @get_stats: Return extended statistics about the PHY device. 1144 * @get_plca_cfg: Return PLCA configuration. 1145 * @set_plca_cfg: Set PLCA configuration. 1146 * @get_plca_status: Get PLCA configuration. 1147 * @start_cable_test: Start a cable test 1148 * @start_cable_test_tdr: Start a Time Domain Reflectometry cable test 1149 * 1150 * All operations are optional (i.e. the function pointer may be set to %NULL) 1151 * and callers must take this into account. Callers must hold the RTNL lock. 1152 */ 1153 struct ethtool_phy_ops { 1154 int (*get_sset_count)(struct phy_device *dev); 1155 int (*get_strings)(struct phy_device *dev, u8 *data); 1156 int (*get_stats)(struct phy_device *dev, 1157 struct ethtool_stats *stats, u64 *data); 1158 int (*get_plca_cfg)(struct phy_device *dev, 1159 struct phy_plca_cfg *plca_cfg); 1160 int (*set_plca_cfg)(struct phy_device *dev, 1161 const struct phy_plca_cfg *plca_cfg, 1162 struct netlink_ext_ack *extack); 1163 int (*get_plca_status)(struct phy_device *dev, 1164 struct phy_plca_status *plca_st); 1165 int (*start_cable_test)(struct phy_device *phydev, 1166 struct netlink_ext_ack *extack); 1167 int (*start_cable_test_tdr)(struct phy_device *phydev, 1168 struct netlink_ext_ack *extack, 1169 const struct phy_tdr_config *config); 1170 }; 1171 1172 /** 1173 * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton 1174 * @ops: Ethtool PHY operations to set 1175 */ 1176 void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops); 1177 1178 /** 1179 * ethtool_params_from_link_mode - Derive link parameters from a given link mode 1180 * @link_ksettings: Link parameters to be derived from the link mode 1181 * @link_mode: Link mode 1182 */ 1183 void 1184 ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings, 1185 enum ethtool_link_mode_bit_indices link_mode); 1186 1187 /** 1188 * ethtool_get_phc_vclocks - Derive phc vclocks information, and caller 1189 * is responsible to free memory of vclock_index 1190 * @dev: pointer to net_device structure 1191 * @vclock_index: pointer to pointer of vclock index 1192 * 1193 * Return number of phc vclocks 1194 */ 1195 int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index); 1196 1197 /* Some generic methods drivers may use in their ethtool_ops */ 1198 u32 ethtool_op_get_link(struct net_device *dev); 1199 int ethtool_op_get_ts_info(struct net_device *dev, 1200 struct kernel_ethtool_ts_info *eti); 1201 1202 /** 1203 * ethtool_mm_frag_size_add_to_min - Translate (standard) additional fragment 1204 * size expressed as multiplier into (absolute) minimum fragment size 1205 * value expressed in octets 1206 * @val_add: Value of addFragSize multiplier 1207 */ 1208 static inline u32 ethtool_mm_frag_size_add_to_min(u32 val_add) 1209 { 1210 return (ETH_ZLEN + ETH_FCS_LEN) * (1 + val_add) - ETH_FCS_LEN; 1211 } 1212 1213 /** 1214 * ethtool_mm_frag_size_min_to_add - Translate (absolute) minimum fragment size 1215 * expressed in octets into (standard) additional fragment size expressed 1216 * as multiplier 1217 * @val_min: Value of addFragSize variable in octets 1218 * @val_add: Pointer where the standard addFragSize value is to be returned 1219 * @extack: Netlink extended ack 1220 * 1221 * Translate a value in octets to one of 0, 1, 2, 3 according to the reverse 1222 * application of the 802.3 formula 64 * (1 + addFragSize) - 4. To be called 1223 * by drivers which do not support programming the minimum fragment size to a 1224 * continuous range. Returns error on other fragment length values. 1225 */ 1226 static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add, 1227 struct netlink_ext_ack *extack) 1228 { 1229 u32 add_frag_size; 1230 1231 for (add_frag_size = 0; add_frag_size < 4; add_frag_size++) { 1232 if (ethtool_mm_frag_size_add_to_min(add_frag_size) == val_min) { 1233 *val_add = add_frag_size; 1234 return 0; 1235 } 1236 } 1237 1238 NL_SET_ERR_MSG_MOD(extack, 1239 "minFragSize required to be one of 60, 124, 188 or 252"); 1240 return -EINVAL; 1241 } 1242 1243 /** 1244 * ethtool_get_ts_info_by_layer - Obtains time stamping capabilities from the MAC or PHY layer. 1245 * @dev: pointer to net_device structure 1246 * @info: buffer to hold the result 1247 * Returns zero on success, non-zero otherwise. 1248 */ 1249 int ethtool_get_ts_info_by_layer(struct net_device *dev, 1250 struct kernel_ethtool_ts_info *info); 1251 1252 /** 1253 * ethtool_sprintf - Write formatted string to ethtool string data 1254 * @data: Pointer to a pointer to the start of string to update 1255 * @fmt: Format of string to write 1256 * 1257 * Write formatted string to *data. Update *data to point at start of 1258 * next string. 1259 */ 1260 extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...); 1261 1262 /** 1263 * ethtool_puts - Write string to ethtool string data 1264 * @data: Pointer to a pointer to the start of string to update 1265 * @str: String to write 1266 * 1267 * Write string to *data without a trailing newline. Update *data 1268 * to point at start of next string. 1269 * 1270 * Prefer this function to ethtool_sprintf() when given only 1271 * two arguments or if @fmt is just "%s". 1272 */ 1273 extern void ethtool_puts(u8 **data, const char *str); 1274 1275 /* Link mode to forced speed capabilities maps */ 1276 struct ethtool_forced_speed_map { 1277 u32 speed; 1278 __ETHTOOL_DECLARE_LINK_MODE_MASK(caps); 1279 1280 const u32 *cap_arr; 1281 u32 arr_size; 1282 }; 1283 1284 #define ETHTOOL_FORCED_SPEED_MAP(prefix, value) \ 1285 { \ 1286 .speed = SPEED_##value, \ 1287 .cap_arr = prefix##_##value, \ 1288 .arr_size = ARRAY_SIZE(prefix##_##value), \ 1289 } 1290 1291 void 1292 ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size); 1293 1294 /* C33 PSE extended state and substate. */ 1295 struct ethtool_c33_pse_ext_state_info { 1296 enum ethtool_c33_pse_ext_state c33_pse_ext_state; 1297 union { 1298 enum ethtool_c33_pse_ext_substate_error_condition error_condition; 1299 enum ethtool_c33_pse_ext_substate_mr_pse_enable mr_pse_enable; 1300 enum ethtool_c33_pse_ext_substate_option_detect_ted option_detect_ted; 1301 enum ethtool_c33_pse_ext_substate_option_vport_lim option_vport_lim; 1302 enum ethtool_c33_pse_ext_substate_ovld_detected ovld_detected; 1303 enum ethtool_c33_pse_ext_substate_power_not_available power_not_available; 1304 enum ethtool_c33_pse_ext_substate_short_detected short_detected; 1305 u32 __c33_pse_ext_substate; 1306 }; 1307 }; 1308 1309 struct ethtool_c33_pse_pw_limit_range { 1310 u32 min; 1311 u32 max; 1312 }; 1313 #endif /* _LINUX_ETHTOOL_H */ 1314
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.