Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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