xref: /wlan-dirver/qca-wifi-host-cmn/umac/cfr/dispatcher/src/wlan_cfr_ucfg_api.c (revision a86b23ee68a2491aede2e03991f3fb37046f4e41)
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 <wlan_cfr_ucfg_api.h>
20 #include "cfr_defs_i.h"
21 #include <wlan_cfr_utils_api.h>
22 #include <wlan_cfr_tgt_api.h>
23 #include <wlan_objmgr_peer_obj.h>
24 #include <wlan_objmgr_pdev_obj.h>
25 #include <qdf_module.h>
26 #ifdef WLAN_ENH_CFR_ENABLE
27 #include "cdp_txrx_ctrl.h"
28 #endif
29 
30 #ifdef WLAN_ENH_CFR_ENABLE
31 static bool cfr_is_filter_enabled(struct cfr_rcc_param *rcc_param)
32 {
33 	if (rcc_param->m_directed_ftm ||
34 	    rcc_param->m_all_ftm_ack ||
35 	    rcc_param->m_ndpa_ndp_directed ||
36 	    rcc_param->m_ndpa_ndp_all ||
37 	    rcc_param->m_ta_ra_filter ||
38 	    rcc_param->m_all_packet)
39 		return true;
40 	else
41 		return false;
42 }
43 
44 static bool cfr_is_rcc_enabled(struct pdev_cfr *pa)
45 {
46 	if (pa->is_cfr_rcc_capable &&
47 	    cfr_is_filter_enabled(&pa->rcc_param))
48 		return true;
49 	else
50 		return false;
51 }
52 #else
53 static bool cfr_is_rcc_enabled(struct pdev_cfr *pa)
54 {
55 	return false;
56 }
57 #endif
58 int ucfg_cfr_start_capture(struct wlan_objmgr_pdev *pdev,
59 			   struct wlan_objmgr_peer *peer,
60 			   struct cfr_capture_params *params)
61 {
62 	int status;
63 	struct pdev_cfr *pa;
64 	struct peer_cfr *pe;
65 
66 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
67 	if (NULL == pa) {
68 		cfr_err("PDEV cfr object is NULL!");
69 		return -EINVAL;
70 	}
71 
72 	if (!(pa->is_cfr_capable)) {
73 		cfr_err("cfr is not supported on this chip");
74 		return -EINVAL;
75 	}
76 
77 	/* Get peer private object */
78 	pe = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_UMAC_COMP_CFR);
79 	if (NULL == pe) {
80 		cfr_err("PEER cfr object is NULL!");
81 		return -EINVAL;
82 	}
83 
84 	if ((params->period < 0) || (params->period > MAX_CFR_PRD) ||
85 		(params->period % 10)) {
86 		cfr_err("Invalid period value: %d", params->period);
87 		return -EINVAL;
88 	}
89 
90 	if (!(params->period) && (pa->cfr_timer_enable)) {
91 		cfr_err("Single shot capture is not allowed during periodic capture");
92 		return -EINVAL;
93 	}
94 
95 	if ((params->period) && !(pa->cfr_timer_enable)) {
96 		cfr_err("Global periodic timer is not enabled, configure global cfr timer");
97 	}
98 
99 	if (params->period) {
100 		if (pa->cfr_current_sta_count == pa->cfr_max_sta_count) {
101 			cfr_err("max periodic cfr clients reached");
102 			return -EINVAL;
103 		}
104 		if (!(pe->request))
105 			pa->cfr_current_sta_count++;
106 	}
107 
108 	if (cfr_is_rcc_enabled(pa)) {
109 		cfr_err("This is not allowed since RCC is enabled");
110 		pa->cfr_timer_enable = 0;
111 		return -EINVAL;
112 	}
113 
114 	status = tgt_cfr_start_capture(pdev, peer, params);
115 
116 	if (status == 0) {
117 		pe->bandwidth = params->bandwidth;
118 		pe->period = params->period;
119 		pe->capture_method = params->method;
120 		pe->request = PEER_CFR_CAPTURE_ENABLE;
121 	} else
122 		pa->cfr_current_sta_count--;
123 
124 	return status;
125 }
126 
127 int ucfg_cfr_start_capture_probe_req(struct wlan_objmgr_pdev *pdev,
128 				     struct qdf_mac_addr *unassoc_mac,
129 				     struct cfr_capture_params *params)
130 {
131 	int idx, idx_to_insert = -1;
132 	struct pdev_cfr *pa;
133 
134 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
135 	if (!pa) {
136 		cfr_err("Pdev cfr object is null!");
137 		return -EINVAL;
138 	}
139 
140 	if (!(pa->is_cfr_capable)) {
141 		cfr_err("CFR is not supported on this chip");
142 		return -EINVAL;
143 	}
144 
145 	if (pa->cfr_current_sta_count == pa->cfr_max_sta_count) {
146 		cfr_err("max cfr cleint reached");
147 		return -EINVAL;
148 	}
149 
150 	for (idx = 0; idx < MAX_CFR_ENABLED_CLIENTS; idx++) {
151 		/* Store first invalid entry's index, to add mac entry if not
152 		 * already present.
153 		 */
154 		if (idx_to_insert < 0) {
155 			if (pa->unassoc_pool[idx].is_valid != true)
156 				idx_to_insert = idx;
157 		}
158 
159 		/* Add new mac entry only if it is not present. If already
160 		 * present, update the capture parameters
161 		 */
162 		if (qdf_mem_cmp(&pa->unassoc_pool[idx].mac, unassoc_mac,
163 				sizeof(struct qdf_mac_addr)) == 0) {
164 			cfr_info("Node already present. Updating params");
165 			qdf_mem_copy(&pa->unassoc_pool[idx].cfr_params,
166 				     params,
167 				     sizeof(struct cfr_capture_params));
168 			pa->unassoc_pool[idx].is_valid = true;
169 			return 0;
170 		}
171 	}
172 
173 	if (idx_to_insert < 0) {
174 		/* All the entries in the table are valid. So we have reached
175 		 * max client capacity. To add a new client, capture on one of
176 		 * the clients in table has to be stopped.
177 		 */
178 		cfr_err("Maximum client capacity reached");
179 		return -EINVAL;
180 	}
181 
182 	/* If control reaches here, we did not find mac in the table
183 	 * and we have atleast one free entry in table.
184 	 * Add the entry at index = idx_to_insert
185 	 */
186 	qdf_mem_copy(&pa->unassoc_pool[idx_to_insert].mac,
187 		     unassoc_mac, sizeof(struct qdf_mac_addr));
188 	qdf_mem_copy(&pa->unassoc_pool[idx_to_insert].cfr_params,
189 		     params, sizeof(struct cfr_capture_params));
190 	pa->unassoc_pool[idx_to_insert].is_valid = true;
191 	pa->cfr_current_sta_count++;
192 
193 	return 0;
194 }
195 
196 int ucfg_cfr_stop_capture_probe_req(struct wlan_objmgr_pdev *pdev,
197 				    struct qdf_mac_addr *unassoc_mac)
198 {
199 	struct pdev_cfr *pa;
200 	int idx;
201 
202 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
203 	if (!pa) {
204 		cfr_err("Pdev cfr object is NULL!");
205 		return -EINVAL;
206 	}
207 
208 	if (!(pa->is_cfr_capable)) {
209 		cfr_err("CFR is not supported on this chip");
210 		return -EINVAL;
211 	}
212 
213 	for (idx = 0; idx < MAX_CFR_ENABLED_CLIENTS; idx++) {
214 		/* Remove mac only if it is present */
215 		if (qdf_mem_cmp(&pa->unassoc_pool[idx].mac, unassoc_mac,
216 				sizeof(struct qdf_mac_addr)) == 0) {
217 			qdf_mem_zero(&pa->unassoc_pool[idx],
218 				     sizeof(struct unassoc_pool_entry));
219 			pa->cfr_current_sta_count--;
220 			return 0;
221 		}
222 	}
223 
224 	/* If mac was present in pool it would have been deleted in the
225 	 * above loop and returned from there.
226 	 * If control reached here, mac was not found. So, ignore the request.
227 	 */
228 	cfr_err("Trying to delete mac not present in pool. Ignoring request.");
229 	return 0;
230 }
231 
232 int ucfg_cfr_set_timer(struct wlan_objmgr_pdev *pdev, uint32_t value)
233 {
234 	struct pdev_cfr *pa;
235 
236 	if (wlan_cfr_is_feature_disabled(pdev)) {
237 		cfr_err("cfr is disabled");
238 		return QDF_STATUS_E_NOSUPPORT;
239 	}
240 
241 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
242 	if (pa == NULL) {
243 		cfr_err("PDEV cfr object is NULL!");
244 		return -EINVAL;
245 	}
246 
247 	if (!(pa->is_cfr_capable)) {
248 		cfr_err("cfr is not supported on this chip");
249 		return -EINVAL;
250 	}
251 
252 	return tgt_cfr_enable_cfr_timer(pdev, value);
253 }
254 qdf_export_symbol(ucfg_cfr_set_timer);
255 
256 int ucfg_cfr_get_timer(struct wlan_objmgr_pdev *pdev)
257 {
258 	struct pdev_cfr *pa;
259 
260 	if (wlan_cfr_is_feature_disabled(pdev)) {
261 		cfr_err("cfr is disabled");
262 		return QDF_STATUS_E_NOSUPPORT;
263 	}
264 
265 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
266 	if (pa == NULL) {
267 		cfr_err("PDEV cfr object is NULL!");
268 		return -EINVAL;
269 	}
270 
271 	if (!(pa->is_cfr_capable)) {
272 		cfr_err("cfr is not supported on this chip");
273 		return -EINVAL;
274 	}
275 
276 	return pa->cfr_timer_enable;
277 }
278 qdf_export_symbol(ucfg_cfr_get_timer);
279 
280 static void cfr_iter_peer_handler(struct wlan_objmgr_pdev *pdev,
281 				  void *object, void *arg)
282 {
283 	struct wlan_objmgr_peer *peer = (struct wlan_objmgr_peer *)object;
284 	struct peer_cfr *pe;
285 	int *cfr_capt_status = (int *)arg;
286 
287 	if (*cfr_capt_status == PEER_CFR_CAPTURE_ENABLE)
288 		return;
289 
290 	if (!peer || !pdev) {
291 		cfr_err("peer or pdev object is NULL");
292 		return;
293 	}
294 
295 	if (wlan_vdev_get_selfpeer(peer->peer_objmgr.vdev) == peer)
296 		return;
297 
298 	pe = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_UMAC_COMP_CFR);
299 	if (!pe) {
300 		cfr_err("PEER cfr object is NULL!");
301 		return;
302 	}
303 
304 	if (pe->request == PEER_CFR_CAPTURE_ENABLE) {
305 		*cfr_capt_status = pe->request;
306 		cfr_debug("CFR capture running for peer "
307 			  QDF_MAC_ADDR_STR,
308 			  QDF_MAC_ADDR_ARRAY(peer->macaddr));
309 	}
310 }
311 
312 void ucfg_cfr_get_capture_status(struct wlan_objmgr_pdev *pdev,
313 				 enum cfr_capt_status *status)
314 {
315 	*status = PEER_CFR_CAPTURE_DISABLE;
316 
317 	wlan_objmgr_pdev_iterate_obj_list(pdev, WLAN_PEER_OP,
318 					  cfr_iter_peer_handler,
319 					  status, 1, WLAN_CFR_ID);
320 }
321 qdf_export_symbol(ucfg_cfr_get_capture_status);
322 
323 int ucfg_cfr_stop_capture(struct wlan_objmgr_pdev *pdev,
324 			  struct wlan_objmgr_peer *peer)
325 {
326 	int status;
327 	struct peer_cfr *pe;
328 	struct pdev_cfr *pa;
329 
330 	pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR);
331 	if (pa == NULL) {
332 		cfr_err("PDEV cfr object is NULL!");
333 		return -EINVAL;
334 	}
335 
336 	if (!(pa->is_cfr_capable)) {
337 		cfr_err("cfr is not supported on this chip");
338 		return -EINVAL;
339 	}
340 
341 	pe = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_UMAC_COMP_CFR);
342 	if (pe == NULL) {
343 		cfr_err("PEER cfr object is NULL!");
344 		return -EINVAL;
345 	}
346 
347 	if ((pe->period) && (pe->request))
348 		status = tgt_cfr_stop_capture(pdev, peer);
349 	else {
350 		cfr_err("periodic cfr not started for the client");
351 		return -EINVAL;
352 	}
353 
354 	if (status == 0) {
355 		pe->request = PEER_CFR_CAPTURE_DISABLE;
356 		pa->cfr_current_sta_count--;
357 	}
358 
359 	return status;
360 }
361 
362 int ucfg_cfr_list_peers(struct wlan_objmgr_pdev *pdev)
363 {
364 	return 0;
365 }
366 
367 QDF_STATUS ucfg_cfr_stop_indication(struct wlan_objmgr_vdev *vdev)
368 {
369 	if (!vdev) {
370 		cfr_err("null vdev");
371 		return QDF_STATUS_E_INVAL;
372 	}
373 
374 	return cfr_stop_indication(vdev);
375 }
376 
377 #ifdef WLAN_ENH_CFR_ENABLE
378 
379 static inline
380 QDF_STATUS dev_sanity_check(struct wlan_objmgr_vdev *vdev,
381 			    struct wlan_objmgr_pdev **ppdev,
382 			    struct pdev_cfr **ppcfr)
383 {
384 	QDF_STATUS status = QDF_STATUS_SUCCESS;
385 
386 	if (!vdev) {
387 		cfr_err("vdev is NULL");
388 		return QDF_STATUS_E_NULL_VALUE;
389 	}
390 
391 	*ppdev = wlan_vdev_get_pdev(vdev);
392 
393 	if (!*ppdev) {
394 		cfr_err("pdev is NULL");
395 		return QDF_STATUS_E_NULL_VALUE;
396 	}
397 
398 	status = wlan_objmgr_pdev_try_get_ref(*ppdev, WLAN_CFR_ID);
399 	if (status != QDF_STATUS_SUCCESS) {
400 		cfr_err("Failed to get pdev reference");
401 		return status;
402 	}
403 
404 	*ppcfr = wlan_objmgr_pdev_get_comp_private_obj(*ppdev,
405 						     WLAN_UMAC_COMP_CFR);
406 
407 	if (!(*ppcfr)) {
408 		cfr_err("pdev object for CFR is null");
409 		wlan_objmgr_pdev_release_ref(*ppdev, WLAN_CFR_ID);
410 		return QDF_STATUS_E_NULL_VALUE;
411 	}
412 
413 	if (!(*ppcfr)->is_cfr_rcc_capable) {
414 		cfr_err("cfr is not supported on this chip");
415 		wlan_objmgr_pdev_release_ref(*ppdev, WLAN_CFR_ID);
416 		return QDF_STATUS_E_NOSUPPORT;
417 	}
418 
419 	return status;
420 }
421 
422 /*
423  * This is needed only in case of m_ta_ra_filter mode.
424  * If user wants to reset the group configurations to default values,
425  * then this handler will come into action.
426  *
427  * If user wants to reset the configurations of 0th, 1st and 3rd group,
428  * then the input should be :
429  *
430  *               wlanconfig ath0 cfr reset_cfg 0xb
431  *
432  */
433 
434 QDF_STATUS ucfg_cfr_set_reset_bitmap(struct wlan_objmgr_vdev *vdev,
435 				     struct cfr_wlanconfig_param *params)
436 {
437 	struct pdev_cfr *pcfr = NULL;
438 	struct wlan_objmgr_pdev *pdev = NULL;
439 	QDF_STATUS status = QDF_STATUS_SUCCESS;
440 
441 	status = dev_sanity_check(vdev, &pdev, &pcfr);
442 	if (status != QDF_STATUS_SUCCESS)
443 		return status;
444 
445 	pcfr->rcc_param.modified_in_curr_session |= params->reset_cfg;
446 	tgt_cfr_default_ta_ra_cfg(pdev, &pcfr->rcc_param,
447 				  true, params->reset_cfg);
448 
449 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
450 
451 	return status;
452 }
453 
454 /*
455  * This is needed only in case of m_ta_ra_filter mode.
456  * After providing all the group configurations, user should provide
457  * the information about which groups need to be enabled.
458  * Based on that FW will enable the configurations for CFR groups.
459  * If user has to enable only 0th group, then input should be :
460  *
461  *               wlanconfig ath0 cfr en_cfg 0x1
462  *
463  * Enable the bitmap from user provided configuration into cfr_rcc_param.
464  */
465 
466 QDF_STATUS ucfg_cfr_set_en_bitmap(struct wlan_objmgr_vdev *vdev,
467 				  struct cfr_wlanconfig_param *params)
468 {
469 	struct pdev_cfr *pcfr = NULL;
470 	struct wlan_objmgr_pdev *pdev = NULL;
471 	QDF_STATUS status = QDF_STATUS_SUCCESS;
472 
473 	status = dev_sanity_check(vdev, &pdev, &pcfr);
474 	if (status != QDF_STATUS_SUCCESS)
475 		return status;
476 
477 	pcfr->rcc_param.filter_group_bitmap = params->en_cfg;
478 
479 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
480 
481 	return status;
482 }
483 
484 /*
485  * Copy user provided input for ul_mu_user_mask into cfr_rcc_param.
486  */
487 
488 QDF_STATUS
489 ucfg_cfr_set_ul_mu_user_mask(struct wlan_objmgr_vdev *vdev,
490 			     struct cfr_wlanconfig_param *params)
491 {
492 	struct pdev_cfr *pcfr = NULL;
493 	struct wlan_objmgr_pdev *pdev = NULL;
494 	QDF_STATUS status = QDF_STATUS_SUCCESS;
495 
496 	status = dev_sanity_check(vdev, &pdev, &pcfr);
497 	if (status != QDF_STATUS_SUCCESS)
498 		return status;
499 
500 	pcfr->rcc_param.ul_mu_user_mask_lower = params->ul_mu_user_mask_lower;
501 	pcfr->rcc_param.ul_mu_user_mask_upper = params->ul_mu_user_mask_upper;
502 
503 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
504 
505 	return status;
506 }
507 
508 /*
509  * FREEZE_TLV_DELAY_CNT_* registers are used for FREEZE TLV timeout mechanism
510  * in MAC side. In case MAC send FREEZE TLV to PHY too late due to
511  * long AST delay, PHY ucode may not handle it well or it will impact
512  * next frame’s normal processing, then MAC needs to drop FREEZE TLV
513  * sending process after reaching the threshold.
514  *
515  * This handler will copy user provided input for freeze_tlv_delay_cnt
516  * into cfr_rcc_param.
517  */
518 
519 QDF_STATUS
520 ucfg_cfr_set_freeze_tlv_delay_cnt(struct wlan_objmgr_vdev *vdev,
521 				  struct cfr_wlanconfig_param *params)
522 {
523 	struct pdev_cfr *pcfr = NULL;
524 	struct wlan_objmgr_pdev *pdev = NULL;
525 	QDF_STATUS status = QDF_STATUS_SUCCESS;
526 
527 	status = dev_sanity_check(vdev, &pdev, &pcfr);
528 	if (status != QDF_STATUS_SUCCESS)
529 		return status;
530 
531 	pcfr->rcc_param.freeze_tlv_delay_cnt_en =
532 		params->freeze_tlv_delay_cnt_en;
533 
534 	pcfr->rcc_param.freeze_tlv_delay_cnt_thr =
535 		params->freeze_tlv_delay_cnt_thr;
536 
537 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
538 
539 	return status;
540 }
541 
542 /*
543  * Set capture interval from the provided configuration into cfr_rcc_param.
544  * All fixed parameters are needed to be stored into cfr_rcc_param.
545  */
546 
547 QDF_STATUS
548 ucfg_cfr_set_capture_interval(struct wlan_objmgr_vdev *vdev,
549 			      struct cfr_wlanconfig_param *params)
550 {
551 	struct pdev_cfr *pcfr = NULL;
552 	struct wlan_objmgr_pdev *pdev = NULL;
553 	QDF_STATUS status = QDF_STATUS_SUCCESS;
554 
555 	status = dev_sanity_check(vdev, &pdev, &pcfr);
556 	if (status != QDF_STATUS_SUCCESS)
557 		return status;
558 
559 	if (pcfr->rcc_param.capture_duration > params->cap_intvl) {
560 		cfr_err("Capture interval should be more than capture duration");
561 		status = QDF_STATUS_E_INVAL;
562 	} else {
563 		pcfr->rcc_param.capture_interval = params->cap_intvl;
564 	}
565 
566 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
567 
568 	return status;
569 }
570 
571 /*
572  * Set capture duration from the provided configuration into cfr_rcc_param.
573  * All fixed parameters are needed to be stored into cfr_rcc_param.
574  */
575 
576 QDF_STATUS
577 ucfg_cfr_set_capture_duration(struct wlan_objmgr_vdev *vdev,
578 			      struct cfr_wlanconfig_param *params)
579 {
580 	struct pdev_cfr *pcfr = NULL;
581 	struct wlan_objmgr_pdev *pdev = NULL;
582 	QDF_STATUS status = QDF_STATUS_SUCCESS;
583 
584 	status = dev_sanity_check(vdev, &pdev, &pcfr);
585 	if (status != QDF_STATUS_SUCCESS)
586 		return status;
587 
588 	if (pcfr->rcc_param.capture_interval &&
589 	    (params->cap_dur > pcfr->rcc_param.capture_interval)) {
590 		cfr_err("Capture duration is exceeding capture interval");
591 		status = QDF_STATUS_E_INVAL;
592 	} else {
593 		pcfr->rcc_param.capture_duration = params->cap_dur;
594 	}
595 
596 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
597 
598 	return status;
599 }
600 
601 /*
602  * Copy user provided group parameters( type/ subtype of mgmt, ctrl, data )
603  * into curr_cfg instance of ta_ra_cfr_cfg.
604  * Set valid mask for the provided configuration.
605  * Set modified_in_this_session for the particular group.
606  */
607 
608 QDF_STATUS
609 ucfg_cfr_set_frame_type_subtype(struct wlan_objmgr_vdev *vdev,
610 				struct cfr_wlanconfig_param *params)
611 {
612 	struct pdev_cfr *pcfr = NULL;
613 	struct wlan_objmgr_pdev *pdev = NULL;
614 	struct ta_ra_cfr_cfg *curr_cfg = NULL;
615 	QDF_STATUS status = QDF_STATUS_SUCCESS;
616 
617 	status = dev_sanity_check(vdev, &pdev, &pcfr);
618 	if (status != QDF_STATUS_SUCCESS)
619 		return status;
620 
621 	/* Populating current config based on user's input */
622 	curr_cfg = &pcfr->rcc_param.curr[params->grp_id];
623 	curr_cfg->mgmt_subtype_filter = params->expected_mgmt_subtype;
624 	curr_cfg->ctrl_subtype_filter = params->expected_ctrl_subtype;
625 	curr_cfg->data_subtype_filter = params->expected_data_subtype;
626 
627 	curr_cfg->valid_mgmt_subtype = 1;
628 	curr_cfg->valid_ctrl_subtype = 1;
629 	curr_cfg->valid_data_subtype = 1;
630 
631 	qdf_set_bit(params->grp_id,
632 		    (unsigned long *)
633 		    &pcfr->rcc_param.modified_in_curr_session);
634 
635 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
636 
637 	return status;
638 }
639 
640 /*
641  * Copy user provided group parameters( BW and NSS )
642  * into curr_cfg instance of ta_ra_cfr_cfg.
643  * Set valid mask for the provided configuration.
644  * Set modified_in_this_session for the particular group.
645  */
646 
647 QDF_STATUS ucfg_cfr_set_bw_nss(struct wlan_objmgr_vdev *vdev,
648 			       struct cfr_wlanconfig_param *params)
649 {
650 	struct pdev_cfr *pcfr = NULL;
651 	struct wlan_objmgr_pdev *pdev = NULL;
652 	struct ta_ra_cfr_cfg *curr_cfg = NULL;
653 	QDF_STATUS status = QDF_STATUS_SUCCESS;
654 
655 	status = dev_sanity_check(vdev, &pdev, &pcfr);
656 	if (status != QDF_STATUS_SUCCESS)
657 		return status;
658 
659 	/* Populating current config based on user's input */
660 	curr_cfg = &pcfr->rcc_param.curr[params->grp_id];
661 	curr_cfg->bw = params->bw;
662 	curr_cfg->nss = params->nss;
663 
664 	curr_cfg->valid_bw_mask = 1;
665 	curr_cfg->valid_nss_mask = 1;
666 
667 	qdf_set_bit(params->grp_id,
668 		    (unsigned long *)&pcfr->rcc_param.modified_in_curr_session);
669 
670 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
671 
672 	return status;
673 }
674 
675 /*
676  * Copy user provided group parameters( TA, RA, TA_MASK, RA_MASK )
677  * into curr_cfg instance of ta_ra_cfr_cfg.
678  * Set valid mask for the provided configuration.
679  * Set modified_in_this_session for the particular group.
680  */
681 
682 QDF_STATUS ucfg_cfr_set_tara_config(struct wlan_objmgr_vdev *vdev,
683 				    struct cfr_wlanconfig_param *params)
684 {
685 	struct pdev_cfr *pcfr = NULL;
686 	struct wlan_objmgr_pdev *pdev = NULL;
687 	struct ta_ra_cfr_cfg *curr_cfg = NULL;
688 	QDF_STATUS status = QDF_STATUS_SUCCESS;
689 
690 	status = dev_sanity_check(vdev, &pdev, &pcfr);
691 	if (status != QDF_STATUS_SUCCESS)
692 		return status;
693 
694 	curr_cfg = &pcfr->rcc_param.curr[params->grp_id];
695 	qdf_mem_copy(curr_cfg->tx_addr, params->ta, QDF_MAC_ADDR_SIZE);
696 	qdf_mem_copy(curr_cfg->rx_addr, params->ra, QDF_MAC_ADDR_SIZE);
697 	qdf_mem_copy(curr_cfg->tx_addr_mask,
698 		     params->ta_mask, QDF_MAC_ADDR_SIZE);
699 	qdf_mem_copy(curr_cfg->rx_addr_mask,
700 		     params->ra_mask, QDF_MAC_ADDR_SIZE);
701 
702 	curr_cfg->valid_ta = 1;
703 	curr_cfg->valid_ta_mask = 1;
704 	curr_cfg->valid_ra = 1;
705 	curr_cfg->valid_ra_mask = 1;
706 
707 	qdf_set_bit(params->grp_id,
708 		    (unsigned long *)
709 		    &pcfr->rcc_param.modified_in_curr_session);
710 
711 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
712 
713 	return status;
714 }
715 
716 QDF_STATUS ucfg_cfr_get_cfg(struct wlan_objmgr_vdev *vdev)
717 {
718 	struct pdev_cfr *pcfr = NULL;
719 	struct wlan_objmgr_pdev *pdev = NULL;
720 	struct ta_ra_cfr_cfg *glbl_cfg = NULL;
721 	QDF_STATUS status = QDF_STATUS_SUCCESS;
722 	uint8_t grp_id;
723 
724 	status = dev_sanity_check(vdev, &pdev, &pcfr);
725 	if (status != QDF_STATUS_SUCCESS)
726 		return status;
727 	if (!cfr_is_filter_enabled(&pcfr->rcc_param)) {
728 		cfr_err(" All RCC modes are disabled");
729 		wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
730 		return status;
731 	}
732 
733 	cfr_err("CAPTURE MODE:\n");
734 
735 	cfr_err("m_directed_ftm is : %s\n",
736 		pcfr->rcc_param.m_directed_ftm ?
737 		"enabled" : "disabled");
738 	cfr_err("m_all_ftm_ack is : %s\n",
739 		pcfr->rcc_param.m_all_ftm_ack ?
740 		"enabled" : "disabled");
741 	cfr_err("m_ndpa_ndp_directed is: %s\n",
742 		pcfr->rcc_param.m_ndpa_ndp_directed ?
743 		"enabled" : "disabled");
744 	cfr_err("m_ndpa_ndp_all is : %s\n",
745 		pcfr->rcc_param.m_ndpa_ndp_all ?
746 		"enabled" : "disabled");
747 	cfr_err("m_ta_ra_filter is : %s\n",
748 		pcfr->rcc_param.m_ta_ra_filter ?
749 		"enabled" : "disabled");
750 	cfr_err("m_all_packet is : %s\n",
751 		pcfr->rcc_param.m_all_packet ?
752 		"enabled" : "disabled");
753 
754 	cfr_err("capture duration : %u usec\n",
755 		pcfr->rcc_param.capture_duration);
756 	cfr_err("capture interval : %u usec\n",
757 		pcfr->rcc_param.capture_interval);
758 	cfr_err("UL MU User mask lower : %u\n",
759 		pcfr->rcc_param.ul_mu_user_mask_lower);
760 	cfr_err("UL MU User mask upper : %u\n",
761 		pcfr->rcc_param.ul_mu_user_mask_upper);
762 	cfr_err("Freeze TLV delay count is : %s\n",
763 		pcfr->rcc_param.freeze_tlv_delay_cnt_en ?
764 		"enabled" : "disabled");
765 	cfr_err("Freeze TLV delay count threshold : %u\n",
766 		pcfr->rcc_param.freeze_tlv_delay_cnt_thr);
767 	cfr_err("Enabled CFG id bitmap : 0x%x\n",
768 		pcfr->rcc_param.filter_group_bitmap);
769 	cfr_err(" Modified cfg id bitmap : 0x%x\n",
770 		pcfr->rcc_param.modified_in_curr_session);
771 
772 	cfr_err("TARA_CONFIG details:\n");
773 
774 	for (grp_id = 0; grp_id < MAX_TA_RA_ENTRIES; grp_id++) {
775 		glbl_cfg = &pcfr->global[grp_id];
776 
777 		cfr_err("Config ID: %d\n", grp_id);
778 		cfr_err("Bandwidth :0x%x\n", glbl_cfg->bw);
779 		cfr_err("NSS : 0x%x\n", glbl_cfg->nss);
780 		cfr_err("valid_ta: %d\n", glbl_cfg->valid_ta);
781 		cfr_err("valid_ta_mask: %d\n", glbl_cfg->valid_ta_mask);
782 		cfr_err("valid_ra: %d\n", glbl_cfg->valid_ra);
783 		cfr_err("valid_ra_mask: %d\n", glbl_cfg->valid_ra_mask);
784 		cfr_err("valid_bw_mask: %d\n", glbl_cfg->valid_bw_mask);
785 		cfr_err("valid_nss_mask: %d\n", glbl_cfg->valid_nss_mask);
786 		cfr_err("valid_mgmt_subtype: %d\n",
787 			glbl_cfg->valid_mgmt_subtype);
788 		cfr_err("valid_ctrl_subtype: %d\n",
789 			glbl_cfg->valid_ctrl_subtype);
790 		cfr_err("valid_data_subtype: %d\n",
791 			glbl_cfg->valid_data_subtype);
792 		cfr_err("Mgmt subtype : 0x%x\n",
793 			glbl_cfg->mgmt_subtype_filter);
794 		cfr_err("CTRL subtype : 0x%x\n",
795 			glbl_cfg->ctrl_subtype_filter);
796 		cfr_err("Data subtype : 0x%x\n",
797 			glbl_cfg->data_subtype_filter);
798 		cfr_err("TX Addr: " QDF_MAC_ADDR_STR,
799 			QDF_MAC_ADDR_ARRAY(glbl_cfg->tx_addr));
800 		cfr_err("TX Addr Mask: " QDF_MAC_ADDR_STR,
801 			QDF_MAC_ADDR_ARRAY(glbl_cfg->tx_addr_mask));
802 		cfr_err("RX Addr: " QDF_MAC_ADDR_STR,
803 			QDF_MAC_ADDR_ARRAY(glbl_cfg->rx_addr));
804 		cfr_err("RX Addr Mask: " QDF_MAC_ADDR_STR,
805 			QDF_MAC_ADDR_ARRAY(glbl_cfg->rx_addr_mask));
806 	}
807 
808 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
809 
810 	return status;
811 }
812 
813 static const char *chan_capture_status_to_str(enum chan_capture_status type)
814 {
815 	switch (type) {
816 	case CAPTURE_IDLE:
817 		return "CAPTURE_IDLE";
818 	case CAPTURE_BUSY:
819 		return "CAPTURE_BUSY";
820 	case CAPTURE_ACTIVE:
821 		return "CAPTURE_ACTIVE";
822 	case CAPTURE_NO_BUFFER:
823 		return "CAPTURE_NO_BUFFER";
824 	default:
825 		return "INVALID";
826 	}
827 }
828 
829 static const
830 char *mac_freeze_reason_to_str(enum mac_freeze_capture_reason type)
831 {
832 	switch (type) {
833 	case FREEZE_REASON_TM:
834 		return "FREEZE_REASON_TM";
835 	case FREEZE_REASON_FTM:
836 		return "FREEZE_REASON_FTM";
837 	case FREEZE_REASON_ACK_RESP_TO_TM_FTM:
838 		return "FREEZE_REASON_ACK_RESP_TO_TM_FTM";
839 	case FREEZE_REASON_TA_RA_TYPE_FILTER:
840 		return "FREEZE_REASON_TA_RA_TYPE_FILTER";
841 	case FREEZE_REASON_NDPA_NDP:
842 		return "FREEZE_REASON_NDPA_NDP";
843 	case FREEZE_REASON_ALL_PACKET:
844 		return "FREEZE_REASON_ALL_PACKET";
845 	default:
846 		return "INVALID";
847 	}
848 }
849 
850 QDF_STATUS ucfg_cfr_rcc_dump_dbg_counters(struct wlan_objmgr_vdev *vdev)
851 {
852 	struct pdev_cfr *pcfr = NULL;
853 	struct wlan_objmgr_pdev *pdev = NULL;
854 	struct wlan_objmgr_psoc *psoc = NULL;
855 	struct cdp_cfr_rcc_stats *cfr_rcc_stats = NULL;
856 	uint8_t stats_cnt;
857 	QDF_STATUS status = QDF_STATUS_SUCCESS;
858 
859 	status = dev_sanity_check(vdev, &pdev, &pcfr);
860 	if (status != QDF_STATUS_SUCCESS)
861 		return status;
862 
863 	psoc = wlan_pdev_get_psoc(pdev);
864 	if (!psoc) {
865 		cfr_err("psoc is null!");
866 		wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
867 		return QDF_STATUS_E_NULL_VALUE;
868 	}
869 
870 	cfr_err("total_tx_evt_cnt = %llu\n",
871 		pcfr->total_tx_evt_cnt);
872 	cfr_err("dbr_evt_cnt = %llu\n",
873 		pcfr->dbr_evt_cnt);
874 	cfr_err("rx_tlv_evt_cnt = %llu\n",
875 		pcfr->rx_tlv_evt_cnt);
876 	cfr_err("release_cnt = %llu\n",
877 		pcfr->release_cnt);
878 	cfr_err("Error cnt:\n");
879 	cfr_err("flush_dbr_cnt = %llu\n",
880 		pcfr->flush_dbr_cnt);
881 	cfr_err("invalid_dma_length_cnt = %llu\n",
882 		pcfr->invalid_dma_length_cnt);
883 	cfr_err("flush_timeout_dbr_cnt = %llu\n",
884 		pcfr->flush_timeout_dbr_cnt);
885 	cfr_err("tx_peer_status_cfr_fail = %llu\n",
886 		pcfr->tx_peer_status_cfr_fail);
887 	cfr_err("tx_evt_status_cfr_fail = %llu\n",
888 		pcfr->tx_evt_status_cfr_fail);
889 	cfr_err("tx_dbr_cookie_lookup_fail = %llu\n",
890 		pcfr->tx_dbr_cookie_lookup_fail);
891 	cfr_err("PPDU id mismatch for same cookie:\n");
892 	cfr_err("clear_txrx_event = %llu\n",
893 		pcfr->clear_txrx_event);
894 	cfr_err("cfr_dma_aborts = %llu\n",
895 		pcfr->cfr_dma_aborts);
896 
897 	cfr_rcc_stats = qdf_mem_malloc(sizeof(struct cdp_cfr_rcc_stats));
898 	if (!cfr_rcc_stats) {
899 		wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
900 		return QDF_STATUS_E_NOMEM;
901 	}
902 
903 	cdp_get_cfr_dbg_stats(wlan_psoc_get_dp_handle(psoc),
904 			      wlan_objmgr_pdev_get_pdev_id(pdev),
905 			      cfr_rcc_stats);
906 
907 	cfr_err("bb_captured_channel_cnt: %llu\n",
908 		cfr_rcc_stats->bb_captured_channel_cnt);
909 	cfr_err("bb_captured_timeout_cnt: %llu\n",
910 		cfr_rcc_stats->bb_captured_timeout_cnt);
911 	cfr_err("rx_loc_info_valid_cnt: %llu\n",
912 		cfr_rcc_stats->rx_loc_info_valid_cnt);
913 
914 	cfr_err("Channel capture status:\n");
915 	for (stats_cnt = 0; stats_cnt < CAPTURE_MAX; stats_cnt++) {
916 		cfr_err("%s = %llu\n",
917 			chan_capture_status_to_str(stats_cnt),
918 			cfr_rcc_stats->chan_capture_status[stats_cnt]);
919 	}
920 
921 	cfr_err("Freeze reason:\n");
922 	for (stats_cnt = 0; stats_cnt < FREEZE_REASON_MAX; stats_cnt++) {
923 		cfr_err("%s = %llu\n",
924 			mac_freeze_reason_to_str(stats_cnt),
925 			cfr_rcc_stats->reason_cnt[stats_cnt]);
926 	}
927 
928 	qdf_mem_free(cfr_rcc_stats);
929 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
930 
931 	return status;
932 }
933 
934 QDF_STATUS ucfg_cfr_rcc_clr_dbg_counters(struct wlan_objmgr_vdev *vdev)
935 {
936 	struct pdev_cfr *pcfr = NULL;
937 	struct wlan_objmgr_pdev *pdev = NULL;
938 	struct wlan_objmgr_psoc *psoc = NULL;
939 	QDF_STATUS status = QDF_STATUS_SUCCESS;
940 
941 	status = dev_sanity_check(vdev, &pdev, &pcfr);
942 	if (status != QDF_STATUS_SUCCESS)
943 		return status;
944 
945 	psoc = wlan_pdev_get_psoc(pdev);
946 	if (!psoc) {
947 		cfr_err("psoc is null!");
948 		wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
949 		return QDF_STATUS_E_NULL_VALUE;
950 	}
951 	cdp_cfr_clr_dbg_stats(wlan_psoc_get_dp_handle(psoc),
952 			      wlan_objmgr_pdev_get_pdev_id(pdev));
953 
954 	pcfr->dbr_evt_cnt = 0;
955 	pcfr->release_cnt = 0;
956 	pcfr->total_tx_evt_cnt = 0;
957 	pcfr->rx_tlv_evt_cnt = 0;
958 	pcfr->flush_dbr_cnt = 0;
959 	pcfr->flush_timeout_dbr_cnt = 0;
960 	pcfr->invalid_dma_length_cnt = 0;
961 	pcfr->clear_txrx_event = 0;
962 	pcfr->cfr_dma_aborts = 0;
963 	pcfr->tx_peer_status_cfr_fail = 0;
964 	pcfr->tx_evt_status_cfr_fail = 0;
965 	pcfr->tx_dbr_cookie_lookup_fail = 0;
966 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
967 
968 	return status;
969 }
970 
971 QDF_STATUS ucfg_cfr_rcc_dump_lut(struct wlan_objmgr_vdev *vdev)
972 {
973 	struct wlan_objmgr_pdev *pdev = NULL;
974 	QDF_STATUS status = QDF_STATUS_SUCCESS;
975 
976 	if (!vdev) {
977 		cfr_err("vdev is NULL");
978 		return QDF_STATUS_E_INVAL;
979 	}
980 
981 	pdev = wlan_vdev_get_pdev(vdev);
982 	if (!pdev) {
983 		cfr_err("pdev is NULL");
984 		return QDF_STATUS_E_INVAL;
985 	}
986 
987 	if (wlan_objmgr_pdev_try_get_ref(pdev, WLAN_CFR_ID) !=
988 	    QDF_STATUS_SUCCESS) {
989 		return QDF_STATUS_E_INVAL;
990 	}
991 
992 	cfr_err("LUT table:");
993 	tgt_cfr_dump_lut_enh(pdev);
994 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
995 
996 	return status;
997 }
998 
999 static void cfr_set_filter(struct wlan_objmgr_pdev *pdev, bool enable,
1000 			   struct cdp_monitor_filter *filter_val)
1001 {
1002 	struct wlan_objmgr_psoc *psoc = wlan_pdev_get_psoc(pdev);
1003 
1004 	cfr_info("pdev_id=%d\n", wlan_objmgr_pdev_get_pdev_id(pdev));
1005 
1006 	cdp_cfr_filter(wlan_psoc_get_dp_handle(psoc),
1007 		       wlan_objmgr_pdev_get_pdev_id(pdev),
1008 		       enable,
1009 		       filter_val);
1010 }
1011 
1012 /*
1013  * With the initiation of commit command, this handler will be triggered.
1014  *
1015  * Starts the procedure of forming the TLVs.
1016  * If Host succeeds to send WMI command to FW, after TLV processing, then it
1017  * will save the previous CFR configurations into one instance ta_ra_cfr_cfg,
1018  * called glbl_cfg and update the current config to default state for the
1019  * next commit session.
1020  *
1021  * Finally, reset the counter (modified_in_this_session) to 0 before moving to
1022  * next commit session.
1023  *
1024  */
1025 
1026 QDF_STATUS ucfg_cfr_committed_rcc_config(struct wlan_objmgr_vdev *vdev)
1027 {
1028 	struct pdev_cfr *pcfr = NULL;
1029 	struct wlan_objmgr_pdev *pdev = NULL;
1030 	struct wlan_objmgr_psoc *psoc = NULL;
1031 	QDF_STATUS status = QDF_STATUS_SUCCESS;
1032 	struct cdp_monitor_filter filter_val = {0};
1033 
1034 	status = dev_sanity_check(vdev, &pdev, &pcfr);
1035 	if (status != QDF_STATUS_SUCCESS)
1036 		return status;
1037 
1038 	psoc = wlan_pdev_get_psoc(pdev);
1039 
1040 	if (!psoc) {
1041 		cfr_err("psoc is null!");
1042 		wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
1043 		return QDF_STATUS_E_NULL_VALUE;
1044 	}
1045 
1046 	pcfr->rcc_param.vdev_id = wlan_vdev_get_id(vdev);
1047 
1048 	/*
1049 	 * If capture mode is valid, then Host:
1050 	 * Subscribes for PPDU status TLVs in monitor status ring.
1051 	 * Sets filter type to either FP or MO, based on the capture mode.
1052 	 * Starts the LUT_AGE_TIMER of 1sec.
1053 	 *
1054 	 * If capture mode is disabled, then Host:
1055 	 * unsubscribes for PPDU status TLVs in monitor status ring.
1056 	 * Sets filter type to 0.
1057 	 * Stops the LUT_AGE_TIMER.
1058 	 *
1059 	 */
1060 
1061 	if (cfr_is_filter_enabled(&pcfr->rcc_param)) {
1062 		if (pcfr->cfr_timer_enable) {
1063 			cfr_err("Not allowed: Periodic capture is enabled.\n");
1064 			wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
1065 			return QDF_STATUS_E_NOSUPPORT;
1066 		}
1067 
1068 		if (pcfr->rcc_param.m_all_ftm_ack) {
1069 			filter_val.mode |= MON_FILTER_PASS |
1070 					   MON_FILTER_OTHER;
1071 			filter_val.fp_mgmt |= FILTER_MGMT_ACTION;
1072 			filter_val.mo_mgmt |= FILTER_MGMT_ACTION;
1073 		}
1074 
1075 		if (pcfr->rcc_param.m_ndpa_ndp_all) {
1076 			filter_val.mode |= MON_FILTER_PASS |
1077 					   MON_FILTER_OTHER;
1078 			filter_val.fp_ctrl |= FILTER_CTRL_VHT_NDP;
1079 			filter_val.mo_ctrl |= FILTER_CTRL_VHT_NDP;
1080 		}
1081 
1082 		if (pcfr->rcc_param.m_all_packet) {
1083 			filter_val.mode |= MON_FILTER_PASS |
1084 					   MON_FILTER_OTHER;
1085 			filter_val.fp_mgmt |= FILTER_MGMT_ALL;
1086 			filter_val.mo_mgmt |= FILTER_MGMT_ALL;
1087 			filter_val.fp_ctrl |= FILTER_CTRL_ALL;
1088 			filter_val.mo_ctrl |= FILTER_CTRL_ALL;
1089 			filter_val.fp_data |= FILTER_DATA_ALL;
1090 			filter_val.mo_data |= FILTER_DATA_ALL;
1091 		}
1092 
1093 		/*
1094 		 * M_TA_RA in monitor other is as intensive as M_ALL pkt
1095 		 * Support only FP in M_TA_RA mode
1096 		 */
1097 		if (pcfr->rcc_param.m_ta_ra_filter) {
1098 			filter_val.mode |= MON_FILTER_PASS |
1099 					   MON_FILTER_OTHER;
1100 			filter_val.fp_mgmt |= FILTER_MGMT_ALL;
1101 			filter_val.mo_mgmt |= FILTER_MGMT_ALL;
1102 			filter_val.fp_ctrl |= FILTER_CTRL_ALL;
1103 			filter_val.mo_ctrl |= FILTER_CTRL_ALL;
1104 			filter_val.fp_data |= FILTER_DATA_ALL;
1105 			filter_val.mo_data |= FILTER_DATA_ALL;
1106 		}
1107 
1108 		if (pcfr->rcc_param.m_directed_ftm) {
1109 			filter_val.mode |= MON_FILTER_PASS;
1110 			filter_val.fp_mgmt |= FILTER_MGMT_ACTION;
1111 		}
1112 
1113 		if (pcfr->rcc_param.m_ndpa_ndp_directed) {
1114 			filter_val.mode |= MON_FILTER_PASS;
1115 			filter_val.fp_ctrl |= FILTER_CTRL_VHT_NDP;
1116 		}
1117 
1118 		if (!cdp_get_cfr_rcc(wlan_psoc_get_dp_handle(psoc),
1119 				    wlan_objmgr_pdev_get_pdev_id(pdev)))
1120 			tgt_cfr_start_lut_age_timer(pdev);
1121 		cfr_set_filter(pdev, 1, &filter_val);
1122 	} else {
1123 		if (cdp_get_cfr_rcc(wlan_psoc_get_dp_handle(psoc),
1124 				    wlan_objmgr_pdev_get_pdev_id(pdev)))
1125 			tgt_cfr_stop_lut_age_timer(pdev);
1126 		cfr_set_filter(pdev, 0, &filter_val);
1127 	}
1128 
1129 	/* Trigger wmi to start the TLV processing. */
1130 	status = tgt_cfr_config_rcc(pdev, &pcfr->rcc_param);
1131 	if (status == QDF_STATUS_SUCCESS) {
1132 		cfr_info("CFR commit done\n");
1133 		/* Update global config */
1134 		tgt_cfr_update_global_cfg(pdev);
1135 
1136 		/* Bring curr_cfg to default state for next commit session */
1137 		tgt_cfr_default_ta_ra_cfg(pdev, &pcfr->rcc_param,
1138 					  false, MAX_RESET_CFG_ENTRY);
1139 	} else {
1140 		cfr_err("CFR commit failed");
1141 	}
1142 
1143 	pcfr->rcc_param.num_grp_tlvs = 0;
1144 	pcfr->rcc_param.modified_in_curr_session = 0;
1145 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
1146 
1147 	return status;
1148 }
1149 
1150 /*
1151  * This handler is used to enable / disable the capture mode.
1152  *
1153  */
1154 QDF_STATUS ucfg_cfr_set_rcc_mode(struct wlan_objmgr_vdev *vdev,
1155 				 enum capture_type mode, uint8_t value)
1156 {
1157 	struct pdev_cfr *pcfr = NULL;
1158 	struct wlan_objmgr_pdev *pdev = NULL;
1159 	QDF_STATUS status = QDF_STATUS_SUCCESS;
1160 
1161 	status = dev_sanity_check(vdev, &pdev, &pcfr);
1162 	if (status != QDF_STATUS_SUCCESS)
1163 		return status;
1164 
1165 	switch (mode) {
1166 	case RCC_DIRECTED_FTM_FILTER:
1167 		pcfr->rcc_param.m_directed_ftm = value;
1168 		break;
1169 	case RCC_ALL_FTM_ACK_FILTER:
1170 		pcfr->rcc_param.m_all_ftm_ack = value;
1171 		break;
1172 	case RCC_DIRECTED_NDPA_NDP_FILTER:
1173 		pcfr->rcc_param.m_ndpa_ndp_directed = value;
1174 		break;
1175 	case RCC_NDPA_NDP_ALL_FILTER:
1176 		pcfr->rcc_param.m_ndpa_ndp_all = value;
1177 		break;
1178 	case RCC_TA_RA_FILTER:
1179 		pcfr->rcc_param.m_ta_ra_filter = value;
1180 		break;
1181 	case RCC_ALL_PACKET_FILTER:
1182 		pcfr->rcc_param.m_all_packet = value;
1183 		break;
1184 	case RCC_DIS_ALL_MODE:
1185 		pcfr->rcc_param.m_directed_ftm = value;
1186 		pcfr->rcc_param.m_all_ftm_ack = value;
1187 		pcfr->rcc_param.m_ndpa_ndp_directed = value;
1188 		pcfr->rcc_param.m_ndpa_ndp_all = value;
1189 		pcfr->rcc_param.m_ta_ra_filter = value;
1190 		pcfr->rcc_param.m_all_packet = value;
1191 		break;
1192 
1193 	default:
1194 		break;
1195 	}
1196 
1197 	cfr_debug("<CFR_UMAC> Capture mode set by user: 0x%x\n", value);
1198 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
1199 
1200 	return status;
1201 }
1202 
1203 bool ucfg_cfr_get_rcc_enabled(struct wlan_objmgr_vdev *vdev)
1204 {
1205 	struct pdev_cfr *pcfr = NULL;
1206 	struct wlan_objmgr_pdev *pdev = NULL;
1207 	QDF_STATUS status = QDF_STATUS_SUCCESS;
1208 	bool rcc_enabled = false;
1209 
1210 	status = dev_sanity_check(vdev, &pdev, &pcfr);
1211 	if (status != QDF_STATUS_SUCCESS)
1212 		return false;
1213 
1214 	rcc_enabled = cfr_is_filter_enabled(&pcfr->rcc_param);
1215 	wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID);
1216 
1217 	return rcc_enabled;
1218 }
1219 
1220 QDF_STATUS ucfg_cfr_subscribe_ppdu_desc(struct wlan_objmgr_pdev *pdev,
1221 					bool is_subscribe)
1222 {
1223 	return tgt_cfr_subscribe_ppdu_desc(pdev, is_subscribe);
1224 }
1225 #endif
1226