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