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 <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 % CFR_MOD_PRD)) { 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->period && (pe->request == PEER_CFR_CAPTURE_ENABLE)) { 305 *cfr_capt_status = pe->request; 306 cfr_debug("CFR capture running for peer " 307 QDF_MAC_ADDR_FMT, 308 QDF_MAC_ADDR_REF(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_CFR_ADRASTEA 378 void ucfg_cfr_capture_data(struct wlan_objmgr_psoc *psoc, uint32_t vdev_id, 379 struct csi_cfr_header *hdr, uint32_t mem_index) 380 { 381 struct wlan_objmgr_vdev *vdev; 382 struct wlan_objmgr_pdev *pdev; 383 struct pdev_cfr *pcfr; 384 uint32_t end_magic_num = 0xBEAFDEAD; 385 void *vaddr, *payload; 386 u32 *rindex, *windex, payload_len; 387 QDF_STATUS status = QDF_STATUS_SUCCESS; 388 389 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, 390 WLAN_CFR_ID); 391 if (!vdev) { 392 cfr_err("vdev is NULL"); 393 return; 394 } 395 396 pdev = wlan_vdev_get_pdev(vdev); 397 if (!pdev) { 398 cfr_err("pdev is NULL"); 399 wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID); 400 return; 401 } 402 403 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_CFR_ID); 404 if (status != QDF_STATUS_SUCCESS) { 405 cfr_err("Failed to get pdev reference"); 406 wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID); 407 return; 408 } 409 410 pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev, 411 WLAN_UMAC_COMP_CFR); 412 if (!pcfr) { 413 cfr_err("pdev is NULL"); 414 goto exit; 415 } 416 417 if (!pcfr->is_cfr_capable) { 418 cfr_err("CFR not supported on this chip"); 419 goto exit; 420 } 421 422 hdr->vendorid = CFR_VENDOR_ID; 423 hdr->cfr_metadata_version = CFR_META_VERSION_1; 424 hdr->cfr_data_version = CFR_DATA_VERSION_1; 425 hdr->chip_type = CFR_CAPTURE_RADIO_ADRASTEA; 426 hdr->pltform_type = CFR_PLATFORM_TYPE_ARM; 427 hdr->cfr_metadata_len = sizeof(struct cfr_metadata_version_1); 428 429 vaddr = pcfr->cfr_mem_chunk.vaddr; 430 rindex = (u32 *)vaddr; 431 windex = rindex + 1; 432 433 /* 434 * mem_index is having the index of the address where CFR dump wrriten, 435 * find data pointer from mem index and start address of memory. 436 */ 437 payload = vaddr + mem_index; 438 payload_len = hdr->u.meta_v1.length; 439 440 /* Write data into streamfs */ 441 tgt_cfr_info_send(pdev, hdr, sizeof(struct csi_cfr_header), 442 payload, payload_len, &end_magic_num, 443 sizeof(uint32_t)); 444 445 /* 446 * Updating the read index to the number of bytes read by host, it will 447 * help in writing next capture. 448 * ignoring 4 byte for FW magic number from the actual allocated memory 449 * length to avoid corruption in magic number. This memory is circular 450 * so after complation of one round, Skipping the first 8 byte as they 451 * are for read index and write index. 452 */ 453 if (((*rindex) + payload_len) <= (pcfr->cfr_mem_chunk.len - 4)) 454 (*rindex) += payload_len; 455 else if (((*rindex) + payload_len) > (pcfr->cfr_mem_chunk.len - 4)) 456 (*rindex) = (payload_len + 8); 457 458 exit: 459 wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID); 460 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 461 } 462 #endif 463 464 #ifdef WLAN_ENH_CFR_ENABLE 465 466 static inline 467 QDF_STATUS dev_sanity_check(struct wlan_objmgr_vdev *vdev, 468 struct wlan_objmgr_pdev **ppdev, 469 struct pdev_cfr **ppcfr) 470 { 471 QDF_STATUS status = QDF_STATUS_SUCCESS; 472 473 if (!vdev) { 474 cfr_err("vdev is NULL"); 475 return QDF_STATUS_E_NULL_VALUE; 476 } 477 478 *ppdev = wlan_vdev_get_pdev(vdev); 479 480 if (!*ppdev) { 481 cfr_err("pdev is NULL"); 482 return QDF_STATUS_E_NULL_VALUE; 483 } 484 485 status = wlan_objmgr_pdev_try_get_ref(*ppdev, WLAN_CFR_ID); 486 if (status != QDF_STATUS_SUCCESS) { 487 cfr_err("Failed to get pdev reference"); 488 return status; 489 } 490 491 *ppcfr = wlan_objmgr_pdev_get_comp_private_obj(*ppdev, 492 WLAN_UMAC_COMP_CFR); 493 494 if (!(*ppcfr)) { 495 cfr_err("pdev object for CFR is null"); 496 wlan_objmgr_pdev_release_ref(*ppdev, WLAN_CFR_ID); 497 return QDF_STATUS_E_NULL_VALUE; 498 } 499 500 if (!(*ppcfr)->is_cfr_rcc_capable) { 501 cfr_err("cfr is not supported on this chip"); 502 wlan_objmgr_pdev_release_ref(*ppdev, WLAN_CFR_ID); 503 return QDF_STATUS_E_NOSUPPORT; 504 } 505 506 return status; 507 } 508 509 /* 510 * This is needed only in case of m_ta_ra_filter mode. 511 * If user wants to reset the group configurations to default values, 512 * then this handler will come into action. 513 * 514 * If user wants to reset the configurations of 0th, 1st and 3rd group, 515 * then the input should be : 516 * 517 * wlanconfig ath0 cfr reset_cfg 0xb 518 * 519 */ 520 521 QDF_STATUS ucfg_cfr_set_reset_bitmap(struct wlan_objmgr_vdev *vdev, 522 struct cfr_wlanconfig_param *params) 523 { 524 struct pdev_cfr *pcfr = NULL; 525 struct wlan_objmgr_pdev *pdev = NULL; 526 QDF_STATUS status = QDF_STATUS_SUCCESS; 527 528 status = dev_sanity_check(vdev, &pdev, &pcfr); 529 if (status != QDF_STATUS_SUCCESS) 530 return status; 531 532 pcfr->rcc_param.modified_in_curr_session |= params->reset_cfg; 533 tgt_cfr_default_ta_ra_cfg(pdev, &pcfr->rcc_param, 534 true, params->reset_cfg); 535 536 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 537 538 return status; 539 } 540 541 #ifdef WLAN_ENH_CFR_ENABLE 542 /* 543 * This is needed only in case of m_ta_ra_filter mode. 544 * After providing all the group configurations, user should provide 545 * the information about which groups need to be enabled. 546 * Based on that FW will enable the configurations for CFR groups. 547 * If user has to enable only 0th group, then input should be : 548 * 549 * wlanconfig ath0 cfr en_cfg 0x1 550 * 551 * Enable the bitmap from user provided configuration into cfr_rcc_param. 552 */ 553 554 QDF_STATUS ucfg_cfr_set_en_bitmap(struct wlan_objmgr_vdev *vdev, 555 struct cfr_wlanconfig_param *params) 556 { 557 struct pdev_cfr *pcfr = NULL; 558 struct wlan_objmgr_pdev *pdev = NULL; 559 QDF_STATUS status = QDF_STATUS_SUCCESS; 560 561 status = dev_sanity_check(vdev, &pdev, &pcfr); 562 if (status != QDF_STATUS_SUCCESS) 563 return status; 564 565 pcfr->rcc_param.filter_group_bitmap = params->en_cfg; 566 567 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 568 569 return status; 570 } 571 #endif 572 573 /* 574 * Copy user provided input for ul_mu_user_mask into cfr_rcc_param. 575 */ 576 577 QDF_STATUS 578 ucfg_cfr_set_ul_mu_user_mask(struct wlan_objmgr_vdev *vdev, 579 struct cfr_wlanconfig_param *params) 580 { 581 struct pdev_cfr *pcfr = NULL; 582 struct wlan_objmgr_pdev *pdev = NULL; 583 QDF_STATUS status = QDF_STATUS_SUCCESS; 584 585 status = dev_sanity_check(vdev, &pdev, &pcfr); 586 if (status != QDF_STATUS_SUCCESS) 587 return status; 588 589 pcfr->rcc_param.ul_mu_user_mask_lower = params->ul_mu_user_mask_lower; 590 pcfr->rcc_param.ul_mu_user_mask_upper = params->ul_mu_user_mask_upper; 591 592 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 593 594 return status; 595 } 596 597 /* 598 * FREEZE_TLV_DELAY_CNT_* registers are used for FREEZE TLV timeout mechanism 599 * in MAC side. In case MAC send FREEZE TLV to PHY too late due to 600 * long AST delay, PHY ucode may not handle it well or it will impact 601 * next frame’s normal processing, then MAC needs to drop FREEZE TLV 602 * sending process after reaching the threshold. 603 * 604 * This handler will copy user provided input for freeze_tlv_delay_cnt 605 * into cfr_rcc_param. 606 */ 607 608 QDF_STATUS 609 ucfg_cfr_set_freeze_tlv_delay_cnt(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 QDF_STATUS status = QDF_STATUS_SUCCESS; 615 616 status = dev_sanity_check(vdev, &pdev, &pcfr); 617 if (status != QDF_STATUS_SUCCESS) 618 return status; 619 620 pcfr->rcc_param.freeze_tlv_delay_cnt_en = 621 params->freeze_tlv_delay_cnt_en; 622 623 pcfr->rcc_param.freeze_tlv_delay_cnt_thr = 624 params->freeze_tlv_delay_cnt_thr; 625 626 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 627 628 return status; 629 } 630 631 /* 632 * Configure ta_ra_filter_in_as_fp from the provided configuration into 633 * cfr_rcc_param. All fixed parameters needed to be stored into cfr_rcc_param. 634 */ 635 QDF_STATUS 636 ucfg_cfr_set_tara_filterin_as_fp(struct wlan_objmgr_vdev *vdev, 637 struct cfr_wlanconfig_param *params) 638 { 639 struct pdev_cfr *pcfr = NULL; 640 struct wlan_objmgr_pdev *pdev = NULL; 641 QDF_STATUS status = QDF_STATUS_SUCCESS; 642 643 status = dev_sanity_check(vdev, &pdev, &pcfr); 644 if (status != QDF_STATUS_SUCCESS) 645 return status; 646 647 if (!pcfr->is_mo_marking_support) { 648 cfr_err("MO marking support not available to filter as FP/MO"); 649 status = QDF_STATUS_E_NOSUPPORT; 650 } else { 651 pcfr->rcc_param.en_ta_ra_filter_in_as_fp = 652 params->en_ta_ra_filter_in_as_fp; 653 } 654 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 655 656 return status; 657 } 658 659 /* 660 * Set the capture count from the provided configuration into cfr_rcc_param. 661 * All fixed parameters are needed to be stored into cfr_rcc_param. 662 */ 663 QDF_STATUS 664 ucfg_cfr_set_capture_count(struct wlan_objmgr_vdev *vdev, 665 struct cfr_wlanconfig_param *params) 666 { 667 struct pdev_cfr *pcfr = NULL; 668 struct wlan_objmgr_pdev *pdev = NULL; 669 QDF_STATUS status = QDF_STATUS_SUCCESS; 670 671 status = dev_sanity_check(vdev, &pdev, &pcfr); 672 if (status != QDF_STATUS_SUCCESS) 673 return status; 674 675 if (!pcfr->is_cap_interval_mode_sel_support) { 676 cfr_err("Capture count support not enabled"); 677 status = QDF_STATUS_E_NOSUPPORT; 678 } else { 679 pcfr->rcc_param.capture_count = params->cap_count; 680 } 681 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 682 683 return status; 684 } 685 686 /* 687 * Set interval mode sel nob from the provided configuration into cfr_rcc_param. 688 * All fixed parameters are needed to be stored into cfr_rcc_param 689 */ 690 QDF_STATUS 691 ucfg_cfr_set_capture_interval_mode_sel(struct wlan_objmgr_vdev *vdev, 692 struct cfr_wlanconfig_param *params) 693 { 694 struct pdev_cfr *pcfr = NULL; 695 struct wlan_objmgr_pdev *pdev = NULL; 696 QDF_STATUS status = QDF_STATUS_SUCCESS; 697 698 status = dev_sanity_check(vdev, &pdev, &pcfr); 699 if (status != QDF_STATUS_SUCCESS) 700 return status; 701 702 if (!pcfr->is_cap_interval_mode_sel_support) { 703 cfr_err("Capture count support not enabled"); 704 status = QDF_STATUS_E_NOSUPPORT; 705 } else { 706 pcfr->rcc_param.capture_intval_mode_sel = 707 params->cap_intval_mode_sel; 708 } 709 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 710 711 return status; 712 } 713 714 /* 715 * Set capture interval from the provided configuration into cfr_rcc_param. 716 * All fixed parameters are needed to be stored into cfr_rcc_param. 717 */ 718 719 QDF_STATUS 720 ucfg_cfr_set_capture_interval(struct wlan_objmgr_vdev *vdev, 721 struct cfr_wlanconfig_param *params) 722 { 723 struct pdev_cfr *pcfr = NULL; 724 struct wlan_objmgr_pdev *pdev = NULL; 725 QDF_STATUS status = QDF_STATUS_SUCCESS; 726 727 status = dev_sanity_check(vdev, &pdev, &pcfr); 728 if (status != QDF_STATUS_SUCCESS) 729 return status; 730 731 if (pcfr->rcc_param.capture_duration > params->cap_intvl) { 732 cfr_err("Capture interval should be more than capture duration"); 733 status = QDF_STATUS_E_INVAL; 734 } else { 735 pcfr->rcc_param.capture_interval = params->cap_intvl; 736 } 737 738 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 739 740 return status; 741 } 742 743 /* 744 * Set capture duration from the provided configuration into cfr_rcc_param. 745 * All fixed parameters are needed to be stored into cfr_rcc_param. 746 */ 747 748 QDF_STATUS 749 ucfg_cfr_set_capture_duration(struct wlan_objmgr_vdev *vdev, 750 struct cfr_wlanconfig_param *params) 751 { 752 struct pdev_cfr *pcfr = NULL; 753 struct wlan_objmgr_pdev *pdev = NULL; 754 QDF_STATUS status = QDF_STATUS_SUCCESS; 755 756 status = dev_sanity_check(vdev, &pdev, &pcfr); 757 if (status != QDF_STATUS_SUCCESS) 758 return status; 759 760 if (pcfr->rcc_param.capture_interval && 761 (params->cap_dur > pcfr->rcc_param.capture_interval)) { 762 cfr_err("Capture duration is exceeding capture interval"); 763 status = QDF_STATUS_E_INVAL; 764 } else { 765 pcfr->rcc_param.capture_duration = params->cap_dur; 766 } 767 768 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 769 770 return status; 771 } 772 773 /* 774 * Copy user provided group parameters( type/ subtype of mgmt, ctrl, data ) 775 * into curr_cfg instance of ta_ra_cfr_cfg. 776 * Set valid mask for the provided configuration. 777 * Set modified_in_curr_session for the particular group. 778 */ 779 780 QDF_STATUS 781 ucfg_cfr_set_frame_type_subtype(struct wlan_objmgr_vdev *vdev, 782 struct cfr_wlanconfig_param *params) 783 { 784 struct pdev_cfr *pcfr = NULL; 785 struct wlan_objmgr_pdev *pdev = NULL; 786 struct ta_ra_cfr_cfg *curr_cfg = NULL; 787 QDF_STATUS status = QDF_STATUS_SUCCESS; 788 789 status = dev_sanity_check(vdev, &pdev, &pcfr); 790 if (status != QDF_STATUS_SUCCESS) 791 return status; 792 793 /* Populating current config based on user's input */ 794 curr_cfg = &pcfr->rcc_param.curr[params->grp_id]; 795 curr_cfg->mgmt_subtype_filter = params->expected_mgmt_subtype; 796 curr_cfg->ctrl_subtype_filter = params->expected_ctrl_subtype; 797 curr_cfg->data_subtype_filter = params->expected_data_subtype; 798 799 curr_cfg->valid_mgmt_subtype = 1; 800 curr_cfg->valid_ctrl_subtype = 1; 801 curr_cfg->valid_data_subtype = 1; 802 803 qdf_set_bit(params->grp_id, 804 &pcfr->rcc_param.modified_in_curr_session); 805 806 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 807 808 return status; 809 } 810 811 /* 812 * Copy user provided group parameters( BW and NSS ) 813 * into curr_cfg instance of ta_ra_cfr_cfg. 814 * Set valid mask for the provided configuration. 815 * Set modified_in_curr_session for the particular group. 816 */ 817 818 QDF_STATUS ucfg_cfr_set_bw_nss(struct wlan_objmgr_vdev *vdev, 819 struct cfr_wlanconfig_param *params) 820 { 821 struct pdev_cfr *pcfr = NULL; 822 struct wlan_objmgr_pdev *pdev = NULL; 823 struct ta_ra_cfr_cfg *curr_cfg = NULL; 824 QDF_STATUS status = QDF_STATUS_SUCCESS; 825 826 status = dev_sanity_check(vdev, &pdev, &pcfr); 827 if (status != QDF_STATUS_SUCCESS) 828 return status; 829 830 /* Populating current config based on user's input */ 831 curr_cfg = &pcfr->rcc_param.curr[params->grp_id]; 832 curr_cfg->bw = params->bw; 833 curr_cfg->nss = params->nss; 834 835 curr_cfg->valid_bw_mask = 1; 836 curr_cfg->valid_nss_mask = 1; 837 838 qdf_set_bit(params->grp_id, 839 &pcfr->rcc_param.modified_in_curr_session); 840 841 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 842 843 return status; 844 } 845 846 /* 847 * Copy user provided group parameters( TA, RA, TA_MASK, RA_MASK ) 848 * into curr_cfg instance of ta_ra_cfr_cfg. 849 * Set valid mask for the provided configuration. 850 * Set modified_in_curr_session for the particular group. 851 */ 852 853 QDF_STATUS ucfg_cfr_set_tara_config(struct wlan_objmgr_vdev *vdev, 854 struct cfr_wlanconfig_param *params) 855 { 856 struct pdev_cfr *pcfr = NULL; 857 struct wlan_objmgr_pdev *pdev = NULL; 858 struct ta_ra_cfr_cfg *curr_cfg = NULL; 859 QDF_STATUS status = QDF_STATUS_SUCCESS; 860 861 status = dev_sanity_check(vdev, &pdev, &pcfr); 862 if (status != QDF_STATUS_SUCCESS) 863 return status; 864 865 curr_cfg = &pcfr->rcc_param.curr[params->grp_id]; 866 qdf_mem_copy(curr_cfg->tx_addr, params->ta, QDF_MAC_ADDR_SIZE); 867 qdf_mem_copy(curr_cfg->rx_addr, params->ra, QDF_MAC_ADDR_SIZE); 868 qdf_mem_copy(curr_cfg->tx_addr_mask, 869 params->ta_mask, QDF_MAC_ADDR_SIZE); 870 qdf_mem_copy(curr_cfg->rx_addr_mask, 871 params->ra_mask, QDF_MAC_ADDR_SIZE); 872 873 curr_cfg->valid_ta = 1; 874 curr_cfg->valid_ta_mask = 1; 875 curr_cfg->valid_ra = 1; 876 curr_cfg->valid_ra_mask = 1; 877 878 qdf_set_bit(params->grp_id, 879 &pcfr->rcc_param.modified_in_curr_session); 880 881 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 882 883 return status; 884 } 885 886 QDF_STATUS ucfg_cfr_get_cfg(struct wlan_objmgr_vdev *vdev) 887 { 888 struct pdev_cfr *pcfr = NULL; 889 struct wlan_objmgr_pdev *pdev = NULL; 890 struct ta_ra_cfr_cfg *glbl_cfg = NULL; 891 QDF_STATUS status = QDF_STATUS_SUCCESS; 892 uint8_t grp_id; 893 894 status = dev_sanity_check(vdev, &pdev, &pcfr); 895 if (status != QDF_STATUS_SUCCESS) 896 return status; 897 if (!cfr_is_filter_enabled(&pcfr->rcc_param)) { 898 cfr_err(" All RCC modes are disabled"); 899 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 900 return status; 901 } 902 903 cfr_err("CAPTURE MODE:\n"); 904 905 cfr_err("m_directed_ftm is : %s\n", 906 pcfr->rcc_param.m_directed_ftm ? 907 "enabled" : "disabled"); 908 cfr_err("m_all_ftm_ack is : %s\n", 909 pcfr->rcc_param.m_all_ftm_ack ? 910 "enabled" : "disabled"); 911 cfr_err("m_ndpa_ndp_directed is: %s\n", 912 pcfr->rcc_param.m_ndpa_ndp_directed ? 913 "enabled" : "disabled"); 914 cfr_err("m_ndpa_ndp_all is : %s\n", 915 pcfr->rcc_param.m_ndpa_ndp_all ? 916 "enabled" : "disabled"); 917 cfr_err("m_ta_ra_filter is : %s\n", 918 pcfr->rcc_param.m_ta_ra_filter ? 919 "enabled" : "disabled"); 920 cfr_err("m_all_packet is : %s\n", 921 pcfr->rcc_param.m_all_packet ? 922 "enabled" : "disabled"); 923 924 cfr_err("capture duration : %u usec\n", 925 pcfr->rcc_param.capture_duration); 926 cfr_err("capture interval : %u usec\n", 927 pcfr->rcc_param.capture_interval); 928 cfr_err("capture count : %u\n", 929 pcfr->rcc_param.capture_count); 930 cfr_err("capture interval mode sel : %u\n", 931 pcfr->rcc_param.capture_intval_mode_sel); 932 cfr_err("UL MU User mask lower : %u\n", 933 pcfr->rcc_param.ul_mu_user_mask_lower); 934 cfr_err("UL MU User mask upper : %u\n", 935 pcfr->rcc_param.ul_mu_user_mask_upper); 936 cfr_err("Freeze TLV delay count is : %s\n", 937 pcfr->rcc_param.freeze_tlv_delay_cnt_en ? 938 "enabled" : "disabled"); 939 cfr_err("Freeze TLV delay count threshold : %u\n", 940 pcfr->rcc_param.freeze_tlv_delay_cnt_thr); 941 cfr_err("Enabled CFG id bitmap : 0x%x\n", 942 pcfr->rcc_param.filter_group_bitmap); 943 cfr_err(" Modified cfg id bitmap : %lu\n", 944 pcfr->rcc_param.modified_in_curr_session); 945 946 cfr_err("TARA_CONFIG details:\n"); 947 948 for (grp_id = 0; grp_id < MAX_TA_RA_ENTRIES; grp_id++) { 949 glbl_cfg = &pcfr->global[grp_id]; 950 951 cfr_err("Config ID: %d\n", grp_id); 952 cfr_err("Bandwidth :0x%x\n", glbl_cfg->bw); 953 cfr_err("NSS : 0x%x\n", glbl_cfg->nss); 954 cfr_err("valid_ta: %d\n", glbl_cfg->valid_ta); 955 cfr_err("valid_ta_mask: %d\n", glbl_cfg->valid_ta_mask); 956 cfr_err("valid_ra: %d\n", glbl_cfg->valid_ra); 957 cfr_err("valid_ra_mask: %d\n", glbl_cfg->valid_ra_mask); 958 cfr_err("valid_bw_mask: %d\n", glbl_cfg->valid_bw_mask); 959 cfr_err("valid_nss_mask: %d\n", glbl_cfg->valid_nss_mask); 960 cfr_err("valid_mgmt_subtype: %d\n", 961 glbl_cfg->valid_mgmt_subtype); 962 cfr_err("valid_ctrl_subtype: %d\n", 963 glbl_cfg->valid_ctrl_subtype); 964 cfr_err("valid_data_subtype: %d\n", 965 glbl_cfg->valid_data_subtype); 966 cfr_err("Mgmt subtype : 0x%x\n", 967 glbl_cfg->mgmt_subtype_filter); 968 cfr_err("CTRL subtype : 0x%x\n", 969 glbl_cfg->ctrl_subtype_filter); 970 cfr_err("Data subtype : 0x%x\n", 971 glbl_cfg->data_subtype_filter); 972 cfr_err("TX Addr: " QDF_MAC_ADDR_FMT, 973 QDF_MAC_ADDR_REF(glbl_cfg->tx_addr)); 974 cfr_err("TX Addr Mask: " QDF_FULL_MAC_FMT, 975 QDF_FULL_MAC_REF(glbl_cfg->tx_addr_mask)); 976 cfr_err("RX Addr: " QDF_MAC_ADDR_FMT, 977 QDF_MAC_ADDR_REF(glbl_cfg->rx_addr)); 978 cfr_err("RX Addr Mask: " QDF_FULL_MAC_FMT, 979 QDF_FULL_MAC_REF(glbl_cfg->rx_addr_mask)); 980 } 981 982 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 983 984 return status; 985 } 986 987 static const char *chan_capture_status_to_str(enum chan_capture_status type) 988 { 989 switch (type) { 990 case CAPTURE_IDLE: 991 return "CAPTURE_IDLE"; 992 case CAPTURE_BUSY: 993 return "CAPTURE_BUSY"; 994 case CAPTURE_ACTIVE: 995 return "CAPTURE_ACTIVE"; 996 case CAPTURE_NO_BUFFER: 997 return "CAPTURE_NO_BUFFER"; 998 default: 999 return "INVALID"; 1000 } 1001 } 1002 1003 static const 1004 char *mac_freeze_reason_to_str(enum mac_freeze_capture_reason type) 1005 { 1006 switch (type) { 1007 case FREEZE_REASON_TM: 1008 return "FREEZE_REASON_TM"; 1009 case FREEZE_REASON_FTM: 1010 return "FREEZE_REASON_FTM"; 1011 case FREEZE_REASON_ACK_RESP_TO_TM_FTM: 1012 return "FREEZE_REASON_ACK_RESP_TO_TM_FTM"; 1013 case FREEZE_REASON_TA_RA_TYPE_FILTER: 1014 return "FREEZE_REASON_TA_RA_TYPE_FILTER"; 1015 case FREEZE_REASON_NDPA_NDP: 1016 return "FREEZE_REASON_NDPA_NDP"; 1017 case FREEZE_REASON_ALL_PACKET: 1018 return "FREEZE_REASON_ALL_PACKET"; 1019 default: 1020 return "INVALID"; 1021 } 1022 } 1023 1024 QDF_STATUS ucfg_cfr_rcc_dump_dbg_counters(struct wlan_objmgr_vdev *vdev) 1025 { 1026 struct pdev_cfr *pcfr = NULL; 1027 struct wlan_objmgr_pdev *pdev = NULL; 1028 struct wlan_objmgr_psoc *psoc = NULL; 1029 struct cdp_cfr_rcc_stats *cfr_rcc_stats = NULL; 1030 uint8_t stats_cnt; 1031 QDF_STATUS status = QDF_STATUS_SUCCESS; 1032 1033 status = dev_sanity_check(vdev, &pdev, &pcfr); 1034 if (status != QDF_STATUS_SUCCESS) 1035 return status; 1036 1037 psoc = wlan_pdev_get_psoc(pdev); 1038 if (!psoc) { 1039 cfr_err("psoc is null!"); 1040 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1041 return QDF_STATUS_E_NULL_VALUE; 1042 } 1043 1044 cfr_err("total_tx_evt_cnt = %llu\n", 1045 pcfr->total_tx_evt_cnt); 1046 cfr_err("dbr_evt_cnt = %llu\n", 1047 pcfr->dbr_evt_cnt); 1048 cfr_err("rx_tlv_evt_cnt = %llu\n", 1049 pcfr->rx_tlv_evt_cnt); 1050 cfr_err("release_cnt = %llu\n", 1051 pcfr->release_cnt); 1052 cfr_err("Error cnt:\n"); 1053 cfr_err("flush_dbr_cnt = %llu\n", 1054 pcfr->flush_dbr_cnt); 1055 cfr_err("invalid_dma_length_cnt = %llu\n", 1056 pcfr->invalid_dma_length_cnt); 1057 cfr_err("flush_timeout_dbr_cnt = %llu\n", 1058 pcfr->flush_timeout_dbr_cnt); 1059 cfr_err("tx_peer_status_cfr_fail = %llu\n", 1060 pcfr->tx_peer_status_cfr_fail); 1061 cfr_err("tx_evt_status_cfr_fail = %llu\n", 1062 pcfr->tx_evt_status_cfr_fail); 1063 cfr_err("tx_dbr_cookie_lookup_fail = %llu\n", 1064 pcfr->tx_dbr_cookie_lookup_fail); 1065 cfr_err("PPDU id mismatch for same cookie:\n"); 1066 cfr_err("clear_txrx_event = %llu\n", 1067 pcfr->clear_txrx_event); 1068 cfr_err("cfr_dma_aborts = %llu\n", 1069 pcfr->cfr_dma_aborts); 1070 1071 cfr_rcc_stats = qdf_mem_malloc(sizeof(struct cdp_cfr_rcc_stats)); 1072 if (!cfr_rcc_stats) { 1073 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1074 return QDF_STATUS_E_NOMEM; 1075 } 1076 1077 cdp_get_cfr_dbg_stats(wlan_psoc_get_dp_handle(psoc), 1078 wlan_objmgr_pdev_get_pdev_id(pdev), 1079 cfr_rcc_stats); 1080 1081 cfr_err("bb_captured_channel_cnt: %llu\n", 1082 cfr_rcc_stats->bb_captured_channel_cnt); 1083 cfr_err("bb_captured_timeout_cnt: %llu\n", 1084 cfr_rcc_stats->bb_captured_timeout_cnt); 1085 cfr_err("rx_loc_info_valid_cnt: %llu\n", 1086 cfr_rcc_stats->rx_loc_info_valid_cnt); 1087 1088 cfr_err("Channel capture status:\n"); 1089 for (stats_cnt = 0; stats_cnt < CAPTURE_MAX; stats_cnt++) { 1090 cfr_err("%s = %llu\n", 1091 chan_capture_status_to_str(stats_cnt), 1092 cfr_rcc_stats->chan_capture_status[stats_cnt]); 1093 } 1094 1095 cfr_err("Freeze reason:\n"); 1096 for (stats_cnt = 0; stats_cnt < FREEZE_REASON_MAX; stats_cnt++) { 1097 cfr_err("%s = %llu\n", 1098 mac_freeze_reason_to_str(stats_cnt), 1099 cfr_rcc_stats->reason_cnt[stats_cnt]); 1100 } 1101 1102 qdf_mem_free(cfr_rcc_stats); 1103 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1104 1105 return status; 1106 } 1107 1108 QDF_STATUS ucfg_cfr_rcc_clr_dbg_counters(struct wlan_objmgr_vdev *vdev) 1109 { 1110 struct pdev_cfr *pcfr = NULL; 1111 struct wlan_objmgr_pdev *pdev = NULL; 1112 struct wlan_objmgr_psoc *psoc = NULL; 1113 QDF_STATUS status = QDF_STATUS_SUCCESS; 1114 1115 status = dev_sanity_check(vdev, &pdev, &pcfr); 1116 if (status != QDF_STATUS_SUCCESS) 1117 return status; 1118 1119 psoc = wlan_pdev_get_psoc(pdev); 1120 if (!psoc) { 1121 cfr_err("psoc is null!"); 1122 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1123 return QDF_STATUS_E_NULL_VALUE; 1124 } 1125 cdp_cfr_clr_dbg_stats(wlan_psoc_get_dp_handle(psoc), 1126 wlan_objmgr_pdev_get_pdev_id(pdev)); 1127 1128 pcfr->dbr_evt_cnt = 0; 1129 pcfr->release_cnt = 0; 1130 pcfr->total_tx_evt_cnt = 0; 1131 pcfr->rx_tlv_evt_cnt = 0; 1132 pcfr->flush_dbr_cnt = 0; 1133 pcfr->flush_timeout_dbr_cnt = 0; 1134 pcfr->invalid_dma_length_cnt = 0; 1135 pcfr->clear_txrx_event = 0; 1136 pcfr->cfr_dma_aborts = 0; 1137 pcfr->tx_peer_status_cfr_fail = 0; 1138 pcfr->tx_evt_status_cfr_fail = 0; 1139 pcfr->tx_dbr_cookie_lookup_fail = 0; 1140 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1141 1142 return status; 1143 } 1144 1145 QDF_STATUS ucfg_cfr_rcc_dump_lut(struct wlan_objmgr_vdev *vdev) 1146 { 1147 struct wlan_objmgr_pdev *pdev = NULL; 1148 QDF_STATUS status = QDF_STATUS_SUCCESS; 1149 1150 if (!vdev) { 1151 cfr_err("vdev is NULL"); 1152 return QDF_STATUS_E_INVAL; 1153 } 1154 1155 pdev = wlan_vdev_get_pdev(vdev); 1156 if (!pdev) { 1157 cfr_err("pdev is NULL"); 1158 return QDF_STATUS_E_INVAL; 1159 } 1160 1161 if (wlan_objmgr_pdev_try_get_ref(pdev, WLAN_CFR_ID) != 1162 QDF_STATUS_SUCCESS) { 1163 return QDF_STATUS_E_INVAL; 1164 } 1165 1166 cfr_err("LUT table:"); 1167 tgt_cfr_dump_lut_enh(pdev); 1168 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1169 1170 return status; 1171 } 1172 1173 static void cfr_set_filter(struct wlan_objmgr_pdev *pdev, bool enable, 1174 struct cdp_monitor_filter *filter_val) 1175 { 1176 struct wlan_objmgr_psoc *psoc = wlan_pdev_get_psoc(pdev); 1177 1178 cfr_info("pdev_id=%d\n", wlan_objmgr_pdev_get_pdev_id(pdev)); 1179 1180 cdp_cfr_filter(wlan_psoc_get_dp_handle(psoc), 1181 wlan_objmgr_pdev_get_pdev_id(pdev), 1182 enable, 1183 filter_val); 1184 } 1185 1186 #ifdef WLAN_ENH_CFR_ENABLE 1187 /* 1188 * With the initiation of commit command, this handler will be triggered. 1189 * 1190 * Starts the procedure of forming the TLVs. 1191 * If Host succeeds to send WMI command to FW, after TLV processing, then it 1192 * will save the previous CFR configurations into one instance ta_ra_cfr_cfg, 1193 * called glbl_cfg and update the current config to default state for the 1194 * next commit session. 1195 * 1196 * Finally, reset the counter (modified_in_curr_session) to 0 before moving to 1197 * next commit session. 1198 * 1199 */ 1200 1201 QDF_STATUS ucfg_cfr_committed_rcc_config(struct wlan_objmgr_vdev *vdev) 1202 { 1203 struct pdev_cfr *pcfr = NULL; 1204 struct wlan_objmgr_pdev *pdev = NULL; 1205 struct wlan_objmgr_psoc *psoc = NULL; 1206 QDF_STATUS status = QDF_STATUS_SUCCESS; 1207 struct cdp_monitor_filter filter_val = {0}; 1208 1209 status = dev_sanity_check(vdev, &pdev, &pcfr); 1210 if (status != QDF_STATUS_SUCCESS) 1211 return status; 1212 1213 psoc = wlan_pdev_get_psoc(pdev); 1214 1215 if (!psoc) { 1216 cfr_err("psoc is null!"); 1217 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1218 return QDF_STATUS_E_NULL_VALUE; 1219 } 1220 1221 pcfr->rcc_param.vdev_id = wlan_vdev_get_id(vdev); 1222 1223 /* 1224 * If capture mode is valid, then Host: 1225 * Subscribes for PPDU status TLVs in monitor status ring. 1226 * Sets filter type to either FP or MO, based on the capture mode. 1227 * Starts the LUT_AGE_TIMER of 1sec. 1228 * 1229 * If capture mode is disabled, then Host: 1230 * unsubscribes for PPDU status TLVs in monitor status ring. 1231 * Sets filter type to 0. 1232 * Stops the LUT_AGE_TIMER. 1233 * 1234 */ 1235 1236 if (cfr_is_filter_enabled(&pcfr->rcc_param)) { 1237 if (pcfr->cfr_timer_enable) { 1238 cfr_err("Not allowed: Periodic capture is enabled.\n"); 1239 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1240 return QDF_STATUS_E_NOSUPPORT; 1241 } 1242 1243 if (pcfr->rcc_param.m_all_ftm_ack) { 1244 filter_val.mode |= MON_FILTER_PASS | 1245 MON_FILTER_OTHER; 1246 filter_val.fp_mgmt |= FILTER_MGMT_ACTION; 1247 filter_val.mo_mgmt |= FILTER_MGMT_ACTION; 1248 } 1249 1250 if (pcfr->rcc_param.m_ndpa_ndp_all) { 1251 filter_val.mode |= MON_FILTER_PASS | 1252 MON_FILTER_OTHER; 1253 filter_val.fp_ctrl |= FILTER_CTRL_VHT_NDP; 1254 filter_val.mo_ctrl |= FILTER_CTRL_VHT_NDP; 1255 } 1256 1257 if (pcfr->rcc_param.m_all_packet) { 1258 filter_val.mode |= MON_FILTER_PASS | 1259 MON_FILTER_OTHER; 1260 filter_val.fp_mgmt |= FILTER_MGMT_ALL; 1261 filter_val.mo_mgmt |= FILTER_MGMT_ALL; 1262 filter_val.fp_ctrl |= FILTER_CTRL_ALL; 1263 filter_val.mo_ctrl |= FILTER_CTRL_ALL; 1264 filter_val.fp_data |= FILTER_DATA_ALL; 1265 filter_val.mo_data |= FILTER_DATA_ALL; 1266 } 1267 1268 /* 1269 * M_TA_RA in monitor other is as intensive as M_ALL pkt 1270 * Support only FP in M_TA_RA mode 1271 */ 1272 if (pcfr->rcc_param.m_ta_ra_filter) { 1273 filter_val.mode |= MON_FILTER_PASS | 1274 MON_FILTER_OTHER; 1275 filter_val.fp_mgmt |= FILTER_MGMT_ALL; 1276 filter_val.mo_mgmt |= FILTER_MGMT_ALL; 1277 filter_val.fp_ctrl |= FILTER_CTRL_ALL; 1278 filter_val.mo_ctrl |= FILTER_CTRL_ALL; 1279 filter_val.fp_data |= FILTER_DATA_ALL; 1280 filter_val.mo_data |= FILTER_DATA_ALL; 1281 } 1282 1283 if (pcfr->rcc_param.m_directed_ftm) { 1284 filter_val.mode |= MON_FILTER_PASS; 1285 filter_val.fp_mgmt |= FILTER_MGMT_ACTION; 1286 } 1287 1288 if (pcfr->rcc_param.m_ndpa_ndp_directed) { 1289 filter_val.mode |= MON_FILTER_PASS; 1290 filter_val.fp_ctrl |= FILTER_CTRL_VHT_NDP; 1291 } 1292 1293 if (!cdp_get_cfr_rcc(wlan_psoc_get_dp_handle(psoc), 1294 wlan_objmgr_pdev_get_pdev_id(pdev))) 1295 tgt_cfr_start_lut_age_timer(pdev); 1296 cfr_set_filter(pdev, 1, &filter_val); 1297 } else { 1298 if (cdp_get_cfr_rcc(wlan_psoc_get_dp_handle(psoc), 1299 wlan_objmgr_pdev_get_pdev_id(pdev))) 1300 tgt_cfr_stop_lut_age_timer(pdev); 1301 cfr_set_filter(pdev, 0, &filter_val); 1302 } 1303 1304 /* Trigger wmi to start the TLV processing. */ 1305 status = tgt_cfr_config_rcc(pdev, &pcfr->rcc_param); 1306 if (status == QDF_STATUS_SUCCESS) { 1307 cfr_info("CFR commit done\n"); 1308 /* Update global config */ 1309 tgt_cfr_update_global_cfg(pdev); 1310 1311 /* Bring curr_cfg to default state for next commit session */ 1312 tgt_cfr_default_ta_ra_cfg(pdev, &pcfr->rcc_param, 1313 false, MAX_RESET_CFG_ENTRY); 1314 } else { 1315 cfr_err("CFR commit failed"); 1316 } 1317 1318 pcfr->rcc_param.num_grp_tlvs = 0; 1319 pcfr->rcc_param.modified_in_curr_session = 0; 1320 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1321 1322 return status; 1323 } 1324 1325 /* 1326 * This handler is used to enable / disable the capture mode. 1327 * 1328 */ 1329 QDF_STATUS ucfg_cfr_set_rcc_mode(struct wlan_objmgr_vdev *vdev, 1330 enum capture_type mode, uint8_t value) 1331 { 1332 struct pdev_cfr *pcfr = NULL; 1333 struct wlan_objmgr_pdev *pdev = NULL; 1334 QDF_STATUS status = QDF_STATUS_SUCCESS; 1335 1336 status = dev_sanity_check(vdev, &pdev, &pcfr); 1337 if (status != QDF_STATUS_SUCCESS) 1338 return status; 1339 1340 switch (mode) { 1341 case RCC_DIRECTED_FTM_FILTER: 1342 pcfr->rcc_param.m_directed_ftm = value; 1343 break; 1344 case RCC_ALL_FTM_ACK_FILTER: 1345 pcfr->rcc_param.m_all_ftm_ack = value; 1346 break; 1347 case RCC_DIRECTED_NDPA_NDP_FILTER: 1348 pcfr->rcc_param.m_ndpa_ndp_directed = value; 1349 break; 1350 case RCC_NDPA_NDP_ALL_FILTER: 1351 pcfr->rcc_param.m_ndpa_ndp_all = value; 1352 break; 1353 case RCC_TA_RA_FILTER: 1354 pcfr->rcc_param.m_ta_ra_filter = value; 1355 break; 1356 case RCC_ALL_PACKET_FILTER: 1357 pcfr->rcc_param.m_all_packet = value; 1358 break; 1359 case RCC_DIS_ALL_MODE: 1360 pcfr->rcc_param.m_directed_ftm = value; 1361 pcfr->rcc_param.m_all_ftm_ack = value; 1362 pcfr->rcc_param.m_ndpa_ndp_directed = value; 1363 pcfr->rcc_param.m_ndpa_ndp_all = value; 1364 pcfr->rcc_param.m_ta_ra_filter = value; 1365 pcfr->rcc_param.m_all_packet = value; 1366 break; 1367 1368 default: 1369 break; 1370 } 1371 1372 cfr_debug("<CFR_UMAC> Capture mode set by user: 0x%x\n", value); 1373 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1374 1375 return status; 1376 } 1377 #endif 1378 1379 bool ucfg_cfr_get_rcc_enabled(struct wlan_objmgr_vdev *vdev) 1380 { 1381 struct pdev_cfr *pcfr = NULL; 1382 struct wlan_objmgr_pdev *pdev = NULL; 1383 QDF_STATUS status = QDF_STATUS_SUCCESS; 1384 bool rcc_enabled = false; 1385 1386 status = dev_sanity_check(vdev, &pdev, &pcfr); 1387 if (status != QDF_STATUS_SUCCESS) 1388 return false; 1389 1390 rcc_enabled = cfr_is_filter_enabled(&pcfr->rcc_param); 1391 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1392 1393 return rcc_enabled; 1394 } 1395 1396 #ifdef WLAN_ENH_CFR_ENABLE 1397 QDF_STATUS ucfg_cfr_subscribe_ppdu_desc(struct wlan_objmgr_pdev *pdev, 1398 bool is_subscribe) 1399 { 1400 return tgt_cfr_subscribe_ppdu_desc(pdev, is_subscribe); 1401 } 1402 #endif 1403 1404 #endif 1405