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

[microblaze-uclinux] [Fwd: Re: [uClinux-dev] [patch] packet alignment in usb-net]



Hi Johann,

Can you please see the attached thread from uclinux-dev regarding your usb-net patch, and submit a patch revised accordingly? In general it's fine, there's just been a request from the maintainer to make it look exactly like the code in the 2.6 kernel.

Thanks,

John
--- Begin Message ---
David McCullough wrote:
Jivin John Williams lays it down ...
Hello,

The attached patch was submitted on the microblaze list, however it
touches the mainline usb-net code.  Essentially the function is to shift
the alignment of incoming IP packets so that the IP headers are aligned.
 Default microblaze systems do'nt implement unaligned handling, so this
is required on that platform.

The author of the patch asserts that this alignment shift is now part of
the mainline 2.6 - can anyone comment?

I actually thought most of the linux networking code relied on this
alignment already.  Most certainly all the net drivers and upper layers.
On x86 it's not a problem but on at least SH and ARM I thought it would be.
Obviously not many people using 2.4 + USB networking on CPU's with
alignment restrictions ;-)

Apart from the comments referring to microblaze which will be removed,
any objections on committing?

If it's in 2.6 then I see no problem at all.  And it is:

    if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) {
        if (netif_msg_rx_err (dev))
            devdbg (dev, "no rx skb");
        usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
        usb_free_urb (urb);
        return;
    }
    skb_reserve (skb, NET_IP_ALIGN);

Given this is in 2.6 code this way, I would like to see the
change commited exactly the way it is done  in 2.6. No point
making it look different between the different kernel versions
for no reason.

Regards
Greg




Date: Tue, 14 Nov 2006 10:13:29 +0100
To: microblaze-uclinux@xxxxxxxxxxxxxx
Subject: [microblaze-uclinux] Another ethernet patch for usbnet.c
From: "Dr. Johann Pfefferl" <j.pfefferl@xxxxxxxxx>
Reply-To: microblaze-uclinux@xxxxxxxxxxxxxx

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;


_______________________________________________
uClinux-dev mailing list
uClinux-dev@xxxxxxxxxxx
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@xxxxxxxxxxx


--
------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg@xxxxxxxxxxxx
SnapGear -- a Secure Computing Company      PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com
_______________________________________________
uClinux-dev mailing list
uClinux-dev@xxxxxxxxxxx
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@xxxxxxxxxxx



--- End Message ---