aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ethernet/sfc/efx.c2
-rw-r--r--drivers/net/macvlan.c2
-rw-r--r--include/linux/if_vlan.h2
-rw-r--r--include/linux/netdev_features.h9
-rw-r--r--include/linux/netdevice.h40
-rw-r--r--net/core/dev.c12
-rw-r--r--net/core/pktgen.c4
-rw-r--r--net/ipv4/ip_output.c2
-rw-r--r--net/ipv4/netfilter/nf_nat_l3proto_ipv4.c3
-rw-r--r--net/ipv4/udp.c3
-rw-r--r--net/ipv4/udp_offload.c5
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/netfilter/nf_nat_l3proto_ipv6.c3
13 files changed, 50 insertions, 39 deletions
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index 1fe13c733c1e..6f697438545d 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -3128,7 +3128,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
3128 net_dev->features |= (efx->type->offload_features | NETIF_F_SG | 3128 net_dev->features |= (efx->type->offload_features | NETIF_F_SG |
3129 NETIF_F_HIGHDMA | NETIF_F_TSO | 3129 NETIF_F_HIGHDMA | NETIF_F_TSO |
3130 NETIF_F_RXCSUM); 3130 NETIF_F_RXCSUM);
3131 if (efx->type->offload_features & NETIF_F_V6_CSUM) 3131 if (efx->type->offload_features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
3132 net_dev->features |= NETIF_F_TSO6; 3132 net_dev->features |= NETIF_F_TSO6;
3133 /* Mask for features that also apply to VLAN devices */ 3133 /* Mask for features that also apply to VLAN devices */
3134 net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG | 3134 net_dev->vlan_features |= (NETIF_F_HW_CSUM | NETIF_F_SG |
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index ae3b486fb663..6a57a005e0ca 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -758,7 +758,7 @@ static struct lock_class_key macvlan_netdev_xmit_lock_key;
758static struct lock_class_key macvlan_netdev_addr_lock_key; 758static struct lock_class_key macvlan_netdev_addr_lock_key;
759 759
760#define ALWAYS_ON_FEATURES \ 760#define ALWAYS_ON_FEATURES \
761 (NETIF_F_SG | NETIF_F_GEN_CSUM | NETIF_F_GSO_SOFTWARE | NETIF_F_LLTX | \ 761 (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | NETIF_F_LLTX | \
762 NETIF_F_GSO_ROBUST) 762 NETIF_F_GSO_ROBUST)
763 763
764#define MACVLAN_FEATURES \ 764#define MACVLAN_FEATURES \
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(
diff --git a/net/core/dev.c b/net/core/dev.c
index 5a3b5a404642..45b013f27625 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6467,9 +6467,9 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
6467 /* UFO needs SG and checksumming */ 6467 /* UFO needs SG and checksumming */
6468 if (features & NETIF_F_UFO) { 6468 if (features & NETIF_F_UFO) {
6469 /* maybe split UFO into V4 and V6? */ 6469 /* maybe split UFO into V4 and V6? */
6470 if (!((features & NETIF_F_GEN_CSUM) || 6470 if (!(features & NETIF_F_HW_CSUM) &&
6471 (features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) 6471 ((features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) !=
6472 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))) { 6472 (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))) {
6473 netdev_dbg(dev, 6473 netdev_dbg(dev,
6474 "Dropping NETIF_F_UFO since no checksum offload features.\n"); 6474 "Dropping NETIF_F_UFO since no checksum offload features.\n");
6475 features &= ~NETIF_F_UFO; 6475 features &= ~NETIF_F_UFO;
@@ -7571,7 +7571,7 @@ static int dev_cpu_callback(struct notifier_block *nfb,
7571netdev_features_t netdev_increment_features(netdev_features_t all, 7571netdev_features_t netdev_increment_features(netdev_features_t all,
7572 netdev_features_t one, netdev_features_t mask) 7572 netdev_features_t one, netdev_features_t mask)
7573{ 7573{
7574 if (mask & NETIF_F_GEN_CSUM) 7574 if (mask & NETIF_F_HW_CSUM)
7575 mask |= NETIF_F_CSUM_MASK; 7575 mask |= NETIF_F_CSUM_MASK;
7576 mask |= NETIF_F_VLAN_CHALLENGED; 7576 mask |= NETIF_F_VLAN_CHALLENGED;
7577 7577
@@ -7579,8 +7579,8 @@ netdev_features_t netdev_increment_features(netdev_features_t all,
7579 all &= one | ~NETIF_F_ALL_FOR_ALL; 7579 all &= one | ~NETIF_F_ALL_FOR_ALL;
7580 7580
7581 /* If one device supports hw checksumming, set for all. */ 7581 /* If one device supports hw checksumming, set for all. */
7582 if (all & NETIF_F_GEN_CSUM) 7582 if (all & NETIF_F_HW_CSUM)
7583 all &= ~(NETIF_F_CSUM_MASK & ~NETIF_F_GEN_CSUM); 7583 all &= ~(NETIF_F_CSUM_MASK & ~NETIF_F_HW_CSUM);
7584 7584
7585 return all; 7585 return all;
7586} 7586}
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index de8d5cc5eb24..2be144498bcf 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2898,7 +2898,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2898 2898
2899 if (!(pkt_dev->flags & F_UDPCSUM)) { 2899 if (!(pkt_dev->flags & F_UDPCSUM)) {
2900 skb->ip_summed = CHECKSUM_NONE; 2900 skb->ip_summed = CHECKSUM_NONE;
2901 } else if (odev->features & NETIF_F_V4_CSUM) { 2901 } else if (odev->features & (NETIF_F_HW_CSUM | NETIF_F_IP_CSUM)) {
2902 skb->ip_summed = CHECKSUM_PARTIAL; 2902 skb->ip_summed = CHECKSUM_PARTIAL;
2903 skb->csum = 0; 2903 skb->csum = 0;
2904 udp4_hwcsum(skb, iph->saddr, iph->daddr); 2904 udp4_hwcsum(skb, iph->saddr, iph->daddr);
@@ -3032,7 +3032,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
3032 3032
3033 if (!(pkt_dev->flags & F_UDPCSUM)) { 3033 if (!(pkt_dev->flags & F_UDPCSUM)) {
3034 skb->ip_summed = CHECKSUM_NONE; 3034 skb->ip_summed = CHECKSUM_NONE;
3035 } else if (odev->features & NETIF_F_V6_CSUM) { 3035 } else if (odev->features & (NETIF_F_HW_CSUM | NETIF_F_IPV6_CSUM)) {
3036 skb->ip_summed = CHECKSUM_PARTIAL; 3036 skb->ip_summed = CHECKSUM_PARTIAL;
3037 skb->csum_start = skb_transport_header(skb) - skb->head; 3037 skb->csum_start = skb_transport_header(skb) - skb->head;
3038 skb->csum_offset = offsetof(struct udphdr, check); 3038 skb->csum_offset = offsetof(struct udphdr, check);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index e0b94cd843d7..568e2bc0d93d 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -911,7 +911,7 @@ static int __ip_append_data(struct sock *sk,
911 */ 911 */
912 if (transhdrlen && 912 if (transhdrlen &&
913 length + fragheaderlen <= mtu && 913 length + fragheaderlen <= mtu &&
914 rt->dst.dev->features & NETIF_F_V4_CSUM && 914 rt->dst.dev->features & (NETIF_F_HW_CSUM | NETIF_F_IP_CSUM) &&
915 !(flags & MSG_MORE) && 915 !(flags & MSG_MORE) &&
916 !exthdrlen) 916 !exthdrlen)
917 csummode = CHECKSUM_PARTIAL; 917 csummode = CHECKSUM_PARTIAL;
diff --git a/net/ipv4/netfilter/nf_nat_l3proto_ipv4.c b/net/ipv4/netfilter/nf_nat_l3proto_ipv4.c
index 5075b7ecd26d..61c7cc22ea68 100644
--- a/net/ipv4/netfilter/nf_nat_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_nat_l3proto_ipv4.c
@@ -132,7 +132,8 @@ static void nf_nat_ipv4_csum_recalc(struct sk_buff *skb,
132 132
133 if (skb->ip_summed != CHECKSUM_PARTIAL) { 133 if (skb->ip_summed != CHECKSUM_PARTIAL) {
134 if (!(rt->rt_flags & RTCF_LOCAL) && 134 if (!(rt->rt_flags & RTCF_LOCAL) &&
135 (!skb->dev || skb->dev->features & NETIF_F_V4_CSUM)) { 135 (!skb->dev || skb->dev->features &
136 (NETIF_F_IP_CSUM | NETIF_F_HW_CSUM))) {
136 skb->ip_summed = CHECKSUM_PARTIAL; 137 skb->ip_summed = CHECKSUM_PARTIAL;
137 skb->csum_start = skb_headroom(skb) + 138 skb->csum_start = skb_headroom(skb) +
138 skb_network_offset(skb) + 139 skb_network_offset(skb) +
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 0c7b0e61b917..8841e984f8bf 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -772,7 +772,8 @@ void udp_set_csum(bool nocheck, struct sk_buff *skb,
772 else if (skb_is_gso(skb)) 772 else if (skb_is_gso(skb))
773 uh->check = ~udp_v4_check(len, saddr, daddr, 0); 773 uh->check = ~udp_v4_check(len, saddr, daddr, 0);
774 else if (skb_dst(skb) && skb_dst(skb)->dev && 774 else if (skb_dst(skb) && skb_dst(skb)->dev &&
775 (skb_dst(skb)->dev->features & NETIF_F_V4_CSUM)) { 775 (skb_dst(skb)->dev->features &
776 (NETIF_F_IP_CSUM | NETIF_F_HW_CSUM))) {
776 777
777 BUG_ON(skb->ip_summed == CHECKSUM_PARTIAL); 778 BUG_ON(skb->ip_summed == CHECKSUM_PARTIAL);
778 779
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index f9386160cbee..130042660181 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -60,8 +60,9 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
60 60
61 /* Try to offload checksum if possible */ 61 /* Try to offload checksum if possible */
62 offload_csum = !!(need_csum && 62 offload_csum = !!(need_csum &&
63 (skb->dev->features & 63 ((skb->dev->features & NETIF_F_HW_CSUM) ||
64 (is_ipv6 ? NETIF_F_V6_CSUM : NETIF_F_V4_CSUM))); 64 (skb->dev->features & (is_ipv6 ?
65 NETIF_F_IPV6_CSUM : NETIF_F_IP_CSUM))));
65 66
66 /* segment inner packet. */ 67 /* segment inner packet. */
67 enc_features = skb->dev->hw_enc_features & features; 68 enc_features = skb->dev->hw_enc_features & features;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index e6a7bd15b9b7..2f748452b4aa 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1322,7 +1322,7 @@ emsgsize:
1322 headersize == sizeof(struct ipv6hdr) && 1322 headersize == sizeof(struct ipv6hdr) &&
1323 length < mtu - headersize && 1323 length < mtu - headersize &&
1324 !(flags & MSG_MORE) && 1324 !(flags & MSG_MORE) &&
1325 rt->dst.dev->features & NETIF_F_V6_CSUM) 1325 rt->dst.dev->features & (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))
1326 csummode = CHECKSUM_PARTIAL; 1326 csummode = CHECKSUM_PARTIAL;
1327 1327
1328 if (sk->sk_type == SOCK_DGRAM || sk->sk_type == SOCK_RAW) { 1328 if (sk->sk_type == SOCK_DGRAM || sk->sk_type == SOCK_RAW) {
diff --git a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
index 238e70c3f7b7..6ce309928841 100644
--- a/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
@@ -136,7 +136,8 @@ static void nf_nat_ipv6_csum_recalc(struct sk_buff *skb,
136 136
137 if (skb->ip_summed != CHECKSUM_PARTIAL) { 137 if (skb->ip_summed != CHECKSUM_PARTIAL) {
138 if (!(rt->rt6i_flags & RTF_LOCAL) && 138 if (!(rt->rt6i_flags & RTF_LOCAL) &&
139 (!skb->dev || skb->dev->features & NETIF_F_V6_CSUM)) { 139 (!skb->dev || skb->dev->features &
140 (NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM))) {
140 skb->ip_summed = CHECKSUM_PARTIAL; 141 skb->ip_summed = CHECKSUM_PARTIAL;
141 skb->csum_start = skb_headroom(skb) + 142 skb->csum_start = skb_headroom(skb) +
142 skb_network_offset(skb) + 143 skb_network_offset(skb) +