include/net/libeth/tx.h

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

File Facts

System
Linux kernel
Corpus path
include/net/libeth/tx.h
Extension
.h
Size
4481 bytes
Lines
160
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 libeth_sqe {
	enum libeth_sqe_type		type:32;
	u32				rs_idx;

	union {
		void				*raw;
		struct sk_buff			*skb;
		struct skb_shared_info		*sinfo;
		struct xdp_frame		*xdpf;
		struct libeth_xdp_buff		*xsk;
	};

	DEFINE_DMA_UNMAP_ADDR(dma);
	DEFINE_DMA_UNMAP_LEN(len);

	u32				nr_frags;
	u32				packets;
	u32				bytes;

	unsigned long			priv;
} __aligned_largest;

/**
 * LIBETH_SQE_CHECK_PRIV - check the driver's private SQE data
 * @p: type or name of the object the driver wants to fit into &libeth_sqe
 *
 * Make sure the driver's private data fits into libeth_sqe::priv. To be used
 * right after its declaration.
 */
#define LIBETH_SQE_CHECK_PRIV(p)					  \
	static_assert(sizeof(p) <= sizeof_field(struct libeth_sqe, priv))

/**
 * struct libeth_cq_pp - completion queue poll params
 * @dev: &device to perform DMA unmapping
 * @bq: XDP frame bulk to combine return operations
 * @ss: onstack NAPI stats to fill
 * @xss: onstack XDPSQ NAPI stats to fill
 * @xdp_tx: number of XDP-not-XSk frames processed
 * @napi: whether it's called from the NAPI context
 *
 * libeth uses this structure to access objects needed for performing full
 * Tx complete operation without passing lots of arguments and change the
 * prototypes each time a new one is added.
 */
struct libeth_cq_pp {
	struct device			*dev;
	struct xdp_frame_bulk		*bq;

	union {
		struct libeth_sq_napi_stats	*ss;
		struct libeth_xdpsq_napi_stats	*xss;
	};
	u32				xdp_tx;

	bool				napi;
};

/**
 * libeth_tx_complete - perform Tx completion for one SQE
 * @sqe: SQE to complete
 * @cp: poll params
 *
 * Do Tx complete for all the types of buffers, incl. freeing, unmapping,
 * updating the stats etc.
 */
static inline void libeth_tx_complete(struct libeth_sqe *sqe,
				      const struct libeth_cq_pp *cp)
{
	switch (sqe->type) {
	case LIBETH_SQE_EMPTY:
		return;
	case LIBETH_SQE_SKB:
	case LIBETH_SQE_FRAG:
	case LIBETH_SQE_SLAB:
		dma_unmap_page(cp->dev, dma_unmap_addr(sqe, dma),
			       dma_unmap_len(sqe, len), DMA_TO_DEVICE);
		break;
	default:
		break;
	}

	switch (sqe->type) {
	case LIBETH_SQE_SKB:
		cp->ss->packets += sqe->packets;
		cp->ss->bytes += sqe->bytes;

		napi_consume_skb(sqe->skb, cp->napi);
		break;
	case LIBETH_SQE_SLAB:

Annotation

Implementation Notes