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

tile: support TSO for IPv6 in tilegx network driver

Signed-off-by: default avatarChris Metcalf <cmetcalf@tilera.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f3286a3a
...@@ -36,6 +36,7 @@ ...@@ -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) ...@@ -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, ...@@ -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. */
ih = ip_hdr(skb); 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_off = skb_network_offset(skb);
isum_seed = ((0xFFFF - ih->check) +
(0xFFFF - ih->tot_len) +
(0xFFFF - ih->id));
id = ntohs(ih->id);
}
th = tcp_hdr(skb); th = tcp_hdr(skb);
ih_off = skb_network_offset(skb);
th_off = skb_transport_offset(skb); th_off = skb_transport_offset(skb);
p_len = sh->gso_size; p_len = sh->gso_size;
/* Set up seed values for IP and TCP csum and initialize id and seq. */
isum_seed = ((0xFFFF - ih->check) +
(0xFFFF - ih->tot_len) +
(0xFFFF - ih->id));
tsum_seed = th->check + (0xFFFF ^ htons(skb->len)); tsum_seed = th->check + (0xFFFF ^ htons(skb->len));
id = ntohs(ih->id);
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, ...@@ -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. */
ih = (struct iphdr *)(buf + ih_off); if (is_ipv6) {
ih->tot_len = htons(sh_len + p_len - ih_off); ih6 = (struct ipv6hdr *)(buf + ih_off);
ih->id = htons(id); ih6->payload_len = htons(sh_len + p_len - ih_off -
ih->check = csum_long(isum_seed + ih->tot_len + sizeof(*ih6));
ih->id) ^ 0xffff; } else {
ih = (struct iphdr *)(buf + ih_off);
ih->tot_len = htons(sh_len + p_len - ih_off);
ih->id = htons(id);
ih->check = csum_long(isum_seed + ih->tot_len +
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) ...@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment