netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] r8169: fix rx checksum offload
@ 2010-09-05 20:03 Eric Dumazet
  2010-09-05 20:45 ` [PATCH v2] " Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2010-09-05 20:03 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Francois Romieu, Neil Horman

While porting GRO to r8169, I found this driver has a bug in its rx
path.

All skbs given to network stack had their ip_summed set to
CHECKSUM_NONE, while hardware said they had correct TCP/UDP checksums.

The reason is driver sets skb->ip_summed on the original skb before the
copy eventually done by copybreak. The fresh skb gets the ip_summed =
CHECKSUM_NONE value, forcing network stack to recompute checksum, and
preventing my GRO patch to work.

Fix is to make the ip_summed setting after skb copy.

Note : rx_copybreak current value is 16383, so all frames are copied...

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 drivers/net/r8169.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 3554041..b589914 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -4458,9 +4458,8 @@ static inline int rtl8169_fragmented_frame(u32 status)
 	return (status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag);
 }
 
-static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc)
+static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
 {
-	u32 opts1 = le32_to_cpu(desc->opts1);
 	u32 status = opts1 & RxProtoMask;
 
 	if (((status == RxProtoTCP) && !(opts1 & TCPFail)) ||
@@ -4541,6 +4540,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
 			dma_addr_t addr = le64_to_cpu(desc->addr);
 			int pkt_size = (status & 0x00001FFF) - 4;
 			struct pci_dev *pdev = tp->pci_dev;
+			u32 opts1;
 
 			/*
 			 * The driver does not support incoming fragmented
@@ -4554,8 +4554,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
 				continue;
 			}
 
-			rtl8169_rx_csum(skb, desc);
-
+			opts1 = le32_to_cpu(desc->opts1);
 			if (rtl8169_try_rx_copy(&skb, tp, pkt_size, addr)) {
 				pci_dma_sync_single_for_device(pdev, addr,
 					pkt_size, PCI_DMA_FROMDEVICE);
@@ -4566,6 +4565,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
 				tp->Rx_skbuff[entry] = NULL;
 			}
 
+			rtl8169_rx_csum(skb, opts1);
 			skb_put(skb, pkt_size);
 			skb->protocol = eth_type_trans(skb, dev);
 



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2] r8169: fix rx checksum offload
  2010-09-05 20:03 [PATCH] r8169: fix rx checksum offload Eric Dumazet
@ 2010-09-05 20:45 ` Eric Dumazet
  2010-09-05 22:29   ` Francois Romieu
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2010-09-05 20:45 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Francois Romieu, Neil Horman

While porting GRO to r8169, I found this driver has a bug in its rx
path.

All skbs given to network stack had their ip_summed set to
CHECKSUM_NONE, while hardware said they had correct TCP/UDP checksums.

The reason is driver sets skb->ip_summed on the original skb before the
copy eventually done by copybreak. The fresh skb gets the ip_summed =
CHECKSUM_NONE value, forcing network stack to recompute checksum, and
preventing my GRO patch to work.

Fix is to make the ip_summed setting after skb copy.

Note : rx_copybreak current value is 16383, so all frames are copied...

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
v2: reuse 'status' variable

 drivers/net/r8169.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 3554041..792eccb 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -4458,9 +4458,8 @@ static inline int rtl8169_fragmented_frame(u32 status)
 	return (status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag);
 }
 
-static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc)
+static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
 {
-	u32 opts1 = le32_to_cpu(desc->opts1);
 	u32 status = opts1 & RxProtoMask;
 
 	if (((status == RxProtoTCP) && !(opts1 & TCPFail)) ||
@@ -4554,8 +4553,6 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
 				continue;
 			}
 
-			rtl8169_rx_csum(skb, desc);
-
 			if (rtl8169_try_rx_copy(&skb, tp, pkt_size, addr)) {
 				pci_dma_sync_single_for_device(pdev, addr,
 					pkt_size, PCI_DMA_FROMDEVICE);
@@ -4566,6 +4563,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
 				tp->Rx_skbuff[entry] = NULL;
 			}
 
+			rtl8169_rx_csum(skb, status);
 			skb_put(skb, pkt_size);
 			skb->protocol = eth_type_trans(skb, dev);
 



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] r8169: fix rx checksum offload
  2010-09-05 20:45 ` [PATCH v2] " Eric Dumazet
@ 2010-09-05 22:29   ` Francois Romieu
  2010-09-06  3:04     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Francois Romieu @ 2010-09-05 22:29 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, netdev, Neil Horman

Eric Dumazet <eric.dumazet@gmail.com> :
[...]
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> ---
> v2: reuse 'status' variable

Acked-by: Francois Romieu <romieu@fr.zoreil.com>

-- 
Ueimor

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] r8169: fix rx checksum offload
  2010-09-05 22:29   ` Francois Romieu
@ 2010-09-06  3:04     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-09-06  3:04 UTC (permalink / raw)
  To: romieu; +Cc: eric.dumazet, netdev, nhorman

From: Francois Romieu <romieu@fr.zoreil.com>
Date: Mon, 6 Sep 2010 00:29:56 +0200

> Eric Dumazet <eric.dumazet@gmail.com> :
> [...]
>> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
>> ---
>> v2: reuse 'status' variable
> 
> Acked-by: Francois Romieu <romieu@fr.zoreil.com>

Applied to net-next-2.6, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-09-06  3:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-05 20:03 [PATCH] r8169: fix rx checksum offload Eric Dumazet
2010-09-05 20:45 ` [PATCH v2] " Eric Dumazet
2010-09-05 22:29   ` Francois Romieu
2010-09-06  3:04     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).