>> = Alan Cox
>  = Petko Manalov

>> Its done for alignment rather than DMA. On a non x86 box many unaligned
>> accesses are extremely expensive. Doing the 2 byte shuffle lands the IP
>> header on a 4byte aligned address

        I wonder if anyone has actually benchmarked this.
I am surprised that this would be fast, given how few 4 byte fields
there are in the IP and TCP headers, and none in the UDP header, and
given that it also takes a few cycles for skb_reserve to increment
to pointers in struct sk_buff.  But, OK, I guess it makes sense if
actually does save time on average.

>Isn't it better if the alignment is done by default by alloc_skb and
>let the driver writer to take care the future skb_reserve() will be
>4 (or 8 or whatever) bytes alignedex.
>It might even make sense to be L1 cahe line aligned...

        Yes.  What I would like even more is an alloc_skb variant
that would take the net_device as a parameter and perhaps an indication
about whether the sk_buff was going to be used for sending or receiving.
This wrapper could then look at a precomputed field in net_device that
would specificy optimal alignment, based on where the packet was going
to land (some devices may write a few status bytes ahead of the packet)
and whether anyone was listening for ipv4 packets (e.g., I only use
my ethernet connection for PPP-over-ethernet when I'm at home).

        More importantly, this wrapper could also take care of setting
up DMA mapping for drivers that want it, and dev_kfree_skb could
automatically take care of unmapping the DMA.  This would simplify
most ethernet drivers a bit, reduce the number of places that
would need to be changed if the DMA mapping system evolves more,
and ensure that DMA mapping failures are caught (the return values
from pci_map_single et al are currently often ignored).

Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
[EMAIL PROTECTED]     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America
fax +1 408 261-6631      "Free Software For The Rest Of Us."

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to