Björn Töpel | dac09149 | 2018-05-18 14:00:21 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* XDP user-space packet buffer |
Björn Töpel | c0c77d8 | 2018-05-02 13:01:23 +0200 | [diff] [blame] | 3 | * Copyright(c) 2018 Intel Corporation. |
Björn Töpel | c0c77d8 | 2018-05-02 13:01:23 +0200 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef XDP_UMEM_H_ |
| 7 | #define XDP_UMEM_H_ |
| 8 | |
Björn Töpel | e61e62b9 | 2018-06-04 14:05:51 +0200 | [diff] [blame] | 9 | #include <net/xdp_sock.h> |
Björn Töpel | c0c77d8 | 2018-05-02 13:01:23 +0200 | [diff] [blame] | 10 | |
Björn Töpel | bbff2f3 | 2018-06-04 13:57:13 +0200 | [diff] [blame] | 11 | static inline char *xdp_umem_get_data(struct xdp_umem *umem, u64 addr) |
Björn Töpel | c497176 | 2018-05-02 13:01:27 +0200 | [diff] [blame] | 12 | { |
Björn Töpel | 8aef734 | 2018-06-04 14:05:52 +0200 | [diff] [blame] | 13 | return umem->pages[addr >> PAGE_SHIFT].addr + (addr & (PAGE_SIZE - 1)); |
Björn Töpel | c497176 | 2018-05-02 13:01:27 +0200 | [diff] [blame] | 14 | } |
| 15 | |
Magnus Karlsson | ac98d8a | 2018-06-04 14:05:57 +0200 | [diff] [blame] | 16 | static inline dma_addr_t xdp_umem_get_dma(struct xdp_umem *umem, u64 addr) |
| 17 | { |
| 18 | return umem->pages[addr >> PAGE_SHIFT].dma + (addr & (PAGE_SIZE - 1)); |
| 19 | } |
| 20 | |
Björn Töpel | 173d3ad | 2018-06-04 14:05:55 +0200 | [diff] [blame] | 21 | int xdp_umem_assign_dev(struct xdp_umem *umem, struct net_device *dev, |
| 22 | u32 queue_id, u16 flags); |
Magnus Karlsson | 965a9909 | 2018-05-02 13:01:26 +0200 | [diff] [blame] | 23 | bool xdp_umem_validate_queues(struct xdp_umem *umem); |
Björn Töpel | c0c77d8 | 2018-05-02 13:01:23 +0200 | [diff] [blame] | 24 | void xdp_get_umem(struct xdp_umem *umem); |
| 25 | void xdp_put_umem(struct xdp_umem *umem); |
Magnus Karlsson | ac98d8a | 2018-06-04 14:05:57 +0200 | [diff] [blame] | 26 | void xdp_add_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs); |
| 27 | void xdp_del_sk_umem(struct xdp_umem *umem, struct xdp_sock *xs); |
Björn Töpel | a49049e | 2018-05-22 09:35:02 +0200 | [diff] [blame] | 28 | struct xdp_umem *xdp_umem_create(struct xdp_umem_reg *mr); |
Björn Töpel | c0c77d8 | 2018-05-02 13:01:23 +0200 | [diff] [blame] | 29 | |
| 30 | #endif /* XDP_UMEM_H_ */ |