at master 51 lines 1.9 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _NET_PAGE_POOL_MEMORY_PROVIDER_H 3#define _NET_PAGE_POOL_MEMORY_PROVIDER_H 4 5#include <net/netmem.h> 6#include <net/page_pool/types.h> 7 8struct netdev_rx_queue; 9struct netlink_ext_ack; 10struct sk_buff; 11 12struct memory_provider_ops { 13 netmem_ref (*alloc_netmems)(struct page_pool *pool, gfp_t gfp); 14 bool (*release_netmem)(struct page_pool *pool, netmem_ref netmem); 15 int (*init)(struct page_pool *pool); 16 void (*destroy)(struct page_pool *pool); 17 int (*nl_fill)(void *mp_priv, struct sk_buff *rsp, 18 struct netdev_rx_queue *rxq); 19 void (*uninstall)(void *mp_priv, struct netdev_rx_queue *rxq); 20}; 21 22bool net_mp_niov_set_dma_addr(struct net_iov *niov, dma_addr_t addr); 23void net_mp_niov_set_page_pool(struct page_pool *pool, struct net_iov *niov); 24void net_mp_niov_clear_page_pool(struct net_iov *niov); 25 26int net_mp_open_rxq(struct net_device *dev, unsigned ifq_idx, 27 struct pp_memory_provider_params *p); 28int __net_mp_open_rxq(struct net_device *dev, unsigned int rxq_idx, 29 const struct pp_memory_provider_params *p, 30 struct netlink_ext_ack *extack); 31void net_mp_close_rxq(struct net_device *dev, unsigned ifq_idx, 32 struct pp_memory_provider_params *old_p); 33void __net_mp_close_rxq(struct net_device *dev, unsigned int rxq_idx, 34 const struct pp_memory_provider_params *old_p); 35 36/** 37 * net_mp_netmem_place_in_cache() - give a netmem to a page pool 38 * @pool: the page pool to place the netmem into 39 * @netmem: netmem to give 40 * 41 * Push an accounted netmem into the page pool's allocation cache. The caller 42 * must ensure that there is space in the cache. It should only be called off 43 * the mp_ops->alloc_netmems() path. 44 */ 45static inline void net_mp_netmem_place_in_cache(struct page_pool *pool, 46 netmem_ref netmem) 47{ 48 pool->alloc.cache[pool->alloc.count++] = netmem; 49} 50 51#endif