ethtool: future-proof interface for speed extensions
[cascardo/linux.git] / include / uapi / linux / ethtool.h
index 57fa390..4345f80 100644 (file)
@@ -31,7 +31,7 @@
  *     physical connectors and other link features that are
  *     advertised through autonegotiation or enabled for
  *     auto-detection.
- * @speed: Low bits of the speed
+ * @speed: Low bits of the speed, 1Mb units, 0 to INT_MAX or SPEED_UNKNOWN
  * @duplex: Duplex mode; one of %DUPLEX_*
  * @port: Physical connector type; one of %PORT_*
  * @phy_address: MDIO address of PHY (transceiver); 0 or 255 if not
@@ -47,7 +47,7 @@
  *     obsoleted by &struct ethtool_coalesce.  Read-only; deprecated.
  * @maxrxpkt: Historically used to report RX IRQ coalescing; now
  *     obsoleted by &struct ethtool_coalesce.  Read-only; deprecated.
- * @speed_hi: High bits of the speed
+ * @speed_hi: High bits of the speed, 1Mb units, 0 to INT_MAX or SPEED_UNKNOWN
  * @eth_tp_mdix: Ethernet twisted-pair MDI(-X) status; one of
  *     %ETH_TP_MDI_*.  If the status is unknown or not applicable, the
  *     value will be %ETH_TP_MDI_INVALID.  Read-only.
@@ -748,6 +748,56 @@ struct ethtool_usrip4_spec {
        __u8    proto;
 };
 
