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

[microblaze-uclinux] Another ethernet patch for usbnet.c



Hello,

if you want to use an USB Ethernet Bridge (for example D-Link DUB-E100)
in conjunction with a microblaze processor you have to apply the
following patch to get the usbnet driver working correctly. The problem
here is that the TCP header must be accessed 32 bit aligned on
microblaze. Otherwise the TCP stack doesn't work.

Happy networking on microblaze!

-- 
Dr. Johann Pfefferl   ------------   mailto j.pfefferl at eubus dot net
Eubus GmbH            http://www.eubus.net +++++ http://www.hydraxc.com
Phone: +49 (0)89 45 22 578-67
Fax:   +49 (0)89 45 22 578-55
==
 -o)   A computer program does what you tell it to do,
 /\\        not what you want it to do.               
_\_v-                                                 
diff --git a/drivers/usb/usbnet.c b/drivers/usb/usbnet.c
index 764be51..4a6cf76 100644
--- a/drivers/usb/usbnet.c
+++ b/drivers/usb/usbnet.c
@@ -1815,12 +1815,21 @@ #ifdef CONFIG_USB_ZAURUS
 #endif
 		size = (sizeof (struct ethhdr) + dev->net.mtu);
 
-	if ((skb = alloc_skb (size, flags)) == 0) {
+	if ((skb = alloc_skb (size + 2, flags)) == 0) {
 		dbg ("no rx skb");
 		defer_kevent (dev, EVENT_RX_MEMORY);
 		usb_free_urb (urb);
 		return;
 	}
+  /* Align the data buffer in such a way that the IP header is aligned
+   * on a 16 byte boundary. The ethernet II header has a length of
+   * 14 bytes. The IP header has a length of 20 bytes.
+   * So: 2 + 14 + 20 = 36
+   * The TCP/UDP header then starts at on offset of 36 bytes, which is
+   * 4 byte aligned. This is necessary on microblaze to get the TCP
+   * network stack working correctly
+   */
+  skb_reserve(skb, 2);
 
 	entry = (struct skb_data *) skb->cb;
 	entry->urb = urb;