#include <linux/bpf.h>
#include <linux/btf.h>
#include <linux/btf_ids.h>
#include <linux/filter.h>
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/netdevice.h>
#include <linux/slab.h>
#include <linux/idr.h>
#include <linux/rhashtable.h>
#include <linux/bug.h>
#include <net/page_pool/helpers.h>
#include <net/hotdata.h>
#include <net/xdp.h>
#include <net/xdp_priv.h>
#include <trace/events/xdp.h>
#include <net/xdp_sock_drv.h>
#define REG_STATE_NEW …
#define REG_STATE_REGISTERED …
#define REG_STATE_UNREGISTERED …
#define REG_STATE_UNUSED …
static DEFINE_IDA(mem_id_pool);
static DEFINE_MUTEX(mem_id_lock);
#define MEM_ID_MAX …
#define MEM_ID_MIN …
static int mem_id_next = …;
static bool mem_id_init;
static struct rhashtable *mem_id_ht;
static u32 xdp_mem_id_hashfn(const void *data, u32 len, u32 seed)
{ … }
static int xdp_mem_id_cmp(struct rhashtable_compare_arg *arg,
const void *ptr)
{ … }
static const struct rhashtable_params mem_id_rht_params = …;
static void __xdp_mem_allocator_rcu_free(struct rcu_head *rcu)
{ … }
static void mem_xa_remove(struct xdp_mem_allocator *xa)
{ … }
static void mem_allocator_disconnect(void *allocator)
{ … }
void xdp_unreg_mem_model(struct xdp_mem_info *mem)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_rxq_info_unreg_mem_model(struct xdp_rxq_info *xdp_rxq)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_rxq_info_unreg(struct xdp_rxq_info *xdp_rxq)
{ … }
EXPORT_SYMBOL_GPL(…);
static void xdp_rxq_info_init(struct xdp_rxq_info *xdp_rxq)
{ … }
int __xdp_rxq_info_reg(struct xdp_rxq_info *xdp_rxq,
struct net_device *dev, u32 queue_index,
unsigned int napi_id, u32 frag_size)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_rxq_info_unused(struct xdp_rxq_info *xdp_rxq)
{ … }
EXPORT_SYMBOL_GPL(…);
bool xdp_rxq_info_is_reg(struct xdp_rxq_info *xdp_rxq)
{ … }
EXPORT_SYMBOL_GPL(…);
static int __mem_id_init_hash_table(void)
{ … }
static int __mem_id_cyclic_get(gfp_t gfp)
{ … }
static bool __is_supported_mem_type(enum xdp_mem_type type)
{ … }
static struct xdp_mem_allocator *__xdp_reg_mem_model(struct xdp_mem_info *mem,
enum xdp_mem_type type,
void *allocator)
{ … }
int xdp_reg_mem_model(struct xdp_mem_info *mem,
enum xdp_mem_type type, void *allocator)
{ … }
EXPORT_SYMBOL_GPL(…);
int xdp_rxq_info_reg_mem_model(struct xdp_rxq_info *xdp_rxq,
enum xdp_mem_type type, void *allocator)
{ … }
EXPORT_SYMBOL_GPL(…);
void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct,
struct xdp_buff *xdp)
{ … }
void xdp_return_frame(struct xdp_frame *xdpf)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_return_frame_rx_napi(struct xdp_frame *xdpf)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_flush_frame_bulk(struct xdp_frame_bulk *bq)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_return_frame_bulk(struct xdp_frame *xdpf,
struct xdp_frame_bulk *bq)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_return_buff(struct xdp_buff *xdp)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_attachment_setup(struct xdp_attachment_info *info,
struct netdev_bpf *bpf)
{ … }
EXPORT_SYMBOL_GPL(…);
struct xdp_frame *xdp_convert_zc_to_xdp_frame(struct xdp_buff *xdp)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_warn(const char *msg, const char *func, const int line)
{
WARN(1, "XDP_WARN: %s(line:%d): %s\n", func, line, msg);
};
EXPORT_SYMBOL_GPL(…);
int xdp_alloc_skb_bulk(void **skbs, int n_skb, gfp_t gfp)
{ … }
EXPORT_SYMBOL_GPL(…);
struct sk_buff *__xdp_build_skb_from_frame(struct xdp_frame *xdpf,
struct sk_buff *skb,
struct net_device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
struct sk_buff *xdp_build_skb_from_frame(struct xdp_frame *xdpf,
struct net_device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
struct xdp_frame *xdpf_clone(struct xdp_frame *xdpf)
{ … }
__bpf_kfunc_start_defs();
__bpf_kfunc int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx, u64 *timestamp)
{ … }
__bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, u32 *hash,
enum xdp_rss_hash_type *rss_type)
{ … }
__bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
__be16 *vlan_proto, u16 *vlan_tci)
{ … }
__bpf_kfunc_end_defs();
BTF_KFUNCS_START(xdp_metadata_kfunc_ids)
#define XDP_METADATA_KFUNC …
XDP_METADATA_KFUNC_xxx
#undef XDP_METADATA_KFUNC
BTF_KFUNCS_END(…)
static const struct btf_kfunc_id_set xdp_metadata_kfunc_set = …;
BTF_ID_LIST(xdp_metadata_kfunc_ids_unsorted)
#define XDP_METADATA_KFUNC …
XDP_METADATA_KFUNC_xxx
#undef XDP_METADATA_KFUNC
u32 bpf_xdp_metadata_kfunc_id(int id)
{ … }
bool bpf_dev_bound_kfunc_id(u32 btf_id)
{ … }
static int __init xdp_metadata_init(void)
{ … }
late_initcall(xdp_metadata_init);
void xdp_set_features_flag(struct net_device *dev, xdp_features_t val)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_features_set_redirect_target(struct net_device *dev, bool support_sg)
{ … }
EXPORT_SYMBOL_GPL(…);
void xdp_features_clear_redirect_target(struct net_device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);