aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ethtool.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ethtool.h')
-rw-r--r--include/linux/ethtool.h616
1 files changed, 499 insertions, 117 deletions
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 991269e5b152..439b173c5882 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -13,14 +13,21 @@
13#ifndef _LINUX_ETHTOOL_H 13#ifndef _LINUX_ETHTOOL_H
14#define _LINUX_ETHTOOL_H 14#define _LINUX_ETHTOOL_H
15 15
16#ifdef __KERNEL__
17#include <linux/compat.h>
18#endif
16#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/if_ether.h>
17 21
18/* This should work for both 32 and 64 bit userland. */ 22/* This should work for both 32 and 64 bit userland. */
19struct ethtool_cmd { 23struct ethtool_cmd {
20 __u32 cmd; 24 __u32 cmd;
21 __u32 supported; /* Features this interface supports */ 25 __u32 supported; /* Features this interface supports */
22 __u32 advertising; /* Features this interface advertises */ 26 __u32 advertising; /* Features this interface advertises */
23 __u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */ 27 __u16 speed; /* The forced speed (lower bits) in
28 * Mbps. Please use
29 * ethtool_cmd_speed()/_set() to
30 * access it */
24 __u8 duplex; /* Duplex, half or full */ 31 __u8 duplex; /* Duplex, half or full */
25 __u8 port; /* Which connector port */ 32 __u8 port; /* Which connector port */
26 __u8 phy_address; 33 __u8 phy_address;
@@ -29,7 +36,10 @@ struct ethtool_cmd {
29 __u8 mdio_support; 36 __u8 mdio_support;
30 __u32 maxtxpkt; /* Tx pkts before generating tx int */ 37 __u32 maxtxpkt; /* Tx pkts before generating tx int */
31 __u32 maxrxpkt; /* Rx pkts before generating rx int */ 38 __u32 maxrxpkt; /* Rx pkts before generating rx int */
32 __u16 speed_hi; 39 __u16 speed_hi; /* The forced speed (upper
40 * bits) in Mbps. Please use
41 * ethtool_cmd_speed()/_set() to
42 * access it */
33 __u8 eth_tp_mdix; 43 __u8 eth_tp_mdix;
34 __u8 reserved2; 44 __u8 reserved2;
35 __u32 lp_advertising; /* Features the link partner advertises */ 45 __u32 lp_advertising; /* Features the link partner advertises */
@@ -37,14 +47,14 @@ struct ethtool_cmd {
37}; 47};
38 48
39static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, 49static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
40 __u32 speed) 50 __u32 speed)
41{ 51{
42 52
43 ep->speed = (__u16)speed; 53 ep->speed = (__u16)speed;
44 ep->speed_hi = (__u16)(speed >> 16); 54 ep->speed_hi = (__u16)(speed >> 16);
45} 55}
46 56
47static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep) 57static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
48{ 58{
49 return (ep->speed_hi << 16) | ep->speed; 59 return (ep->speed_hi << 16) | ep->speed;
50} 60}
@@ -225,12 +235,40 @@ struct ethtool_ringparam {
225 __u32 tx_pending; 235 __u32 tx_pending;
226}; 236};
227 237
238/**
239 * struct ethtool_channels - configuring number of network channel
240 * @cmd: ETHTOOL_{G,S}CHANNELS
241 * @max_rx: Read only. Maximum number of receive channel the driver support.
242 * @max_tx: Read only. Maximum number of transmit channel the driver support.
243 * @max_other: Read only. Maximum number of other channel the driver support.
244 * @max_combined: Read only. Maximum number of combined channel the driver
245 * support. Set of queues RX, TX or other.
246 * @rx_count: Valid values are in the range 1 to the max_rx.
247 * @tx_count: Valid values are in the range 1 to the max_tx.
248 * @other_count: Valid values are in the range 1 to the max_other.
249 * @combined_count: Valid values are in the range 1 to the max_combined.
250 *
251 * This can be used to configure RX, TX and other channels.
252 */
253
254struct ethtool_channels {
255 __u32 cmd;
256 __u32 max_rx;
257 __u32 max_tx;
258 __u32 max_other;
259 __u32 max_combined;
260 __u32 rx_count;
261 __u32 tx_count;
262 __u32 other_count;
263 __u32 combined_count;
264};
265
228/* for configuring link flow control parameters */ 266/* for configuring link flow control parameters */
229struct ethtool_pauseparam { 267struct ethtool_pauseparam {
230 __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */ 268 __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
231 269
232 /* If the link is being auto-negotiated (via ethtool_cmd.autoneg 270 /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
233 * being true) the user may set 'autonet' here non-zero to have the 271 * being true) the user may set 'autoneg' here non-zero to have the
234 * pause parameters be auto-negotiated too. In such a case, the 272 * pause parameters be auto-negotiated too. In such a case, the
235 * {rx,tx}_pause values below determine what capabilities are 273 * {rx,tx}_pause values below determine what capabilities are
236 * advertised. 274 * advertised.
@@ -250,6 +288,7 @@ enum ethtool_stringset {
250 ETH_SS_STATS, 288 ETH_SS_STATS,
251 ETH_SS_PRIV_FLAGS, 289 ETH_SS_PRIV_FLAGS,
252 ETH_SS_NTUPLE_FILTERS, 290 ETH_SS_NTUPLE_FILTERS,
291 ETH_SS_FEATURES,
253}; 292};
254 293
255/* for passing string sets for data tagging */ 294/* for passing string sets for data tagging */
@@ -308,15 +347,28 @@ struct ethtool_perm_addr {
308 * flag differs from the read-only value. 347 * flag differs from the read-only value.
309 */ 348 */
310enum ethtool_flags { 349enum ethtool_flags {
350 ETH_FLAG_TXVLAN = (1 << 7), /* TX VLAN offload enabled */
351 ETH_FLAG_RXVLAN = (1 << 8), /* RX VLAN offload enabled */
311 ETH_FLAG_LRO = (1 << 15), /* LRO is enabled */ 352 ETH_FLAG_LRO = (1 << 15), /* LRO is enabled */
312 ETH_FLAG_NTUPLE = (1 << 27), /* N-tuple filters enabled */ 353 ETH_FLAG_NTUPLE = (1 << 27), /* N-tuple filters enabled */
313 ETH_FLAG_RXHASH = (1 << 28), 354 ETH_FLAG_RXHASH = (1 << 28),
314}; 355};
315 356
316/* The following structures are for supporting RX network flow 357/* The following structures are for supporting RX network flow
317 * classification configuration. Note, all multibyte fields, e.g., 358 * classification and RX n-tuple configuration. Note, all multibyte
318 * ip4src, ip4dst, psrc, pdst, spi, etc. are expected to be in network 359 * fields, e.g., ip4src, ip4dst, psrc, pdst, spi, etc. are expected to
319 * byte order. 360 * be in network byte order.
361 */
362
363/**
364 * struct ethtool_tcpip4_spec - flow specification for TCP/IPv4 etc.
365 * @ip4src: Source host
366 * @ip4dst: Destination host
367 * @psrc: Source port
368 * @pdst: Destination port
369 * @tos: Type-of-service
370 *
371 * This can be used to specify a TCP/IPv4, UDP/IPv4 or SCTP/IPv4 flow.
320 */ 372 */
321struct ethtool_tcpip4_spec { 373struct ethtool_tcpip4_spec {
322 __be32 ip4src; 374 __be32 ip4src;
@@ -326,6 +378,15 @@ struct ethtool_tcpip4_spec {
326 __u8 tos; 378 __u8 tos;
327}; 379};
328 380
381/**
382 * struct ethtool_ah_espip4_spec - flow specification for IPsec/IPv4
383 * @ip4src: Source host
384 * @ip4dst: Destination host
385 * @spi: Security parameters index
386 * @tos: Type-of-service
387 *
388 * This can be used to specify an IPsec transport or tunnel over IPv4.
389 */
329struct ethtool_ah_espip4_spec { 390struct ethtool_ah_espip4_spec {
330 __be32 ip4src; 391 __be32 ip4src;
331 __be32 ip4dst; 392 __be32 ip4dst;
@@ -333,21 +394,17 @@ struct ethtool_ah_espip4_spec {
333 __u8 tos; 394 __u8 tos;
334}; 395};
335 396
336struct ethtool_rawip4_spec {
337 __be32 ip4src;
338 __be32 ip4dst;
339 __u8 hdata[64];
340};
341
342struct ethtool_ether_spec {
343 __be16 ether_type;
344 __u8 frame_size;
345 __u8 eframe[16];
346};
347
348#define ETH_RX_NFC_IP4 1 397#define ETH_RX_NFC_IP4 1
349#define ETH_RX_NFC_IP6 2
350 398
399/**
400 * struct ethtool_usrip4_spec - general flow specification for IPv4
401 * @ip4src: Source host
402 * @ip4dst: Destination host
403 * @l4_4_bytes: First 4 bytes of transport (layer 4) header
404 * @tos: Type-of-service
405 * @ip_ver: Value must be %ETH_RX_NFC_IP4; mask must be 0
406 * @proto: Transport protocol number; mask must be 0
407 */
351struct ethtool_usrip4_spec { 408struct ethtool_usrip4_spec {
352 __be32 ip4src; 409 __be32 ip4src;
353 __be32 ip4dst; 410 __be32 ip4dst;
@@ -357,44 +414,148 @@ struct ethtool_usrip4_spec {
357 __u8 proto; 414 __u8 proto;
358}; 415};
359 416
417union ethtool_flow_union {
418 struct ethtool_tcpip4_spec tcp_ip4_spec;
419 struct ethtool_tcpip4_spec udp_ip4_spec;
420 struct ethtool_tcpip4_spec sctp_ip4_spec;
421 struct ethtool_ah_espip4_spec ah_ip4_spec;
422 struct ethtool_ah_espip4_spec esp_ip4_spec;
423 struct ethtool_usrip4_spec usr_ip4_spec;
424 struct ethhdr ether_spec;
425 __u8 hdata[60];
426};
427
428struct ethtool_flow_ext {
429 __be16 vlan_etype;
430 __be16 vlan_tci;
431 __be32 data[2];
432};
433
434/**
435 * struct ethtool_rx_flow_spec - specification for RX flow filter
436 * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
437 * @h_u: Flow fields to match (dependent on @flow_type)
438 * @h_ext: Additional fields to match
439 * @m_u: Masks for flow field bits to be matched
440 * @m_ext: Masks for additional field bits to be matched
441 * Note, all additional fields must be ignored unless @flow_type
442 * includes the %FLOW_EXT flag.
443 * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC
444 * if packets should be discarded
445 * @location: Index of filter in hardware table
446 */
360struct ethtool_rx_flow_spec { 447struct ethtool_rx_flow_spec {
361 __u32 flow_type; 448 __u32 flow_type;
362 union { 449 union ethtool_flow_union h_u;
363 struct ethtool_tcpip4_spec tcp_ip4_spec; 450 struct ethtool_flow_ext h_ext;
364 struct ethtool_tcpip4_spec udp_ip4_spec; 451 union ethtool_flow_union m_u;
365 struct ethtool_tcpip4_spec sctp_ip4_spec; 452 struct ethtool_flow_ext m_ext;
366 struct ethtool_ah_espip4_spec ah_ip4_spec;
367 struct ethtool_ah_espip4_spec esp_ip4_spec;
368 struct ethtool_rawip4_spec raw_ip4_spec;
369 struct ethtool_ether_spec ether_spec;
370 struct ethtool_usrip4_spec usr_ip4_spec;
371 __u8 hdata[64];
372 } h_u, m_u; /* entry, mask */
373 __u64 ring_cookie; 453 __u64 ring_cookie;
374 __u32 location; 454 __u32 location;
375}; 455};
376 456
457/**
458 * struct ethtool_rxnfc - command to get or set RX flow classification rules
459 * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,
460 * %ETHTOOL_GRXRINGS, %ETHTOOL_GRXCLSRLCNT, %ETHTOOL_GRXCLSRULE,
461 * %ETHTOOL_GRXCLSRLALL, %ETHTOOL_SRXCLSRLDEL or %ETHTOOL_SRXCLSRLINS
462 * @flow_type: Type of flow to be affected, e.g. %TCP_V4_FLOW
463 * @data: Command-dependent value
464 * @fs: Flow filter specification
465 * @rule_cnt: Number of rules to be affected
466 * @rule_locs: Array of valid rule indices
467 *
468 * For %ETHTOOL_GRXFH and %ETHTOOL_SRXFH, @data is a bitmask indicating
469 * the fields included in the flow hash, e.g. %RXH_IP_SRC. The following
470 * structure fields must not be used.
471 *
472 * For %ETHTOOL_GRXRINGS, @data is set to the number of RX rings/queues
473 * on return.
474 *
475 * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined
476 * rules on return.
477 *
478 * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the index of an
479 * existing filter rule on entry and @fs contains the rule on return.
480 *
481 * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the
482 * user buffer for @rule_locs on entry. On return, @data is the size
483 * of the filter table and @rule_locs contains the indices of the
484 * defined rules.
485 *
486 * For %ETHTOOL_SRXCLSRLINS, @fs specifies the filter rule to add or
487 * update. @fs.@location specifies the index to use and must not be
488 * ignored.
489 *
490 * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the index of an
491 * existing filter rule on entry.
492 *
493 * Implementation of indexed classification rules generally requires a
494 * TCAM.
495 */
377struct ethtool_rxnfc { 496struct ethtool_rxnfc {
378 __u32 cmd; 497 __u32 cmd;
379 __u32 flow_type; 498 __u32 flow_type;
380 /* The rx flow hash value or the rule DB size */
381 __u64 data; 499 __u64 data;
382 /* The following fields are not valid and must not be used for
383 * the ETHTOOL_{G,X}RXFH commands. */
384 struct ethtool_rx_flow_spec fs; 500 struct ethtool_rx_flow_spec fs;
385 __u32 rule_cnt; 501 __u32 rule_cnt;
386 __u32 rule_locs[0]; 502 __u32 rule_locs[0];
387}; 503};
388 504
505#ifdef __KERNEL__
506#ifdef CONFIG_COMPAT
507
508struct compat_ethtool_rx_flow_spec {
509 u32 flow_type;
510 union ethtool_flow_union h_u;
511 struct ethtool_flow_ext h_ext;
512 union ethtool_flow_union m_u;
513 struct ethtool_flow_ext m_ext;
514 compat_u64 ring_cookie;
515 u32 location;
516};
517
518struct compat_ethtool_rxnfc {
519 u32 cmd;
520 u32 flow_type;
521 compat_u64 data;
522 struct compat_ethtool_rx_flow_spec fs;
523 u32 rule_cnt;
524 u32 rule_locs[0];
525};
526
527#endif /* CONFIG_COMPAT */
528#endif /* __KERNEL__ */
529
530/**
531 * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection
532 * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR
533 * @size: On entry, the array size of the user buffer. On return from
534 * %ETHTOOL_GRXFHINDIR, the array size of the hardware indirection table.
535 * @ring_index: RX ring/queue index for each hash value
536 */
389struct ethtool_rxfh_indir { 537struct ethtool_rxfh_indir {
390 __u32 cmd; 538 __u32 cmd;
391 /* On entry, this is the array size of the user buffer. On
392 * return from ETHTOOL_GRXFHINDIR, this is the array size of
393 * the hardware indirection table. */
394 __u32 size; 539 __u32 size;
395 __u32 ring_index[0]; /* ring/queue index for each hash value */ 540 __u32 ring_index[0];
396}; 541};
397 542
543/**
544 * struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter
545 * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
546 * @h_u: Flow field values to match (dependent on @flow_type)
547 * @m_u: Masks for flow field value bits to be ignored
548 * @vlan_tag: VLAN tag to match
549 * @vlan_tag_mask: Mask for VLAN tag bits to be ignored
550 * @data: Driver-dependent data to match
551 * @data_mask: Mask for driver-dependent data bits to be ignored
552 * @action: RX ring/queue index to deliver to (non-negative) or other action
553 * (negative, e.g. %ETHTOOL_RXNTUPLE_ACTION_DROP)
554 *
555 * For flow types %TCP_V4_FLOW, %UDP_V4_FLOW and %SCTP_V4_FLOW, where
556 * a field value and mask are both zero this is treated as if all mask
557 * bits are set i.e. the field is ignored.
558 */
398struct ethtool_rx_ntuple_flow_spec { 559struct ethtool_rx_ntuple_flow_spec {
399 __u32 flow_type; 560 __u32 flow_type;
400 union { 561 union {
@@ -403,22 +564,26 @@ struct ethtool_rx_ntuple_flow_spec {
403 struct ethtool_tcpip4_spec sctp_ip4_spec; 564 struct ethtool_tcpip4_spec sctp_ip4_spec;
404 struct ethtool_ah_espip4_spec ah_ip4_spec; 565 struct ethtool_ah_espip4_spec ah_ip4_spec;
405 struct ethtool_ah_espip4_spec esp_ip4_spec; 566 struct ethtool_ah_espip4_spec esp_ip4_spec;
406 struct ethtool_rawip4_spec raw_ip4_spec;
407 struct ethtool_ether_spec ether_spec;
408 struct ethtool_usrip4_spec usr_ip4_spec; 567 struct ethtool_usrip4_spec usr_ip4_spec;
409 __u8 hdata[64]; 568 struct ethhdr ether_spec;
410 } h_u, m_u; /* entry, mask */ 569 __u8 hdata[72];
570 } h_u, m_u;
411 571
412 __u16 vlan_tag; 572 __u16 vlan_tag;
413 __u16 vlan_tag_mask; 573 __u16 vlan_tag_mask;
414 __u64 data; /* user-defined flow spec data */ 574 __u64 data;
415 __u64 data_mask; /* user-defined flow spec mask */ 575 __u64 data_mask;
416 576
417 /* signed to distinguish between queue and actions (DROP) */
418 __s32 action; 577 __s32 action;
419#define ETHTOOL_RXNTUPLE_ACTION_DROP -1 578#define ETHTOOL_RXNTUPLE_ACTION_DROP (-1) /* drop packet */
579#define ETHTOOL_RXNTUPLE_ACTION_CLEAR (-2) /* clear filter */
420}; 580};
421 581
582/**
583 * struct ethtool_rx_ntuple - command to set or clear RX flow filter
584 * @cmd: Command number - %ETHTOOL_SRXNTUPLE
585 * @fs: Flow filter specification
586 */
422struct ethtool_rx_ntuple { 587struct ethtool_rx_ntuple {
423 __u32 cmd; 588 __u32 cmd;
424 struct ethtool_rx_ntuple_flow_spec fs; 589 struct ethtool_rx_ntuple_flow_spec fs;
@@ -436,10 +601,119 @@ struct ethtool_flash {
436 char data[ETHTOOL_FLASH_MAX_FILENAME]; 601 char data[ETHTOOL_FLASH_MAX_FILENAME];
437}; 602};
438 603
604/**
605 * struct ethtool_dump - used for retrieving, setting device dump
606 * @cmd: Command number - %ETHTOOL_GET_DUMP_FLAG, %ETHTOOL_GET_DUMP_DATA, or
607 * %ETHTOOL_SET_DUMP
608 * @version: FW version of the dump, filled in by driver
609 * @flag: driver dependent flag for dump setting, filled in by driver during
610 * get and filled in by ethtool for set operation
611 * @len: length of dump data, used as the length of the user buffer on entry to
612 * %ETHTOOL_GET_DUMP_DATA and this is returned as dump length by driver
613 * for %ETHTOOL_GET_DUMP_FLAG command
614 * @data: data collected for get dump data operation
615 */
616struct ethtool_dump {
617 __u32 cmd;
618 __u32 version;
619 __u32 flag;
620 __u32 len;
621 __u8 data[0];
622};
623
624/* for returning and changing feature sets */
625
626/**
627 * struct ethtool_get_features_block - block with state of 32 features
628 * @available: mask of changeable features
629 * @requested: mask of features requested to be enabled if possible
630 * @active: mask of currently enabled features
631 * @never_changed: mask of features not changeable for any device
632 */
633struct ethtool_get_features_block {
634 __u32 available;
635 __u32 requested;
636 __u32 active;
637 __u32 never_changed;
638};
639
640/**
641 * struct ethtool_gfeatures - command to get state of device's features
642 * @cmd: command number = %ETHTOOL_GFEATURES
643 * @size: in: number of elements in the features[] array;
644 * out: number of elements in features[] needed to hold all features
645 * @features: state of features
646 */
647struct ethtool_gfeatures {
648 __u32 cmd;
649 __u32 size;
650 struct ethtool_get_features_block features[0];
651};
652
653/**
654 * struct ethtool_set_features_block - block with request for 32 features
655 * @valid: mask of features to be changed
656 * @requested: values of features to be changed
657 */
658struct ethtool_set_features_block {
659 __u32 valid;
660 __u32 requested;
661};
662
663/**
664 * struct ethtool_sfeatures - command to request change in device's features
665 * @cmd: command number = %ETHTOOL_SFEATURES
666 * @size: array size of the features[] array
667 * @features: feature change masks
668 */
669struct ethtool_sfeatures {
670 __u32 cmd;
671 __u32 size;
672 struct ethtool_set_features_block features[0];
673};
674
675/*
676 * %ETHTOOL_SFEATURES changes features present in features[].valid to the
677 * values of corresponding bits in features[].requested. Bits in .requested
678 * not set in .valid or not changeable are ignored.
679 *
680 * Returns %EINVAL when .valid contains undefined or never-changeable bits
681 * or size is not equal to required number of features words (32-bit blocks).
682 * Returns >= 0 if request was completed; bits set in the value mean:
683 * %ETHTOOL_F_UNSUPPORTED - there were bits set in .valid that are not
684 * changeable (not present in %ETHTOOL_GFEATURES' features[].available)
685 * those bits were ignored.
686 * %ETHTOOL_F_WISH - some or all changes requested were recorded but the
687 * resulting state of bits masked by .valid is not equal to .requested.
688 * Probably there are other device-specific constraints on some features
689 * in the set. When %ETHTOOL_F_UNSUPPORTED is set, .valid is considered
690 * here as though ignored bits were cleared.
691 * %ETHTOOL_F_COMPAT - some or all changes requested were made by calling
692 * compatibility functions. Requested offload state cannot be properly
693 * managed by kernel.
694 *
695 * Meaning of bits in the masks are obtained by %ETHTOOL_GSSET_INFO (number of
696 * bits in the arrays - always multiple of 32) and %ETHTOOL_GSTRINGS commands
697 * for ETH_SS_FEATURES string set. First entry in the table corresponds to least
698 * significant bit in features[0] fields. Empty strings mark undefined features.
699 */
700enum ethtool_sfeatures_retval_bits {
701 ETHTOOL_F_UNSUPPORTED__BIT,
702 ETHTOOL_F_WISH__BIT,
703 ETHTOOL_F_COMPAT__BIT,
704};
705
706#define ETHTOOL_F_UNSUPPORTED (1 << ETHTOOL_F_UNSUPPORTED__BIT)
707#define ETHTOOL_F_WISH (1 << ETHTOOL_F_WISH__BIT)
708#define ETHTOOL_F_COMPAT (1 << ETHTOOL_F_COMPAT__BIT)
709
439#ifdef __KERNEL__ 710#ifdef __KERNEL__
440 711
441#include <linux/rculist.h> 712#include <linux/rculist.h>
442 713
714/* needed by dev_disable_lro() */
715extern int __ethtool_set_flags(struct net_device *dev, u32 flags);
716
443struct ethtool_rx_ntuple_flow_spec_container { 717struct ethtool_rx_ntuple_flow_spec_container {
444 struct ethtool_rx_ntuple_flow_spec fs; 718 struct ethtool_rx_ntuple_flow_spec fs;
445 struct list_head list; 719 struct list_head list;
@@ -452,11 +726,26 @@ struct ethtool_rx_ntuple_list {
452 unsigned int count; 726 unsigned int count;
453}; 727};
454 728
729/**
730 * enum ethtool_phys_id_state - indicator state for physical identification
731 * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
732 * @ETHTOOL_ID_ACTIVE: Physical ID indicator should be activated
733 * @ETHTOOL_ID_ON: LED should be turned on (used iff %ETHTOOL_ID_ACTIVE
734 * is not supported)
735 * @ETHTOOL_ID_OFF: LED should be turned off (used iff %ETHTOOL_ID_ACTIVE
736 * is not supported)
737 */
738enum ethtool_phys_id_state {
739 ETHTOOL_ID_INACTIVE,
740 ETHTOOL_ID_ACTIVE,
741 ETHTOOL_ID_ON,
742 ETHTOOL_ID_OFF
743};
744
455struct net_device; 745struct net_device;
456 746
457/* Some generic methods drivers may use in their ethtool_ops */ 747/* Some generic methods drivers may use in their ethtool_ops */
458u32 ethtool_op_get_link(struct net_device *dev); 748u32 ethtool_op_get_link(struct net_device *dev);
459u32 ethtool_op_get_rx_csum(struct net_device *dev);
460u32 ethtool_op_get_tx_csum(struct net_device *dev); 749u32 ethtool_op_get_tx_csum(struct net_device *dev);
461int ethtool_op_set_tx_csum(struct net_device *dev, u32 data); 750int ethtool_op_set_tx_csum(struct net_device *dev, u32 data);
462int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data); 751int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data);
@@ -470,65 +759,134 @@ int ethtool_op_set_ufo(struct net_device *dev, u32 data);
470u32 ethtool_op_get_flags(struct net_device *dev); 759u32 ethtool_op_get_flags(struct net_device *dev);
471int ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported); 760int ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported);
472void ethtool_ntuple_flush(struct net_device *dev); 761void ethtool_ntuple_flush(struct net_device *dev);
762bool ethtool_invalid_flags(struct net_device *dev, u32 data, u32 supported);
473 763
474/** 764/**
475 * &ethtool_ops - Alter and report network device settings 765 * struct ethtool_ops - optional netdev operations
476 * get_settings: Get device-specific settings 766 * @get_settings: Get various device settings including Ethernet link
477 * set_settings: Set device-specific settings 767 * settings. The @cmd parameter is expected to have been cleared
478 * get_drvinfo: Report driver information 768 * before get_settings is called. Returns a negative error code or
479 * get_regs: Get device registers 769 * zero.
480 * get_wol: Report whether Wake-on-Lan is enabled 770 * @set_settings: Set various device settings including Ethernet link
481 * set_wol: Turn Wake-on-Lan on or off 771 * settings. Returns a negative error code or zero.
482 * get_msglevel: Report driver message level 772 * @get_drvinfo: Report driver/device information. Should only set the
483 * set_msglevel: Set driver message level 773 * @driver, @version, @fw_version and @bus_info fields. If not
484 * nway_reset: Restart autonegotiation 774 * implemented, the @driver and @bus_info fields will be filled in
485 * get_link: Get link status 775 * according to the netdev's parent device.
486 * get_eeprom: Read data from the device EEPROM 776 * @get_regs_len: Get buffer length required for @get_regs
487 * set_eeprom: Write data to the device EEPROM 777 * @get_regs: Get device registers
488 * get_coalesce: Get interrupt coalescing parameters 778 * @get_wol: Report whether Wake-on-Lan is enabled
489 * set_coalesce: Set interrupt coalescing parameters 779 * @set_wol: Turn Wake-on-Lan on or off. Returns a negative error code
490 * get_ringparam: Report ring sizes 780 * or zero.
491 * set_ringparam: Set ring sizes 781 * @get_msglevel: Report driver message level. This should be the value
492 * get_pauseparam: Report pause parameters 782 * of the @msg_enable field used by netif logging functions.
493 * set_pauseparam: Set pause parameters 783 * @set_msglevel: Set driver message level
494 * get_rx_csum: Report whether receive checksums are turned on or off 784 * @nway_reset: Restart autonegotiation. Returns a negative error code
495 * set_rx_csum: Turn receive checksum on or off 785 * or zero.
496 * get_tx_csum: Report whether transmit checksums are turned on or off 786 * @get_link: Report whether physical link is up. Will only be called if
497 * set_tx_csum: Turn transmit checksums on or off 787 * the netdev is up. Should usually be set to ethtool_op_get_link(),
498 * get_sg: Report whether scatter-gather is enabled 788 * which uses netif_carrier_ok().
499 * set_sg: Turn scatter-gather on or off 789 * @get_eeprom: Read data from the device EEPROM.
500 * get_tso: Report whether TCP segmentation offload is enabled
501 * set_tso: Turn TCP segmentation offload on or off
502 * get_ufo: Report whether UDP fragmentation offload is enabled
503 * set_ufo: Turn UDP fragmentation offload on or off
504 * self_test: Run specified self-tests
505 * get_strings: Return a set of strings that describe the requested objects
506 * phys_id: Identify the device
507 * get_stats: Return statistics about the device
508 * get_flags: get 32-bit flags bitmap
509 * set_flags: set 32-bit flags bitmap
510 *
511 * Description:
512 *
513 * get_settings:
514 * @get_settings is passed an &ethtool_cmd to fill in. It returns
515 * an negative errno or zero.
516 *
517 * set_settings:
518 * @set_settings is passed an &ethtool_cmd and should attempt to set
519 * all the settings this device supports. It may return an error value
520 * if something goes wrong (otherwise 0).
521 *
522 * get_eeprom:
523 * Should fill in the magic field. Don't need to check len for zero 790 * Should fill in the magic field. Don't need to check len for zero
524 * or wraparound. Fill in the data argument with the eeprom values 791 * or wraparound. Fill in the data argument with the eeprom values
525 * from offset to offset + len. Update len to the amount read. 792 * from offset to offset + len. Update len to the amount read.
526 * Returns an error or zero. 793 * Returns an error or zero.
527 * 794 * @set_eeprom: Write data to the device EEPROM.
528 * set_eeprom:
529 * Should validate the magic field. Don't need to check len for zero 795 * Should validate the magic field. Don't need to check len for zero
530 * or wraparound. Update len to the amount written. Returns an error 796 * or wraparound. Update len to the amount written. Returns an error
531 * or zero. 797 * or zero.
798 * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
799 * error code or zero.
800 * @set_coalesce: Set interrupt coalescing parameters. Returns a negative
801 * error code or zero.
802 * @get_ringparam: Report ring sizes
803 * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
804 * @get_pauseparam: Report pause parameters
805 * @set_pauseparam: Set pause parameters. Returns a negative error code
806 * or zero.
807 * @get_rx_csum: Deprecated in favour of the netdev feature %NETIF_F_RXCSUM.
808 * Report whether receive checksums are turned on or off.
809 * @set_rx_csum: Deprecated in favour of generic netdev features. Turn
810 * receive checksum on or off. Returns a negative error code or zero.
811 * @get_tx_csum: Deprecated as redundant. Report whether transmit checksums
812 * are turned on or off.
813 * @set_tx_csum: Deprecated in favour of generic netdev features. Turn
814 * transmit checksums on or off. Returns a negative error code or zero.
815 * @get_sg: Deprecated as redundant. Report whether scatter-gather is
816 * enabled.
817 * @set_sg: Deprecated in favour of generic netdev features. Turn
818 * scatter-gather on or off. Returns a negative error code or zero.
819 * @get_tso: Deprecated as redundant. Report whether TCP segmentation
820 * offload is enabled.
821 * @set_tso: Deprecated in favour of generic netdev features. Turn TCP
822 * segmentation offload on or off. Returns a negative error code or zero.
823 * @self_test: Run specified self-tests
824 * @get_strings: Return a set of strings that describe the requested objects
825 * @set_phys_id: Identify the physical devices, e.g. by flashing an LED
826 * attached to it. The implementation may update the indicator
827 * asynchronously or synchronously, but in either case it must return
828 * quickly. It is initially called with the argument %ETHTOOL_ID_ACTIVE,
829 * and must either activate asynchronous updates and return zero, return
830 * a negative error or return a positive frequency for synchronous
831 * indication (e.g. 1 for one on/off cycle per second). If it returns
832 * a frequency then it will be called again at intervals with the
833 * argument %ETHTOOL_ID_ON or %ETHTOOL_ID_OFF and should set the state of
834 * the indicator accordingly. Finally, it is called with the argument
835 * %ETHTOOL_ID_INACTIVE and must deactivate the indicator. Returns a
836 * negative error code or zero.
837 * @get_ethtool_stats: Return extended statistics about the device.
838 * This is only useful if the device maintains statistics not
839 * included in &struct rtnl_link_stats64.
840 * @begin: Function to be called before any other operation. Returns a
841 * negative error code or zero.
842 * @complete: Function to be called after any other operation except
843 * @begin. Will be called even if the other operation failed.
844 * @get_ufo: Deprecated as redundant. Report whether UDP fragmentation
845 * offload is enabled.
846 * @set_ufo: Deprecated in favour of generic netdev features. Turn UDP
847 * fragmentation offload on or off. Returns a negative error code or zero.
848 * @get_flags: Deprecated as redundant. Report features included in
849 * &enum ethtool_flags that are enabled.
850 * @set_flags: Deprecated in favour of generic netdev features. Turn
851 * features included in &enum ethtool_flags on or off. Returns a
852 * negative error code or zero.
853 * @get_priv_flags: Report driver-specific feature flags.
854 * @set_priv_flags: Set driver-specific feature flags. Returns a negative
855 * error code or zero.
856 * @get_sset_count: Get number of strings that @get_strings will write.
857 * @get_rxnfc: Get RX flow classification rules. Returns a negative
858 * error code or zero.
859 * @set_rxnfc: Set RX flow classification rules. Returns a negative
860 * error code or zero.
861 * @flash_device: Write a firmware image to device's flash memory.
862 * Returns a negative error code or zero.
863 * @reset: Reset (part of) the device, as specified by a bitmask of
864 * flags from &enum ethtool_reset_flags. Returns a negative
865 * error code or zero.
866 * @set_rx_ntuple: Set an RX n-tuple rule. Returns a negative error code
867 * or zero.
868 * @get_rx_ntuple: Deprecated.
869 * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
870 * Returns a negative error code or zero.
871 * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
872 * Returns a negative error code or zero.
873 * @get_channels: Get number of channels.
874 * @set_channels: Set number of channels. Returns a negative error code or
875 * zero.
876 * @get_dump_flag: Get dump flag indicating current dump length, version,
877 * and flag of the device.
878 * @get_dump_data: Get dump data.
879 * @set_dump: Set dump specific flags to the device.
880 *
881 * All operations are optional (i.e. the function pointer may be set
882 * to %NULL) and callers must take this into account. Callers must
883 * hold the RTNL, except that for @get_drvinfo the caller may or may
884 * not hold the RTNL.
885 *
886 * See the structures used by these operations for further documentation.
887 *
888 * See &struct net_device and &struct net_device_ops for documentation
889 * of the generic netdev features interface.
532 */ 890 */
533struct ethtool_ops { 891struct ethtool_ops {
534 int (*get_settings)(struct net_device *, struct ethtool_cmd *); 892 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
@@ -567,7 +925,7 @@ struct ethtool_ops {
567 int (*set_tso)(struct net_device *, u32); 925 int (*set_tso)(struct net_device *, u32);
568 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); 926 void (*self_test)(struct net_device *, struct ethtool_test *, u64 *);
569 void (*get_strings)(struct net_device *, u32 stringset, u8 *); 927 void (*get_strings)(struct net_device *, u32 stringset, u8 *);
570 int (*phys_id)(struct net_device *, u32); 928 int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state);
571 void (*get_ethtool_stats)(struct net_device *, 929 void (*get_ethtool_stats)(struct net_device *,
572 struct ethtool_stats *, u64 *); 930 struct ethtool_stats *, u64 *);
573 int (*begin)(struct net_device *); 931 int (*begin)(struct net_device *);
@@ -591,6 +949,13 @@ struct ethtool_ops {
591 struct ethtool_rxfh_indir *); 949 struct ethtool_rxfh_indir *);
592 int (*set_rxfh_indir)(struct net_device *, 950 int (*set_rxfh_indir)(struct net_device *,
593 const struct ethtool_rxfh_indir *); 951 const struct ethtool_rxfh_indir *);
952 void (*get_channels)(struct net_device *, struct ethtool_channels *);
953 int (*set_channels)(struct net_device *, struct ethtool_channels *);
954 int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
955 int (*get_dump_data)(struct net_device *,
956 struct ethtool_dump *, void *);
957 int (*set_dump)(struct net_device *, struct ethtool_dump *);
958
594}; 959};
595#endif /* __KERNEL__ */ 960#endif /* __KERNEL__ */
596 961
@@ -604,7 +969,9 @@ struct ethtool_ops {
604#define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */ 969#define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
605#define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */ 970#define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */
606#define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation. */ 971#define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation. */
607#define ETHTOOL_GLINK 0x0000000a /* Get link status (ethtool_value) */ 972/* Get link status for host, i.e. whether the interface *and* the
973 * physical port (if there is one) are up (ethtool_value). */
974#define ETHTOOL_GLINK 0x0000000a
608#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */ 975#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
609#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */ 976#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */
610#define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */ 977#define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
@@ -655,6 +1022,14 @@ struct ethtool_ops {
655#define ETHTOOL_GRXFHINDIR 0x00000038 /* Get RX flow hash indir'n table */ 1022#define ETHTOOL_GRXFHINDIR 0x00000038 /* Get RX flow hash indir'n table */
656#define ETHTOOL_SRXFHINDIR 0x00000039 /* Set RX flow hash indir'n table */ 1023#define ETHTOOL_SRXFHINDIR 0x00000039 /* Set RX flow hash indir'n table */
657 1024
1025#define ETHTOOL_GFEATURES 0x0000003a /* Get device offload settings */
1026#define ETHTOOL_SFEATURES 0x0000003b /* Change device offload settings */
1027#define ETHTOOL_GCHANNELS 0x0000003c /* Get no of channels */
1028#define ETHTOOL_SCHANNELS 0x0000003d /* Set no of channels */
1029#define ETHTOOL_SET_DUMP 0x0000003e /* Set dump settings */
1030#define ETHTOOL_GET_DUMP_FLAG 0x0000003f /* Get dump settings */
1031#define ETHTOOL_GET_DUMP_DATA 0x00000040 /* Get dump data */
1032
658/* compatibility with older code */ 1033/* compatibility with older code */
659#define SPARC_ETH_GSET ETHTOOL_GSET 1034#define SPARC_ETH_GSET ETHTOOL_GSET
660#define SPARC_ETH_SSET ETHTOOL_SSET 1035#define SPARC_ETH_SSET ETHTOOL_SSET
@@ -681,6 +1056,8 @@ struct ethtool_ops {
681#define SUPPORTED_10000baseKX4_Full (1 << 18) 1056#define SUPPORTED_10000baseKX4_Full (1 << 18)
682#define SUPPORTED_10000baseKR_Full (1 << 19) 1057#define SUPPORTED_10000baseKR_Full (1 << 19)
683#define SUPPORTED_10000baseR_FEC (1 << 20) 1058#define SUPPORTED_10000baseR_FEC (1 << 20)
1059#define SUPPORTED_20000baseMLD2_Full (1 << 21)
1060#define SUPPORTED_20000baseKR2_Full (1 << 22)
684 1061
685/* Indicates what features are advertised by the interface. */ 1062/* Indicates what features are advertised by the interface. */
686#define ADVERTISED_10baseT_Half (1 << 0) 1063#define ADVERTISED_10baseT_Half (1 << 0)
@@ -704,11 +1081,13 @@ struct ethtool_ops {
704#define ADVERTISED_10000baseKX4_Full (1 << 18) 1081#define ADVERTISED_10000baseKX4_Full (1 << 18)
705#define ADVERTISED_10000baseKR_Full (1 << 19) 1082#define ADVERTISED_10000baseKR_Full (1 << 19)
706#define ADVERTISED_10000baseR_FEC (1 << 20) 1083#define ADVERTISED_10000baseR_FEC (1 << 20)
1084#define ADVERTISED_20000baseMLD2_Full (1 << 21)
1085#define ADVERTISED_20000baseKR2_Full (1 << 22)
707 1086
708/* The following are all involved in forcing a particular link 1087/* The following are all involved in forcing a particular link
709 * mode for the device for setting things. When getting the 1088 * mode for the device for setting things. When getting the
710 * devices settings, these indicate the current mode and whether 1089 * devices settings, these indicate the current mode and whether
711 * it was foced up into this mode or autonegotiated. 1090 * it was forced up into this mode or autonegotiated.
712 */ 1091 */
713 1092
714/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */ 1093/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */
@@ -759,22 +1138,25 @@ struct ethtool_ops {
759#define WAKE_MAGIC (1 << 5) 1138#define WAKE_MAGIC (1 << 5)
760#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */ 1139#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */
761 1140
762/* L3-L4 network traffic flow types */ 1141/* L2-L4 network traffic flow types */
763#define TCP_V4_FLOW 0x01 1142#define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */
764#define UDP_V4_FLOW 0x02 1143#define UDP_V4_FLOW 0x02 /* hash or spec (udp_ip4_spec) */
765#define SCTP_V4_FLOW 0x03 1144#define SCTP_V4_FLOW 0x03 /* hash or spec (sctp_ip4_spec) */
766#define AH_ESP_V4_FLOW 0x04 1145#define AH_ESP_V4_FLOW 0x04 /* hash only */
767#define TCP_V6_FLOW 0x05 1146#define TCP_V6_FLOW 0x05 /* hash only */
768#define UDP_V6_FLOW 0x06 1147#define UDP_V6_FLOW 0x06 /* hash only */
769#define SCTP_V6_FLOW 0x07 1148#define SCTP_V6_FLOW 0x07 /* hash only */
770#define AH_ESP_V6_FLOW 0x08 1149#define AH_ESP_V6_FLOW 0x08 /* hash only */
771#define AH_V4_FLOW 0x09 1150#define AH_V4_FLOW 0x09 /* hash or spec (ah_ip4_spec) */
772#define ESP_V4_FLOW 0x0a 1151#define ESP_V4_FLOW 0x0a /* hash or spec (esp_ip4_spec) */
773#define AH_V6_FLOW 0x0b 1152#define AH_V6_FLOW 0x0b /* hash only */
774#define ESP_V6_FLOW 0x0c 1153#define ESP_V6_FLOW 0x0c /* hash only */
775#define IP_USER_FLOW 0x0d 1154#define IP_USER_FLOW 0x0d /* spec only (usr_ip4_spec) */
776#define IPV4_FLOW 0x10 1155#define IPV4_FLOW 0x10 /* hash only */
777#define IPV6_FLOW 0x11 1156#define IPV6_FLOW 0x11 /* hash only */
1157#define ETHER_FLOW 0x12 /* spec only (ether_spec) */
1158/* Flag to enable additional fields in struct ethtool_rx_flow_spec */
1159#define FLOW_EXT 0x80000000
778 1160
779/* L3-L4 network traffic flow hash options */ 1161/* L3-L4 network traffic flow hash options */
780#define RXH_L2DA (1 << 1) 1162#define RXH_L2DA (1 << 1)