blob: c978b8d335b58790e16dd169c7f1f03ed8c0c8e1 [file] [log] [blame]
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +05301/*
Dhanashri Atred4032ab2017-01-17 15:05:41 -08002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +05303 *
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#if defined(CONFIG_HL_SUPPORT)
20#include "wlan_tgt_def_config_hl.h"
21#else
22#include "wlan_tgt_def_config.h"
23#endif
24
25#include "qdf_trace.h"
26#include "qdf_mem.h"
27#include "wlan_cfg.h"
28
29/*
30 * FIX THIS -
31 * For now, all these configuration parameters are hardcoded.
32 * Many of these should actually be coming from dts file/ini file
33 */
34#define WLAN_CFG_INT_NUM_CONTEXTS 4
Vijay Pamidipatic84501a2016-11-17 21:51:35 +053035
36#define RXDMA_BUF_RING_SIZE 2048
37#define RXDMA_MONITOR_BUF_RING_SIZE 2048
38#define RXDMA_MONITOR_DEST_RING_SIZE 2048
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053039#define RXDMA_MONITOR_STATUS_RING_SIZE 2048
40
Vijay Pamidipatic84501a2016-11-17 21:51:35 +053041#define WLAN_CFG_NUM_TX_DESC 1024
42#define WLAN_CFG_NUM_TX_EXT_DESC 1024
Ravi Joshifb39e002017-02-11 21:18:40 -080043
44#ifdef TX_PER_PDEV_DESC_POOL
45#define WLAN_CFG_NUM_TX_DESC_POOL MAX_PDEV_CNT
46#define WLAN_CFG_NUM_TXEXT_DESC_POOL MAX_PDEV_CNT
47#else
Vijay Pamidipatic84501a2016-11-17 21:51:35 +053048#define WLAN_CFG_NUM_TX_DESC_POOL 3
49#define WLAN_CFG_NUM_TXEXT_DESC_POOL 3
Ravi Joshifb39e002017-02-11 21:18:40 -080050#endif /* TX_PER_PDEV_DESC_POOL */
51
Vijay Pamidipatic84501a2016-11-17 21:51:35 +053052
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053053#define WLAN_CFG_TX_RING_MASK_0 0x1
54#define WLAN_CFG_TX_RING_MASK_1 0x2
55#define WLAN_CFG_TX_RING_MASK_2 0x4
56#define WLAN_CFG_TX_RING_MASK_3 0x0
57
58#define WLAN_CFG_RX_RING_MASK_0 0x1
59#define WLAN_CFG_RX_RING_MASK_1 0x2
60#define WLAN_CFG_RX_RING_MASK_2 0x4
61#define WLAN_CFG_RX_RING_MASK_3 0x8
62
63#define WLAN_CFG_RX_MON_RING_MASK_0 0x1
64#define WLAN_CFG_RX_MON_RING_MASK_1 0x2
65#define WLAN_CFG_RX_MON_RING_MASK_2 0x4
66#define WLAN_CFG_RX_MON_RING_MASK_3 0x0
67
68#define WLAN_CFG_DP_TX_NUM_POOLS 3
69/* Change this to a lower value to enforce scattered idle list mode */
70#define WLAN_CFG_MAX_ALLOC_SIZE (32 << 20)
71
Karunakar Dasinenid0ea21f2017-01-31 22:58:15 -080072#define WLAN_CFG_MAX_CLIENTS 64
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053073
Vijay Pamidipatic84501a2016-11-17 21:51:35 +053074#define WLAN_CFG_PER_PDEV_TX_RING 1
75#define WLAN_CFG_NUM_TCL_DATA_RINGS 3
76#define WLAN_CFG_PER_PDEV_RX_RING 1
77#define WLAN_CFG_NUM_REO_DEST_RING 4
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053078
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053079#define WLAN_CFG_HTT_PKT_TYPE 2
80#define WLAN_CFG_MAX_PEER_ID 16
81
Dhanashri Atred4032ab2017-01-17 15:05:41 -080082#ifdef CONFIG_MCL
83#define NUM_RXDMA_RINGS_PER_PDEV 2
84#else
85#define NUM_RXDMA_RINGS_PER_PDEV 1
86#endif
87
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053088static const int tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
89 WLAN_CFG_TX_RING_MASK_0,
90 WLAN_CFG_TX_RING_MASK_1,
91 WLAN_CFG_TX_RING_MASK_2,
92 WLAN_CFG_TX_RING_MASK_3};
93
94static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
95 WLAN_CFG_RX_RING_MASK_0,
96 WLAN_CFG_RX_RING_MASK_1,
97 WLAN_CFG_RX_RING_MASK_2,
98 WLAN_CFG_RX_RING_MASK_3};
99
100static const int rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
101 WLAN_CFG_RX_MON_RING_MASK_0,
102 WLAN_CFG_RX_MON_RING_MASK_1,
103 WLAN_CFG_RX_MON_RING_MASK_2,
104 WLAN_CFG_RX_MON_RING_MASK_3};
105
106/**
107 * struct wlan_cfg_dp_soc_ctxt - Configuration parameters for SoC (core TxRx)
108 * @num_int_ctxts - Number of NAPI/Interrupt contexts to be registered for DP
109 * @max_clients - Maximum number of peers/stations supported by device
110 * @max_alloc_size - Maximum allocation size for any dynamic memory
111 * allocation request for this device
112 * @per_pdev_tx_ring - 0 - TCL ring is not mapped per radio
113 * 1 - Each TCL ring is mapped to one radio/pdev
114 * @num_tcl_data_rings - Number of TCL Data rings supported by device
115 * @per_pdev_rx_ring - 0 - REO ring is not mapped per radio
116 * 1 - Each REO ring is mapped to one radio/pdev
117 * @num_tx_desc_pool - Number of Tx Descriptor pools
118 * @num_tx_ext_desc_pool - Number of Tx MSDU extension Descriptor pools
119 * @num_tx_desc - Number of Tx Descriptors per pool
120 * @num_tx_ext_desc - Number of Tx MSDU extension Descriptors per pool
121 * @max_peer_id - Maximum value of peer id that FW can assign for a client
122 * @htt_packet_type - Default 802.11 encapsulation type for any VAP created
123 * @int_tx_ring_mask - Bitmap of Tx interrupts mapped to each NAPI/Intr context
124 * @int_rx_ring_mask - Bitmap of Rx interrupts mapped to each NAPI/Intr context
125 * @int_rx_mon_ring_mask - Bitmap of Rx monitor ring interrupts mapped to each
126 * NAPI/Intr context
127 * @int_ce_ring_mask - Bitmap of CE interrupts mapped to each NAPI/Intr context
128 *
129 */
130struct wlan_cfg_dp_soc_ctxt {
131 int num_int_ctxts;
132 int max_clients;
133 int max_alloc_size;
134 int per_pdev_tx_ring;
135 int num_tcl_data_rings;
136 int per_pdev_rx_ring;
137 int num_reo_dest_rings;
138 int num_tx_desc_pool;
139 int num_tx_ext_desc_pool;
140 int num_tx_desc;
141 int num_tx_ext_desc;
142 int max_peer_id;
143 int htt_packet_type;
144 int int_tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
145 int int_rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
146 int int_rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
147 int int_ce_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
148};
149
150/**
151 * struct wlan_cfg_dp_pdev_ctxt - Configuration parameters for pdev (radio)
152 * @rx_dma_buf_ring_size - Size of RxDMA buffer ring
153 * @dma_mon_buf_ring_size - Size of RxDMA Monitor buffer ring
154 * @dma_mon_dest_ring_size - Size of RxDMA Monitor Destination ring
155 * @dma_mon_status_ring_size - Size of RxDMA Monitor Status ring
156 */
157struct wlan_cfg_dp_pdev_ctxt {
158 int rx_dma_buf_ring_size;
159 int dma_mon_buf_ring_size;
160 int dma_mon_dest_ring_size;
161 int dma_mon_status_ring_size;
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800162 int num_mac_rings;
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +0530163};
164
165/**
166 * wlan_cfg_soc_attach() - Allocate and prepare SoC configuration
167 *
168 * Return: wlan_cfg_ctx - Handle to Configuration context
169 */
170struct wlan_cfg_dp_soc_ctxt *wlan_cfg_soc_attach(void)
171{
172 int i = 0;
173 struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx =
174 qdf_mem_malloc(sizeof(struct wlan_cfg_dp_soc_ctxt));
175
176 if (wlan_cfg_ctx == NULL)
177 return NULL;
178
179 wlan_cfg_ctx->num_int_ctxts = WLAN_CFG_INT_NUM_CONTEXTS;
180 wlan_cfg_ctx->max_clients = WLAN_CFG_MAX_CLIENTS;
181 wlan_cfg_ctx->max_alloc_size = WLAN_CFG_MAX_ALLOC_SIZE;
182 wlan_cfg_ctx->per_pdev_tx_ring = WLAN_CFG_PER_PDEV_TX_RING;
183 wlan_cfg_ctx->num_tcl_data_rings = WLAN_CFG_NUM_TCL_DATA_RINGS;
184 wlan_cfg_ctx->per_pdev_rx_ring = WLAN_CFG_PER_PDEV_RX_RING;
185 wlan_cfg_ctx->num_reo_dest_rings = WLAN_CFG_NUM_REO_DEST_RING;
186 wlan_cfg_ctx->num_tx_desc_pool = WLAN_CFG_NUM_TX_DESC_POOL;
187 wlan_cfg_ctx->num_tx_ext_desc_pool = WLAN_CFG_NUM_TXEXT_DESC_POOL;
188 wlan_cfg_ctx->num_tx_desc = WLAN_CFG_NUM_TX_DESC;
189 wlan_cfg_ctx->num_tx_ext_desc = WLAN_CFG_NUM_TX_EXT_DESC;
190 wlan_cfg_ctx->max_peer_id = WLAN_CFG_MAX_PEER_ID;
191 wlan_cfg_ctx->htt_packet_type = WLAN_CFG_HTT_PKT_TYPE;
192
193 for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
194 wlan_cfg_ctx->int_tx_ring_mask[i] = tx_ring_mask[i];
195 wlan_cfg_ctx->int_rx_ring_mask[i] = rx_ring_mask[i];
196 wlan_cfg_ctx->int_rx_mon_ring_mask[i] = rx_mon_ring_mask[i];
197 }
198
199 return wlan_cfg_ctx;
200}
201
202void wlan_cfg_soc_detach(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx)
203{
204 qdf_mem_free(wlan_cfg_ctx);
205}
206
207struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_pdev_attach(void)
208{
209 struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx =
210 qdf_mem_malloc(sizeof(struct wlan_cfg_dp_pdev_ctxt));
211
212 if (wlan_cfg_ctx == NULL)
213 return NULL;
214
215 wlan_cfg_ctx->rx_dma_buf_ring_size = RXDMA_BUF_RING_SIZE;
216 wlan_cfg_ctx->dma_mon_buf_ring_size = RXDMA_MONITOR_BUF_RING_SIZE;
217 wlan_cfg_ctx->dma_mon_dest_ring_size = RXDMA_MONITOR_DEST_RING_SIZE;
218 wlan_cfg_ctx->dma_mon_status_ring_size = RXDMA_MONITOR_STATUS_RING_SIZE;
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800219 wlan_cfg_ctx->num_mac_rings = NUM_RXDMA_RINGS_PER_PDEV;
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +0530220
221 return wlan_cfg_ctx;
222}
223
224void wlan_cfg_pdev_detach(struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx)
225{
226 qdf_mem_free(wlan_cfg_ctx);
227}
228
229void wlan_cfg_set_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg, int num)
230{
231 cfg->num_int_ctxts = num;
232}
233
234void wlan_cfg_set_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
235 int context, int mask)
236{
237 cfg->int_tx_ring_mask[context] = mask;
238}
239
240void wlan_cfg_set_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
241 int context, int mask)
242{
243 cfg->int_rx_ring_mask[context] = mask;
244}
245
246void wlan_cfg_set_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
247 int context, int mask)
248{
249 cfg->int_rx_mon_ring_mask[context] = mask;
250}
251
252void wlan_cfg_set_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
253 int context, int mask)
254{
255 cfg->int_ce_ring_mask[context] = mask;
256}
257
258void wlan_cfg_set_rxbuf_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context,
259 int mask)
260{
261 cfg->int_rx_ring_mask[context] = mask;
262}
263
264int wlan_cfg_get_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg)
265{
266 return cfg->num_int_ctxts;
267}
268
269int wlan_cfg_get_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
270{
271 return cfg->int_tx_ring_mask[context];
272}
273
274int wlan_cfg_get_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
275{
276 return cfg->int_rx_ring_mask[context];
277}
278
279int wlan_cfg_get_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
280{
281 return cfg->int_rx_mon_ring_mask[context];
282}
283
284int wlan_cfg_get_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
285{
286 return cfg->int_ce_ring_mask[context];
287}
288
289uint32_t wlan_cfg_get_max_clients(struct wlan_cfg_dp_soc_ctxt *cfg)
290{
291 return cfg->max_clients;
292}
293
294uint32_t wlan_cfg_max_alloc_size(struct wlan_cfg_dp_soc_ctxt *cfg)
295{
296 return cfg->max_alloc_size;
297}
298
299int wlan_cfg_per_pdev_tx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
300{
301 return cfg->per_pdev_tx_ring;
302}
303
304int wlan_cfg_num_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
305{
306 return cfg->num_tcl_data_rings;
307}
308
309int wlan_cfg_per_pdev_rx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
310{
311 return cfg->per_pdev_rx_ring;
312}
313
314int wlan_cfg_num_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
315{
316 return cfg->num_reo_dest_rings;
317}
318
319int wlan_cfg_pkt_type(struct wlan_cfg_dp_soc_ctxt *cfg)
320{
321 return cfg->htt_packet_type; /*htt_pkt_type_ethernet*/
322}
323
324int wlan_cfg_get_num_tx_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
325{
326 return cfg->num_tx_desc_pool;
327}
328
329int wlan_cfg_get_num_tx_ext_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
330{
331 return cfg->num_tx_ext_desc_pool;
332}
333
334int wlan_cfg_get_num_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
335{
336 return cfg->num_tx_desc;
337}
338
339int wlan_cfg_get_num_tx_ext_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
340{
341 return cfg->num_tx_ext_desc;
342}
343
344uint32_t wlan_cfg_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg)
345{
346 /* TODO: This should be calculated based on target capabilities */
347 return cfg->max_peer_id;
348}
349
350int wlan_cfg_get_dma_mon_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
351{
352 return cfg->dma_mon_buf_ring_size;
353}
354
355int wlan_cfg_get_dma_mon_dest_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
356{
357 return cfg->dma_mon_dest_ring_size;
358}
359
360int wlan_cfg_get_dma_mon_stat_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
361{
362 return cfg->dma_mon_status_ring_size;
363}
364
365int wlan_cfg_get_rx_dma_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
366{
367 return cfg->rx_dma_buf_ring_size;
368}
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800369
370int wlan_cfg_get_num_mac_rings(struct wlan_cfg_dp_pdev_ctxt *cfg)
371{
372 return cfg->num_mac_rings;
373}