1*5113495bSYour Name /* 2*5113495bSYour Name * Copyright (c) 2018 The Linux Foundation. All rights reserved. 3*5113495bSYour Name * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. 4*5113495bSYour Name * 5*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for 6*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the 7*5113495bSYour Name * above copyright notice and this permission notice appear in all 8*5113495bSYour Name * copies. 9*5113495bSYour Name * 10*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE. 18*5113495bSYour Name */ 19*5113495bSYour Name 20*5113495bSYour Name /** 21*5113495bSYour Name * DOC: i_wbuff.h 22*5113495bSYour Name * wbuff private 23*5113495bSYour Name */ 24*5113495bSYour Name 25*5113495bSYour Name #ifndef _I_WBUFF_H 26*5113495bSYour Name #define _I_WBUFF_H 27*5113495bSYour Name 28*5113495bSYour Name #include <qdf_nbuf.h> 29*5113495bSYour Name #include <wbuff.h> 30*5113495bSYour Name 31*5113495bSYour Name #define WBUFF_MODULE_ID_SHIFT 4 32*5113495bSYour Name #define WBUFF_MODULE_ID_BITMASK 0xF0 33*5113495bSYour Name 34*5113495bSYour Name #define WBUFF_POOL_ID_SHIFT 1 35*5113495bSYour Name #define WBUFF_POOL_ID_BITMASK 0xE 36*5113495bSYour Name 37*5113495bSYour Name /** 38*5113495bSYour Name * struct wbuff_handle - wbuff handle to the registered module 39*5113495bSYour Name * @id: the identifier for the registered module. 40*5113495bSYour Name */ 41*5113495bSYour Name struct wbuff_handle { 42*5113495bSYour Name uint8_t id; 43*5113495bSYour Name }; 44*5113495bSYour Name 45*5113495bSYour Name /** 46*5113495bSYour Name * struct wbuff_pool - structure representing wbuff pool 47*5113495bSYour Name * @initialized: To identify whether pool is initialized 48*5113495bSYour Name * @pool: nbuf pool 49*5113495bSYour Name * @buffer_size: size of the buffer in this @pool 50*5113495bSYour Name * @pool_id: pool identifier 51*5113495bSYour Name * @alloc_success: Successful allocations for this pool 52*5113495bSYour Name * @alloc_fail: Failed allocations for this pool 53*5113495bSYour Name * @mem_alloc: Memory allocated for this pool 54*5113495bSYour Name */ 55*5113495bSYour Name struct wbuff_pool { 56*5113495bSYour Name bool initialized; 57*5113495bSYour Name qdf_nbuf_t pool; 58*5113495bSYour Name uint16_t buffer_size; 59*5113495bSYour Name uint8_t pool_id; 60*5113495bSYour Name uint64_t alloc_success; 61*5113495bSYour Name uint64_t alloc_fail; 62*5113495bSYour Name uint64_t mem_alloc; 63*5113495bSYour Name }; 64*5113495bSYour Name 65*5113495bSYour Name /** 66*5113495bSYour Name * struct wbuff_module - allocation holder for wbuff registered module 67*5113495bSYour Name * @registered: To identify whether module is registered 68*5113495bSYour Name * @pending_returns: Number of buffers pending to be returned to 69*5113495bSYour Name * wbuff by the module 70*5113495bSYour Name * @lock: Lock for accessing per module buffer pools 71*5113495bSYour Name * @handle: wbuff handle for the registered module 72*5113495bSYour Name * @reserve: nbuf headroom to start with 73*5113495bSYour Name * @align: alignment for the nbuf 74*5113495bSYour Name * @wbuff_pool: pools for all available buffers for the module 75*5113495bSYour Name */ 76*5113495bSYour Name struct wbuff_module { 77*5113495bSYour Name bool registered; 78*5113495bSYour Name uint16_t pending_returns; 79*5113495bSYour Name qdf_spinlock_t lock; 80*5113495bSYour Name struct wbuff_handle handle; 81*5113495bSYour Name int reserve; 82*5113495bSYour Name int align; 83*5113495bSYour Name struct wbuff_pool wbuff_pool[WBUFF_MAX_POOLS]; 84*5113495bSYour Name }; 85*5113495bSYour Name 86*5113495bSYour Name /** 87*5113495bSYour Name * struct wbuff_holder - allocation holder for wbuff 88*5113495bSYour Name * @initialized: to identified whether module is initialized 89*5113495bSYour Name * @mod: list of modules 90*5113495bSYour Name * @pf_cache: Reference to page frag cache, used for nbuf allocations 91*5113495bSYour Name * @wbuff_debugfs_dir: wbuff debugfs root directory 92*5113495bSYour Name * @wbuff_stats_dentry: wbuff debugfs stats file 93*5113495bSYour Name */ 94*5113495bSYour Name struct wbuff_holder { 95*5113495bSYour Name bool initialized; 96*5113495bSYour Name struct wbuff_module mod[WBUFF_MAX_MODULES]; 97*5113495bSYour Name qdf_frag_cache_t pf_cache; 98*5113495bSYour Name struct dentry *wbuff_debugfs_dir; 99*5113495bSYour Name struct dentry *wbuff_stats_dentry; 100*5113495bSYour Name }; 101*5113495bSYour Name #endif /* _WBUFF_H */ 102