xref: /freebsd/sys/compat/linuxkpi/common/include/net/page_pool.h (revision 4b972f77a16f9a217c211c8c4f28a41eca98554e)
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 
26 #ifndef	_LINUXKPI_NET_PAGE_POOL_H
27 #define	_LINUXKPI_NET_PAGE_POOL_H
28 
29 #include <linux/kernel.h>	/* pr_debug */
30 #include <linux/types.h>
31 #include <linux/dma-mapping.h>
32 #include <linux/netdevice.h>
33 
34 struct device;
35 
36 struct page_pool_params {
37 	struct device			*dev;
38 	uint32_t			flags;
39 	uint32_t			order;
40 	uint32_t			pool_size;
41 	uint32_t			max_len;
42 	uint32_t			offset;
43 	int				nid;		/* NUMA */
44 	enum dma_data_direction		dma_dir;
45 	struct napi_struct		*napi;
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 *
page_pool_create(const struct page_pool_params * ppparams)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
page_pool_destroy(struct page_pool * ppool)64 page_pool_destroy(struct page_pool *ppool)
65 {
66 
67 	pr_debug("%s: TODO\n", __func__);
68 }
69 
70 static inline struct page *
page_pool_dev_alloc_frag(struct page_pool * ppool,uint32_t * offset,size_t size)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
page_pool_get_dma_addr(struct page * page)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
page_pool_get_dma_dir(const struct page_pool * ppool)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
page_pool_put_full_page(struct page_pool * ppool,struct page * page,bool allow_direct)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
page_pool_ethtool_stats_get_count(void)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 *
page_pool_ethtool_stats_get_strings(uint8_t * x)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