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
33 struct device;
34
35 struct page_pool_params {
36 struct device *dev;
37 uint32_t flags;
38 uint32_t order;
39 uint32_t pool_size;
40 uint32_t max_len;
41 uint32_t offset;
42 int nid; /* NUMA */
43 enum dma_data_direction dma_dir;
44 };
45
46 struct page_pool {
47 };
48
49 #define PP_FLAG_DMA_MAP BIT(0)
50 #define PP_FLAG_DMA_SYNC_DEV BIT(1)
51 #define PP_FLAG_PAGE_FRAG BIT(2)
52
53 static inline struct page_pool *
page_pool_create(const struct page_pool_params * ppparams)54 page_pool_create(const struct page_pool_params *ppparams)
55 {
56
57 pr_debug("%s: TODO\n", __func__);
58 return (NULL);
59 }
60
61 static inline void
page_pool_destroy(struct page_pool * ppool)62 page_pool_destroy(struct page_pool *ppool)
63 {
64
65 pr_debug("%s: TODO\n", __func__);
66 }
67
68 static inline struct page *
page_pool_dev_alloc_frag(struct page_pool * ppool,uint32_t * offset,size_t size)69 page_pool_dev_alloc_frag(struct page_pool *ppool, uint32_t *offset,
70 size_t size)
71 {
72
73 pr_debug("%s: TODO\n", __func__);
74 return (NULL);
75 }
76
77 static inline dma_addr_t
page_pool_get_dma_addr(struct page * page)78 page_pool_get_dma_addr(struct page *page)
79 {
80
81 pr_debug("%s: TODO\n", __func__);
82 return (0);
83 }
84
85 static inline enum dma_data_direction
page_pool_get_dma_dir(const struct page_pool * ppool)86 page_pool_get_dma_dir(const struct page_pool *ppool)
87 {
88
89 pr_debug("%s: TODO\n", __func__);
90 return (DMA_BIDIRECTIONAL);
91 }
92
93 static inline void
page_pool_put_full_page(struct page_pool * ppool,struct page * page,bool allow_direct)94 page_pool_put_full_page(struct page_pool *ppool, struct page *page,
95 bool allow_direct)
96 {
97
98 pr_debug("%s: TODO\n", __func__);
99 }
100
101 static inline int
page_pool_ethtool_stats_get_count(void)102 page_pool_ethtool_stats_get_count(void)
103 {
104
105 pr_debug("%s: TODO\n", __func__);
106 return (0);
107 }
108
109 static inline uint8_t *
page_pool_ethtool_stats_get_strings(uint8_t * x)110 page_pool_ethtool_stats_get_strings(uint8_t *x)
111 {
112
113 pr_debug("%s: TODO\n", __func__);
114 return (x);
115 }
116
117 #endif /* _LINUXKPI_NET_PAGE_POOL_H */
118