include/net/xdp_sock_drv.h

Source file repositories/reference/linux-study-clean/include/net/xdp_sock_drv.h

File Facts

System
Linux kernel
Corpus path
include/net/xdp_sock_drv.h
Extension
.h
Size
11827 bytes
Lines
502
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct xsk_cb_desc {
	void *src;
	u8 off;
	u8 bytes;
};

#ifdef CONFIG_XDP_SOCKETS

void xsk_tx_completed(struct xsk_buff_pool *pool, u32 nb_entries);
bool xsk_tx_peek_desc(struct xsk_buff_pool *pool, struct xdp_desc *desc);
u32 xsk_tx_peek_release_desc_batch(struct xsk_buff_pool *pool, u32 max);
void xsk_tx_release(struct xsk_buff_pool *pool);
struct xsk_buff_pool *xsk_get_pool_from_qid(struct net_device *dev,
					    u16 queue_id);
void xsk_set_rx_need_wakeup(struct xsk_buff_pool *pool);
void xsk_set_tx_need_wakeup(struct xsk_buff_pool *pool);
void xsk_clear_rx_need_wakeup(struct xsk_buff_pool *pool);
void xsk_clear_tx_need_wakeup(struct xsk_buff_pool *pool);
bool xsk_uses_need_wakeup(struct xsk_buff_pool *pool);

static inline u32 xsk_pool_get_headroom(struct xsk_buff_pool *pool)
{
	return XDP_PACKET_HEADROOM + pool->headroom;
}

static inline u32 xsk_pool_get_tailroom(bool mbuf)
{
	return mbuf ? SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) : 0;
}

static inline u32 xsk_pool_get_chunk_size(struct xsk_buff_pool *pool)
{
	return pool->chunk_size;
}

static inline u32 __xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
{
	return xsk_pool_get_chunk_size(pool) - xsk_pool_get_headroom(pool);
}

static inline u32 xsk_pool_get_rx_frame_size(struct xsk_buff_pool *pool)
{
	u32 frame_size =  __xsk_pool_get_rx_frame_size(pool);
	struct xdp_umem *umem = pool->umem;
	bool mbuf;

	/* Reserve tailroom only for zero-copy pools that opted into
	 * multi-buffer. The reserved area is used for skb_shared_info,
	 * matching the XDP core's xdp_data_hard_end() layout.
	 */
	mbuf = pool->dev && (umem->flags & XDP_UMEM_SG_FLAG);
	frame_size -= xsk_pool_get_tailroom(mbuf);

	return ALIGN_DOWN(frame_size, 128);
}

static inline u32 xsk_pool_get_rx_frag_step(struct xsk_buff_pool *pool)
{
	return pool->unaligned ? 0 : xsk_pool_get_chunk_size(pool);
}

static inline void xsk_pool_set_rxq_info(struct xsk_buff_pool *pool,
					 struct xdp_rxq_info *rxq)
{
	xp_set_rxq_info(pool, rxq);
}

static inline void xsk_pool_fill_cb(struct xsk_buff_pool *pool,
				    struct xsk_cb_desc *desc)
{
	xp_fill_cb(pool, desc);
}

static inline void xsk_pool_dma_unmap(struct xsk_buff_pool *pool,
				      unsigned long attrs)
{
	xp_dma_unmap(pool, attrs);
}

static inline int xsk_pool_dma_map(struct xsk_buff_pool *pool,
				   struct device *dev, unsigned long attrs)
{
	struct xdp_umem *umem = pool->umem;

	return xp_dma_map(pool, dev, attrs, umem->pgs, umem->npgs);
}

static inline dma_addr_t xsk_buff_xdp_get_dma(struct xdp_buff *xdp)
{
	struct xdp_buff_xsk *xskb = container_of(xdp, struct xdp_buff_xsk, xdp);

Annotation

Implementation Notes