Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Peter Zijlstra and committed by
David S. Miller
654bed16 c57943a1

+43
+23
include/linux/skbuff.h
··· 968 968 skb_shinfo(skb)->nr_frags = i + 1; 969 969 } 970 970 971 + extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, 972 + int off, int size); 973 + 971 974 #define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags) 972 975 #define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list) 973 976 #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) ··· 1383 1380 unsigned int length) 1384 1381 { 1385 1382 return __netdev_alloc_skb(dev, length, GFP_ATOMIC); 1383 + } 1384 + 1385 + extern struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask); 1386 + 1387 + /** 1388 + * netdev_alloc_page - allocate a page for ps-rx on a specific device 1389 + * @dev: network device to receive on 1390 + * 1391 + * Allocate a new page node local to the specified device. 1392 + * 1393 + * %NULL is returned if there is no free memory. 1394 + */ 1395 + static inline struct page *netdev_alloc_page(struct net_device *dev) 1396 + { 1397 + return __netdev_alloc_page(dev, GFP_ATOMIC); 1398 + } 1399 + 1400 + static inline void netdev_free_page(struct net_device *dev, struct page *page) 1401 + { 1402 + __free_page(page); 1386 1403 } 1387 1404 1388 1405 /**
+20
net/core/skbuff.c
··· 263 263 return skb; 264 264 } 265 265 266 + struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask) 267 + { 268 + int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1; 269 + struct page *page; 270 + 271 + page = alloc_pages_node(node, gfp_mask, 0); 272 + return page; 273 + } 274 + EXPORT_SYMBOL(__netdev_alloc_page); 275 + 276 + void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, 277 + int size) 278 + { 279 + skb_fill_page_desc(skb, i, page, off, size); 280 + skb->len += size; 281 + skb->data_len += size; 282 + skb->truesize += size; 283 + } 284 + EXPORT_SYMBOL(skb_add_rx_frag); 285 + 266 286 /** 267 287 * dev_alloc_skb - allocate an skbuff for receiving 268 288 * @length: length to allocate