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

Commit 2c7d04a9 authored by Chris Metcalf's avatar Chris Metcalf Committed by David S. Miller
Browse files

tile: support TSO for IPv6 in tilegx network driver

parent f3286a3a
Loading
Loading
Loading
Loading
+29 −15
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@
#include <linux/io.h>
#include <linux/io.h>
#include <linux/ctype.h>
#include <linux/ctype.h>
#include <linux/ip.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/tcp.h>
#include <linux/tcp.h>


#include <asm/checksum.h>
#include <asm/checksum.h>
@@ -1512,20 +1513,20 @@ static int tso_count_edescs(struct sk_buff *skb)
	return num_edescs;
	return num_edescs;
}
}


/* Prepare modified copies of the skbuff headers.
/* Prepare modified copies of the skbuff headers. */
 * FIXME: add support for IPv6.
 */
static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
				s64 slot)
				s64 slot)
{
{
	struct skb_shared_info *sh = skb_shinfo(skb);
	struct skb_shared_info *sh = skb_shinfo(skb);
	struct iphdr *ih;
	struct iphdr *ih;
	struct ipv6hdr *ih6;
	struct tcphdr *th;
	struct tcphdr *th;
	unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
	unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
	unsigned int data_len = skb->len - sh_len;
	unsigned int data_len = skb->len - sh_len;
	unsigned char *data = skb->data;
	unsigned char *data = skb->data;
	unsigned int ih_off, th_off, p_len;
	unsigned int ih_off, th_off, p_len;
	unsigned int isum_seed, tsum_seed, id, seq;
	unsigned int isum_seed, tsum_seed, id, seq;
	int is_ipv6;
	long f_id = -1;    /* id of the current fragment */
	long f_id = -1;    /* id of the current fragment */
	long f_size = skb_headlen(skb) - sh_len;  /* current fragment size */
	long f_size = skb_headlen(skb) - sh_len;  /* current fragment size */
	long f_used = 0;  /* bytes used from the current fragment */
	long f_used = 0;  /* bytes used from the current fragment */
@@ -1533,18 +1534,24 @@ static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
	int segment;
	int segment;


	/* Locate original headers and compute various lengths. */
	/* Locate original headers and compute various lengths. */
	is_ipv6 = skb_is_gso_v6(skb);
	if (is_ipv6) {
		ih6 = ipv6_hdr(skb);
		ih_off = skb_network_offset(skb);
	} else {
		ih = ip_hdr(skb);
		ih = ip_hdr(skb);
	th = tcp_hdr(skb);
		ih_off = skb_network_offset(skb);
		ih_off = skb_network_offset(skb);
	th_off = skb_transport_offset(skb);
	p_len = sh->gso_size;

	/* Set up seed values for IP and TCP csum and initialize id and seq. */
		isum_seed = ((0xFFFF - ih->check) +
		isum_seed = ((0xFFFF - ih->check) +
			     (0xFFFF - ih->tot_len) +
			     (0xFFFF - ih->tot_len) +
			     (0xFFFF - ih->id));
			     (0xFFFF - ih->id));
	tsum_seed = th->check + (0xFFFF ^ htons(skb->len));
		id = ntohs(ih->id);
		id = ntohs(ih->id);
	}

	th = tcp_hdr(skb);
	th_off = skb_transport_offset(skb);
	p_len = sh->gso_size;

	tsum_seed = th->check + (0xFFFF ^ htons(skb->len));
	seq = ntohl(th->seq);
	seq = ntohl(th->seq);


	/* Prepare all the headers. */
	/* Prepare all the headers. */
@@ -1558,11 +1565,17 @@ static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
		memcpy(buf, data, sh_len);
		memcpy(buf, data, sh_len);


		/* Update copied ip header. */
		/* Update copied ip header. */
		if (is_ipv6) {
			ih6 = (struct ipv6hdr *)(buf + ih_off);
			ih6->payload_len = htons(sh_len + p_len - ih_off -
						 sizeof(*ih6));
		} else {
			ih = (struct iphdr *)(buf + ih_off);
			ih = (struct iphdr *)(buf + ih_off);
			ih->tot_len = htons(sh_len + p_len - ih_off);
			ih->tot_len = htons(sh_len + p_len - ih_off);
			ih->id = htons(id);
			ih->id = htons(id);
			ih->check = csum_long(isum_seed + ih->tot_len +
			ih->check = csum_long(isum_seed + ih->tot_len +
					      ih->id) ^ 0xffff;
					      ih->id) ^ 0xffff;
		}


		/* Update copied tcp header. */
		/* Update copied tcp header. */
		th = (struct tcphdr *)(buf + th_off);
		th = (struct tcphdr *)(buf + th_off);
@@ -1954,6 +1967,7 @@ static void tile_net_setup(struct net_device *dev)
	features |= NETIF_F_HW_CSUM;
	features |= NETIF_F_HW_CSUM;
	features |= NETIF_F_SG;
	features |= NETIF_F_SG;
	features |= NETIF_F_TSO;
	features |= NETIF_F_TSO;
	features |= NETIF_F_TSO6;


	dev->hw_features   |= features;
	dev->hw_features   |= features;
	dev->vlan_features |= features;
	dev->vlan_features |= features;