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