1 /* 2 * Copyright (c) 2023-2025 Bjoern A. Zeeb 3 * Copyright (c) 2025-2026 The FreeBSD Foundation 4 * 5 * Portions of this software were developed by Björn Zeeb 6 * under sponsorship from the FreeBSD Foundation. 7 * 8 * SPDX-License-Identifier: BSD-2-Clause 9 */ 10 11 #ifndef _LINUXKPI_NET_PAGE_POOL_HELPERS_H 12 #define _LINUXKPI_NET_PAGE_POOL_HELPERS_H 13 14 #include <linux/kernel.h> /* pr_debug */ 15 #include <linux/types.h> 16 #include <linux/dma-mapping.h> 17 #include <net/page_pool/types.h> 18 19 struct page_pool *linuxkpi_page_pool_create(const struct page_pool_params *); 20 void linuxkpi_page_pool_destroy(struct page_pool *); 21 22 struct page *linuxkpi_page_pool_dev_alloc_frag(struct page_pool *, 23 uint32_t *, size_t); 24 void linuxkpi_page_pool_put_full_page(struct page_pool *, struct page *, bool); 25 dma_addr_t linuxkpi_page_pool_get_dma_addr(const struct page *); 26 27 28 static inline struct page_pool * 29 page_pool_create(const struct page_pool_params *ppparams) 30 { 31 return (linuxkpi_page_pool_create(ppparams)); 32 } 33 34 static inline void 35 page_pool_destroy(struct page_pool *pp) 36 { 37 linuxkpi_page_pool_destroy(pp); 38 } 39 40 41 static inline struct page * 42 page_pool_dev_alloc_frag(struct page_pool *pp, uint32_t *offset, 43 size_t size) 44 { 45 return (linuxkpi_page_pool_dev_alloc_frag(pp, offset, size)); 46 } 47 48 static inline void 49 page_pool_put_full_page(struct page_pool *pp, struct page *page, 50 bool allow_direct) 51 { 52 linuxkpi_page_pool_put_full_page(pp, page, allow_direct); 53 } 54 55 static inline dma_addr_t 56 page_pool_get_dma_addr(const struct page *page) 57 { 58 return (linuxkpi_page_pool_get_dma_addr(page)); 59 } 60 61 static inline enum dma_data_direction 62 page_pool_get_dma_dir(const struct page_pool *pp) 63 { 64 return (pp->params.dma_dir); 65 } 66 67 static inline int 68 page_pool_ethtool_stats_get_count(void) 69 { 70 pr_debug("%s: TODO\n", __func__); 71 return (0); 72 } 73 74 static inline uint8_t * 75 page_pool_ethtool_stats_get_strings(uint8_t *x) 76 { 77 pr_debug("%s: TODO\n", __func__); 78 return (x); 79 } 80 81 #endif /* _LINUXKPI_NET_PAGE_POOL_HELPERS_H */ 82