Commit 1ff22795 authored by Vikram Narayanan's avatar Vikram Narayanan

net/core: Modify allocation to allocate for containers

struct net_device is wrapped inside a container for the sake of LCDs. To
facilitate this, allocate memory for net_device_container instead of
net_device. Alter the api for accessing private area of net_device struct
Signed-off-by: Vikram Narayanan's avatarVikram Narayanan <>
parent d411a759
......@@ -2032,6 +2032,11 @@ static inline bool netdev_uses_dsa(struct net_device *dev)
return false;
struct _net_device_container {
struct net_device net_device;
u64 cptr1, cptr2;
} __packed;
* netdev_priv - access network device private data
* @dev: network device
......@@ -2040,7 +2045,7 @@ static inline bool netdev_uses_dsa(struct net_device *dev)
static inline void *netdev_priv(const struct net_device *dev)
return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN);
return (char *)dev + ALIGN(sizeof(struct _net_device_container), NETDEV_ALIGN);
/* Set the sysfs physical device reference for the network logical device
......@@ -7581,8 +7581,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
unsigned int txqs, unsigned int rxqs)
struct net_device *dev;
struct _net_device_container *dev_c;
size_t alloc_size;
struct net_device *p;
struct _net_device_container *p;
BUG_ON(strlen(name) >= sizeof(dev->name));
......@@ -7598,7 +7599,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
alloc_size = sizeof(struct net_device);
alloc_size = sizeof(struct _net_device_container);
if (sizeof_priv) {
/* ensure 32-byte alignment of private area */
alloc_size = ALIGN(alloc_size, NETDEV_ALIGN);
......@@ -7613,8 +7614,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
if (!p)
return NULL;
dev->padded = (char *)dev - (char *)p;
dev = &dev_c->net_device;
dev->padded = (char *)dev_c - (char *)p;
dev->pcpu_refcnt = alloc_percpu(int);
if (!dev->pcpu_refcnt)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment