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