Skip to content

Commit

Permalink
smsc95xx: Fix tx checksum offload for small packets
Browse files Browse the repository at this point in the history
TX checksum offload does not work properly when transmitting
UDP packets with 0, 1 or 2 bytes of data.  This patch works
around the problem by calculating checksums for these packets
in the driver.

Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Steve Glendinning authored and David S. Miller committed Mar 19, 2010
1 parent 0ecad5a commit 11bc308
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions drivers/net/usb/smsc95xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,9 +1189,21 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev,
}

if (csum) {
u32 csum_preamble = smsc95xx_calc_csum_preamble(skb);
skb_push(skb, 4);
memcpy(skb->data, &csum_preamble, 4);
if (skb->len <= 45) {
/* workaround - hardware tx checksum does not work
* properly with extremely small packets */
long csstart = skb->csum_start - skb_headroom(skb);
__wsum calc = csum_partial(skb->data + csstart,
skb->len - csstart, 0);
*((__sum16 *)(skb->data + csstart
+ skb->csum_offset)) = csum_fold(calc);

csum = false;
} else {
u32 csum_preamble = smsc95xx_calc_csum_preamble(skb);
skb_push(skb, 4);
memcpy(skb->data, &csum_preamble, 4);
}
}

skb_push(skb, 4);
Expand Down

0 comments on commit 11bc308

Please sign in to comment.