xref: /wlan-dirver/qca-wifi-host-cmn/target_if/cfr/src/target_if_cfr.c (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
1 /*
2  * Copyright (c) 2019-2020 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 #include <target_if_cfr.h>
20 #include <wlan_tgt_def_config.h>
21 #include <target_type.h>
22 #include <hif_hw_version.h>
23 #include <target_if.h>
24 #include <wlan_lmac_if_def.h>
25 #include <wlan_osif_priv.h>
26 #include <init_deinit_lmac.h>
27 #include <wlan_cfr_utils_api.h>
28 #include <wlan_objmgr_pdev_obj.h>
29 #include <target_if_cfr_enh.h>
30 #ifdef CFR_USE_FIXED_FOLDER
31 #include "target_if_cfr_6490.h"
32 #include "target_if_cfr_adrastea.h"
33 #include "wlan_reg_services_api.h"
34 #else
35 #include <target_if_cfr_8074v2.h>
36 #endif
37 
38 int target_if_cfr_stop_capture(struct wlan_objmgr_pdev *pdev,
39 			       struct wlan_objmgr_peer *peer)
40 {
41 	struct peer_cfr *pe;
42 	struct peer_cfr_params param = {0};
43 	struct wmi_unified *pdev_wmi_handle = NULL;
44 	struct wlan_objmgr_vdev *vdev = {0};
45 	struct pdev_cfr *pdev_cfrobj;
46 	int retv = 0;
47 
48 	pe = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_UMAC_COMP_CFR);
49 	if (pe == NULL)
50 		return -EINVAL;
51 
52 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
53 	if (!pdev_wmi_handle) {
54 		cfr_err("pdev wmi handle NULL");
55 		return -EINVAL;
56 	}
57 	vdev = wlan_peer_get_vdev(peer);
58 
59 	qdf_mem_set(&param, sizeof(param), 0);
60 
61 	param.request = PEER_CFR_CAPTURE_DISABLE;
62 	param.macaddr = wlan_peer_get_macaddr(peer);
63 	param.vdev_id = wlan_vdev_get_id(vdev);
64 
65 	param.periodicity = pe->period;
66 	param.bandwidth = pe->bandwidth;
67 	param.capture_method = pe->capture_method;
68 
69 	retv = wmi_unified_send_peer_cfr_capture_cmd(pdev_wmi_handle, &param);
70 
71 	pdev_cfrobj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
72 							    WLAN_UMAC_COMP_CFR);
73 	if (!pdev_cfrobj) {
74 		cfr_err("pdev object for CFR is null");
75 		return -EINVAL;
76 	}
77 	cfr_err("CFR capture stats for this capture:");
78 	cfr_err("DBR event count = %llu, Tx event count = %llu "
79 		"Release count = %llu",
80 		pdev_cfrobj->dbr_evt_cnt, pdev_cfrobj->tx_evt_cnt,
81 		pdev_cfrobj->release_cnt);
82 	cfr_err("tx_peer_status_cfr_fail = %llu",
83 		pdev_cfrobj->tx_peer_status_cfr_fail = 0);
84 	cfr_err("tx_evt_status_cfr_fail = %llu",
85 		pdev_cfrobj->tx_evt_status_cfr_fail);
86 	cfr_err("tx_dbr_cookie_lookup_fail = %llu",
87 		pdev_cfrobj->tx_dbr_cookie_lookup_fail);
88 
89 	pdev_cfrobj->dbr_evt_cnt = 0;
90 	pdev_cfrobj->tx_evt_cnt  = 0;
91 	pdev_cfrobj->release_cnt = 0;
92 	pdev_cfrobj->tx_peer_status_cfr_fail = 0;
93 	pdev_cfrobj->tx_evt_status_cfr_fail = 0;
94 	pdev_cfrobj->tx_dbr_cookie_lookup_fail = 0;
95 
96 	return retv;
97 }
98 
99 int target_if_cfr_start_capture(struct wlan_objmgr_pdev *pdev,
100 				struct wlan_objmgr_peer *peer,
101 				struct cfr_capture_params *cfr_params)
102 {
103 	struct peer_cfr_params param = {0};
104 	struct wmi_unified *pdev_wmi_handle = NULL;
105 	struct wlan_objmgr_vdev *vdev;
106 	int retv = 0;
107 
108 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
109 	if (!pdev_wmi_handle) {
110 		cfr_err("pdev wmi handle NULL");
111 		return -EINVAL;
112 	}
113 	vdev = wlan_peer_get_vdev(peer);
114 	qdf_mem_set(&param, sizeof(param), 0);
115 
116 	param.request = PEER_CFR_CAPTURE_ENABLE;
117 	param.macaddr = wlan_peer_get_macaddr(peer);
118 	param.vdev_id = wlan_vdev_get_id(vdev);
119 
120 	param.periodicity = cfr_params->period;
121 	param.bandwidth = cfr_params->bandwidth;
122 	param.capture_method = cfr_params->method;
123 
124 	retv = wmi_unified_send_peer_cfr_capture_cmd(pdev_wmi_handle, &param);
125 	return retv;
126 }
127 
128 int target_if_cfr_pdev_set_param(struct wlan_objmgr_pdev *pdev,
129 				 uint32_t param_id, uint32_t param_value)
130 {
131 	struct pdev_params pparam;
132 	uint32_t pdev_id;
133 	struct wmi_unified *pdev_wmi_handle = NULL;
134 
135 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
136 	if (pdev_id < 0)
137 		return -EINVAL;
138 
139 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
140 	if (!pdev_wmi_handle) {
141 		cfr_err("pdev wmi handle NULL");
142 		return -EINVAL;
143 	}
144 	qdf_mem_set(&pparam, sizeof(pparam), 0);
145 	pparam.param_id = param_id;
146 	pparam.param_value = param_value;
147 
148 	return wmi_unified_pdev_param_send(pdev_wmi_handle,
149 					   &pparam, pdev_id);
150 }
151 
152 int target_if_cfr_enable_cfr_timer(struct wlan_objmgr_pdev *pdev,
153 				   uint32_t cfr_timer)
154 {
155 	struct pdev_cfr *pa;
156 	int retval;
157 
158 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
159 	if (pa == NULL)
160 		return QDF_STATUS_E_FAILURE;
161 
162 	if (!cfr_timer) {
163 	     /* disable periodic cfr capture */
164 		retval =
165 	target_if_cfr_pdev_set_param(pdev,
166 				     wmi_pdev_param_per_peer_prd_cfr_enable,
167 				     WMI_HOST_PEER_CFR_TIMER_DISABLE);
168 
169 		if (retval == QDF_STATUS_SUCCESS)
170 			pa->cfr_timer_enable = 0;
171 	} else {
172 	    /* enable periodic cfr capture (default base timer is 10ms ) */
173 		retval =
174 	target_if_cfr_pdev_set_param(pdev,
175 				     wmi_pdev_param_per_peer_prd_cfr_enable,
176 				     WMI_HOST_PEER_CFR_TIMER_ENABLE);
177 
178 		if (retval == QDF_STATUS_SUCCESS)
179 			pa->cfr_timer_enable = 1;
180 	}
181 
182 	return retval;
183 }
184 
185 int target_if_cfr_get_target_type(struct wlan_objmgr_psoc *psoc)
186 {
187 	uint32_t target_type = 0;
188 	struct wlan_lmac_if_target_tx_ops *target_type_tx_ops;
189 	struct wlan_lmac_if_tx_ops *tx_ops;
190 
191 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
192 	if (!tx_ops) {
193 		cfr_err("tx_ops is NULL");
194 		return target_type;
195 	}
196 	target_type_tx_ops = &tx_ops->target_tx_ops;
197 
198 	if (target_type_tx_ops->tgt_get_tgt_type)
199 		target_type = target_type_tx_ops->tgt_get_tgt_type(psoc);
200 
201 	return target_type;
202 }
203 
204 #ifdef CFR_USE_FIXED_FOLDER
205 static QDF_STATUS target_if_cfr_init_target(struct wlan_objmgr_psoc *psoc,
206 					    struct wlan_objmgr_pdev *pdev,
207 					    uint32_t target)
208 {
209 	struct pdev_cfr *cfr_pdev;
210 	struct psoc_cfr *cfr_psoc;
211 	struct wmi_unified *wmi_handle = NULL;
212 	bool cfr_capable;
213 	QDF_STATUS status;
214 
215 	if (!psoc || !pdev) {
216 		cfr_err("null pdev or psoc");
217 		return QDF_STATUS_E_FAILURE;
218 	}
219 
220 	cfr_pdev = wlan_objmgr_pdev_get_comp_private_obj(pdev,
221 							 WLAN_UMAC_COMP_CFR);
222 	if (!cfr_pdev) {
223 		cfr_err("null pdev cfr");
224 		return QDF_STATUS_E_FAILURE;
225 	}
226 
227 	cfr_psoc = wlan_objmgr_psoc_get_comp_private_obj(psoc,
228 							 WLAN_UMAC_COMP_CFR);
229 
230 	if (!cfr_psoc) {
231 		cfr_err("null psoc cfr");
232 		return QDF_STATUS_E_FAILURE;
233 	}
234 
235 	wmi_handle = lmac_get_pdev_wmi_handle(pdev);
236 	if (!wmi_handle) {
237 		cfr_err("null wmi handle");
238 		return QDF_STATUS_E_FAILURE;
239 	}
240 
241 	if (wlan_cfr_is_feature_disabled(pdev)) {
242 		cfr_pdev->is_cfr_capable = 0;
243 		cfr_psoc->is_cfr_capable = 0;
244 		cfr_info("cfr disabled");
245 		return QDF_STATUS_SUCCESS;
246 	}
247 
248 	cfr_capable = wmi_service_enabled(wmi_handle,
249 					  wmi_service_cfr_capture_support);
250 	cfr_pdev->is_cfr_capable = cfr_capable;
251 	cfr_psoc->is_cfr_capable = cfr_capable;
252 	if (!cfr_capable) {
253 		cfr_err("FW doesn't support CFR");
254 		return QDF_STATUS_SUCCESS;
255 	}
256 
257 	status = cfr_enh_init_pdev(psoc, pdev);
258 	if (target == TARGET_TYPE_QCA6490)
259 		cfr_pdev->chip_type = CFR_CAPTURE_RADIO_HSP;
260 	else if (target == TARGET_TYPE_QCA6750)
261 		cfr_pdev->chip_type = CFR_CAPTURE_RADIO_MOSELLE;
262 
263 	return status;
264 }
265 
266 static QDF_STATUS target_if_cfr_deinit_target(struct wlan_objmgr_psoc *psoc,
267 					      struct wlan_objmgr_pdev *pdev)
268 {
269 	struct pdev_cfr *pcfr;
270 
271 	if (!psoc || !pdev) {
272 		cfr_err("null pdev or psoc");
273 		return QDF_STATUS_E_FAILURE;
274 	}
275 
276 	pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev,
277 						     WLAN_UMAC_COMP_CFR);
278 	if (!pcfr) {
279 		cfr_err("null pdev cfr");
280 		return QDF_STATUS_E_FAILURE;
281 	}
282 
283 	if (!pcfr->is_cfr_capable) {
284 		cfr_info("cfr disabled or FW not support");
285 		return QDF_STATUS_SUCCESS;
286 	}
287 
288 	return cfr_enh_deinit_pdev(psoc, pdev);
289 }
290 
291 QDF_STATUS
292 target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc,
293 			struct wlan_objmgr_pdev *pdev)
294 {
295 	uint32_t target_type;
296 	QDF_STATUS status;
297 
298 	target_type = target_if_cfr_get_target_type(psoc);
299 
300 	if (target_type == TARGET_TYPE_QCA6490 ||
301 	    target_type == TARGET_TYPE_QCA6750) {
302 		status = target_if_cfr_init_target(psoc,
303 						   pdev, target_type);
304 	} else if (target_type == TARGET_TYPE_ADRASTEA) {
305 		status = cfr_adrastea_init_pdev(psoc, pdev);
306 	} else {
307 		cfr_info("unsupport chip");
308 		status = QDF_STATUS_SUCCESS;
309 	}
310 
311 	return status;
312 }
313 
314 QDF_STATUS
315 target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc,
316 			  struct wlan_objmgr_pdev *pdev)
317 {
318 	uint32_t target_type;
319 	QDF_STATUS status;
320 
321 	target_type = target_if_cfr_get_target_type(psoc);
322 
323 	if (target_type == TARGET_TYPE_QCA6490 ||
324 	    target_type == TARGET_TYPE_QCA6750) {
325 		status = target_if_cfr_deinit_target(psoc, pdev);
326 	} else if (target_type == TARGET_TYPE_ADRASTEA) {
327 		status = cfr_adrastea_deinit_pdev(psoc, pdev);
328 	} else {
329 		cfr_info("unsupport chip");
330 		status = QDF_STATUS_SUCCESS;
331 	}
332 
333 	return status;
334 }
335 #else
336 QDF_STATUS
337 target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc,
338 			struct wlan_objmgr_pdev *pdev)
339 {
340 	uint32_t target_type;
341 	struct pdev_cfr *pa;
342 	struct psoc_cfr *cfr_sc;
343 
344 	if (wlan_cfr_is_feature_disabled(pdev)) {
345 		cfr_err("cfr is disabled");
346 		return QDF_STATUS_E_NOSUPPORT;
347 	}
348 
349 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
350 	if (pa == NULL)
351 		return QDF_STATUS_E_FAILURE;
352 
353 	/* Reset unassociated entries for every init */
354 	qdf_mem_zero(&pa->unassoc_pool[0], MAX_CFR_ENABLED_CLIENTS *
355 		     sizeof(struct unassoc_pool_entry));
356 
357 	cfr_sc = wlan_objmgr_psoc_get_comp_private_obj(psoc,
358 						       WLAN_UMAC_COMP_CFR);
359 
360 	if (cfr_sc == NULL)
361 		return QDF_STATUS_E_FAILURE;
362 
363 	target_type = target_if_cfr_get_target_type(psoc);
364 
365 	if (target_type == TARGET_TYPE_QCA8074V2) {
366 		pa->is_cfr_capable = cfr_sc->is_cfr_capable;
367 		return cfr_8074v2_init_pdev(psoc, pdev);
368 	} else if ((target_type == TARGET_TYPE_IPQ4019) ||
369 		   (target_type == TARGET_TYPE_QCA9984) ||
370 		   (target_type == TARGET_TYPE_QCA9888)) {
371 
372 		pa->is_cfr_capable = cfr_sc->is_cfr_capable;
373 
374 		return cfr_wifi2_0_init_pdev(psoc, pdev);
375 	} else if ((target_type == TARGET_TYPE_QCA6018) ||
376 		   (target_type == TARGET_TYPE_QCN9000) ||
377 		   (target_type == TARGET_TYPE_QCN9100) ||
378 		   (target_type == TARGET_TYPE_QCA5018)) {
379 		pa->is_cfr_capable = cfr_sc->is_cfr_capable;
380 		return cfr_enh_init_pdev(psoc, pdev);
381 	} else
382 		return QDF_STATUS_E_NOSUPPORT;
383 }
384 
385 QDF_STATUS
386 target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc,
387 			  struct wlan_objmgr_pdev *pdev)
388 {
389 	uint32_t target_type;
390 
391 	if (wlan_cfr_is_feature_disabled(pdev)) {
392 		cfr_err("cfr is disabled");
393 		return QDF_STATUS_E_NOSUPPORT;
394 	}
395 
396 	target_type = target_if_cfr_get_target_type(psoc);
397 
398 	if (target_type == TARGET_TYPE_QCA8074V2) {
399 		return cfr_8074v2_deinit_pdev(psoc, pdev);
400 	} else if ((target_type == TARGET_TYPE_IPQ4019) ||
401 		   (target_type == TARGET_TYPE_QCA9984) ||
402 		   (target_type == TARGET_TYPE_QCA9888)) {
403 
404 		return cfr_wifi2_0_deinit_pdev(psoc, pdev);
405 	} else if ((target_type == TARGET_TYPE_QCA6018) ||
406 		   (target_type == TARGET_TYPE_QCN9000) ||
407 		   (target_type == TARGET_TYPE_QCN9100) ||
408 		   (target_type == TARGET_TYPE_QCA5018)) {
409 		return cfr_enh_deinit_pdev(psoc, pdev);
410 	} else
411 		return QDF_STATUS_E_NOSUPPORT;
412 }
413 #endif
414 
415 #ifdef WLAN_ENH_CFR_ENABLE
416 #ifdef QCA_WIFI_QCA6490
417 static uint8_t target_if_cfr_get_mac_id(struct wlan_objmgr_pdev *pdev)
418 {
419 	struct wlan_objmgr_vdev *vdev;
420 	struct wlan_channel *bss_chan;
421 	struct pdev_cfr *pcfr;
422 	uint8_t mac_id = 0;
423 
424 	if (!pdev) {
425 		cfr_err("null pdev");
426 		return mac_id;
427 	}
428 
429 	mac_id = wlan_objmgr_pdev_get_pdev_id(pdev);
430 	pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
431 	if (!pcfr)  {
432 		cfr_err("null pcfr");
433 		return mac_id;
434 	}
435 
436 	if (pcfr->rcc_param.vdev_id == CFR_INVALID_VDEV_ID)
437 		return mac_id;
438 
439 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev,
440 						    pcfr->rcc_param.vdev_id,
441 						    WLAN_CFR_ID);
442 	if (!vdev) {
443 		cfr_err("null vdev");
444 		return mac_id;
445 	}
446 
447 	bss_chan = wlan_vdev_mlme_get_bss_chan(vdev);
448 	if (!bss_chan) {
449 		cfr_info("null bss chan");
450 		wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
451 		return mac_id;
452 	}
453 
454 	cfr_debug("bss freq %d", bss_chan->ch_freq);
455 	if (wlan_reg_is_24ghz_ch_freq(bss_chan->ch_freq))
456 		mac_id = CFR_MAC_ID_24G;
457 	else
458 		mac_id = CFR_MAC_ID_5G;
459 
460 	pcfr->rcc_param.srng_id = mac_id;
461 	wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
462 
463 	return mac_id;
464 }
465 
466 static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev)
467 {
468 	return target_if_cfr_get_mac_id(pdev);
469 }
470 #else
471 static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev)
472 {
473 	return wlan_objmgr_pdev_get_pdev_id(pdev);
474 }
475 #endif /* QCA_WIFI_QCA6490 */
476 
477 QDF_STATUS target_if_cfr_config_rcc(struct wlan_objmgr_pdev *pdev,
478 				    struct cfr_rcc_param *rcc_info)
479 {
480 	QDF_STATUS status;
481 	struct wmi_unified *pdev_wmi_handle = NULL;
482 
483 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
484 	if (!pdev_wmi_handle) {
485 		cfr_err("pdev_wmi_handle is null");
486 		return QDF_STATUS_E_NULL_VALUE;
487 	}
488 
489 	rcc_info->pdev_id = target_if_cfr_get_pdev_id(pdev);
490 	rcc_info->num_grp_tlvs =
491 		count_set_bits(rcc_info->modified_in_curr_session);
492 
493 	status = wmi_unified_send_cfr_rcc_cmd(pdev_wmi_handle, rcc_info);
494 	return status;
495 }
496 
497 void target_if_cfr_default_ta_ra_config(struct cfr_rcc_param *rcc_info,
498 					bool allvalid, uint16_t reset_cfg)
499 {
500 	struct ta_ra_cfr_cfg *curr_cfg = NULL;
501 	int grp_id;
502 	unsigned long bitmap = reset_cfg;
503 	uint8_t def_mac[QDF_MAC_ADDR_SIZE] = {0xFF, 0xFF, 0xFF,
504 		0xFF, 0xFF, 0xFF};
505 	uint8_t null_mac[QDF_MAC_ADDR_SIZE] = {0x00, 0x00, 0x00,
506 		0x00, 0x00, 0x00};
507 
508 	for (grp_id = 0; grp_id < MAX_TA_RA_ENTRIES; grp_id++) {
509 		if (qdf_test_bit(grp_id, &bitmap)) {
510 			curr_cfg = &rcc_info->curr[grp_id];
511 			qdf_mem_copy(curr_cfg->tx_addr,
512 				     null_mac, QDF_MAC_ADDR_SIZE);
513 			qdf_mem_copy(curr_cfg->tx_addr_mask,
514 				     def_mac, QDF_MAC_ADDR_SIZE);
515 			qdf_mem_copy(curr_cfg->rx_addr,
516 				     null_mac, QDF_MAC_ADDR_SIZE);
517 			qdf_mem_copy(curr_cfg->rx_addr_mask,
518 				     def_mac, QDF_MAC_ADDR_SIZE);
519 			curr_cfg->bw = 0xf;
520 			curr_cfg->nss = 0xff;
521 			curr_cfg->mgmt_subtype_filter = 0;
522 			curr_cfg->ctrl_subtype_filter = 0;
523 			curr_cfg->data_subtype_filter = 0;
524 			if (!allvalid) {
525 				curr_cfg->valid_ta = 0;
526 				curr_cfg->valid_ta_mask = 0;
527 				curr_cfg->valid_ra = 0;
528 				curr_cfg->valid_ra_mask = 0;
529 				curr_cfg->valid_bw_mask = 0;
530 				curr_cfg->valid_nss_mask = 0;
531 				curr_cfg->valid_mgmt_subtype = 0;
532 				curr_cfg->valid_ctrl_subtype = 0;
533 				curr_cfg->valid_data_subtype = 0;
534 			} else {
535 				curr_cfg->valid_ta = 1;
536 				curr_cfg->valid_ta_mask = 1;
537 				curr_cfg->valid_ra = 1;
538 				curr_cfg->valid_ra_mask = 1;
539 				curr_cfg->valid_bw_mask = 1;
540 				curr_cfg->valid_nss_mask = 1;
541 				curr_cfg->valid_mgmt_subtype = 1;
542 				curr_cfg->valid_ctrl_subtype = 1;
543 				curr_cfg->valid_data_subtype = 1;
544 			}
545 		}
546 	}
547 }
548 #endif
549 
550 #ifdef WLAN_ENH_CFR_ENABLE
551 #ifdef CFR_USE_FIXED_FOLDER
552 static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops)
553 {
554 	tx_ops->cfr_tx_ops.cfr_subscribe_ppdu_desc =
555 				target_if_cfr_subscribe_ppdu_desc;
556 }
557 #else
558 static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops)
559 {
560 }
561 #endif /* CFR_USE_FIXED_FOLDER */
562 static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
563 {
564 	tx_ops->cfr_tx_ops.cfr_config_rcc =
565 		target_if_cfr_config_rcc;
566 	tx_ops->cfr_tx_ops.cfr_start_lut_timer =
567 		target_if_cfr_start_lut_age_timer;
568 	tx_ops->cfr_tx_ops.cfr_stop_lut_timer =
569 		target_if_cfr_stop_lut_age_timer;
570 	tx_ops->cfr_tx_ops.cfr_default_ta_ra_cfg =
571 		target_if_cfr_default_ta_ra_config;
572 	tx_ops->cfr_tx_ops.cfr_dump_lut_enh =
573 		target_if_cfr_dump_lut_enh;
574 	tx_ops->cfr_tx_ops.cfr_rx_tlv_process =
575 		target_if_cfr_rx_tlv_process;
576 	tx_ops->cfr_tx_ops.cfr_update_global_cfg =
577 		target_if_cfr_update_global_cfg;
578 	target_if_enh_cfr_add_ops(tx_ops);
579 }
580 #else
581 static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
582 {
583 }
584 #endif
585 
586 void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
587 {
588 	tx_ops->cfr_tx_ops.cfr_init_pdev =
589 		target_if_cfr_init_pdev;
590 	tx_ops->cfr_tx_ops.cfr_deinit_pdev =
591 		target_if_cfr_deinit_pdev;
592 	tx_ops->cfr_tx_ops.cfr_enable_cfr_timer =
593 		target_if_cfr_enable_cfr_timer;
594 	tx_ops->cfr_tx_ops.cfr_start_capture =
595 		target_if_cfr_start_capture;
596 	tx_ops->cfr_tx_ops.cfr_stop_capture =
597 		target_if_cfr_stop_capture;
598 	target_if_enh_cfr_tx_ops(tx_ops);
599 }
600 
601 void target_if_cfr_set_cfr_support(struct wlan_objmgr_psoc *psoc,
602 				   uint8_t value)
603 {
604 	struct wlan_lmac_if_rx_ops *rx_ops;
605 
606 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
607 	if (!rx_ops) {
608 		cfr_err("rx_ops is NULL");
609 		return;
610 	}
611 	if (rx_ops->cfr_rx_ops.cfr_support_set)
612 		rx_ops->cfr_rx_ops.cfr_support_set(psoc, value);
613 }
614 
615 QDF_STATUS
616 target_if_cfr_set_capture_count_support(struct wlan_objmgr_psoc *psoc,
617 					uint8_t value)
618 {
619 	struct wlan_lmac_if_rx_ops *rx_ops;
620 
621 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
622 	if (!rx_ops) {
623 		cfr_err("rx_ops is NULL");
624 		return QDF_STATUS_E_INVAL;
625 	}
626 
627 	if (rx_ops->cfr_rx_ops.cfr_capture_count_support_set)
628 		return rx_ops->cfr_rx_ops.cfr_capture_count_support_set(
629 						psoc, value);
630 
631 	return QDF_STATUS_E_INVAL;
632 }
633 
634 QDF_STATUS
635 target_if_cfr_set_mo_marking_support(struct wlan_objmgr_psoc *psoc,
636 				     uint8_t value)
637 {
638 	struct wlan_lmac_if_rx_ops *rx_ops;
639 
640 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
641 	if (!rx_ops) {
642 		cfr_err("rx_ops is NULL");
643 		return QDF_STATUS_E_INVAL;
644 	}
645 
646 	if (rx_ops->cfr_rx_ops.cfr_mo_marking_support_set)
647 		return rx_ops->cfr_rx_ops.cfr_mo_marking_support_set(
648 						psoc, value);
649 
650 	return QDF_STATUS_E_INVAL;
651 }
652 
653 void target_if_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head,
654 			     size_t hlen, void *data, size_t dlen, void *tail,
655 			     size_t tlen)
656 {
657 	struct wlan_objmgr_psoc *psoc;
658 	struct wlan_lmac_if_rx_ops *rx_ops;
659 
660 	psoc = wlan_pdev_get_psoc(pdev);
661 
662 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
663 	if (!rx_ops) {
664 		cfr_err("rx_ops is NULL");
665 		return;
666 	}
667 	if (rx_ops->cfr_rx_ops.cfr_info_send)
668 		rx_ops->cfr_rx_ops.cfr_info_send(pdev, head, hlen, data, dlen,
669 						 tail, tlen);
670 }
671