Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

smsc95xx: fix transmission where ZLP is expected

Usbnet framework assumes USB hardware doesn't handle zero length
packets, but SMSC LAN95xx requires these to be sent for correct
operation.

This patch fixes an easily reproducible tx lockup when sending a frame
that results in exactly 512 bytes in a USB transmission (e.g. a UDP
frame with 458 data bytes, due to IP headers and our USB headers). It
adds an extra flag to usbnet for the hardware driver to indicate that
it can handle and requires the zero length packets.

This patch should not affect other usbnet users, please also consider
for -stable.

Signed-off-by: Steve Glendinning <steve.glendinning@smsc.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Steve Glendinning and committed by
David S. Miller
ec475623 36989b90

+3 -2
+1 -1
drivers/net/usb/smsc95xx.c
··· 1227 1227 .rx_fixup = smsc95xx_rx_fixup, 1228 1228 .tx_fixup = smsc95xx_tx_fixup, 1229 1229 .status = smsc95xx_status, 1230 - .flags = FLAG_ETHER, 1230 + .flags = FLAG_ETHER | FLAG_SEND_ZLP, 1231 1231 }; 1232 1232 1233 1233 static const struct usb_device_id products[] = {
+1 -1
drivers/net/usb/usbnet.c
··· 1049 1049 * NOTE: strictly conforming cdc-ether devices should expect 1050 1050 * the ZLP here, but ignore the one-byte packet. 1051 1051 */ 1052 - if ((length % dev->maxpacket) == 0) { 1052 + if (!(info->flags & FLAG_SEND_ZLP) && (length % dev->maxpacket) == 0) { 1053 1053 urb->transfer_buffer_length++; 1054 1054 if (skb_tailroom(skb)) { 1055 1055 skb->data[skb->len] = 0;
+1
include/linux/usb/usbnet.h
··· 89 89 #define FLAG_FRAMING_AX 0x0040 /* AX88772/178 packets */ 90 90 #define FLAG_WLAN 0x0080 /* use "wlan%d" names */ 91 91 #define FLAG_AVOID_UNLINK_URBS 0x0100 /* don't unlink urbs at usbnet_stop() */ 92 + #define FLAG_SEND_ZLP 0x0200 /* hw requires ZLPs are sent */ 92 93 93 94 94 95 /* init device ... can sleep, or cause probe() failure */