Re: alloc_netdev() and 32 byte or 32 bit alignment???

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

 



On Fri, May 18, 2007 at 05:10:02PM +0530, pradeep singh wrote:
> Hi ,
> 
> following code snippet is self evident in what it does -
> 
> truct net_device *alloc_netdev(int sizeof_priv, const char *name,
> 		void (*setup)(struct net_device *))
> {
> 	void *p;
> 	struct net_device *dev;
> 	int alloc_size;
> 
> 	/* ensure 32-byte alignment of both the device and private area */
> 	alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST;
> 	alloc_size += sizeof_priv + NETDEV_ALIGN_CONST;
> 
> 	p = kzalloc(alloc_size, GFP_KERNEL);
> 	if (!p) {
> 		printk(KERN_ERR "alloc_dev: Unable to allocate device.\n");
> 		return NULL;
> 	}
> [snip]
> 
> Is the comment correct?
> Why is it 'ensure 32 byte alignment', instead of 32 bit alignment?
> 
> What am i missing here?

Google turned up following useful link:
http://www.nabble.com/-RFC--changing-value-of-NETDEV_ALIGN-to-cacheline-size-t1620499.html

snip:
The reason it's 32 is that old drivers depended on the
struct being at least 32-byte aligned because they would
embed structures DMA'd to/from the card in their private
area and just assumed that would be aligned enough for
the card's restrictions. 

	Sam
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux