Re: net: alignment problem in icmp code

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Dumazet
Date: Monday, October 22, 2007 - 2:52 am

Pierre Ossman a écrit :
This is not obvious you are right, but documented in 
include/linux/skbuff.h (lines 1150 ...)

/*
 * CPUs often take a performance hit when accessing unaligned memory
 * locations. The actual performance hit varies, it can be small if the
 * hardware handles it or large if we have to take an exception and fix it
 * in software.
 *
 * Since an ethernet header is 14 bytes network drivers often end up with
 * the IP header at an unaligned offset. The IP header can be aligned by
 * shifting the start of the packet by 2 bytes. Drivers should do this
 * with:
 *
 * skb_reserve(NET_IP_ALIGN);
 *
 * The downside to this alignment of the IP header is that the DMA is now
 * unaligned. On some architectures the cost of an unaligned DMA is high
 * and this cost outweighs the gains made by aligning the IP header.
 *
 * Since this trade off varies between architectures, we allow NET_IP_ALIGN
 * to be overridden.
 */
#ifndef NET_IP_ALIGN
#define NET_IP_ALIGN    2
#endif

But then, many drivers dont use NET_IP_ALIGN but a hardcoded 2

drivers/net/pcnet32.c:608:              skb_reserve(rx_skbuff, 2);
drivers/net/pcnet32.c:1214:                     skb_reserve(newskb, 2);
drivers/net/pcnet32.c:1245:             skb_reserve(skb, 2);    /* 16 
byte align */
drivers/net/pcnet32.c:2396:                     skb_reserve(rx_skbuff, 2);
drivers/net/sundance.c:989:             skb_reserve(skb, 2);    /* 16 
byte align the IP header. */
drivers/net/sundance.c:1312:                            skb_reserve(skb, 
2);    /* 16 byte align the IP header */
drivers/net/sundance.c:1375:                    skb_reserve(skb, 2); /* 
Align IP on 16 byte boundaries */




-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
net: alignment problem in icmp code, Pierre Ossman, (Sat Oct 20, 2:35 pm)
Re: net: alignment problem in icmp code, David Miller, (Sat Oct 20, 10:12 pm)
Re: net: alignment problem in icmp code, Pierre Ossman, (Sun Oct 21, 2:34 am)
Re: net: alignment problem in icmp code, David Miller, (Sun Oct 21, 12:48 pm)
Re: net: alignment problem in icmp code, Pierre Ossman, (Sun Oct 21, 2:21 pm)
Re: net: alignment problem in icmp code, David Miller, (Sun Oct 21, 4:02 pm)
Re: net: alignment problem in icmp code, Pierre Ossman, (Sun Oct 21, 9:54 pm)
Re: net: alignment problem in icmp code, David Miller, (Sun Oct 21, 10:15 pm)
Re: net: alignment problem in icmp code, Pierre Ossman, (Mon Oct 22, 12:23 am)
Re: net: alignment problem in icmp code, David Miller, (Mon Oct 22, 1:31 am)
Re: net: alignment problem in icmp code, Pierre Ossman, (Mon Oct 22, 1:42 am)
Re: net: alignment problem in icmp code, David Miller, (Mon Oct 22, 2:05 am)
Re: net: alignment problem in icmp code, Pierre Ossman, (Mon Oct 22, 2:26 am)
Re: net: alignment problem in icmp code, Eric Dumazet, (Mon Oct 22, 2:52 am)