xref: /wlan-dirver/qca-wifi-host-cmn/wlan_cfg/wlan_cfg.c (revision 0626a4da6c07f30da06dd6747e8cc290a60371d8)
1 /*
2  * Copyright (c) 2016-2018 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 #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 #include "cfg_ucfg_api.h"
29 
30 /*
31  * FIX THIS -
32  * For now, all these configuration parameters are hardcoded.
33  * Many of these should actually be coming from dts file/ini file
34  */
35 
36 /*
37  * The max allowed size for tx comp ring is 8191.
38  * This is limitted by h/w ring max size.
39  * As this is not a power of 2 it does not work with nss offload so the
40  * nearest available size which is power of 2 is 4096 chosen for nss
41  */
42 
43 #define WLAN_CFG_TX_RING_MASK_0 0x1
44 #define WLAN_CFG_TX_RING_MASK_1 0x2
45 #define WLAN_CFG_TX_RING_MASK_2 0x4
46 #define WLAN_CFG_TX_RING_MASK_3 0x0
47 
48 #define WLAN_CFG_RX_RING_MASK_0 0x1
49 #define WLAN_CFG_RX_RING_MASK_1 0x2
50 #define WLAN_CFG_RX_RING_MASK_2 0x4
51 #define WLAN_CFG_RX_RING_MASK_3 0x8
52 
53 #define WLAN_CFG_RX_MON_RING_MASK_0 0x1
54 #define WLAN_CFG_RX_MON_RING_MASK_1 0x2
55 #define WLAN_CFG_RX_MON_RING_MASK_2 0x4
56 #define WLAN_CFG_RX_MON_RING_MASK_3 0x0
57 
58 #define WLAN_CFG_RX_ERR_RING_MASK_0 0x1
59 #define WLAN_CFG_RX_ERR_RING_MASK_1 0x0
60 #define WLAN_CFG_RX_ERR_RING_MASK_2 0x0
61 #define WLAN_CFG_RX_ERR_RING_MASK_3 0x0
62 
63 #define WLAN_CFG_RX_WBM_REL_RING_MASK_0 0x1
64 #define WLAN_CFG_RX_WBM_REL_RING_MASK_1 0x0
65 #define WLAN_CFG_RX_WBM_REL_RING_MASK_2 0x0
66 #define WLAN_CFG_RX_WBM_REL_RING_MASK_3 0x0
67 
68 #define WLAN_CFG_REO_STATUS_RING_MASK_0 0x1
69 #define WLAN_CFG_REO_STATUS_RING_MASK_1 0x0
70 #define WLAN_CFG_REO_STATUS_RING_MASK_2 0x0
71 #define WLAN_CFG_REO_STATUS_RING_MASK_3 0x0
72 
73 #define WLAN_CFG_RXDMA2HOST_RING_MASK_0 0x1
74 #define WLAN_CFG_RXDMA2HOST_RING_MASK_1 0x2
75 #define WLAN_CFG_RXDMA2HOST_RING_MASK_2 0x4
76 #define WLAN_CFG_RXDMA2HOST_RING_MASK_3 0x0
77 
78 #define WLAN_CFG_HOST2RXDMA_RING_MASK_0 0x1
79 #define WLAN_CFG_HOST2RXDMA_RING_MASK_1 0x2
80 #define WLAN_CFG_HOST2RXDMA_RING_MASK_2 0x4
81 #define WLAN_CFG_HOST2RXDMA_RING_MASK_3 0x0
82 
83 #ifdef CONFIG_MCL
84 static const int tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
85 						0,
86 						WLAN_CFG_TX_RING_MASK_0,
87 						0,
88 						0,
89 						0,
90 						0,
91 						0};
92 
93 #ifndef IPA_OFFLOAD
94 static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
95 					0,
96 					0,
97 					WLAN_CFG_RX_RING_MASK_0,
98 					0,
99 					WLAN_CFG_RX_RING_MASK_1,
100 					WLAN_CFG_RX_RING_MASK_2,
101 					WLAN_CFG_RX_RING_MASK_3};
102 #else
103 static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
104 					0,
105 					0,
106 					WLAN_CFG_RX_RING_MASK_0,
107 					0,
108 					WLAN_CFG_RX_RING_MASK_1,
109 					WLAN_CFG_RX_RING_MASK_2,
110 					0};
111 #endif
112 
113 static const int rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
114 					0,
115 					0,
116 					0,
117 					WLAN_CFG_RX_MON_RING_MASK_0,
118 					WLAN_CFG_RX_MON_RING_MASK_1,
119 					WLAN_CFG_RX_MON_RING_MASK_2,
120 					WLAN_CFG_RX_MON_RING_MASK_3};
121 
122 static const int host2rxdma_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
123 					WLAN_CFG_HOST2RXDMA_RING_MASK_0,
124 					0,
125 					0,
126 					0,
127 					0,
128 					0,
129 					0};
130 #else
131 static const int tx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
132 						WLAN_CFG_TX_RING_MASK_0,
133 						WLAN_CFG_TX_RING_MASK_1,
134 						WLAN_CFG_TX_RING_MASK_2,
135 						WLAN_CFG_TX_RING_MASK_3};
136 
137 static const int rx_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
138 					WLAN_CFG_RX_RING_MASK_0,
139 					WLAN_CFG_RX_RING_MASK_1,
140 					WLAN_CFG_RX_RING_MASK_2,
141 					WLAN_CFG_RX_RING_MASK_3};
142 
143 static const int rx_mon_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
144 					0,
145 					0,
146 					0,
147 					0,
148 					WLAN_CFG_RX_MON_RING_MASK_0,
149 					WLAN_CFG_RX_MON_RING_MASK_1,
150 					WLAN_CFG_RX_MON_RING_MASK_2};
151 
152 static const int host2rxdma_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
153 					WLAN_CFG_HOST2RXDMA_RING_MASK_0,
154 					WLAN_CFG_HOST2RXDMA_RING_MASK_1,
155 					WLAN_CFG_HOST2RXDMA_RING_MASK_2,
156 					WLAN_CFG_HOST2RXDMA_RING_MASK_3};
157 #endif
158 
159 static const int rx_err_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
160 					WLAN_CFG_RX_ERR_RING_MASK_0,
161 					WLAN_CFG_RX_ERR_RING_MASK_1,
162 					WLAN_CFG_RX_ERR_RING_MASK_2,
163 					WLAN_CFG_RX_ERR_RING_MASK_3};
164 
165 static const int rx_wbm_rel_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
166 					WLAN_CFG_RX_WBM_REL_RING_MASK_0,
167 					WLAN_CFG_RX_WBM_REL_RING_MASK_1,
168 					WLAN_CFG_RX_WBM_REL_RING_MASK_2,
169 					WLAN_CFG_RX_WBM_REL_RING_MASK_3};
170 
171 static const int reo_status_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
172 					WLAN_CFG_REO_STATUS_RING_MASK_0,
173 					WLAN_CFG_REO_STATUS_RING_MASK_1,
174 					WLAN_CFG_REO_STATUS_RING_MASK_2,
175 					WLAN_CFG_REO_STATUS_RING_MASK_3};
176 
177 static const int rxdma2host_ring_mask[WLAN_CFG_INT_NUM_CONTEXTS] = {
178 					WLAN_CFG_RXDMA2HOST_RING_MASK_0,
179 					WLAN_CFG_RXDMA2HOST_RING_MASK_1,
180 					WLAN_CFG_RXDMA2HOST_RING_MASK_2,
181 					WLAN_CFG_RXDMA2HOST_RING_MASK_3};
182 
183 /**
184  * struct wlan_cfg_dp_pdev_ctxt - Configuration parameters for pdev (radio)
185  * @rx_dma_buf_ring_size - Size of RxDMA buffer ring
186  * @dma_mon_buf_ring_size - Size of RxDMA Monitor buffer ring
187  * @dma_mon_dest_ring_size - Size of RxDMA Monitor Destination ring
188  * @dma_mon_status_ring_size - Size of RxDMA Monitor Status ring
189  * @rxdma_monitor_desc_ring - rxdma monitor desc ring size
190  */
191 struct wlan_cfg_dp_pdev_ctxt {
192 	int rx_dma_buf_ring_size;
193 	int dma_mon_buf_ring_size;
194 	int dma_mon_dest_ring_size;
195 	int dma_mon_status_ring_size;
196 	int rxdma_monitor_desc_ring;
197 	int num_mac_rings;
198 	int nss_enabled;
199 };
200 
201 /**
202  * wlan_cfg_soc_attach() - Allocate and prepare SoC configuration
203  * @psoc - Object manager psoc
204  * Return: wlan_cfg_ctx - Handle to Configuration context
205  */
206 struct wlan_cfg_dp_soc_ctxt *wlan_cfg_soc_attach(void *psoc)
207 {
208 	int i = 0;
209 
210 	struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx =
211 		qdf_mem_malloc(sizeof(struct wlan_cfg_dp_soc_ctxt));
212 
213 	if (wlan_cfg_ctx == NULL)
214 		return NULL;
215 
216 	wlan_cfg_ctx->num_int_ctxts = WLAN_CFG_INT_NUM_CONTEXTS;
217 	wlan_cfg_ctx->max_clients = cfg_get(psoc, CFG_DP_MAX_CLIENTS);
218 	wlan_cfg_ctx->max_alloc_size = cfg_get(psoc, CFG_DP_MAX_ALLOC_SIZE);
219 	wlan_cfg_ctx->per_pdev_tx_ring = cfg_get(psoc, CFG_DP_PDEV_TX_RING);
220 	wlan_cfg_ctx->num_tcl_data_rings = cfg_get(psoc, CFG_DP_TCL_DATA_RINGS);
221 	wlan_cfg_ctx->per_pdev_rx_ring = cfg_get(psoc, CFG_DP_PDEV_RX_RING);
222 	wlan_cfg_ctx->per_pdev_lmac_ring = cfg_get(psoc, CFG_DP_PDEV_LMAC_RING);
223 	wlan_cfg_ctx->num_reo_dest_rings = cfg_get(psoc, CFG_DP_REO_DEST_RINGS);
224 	wlan_cfg_ctx->num_tx_desc_pool = MAX_TXDESC_POOLS;
225 	wlan_cfg_ctx->num_tx_ext_desc_pool = cfg_get(psoc,
226 						     CFG_DP_TX_EXT_DESC_POOLS);
227 	wlan_cfg_ctx->num_tx_desc = cfg_get(psoc, CFG_DP_TX_DESC);
228 	wlan_cfg_ctx->num_tx_ext_desc = cfg_get(psoc, CFG_DP_TX_EXT_DESC);
229 	wlan_cfg_ctx->htt_packet_type = cfg_get(psoc, CFG_DP_HTT_PACKET_TYPE);
230 	wlan_cfg_ctx->max_peer_id = cfg_get(psoc, CFG_DP_MAX_PEER_ID);
231 
232 	wlan_cfg_ctx->tx_ring_size = cfg_get(psoc, CFG_DP_TX_RING_SIZE);
233 	wlan_cfg_ctx->tx_comp_ring_size = cfg_get(psoc,
234 						  CFG_DP_TX_COMPL_RING_SIZE);
235 
236 	wlan_cfg_ctx->tx_comp_ring_size_nss =
237 		cfg_get(psoc, CFG_DP_NSS_COMP_RING_SIZE);
238 	wlan_cfg_ctx->int_batch_threshold_tx =
239 			cfg_get(psoc, CFG_DP_INT_BATCH_THRESHOLD_TX);
240 	wlan_cfg_ctx->int_timer_threshold_tx =
241 			cfg_get(psoc, CFG_DP_INT_TIMER_THRESHOLD_TX);
242 	wlan_cfg_ctx->int_batch_threshold_rx =
243 			cfg_get(psoc, CFG_DP_INT_BATCH_THRESHOLD_RX);
244 	wlan_cfg_ctx->int_timer_threshold_rx =
245 			cfg_get(psoc, CFG_DP_INT_TIMER_THRESHOLD_RX);
246 	wlan_cfg_ctx->int_batch_threshold_other =
247 		cfg_get(psoc, CFG_DP_INT_BATCH_THRESHOLD_OTHER);
248 	wlan_cfg_ctx->int_timer_threshold_other =
249 		cfg_get(psoc, CFG_DP_INT_TIMER_THRESHOLD_OTHER);
250 
251 	for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
252 		wlan_cfg_ctx->int_tx_ring_mask[i] = tx_ring_mask[i];
253 		wlan_cfg_ctx->int_rx_ring_mask[i] = rx_ring_mask[i];
254 		wlan_cfg_ctx->int_rx_mon_ring_mask[i] = rx_mon_ring_mask[i];
255 		wlan_cfg_ctx->int_rx_err_ring_mask[i] = rx_err_ring_mask[i];
256 		wlan_cfg_ctx->int_rx_wbm_rel_ring_mask[i] =
257 					rx_wbm_rel_ring_mask[i];
258 		wlan_cfg_ctx->int_reo_status_ring_mask[i] =
259 					reo_status_ring_mask[i];
260 		wlan_cfg_ctx->int_rxdma2host_ring_mask[i] =
261 			rxdma2host_ring_mask[i];
262 		wlan_cfg_ctx->int_host2rxdma_ring_mask[i] =
263 			host2rxdma_ring_mask[i];
264 	}
265 
266 	/* This is default mapping and can be overridden by HW config
267 	 * received from FW */
268 	wlan_cfg_set_hw_macid(wlan_cfg_ctx, 0, 1);
269 	if (MAX_PDEV_CNT > 1)
270 		wlan_cfg_set_hw_macid(wlan_cfg_ctx, 1, 3);
271 	if (MAX_PDEV_CNT > 2)
272 		wlan_cfg_set_hw_macid(wlan_cfg_ctx, 2, 2);
273 
274 	wlan_cfg_ctx->base_hw_macid = cfg_get(psoc, CFG_DP_BASE_HW_MAC_ID);
275 
276 	wlan_cfg_ctx->lro_enabled = cfg_get(psoc, CFG_DP_LRO);
277 	wlan_cfg_ctx->rx_hash = cfg_get(psoc, CFG_DP_RX_HASH);
278 	wlan_cfg_ctx->tso_enabled = cfg_get(psoc, CFG_DP_TSO);
279 	wlan_cfg_ctx->napi_enabled = cfg_get(psoc, CFG_DP_NAPI);
280 	/*Enable checksum offload by default*/
281 	wlan_cfg_ctx->tcp_udp_checksumoffload =
282 			cfg_get(psoc, CFG_DP_TCP_UDP_CKSUM_OFFLOAD);
283 
284 	wlan_cfg_ctx->defrag_timeout_check =
285 			cfg_get(psoc, CFG_DP_DEFRAG_TIMEOUT_CHECK);
286 	wlan_cfg_ctx->rx_defrag_min_timeout =
287 			cfg_get(psoc, CFG_DP_RX_DEFRAG_TIMEOUT);
288 
289 	wlan_cfg_ctx->wbm_release_ring = cfg_get(psoc,
290 						 CFG_DP_WBM_RELEASE_RING);
291 	wlan_cfg_ctx->tcl_cmd_ring = cfg_get(psoc,
292 					     CFG_DP_TCL_CMD_RING);
293 	wlan_cfg_ctx->tcl_status_ring = cfg_get(psoc,
294 						CFG_DP_TCL_STATUS_RING);
295 	wlan_cfg_ctx->reo_reinject_ring = cfg_get(psoc,
296 						  CFG_DP_REO_REINJECT_RING);
297 	wlan_cfg_ctx->rx_release_ring = cfg_get(psoc,
298 						CFG_DP_RX_RELEASE_RING);
299 	wlan_cfg_ctx->reo_exception_ring = cfg_get(psoc,
300 						   CFG_DP_REO_EXCEPTION_RING);
301 	wlan_cfg_ctx->reo_cmd_ring = cfg_get(psoc,
302 					     CFG_DP_REO_CMD_RING);
303 	wlan_cfg_ctx->reo_status_ring = cfg_get(psoc,
304 						CFG_DP_REO_STATUS_RING);
305 
306 	wlan_cfg_ctx->rxdma_refill_ring = cfg_get(psoc,
307 						  CFG_DP_RXDMA_REFILL_RING);
308 
309 	wlan_cfg_ctx->rxdma_err_dst_ring = cfg_get(psoc,
310 						   CFG_DP_RXDMA_ERR_DST_RING);
311 
312 	return wlan_cfg_ctx;
313 }
314 
315 void wlan_cfg_soc_detach(struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx)
316 {
317 	qdf_mem_free(wlan_cfg_ctx);
318 }
319 
320 struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_pdev_attach(void *psoc)
321 {
322 	struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx =
323 		qdf_mem_malloc(sizeof(struct wlan_cfg_dp_pdev_ctxt));
324 
325 	if (wlan_cfg_ctx == NULL)
326 		return NULL;
327 
328 	wlan_cfg_ctx->rx_dma_buf_ring_size = cfg_get(psoc,
329 					CFG_DP_RXDMA_BUF_RING);
330 	wlan_cfg_ctx->dma_mon_buf_ring_size = cfg_get(psoc,
331 					CFG_DP_RXDMA_MONITOR_BUF_RING);
332 	wlan_cfg_ctx->dma_mon_dest_ring_size = cfg_get(psoc,
333 					CFG_DP_RXDMA_MONITOR_DST_RING);
334 	wlan_cfg_ctx->dma_mon_status_ring_size = cfg_get(psoc,
335 					CFG_DP_RXDMA_MONITOR_STATUS_RING);
336 	wlan_cfg_ctx->rxdma_monitor_desc_ring = cfg_get(psoc,
337 					CFG_DP_RXDMA_MONITOR_DESC_RING);
338 	wlan_cfg_ctx->num_mac_rings = NUM_RXDMA_RINGS_PER_PDEV;
339 
340 	return wlan_cfg_ctx;
341 }
342 
343 void wlan_cfg_pdev_detach(struct wlan_cfg_dp_pdev_ctxt *wlan_cfg_ctx)
344 {
345 	qdf_mem_free(wlan_cfg_ctx);
346 }
347 
348 void wlan_cfg_set_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg, int num)
349 {
350 	cfg->num_int_ctxts = num;
351 }
352 
353 void wlan_cfg_set_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg, uint32_t val)
354 {
355 	cfg->max_peer_id = val;;
356 }
357 
358 void wlan_cfg_set_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
359 		int context, int mask)
360 {
361 	cfg->int_tx_ring_mask[context] = mask;
362 }
363 
364 void wlan_cfg_set_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
365 		int context, int mask)
366 {
367 	cfg->int_rx_ring_mask[context] = mask;
368 }
369 
370 void wlan_cfg_set_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
371 		int context, int mask)
372 {
373 	cfg->int_rx_mon_ring_mask[context] = mask;
374 }
375 
376 void wlan_cfg_set_rxdma2host_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
377 	int context, int mask)
378 {
379 	cfg->int_rxdma2host_ring_mask[context] = mask;
380 }
381 
382 int wlan_cfg_get_rxdma2host_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
383 	int context)
384 {
385 	return cfg->int_rxdma2host_ring_mask[context];
386 }
387 
388 void wlan_cfg_set_host2rxdma_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
389 	int context, int mask)
390 {
391 	cfg->int_host2rxdma_ring_mask[context] = mask;
392 }
393 
394 int wlan_cfg_get_host2rxdma_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
395 	int context)
396 {
397 	return cfg->int_host2rxdma_ring_mask[context];
398 }
399 
400 void wlan_cfg_set_hw_macid(struct wlan_cfg_dp_soc_ctxt *cfg, int pdev_idx,
401 	int hw_macid)
402 {
403 	qdf_assert_always(pdev_idx < MAX_PDEV_CNT);
404 	cfg->hw_macid[pdev_idx] = hw_macid;
405 }
406 
407 int wlan_cfg_get_hw_macid(struct wlan_cfg_dp_soc_ctxt *cfg, int pdev_idx)
408 {
409 	qdf_assert_always(pdev_idx < MAX_PDEV_CNT);
410 	return cfg->hw_macid[pdev_idx];
411 }
412 
413 int wlan_cfg_get_hw_mac_idx(struct wlan_cfg_dp_soc_ctxt *cfg, int pdev_idx)
414 {
415 	qdf_assert_always(pdev_idx < MAX_PDEV_CNT);
416 	return cfg->hw_macid[pdev_idx] - cfg->base_hw_macid;
417 }
418 
419 void wlan_cfg_set_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
420 		int context, int mask)
421 {
422 	cfg->int_ce_ring_mask[context] = mask;
423 }
424 
425 void wlan_cfg_set_rxbuf_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context,
426 		int mask)
427 {
428 	cfg->int_rx_ring_mask[context] = mask;
429 }
430 
431 int wlan_cfg_set_rx_err_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
432 		int context, int mask)
433 {
434 	return cfg->int_rx_err_ring_mask[context] = mask;
435 }
436 
437 int wlan_cfg_set_rx_wbm_rel_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
438 		int context, int mask)
439 {
440 	return cfg->int_rx_wbm_rel_ring_mask[context] = mask;
441 }
442 
443 int wlan_cfg_set_reo_status_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
444 		int context, int mask)
445 {
446 	return cfg->int_reo_status_ring_mask[context] = mask;
447 }
448 
449 int wlan_cfg_get_num_contexts(struct wlan_cfg_dp_soc_ctxt *cfg)
450 {
451 	return cfg->num_int_ctxts;
452 }
453 
454 int wlan_cfg_get_tx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
455 {
456 	return cfg->int_tx_ring_mask[context];
457 }
458 
459 int wlan_cfg_get_rx_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
460 {
461 	return cfg->int_rx_ring_mask[context];
462 }
463 
464 int wlan_cfg_get_rx_err_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
465 						int context)
466 {
467 	return cfg->int_rx_err_ring_mask[context];
468 }
469 
470 int wlan_cfg_get_rx_wbm_rel_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
471 					int context)
472 {
473 	return cfg->int_rx_wbm_rel_ring_mask[context];
474 }
475 
476 int wlan_cfg_get_reo_status_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg,
477 					int context)
478 {
479 	return cfg->int_reo_status_ring_mask[context];
480 }
481 
482 int wlan_cfg_get_rx_mon_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
483 {
484 	return cfg->int_rx_mon_ring_mask[context];
485 }
486 
487 int wlan_cfg_get_ce_ring_mask(struct wlan_cfg_dp_soc_ctxt *cfg, int context)
488 {
489 	return cfg->int_ce_ring_mask[context];
490 }
491 
492 uint32_t wlan_cfg_get_max_clients(struct wlan_cfg_dp_soc_ctxt *cfg)
493 {
494 	return cfg->max_clients;
495 }
496 
497 uint32_t wlan_cfg_max_alloc_size(struct wlan_cfg_dp_soc_ctxt *cfg)
498 {
499 	return cfg->max_alloc_size;
500 }
501 
502 int wlan_cfg_per_pdev_tx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
503 {
504 	return cfg->per_pdev_tx_ring;
505 }
506 
507 int wlan_cfg_per_pdev_lmac_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
508 {
509 	return cfg->per_pdev_lmac_ring;
510 }
511 
512 int wlan_cfg_num_tcl_data_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
513 {
514 	return cfg->num_tcl_data_rings;
515 }
516 
517 int wlan_cfg_tx_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
518 {
519 	return cfg->tx_ring_size;
520 }
521 
522 int wlan_cfg_tx_comp_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
523 {
524 	return cfg->tx_comp_ring_size;
525 }
526 
527 int wlan_cfg_per_pdev_rx_ring(struct wlan_cfg_dp_soc_ctxt *cfg)
528 {
529 	return cfg->per_pdev_rx_ring;
530 }
531 
532 int wlan_cfg_num_reo_dest_rings(struct wlan_cfg_dp_soc_ctxt *cfg)
533 {
534 	return cfg->num_reo_dest_rings;
535 }
536 
537 int wlan_cfg_pkt_type(struct wlan_cfg_dp_soc_ctxt *cfg)
538 {
539 	return cfg->htt_packet_type;            /*htt_pkt_type_ethernet*/
540 }
541 
542 int wlan_cfg_get_num_tx_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
543 {
544 	return cfg->num_tx_desc_pool;
545 }
546 
547 void wlan_cfg_set_num_tx_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg, int num_pool)
548 {
549 	cfg->num_tx_desc_pool = num_pool;
550 }
551 
552 int wlan_cfg_get_num_tx_ext_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg)
553 {
554 	return cfg->num_tx_ext_desc_pool;
555 }
556 
557 void wlan_cfg_set_num_tx_ext_desc_pool(struct wlan_cfg_dp_soc_ctxt *cfg, int num_pool)
558 {
559 	cfg->num_tx_ext_desc_pool = num_pool;
560 }
561 
562 int wlan_cfg_get_reo_dst_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
563 {
564 	return cfg->reo_dst_ring_size;
565 }
566 
567 void wlan_cfg_set_reo_dst_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg,
568 				    int reo_dst_ring_size)
569 {
570 	cfg->reo_dst_ring_size = reo_dst_ring_size;
571 }
572 
573 void wlan_cfg_set_raw_mode_war(struct wlan_cfg_dp_soc_ctxt *cfg,
574 			       bool raw_mode_war)
575 {
576 	cfg->raw_mode_war = raw_mode_war;
577 }
578 
579 bool wlan_cfg_get_raw_mode_war(struct wlan_cfg_dp_soc_ctxt *cfg)
580 {
581 	return cfg->raw_mode_war;
582 }
583 
584 int wlan_cfg_get_num_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
585 {
586 	return cfg->num_tx_desc;
587 }
588 
589 void wlan_cfg_set_num_tx_desc(struct wlan_cfg_dp_soc_ctxt *cfg, int num_desc)
590 {
591 	cfg->num_tx_desc = num_desc;
592 }
593 
594 int wlan_cfg_get_num_tx_ext_desc(struct wlan_cfg_dp_soc_ctxt *cfg)
595 {
596 	return cfg->num_tx_ext_desc;
597 }
598 
599 void wlan_cfg_set_num_tx_ext_desc(struct wlan_cfg_dp_soc_ctxt *cfg, int num_ext_desc)
600 {
601 	cfg->num_tx_ext_desc = num_ext_desc;
602 }
603 
604 uint32_t wlan_cfg_max_peer_id(struct wlan_cfg_dp_soc_ctxt *cfg)
605 {
606 	/* TODO: This should be calculated based on target capabilities */
607 	return cfg->max_peer_id;
608 }
609 
610 int wlan_cfg_get_dma_mon_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
611 {
612 	return  cfg->dma_mon_buf_ring_size;
613 }
614 
615 int wlan_cfg_get_dma_mon_dest_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
616 {
617 	return  cfg->dma_mon_dest_ring_size;
618 }
619 
620 int wlan_cfg_get_dma_mon_stat_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
621 {
622 	return  cfg->dma_mon_status_ring_size;
623 }
624 
625 int
626 wlan_cfg_get_dma_mon_desc_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
627 {
628 	return cfg->rxdma_monitor_desc_ring;
629 }
630 
631 int wlan_cfg_get_rx_dma_buf_ring_size(struct wlan_cfg_dp_pdev_ctxt *cfg)
632 {
633 	return  cfg->rx_dma_buf_ring_size;
634 }
635 
636 int wlan_cfg_get_num_mac_rings(struct wlan_cfg_dp_pdev_ctxt *cfg)
637 {
638 	return  cfg->num_mac_rings;
639 }
640 
641 bool wlan_cfg_is_lro_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
642 {
643 	return  cfg->lro_enabled;
644 }
645 
646 void wlan_cfg_set_rx_hash(struct wlan_cfg_dp_soc_ctxt *cfg, bool val)
647 {
648 	cfg->rx_hash = val;
649 }
650 
651 bool wlan_cfg_is_rx_hash_enabled(struct wlan_cfg_dp_soc_ctxt *cfg)
652 {
653 	return  cfg->rx_hash;
654 }
655 
656 int wlan_cfg_get_dp_pdev_nss_enabled(struct wlan_cfg_dp_pdev_ctxt *cfg)
657 {
658 	return  cfg->nss_enabled;
659 }
660 
661 void wlan_cfg_set_dp_pdev_nss_enabled(struct wlan_cfg_dp_pdev_ctxt *cfg, int nss_enabled)
662 {
663 	cfg->nss_enabled = nss_enabled;
664 }
665 
666 int wlan_cfg_get_dp_soc_nss_cfg(struct wlan_cfg_dp_soc_ctxt *cfg)
667 {
668 	return  cfg->nss_cfg;
669 }
670 
671 void wlan_cfg_set_dp_soc_nss_cfg(struct wlan_cfg_dp_soc_ctxt *cfg, int nss_cfg)
672 {
673 	cfg->nss_cfg = nss_cfg;
674 	if (cfg->nss_cfg)
675 		cfg->tx_comp_ring_size = cfg->tx_comp_ring_size_nss;
676 }
677 
678 int wlan_cfg_get_int_batch_threshold_tx(struct wlan_cfg_dp_soc_ctxt *cfg)
679 {
680 	return cfg->int_batch_threshold_tx;
681 }
682 
683 int wlan_cfg_get_int_timer_threshold_tx(struct wlan_cfg_dp_soc_ctxt *cfg)
684 {
685 	return cfg->int_timer_threshold_tx;
686 }
687 
688 int wlan_cfg_get_int_batch_threshold_rx(struct wlan_cfg_dp_soc_ctxt *cfg)
689 {
690 	return cfg->int_batch_threshold_rx;
691 }
692 
693 int wlan_cfg_get_int_timer_threshold_rx(struct wlan_cfg_dp_soc_ctxt *cfg)
694 {
695 	return cfg->int_timer_threshold_rx;
696 }
697 
698 int wlan_cfg_get_int_batch_threshold_other(struct wlan_cfg_dp_soc_ctxt *cfg)
699 {
700 	return cfg->int_batch_threshold_other;
701 }
702 
703 int wlan_cfg_get_int_timer_threshold_other(struct wlan_cfg_dp_soc_ctxt *cfg)
704 {
705 	return cfg->int_timer_threshold_other;
706 }
707 
708 int wlan_cfg_get_checksum_offload(struct wlan_cfg_dp_soc_ctxt *cfg)
709 {
710 	return cfg->tcp_udp_checksumoffload;
711 }
712 
713 int wlan_cfg_get_rx_defrag_min_timeout(struct wlan_cfg_dp_soc_ctxt *cfg)
714 {
715 	return cfg->rx_defrag_min_timeout;
716 }
717 
718 int wlan_cfg_get_defrag_timeout_check(struct wlan_cfg_dp_soc_ctxt *cfg)
719 {
720 	return cfg->defrag_timeout_check;
721 }
722 
723 int
724 wlan_cfg_get_dp_soc_wbm_release_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
725 {
726 	return cfg->wbm_release_ring;
727 }
728 
729 int
730 wlan_cfg_get_dp_soc_tcl_cmd_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
731 {
732 	return cfg->tcl_cmd_ring;
733 }
734 
735 int
736 wlan_cfg_get_dp_soc_tcl_status_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
737 {
738 	return cfg->tcl_status_ring;
739 }
740 
741 int
742 wlan_cfg_get_dp_soc_reo_reinject_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
743 {
744 	return cfg->reo_reinject_ring;
745 }
746 
747 int
748 wlan_cfg_get_dp_soc_rx_release_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
749 {
750 	return cfg->rx_release_ring;
751 }
752 
753 int
754 wlan_cfg_get_dp_soc_reo_exception_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
755 {
756 	return cfg->reo_exception_ring;
757 }
758 
759 int
760 wlan_cfg_get_dp_soc_reo_cmd_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
761 {
762 	return cfg->reo_cmd_ring;
763 }
764 
765 int
766 wlan_cfg_get_dp_soc_reo_status_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
767 {
768 	return cfg->reo_status_ring;
769 }
770 
771 int
772 wlan_cfg_get_dp_soc_rxdma_refill_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
773 {
774 	return cfg->rxdma_refill_ring;
775 }
776 
777 int
778 wlan_cfg_get_dp_soc_rxdma_err_dst_ring_size(struct wlan_cfg_dp_soc_ctxt *cfg)
779 {
780 	return cfg->rxdma_err_dst_ring;
781 }
782 
783 #ifdef QCA_LL_TX_FLOW_CONTROL_V2
784 /**
785  * wlan_cfg_get_tx_flow_stop_queue_th() - Get flow control stop threshold
786  * @cfg: config context
787  *
788  * Return: stop threshold
789  */
790 int wlan_cfg_get_tx_flow_stop_queue_th(struct wlan_cfg_dp_soc_ctxt *cfg)
791 {
792 	return cfg->tx_flow_stop_queue_threshold;
793 }
794 
795 /**
796  * wlan_cfg_get_tx_flow_start_queue_offset() - Get flow control start offset
797  *					for TX to resume
798  * @cfg: config context
799  *
800  * Return: stop threshold
801  */
802 int wlan_cfg_get_tx_flow_start_queue_offset(struct wlan_cfg_dp_soc_ctxt *cfg)
803 {
804 	return cfg->tx_flow_start_queue_offset;
805 }
806 #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
807