1 /* 2 * Copyright (c) 2020 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _DP_RX_BUFFER_POOL_H_ 20 #define _DP_RX_BUFFER_POOL_H_ 21 22 #include "dp_types.h" 23 #include "qdf_nbuf.h" 24 #include "qdf_module.h" 25 #include "athdefs.h" 26 #include "wlan_cfg.h" 27 #include "dp_internal.h" 28 #include "dp_rx.h" 29 #include "dp_rx_mon.h" 30 31 #ifdef WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL 32 /** 33 * dp_rx_buffer_pool_init() - Initialize emergency buffer pool 34 * @soc: SoC handle 35 * @mac_id: MAC ID 36 * 37 * Return: None 38 */ 39 void dp_rx_buffer_pool_init(struct dp_soc *soc, u8 mac_id); 40 41 /** 42 * dp_rx_buffer_pool_deinit() - De-Initialize emergency buffer pool 43 * @soc: SoC handle 44 * @mac_id: MAC ID 45 * 46 * Return: None 47 */ 48 void dp_rx_buffer_pool_deinit(struct dp_soc *soc, u8 mac_id); 49 50 /** 51 * dp_rx_buffer_pool_refill() - Process the rx nbuf list and 52 * refill the emergency buffer pool 53 * @soc: SoC handle 54 * @nbuf: RX buffer 55 * @mac_id: MAC ID 56 * 57 * Return: Whether the rx nbuf is consumed into the pool or not. 58 */ 59 bool dp_rx_buffer_pool_refill(struct dp_soc *soc, qdf_nbuf_t nbuf, u8 mac_id); 60 61 /** 62 * dp_rx_buffer_pool_nbuf_free() - Free the nbuf or queue it 63 * back into the pool 64 * @soc: SoC handle 65 * @nbuf: RX buffer 66 * @mac_id: MAC ID 67 * 68 * Return: None 69 */ 70 void dp_rx_buffer_pool_nbuf_free(struct dp_soc *soc, qdf_nbuf_t nbuf, 71 u8 mac_id); 72 73 /** 74 * dp_rx_buffer_pool_nbuf_alloc() - Allocate nbuf for buffer replenish, 75 * give nbuf from the pool if allocation fails 76 * @soc: SoC handle 77 * @mac_id: MAC ID 78 * @rx_desc_pool: RX descriptor pool 79 * @num_available_buffers: number of available buffers in the ring. 80 * 81 * Return: nbuf 82 */ 83 qdf_nbuf_t dp_rx_buffer_pool_nbuf_alloc(struct dp_soc *soc, uint32_t mac_id, 84 struct rx_desc_pool *rx_desc_pool, 85 uint32_t num_available_buffers); 86 #else 87 /** 88 * dp_rx_buffer_pool_init() - Initialize emergency buffer pool 89 * @soc: SoC handle 90 * @mac_id: MAC ID 91 * 92 * Return: None 93 */ 94 static inline 95 void dp_rx_buffer_pool_init(struct dp_soc *soc, u8 mac_id) 96 { 97 soc->rx_buff_pool[mac_id].is_initialized = false; 98 } 99 100 /** 101 * dp_rx_buffer_pool_deinit() - De-Initialize emergency buffer pool 102 * @soc: SoC handle 103 * @mac_id: MAC ID 104 * 105 * Return: None 106 */ 107 static inline 108 void dp_rx_buffer_pool_deinit(struct dp_soc *soc, u8 mac_id) 109 { 110 } 111 112 /** 113 * dp_rx_buffer_pool_refill() - Process the rx nbuf list and 114 * refill the emergency buffer pool 115 * @soc: SoC handle 116 * @nbuf: RX buffer 117 * @mac_id: MAC ID 118 * 119 * Return: Whether the rx nbuf is consumed into the pool or not. 120 */ 121 static inline 122 bool dp_rx_buffer_pool_refill(struct dp_soc *soc, qdf_nbuf_t nbuf, u8 mac_id) 123 { 124 return false; 125 } 126 127 /** 128 * dp_rx_buffer_pool_nbuf_free() - Free the nbuf or queue it 129 * back into the pool 130 * @soc: SoC handle 131 * @nbuf: RX buffer 132 * @mac_id: MAC ID 133 * 134 * Return: None 135 */ 136 static inline 137 void dp_rx_buffer_pool_nbuf_free(struct dp_soc *soc, qdf_nbuf_t nbuf, 138 u8 mac_id) 139 { 140 qdf_nbuf_free(nbuf); 141 } 142 143 /** 144 * dp_rx_buffer_pool_nbuf_alloc() - Allocate nbuf for buffer replenish, 145 * give nbuf from the pool if allocation fails 146 * @soc: SoC handle 147 * @mac_id: MAC ID 148 * @rx_desc_pool: RX descriptor pool 149 * @num_available_buffers: number of available buffers in the ring. 150 * 151 * Return: nbuf 152 */ 153 static inline qdf_nbuf_t 154 dp_rx_buffer_pool_nbuf_alloc(struct dp_soc *soc, uint32_t mac_id, 155 struct rx_desc_pool *rx_desc_pool, 156 uint32_t num_available_buffers) 157 { 158 return qdf_nbuf_alloc(soc->osdev, rx_desc_pool->buf_size, 159 RX_BUFFER_RESERVATION, 160 rx_desc_pool->buf_alignment, FALSE); 161 } 162 #endif /* WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL */ 163 #endif /* _DP_RX_BUFFER_POOL_H_ */ 164