1c0c77d8fSBjörn Töpel /* SPDX-License-Identifier: GPL-2.0 2c0c77d8fSBjörn Töpel * XDP user-space packet buffer 3c0c77d8fSBjörn Töpel * Copyright(c) 2018 Intel Corporation. 4c0c77d8fSBjörn Töpel * 5c0c77d8fSBjörn Töpel * This program is free software; you can redistribute it and/or modify it 6c0c77d8fSBjörn Töpel * under the terms and conditions of the GNU General Public License, 7c0c77d8fSBjörn Töpel * version 2, as published by the Free Software Foundation. 8c0c77d8fSBjörn Töpel * 9c0c77d8fSBjörn Töpel * This program is distributed in the hope it will be useful, but WITHOUT 10c0c77d8fSBjörn Töpel * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11c0c77d8fSBjörn Töpel * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12c0c77d8fSBjörn Töpel * more details. 13c0c77d8fSBjörn Töpel */ 14c0c77d8fSBjörn Töpel 15c0c77d8fSBjörn Töpel #ifndef XDP_UMEM_H_ 16c0c77d8fSBjörn Töpel #define XDP_UMEM_H_ 17c0c77d8fSBjörn Töpel 18c0c77d8fSBjörn Töpel #include <linux/mm.h> 19c0c77d8fSBjörn Töpel #include <linux/if_xdp.h> 20c0c77d8fSBjörn Töpel #include <linux/workqueue.h> 21c0c77d8fSBjörn Töpel 22c0c77d8fSBjörn Töpel #include "xdp_umem_props.h" 23c0c77d8fSBjörn Töpel 24c0c77d8fSBjörn Töpel struct xdp_umem { 25c0c77d8fSBjörn Töpel struct page **pgs; 26c0c77d8fSBjörn Töpel struct xdp_umem_props props; 27c0c77d8fSBjörn Töpel u32 npgs; 28c0c77d8fSBjörn Töpel u32 frame_headroom; 29c0c77d8fSBjörn Töpel u32 nfpp_mask; 30c0c77d8fSBjörn Töpel u32 nfpplog2; 31c0c77d8fSBjörn Töpel u32 frame_size_log2; 32c0c77d8fSBjörn Töpel struct user_struct *user; 33c0c77d8fSBjörn Töpel struct pid *pid; 34c0c77d8fSBjörn Töpel unsigned long address; 35c0c77d8fSBjörn Töpel size_t size; 36c0c77d8fSBjörn Töpel atomic_t users; 37c0c77d8fSBjörn Töpel struct work_struct work; 38c0c77d8fSBjörn Töpel }; 39c0c77d8fSBjörn Töpel 40c0c77d8fSBjörn Töpel int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr); 41c0c77d8fSBjörn Töpel void xdp_get_umem(struct xdp_umem *umem); 42c0c77d8fSBjörn Töpel void xdp_put_umem(struct xdp_umem *umem); 43c0c77d8fSBjörn Töpel int xdp_umem_create(struct xdp_umem **umem); 44c0c77d8fSBjörn Töpel 45c0c77d8fSBjörn Töpel #endif /* XDP_UMEM_H_ */ 46