blob: f1a9c959c754040f641b98d92816e0a1bb482957 [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 */
Karunakar Dasineni67c78772017-02-27 22:03:25 -080070#define WLAN_CFG_MAX_ALLOC_SIZE (2 << 20)
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053071
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
Vijay Pamidipatic84501a2016-11-17 21:51:35 +053076#define WLAN_CFG_NUM_REO_DEST_RING 4
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053077
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053078#define WLAN_CFG_HTT_PKT_TYPE 2
Kiran Venkatappa8dac1db2017-05-16 12:40:38 +053079#define WLAN_CFG_MAX_PEER_ID 64
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053080
Dhanashri Atred4032ab2017-01-17 15:05:41 -080081#ifdef CONFIG_MCL
Dhanashri Atrecdfde222017-04-13 22:41:19 -070082#define WLAN_CFG_PER_PDEV_RX_RING 0
Dhanashri Atred4032ab2017-01-17 15:05:41 -080083#define NUM_RXDMA_RINGS_PER_PDEV 2
Manjunathappa Prakash9737bd72017-05-26 20:59:19 -070084#define WLAN_LRO_ENABLE 1
Dhanashri Atred4032ab2017-01-17 15:05:41 -080085#else
Dhanashri Atrecdfde222017-04-13 22:41:19 -070086#define WLAN_CFG_PER_PDEV_RX_RING 1
Dhanashri Atred4032ab2017-01-17 15:05:41 -080087#define NUM_RXDMA_RINGS_PER_PDEV 1
Manjunathappa Prakash9737bd72017-05-26 20:59:19 -070088#define WLAN_LRO_ENABLE 0
Dhanashri Atred4032ab2017-01-17 15:05:41 -080089#endif
90
Dhanashri Atreb178eb42017-03-21 12:32:33 -070091#ifdef WLAN_RX_HASH
92#define WLAN_RX_HASH_ENABLE 1
93#else
Dhanashri Atre14049172016-11-11 18:32:36 -080094#define WLAN_RX_HASH_ENABLE 0
Dhanashri Atreb178eb42017-03-21 12:32:33 -070095#endif
Dhanashri Atre14049172016-11-11 18:32:36 -080096
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +053097static const int tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
98 WLAN_CFG_TX_RING_MASK_0,
99 WLAN_CFG_TX_RING_MASK_1,
100 WLAN_CFG_TX_RING_MASK_2,
101 WLAN_CFG_TX_RING_MASK_3};
102
103static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
104 WLAN_CFG_RX_RING_MASK_0,
105 WLAN_CFG_RX_RING_MASK_1,
106 WLAN_CFG_RX_RING_MASK_2,
107 WLAN_CFG_RX_RING_MASK_3};
108
109static const int rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
110 WLAN_CFG_RX_MON_RING_MASK_0,
111 WLAN_CFG_RX_MON_RING_MASK_1,
112 WLAN_CFG_RX_MON_RING_MASK_2,
113 WLAN_CFG_RX_MON_RING_MASK_3};
114
115/**
116 * struct wlan_cfg_dp_soc_ctxt - Configuration parameters for SoC (core TxRx)
117 * @num_int_ctxts - Number of NAPI/Interrupt contexts to be registered for DP
118 * @max_clients - Maximum number of peers/stations supported by device
119 * @max_alloc_size - Maximum allocation size for any dynamic memory
120 * allocation request for this device
121 * @per_pdev_tx_ring - 0 - TCL ring is not mapped per radio
122 * 1 - Each TCL ring is mapped to one radio/pdev
123 * @num_tcl_data_rings - Number of TCL Data rings supported by device
124 * @per_pdev_rx_ring - 0 - REO ring is not mapped per radio
125 * 1 - Each REO ring is mapped to one radio/pdev
126 * @num_tx_desc_pool - Number of Tx Descriptor pools
127 * @num_tx_ext_desc_pool - Number of Tx MSDU extension Descriptor pools
128 * @num_tx_desc - Number of Tx Descriptors per pool
129 * @num_tx_ext_desc - Number of Tx MSDU extension Descriptors per pool
130 * @max_peer_id - Maximum value of peer id that FW can assign for a client
131 * @htt_packet_type - Default 802.11 encapsulation type for any VAP created
132 * @int_tx_ring_mask - Bitmap of Tx interrupts mapped to each NAPI/Intr context
133 * @int_rx_ring_mask - Bitmap of Rx interrupts mapped to each NAPI/Intr context
134 * @int_rx_mon_ring_mask - Bitmap of Rx monitor ring interrupts mapped to each
135 * NAPI/Intr context
136 * @int_ce_ring_mask - Bitmap of CE interrupts mapped to each NAPI/Intr context
Dhanashri Atre14049172016-11-11 18:32:36 -0800137 * @lro_enabled - is LRO enabled
138 * @rx_hash - Enable hash based steering of rx packets
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +0530139 *
140 */
141struct wlan_cfg_dp_soc_ctxt {
142 int num_int_ctxts;
143 int max_clients;
144 int max_alloc_size;
145 int per_pdev_tx_ring;
146 int num_tcl_data_rings;
147 int per_pdev_rx_ring;
148 int num_reo_dest_rings;
149 int num_tx_desc_pool;
150 int num_tx_ext_desc_pool;
151 int num_tx_desc;
152 int num_tx_ext_desc;
153 int max_peer_id;
154 int htt_packet_type;
155 int int_tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
156 int int_rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
157 int int_rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
158 int int_ce_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS];
Dhanashri Atre14049172016-11-11 18:32:36 -0800159 bool lro_enabled;
160 bool rx_hash;
Bharat Kumar M9a5d5372017-05-08 17:41:42 +0530161 int nss_cfg;
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +0530162};
163
164/**
165 * struct wlan_cfg_dp_pdev_ctxt - Configuration parameters for pdev (radio)
166 * @rx_dma_buf_ring_size - Size of RxDMA buffer ring
167 * @dma_mon_buf_ring_size - Size of RxDMA Monitor buffer ring
168 * @dma_mon_dest_ring_size - Size of RxDMA Monitor Destination ring
169 * @dma_mon_status_ring_size - Size of RxDMA Monitor Status ring
170 */
171struct wlan_cfg_dp_pdev_ctxt {
172 int rx_dma_buf_ring_size;
173 int dma_mon_buf_ring_size;
174 int dma_mon_dest_ring_size;
175 int dma_mon_status_ring_size;
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800176 int num_mac_rings;
Bharat Kumar M9a5d5372017-05-08 17:41:42 +0530177 int nss_enabled;
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +0530178};
179
180/**
181 * wlan_cfg_soc_attach() - Allocate and prepare SoC configuration
182 *
183 * Return: wlan_cfg_ctx - Handle to Configuration context
184 */
185struct wlan_cfg_dp_soc_ctxt *wlan_cfg_soc_attach(void)
186{
187 int i = 0;
188 struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx =
189 qdf_mem_malloc(sizeof(struct wlan_cfg_dp_soc_ctxt));
190
191 if (wlan_cfg_ctx == NULL)
192 return NULL;
193
194 wlan_cfg_ctx->num_int_ctxts = WLAN_CFG_INT_NUM_CONTEXTS;
195 wlan_cfg_ctx->max_clients = WLAN_CFG_MAX_CLIENTS;
196 wlan_cfg_ctx->max_alloc_size = WLAN_CFG_MAX_ALLOC_SIZE;
197 wlan_cfg_ctx->per_pdev_tx_ring = WLAN_CFG_PER_PDEV_TX_RING;
198 wlan_cfg_ctx->num_tcl_data_rings = WLAN_CFG_NUM_TCL_DATA_RINGS;
199 wlan_cfg_ctx->per_pdev_rx_ring = WLAN_CFG_PER_PDEV_RX_RING;
200 wlan_cfg_ctx->num_reo_dest_rings = WLAN_CFG_NUM_REO_DEST_RING;
201 wlan_cfg_ctx->num_tx_desc_pool = WLAN_CFG_NUM_TX_DESC_POOL;
202 wlan_cfg_ctx->num_tx_ext_desc_pool = WLAN_CFG_NUM_TXEXT_DESC_POOL;
203 wlan_cfg_ctx->num_tx_desc = WLAN_CFG_NUM_TX_DESC;
204 wlan_cfg_ctx->num_tx_ext_desc = WLAN_CFG_NUM_TX_EXT_DESC;
205 wlan_cfg_ctx->max_peer_id = WLAN_CFG_MAX_PEER_ID;
206 wlan_cfg_ctx->htt_packet_type = WLAN_CFG_HTT_PKT_TYPE;
207
208 for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
209 wlan_cfg_ctx->int_tx_ring_mask[i] = tx_ring_mask[i];
210 wlan_cfg_ctx->int_rx_ring_mask[i] = rx_ring_mask[i];
211 wlan_cfg_ctx->int_rx_mon_ring_mask[i] = rx_mon_ring_mask[i];
212 }
213
Dhanashri Atre14049172016-11-11 18:32:36 -0800214 wlan_cfg_ctx->rx_hash = WLAN_RX_HASH_ENABLE;
215 wlan_cfg_ctx->lro_enabled = WLAN_LRO_ENABLE;
216
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +0530217 return wlan_cfg_ctx;
218}
219
220void wlan_cfg_soc_detach(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx)
221{
222 qdf_mem_free(wlan_cfg_ctx);
223}
224
225struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_pdev_attach(void)
226{
227 struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx =
228 qdf_mem_malloc(sizeof(struct wlan_cfg_dp_pdev_ctxt));
229
230 if (wlan_cfg_ctx == NULL)
231 return NULL;
232
233 wlan_cfg_ctx->rx_dma_buf_ring_size = RXDMA_BUF_RING_SIZE;
234 wlan_cfg_ctx->dma_mon_buf_ring_size = RXDMA_MONITOR_BUF_RING_SIZE;
235 wlan_cfg_ctx->dma_mon_dest_ring_size = RXDMA_MONITOR_DEST_RING_SIZE;
236 wlan_cfg_ctx->dma_mon_status_ring_size = RXDMA_MONITOR_STATUS_RING_SIZE;
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800237 wlan_cfg_ctx->num_mac_rings = NUM_RXDMA_RINGS_PER_PDEV;
Vijay Pamidipatid41d6d62016-10-19 21:19:00 +0530238
239 return wlan_cfg_ctx;
240}
241
242void wlan_cfg_pdev_detach(struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx)
243{
244 qdf_mem_free(wlan_cfg_ctx);
245}
246
247void wlan_cfg_set_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg, int num)
248{
249 cfg->num_int_ctxts = num;
250}
251
252void wlan_cfg_set_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
253 int context, int mask)
254{
255 cfg->int_tx_ring_mask[context] = mask;
256}
257
258void wlan_cfg_set_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
259 int context, int mask)
260{
261 cfg->int_rx_ring_mask[context] = mask;
262}
263
264void wlan_cfg_set_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
265 int context, int mask)
266{
267 cfg->int_rx_mon_ring_mask[context] = mask;
268}
269
270void wlan_cfg_set_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
271 int context, int mask)
272{
273 cfg->int_ce_ring_mask[context] = mask;
274}
275
276void wlan_cfg_set_rxbuf_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context,
277 int mask)
278{
279 cfg->int_rx_ring_mask[context] = mask;
280}
281
282int wlan_cfg_get_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg)
283{
284 return cfg->num_int_ctxts;
285}
286
287int wlan_cfg_get_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
288{
289 return cfg->int_tx_ring_mask[context];
290}
291
292int wlan_cfg_get_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
293{
294 return cfg->int_rx_ring_mask[context];
295}
296
297int wlan_cfg_get_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
298{
299 return cfg->int_rx_mon_ring_mask[context];
300}
301
302int wlan_cfg_get_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
303{
304 return cfg->int_ce_ring_mask[context];
305}
306
307uint32_t wlan_cfg_get_max_clients(struct wlan_cfg_dp_soc_ctxt *cfg)
308{
309 return cfg->max_clients;
310}
311
312uint32_t wlan_cfg_max_alloc_size(struct wlan_cfg_dp_soc_ctxt *cfg)
313{
314 return cfg->max_alloc_size;
315}
316
317int wlan_cfg_per_pdev_tx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
318{
319 return cfg->per_pdev_tx_ring;
320}
321
322int wlan_cfg_num_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
323{
324 return cfg->num_tcl_data_rings;
325}
326
327int wlan_cfg_per_pdev_rx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
328{
329 return cfg->per_pdev_rx_ring;
330}
331
332int wlan_cfg_num_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
333{
334 return cfg->num_reo_dest_rings;
335}
336
337int wlan_cfg_pkt_type(struct wlan_cfg_dp_soc_ctxt *cfg)
338{
339 return cfg->htt_packet_type; /*htt_pkt_type_ethernet*/
340}
341
342int wlan_cfg_get_num_tx_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
343{
344 return cfg->num_tx_desc_pool;
345}
346
347int wlan_cfg_get_num_tx_ext_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
348{
349 return cfg->num_tx_ext_desc_pool;
350}
351
352int wlan_cfg_get_num_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
353{
354 return cfg->num_tx_desc;
355}
356
357int wlan_cfg_get_num_tx_ext_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
358{
359 return cfg->num_tx_ext_desc;
360}
361
362uint32_t wlan_cfg_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg)
363{
364 /* TODO: This should be calculated based on target capabilities */
365 return cfg->max_peer_id;
366}
367
368int wlan_cfg_get_dma_mon_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
369{
370 return cfg->dma_mon_buf_ring_size;
371}
372
373int wlan_cfg_get_dma_mon_dest_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
374{
375 return cfg->dma_mon_dest_ring_size;
376}
377
378int wlan_cfg_get_dma_mon_stat_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
379{
380 return cfg->dma_mon_status_ring_size;
381}
382
383int wlan_cfg_get_rx_dma_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
384{
385 return cfg->rx_dma_buf_ring_size;
386}
Dhanashri Atred4032ab2017-01-17 15:05:41 -0800387
388int wlan_cfg_get_num_mac_rings(struct wlan_cfg_dp_pdev_ctxt *cfg)
389{
390 return cfg->num_mac_rings;
391}
Dhanashri Atre14049172016-11-11 18:32:36 -0800392
393bool wlan_cfg_is_lro_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
394{
395 return cfg->lro_enabled;
396}
397
398bool wlan_cfg_is_rx_hash_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
399{
400 return cfg->rx_hash;
401}
Bharat Kumar M9a5d5372017-05-08 17:41:42 +0530402
403int wlan_cfg_get_dp_pdev_nss_enabled(struct wlan_cfg_dp_pdev_ctxt *cfg)
404{
405 return cfg->nss_enabled;
406}
407
408void wlan_cfg_set_dp_pdev_nss_enabled(struct wlan_cfg_dp_pdev_ctxt *cfg, int nss_enabled)
409{
410 cfg->nss_enabled = nss_enabled;
411}
412
413int wlan_cfg_get_dp_soc_nss_cfg(struct wlan_cfg_dp_soc_ctxt *cfg)
414{
415 return cfg->nss_cfg;
416}
417
418void wlan_cfg_set_dp_soc_nss_cfg(struct wlan_cfg_dp_soc_ctxt *cfg, int nss_cfg)
419{
420 cfg->nss_cfg = nss_cfg;
421}