include/net/xdp.h
Source file repositories/reference/linux-study-clean/include/net/xdp.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/xdp.h- Extension
.h- Size
- 21366 bytes
- Lines
- 706
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/filter.hlinux/netdevice.hlinux/skbuff.hnet/page_pool/types.h
Detected Declarations
struct xdp_mem_infostruct page_poolstruct xdp_rxq_infostruct xdp_txq_infostruct xdp_buffstruct xdp_framestruct xdp_frame_bulkstruct xdp_cpumap_statsstruct xdp_attachment_infostruct netdev_bpfstruct xdp_metadata_opsenum xdp_mem_typeenum xdp_buff_flagsenum xdp_rx_metadataenum xdp_rss_hash_typefunction xdp_buff_has_fragsfunction xdp_buff_set_frags_flagfunction xdp_buff_clear_frags_flagfunction xdp_buff_set_frag_pfmemallocfunction xdp_buff_set_frag_unreadablefunction xdp_buff_get_skb_flagsfunction xdp_buff_clear_frag_pfmemallocfunction xdp_init_bufffunction xdp_prepare_bufffunction SKB_DATA_ALIGNfunction xdp_get_buff_lenfunction __xdp_buff_add_fragfunction __xdp_buff_add_fragfunction xdp_frame_has_fragsfunction xdp_frame_get_skb_flagsfunction xdp_frame_bulk_initfunction xdp_get_shared_info_from_framefunction xdp_scrub_framefunction xdp_update_skb_frags_infofunction xdp_convert_frame_to_bufffunction xdp_update_frame_from_bufffunction xdp_flush_frame_bulkfunction xdp_get_frame_lenfunction xdp_rxq_info_regfunction xdp_rxq_info_reg_mem_modelfunction xdp_rxq_info_attach_mem_modelfunction xdp_set_data_meta_invalidfunction xdp_data_meta_unsupportedfunction xdp_metalen_invalidfunction bpf_xdp_metadata_kfunc_idfunction bpf_dev_bound_kfunc_idfunction xdp_set_features_flagfunction bpf_prog_run_xdp
Annotated Snippet
struct xdp_mem_info {
u32 type; /* enum xdp_mem_type, but known size type */
u32 id;
};
struct page_pool;
struct xdp_rxq_info {
struct net_device *dev;
u32 queue_index;
u32 reg_state;
struct xdp_mem_info mem;
u32 frag_size;
} ____cacheline_aligned; /* perf critical, avoid false-sharing */
struct xdp_txq_info {
struct net_device *dev;
};
enum xdp_buff_flags {
XDP_FLAGS_HAS_FRAGS = BIT(0), /* non-linear xdp buff */
XDP_FLAGS_FRAGS_PF_MEMALLOC = BIT(1), /* xdp paged memory is under
* pressure
*/
/* frags have unreadable mem, this can't be true for real XDP packets,
* but drivers may use XDP helpers to construct Rx pkt state even when
* XDP program is not attached.
*/
XDP_FLAGS_FRAGS_UNREADABLE = BIT(2),
};
struct xdp_buff {
void *data;
void *data_end;
void *data_meta;
void *data_hard_start;
struct xdp_rxq_info *rxq;
struct xdp_txq_info *txq;
union {
struct {
/* frame size to deduce data_hard_end/tailroom */
u32 frame_sz;
/* supported values defined in xdp_buff_flags */
u32 flags;
};
#ifdef __LITTLE_ENDIAN
/* Used to micro-optimize xdp_init_buff(), don't use directly */
u64 frame_sz_flags_init;
#endif
};
};
static __always_inline bool xdp_buff_has_frags(const struct xdp_buff *xdp)
{
return !!(xdp->flags & XDP_FLAGS_HAS_FRAGS);
}
static __always_inline void xdp_buff_set_frags_flag(struct xdp_buff *xdp)
{
xdp->flags |= XDP_FLAGS_HAS_FRAGS;
}
static __always_inline void xdp_buff_clear_frags_flag(struct xdp_buff *xdp)
{
xdp->flags &= ~XDP_FLAGS_HAS_FRAGS;
}
static __always_inline void xdp_buff_set_frag_pfmemalloc(struct xdp_buff *xdp)
{
xdp->flags |= XDP_FLAGS_FRAGS_PF_MEMALLOC;
}
static __always_inline void xdp_buff_set_frag_unreadable(struct xdp_buff *xdp)
{
xdp->flags |= XDP_FLAGS_FRAGS_UNREADABLE;
}
static __always_inline u32 xdp_buff_get_skb_flags(const struct xdp_buff *xdp)
{
return xdp->flags;
}
static __always_inline void xdp_buff_clear_frag_pfmemalloc(struct xdp_buff *xdp)
{
xdp->flags &= ~XDP_FLAGS_FRAGS_PF_MEMALLOC;
}
static __always_inline void
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/filter.h`, `linux/netdevice.h`, `linux/skbuff.h`, `net/page_pool/types.h`.
- Detected declarations: `struct xdp_mem_info`, `struct page_pool`, `struct xdp_rxq_info`, `struct xdp_txq_info`, `struct xdp_buff`, `struct xdp_frame`, `struct xdp_frame_bulk`, `struct xdp_cpumap_stats`, `struct xdp_attachment_info`, `struct netdev_bpf`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
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.