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