提交 8bca5d1e 编写于 作者: E Eric Dumazet 提交者: David S. Miller

vmxnet3: cleanup tso headers manipulation

Use existing helpers to clarify skb headers manipulation.
Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
Cc: Shreyas Bhatewara <sbhatewara@vmware.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 aaca2377
...@@ -816,27 +816,24 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, ...@@ -816,27 +816,24 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
if (ctx->mss) { /* TSO */ if (ctx->mss) { /* TSO */
ctx->eth_ip_hdr_size = skb_transport_offset(skb); ctx->eth_ip_hdr_size = skb_transport_offset(skb);
ctx->l4_hdr_size = ((struct tcphdr *) ctx->l4_hdr_size = tcp_hdrlen(skb);
skb_transport_header(skb))->doff * 4;
ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size; ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size;
} else { } else {
if (skb->ip_summed == CHECKSUM_PARTIAL) { if (skb->ip_summed == CHECKSUM_PARTIAL) {
ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb); ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb);
if (ctx->ipv4) { if (ctx->ipv4) {
struct iphdr *iph = (struct iphdr *) const struct iphdr *iph = ip_hdr(skb);
skb_network_header(skb);
if (iph->protocol == IPPROTO_TCP) if (iph->protocol == IPPROTO_TCP)
ctx->l4_hdr_size = ((struct tcphdr *) ctx->l4_hdr_size = tcp_hdrlen(skb);
skb_transport_header(skb))->doff * 4;
else if (iph->protocol == IPPROTO_UDP) else if (iph->protocol == IPPROTO_UDP)
/* /*
* Use tcp header size so that bytes to * Use tcp header size so that bytes to
* be copied are more than required by * be copied are more than required by
* the device. * the device.
*/ */
ctx->l4_hdr_size = ctx->l4_hdr_size = sizeof(struct tcphdr);
sizeof(struct tcphdr);
else else
ctx->l4_hdr_size = 0; ctx->l4_hdr_size = 0;
} else { } else {
...@@ -881,14 +878,17 @@ static void ...@@ -881,14 +878,17 @@ static void
vmxnet3_prepare_tso(struct sk_buff *skb, vmxnet3_prepare_tso(struct sk_buff *skb,
struct vmxnet3_tx_ctx *ctx) struct vmxnet3_tx_ctx *ctx)
{ {
struct tcphdr *tcph = (struct tcphdr *)skb_transport_header(skb); struct tcphdr *tcph = tcp_hdr(skb);
if (ctx->ipv4) { if (ctx->ipv4) {
struct iphdr *iph = (struct iphdr *)skb_network_header(skb); struct iphdr *iph = ip_hdr(skb);
iph->check = 0; iph->check = 0;
tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0, tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0,
IPPROTO_TCP, 0); IPPROTO_TCP, 0);
} else { } else {
struct ipv6hdr *iph = (struct ipv6hdr *)skb_network_header(skb); struct ipv6hdr *iph = ipv6_hdr(skb);
tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0, tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0,
IPPROTO_TCP, 0); IPPROTO_TCP, 0);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册