提交 654bed16 编写于 作者: P Peter Zijlstra 提交者: David S. Miller

net: packet split receive api

Add some packet-split receive hooks.

For one this allows to do NUMA node affine page allocs. Later on these
hooks will be extended to do emergency reserve allocations for
fragments.
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c57943a1
...@@ -968,6 +968,9 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i, ...@@ -968,6 +968,9 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
skb_shinfo(skb)->nr_frags = i + 1; skb_shinfo(skb)->nr_frags = i + 1;
} }
extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
int off, int size);
#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags) #define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags)
#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list) #define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list)
#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb))
...@@ -1382,6 +1385,26 @@ static inline struct sk_buff *netdev_alloc_skb(struct net_device *dev, ...@@ -1382,6 +1385,26 @@ static inline struct sk_buff *netdev_alloc_skb(struct net_device *dev,
return __netdev_alloc_skb(dev, length, GFP_ATOMIC); return __netdev_alloc_skb(dev, length, GFP_ATOMIC);
} }
extern struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask);
/**
* netdev_alloc_page - allocate a page for ps-rx on a specific device
* @dev: network device to receive on
*
* Allocate a new page node local to the specified device.
*
* %NULL is returned if there is no free memory.
*/
static inline struct page *netdev_alloc_page(struct net_device *dev)
{
return __netdev_alloc_page(dev, GFP_ATOMIC);
}
static inline void netdev_free_page(struct net_device *dev, struct page *page)
{
__free_page(page);
}
/** /**
* skb_clone_writable - is the header of a clone writable * skb_clone_writable - is the header of a clone writable
* @skb: buffer to check * @skb: buffer to check
......
...@@ -263,6 +263,26 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, ...@@ -263,6 +263,26 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
return skb; return skb;
} }
struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask)
{
int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
struct page *page;
page = alloc_pages_node(node, gfp_mask, 0);
return page;
}
EXPORT_SYMBOL(__netdev_alloc_page);
void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
int size)
{
skb_fill_page_desc(skb, i, page, off, size);
skb->len += size;
skb->data_len += size;
skb->truesize += size;
}
EXPORT_SYMBOL(skb_add_rx_frag);
/** /**
* dev_alloc_skb - allocate an skbuff for receiving * dev_alloc_skb - allocate an skbuff for receiving
* @length: length to allocate * @length: length to allocate
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册