Skip to contentSkip to conversation

A couple of minor fixes

PATCH New Alexander Duyck 2 participants 5 messages Mar 18, 2016 – Mar 24, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover A couple of minor fixes

These two patches are minor fixes for some previous work.

The i40e patch updates the code so that it will correctly compute the checksum based on changes I made to the upstream kernel. However the impact should be minimal as TCP doesn't appear to currently generate frames large enough to actually overflow the 16 bit UDP length field.

The igb patch is a fix for a bug reported by the kbuild test robot.

---

Alexander Duyck (2):
i40e/i40evf: Fix TSO checksum pseudo-header adjustment
igb: Fix sparse warning about passing __beXX into leXX_to_cpup

 drivers/net/ethernet/intel/i40e/i40e_txrx.c   |   11 ++++-------
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c |   11 ++++-------
 drivers/net/ethernet/intel/igb/igb_main.c     |   10 ++++++----
 3 files changed, 14 insertions(+), 18 deletions(-)

--

#1 lore raw

PATCH 1/2 i40e/i40evf: Fix TSO checksum pseudo-header adjustment

With IPv4 and IPv6 now using the same format for checksums based on the length of the frame we need to update the i40e and i40evf drivers so that they correctly account for lengths greater than or equal to 64K.

With this patch the driver should now correctly update checksums for frames up to 16776960 in length which should be more than large enough for all possible TSO frames in the near future.

---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   |   11 ++++-------
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c |   11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +4 -7
index 5bef5b0f00d9..5d5fa5359a1d 100644
@@ -2304,10 +2304,8 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
 			l4_offset = l4.hdr - skb->data;
 
 			/* remove payload length from outer checksum */
-			paylen = (__force u16)l4.udp->check;
-			paylen += ntohs((__force __be16)1) *
-					(u16)~(skb->len - l4_offset);
-			l4.udp->check = ~csum_fold((__force __wsum)paylen);
+			paylen = skb->len - l4_offset;
+			csum_replace_by_diff(&l4.udp->check, htonl(paylen));
 		}
 
 		/* reset pointers to inner headers */
@@ -2327,9 +2325,8 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
 	l4_offset = l4.hdr - skb->data;
 
 	/* remove payload length from inner checksum */
-	paylen = (__force u16)l4.tcp->check;
-	paylen += ntohs((__force __be16)1) * (u16)~(skb->len - l4_offset);
-	l4.tcp->check = ~csum_fold((__force __wsum)paylen);
+	paylen = skb->len - l4_offset;
+	csum_replace_by_diff(&l4.tcp->check, htonl(paylen));
 
 	/* compute length of segmentation header */
 	*hdr_len = (l4.tcp->doff * 4) + l4_offset;
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +4 -7
index 570348d93e5d..04aabc52ba0d 100644
@@ -1571,10 +1571,8 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
 			l4_offset = l4.hdr - skb->data;
 
 			/* remove payload length from outer checksum */
-			paylen = (__force u16)l4.udp->check;
-			paylen += ntohs((__force __be16)1) *
-					(u16)~(skb->len - l4_offset);
-			l4.udp->check = ~csum_fold((__force __wsum)paylen);
+			paylen = skb->len - l4_offset;
+			csum_replace_by_diff(&l4.udp->check, htonl(paylen));
 		}
 
 		/* reset pointers to inner headers */
@@ -1594,9 +1592,8 @@ static int i40e_tso(struct i40e_ring *tx_ring, struct sk_buff *skb,
 	l4_offset = l4.hdr - skb->data;
 
 	/* remove payload length from inner checksum */
-	paylen = (__force u16)l4.tcp->check;
-	paylen += ntohs((__force __be16)1) * (u16)~(skb->len - l4_offset);
-	l4.tcp->check = ~csum_fold((__force __wsum)paylen);
+	paylen = skb->len - l4_offset;
+	csum_replace_by_diff(&l4.tcp->check, htonl(paylen));
 
 	/* compute length of segmentation header */
 	*hdr_len = (l4.tcp->doff * 4) + l4_offset;
#2 lore raw

PATCH 1/2 i40e/i40evf: Fix TSO checksum pseudo-header adjustment

Quoted 16 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alexander Duyck
Sent: Friday, March 18, 2016 4:07 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 1/2] i40e/i40evf: Fix TSO checksum pseudo-header adjustment

With IPv4 and IPv6 now using the same format for checksums based on the length of the frame we need to update the i40e and i40evf drivers so that they correctly account for lengths greater than or equal to 64K.

With this patch the driver should now correctly update checksums for frames up to 16776960 in length which should be more than large enough for all possible TSO frames in the near future.

Quoted 5 lines
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   |   11 ++++-------
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c |   11 ++++-------
 2 files changed, 8 insertions(+), 14 deletions(-)

TSO works correctly

#3 lore raw

PATCH 2/2 igb: Fix sparse warning about passing __beXX into leXX_to_cpup

In reply to Alexander Duyck

We were casting the addr as __beXX and then passing it into le32_to_cpu because the device expects the MAC address to be in network order even though the register set is little endian. Instead of casting it as __beXX we can just cast it as __leXX in order to maintain consistency since the region of memory is already in little endian order as far as we are concerned.

---
 drivers/net/ethernet/intel/igb/igb_main.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +6 -4
index 7f7e4a2a5fe2..f3fd43e1c4e8 100644
@@ -7850,11 +7850,13 @@ static void igb_rar_set_qsel(struct igb_adapter *adapter, u8 *addr, u32 index,
 	struct e1000_hw *hw = &adapter->hw;
 	u32 rar_low, rar_high;
 
-	/* HW expects these in little endian so we reverse the byte order
-	 * from network order (big endian) to CPU endian
+	/* HW expects these to be in network order when they are plugged
+	 * into the registers which are little endian.  In order to guarantee
+	 * that ordering we need to do an leXX_to_cpup here in order to be
+	 * ready for the byteswap that occurs with writel
 	 */
-	rar_low = le32_to_cpup((__be32 *)(addr));
-	rar_high = le16_to_cpup((__be16 *)(addr + 4));
+	rar_low = le32_to_cpup((__le32 *)(addr));
+	rar_high = le16_to_cpup((__le16 *)(addr + 4));
 
 	/* Indicate to hardware the Address is Valid. */
 	rar_high |= E1000_RAH_AV;
#4 lore raw

PATCH 2/2 igb: Fix sparse warning about passing __beXX into leXX_to_cpup

Quoted 14 lines

From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Alexander Duyck
Sent: Friday, March 18, 2016 4:07 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH 2/2] igb: Fix sparse warning about passing __beXX into leXX_to_cpup

We were casting the addr as __beXX and then passing it into le32_to_cpu because the device expects the MAC address to be in network order even though the register set is little endian. Instead of casting it as __beXX we can just cast it as __leXX in order to maintain consistency since the region of memory is already in little endian order as far as we are concerned.

Quoted 4 lines
---
 drivers/net/ethernet/intel/igb/igb_main.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)