[PATCH] staging: octeon-ethernet: fix TCP/UDP checksum calc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the network portion of a frame is preceded by more than 14 bytes of
data, the checksum calculated in the HW is done over the wrong data and
is put in the wrong place.
In our use case an Octeon ethernet controller is connected to a Broadcom
switch chip. Extra data is included in the frame prior to egressing the
Octeon ethernet (i.e. 4 bytes of an 802.1Q tag, 4 bytes of a proprietary
BCM tag later stripped by the switch chip). This extra data causes the
checksum calculation to be incorrect.
The fix in this patch is to make use of the network header offset of the
skb. This enables the checksum to be calculated correctly.
This has been tested in both the configuration with the switch chip in
the egress path (as described above) and in a simple connection direct
to the wire.

Reviewed-by: Richard Laing <richard.laing@xxxxxxxxxxxxxxxxxxx>
Reviewed-by: Tim Beale <tim.beale@xxxxxxxxxxxxxxxxxxx>
Reviewed-by: Chris Packham <chris.packham@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Hamish Martin <hamish.martin@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/octeon/ethernet-tx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
index c053c4a..5611a02 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -403,7 +403,7 @@ dont_put_skbuff_in_hw:
 	    ((ip_hdr(skb)->protocol == IPPROTO_TCP) ||
 	     (ip_hdr(skb)->protocol == IPPROTO_UDP))) {
 		/* Use hardware checksum calc */
-		pko_command.s.ipoffp1 = sizeof(struct ethhdr) + 1;
+		pko_command.s.ipoffp1 = skb_network_offset(skb) + 1;
 	}
 
 	if (USE_ASYNC_IOBDMA) {
-- 
2.6.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux