aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorTom Herbert <tom@herbertland.com>2015-12-14 14:19:44 -0500
committerDavid S. Miller <davem@davemloft.net>2015-12-15 16:50:20 -0500
commitc8cd0989bd151fda87bbf10887b3df18021284bc (patch)
tree714a0169000dfa3c7456e69b58da887159b71586 /include/linux
parenta188222b6ed29404ac2d4232d35d1fe0e77af370 (diff)
net: Eliminate NETIF_F_GEN_CSUM and NETIF_F_V[46]_CSUM
These netif flags are unnecessary convolutions. It is more straightforward to just use NETIF_F_HW_CSUM, NETIF_F_IP_CSUM, and NETIF_F_IPV6_CSUM directly. This patch also: - Cleans up can_checksum_protocol - Simplifies netdev_intersect_features Signed-off-by: Tom Herbert <tom@herbertland.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/if_vlan.h2
-rw-r--r--include/linux/netdev_features.h9
-rw-r--r--include/linux/netdevice.h40
3 files changed, 29 insertions, 22 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 05f5879821b8..a5f6ce6b578c 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -621,7 +621,7 @@ static inline netdev_features_t vlan_features_check(const struct sk_buff *skb,
621 NETIF_F_SG | 621 NETIF_F_SG |
622 NETIF_F_HIGHDMA | 622 NETIF_F_HIGHDMA |
623 NETIF_F_FRAGLIST | 623 NETIF_F_FRAGLIST |
624 NETIF_F_GEN_CSUM | 624 NETIF_F_HW_CSUM |
625 NETIF_F_HW_VLAN_CTAG_TX | 625 NETIF_F_HW_VLAN_CTAG_TX |
626 NETIF_F_HW_VLAN_STAG_TX); 626 NETIF_F_HW_VLAN_STAG_TX);
627 627
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 2c4e94ab88da..d9654f0eecb3 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -146,15 +146,12 @@ enum {
146#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ 146#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \
147 NETIF_F_TSO6 | NETIF_F_UFO) 147 NETIF_F_TSO6 | NETIF_F_UFO)
148 148
149#define NETIF_F_GEN_CSUM NETIF_F_HW_CSUM 149/* List of IP checksum features. Note that NETIF_F_ HW_CSUM should not be
150#define NETIF_F_V4_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
151#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)
152
153/* List of IP checksum features. Note that NETIF_HW_CSUM should not be
154 * set in features when NETIF_F_IP_CSUM or NETIF_F_IPV6_CSUM are set-- 150 * set in features when NETIF_F_IP_CSUM or NETIF_F_IPV6_CSUM are set--
155 * this would be contradictory 151 * this would be contradictory
156 */ 152 */
157#define NETIF_F_CSUM_MASK (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM) 153#define NETIF_F_CSUM_MASK (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
154 NETIF_F_HW_CSUM)
158 155
159#define NETIF_F_ALL_TSO (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN) 156#define NETIF_F_ALL_TSO (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN)
160 157
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a54223a113b1..283984b67cd9 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3691,13 +3691,24 @@ __be16 skb_network_protocol(struct sk_buff *skb, int *depth);
3691static inline bool can_checksum_protocol(netdev_features_t features, 3691static inline bool can_checksum_protocol(netdev_features_t features,
3692 __be16 protocol) 3692 __be16 protocol)
3693{ 3693{
3694 return ((features & NETIF_F_GEN_CSUM) || 3694 if (protocol == htons(ETH_P_FCOE))
3695 ((features & NETIF_F_V4_CSUM) && 3695 return !!(features & NETIF_F_FCOE_CRC);
3696 protocol == htons(ETH_P_IP)) || 3696
3697 ((features & NETIF_F_V6_CSUM) && 3697 /* Assume this is an IP checksum (not SCTP CRC) */
3698 protocol == htons(ETH_P_IPV6)) || 3698
3699 ((features & NETIF_F_FCOE_CRC) && 3699 if (features & NETIF_F_HW_CSUM) {
3700 protocol == htons(ETH_P_FCOE))); 3700 /* Can checksum everything */
3701 return true;
3702 }
3703
3704 switch (protocol) {
3705 case htons(ETH_P_IP):
3706 return !!(features & NETIF_F_IP_CSUM);
3707 case htons(ETH_P_IPV6):
3708 return !!(features & NETIF_F_IPV6_CSUM);
3709 default:
3710 return false;
3711 }
3701} 3712}
3702 3713
3703#ifdef CONFIG_BUG 3714#ifdef CONFIG_BUG
@@ -3762,15 +3773,14 @@ void linkwatch_run_queue(void);
3762static inline netdev_features_t netdev_intersect_features(netdev_features_t f1, 3773static inline netdev_features_t netdev_intersect_features(netdev_features_t f1,
3763 netdev_features_t f2) 3774 netdev_features_t f2)
3764{ 3775{
3765 if (f1 & NETIF_F_GEN_CSUM) 3776 if ((f1 ^ f2) & NETIF_F_HW_CSUM) {
3766 f1 |= (NETIF_F_CSUM_MASK & ~NETIF_F_GEN_CSUM); 3777 if (f1 & NETIF_F_HW_CSUM)
3767 if (f2 & NETIF_F_GEN_CSUM) 3778 f1 |= (NETIF_F_IP_CSUM|NETIF_F_IP_CSUM);
3768 f2 |= (NETIF_F_CSUM_MASK & ~NETIF_F_GEN_CSUM); 3779 else
3769 f1 &= f2; 3780 f2 |= (NETIF_F_IP_CSUM|NETIF_F_IP_CSUM);
3770 if (f1 & NETIF_F_GEN_CSUM) 3781 }
3771 f1 &= ~(NETIF_F_CSUM_MASK & ~NETIF_F_GEN_CSUM);
3772 3782
3773 return f1; 3783 return f1 & f2;
3774} 3784}
3775 3785
3776static inline netdev_features_t netdev_get_wanted_features( 3786static inline netdev_features_t netdev_get_wanted_features(