include/net/page_pool/helpers.h
Source file repositories/reference/linux-study-clean/include/net/page_pool/helpers.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/page_pool/helpers.h- Extension
.h- Size
- 17149 bytes
- Lines
- 526
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma-mapping.hnet/page_pool/types.hnet/net_debug.hnet/netmem.h
Detected Declarations
function page_pool_ethtool_stats_get_countfunction page_pool_dev_alloc_pagesfunction page_pool_dev_alloc_fragfunction page_pool_alloc_netmemfunction page_pool_dev_alloc_netmemfunction page_pool_dev_alloc_netmemsfunction page_pool_dev_allocfunction page_pool_dev_alloc_vafunction page_pool_get_dma_dirfunction page_pool_fragment_netmemfunction decfunction page_pool_unref_netmemfunction page_pool_unref_pagefunction page_pool_ref_netmemfunction page_pool_ref_pagefunction page_pool_unref_and_testfunction page_pool_put_netmemfunction page_pool_put_pagefunction page_pool_put_full_netmemfunction page_pool_put_full_pagefunction page_pool_recycle_directfunction page_pool_recycle_direct_netmemfunction page_pool_free_vafunction page_pool_get_dma_addr_netmemfunction page_pool_get_dma_addrfunction __page_pool_dma_sync_for_cpufunction page_pool_dma_sync_for_cpufunction page_pool_dma_sync_netmem_for_cpufunction page_pool_getfunction page_pool_putfunction page_pool_nid_changedfunction page_pool_is_unreadable
Annotated Snippet
#ifndef _NET_PAGE_POOL_HELPERS_H
#define _NET_PAGE_POOL_HELPERS_H
#include <linux/dma-mapping.h>
#include <net/page_pool/types.h>
#include <net/net_debug.h>
#include <net/netmem.h>
#ifdef CONFIG_PAGE_POOL_STATS
/* Deprecated driver-facing API, use netlink instead */
int page_pool_ethtool_stats_get_count(void);
u8 *page_pool_ethtool_stats_get_strings(u8 *data);
u64 *page_pool_ethtool_stats_get(u64 *data, const void *stats);
void page_pool_get_stats(const struct page_pool *pool,
struct page_pool_stats *stats);
#else
static inline int page_pool_ethtool_stats_get_count(void)
{
return 0;
}
static inline u8 *page_pool_ethtool_stats_get_strings(u8 *data)
{
return data;
}
static inline u64 *page_pool_ethtool_stats_get(u64 *data, const void *stats)
{
return data;
}
#endif
/**
* page_pool_dev_alloc_pages() - allocate a page.
* @pool: pool from which to allocate
*
* Get a page from the page allocator or page_pool caches.
*/
static inline struct page *page_pool_dev_alloc_pages(struct page_pool *pool)
{
gfp_t gfp = (GFP_ATOMIC | __GFP_NOWARN);
return page_pool_alloc_pages(pool, gfp);
}
/**
* page_pool_dev_alloc_frag() - allocate a page fragment.
* @pool: pool from which to allocate
* @offset: offset to the allocated page
* @size: requested size
*
* Get a page fragment from the page allocator or page_pool caches.
*
* Return: allocated page fragment, otherwise return NULL.
*/
static inline struct page *page_pool_dev_alloc_frag(struct page_pool *pool,
unsigned int *offset,
unsigned int size)
{
gfp_t gfp = (GFP_ATOMIC | __GFP_NOWARN);
return page_pool_alloc_frag(pool, offset, size, gfp);
}
static inline netmem_ref page_pool_alloc_netmem(struct page_pool *pool,
unsigned int *offset,
unsigned int *size, gfp_t gfp)
{
unsigned int max_size = PAGE_SIZE << pool->p.order;
netmem_ref netmem;
if ((*size << 1) > max_size) {
*size = max_size;
*offset = 0;
return page_pool_alloc_netmems(pool, gfp);
}
netmem = page_pool_alloc_frag_netmem(pool, offset, *size, gfp);
if (unlikely(!netmem))
return 0;
/* There is very likely not enough space for another fragment, so append
* the remaining size to the current fragment to avoid truesize
* underestimate problem.
*/
if (pool->frag_offset + *size > max_size) {
*size = max_size - *offset;
pool->frag_offset = max_size;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `net/page_pool/types.h`, `net/net_debug.h`, `net/netmem.h`.
- Detected declarations: `function page_pool_ethtool_stats_get_count`, `function page_pool_dev_alloc_pages`, `function page_pool_dev_alloc_frag`, `function page_pool_alloc_netmem`, `function page_pool_dev_alloc_netmem`, `function page_pool_dev_alloc_netmems`, `function page_pool_dev_alloc`, `function page_pool_dev_alloc_va`, `function page_pool_get_dma_dir`, `function page_pool_fragment_netmem`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.