Blame lib/bpf/include/uapi/linux/if_xdp.h

Packit b92951
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
Packit b92951
/*
Packit b92951
 * if_xdp: XDP socket user-space interface
Packit b92951
 * Copyright(c) 2018 Intel Corporation.
Packit b92951
 *
Packit b92951
 * Author(s): Björn Töpel <bjorn.topel@intel.com>
Packit b92951
 *	      Magnus Karlsson <magnus.karlsson@intel.com>
Packit b92951
 */
Packit b92951
Packit b92951
#ifndef _LINUX_IF_XDP_H
Packit b92951
#define _LINUX_IF_XDP_H
Packit b92951
Packit b92951
#include <linux/types.h>
Packit b92951
Packit b92951
/* Options for the sxdp_flags field */
Packit b92951
#define XDP_SHARED_UMEM	(1 << 0)
Packit b92951
#define XDP_COPY	(1 << 1) /* Force copy-mode */
Packit b92951
#define XDP_ZEROCOPY	(1 << 2) /* Force zero-copy mode */
Packit b92951
/* If this option is set, the driver might go sleep and in that case
Packit b92951
 * the XDP_RING_NEED_WAKEUP flag in the fill and/or Tx rings will be
Packit b92951
 * set. If it is set, the application need to explicitly wake up the
Packit b92951
 * driver with a poll() (Rx and Tx) or sendto() (Tx only). If you are
Packit b92951
 * running the driver and the application on the same core, you should
Packit b92951
 * use this option so that the kernel will yield to the user space
Packit b92951
 * application.
Packit b92951
 */
Packit b92951
#define XDP_USE_NEED_WAKEUP (1 << 3)
Packit b92951
Packit b92951
/* Flags for xsk_umem_config flags */
Packit b92951
#define XDP_UMEM_UNALIGNED_CHUNK_FLAG (1 << 0)
Packit b92951
Packit b92951
struct sockaddr_xdp {
Packit b92951
	__u16 sxdp_family;
Packit b92951
	__u16 sxdp_flags;
Packit b92951
	__u32 sxdp_ifindex;
Packit b92951
	__u32 sxdp_queue_id;
Packit b92951
	__u32 sxdp_shared_umem_fd;
Packit b92951
};
Packit b92951
Packit b92951
/* XDP_RING flags */
Packit b92951
#define XDP_RING_NEED_WAKEUP (1 << 0)
Packit b92951
Packit b92951
struct xdp_ring_offset {
Packit b92951
	__u64 producer;
Packit b92951
	__u64 consumer;
Packit b92951
	__u64 desc;
Packit b92951
	__u64 flags;
Packit b92951
};
Packit b92951
Packit b92951
struct xdp_mmap_offsets {
Packit b92951
	struct xdp_ring_offset rx;
Packit b92951
	struct xdp_ring_offset tx;
Packit b92951
	struct xdp_ring_offset fr; /* Fill */
Packit b92951
	struct xdp_ring_offset cr; /* Completion */
Packit b92951
};
Packit b92951
Packit b92951
/* XDP socket options */
Packit b92951
#define XDP_MMAP_OFFSETS		1
Packit b92951
#define XDP_RX_RING			2
Packit b92951
#define XDP_TX_RING			3
Packit b92951
#define XDP_UMEM_REG			4
Packit b92951
#define XDP_UMEM_FILL_RING		5
Packit b92951
#define XDP_UMEM_COMPLETION_RING	6
Packit b92951
#define XDP_STATISTICS			7
Packit b92951
#define XDP_OPTIONS			8
Packit b92951
Packit b92951
struct xdp_umem_reg {
Packit b92951
	__u64 addr; /* Start of packet data area */
Packit b92951
	__u64 len; /* Length of packet data area */
Packit b92951
	__u32 chunk_size;
Packit b92951
	__u32 headroom;
Packit b92951
	__u32 flags;
Packit b92951
};
Packit b92951
Packit b92951
struct xdp_statistics {
Packit b92951
	__u64 rx_dropped; /* Dropped for reasons other than invalid desc */
Packit b92951
	__u64 rx_invalid_descs; /* Dropped due to invalid descriptor */
Packit b92951
	__u64 tx_invalid_descs; /* Dropped due to invalid descriptor */
Packit b92951
};
Packit b92951
Packit b92951
struct xdp_options {
Packit b92951
	__u32 flags;
Packit b92951
};
Packit b92951
Packit b92951
/* Flags for the flags field of struct xdp_options */
Packit b92951
#define XDP_OPTIONS_ZEROCOPY (1 << 0)
Packit b92951
Packit b92951
/* Pgoff for mmaping the rings */
Packit b92951
#define XDP_PGOFF_RX_RING			  0
Packit b92951
#define XDP_PGOFF_TX_RING		 0x80000000
Packit b92951
#define XDP_UMEM_PGOFF_FILL_RING	0x100000000ULL
Packit b92951
#define XDP_UMEM_PGOFF_COMPLETION_RING	0x180000000ULL
Packit b92951
Packit b92951
/* Masks for unaligned chunks mode */
Packit b92951
#define XSK_UNALIGNED_BUF_OFFSET_SHIFT 48
Packit b92951
#define XSK_UNALIGNED_BUF_ADDR_MASK \
Packit b92951
	((1ULL << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1)
Packit b92951
Packit b92951
/* Rx/Tx descriptor */
Packit b92951
struct xdp_desc {
Packit b92951
	__u64 addr;
Packit b92951
	__u32 len;
Packit b92951
	__u32 options;
Packit b92951
};
Packit b92951
Packit b92951
/* UMEM descriptor is __u64 */
Packit b92951
Packit b92951
#endif /* _LINUX_IF_XDP_H */