xref: /freebsd/sys/compat/linuxkpi/common/include/net/page_pool.h (revision 535af610a4fdace6d50960c0ad9be0597eea7a1b)
1 /*-
2  * Copyright (c) 2023 Bjoern A. Zeeb
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  * $FreeBSD$
26  */
27 
28 #ifndef	_LINUXKPI_NET_PAGE_POOL_H
29 #define	_LINUXKPI_NET_PAGE_POOL_H
30 
31 #include <linux/kernel.h>	/* pr_debug */
32 #include <linux/types.h>
33 #include <linux/dma-mapping.h>
34 
35 struct device;
36 
37 struct page_pool_params {
38 	struct device			*dev;
39 	uint32_t			flags;
40 	uint32_t			order;
41 	uint32_t			pool_size;
42 	uint32_t			max_len;
43 	uint32_t			offset;
44 	int				nid;		/* NUMA */
45 	enum dma_data_direction		dma_dir;
46 };
47 
48 struct page_pool {
49 };
50 
51 #define	PP_FLAG_DMA_MAP		BIT(0)
52 #define	PP_FLAG_DMA_SYNC_DEV	BIT(1)
53 #define	PP_FLAG_PAGE_FRAG	BIT(2)
54 
55 static inline struct page_pool *
56 page_pool_create(const struct page_pool_params *ppparams)
57 {
58 
59 	pr_debug("%s: TODO\n", __func__);
60 	return (NULL);
61 }
62 
63 static inline void
64 page_pool_destroy(struct page_pool *ppool)
65 {
66 
67 	pr_debug("%s: TODO\n", __func__);
68 }
69 
70 static inline struct page *
71 page_pool_dev_alloc_frag(struct page_pool *ppool, uint32_t *offset,
72     size_t size)
73 {
74 
75 	pr_debug("%s: TODO\n", __func__);
76 	return (NULL);
77 }
78 
79 static inline dma_addr_t
80 page_pool_get_dma_addr(struct page *page)
81 {
82 
83 	pr_debug("%s: TODO\n", __func__);
84 	return (0);
85 }
86 
87 static inline enum dma_data_direction
88 page_pool_get_dma_dir(const struct page_pool *ppool)
89 {
90 
91 	pr_debug("%s: TODO\n", __func__);
92 	return (DMA_BIDIRECTIONAL);
93 }
94 
95 static inline void
96 page_pool_put_full_page(struct page_pool *ppool, struct page *page,
97     bool allow_direct)
98 {
99 
100 	pr_debug("%s: TODO\n", __func__);
101 }
102 
103 static inline int
104 page_pool_ethtool_stats_get_count(void)
105 {
106 
107 	pr_debug("%s: TODO\n", __func__);
108 	return (0);
109 }
110 
111 static inline uint8_t *
112 page_pool_ethtool_stats_get_strings(uint8_t *x)
113 {
114 
115 	pr_debug("%s: TODO\n", __func__);
116 	return (x);
117 }
118 
119 #endif	/* _LINUXKPI_NET_PAGE_POOL_H */
120