Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Network device features.
0004  */
0005 #ifndef _LINUX_NETDEV_FEATURES_H
0006 #define _LINUX_NETDEV_FEATURES_H
0007 
0008 #include <linux/types.h>
0009 #include <linux/bitops.h>
0010 #include <asm/byteorder.h>
0011 
0012 typedef u64 netdev_features_t;
0013 
0014 enum {
0015     NETIF_F_SG_BIT,         /* Scatter/gather IO. */
0016     NETIF_F_IP_CSUM_BIT,        /* Can checksum TCP/UDP over IPv4. */
0017     __UNUSED_NETIF_F_1,
0018     NETIF_F_HW_CSUM_BIT,        /* Can checksum all the packets. */
0019     NETIF_F_IPV6_CSUM_BIT,      /* Can checksum TCP/UDP over IPV6 */
0020     NETIF_F_HIGHDMA_BIT,        /* Can DMA to high memory. */
0021     NETIF_F_FRAGLIST_BIT,       /* Scatter/gather IO. */
0022     NETIF_F_HW_VLAN_CTAG_TX_BIT,    /* Transmit VLAN CTAG HW acceleration */
0023     NETIF_F_HW_VLAN_CTAG_RX_BIT,    /* Receive VLAN CTAG HW acceleration */
0024     NETIF_F_HW_VLAN_CTAG_FILTER_BIT,/* Receive filtering on VLAN CTAGs */
0025     NETIF_F_VLAN_CHALLENGED_BIT,    /* Device cannot handle VLAN packets */
0026     NETIF_F_GSO_BIT,        /* Enable software GSO. */
0027     NETIF_F_LLTX_BIT,       /* LockLess TX - deprecated. Please */
0028                     /* do not use LLTX in new drivers */
0029     NETIF_F_NETNS_LOCAL_BIT,    /* Does not change network namespaces */
0030     NETIF_F_GRO_BIT,        /* Generic receive offload */
0031     NETIF_F_LRO_BIT,        /* large receive offload */
0032 
0033     /**/NETIF_F_GSO_SHIFT,      /* keep the order of SKB_GSO_* bits */
0034     NETIF_F_TSO_BIT         /* ... TCPv4 segmentation */
0035         = NETIF_F_GSO_SHIFT,
0036     NETIF_F_GSO_ROBUST_BIT,     /* ... ->SKB_GSO_DODGY */
0037     NETIF_F_TSO_ECN_BIT,        /* ... TCP ECN support */
0038     NETIF_F_TSO_MANGLEID_BIT,   /* ... IPV4 ID mangling allowed */
0039     NETIF_F_TSO6_BIT,       /* ... TCPv6 segmentation */
0040     NETIF_F_FSO_BIT,        /* ... FCoE segmentation */
0041     NETIF_F_GSO_GRE_BIT,        /* ... GRE with TSO */
0042     NETIF_F_GSO_GRE_CSUM_BIT,   /* ... GRE with csum with TSO */
0043     NETIF_F_GSO_IPXIP4_BIT,     /* ... IP4 or IP6 over IP4 with TSO */
0044     NETIF_F_GSO_IPXIP6_BIT,     /* ... IP4 or IP6 over IP6 with TSO */
0045     NETIF_F_GSO_UDP_TUNNEL_BIT, /* ... UDP TUNNEL with TSO */
0046     NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT,/* ... UDP TUNNEL with TSO & CSUM */
0047     NETIF_F_GSO_PARTIAL_BIT,    /* ... Only segment inner-most L4
0048                      *     in hardware and all other
0049                      *     headers in software.
0050                      */
0051     NETIF_F_GSO_TUNNEL_REMCSUM_BIT, /* ... TUNNEL with TSO & REMCSUM */
0052     NETIF_F_GSO_SCTP_BIT,       /* ... SCTP fragmentation */
0053     NETIF_F_GSO_ESP_BIT,        /* ... ESP with TSO */
0054     NETIF_F_GSO_UDP_BIT,        /* ... UFO, deprecated except tuntap */
0055     NETIF_F_GSO_UDP_L4_BIT,     /* ... UDP payload GSO (not UFO) */
0056     NETIF_F_GSO_FRAGLIST_BIT,       /* ... Fraglist GSO */
0057     /**/NETIF_F_GSO_LAST =      /* last bit, see GSO_MASK */
0058         NETIF_F_GSO_FRAGLIST_BIT,
0059 
0060     NETIF_F_FCOE_CRC_BIT,       /* FCoE CRC32 */
0061     NETIF_F_SCTP_CRC_BIT,       /* SCTP checksum offload */
0062     NETIF_F_FCOE_MTU_BIT,       /* Supports max FCoE MTU, 2158 bytes*/
0063     NETIF_F_NTUPLE_BIT,     /* N-tuple filters supported */
0064     NETIF_F_RXHASH_BIT,     /* Receive hashing offload */
0065     NETIF_F_RXCSUM_BIT,     /* Receive checksumming offload */
0066     NETIF_F_NOCACHE_COPY_BIT,   /* Use no-cache copyfromuser */
0067     NETIF_F_LOOPBACK_BIT,       /* Enable loopback */
0068     NETIF_F_RXFCS_BIT,      /* Append FCS to skb pkt data */
0069     NETIF_F_RXALL_BIT,      /* Receive errored frames too */
0070     NETIF_F_HW_VLAN_STAG_TX_BIT,    /* Transmit VLAN STAG HW acceleration */
0071     NETIF_F_HW_VLAN_STAG_RX_BIT,    /* Receive VLAN STAG HW acceleration */
0072     NETIF_F_HW_VLAN_STAG_FILTER_BIT,/* Receive filtering on VLAN STAGs */
0073     NETIF_F_HW_L2FW_DOFFLOAD_BIT,   /* Allow L2 Forwarding in Hardware */
0074 
0075     NETIF_F_HW_TC_BIT,      /* Offload TC infrastructure */
0076     NETIF_F_HW_ESP_BIT,     /* Hardware ESP transformation offload */
0077     NETIF_F_HW_ESP_TX_CSUM_BIT, /* ESP with TX checksum offload */
0078     NETIF_F_RX_UDP_TUNNEL_PORT_BIT, /* Offload of RX port for UDP tunnels */
0079     NETIF_F_HW_TLS_TX_BIT,      /* Hardware TLS TX offload */
0080     NETIF_F_HW_TLS_RX_BIT,      /* Hardware TLS RX offload */
0081 
0082     NETIF_F_GRO_HW_BIT,     /* Hardware Generic receive offload */
0083     NETIF_F_HW_TLS_RECORD_BIT,  /* Offload TLS record */
0084     NETIF_F_GRO_FRAGLIST_BIT,   /* Fraglist GRO */
0085 
0086     NETIF_F_HW_MACSEC_BIT,      /* Offload MACsec operations */
0087     NETIF_F_GRO_UDP_FWD_BIT,    /* Allow UDP GRO for forwarding */
0088 
0089     NETIF_F_HW_HSR_TAG_INS_BIT, /* Offload HSR tag insertion */
0090     NETIF_F_HW_HSR_TAG_RM_BIT,  /* Offload HSR tag removal */
0091     NETIF_F_HW_HSR_FWD_BIT,     /* Offload HSR forwarding */
0092     NETIF_F_HW_HSR_DUP_BIT,     /* Offload HSR duplication */
0093 
0094     /*
0095      * Add your fresh new feature above and remember to update
0096      * netdev_features_strings[] in net/ethtool/common.c and maybe
0097      * some feature mask #defines below. Please also describe it
0098      * in Documentation/networking/netdev-features.rst.
0099      */
0100 
0101     /**/NETDEV_FEATURE_COUNT
0102 };
0103 
0104 /* copy'n'paste compression ;) */
0105 #define __NETIF_F_BIT(bit)  ((netdev_features_t)1 << (bit))
0106 #define __NETIF_F(name)     __NETIF_F_BIT(NETIF_F_##name##_BIT)
0107 
0108 #define NETIF_F_FCOE_CRC    __NETIF_F(FCOE_CRC)
0109 #define NETIF_F_FCOE_MTU    __NETIF_F(FCOE_MTU)
0110 #define NETIF_F_FRAGLIST    __NETIF_F(FRAGLIST)
0111 #define NETIF_F_FSO     __NETIF_F(FSO)
0112 #define NETIF_F_GRO     __NETIF_F(GRO)
0113 #define NETIF_F_GRO_HW      __NETIF_F(GRO_HW)
0114 #define NETIF_F_GSO     __NETIF_F(GSO)
0115 #define NETIF_F_GSO_ROBUST  __NETIF_F(GSO_ROBUST)
0116 #define NETIF_F_HIGHDMA     __NETIF_F(HIGHDMA)
0117 #define NETIF_F_HW_CSUM     __NETIF_F(HW_CSUM)
0118 #define NETIF_F_HW_VLAN_CTAG_FILTER __NETIF_F(HW_VLAN_CTAG_FILTER)
0119 #define NETIF_F_HW_VLAN_CTAG_RX __NETIF_F(HW_VLAN_CTAG_RX)
0120 #define NETIF_F_HW_VLAN_CTAG_TX __NETIF_F(HW_VLAN_CTAG_TX)
0121 #define NETIF_F_IP_CSUM     __NETIF_F(IP_CSUM)
0122 #define NETIF_F_IPV6_CSUM   __NETIF_F(IPV6_CSUM)
0123 #define NETIF_F_LLTX        __NETIF_F(LLTX)
0124 #define NETIF_F_LOOPBACK    __NETIF_F(LOOPBACK)
0125 #define NETIF_F_LRO     __NETIF_F(LRO)
0126 #define NETIF_F_NETNS_LOCAL __NETIF_F(NETNS_LOCAL)
0127 #define NETIF_F_NOCACHE_COPY    __NETIF_F(NOCACHE_COPY)
0128 #define NETIF_F_NTUPLE      __NETIF_F(NTUPLE)
0129 #define NETIF_F_RXCSUM      __NETIF_F(RXCSUM)
0130 #define NETIF_F_RXHASH      __NETIF_F(RXHASH)
0131 #define NETIF_F_SCTP_CRC    __NETIF_F(SCTP_CRC)
0132 #define NETIF_F_SG      __NETIF_F(SG)
0133 #define NETIF_F_TSO6        __NETIF_F(TSO6)
0134 #define NETIF_F_TSO_ECN     __NETIF_F(TSO_ECN)
0135 #define NETIF_F_TSO     __NETIF_F(TSO)
0136 #define NETIF_F_VLAN_CHALLENGED __NETIF_F(VLAN_CHALLENGED)
0137 #define NETIF_F_RXFCS       __NETIF_F(RXFCS)
0138 #define NETIF_F_RXALL       __NETIF_F(RXALL)
0139 #define NETIF_F_GSO_GRE     __NETIF_F(GSO_GRE)
0140 #define NETIF_F_GSO_GRE_CSUM    __NETIF_F(GSO_GRE_CSUM)
0141 #define NETIF_F_GSO_IPXIP4  __NETIF_F(GSO_IPXIP4)
0142 #define NETIF_F_GSO_IPXIP6  __NETIF_F(GSO_IPXIP6)
0143 #define NETIF_F_GSO_UDP_TUNNEL  __NETIF_F(GSO_UDP_TUNNEL)
0144 #define NETIF_F_GSO_UDP_TUNNEL_CSUM __NETIF_F(GSO_UDP_TUNNEL_CSUM)
0145 #define NETIF_F_TSO_MANGLEID    __NETIF_F(TSO_MANGLEID)
0146 #define NETIF_F_GSO_PARTIAL  __NETIF_F(GSO_PARTIAL)
0147 #define NETIF_F_GSO_TUNNEL_REMCSUM __NETIF_F(GSO_TUNNEL_REMCSUM)
0148 #define NETIF_F_GSO_SCTP    __NETIF_F(GSO_SCTP)
0149 #define NETIF_F_GSO_ESP     __NETIF_F(GSO_ESP)
0150 #define NETIF_F_GSO_UDP     __NETIF_F(GSO_UDP)
0151 #define NETIF_F_HW_VLAN_STAG_FILTER __NETIF_F(HW_VLAN_STAG_FILTER)
0152 #define NETIF_F_HW_VLAN_STAG_RX __NETIF_F(HW_VLAN_STAG_RX)
0153 #define NETIF_F_HW_VLAN_STAG_TX __NETIF_F(HW_VLAN_STAG_TX)
0154 #define NETIF_F_HW_L2FW_DOFFLOAD    __NETIF_F(HW_L2FW_DOFFLOAD)
0155 #define NETIF_F_HW_TC       __NETIF_F(HW_TC)
0156 #define NETIF_F_HW_ESP      __NETIF_F(HW_ESP)
0157 #define NETIF_F_HW_ESP_TX_CSUM  __NETIF_F(HW_ESP_TX_CSUM)
0158 #define NETIF_F_RX_UDP_TUNNEL_PORT  __NETIF_F(RX_UDP_TUNNEL_PORT)
0159 #define NETIF_F_HW_TLS_RECORD   __NETIF_F(HW_TLS_RECORD)
0160 #define NETIF_F_GSO_UDP_L4  __NETIF_F(GSO_UDP_L4)
0161 #define NETIF_F_HW_TLS_TX   __NETIF_F(HW_TLS_TX)
0162 #define NETIF_F_HW_TLS_RX   __NETIF_F(HW_TLS_RX)
0163 #define NETIF_F_GRO_FRAGLIST    __NETIF_F(GRO_FRAGLIST)
0164 #define NETIF_F_GSO_FRAGLIST    __NETIF_F(GSO_FRAGLIST)
0165 #define NETIF_F_HW_MACSEC   __NETIF_F(HW_MACSEC)
0166 #define NETIF_F_GRO_UDP_FWD __NETIF_F(GRO_UDP_FWD)
0167 #define NETIF_F_HW_HSR_TAG_INS  __NETIF_F(HW_HSR_TAG_INS)
0168 #define NETIF_F_HW_HSR_TAG_RM   __NETIF_F(HW_HSR_TAG_RM)
0169 #define NETIF_F_HW_HSR_FWD  __NETIF_F(HW_HSR_FWD)
0170 #define NETIF_F_HW_HSR_DUP  __NETIF_F(HW_HSR_DUP)
0171 
0172 /* Finds the next feature with the highest number of the range of start-1 till 0.
0173  */
0174 static inline int find_next_netdev_feature(u64 feature, unsigned long start)
0175 {
0176     /* like BITMAP_LAST_WORD_MASK() for u64
0177      * this sets the most significant 64 - start to 0.
0178      */
0179     feature &= ~0ULL >> (-start & ((sizeof(feature) * 8) - 1));
0180 
0181     return fls64(feature) - 1;
0182 }
0183 
0184 /* This goes for the MSB to the LSB through the set feature bits,
0185  * mask_addr should be a u64 and bit an int
0186  */
0187 #define for_each_netdev_feature(mask_addr, bit)             \
0188     for ((bit) = find_next_netdev_feature((mask_addr),      \
0189                           NETDEV_FEATURE_COUNT);    \
0190          (bit) >= 0;                        \
0191          (bit) = find_next_netdev_feature((mask_addr), (bit)))
0192 
0193 /* Features valid for ethtool to change */
0194 /* = all defined minus driver/device-class-related */
0195 #define NETIF_F_NEVER_CHANGE    (NETIF_F_VLAN_CHALLENGED | \
0196                  NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
0197 
0198 /* remember that ((t)1 << t_BITS) is undefined in C99 */
0199 #define NETIF_F_ETHTOOL_BITS    ((__NETIF_F_BIT(NETDEV_FEATURE_COUNT - 1) | \
0200         (__NETIF_F_BIT(NETDEV_FEATURE_COUNT - 1) - 1)) & \
0201         ~NETIF_F_NEVER_CHANGE)
0202 
0203 /* Segmentation offload feature mask */
0204 #define NETIF_F_GSO_MASK    (__NETIF_F_BIT(NETIF_F_GSO_LAST + 1) - \
0205         __NETIF_F_BIT(NETIF_F_GSO_SHIFT))
0206 
0207 /* List of IP checksum features. Note that NETIF_F_HW_CSUM should not be
0208  * set in features when NETIF_F_IP_CSUM or NETIF_F_IPV6_CSUM are set--
0209  * this would be contradictory
0210  */
0211 #define NETIF_F_CSUM_MASK   (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
0212                  NETIF_F_HW_CSUM)
0213 
0214 #define NETIF_F_ALL_TSO     (NETIF_F_TSO | NETIF_F_TSO6 | \
0215                  NETIF_F_TSO_ECN | NETIF_F_TSO_MANGLEID)
0216 
0217 #define NETIF_F_ALL_FCOE    (NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \
0218                  NETIF_F_FSO)
0219 
0220 /* List of features with software fallbacks. */
0221 #define NETIF_F_GSO_SOFTWARE    (NETIF_F_ALL_TSO | NETIF_F_GSO_SCTP |        \
0222                  NETIF_F_GSO_UDP_L4 | NETIF_F_GSO_FRAGLIST)
0223 
0224 /*
0225  * If one device supports one of these features, then enable them
0226  * for all in netdev_increment_features.
0227  */
0228 #define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
0229                  NETIF_F_SG | NETIF_F_HIGHDMA |     \
0230                  NETIF_F_FRAGLIST | NETIF_F_VLAN_CHALLENGED)
0231 
0232 /*
0233  * If one device doesn't support one of these features, then disable it
0234  * for all in netdev_increment_features.
0235  */
0236 #define NETIF_F_ALL_FOR_ALL (NETIF_F_NOCACHE_COPY | NETIF_F_FSO)
0237 
0238 /*
0239  * If upper/master device has these features disabled, they must be disabled
0240  * on all lower/slave devices as well.
0241  */
0242 #define NETIF_F_UPPER_DISABLES  NETIF_F_LRO
0243 
0244 /* changeable features with no special hardware requirements */
0245 #define NETIF_F_SOFT_FEATURES   (NETIF_F_GSO | NETIF_F_GRO)
0246 
0247 /* Changeable features with no special hardware requirements that defaults to off. */
0248 #define NETIF_F_SOFT_FEATURES_OFF   (NETIF_F_GRO_FRAGLIST | NETIF_F_GRO_UDP_FWD)
0249 
0250 #define NETIF_F_VLAN_FEATURES   (NETIF_F_HW_VLAN_CTAG_FILTER | \
0251                  NETIF_F_HW_VLAN_CTAG_RX | \
0252                  NETIF_F_HW_VLAN_CTAG_TX | \
0253                  NETIF_F_HW_VLAN_STAG_FILTER | \
0254                  NETIF_F_HW_VLAN_STAG_RX | \
0255                  NETIF_F_HW_VLAN_STAG_TX)
0256 
0257 #define NETIF_F_GSO_ENCAP_ALL   (NETIF_F_GSO_GRE |          \
0258                  NETIF_F_GSO_GRE_CSUM |         \
0259                  NETIF_F_GSO_IPXIP4 |           \
0260                  NETIF_F_GSO_IPXIP6 |           \
0261                  NETIF_F_GSO_UDP_TUNNEL |       \
0262                  NETIF_F_GSO_UDP_TUNNEL_CSUM)
0263 
0264 #endif  /* _LINUX_NETDEV_FEATURES_H */