aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index efc55feddc5c..9f54ccbddea7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -593,30 +593,25 @@ static int get_fixed_ipv4_csum(__wsum hw_checksum, struct sk_buff *skb,
593} 593}
594 594
595#if IS_ENABLED(CONFIG_IPV6) 595#if IS_ENABLED(CONFIG_IPV6)
596/* In IPv6 packets, besides subtracting the pseudo header checksum, 596/* In IPv6 packets, hw_checksum lacks 6 bytes from IPv6 header:
597 * we also compute/add the IP header checksum which 597 * 4 first bytes : priority, version, flow_lbl
598 * is not added by the HW. 598 * and 2 additional bytes : nexthdr, hop_limit.
599 */ 599 */
600static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb, 600static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb,
601 struct ipv6hdr *ipv6h) 601 struct ipv6hdr *ipv6h)
602{ 602{
603 __u8 nexthdr = ipv6h->nexthdr; 603 __u8 nexthdr = ipv6h->nexthdr;
604 __wsum csum_pseudo_hdr = 0; 604 __wsum temp;
605 605
606 if (unlikely(nexthdr == IPPROTO_FRAGMENT || 606 if (unlikely(nexthdr == IPPROTO_FRAGMENT ||
607 nexthdr == IPPROTO_HOPOPTS || 607 nexthdr == IPPROTO_HOPOPTS ||
608 nexthdr == IPPROTO_SCTP)) 608 nexthdr == IPPROTO_SCTP))
609 return -1; 609 return -1;
610 hw_checksum = csum_add(hw_checksum, (__force __wsum)htons(nexthdr));
611 610
612 csum_pseudo_hdr = csum_partial(&ipv6h->saddr, 611 /* priority, version, flow_lbl */
613 sizeof(ipv6h->saddr) + sizeof(ipv6h->daddr), 0); 612 temp = csum_add(hw_checksum, *(__wsum *)ipv6h);
614 csum_pseudo_hdr = csum_add(csum_pseudo_hdr, (__force __wsum)ipv6h->payload_len); 613 /* nexthdr and hop_limit */
615 csum_pseudo_hdr = csum_add(csum_pseudo_hdr, 614 skb->csum = csum_add(temp, (__force __wsum)*(__be16 *)&ipv6h->nexthdr);
616 (__force __wsum)htons(nexthdr));
617
618 skb->csum = csum_sub(hw_checksum, csum_pseudo_hdr);
619 skb->csum = csum_add(skb->csum, csum_partial(ipv6h, sizeof(struct ipv6hdr), 0));
620 return 0; 615 return 0;
621} 616}
622#endif 617#endif