xref: /wlan-dirver/qca-wifi-host-cmn/target_if/cfr/src/target_if_cfr.c (revision 5611ef508114526caa3c58ffe2e188650c7b53d1)
1 /*
2  * Copyright (c) 2019-2021 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_dbr.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 #ifdef ENABLE_HOST_TO_TARGET_CONVERSION
129 int target_if_cfr_periodic_peer_cfr_enable(struct wlan_objmgr_pdev *pdev,
130 					   uint32_t param_value)
131 {
132 	struct pdev_params pparam;
133 	uint32_t pdev_id;
134 	struct wmi_unified *pdev_wmi_handle = NULL;
135 
136 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
137 	if (pdev_id < 0)
138 		return -EINVAL;
139 
140 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
141 	if (!pdev_wmi_handle) {
142 		cfr_err("pdev wmi handle NULL");
143 		return -EINVAL;
144 	}
145 	qdf_mem_set(&pparam, sizeof(pparam), 0);
146 	pparam.param_id = wmi_pdev_param_per_peer_prd_cfr_enable;
147 	pparam.param_value = param_value;
148 
149 	return wmi_unified_pdev_param_send(pdev_wmi_handle,
150 					   &pparam, pdev_id);
151 }
152 #else
153 int target_if_cfr_periodic_peer_cfr_enable(struct wlan_objmgr_pdev *pdev,
154 					   uint32_t param_value)
155 {
156 	struct pdev_params pparam;
157 	uint32_t pdev_id;
158 	struct wmi_unified *pdev_wmi_handle = NULL;
159 
160 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
161 	if (pdev_id < 0)
162 		return -EINVAL;
163 
164 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
165 	if (!pdev_wmi_handle) {
166 		cfr_err("pdev wmi handle NULL");
167 		return -EINVAL;
168 	}
169 	qdf_mem_set(&pparam, sizeof(pparam), 0);
170 	pparam.param_id = WMI_PDEV_PARAM_PER_PEER_PERIODIC_CFR_ENABLE;
171 	pparam.param_value = param_value;
172 
173 	return wmi_unified_pdev_param_send(pdev_wmi_handle,
174 					   &pparam, pdev_id);
175 }
176 #endif
177 
178 int target_if_cfr_enable_cfr_timer(struct wlan_objmgr_pdev *pdev,
179 				   uint32_t cfr_timer)
180 {
181 	struct pdev_cfr *pa;
182 	int retval;
183 
184 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
185 	if (pa == NULL)
186 		return QDF_STATUS_E_FAILURE;
187 
188 	if (!cfr_timer) {
189 	     /* disable periodic cfr capture */
190 		retval =
191 	target_if_cfr_periodic_peer_cfr_enable(pdev,
192 					       WMI_HOST_PEER_CFR_TIMER_DISABLE);
193 
194 		if (retval == QDF_STATUS_SUCCESS)
195 			pa->cfr_timer_enable = 0;
196 	} else {
197 	    /* enable periodic cfr capture (default base timer is 10ms ) */
198 		retval =
199 	target_if_cfr_periodic_peer_cfr_enable(pdev,
200 					       WMI_HOST_PEER_CFR_TIMER_ENABLE);
201 
202 		if (retval == QDF_STATUS_SUCCESS)
203 			pa->cfr_timer_enable = 1;
204 	}
205 
206 	return retval;
207 }
208 
209 int target_if_cfr_get_target_type(struct wlan_objmgr_psoc *psoc)
210 {
211 	uint32_t target_type = 0;
212 	struct wlan_lmac_if_target_tx_ops *target_type_tx_ops;
213 	struct wlan_lmac_if_tx_ops *tx_ops;
214 
215 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
216 	if (!tx_ops) {
217 		cfr_err("tx_ops is NULL");
218 		return target_type;
219 	}
220 	target_type_tx_ops = &tx_ops->target_tx_ops;
221 
222 	if (target_type_tx_ops->tgt_get_tgt_type)
223 		target_type = target_type_tx_ops->tgt_get_tgt_type(psoc);
224 
225 	return target_type;
226 }
227 
228 void target_if_cfr_fill_header(struct csi_cfr_header *hdr,
229 			       bool is_wifi_2_0,
230 			       uint32_t target_type,
231 			       bool is_rcc)
232 {
233 	hdr->cmn.start_magic_num = 0xDEADBEAF;
234 	hdr->cmn.vendorid = 0x8cfdf0;
235 	hdr->cmn.pltform_type = CFR_PLATFORM_TYPE_ARM;
236 	hdr->cmn.cfr_metadata_len = CFR_META_DATA_LEN;
237 	hdr->cmn.cfr_data_version = CFR_DATA_VERSION_1;
238 
239 	if (is_wifi_2_0) {
240 		hdr->cmn.cfr_metadata_version  = CFR_META_VERSION_1;
241 		if (target_type == TARGET_TYPE_IPQ4019)
242 			hdr->cmn.chip_type = CFR_CAPTURE_RADIO_DAKOTA;
243 		else if (target_type == TARGET_TYPE_QCA9888)
244 			hdr->cmn.chip_type = CFR_CAPTURE_RADIO_BESRA;
245 		else if (target_type == TARGET_TYPE_QCA9984)
246 			hdr->cmn.chip_type = CFR_CAPTURE_RADIO_CASCADE;
247 		else
248 			hdr->cmn.chip_type = CFR_CAPTURE_RADIO_NONE;
249 	} else if (target_type == TARGET_TYPE_QCA8074V2) {
250 		hdr->cmn.cfr_metadata_version = CFR_META_VERSION_6;
251 		hdr->cmn.chip_type = CFR_CAPTURE_RADIO_HKV2;
252 	} else {
253 		if (target_type == TARGET_TYPE_QCN9000)
254 			hdr->cmn.cfr_metadata_version = CFR_META_VERSION_7;
255 		else if ((target_type == TARGET_TYPE_QCA6018) ||
256 			 ((target_type == TARGET_TYPE_QCA5018) && (!is_rcc)))
257 			hdr->cmn.cfr_metadata_version = CFR_META_VERSION_5;
258 		else
259 			hdr->cmn.cfr_metadata_version = CFR_META_VERSION_3;
260 
261 		if (target_type == TARGET_TYPE_QCN9000)
262 			hdr->cmn.chip_type = CFR_CAPTURE_RADIO_PINE;
263 		else if (target_type == TARGET_TYPE_QCA5018)
264 			hdr->cmn.chip_type = CFR_CAPTURE_RADIO_MAPLE;
265 		else if (target_type == TARGET_TYPE_QCN6122)
266 			hdr->cmn.chip_type = CFR_CAPTURE_RADIO_SPRUCE;
267 		else
268 			hdr->cmn.chip_type = CFR_CAPTURE_RADIO_CYP;
269 	}
270 }
271 
272 #ifdef CFR_USE_FIXED_FOLDER
273 static QDF_STATUS target_if_cfr_init_target(struct wlan_objmgr_psoc *psoc,
274 					    struct wlan_objmgr_pdev *pdev,
275 					    uint32_t target)
276 {
277 	struct pdev_cfr *cfr_pdev;
278 	struct psoc_cfr *cfr_psoc;
279 	struct wmi_unified *wmi_handle = NULL;
280 	bool cfr_capable;
281 	QDF_STATUS status;
282 
283 	if (!psoc || !pdev) {
284 		cfr_err("null pdev or psoc");
285 		return QDF_STATUS_E_FAILURE;
286 	}
287 
288 	cfr_pdev = wlan_objmgr_pdev_get_comp_private_obj(pdev,
289 							 WLAN_UMAC_COMP_CFR);
290 	if (!cfr_pdev) {
291 		cfr_err("null pdev cfr");
292 		return QDF_STATUS_E_FAILURE;
293 	}
294 
295 	cfr_psoc = wlan_objmgr_psoc_get_comp_private_obj(psoc,
296 							 WLAN_UMAC_COMP_CFR);
297 
298 	if (!cfr_psoc) {
299 		cfr_err("null psoc cfr");
300 		return QDF_STATUS_E_FAILURE;
301 	}
302 
303 	wmi_handle = lmac_get_pdev_wmi_handle(pdev);
304 	if (!wmi_handle) {
305 		cfr_err("null wmi handle");
306 		return QDF_STATUS_E_FAILURE;
307 	}
308 
309 	if (wlan_cfr_is_feature_disabled(pdev)) {
310 		cfr_pdev->is_cfr_capable = 0;
311 		cfr_psoc->is_cfr_capable = 0;
312 		cfr_info("cfr disabled");
313 		return QDF_STATUS_SUCCESS;
314 	}
315 
316 	cfr_capable = wmi_service_enabled(wmi_handle,
317 					  wmi_service_cfr_capture_support);
318 	cfr_pdev->is_cfr_capable = cfr_capable;
319 	cfr_psoc->is_cfr_capable = cfr_capable;
320 	if (!cfr_capable) {
321 		cfr_err("FW doesn't support CFR");
322 		return QDF_STATUS_SUCCESS;
323 	}
324 
325 	status = cfr_enh_init_pdev(psoc, pdev);
326 	if (target == TARGET_TYPE_QCA6490)
327 		cfr_pdev->chip_type = CFR_CAPTURE_RADIO_HSP;
328 	else if (target == TARGET_TYPE_QCA6750)
329 		cfr_pdev->chip_type = CFR_CAPTURE_RADIO_MOSELLE;
330 
331 	return status;
332 }
333 
334 static QDF_STATUS target_if_cfr_deinit_target(struct wlan_objmgr_psoc *psoc,
335 					      struct wlan_objmgr_pdev *pdev)
336 {
337 	struct pdev_cfr *pcfr;
338 
339 	if (!psoc || !pdev) {
340 		cfr_err("null pdev or psoc");
341 		return QDF_STATUS_E_FAILURE;
342 	}
343 
344 	pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev,
345 						     WLAN_UMAC_COMP_CFR);
346 	if (!pcfr) {
347 		cfr_err("null pdev cfr");
348 		return QDF_STATUS_E_FAILURE;
349 	}
350 
351 	if (!pcfr->is_cfr_capable) {
352 		cfr_info("cfr disabled or FW not support");
353 		return QDF_STATUS_SUCCESS;
354 	}
355 
356 	return cfr_enh_deinit_pdev(psoc, pdev);
357 }
358 
359 QDF_STATUS
360 target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc,
361 			struct wlan_objmgr_pdev *pdev)
362 {
363 	uint32_t target_type;
364 	QDF_STATUS status;
365 
366 	target_type = target_if_cfr_get_target_type(psoc);
367 
368 	if (target_type == TARGET_TYPE_QCA6490 ||
369 	    target_type == TARGET_TYPE_QCA6750) {
370 		status = target_if_cfr_init_target(psoc,
371 						   pdev, target_type);
372 	} else if (target_type == TARGET_TYPE_ADRASTEA) {
373 		status = cfr_adrastea_init_pdev(psoc, pdev);
374 	} else {
375 		cfr_info("unsupport chip");
376 		status = QDF_STATUS_SUCCESS;
377 	}
378 
379 	return status;
380 }
381 
382 QDF_STATUS
383 target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc,
384 			  struct wlan_objmgr_pdev *pdev)
385 {
386 	uint32_t target_type;
387 	QDF_STATUS status;
388 
389 	target_type = target_if_cfr_get_target_type(psoc);
390 
391 	if (target_type == TARGET_TYPE_QCA6490 ||
392 	    target_type == TARGET_TYPE_QCA6750) {
393 		status = target_if_cfr_deinit_target(psoc, pdev);
394 	} else if (target_type == TARGET_TYPE_ADRASTEA) {
395 		status = cfr_adrastea_deinit_pdev(psoc, pdev);
396 	} else {
397 		cfr_info("unsupport chip");
398 		status = QDF_STATUS_SUCCESS;
399 	}
400 
401 	return status;
402 }
403 #else
404 QDF_STATUS
405 target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc,
406 			struct wlan_objmgr_pdev *pdev)
407 {
408 	uint32_t target_type;
409 	struct pdev_cfr *pa;
410 	struct psoc_cfr *cfr_sc;
411 
412 	if (wlan_cfr_is_feature_disabled(pdev)) {
413 		cfr_err("cfr is disabled");
414 		return QDF_STATUS_E_NOSUPPORT;
415 	}
416 
417 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
418 	if (pa == NULL)
419 		return QDF_STATUS_E_FAILURE;
420 
421 	/* Reset unassociated entries for every init */
422 	qdf_mem_zero(&pa->unassoc_pool[0], MAX_CFR_ENABLED_CLIENTS *
423 		     sizeof(struct unassoc_pool_entry));
424 
425 	cfr_sc = wlan_objmgr_psoc_get_comp_private_obj(psoc,
426 						       WLAN_UMAC_COMP_CFR);
427 
428 	if (cfr_sc == NULL)
429 		return QDF_STATUS_E_FAILURE;
430 
431 	target_type = target_if_cfr_get_target_type(psoc);
432 
433 	if (target_type == TARGET_TYPE_QCA8074V2) {
434 		pa->is_cfr_capable = cfr_sc->is_cfr_capable;
435 		return cfr_dbr_init_pdev(psoc, pdev);
436 	} else if ((target_type == TARGET_TYPE_IPQ4019) ||
437 		   (target_type == TARGET_TYPE_QCA9984) ||
438 		   (target_type == TARGET_TYPE_QCA9888)) {
439 
440 		pa->is_cfr_capable = cfr_sc->is_cfr_capable;
441 
442 		return cfr_wifi2_0_init_pdev(psoc, pdev);
443 	} else if ((target_type == TARGET_TYPE_QCA6018) ||
444 		   (target_type == TARGET_TYPE_QCN9000) ||
445 		   (target_type == TARGET_TYPE_QCN6122) ||
446 		   (target_type == TARGET_TYPE_QCA5018)) {
447 		pa->is_cfr_capable = cfr_sc->is_cfr_capable;
448 		return cfr_enh_init_pdev(psoc, pdev);
449 	} else
450 		return QDF_STATUS_E_NOSUPPORT;
451 }
452 
453 QDF_STATUS
454 target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc,
455 			  struct wlan_objmgr_pdev *pdev)
456 {
457 	uint32_t target_type;
458 
459 	if (wlan_cfr_is_feature_disabled(pdev)) {
460 		cfr_err("cfr is disabled");
461 		return QDF_STATUS_E_NOSUPPORT;
462 	}
463 
464 	target_type = target_if_cfr_get_target_type(psoc);
465 
466 	if (target_type == TARGET_TYPE_QCA8074V2) {
467 		return cfr_dbr_deinit_pdev(psoc, pdev);
468 	} else if ((target_type == TARGET_TYPE_IPQ4019) ||
469 		   (target_type == TARGET_TYPE_QCA9984) ||
470 		   (target_type == TARGET_TYPE_QCA9888)) {
471 
472 		return cfr_wifi2_0_deinit_pdev(psoc, pdev);
473 	} else if ((target_type == TARGET_TYPE_QCA6018) ||
474 		   (target_type == TARGET_TYPE_QCN9000) ||
475 		   (target_type == TARGET_TYPE_QCN6122) ||
476 		   (target_type == TARGET_TYPE_QCA5018)) {
477 		return cfr_enh_deinit_pdev(psoc, pdev);
478 	} else
479 		return QDF_STATUS_E_NOSUPPORT;
480 }
481 #endif
482 
483 #ifdef WLAN_ENH_CFR_ENABLE
484 #if defined(QCA_WIFI_QCA6490) || defined(QCA_WIFI_WCN7850)
485 static uint8_t target_if_cfr_get_mac_id(struct wlan_objmgr_pdev *pdev)
486 {
487 	struct wlan_objmgr_vdev *vdev;
488 	struct wlan_channel *bss_chan;
489 	struct pdev_cfr *pcfr;
490 	uint8_t mac_id = 0;
491 
492 	if (!pdev) {
493 		cfr_err("null pdev");
494 		return mac_id;
495 	}
496 
497 	mac_id = wlan_objmgr_pdev_get_pdev_id(pdev);
498 	pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
499 	if (!pcfr)  {
500 		cfr_err("null pcfr");
501 		return mac_id;
502 	}
503 
504 	if (pcfr->rcc_param.vdev_id == CFR_INVALID_VDEV_ID)
505 		return mac_id;
506 
507 	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev,
508 						    pcfr->rcc_param.vdev_id,
509 						    WLAN_CFR_ID);
510 	if (!vdev) {
511 		cfr_err("null vdev");
512 		return mac_id;
513 	}
514 
515 	bss_chan = wlan_vdev_mlme_get_bss_chan(vdev);
516 	if (!bss_chan) {
517 		cfr_info("null bss chan");
518 		wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
519 		return mac_id;
520 	}
521 
522 	cfr_debug("bss freq %d", bss_chan->ch_freq);
523 	if (wlan_reg_is_24ghz_ch_freq(bss_chan->ch_freq))
524 		mac_id = CFR_MAC_ID_24G;
525 	else
526 		mac_id = CFR_MAC_ID_5G;
527 
528 	pcfr->rcc_param.srng_id = mac_id;
529 	wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
530 
531 	return mac_id;
532 }
533 
534 static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev)
535 {
536 	return target_if_cfr_get_mac_id(pdev);
537 }
538 #else
539 static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev)
540 {
541 	return wlan_objmgr_pdev_get_pdev_id(pdev);
542 }
543 #endif /* QCA_WIFI_QCA6490 */
544 
545 QDF_STATUS target_if_cfr_config_rcc(struct wlan_objmgr_pdev *pdev,
546 				    struct cfr_rcc_param *rcc_info)
547 {
548 	QDF_STATUS status;
549 	struct wmi_unified *pdev_wmi_handle = NULL;
550 
551 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
552 	if (!pdev_wmi_handle) {
553 		cfr_err("pdev_wmi_handle is null");
554 		return QDF_STATUS_E_NULL_VALUE;
555 	}
556 
557 	rcc_info->pdev_id = target_if_cfr_get_pdev_id(pdev);
558 	rcc_info->num_grp_tlvs =
559 		count_set_bits(rcc_info->modified_in_curr_session);
560 
561 	status = wmi_unified_send_cfr_rcc_cmd(pdev_wmi_handle, rcc_info);
562 	return status;
563 }
564 
565 void target_if_cfr_default_ta_ra_config(struct cfr_rcc_param *rcc_info,
566 					bool allvalid, uint16_t reset_cfg)
567 {
568 	struct ta_ra_cfr_cfg *curr_cfg = NULL;
569 	int grp_id;
570 	unsigned long bitmap = reset_cfg;
571 	uint8_t def_mac[QDF_MAC_ADDR_SIZE] = {0xFF, 0xFF, 0xFF,
572 		0xFF, 0xFF, 0xFF};
573 	uint8_t null_mac[QDF_MAC_ADDR_SIZE] = {0x00, 0x00, 0x00,
574 		0x00, 0x00, 0x00};
575 
576 	for (grp_id = 0; grp_id < MAX_TA_RA_ENTRIES; grp_id++) {
577 		if (qdf_test_bit(grp_id, &bitmap)) {
578 			curr_cfg = &rcc_info->curr[grp_id];
579 			qdf_mem_copy(curr_cfg->tx_addr,
580 				     null_mac, QDF_MAC_ADDR_SIZE);
581 			qdf_mem_copy(curr_cfg->tx_addr_mask,
582 				     def_mac, QDF_MAC_ADDR_SIZE);
583 			qdf_mem_copy(curr_cfg->rx_addr,
584 				     null_mac, QDF_MAC_ADDR_SIZE);
585 			qdf_mem_copy(curr_cfg->rx_addr_mask,
586 				     def_mac, QDF_MAC_ADDR_SIZE);
587 			curr_cfg->bw = 0xf;
588 			curr_cfg->nss = 0xff;
589 			curr_cfg->mgmt_subtype_filter = 0;
590 			curr_cfg->ctrl_subtype_filter = 0;
591 			curr_cfg->data_subtype_filter = 0;
592 			if (!allvalid) {
593 				curr_cfg->valid_ta = 0;
594 				curr_cfg->valid_ta_mask = 0;
595 				curr_cfg->valid_ra = 0;
596 				curr_cfg->valid_ra_mask = 0;
597 				curr_cfg->valid_bw_mask = 0;
598 				curr_cfg->valid_nss_mask = 0;
599 				curr_cfg->valid_mgmt_subtype = 0;
600 				curr_cfg->valid_ctrl_subtype = 0;
601 				curr_cfg->valid_data_subtype = 0;
602 			} else {
603 				curr_cfg->valid_ta = 1;
604 				curr_cfg->valid_ta_mask = 1;
605 				curr_cfg->valid_ra = 1;
606 				curr_cfg->valid_ra_mask = 1;
607 				curr_cfg->valid_bw_mask = 1;
608 				curr_cfg->valid_nss_mask = 1;
609 				curr_cfg->valid_mgmt_subtype = 1;
610 				curr_cfg->valid_ctrl_subtype = 1;
611 				curr_cfg->valid_data_subtype = 1;
612 			}
613 		}
614 	}
615 }
616 #endif
617 
618 #ifdef WLAN_ENH_CFR_ENABLE
619 #ifdef CFR_USE_FIXED_FOLDER
620 static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops)
621 {
622 	tx_ops->cfr_tx_ops.cfr_subscribe_ppdu_desc =
623 				target_if_cfr_subscribe_ppdu_desc;
624 }
625 #else
626 static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops)
627 {
628 }
629 #endif /* CFR_USE_FIXED_FOLDER */
630 static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
631 {
632 	tx_ops->cfr_tx_ops.cfr_config_rcc =
633 		target_if_cfr_config_rcc;
634 	tx_ops->cfr_tx_ops.cfr_start_lut_timer =
635 		target_if_cfr_start_lut_age_timer;
636 	tx_ops->cfr_tx_ops.cfr_stop_lut_timer =
637 		target_if_cfr_stop_lut_age_timer;
638 	tx_ops->cfr_tx_ops.cfr_default_ta_ra_cfg =
639 		target_if_cfr_default_ta_ra_config;
640 	tx_ops->cfr_tx_ops.cfr_dump_lut_enh =
641 		target_if_cfr_dump_lut_enh;
642 	tx_ops->cfr_tx_ops.cfr_rx_tlv_process =
643 		target_if_cfr_rx_tlv_process;
644 	tx_ops->cfr_tx_ops.cfr_update_global_cfg =
645 		target_if_cfr_update_global_cfg;
646 	target_if_enh_cfr_add_ops(tx_ops);
647 }
648 #else
649 static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
650 {
651 }
652 #endif
653 
654 void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops)
655 {
656 	tx_ops->cfr_tx_ops.cfr_init_pdev =
657 		target_if_cfr_init_pdev;
658 	tx_ops->cfr_tx_ops.cfr_deinit_pdev =
659 		target_if_cfr_deinit_pdev;
660 	tx_ops->cfr_tx_ops.cfr_enable_cfr_timer =
661 		target_if_cfr_enable_cfr_timer;
662 	tx_ops->cfr_tx_ops.cfr_start_capture =
663 		target_if_cfr_start_capture;
664 	tx_ops->cfr_tx_ops.cfr_stop_capture =
665 		target_if_cfr_stop_capture;
666 	target_if_enh_cfr_tx_ops(tx_ops);
667 }
668 
669 void target_if_cfr_set_cfr_support(struct wlan_objmgr_psoc *psoc,
670 				   uint8_t value)
671 {
672 	struct wlan_lmac_if_rx_ops *rx_ops;
673 
674 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
675 	if (!rx_ops) {
676 		cfr_err("rx_ops is NULL");
677 		return;
678 	}
679 	if (rx_ops->cfr_rx_ops.cfr_support_set)
680 		rx_ops->cfr_rx_ops.cfr_support_set(psoc, value);
681 }
682 
683 QDF_STATUS
684 target_if_cfr_set_capture_count_support(struct wlan_objmgr_psoc *psoc,
685 					uint8_t value)
686 {
687 	struct wlan_lmac_if_rx_ops *rx_ops;
688 
689 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
690 	if (!rx_ops) {
691 		cfr_err("rx_ops is NULL");
692 		return QDF_STATUS_E_INVAL;
693 	}
694 
695 	if (rx_ops->cfr_rx_ops.cfr_capture_count_support_set)
696 		return rx_ops->cfr_rx_ops.cfr_capture_count_support_set(
697 						psoc, value);
698 
699 	return QDF_STATUS_E_INVAL;
700 }
701 
702 QDF_STATUS
703 target_if_cfr_set_mo_marking_support(struct wlan_objmgr_psoc *psoc,
704 				     uint8_t value)
705 {
706 	struct wlan_lmac_if_rx_ops *rx_ops;
707 
708 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
709 	if (!rx_ops) {
710 		cfr_err("rx_ops is NULL");
711 		return QDF_STATUS_E_INVAL;
712 	}
713 
714 	if (rx_ops->cfr_rx_ops.cfr_mo_marking_support_set)
715 		return rx_ops->cfr_rx_ops.cfr_mo_marking_support_set(
716 						psoc, value);
717 
718 	return QDF_STATUS_E_INVAL;
719 }
720 
721 QDF_STATUS
722 target_if_cfr_set_aoa_for_rcc_support(struct wlan_objmgr_psoc *psoc,
723 				      uint8_t value)
724 {
725 	struct wlan_lmac_if_rx_ops *rx_ops;
726 
727 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
728 	if (!rx_ops) {
729 		cfr_err("rx_ops is NULL");
730 		return QDF_STATUS_E_INVAL;
731 	}
732 
733 	if (rx_ops->cfr_rx_ops.cfr_aoa_for_rcc_support_set)
734 		return rx_ops->cfr_rx_ops.cfr_aoa_for_rcc_support_set(
735 						psoc, value);
736 
737 	return QDF_STATUS_E_INVAL;
738 }
739 
740 void target_if_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head,
741 			     size_t hlen, void *data, size_t dlen, void *tail,
742 			     size_t tlen)
743 {
744 	struct wlan_objmgr_psoc *psoc;
745 	struct wlan_lmac_if_rx_ops *rx_ops;
746 
747 	psoc = wlan_pdev_get_psoc(pdev);
748 
749 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
750 	if (!rx_ops) {
751 		cfr_err("rx_ops is NULL");
752 		return;
753 	}
754 	if (rx_ops->cfr_rx_ops.cfr_info_send)
755 		rx_ops->cfr_rx_ops.cfr_info_send(pdev, head, hlen, data, dlen,
756 						 tail, tlen);
757 }
758