From: Alexander Duyck <aduyck@mirantis.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [next PATCH v3 04/15] i40e/i40evf: Consolidate all header changes into TSO function
Date: Sun, 24 Jan 2016 21:16:35 -0800 [thread overview]
Message-ID: <20160125051635.12004.43998.stgit@localhost.localdomain> (raw)
In-Reply-To: <20160125050602.12004.38884.stgit@localhost.localdomain>
This patch goes through and pulls all of the spots where we were updating
either the TCP or IP checksums in the TSO and checksum path into the TSO
function. The general idea here is that we should only be updating the
header after we verify we have completed a skb_cow_head check to verify the
head is writable.
One other advantage to doing this is that it makes things much more
obvious. For example, in the case of IPv6 there was one spot where the
offset of the IPv4 header checksum was being updated which is obviously
incorrect.
Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
---
drivers/net/ethernet/intel/i40e/i40e_txrx.c | 44 +++++++++++++++----------
drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 44 +++++++++++++++----------
2 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index b09859e55996..c84ba5d4634a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -2268,8 +2268,11 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
u8 *hdr_len, u64 *cd_type_cmd_tso_mss)
{
u64 cd_cmd, cd_tso_len, cd_mss;
- struct ipv6hdr *ipv6h;
- struct iphdr *iph;
+ union {
+ struct iphdr *v4;
+ struct ipv6hdr *v6;
+ unsigned char *hdr;
+ } ip;
union {
struct tcphdr *tcp;
unsigned char *hdr;
@@ -2287,16 +2290,29 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
if (err < 0)
return err;
- iph = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb);
- ipv6h = skb->encapsulation ? inner_ipv6_hdr(skb) : ipv6_hdr(skb);
- l4.hdr = skb->encapsulation ? skb_inner_transport_header(skb) :
- skb_transport_header(skb);
+ ip.hdr = skb_network_header(skb);
+ l4.hdr = skb_transport_header(skb);
- if (iph->version == 4) {
- iph->tot_len = 0;
- iph->check = 0;
+ /* initialize outer IP header fields */
+ if (ip.v4->version == 4) {
+ ip.v4->tot_len = 0;
+ ip.v4->check = 0;
} else {
- ipv6h->payload_len = 0;
+ ip.v6->payload_len = 0;
+ }
+
+ if (skb_shinfo(skb)->gso_type & (SKB_GSO_UDP_TUNNEL | SKB_GSO_GRE)) {
+ /* reset pointers to inner headers */
+ ip.hdr = skb_inner_network_header(skb);
+ l4.hdr = skb_inner_transport_header(skb);
+
+ /* initialize inner IP header fields */
+ if (ip.v4->version == 4) {
+ ip.v4->tot_len = 0;
+ ip.v4->check = 0;
+ } else {
+ ip.v6->payload_len = 0;
+ }
}
/* determine offset of inner transport header */
@@ -2381,15 +2397,11 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags,
struct iphdr *this_ip_hdr;
u32 network_hdr_len;
u8 l4_hdr = 0;
- struct udphdr *oudph = NULL;
- struct iphdr *oiph = NULL;
u32 l4_tunnel = 0;
if (skb->encapsulation) {
switch (ip_hdr(skb)->protocol) {
case IPPROTO_UDP:
- oudph = udp_hdr(skb);
- oiph = ip_hdr(skb);
l4_tunnel = I40E_TXD_CTX_UDP_TUNNELING;
*tx_flags |= I40E_TX_FLAGS_TUNNEL;
break;
@@ -2408,15 +2420,12 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags,
if (*tx_flags & I40E_TX_FLAGS_IPV4) {
if (*tx_flags & I40E_TX_FLAGS_TSO) {
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
- ip_hdr(skb)->check = 0;
} else {
*cd_tunneling |=
I40E_TX_CTX_EXT_IP_IPV4_NO_CSUM;
}
} else if (*tx_flags & I40E_TX_FLAGS_IPV6) {
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;
- if (*tx_flags & I40E_TX_FLAGS_TSO)
- ip_hdr(skb)->check = 0;
}
/* Now set the ctx descriptor fields */
@@ -2445,7 +2454,6 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags,
*/
if (*tx_flags & I40E_TX_FLAGS_TSO) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
- this_ip_hdr->check = 0;
} else {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4;
}
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index b0dc21af3cc8..1b2788093425 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -1528,8 +1528,11 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
u8 *hdr_len, u64 *cd_type_cmd_tso_mss)
{
u64 cd_cmd, cd_tso_len, cd_mss;
- struct ipv6hdr *ipv6h;
- struct iphdr *iph;
+ union {
+ struct iphdr *v4;
+ struct ipv6hdr *v6;
+ unsigned char *hdr;
+ } ip;
union {
struct tcphdr *tcp;
unsigned char *hdr;
@@ -1547,16 +1550,29 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
if (err < 0)
return err;
- iph = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb);
- ipv6h = skb->encapsulation ? inner_ipv6_hdr(skb) : ipv6_hdr(skb);
- l4.hdr = skb->encapsulation ? skb_inner_transport_header(skb) :
- skb_transport_header(skb);
+ ip.hdr = skb_network_header(skb);
+ l4.hdr = skb_transport_header(skb);
- if (iph->version == 4) {
- iph->tot_len = 0;
- iph->check = 0;
+ /* initialize outer IP header fields */
+ if (ip.v4->version == 4) {
+ ip.v4->tot_len = 0;
+ ip.v4->check = 0;
} else {
- ipv6h->payload_len = 0;
+ ip.v6->payload_len = 0;
+ }
+
+ if (skb_shinfo(skb)->gso_type & (SKB_GSO_UDP_TUNNEL | SKB_GSO_GRE)) {
+ /* reset pointers to inner headers */
+ ip.hdr = skb_inner_network_header(skb);
+ l4.hdr = skb_inner_transport_header(skb);
+
+ /* initialize inner IP header fields */
+ if (ip.v4->version == 4) {
+ ip.v4->tot_len = 0;
+ ip.v4->check = 0;
+ } else {
+ ip.v6->payload_len = 0;
+ }
}
/* determine offset of inner transport header */
@@ -1598,15 +1614,11 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags,
struct iphdr *this_ip_hdr;
u32 network_hdr_len;
u8 l4_hdr = 0;
- struct udphdr *oudph;
- struct iphdr *oiph;
u32 l4_tunnel = 0;
if (skb->encapsulation) {
switch (ip_hdr(skb)->protocol) {
case IPPROTO_UDP:
- oudph = udp_hdr(skb);
- oiph = ip_hdr(skb);
l4_tunnel = I40E_TXD_CTX_UDP_TUNNELING;
*tx_flags |= I40E_TX_FLAGS_TUNNEL;
break;
@@ -1621,15 +1633,12 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags,
if (*tx_flags & I40E_TX_FLAGS_IPV4) {
if (*tx_flags & I40E_TX_FLAGS_TSO) {
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV4;
- ip_hdr(skb)->check = 0;
} else {
*cd_tunneling |=
I40E_TX_CTX_EXT_IP_IPV4_NO_CSUM;
}
} else if (*tx_flags & I40E_TX_FLAGS_IPV6) {
*cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;
- if (*tx_flags & I40E_TX_FLAGS_TSO)
- ip_hdr(skb)->check = 0;
}
/* Now set the ctx descriptor fields */
@@ -1659,7 +1668,6 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags,
*/
if (*tx_flags & I40E_TX_FLAGS_TSO) {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM;
- this_ip_hdr->check = 0;
} else {
*td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4;
}
next prev parent reply other threads:[~2016-01-25 5:16 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-25 5:16 [Intel-wired-lan] [next PATCH v3 00/15] TSO and checksum fixes for i40e Alexander Duyck
2016-01-25 5:16 ` [Intel-wired-lan] [next PATCH v3 01/15] i40e/i40evf: Drop outer checksum offload that was not requested Alexander Duyck
2016-01-27 16:00 ` Bowers, AndrewX
2016-01-25 5:16 ` [Intel-wired-lan] [next PATCH v3 02/15] i40e/i40evf: Use u64 values instead of casting them in TSO function Alexander Duyck
2016-01-27 16:03 ` Bowers, AndrewX
2016-01-25 5:16 ` [Intel-wired-lan] [next PATCH v3 03/15] i40e/i40evf: Factor out L4 header and checksum from L3 bits in TSO path Alexander Duyck
2016-01-27 16:09 ` Bowers, AndrewX
2016-01-25 5:16 ` Alexander Duyck [this message]
2016-01-27 16:14 ` [Intel-wired-lan] [next PATCH v3 04/15] i40e/i40evf: Consolidate all header changes into TSO function Bowers, AndrewX
2016-01-25 5:16 ` [Intel-wired-lan] [next PATCH v3 05/15] i40e/i40evf: Replace header pointers with unions of pointers in Tx checksum path Alexander Duyck
2016-01-27 16:27 ` Bowers, AndrewX
2016-01-25 5:16 ` [Intel-wired-lan] [next PATCH v3 06/15] i40e/i40evf: Add support for IPv4 encapsulated in IPv6 Alexander Duyck
2016-01-27 18:04 ` Bowers, AndrewX
2016-01-25 5:16 ` [Intel-wired-lan] [next PATCH v3 07/15] i40e/i40evf: Handle IPv6 extension headers in checksum offload Alexander Duyck
2016-01-27 18:05 ` Bowers, AndrewX
2016-01-25 5:17 ` [Intel-wired-lan] [next PATCH v3 08/15] i40e/i40evf: Do not write to descriptor unless we complete Alexander Duyck
2016-01-27 18:07 ` Bowers, AndrewX
2016-01-25 5:17 ` [Intel-wired-lan] [next PATCH v3 09/15] i40e/i40evf: Add exception handling for Tx checksum Alexander Duyck
2016-01-27 18:08 ` Bowers, AndrewX
2016-01-25 5:17 ` [Intel-wired-lan] [next PATCH v3 10/15] i40e/i40evf: Clean-up Rx packet checksum handling Alexander Duyck
2016-01-27 18:09 ` Bowers, AndrewX
2016-01-25 5:17 ` [Intel-wired-lan] [next PATCH v3 11/15] i40e/i40evf: Enable support for SKB_GSO_UDP_TUNNEL_CSUM Alexander Duyck
2016-01-27 18:17 ` Bowers, AndrewX
2016-02-02 22:49 ` Jesse Brandeburg
2016-02-02 23:10 ` Jesse Brandeburg
2016-02-02 23:18 ` Jesse Brandeburg
2016-02-03 0:06 ` Alexander Duyck
2016-01-25 5:17 ` [Intel-wired-lan] [next PATCH v3 12/15] i40e: Fix ATR in relation to tunnels Alexander Duyck
2016-01-25 19:27 ` Patil, Kiran
2016-01-25 22:21 ` Alexander Duyck
2016-01-26 0:16 ` Patil, Kiran
2016-01-27 18:18 ` Bowers, AndrewX
2016-01-25 5:17 ` [Intel-wired-lan] [next PATCH v3 13/15] i40e: Do not drop support for IPv6 VXLAN or GENEVE tunnels Alexander Duyck
2016-01-27 18:26 ` Bowers, AndrewX
2016-01-25 5:17 ` [Intel-wired-lan] [next PATCH v3 14/15] i40e: Update feature flags to reflect newly enabled features Alexander Duyck
2016-01-27 18:44 ` Bowers, AndrewX
2016-01-25 5:17 ` [Intel-wired-lan] [next PATCH v3 15/15] i40evf: " Alexander Duyck
2016-01-25 19:43 ` Singhai, Anjali
2016-01-27 18:45 ` Bowers, AndrewX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160125051635.12004.43998.stgit@localhost.localdomain \
--to=aduyck@mirantis.com \
--cc=intel-wired-lan@osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.