mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 22:21:42 +00:00
c497176cb2
Here the actual receive functions of AF_XDP are implemented, that in a later commit, will be called from the XDP layers. There's one set of functions for the XDP_DRV side and another for XDP_SKB (generic). A new XDP API, xdp_return_buff, is also introduced. Adding xdp_return_buff, which is analogous to xdp_return_frame, but acts upon an struct xdp_buff. The API will be used by AF_XDP in future commits. Support for the poll syscall is also implemented. v2: xskq_validate_id did not update cons_tail. The entries variable was calculated twice in xskq_nb_avail. Squashed xdp_return_buff commit. Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
67 lines
1.7 KiB
C
67 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0
|
|
* XDP user-space packet buffer
|
|
* Copyright(c) 2018 Intel Corporation.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*/
|
|
|
|
#ifndef XDP_UMEM_H_
|
|
#define XDP_UMEM_H_
|
|
|
|
#include <linux/mm.h>
|
|
#include <linux/if_xdp.h>
|
|
#include <linux/workqueue.h>
|
|
|
|
#include "xsk_queue.h"
|
|
#include "xdp_umem_props.h"
|
|
|
|
struct xdp_umem {
|
|
struct xsk_queue *fq;
|
|
struct page **pgs;
|
|
struct xdp_umem_props props;
|
|
u32 npgs;
|
|
u32 frame_headroom;
|
|
u32 nfpp_mask;
|
|
u32 nfpplog2;
|
|
u32 frame_size_log2;
|
|
struct user_struct *user;
|
|
struct pid *pid;
|
|
unsigned long address;
|
|
size_t size;
|
|
atomic_t users;
|
|
struct work_struct work;
|
|
};
|
|
|
|
static inline char *xdp_umem_get_data(struct xdp_umem *umem, u32 idx)
|
|
{
|
|
u64 pg, off;
|
|
char *data;
|
|
|
|
pg = idx >> umem->nfpplog2;
|
|
off = (idx & umem->nfpp_mask) << umem->frame_size_log2;
|
|
|
|
data = page_address(umem->pgs[pg]);
|
|
return data + off;
|
|
}
|
|
|
|
static inline char *xdp_umem_get_data_with_headroom(struct xdp_umem *umem,
|
|
u32 idx)
|
|
{
|
|
return xdp_umem_get_data(umem, idx) + umem->frame_headroom;
|
|
}
|
|
|
|
bool xdp_umem_validate_queues(struct xdp_umem *umem);
|
|
int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr);
|
|
void xdp_get_umem(struct xdp_umem *umem);
|
|
void xdp_put_umem(struct xdp_umem *umem);
|
|
int xdp_umem_create(struct xdp_umem **umem);
|
|
|
|
#endif /* XDP_UMEM_H_ */
|