Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0914a57 authored by Alexander Duyck's avatar Alexander Duyck Committed by Sean Tranchetti
Browse files

udp: Add support for software checksum and GSO_PARTIAL with GSO offload



This patch adds support for a software provided checksum and GSO_PARTIAL
segmentation support. With this we can offload UDP segmentation on devices
that only have partial support for tunnels.

Since we are no longer needing the hardware checksum we can drop the checks
in the segmentation code that were verifying if it was present.

Change-Id: I7a24452f0f906e391fb968c3bac58177dd6c407d
CRs-Fixed: 2351793
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Acked-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Git-commit: 6053d0f1
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git


Signed-off-by: default avatarSean Tranchetti <stranche@codeaurora.org>
parent 575cdff0
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -214,6 +214,13 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
		return segs;
	}

	/* GSO partial and frag_list segmentation only requires splitting
	 * the frame into an MSS multiple and possibly a remainder, both
	 * cases return a GSO skb. So update the mss now.
	 */
	if (skb_is_gso(segs))
		mss *= skb_shinfo(segs)->gso_segs;

	seg = segs;
	uh = udp_hdr(seg);

@@ -232,6 +239,12 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
		uh->len = newlen;
		uh->check = check;

		if (seg->ip_summed == CHECKSUM_PARTIAL)
			gso_reset_checksum(seg, ~check);
		else
			uh->check = gso_make_checksum(seg, ~check) ? :
				    CSUM_MANGLED_0;

		seg = seg->next;
		uh = udp_hdr(seg);
	}
@@ -244,21 +257,17 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
	uh->len = newlen;
	uh->check = check;

	if (seg->ip_summed == CHECKSUM_PARTIAL)
		gso_reset_checksum(seg, ~check);
	else
		uh->check = gso_make_checksum(seg, ~check) ? : CSUM_MANGLED_0;

	/* update refcount for the packet */
	refcount_add(sum_truesize - gso_skb->truesize, &sk->sk_wmem_alloc);

	return segs;
}

static struct sk_buff *__udp4_gso_segment(struct sk_buff *gso_skb,
					  netdev_features_t features)
{
	if (!can_checksum_protocol(features, htons(ETH_P_IP)))
		return ERR_PTR(-EIO);

	return __udp_gso_segment(gso_skb, features);
}
EXPORT_SYMBOL_GPL(__udp4_gso_segment);
EXPORT_SYMBOL_GPL(__udp_gso_segment);

static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
					 netdev_features_t features)
@@ -283,7 +292,7 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
		goto out;

	if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
		return __udp4_gso_segment(skb, features);
		return __udp_gso_segment(skb, features);

	mss = skb_shinfo(skb)->gso_size;
	if (unlikely(skb->len <= mss))
+1 −10
Original line number Diff line number Diff line
@@ -17,15 +17,6 @@
#include <net/ip6_checksum.h>
#include "ip6_offload.h"

static struct sk_buff *__udp6_gso_segment(struct sk_buff *gso_skb,
					  netdev_features_t features)
{
	if (!can_checksum_protocol(features, htons(ETH_P_IPV6)))
		return ERR_PTR(-EIO);

	return __udp_gso_segment(gso_skb, features);
}

static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
					 netdev_features_t features)
{
@@ -58,7 +49,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
			goto out;

		if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
			return __udp6_gso_segment(skb, features);
			return __udp_gso_segment(skb, features);

		/* Do software UFO. Complete and fill in the UDP checksum as HW cannot
		 * do checksum of UDP packets sent as multiple IP fragments.