diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2012-01-24 14:47:21 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-01-25 16:53:10 -0500 |
commit | 8bca5d1ebb8bf18187256845ba3aaff5fbc01934 (patch) | |
tree | 632ac1df401ad84d8bc116ef297953ed20909b9c /drivers/net/vmxnet3 | |
parent | aaca2377e9c08d1964a5cacb95330708a6f6d106 (diff) |
vmxnet3: cleanup tso headers manipulation
Use existing helpers to clarify skb headers manipulation.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Shreyas Bhatewara <sbhatewara@vmware.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/vmxnet3')
-rw-r--r-- | drivers/net/vmxnet3/vmxnet3_drv.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index de7fc345148a..be6aa353f6a1 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c | |||
@@ -816,27 +816,24 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, | |||
816 | 816 | ||
817 | if (ctx->mss) { /* TSO */ | 817 | if (ctx->mss) { /* TSO */ |
818 | ctx->eth_ip_hdr_size = skb_transport_offset(skb); | 818 | ctx->eth_ip_hdr_size = skb_transport_offset(skb); |
819 | ctx->l4_hdr_size = ((struct tcphdr *) | 819 | ctx->l4_hdr_size = tcp_hdrlen(skb); |
820 | skb_transport_header(skb))->doff * 4; | ||
821 | ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size; | 820 | ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size; |
822 | } else { | 821 | } else { |
823 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | 822 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
824 | ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb); | 823 | ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb); |
825 | 824 | ||
826 | if (ctx->ipv4) { | 825 | if (ctx->ipv4) { |
827 | struct iphdr *iph = (struct iphdr *) | 826 | const struct iphdr *iph = ip_hdr(skb); |
828 | skb_network_header(skb); | 827 | |
829 | if (iph->protocol == IPPROTO_TCP) | 828 | if (iph->protocol == IPPROTO_TCP) |
830 | ctx->l4_hdr_size = ((struct tcphdr *) | 829 | ctx->l4_hdr_size = tcp_hdrlen(skb); |
831 | skb_transport_header(skb))->doff * 4; | ||
832 | else if (iph->protocol == IPPROTO_UDP) | 830 | else if (iph->protocol == IPPROTO_UDP) |
833 | /* | 831 | /* |
834 | * Use tcp header size so that bytes to | 832 | * Use tcp header size so that bytes to |
835 | * be copied are more than required by | 833 | * be copied are more than required by |
836 | * the device. | 834 | * the device. |
837 | */ | 835 | */ |
838 | ctx->l4_hdr_size = | 836 | ctx->l4_hdr_size = sizeof(struct tcphdr); |
839 | sizeof(struct tcphdr); | ||
840 | else | 837 | else |
841 | ctx->l4_hdr_size = 0; | 838 | ctx->l4_hdr_size = 0; |
842 | } else { | 839 | } else { |
@@ -881,14 +878,17 @@ static void | |||
881 | vmxnet3_prepare_tso(struct sk_buff *skb, | 878 | vmxnet3_prepare_tso(struct sk_buff *skb, |
882 | struct vmxnet3_tx_ctx *ctx) | 879 | struct vmxnet3_tx_ctx *ctx) |
883 | { | 880 | { |
884 | struct tcphdr *tcph = (struct tcphdr *)skb_transport_header(skb); | 881 | struct tcphdr *tcph = tcp_hdr(skb); |
882 | |||
885 | if (ctx->ipv4) { | 883 | if (ctx->ipv4) { |
886 | struct iphdr *iph = (struct iphdr *)skb_network_header(skb); | 884 | struct iphdr *iph = ip_hdr(skb); |
885 | |||
887 | iph->check = 0; | 886 | iph->check = 0; |
888 | tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0, | 887 | tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0, |
889 | IPPROTO_TCP, 0); | 888 | IPPROTO_TCP, 0); |
890 | } else { | 889 | } else { |
891 | struct ipv6hdr *iph = (struct ipv6hdr *)skb_network_header(skb); | 890 | struct ipv6hdr *iph = ipv6_hdr(skb); |
891 | |||
892 | tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0, | 892 | tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0, |
893 | IPPROTO_TCP, 0); | 893 | IPPROTO_TCP, 0); |
894 | } | 894 | } |