+/**
+ * struct ethtool_tcpip6_spec - flow specification for TCP/IPv6 etc.
+ * @ip6src: Source host
+ * @ip6dst: Destination host
+ * @psrc: Source port
+ * @pdst: Destination port
+ * @tclass: Traffic Class
+ *
+ * This can be used to specify a TCP/IPv6, UDP/IPv6 or SCTP/IPv6 flow.
+ */
+struct ethtool_tcpip6_spec {
+       __be32  ip6src[4];
+       __be32  ip6dst[4];
+       __be16  psrc;
+       __be16  pdst;
+       __u8    tclass;
+};
+
+/**
+ * struct ethtool_ah_espip6_spec - flow specification for IPsec/IPv6
+ * @ip6src: Source host
+ * @ip6dst: Destination host
+ * @spi: Security parameters index
+ * @tclass: Traffic Class
+ *
+ * This can be used to specify an IPsec transport or tunnel over IPv6.
+ */
+struct ethtool_ah_espip6_spec {
+       __be32  ip6src[4];
+       __be32  ip6dst[4];
+       __be32  spi;
+       __u8    tclass;
+};
+
+/**
+ * struct ethtool_usrip6_spec - general flow specification for IPv6
+ * @ip6src: Source host
+ * @ip6dst: Destination host
+ * @l4_4_bytes: First 4 bytes of transport (layer 4) header
+ * @tclass: Traffic Class
+ * @l4_proto: Transport protocol number (nexthdr after any Extension Headers)
+ */
+struct ethtool_usrip6_spec {
+       __be32  ip6src[4];
+       __be32  ip6dst[4];
+       __be32  l4_4_bytes;
+       __u8    tclass;
+       __u8    l4_proto;
+};
+
 union ethtool_flow_union {
        struct ethtool_tcpip4_spec              tcp_ip4_spec;
        struct ethtool_tcpip4_spec              udp_ip4_spec;
@@ -755,6 +805,12 @@ union ethtool_flow_union {
        struct ethtool_ah_espip4_spec           ah_ip4_spec;
        struct ethtool_ah_espip4_spec           esp_ip4_spec;
        struct ethtool_usrip4_spec              usr_ip4_spec;
+       struct ethtool_tcpip6_spec              tcp_ip6_spec;
+       struct ethtool_tcpip6_spec              udp_ip6_spec;
+       struct ethtool_tcpip6_spec              sctp_ip6_spec;
+       struct ethtool_ah_espip6_spec           ah_ip6_spec;
+       struct ethtool_ah_espip6_spec           esp_ip6_spec;
+       struct ethtool_usrip6_spec              usr_ip6_spec;
        struct ethhdr                           ether_spec;
        __u8                                    hdata[52];
 };
@@ -1303,7 +1359,7 @@ enum ethtool_sfeatures_retval_bits {
  * it was forced up into this mode or autonegotiated.
  */
 
-/* The forced speed, 10Mb, 100Mb, gigabit, [2.5|5|10|20|25|40|50|56|100]GbE. */
+/* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal. */
 #define SPEED_10               10
 #define SPEED_100              100
 #define SPEED_1000             1000
@@ -1319,11 +1375,45 @@ enum ethtool_sfeatures_retval_bits {
 
 #define SPEED_UNKNOWN          -1
 
+static inline int ethtool_validate_speed(__u32 speed)
+{
+       switch (speed) {
+       case SPEED_10:
+       case SPEED_100:
+       case SPEED_1000:
+       case SPEED_2500:
+       case SPEED_5000:
+       case SPEED_10000:
+       case SPEED_20000:
+       case SPEED_25000:
+       case SPEED_40000:
+       case SPEED_50000:
+       case SPEED_56000:
+       case SPEED_100000:
+       case SPEED_UNKNOWN:
+               return 1;
+       }
+
+       return 0;
+}
+
 /* Duplex, half or full. */
 #define DUPLEX_HALF            0x00
 #define DUPLEX_FULL            0x01
 #define DUPLEX_UNKNOWN         0xff
 
+static inline int ethtool_validate_duplex(__u8 duplex)
+{
+       switch (duplex) {
+       case DUPLEX_HALF:
+       case DUPLEX_FULL:
+       case DUPLEX_UNKNOWN:
+               return 1;
+       }
+
+       return 0;
+}
+
 /* Which connector port. */
 #define PORT_TP                        0x00
 #define PORT_AUI               0x01
@@ -1367,15 +1457,17 @@ enum ethtool_sfeatures_retval_bits {
 #define        UDP_V4_FLOW     0x02    /* hash or spec (udp_ip4_spec) */
 #define        SCTP_V4_FLOW    0x03    /* hash or spec (sctp_ip4_spec) */
 #define        AH_ESP_V4_FLOW  0x04    /* hash only */
-#define        TCP_V6_FLOW     0x05    /* hash only */
-#define        UDP_V6_FLOW     0x06    /* hash only */
-#define        SCTP_V6_FLOW    0x07    /* hash only */
+#define        TCP_V6_FLOW     0x05    /* hash or spec (tcp_ip6_spec; nfc only) */
+#define        UDP_V6_FLOW     0x06    /* hash or spec (udp_ip6_spec; nfc only) */
+#define        SCTP_V6_FLOW    0x07    /* hash or spec (sctp_ip6_spec; nfc only) */
 #define        AH_ESP_V6_FLOW  0x08    /* hash only */
 #define        AH_V4_FLOW      0x09    /* hash or spec (ah_ip4_spec) */
 #define        ESP_V4_FLOW     0x0a    /* hash or spec (esp_ip4_spec) */
-#define        AH_V6_FLOW      0x0b    /* hash only */
-#define        ESP_V6_FLOW     0x0c    /* hash only */
-#define        IP_USER_FLOW    0x0d    /* spec only (usr_ip4_spec) */
+#define        AH_V6_FLOW      0x0b    /* hash or spec (ah_ip6_spec; nfc only) */
+#define        ESP_V6_FLOW     0x0c    /* hash or spec (esp_ip6_spec; nfc only) */
+#define        IPV4_USER_FLOW  0x0d    /* spec only (usr_ip4_spec) */
+#define        IP_USER_FLOW    IPV4_USER_FLOW
+#define        IPV6_USER_FLOW  0x0e    /* spec only (usr_ip6_spec; nfc only) */
 #define        IPV4_FLOW       0x10    /* hash only */
 #define        IPV6_FLOW       0x11    /* hash only */
 #define        ETHER_FLOW      0x12    /* spec only (ether_spec) */