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->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_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_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->Reserved = 0; 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_this_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 (unsigned long *) 805 &pcfr->rcc_param.modified_in_curr_session); 806 807 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 808 809 return status; 810 } 811 812 /* 813 * Copy user provided group parameters( BW and NSS ) 814 * into curr_cfg instance of ta_ra_cfr_cfg. 815 * Set valid mask for the provided configuration. 816 * Set modified_in_this_session for the particular group. 817 */ 818 819 QDF_STATUS ucfg_cfr_set_bw_nss(struct wlan_objmgr_vdev *vdev, 820 struct cfr_wlanconfig_param *params) 821 { 822 struct pdev_cfr *pcfr = NULL; 823 struct wlan_objmgr_pdev *pdev = NULL; 824 struct ta_ra_cfr_cfg *curr_cfg = NULL; 825 QDF_STATUS status = QDF_STATUS_SUCCESS; 826 827 status = dev_sanity_check(vdev, &pdev, &pcfr); 828 if (status != QDF_STATUS_SUCCESS) 829 return status; 830 831 /* Populating current config based on user's input */ 832 curr_cfg = &pcfr->rcc_param.curr[params->grp_id]; 833 curr_cfg->bw = params->bw; 834 curr_cfg->nss = params->nss; 835 836 curr_cfg->valid_bw_mask = 1; 837 curr_cfg->valid_nss_mask = 1; 838 839 qdf_set_bit(params->grp_id, 840 (unsigned long *)&pcfr->rcc_param.modified_in_curr_session); 841 842 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 843 844 return status; 845 } 846 847 /* 848 * Copy user provided group parameters( TA, RA, TA_MASK, RA_MASK ) 849 * into curr_cfg instance of ta_ra_cfr_cfg. 850 * Set valid mask for the provided configuration. 851 * Set modified_in_this_session for the particular group. 852 */ 853 854 QDF_STATUS ucfg_cfr_set_tara_config(struct wlan_objmgr_vdev *vdev, 855 struct cfr_wlanconfig_param *params) 856 { 857 struct pdev_cfr *pcfr = NULL; 858 struct wlan_objmgr_pdev *pdev = NULL; 859 struct ta_ra_cfr_cfg *curr_cfg = NULL; 860 QDF_STATUS status = QDF_STATUS_SUCCESS; 861 862 status = dev_sanity_check(vdev, &pdev, &pcfr); 863 if (status != QDF_STATUS_SUCCESS) 864 return status; 865 866 curr_cfg = &pcfr->rcc_param.curr[params->grp_id]; 867 qdf_mem_copy(curr_cfg->tx_addr, params->ta, QDF_MAC_ADDR_SIZE); 868 qdf_mem_copy(curr_cfg->rx_addr, params->ra, QDF_MAC_ADDR_SIZE); 869 qdf_mem_copy(curr_cfg->tx_addr_mask, 870 params->ta_mask, QDF_MAC_ADDR_SIZE); 871 qdf_mem_copy(curr_cfg->rx_addr_mask, 872 params->ra_mask, QDF_MAC_ADDR_SIZE); 873 874 curr_cfg->valid_ta = 1; 875 curr_cfg->valid_ta_mask = 1; 876 curr_cfg->valid_ra = 1; 877 curr_cfg->valid_ra_mask = 1; 878 879 qdf_set_bit(params->grp_id, 880 (unsigned long *) 881 &pcfr->rcc_param.modified_in_curr_session); 882 883 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 884 885 return status; 886 } 887 888 QDF_STATUS ucfg_cfr_get_cfg(struct wlan_objmgr_vdev *vdev) 889 { 890 struct pdev_cfr *pcfr = NULL; 891 struct wlan_objmgr_pdev *pdev = NULL; 892 struct ta_ra_cfr_cfg *glbl_cfg = NULL; 893 QDF_STATUS status = QDF_STATUS_SUCCESS; 894 uint8_t grp_id; 895 896 status = dev_sanity_check(vdev, &pdev, &pcfr); 897 if (status != QDF_STATUS_SUCCESS) 898 return status; 899 if (!cfr_is_filter_enabled(&pcfr->rcc_param)) { 900 cfr_err(" All RCC modes are disabled"); 901 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 902 return status; 903 } 904 905 cfr_err("CAPTURE MODE:\n"); 906 907 cfr_err("m_directed_ftm is : %s\n", 908 pcfr->rcc_param.m_directed_ftm ? 909 "enabled" : "disabled"); 910 cfr_err("m_all_ftm_ack is : %s\n", 911 pcfr->rcc_param.m_all_ftm_ack ? 912 "enabled" : "disabled"); 913 cfr_err("m_ndpa_ndp_directed is: %s\n", 914 pcfr->rcc_param.m_ndpa_ndp_directed ? 915 "enabled" : "disabled"); 916 cfr_err("m_ndpa_ndp_all is : %s\n", 917 pcfr->rcc_param.m_ndpa_ndp_all ? 918 "enabled" : "disabled"); 919 cfr_err("m_ta_ra_filter is : %s\n", 920 pcfr->rcc_param.m_ta_ra_filter ? 921 "enabled" : "disabled"); 922 cfr_err("m_all_packet is : %s\n", 923 pcfr->rcc_param.m_all_packet ? 924 "enabled" : "disabled"); 925 926 cfr_err("capture duration : %u usec\n", 927 pcfr->rcc_param.capture_duration); 928 cfr_err("capture interval : %u usec\n", 929 pcfr->rcc_param.capture_interval); 930 cfr_err("capture count : %u\n", 931 pcfr->rcc_param.capture_count); 932 cfr_err("capture interval mode sel : %u\n", 933 pcfr->rcc_param.capture_intval_mode_sel); 934 cfr_err("UL MU User mask lower : %u\n", 935 pcfr->rcc_param.ul_mu_user_mask_lower); 936 cfr_err("UL MU User mask upper : %u\n", 937 pcfr->rcc_param.ul_mu_user_mask_upper); 938 cfr_err("Freeze TLV delay count is : %s\n", 939 pcfr->rcc_param.freeze_tlv_delay_cnt_en ? 940 "enabled" : "disabled"); 941 cfr_err("Freeze TLV delay count threshold : %u\n", 942 pcfr->rcc_param.freeze_tlv_delay_cnt_thr); 943 cfr_err("Enabled CFG id bitmap : 0x%x\n", 944 pcfr->rcc_param.filter_group_bitmap); 945 cfr_err(" Modified cfg id bitmap : 0x%x\n", 946 pcfr->rcc_param.modified_in_curr_session); 947 948 cfr_err("TARA_CONFIG details:\n"); 949 950 for (grp_id = 0; grp_id < MAX_TA_RA_ENTRIES; grp_id++) { 951 glbl_cfg = &pcfr->global[grp_id]; 952 953 cfr_err("Config ID: %d\n", grp_id); 954 cfr_err("Bandwidth :0x%x\n", glbl_cfg->bw); 955 cfr_err("NSS : 0x%x\n", glbl_cfg->nss); 956 cfr_err("valid_ta: %d\n", glbl_cfg->valid_ta); 957 cfr_err("valid_ta_mask: %d\n", glbl_cfg->valid_ta_mask); 958 cfr_err("valid_ra: %d\n", glbl_cfg->valid_ra); 959 cfr_err("valid_ra_mask: %d\n", glbl_cfg->valid_ra_mask); 960 cfr_err("valid_bw_mask: %d\n", glbl_cfg->valid_bw_mask); 961 cfr_err("valid_nss_mask: %d\n", glbl_cfg->valid_nss_mask); 962 cfr_err("valid_mgmt_subtype: %d\n", 963 glbl_cfg->valid_mgmt_subtype); 964 cfr_err("valid_ctrl_subtype: %d\n", 965 glbl_cfg->valid_ctrl_subtype); 966 cfr_err("valid_data_subtype: %d\n", 967 glbl_cfg->valid_data_subtype); 968 cfr_err("Mgmt subtype : 0x%x\n", 969 glbl_cfg->mgmt_subtype_filter); 970 cfr_err("CTRL subtype : 0x%x\n", 971 glbl_cfg->ctrl_subtype_filter); 972 cfr_err("Data subtype : 0x%x\n", 973 glbl_cfg->data_subtype_filter); 974 cfr_err("TX Addr: " QDF_MAC_ADDR_STR, 975 QDF_MAC_ADDR_ARRAY(glbl_cfg->tx_addr)); 976 cfr_err("TX Addr Mask: " QDF_MAC_ADDR_STR, 977 QDF_MAC_ADDR_ARRAY(glbl_cfg->tx_addr_mask)); 978 cfr_err("RX Addr: " QDF_MAC_ADDR_STR, 979 QDF_MAC_ADDR_ARRAY(glbl_cfg->rx_addr)); 980 cfr_err("RX Addr Mask: " QDF_MAC_ADDR_STR, 981 QDF_MAC_ADDR_ARRAY(glbl_cfg->rx_addr_mask)); 982 } 983 984 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 985 986 return status; 987 } 988 989 static const char *chan_capture_status_to_str(enum chan_capture_status type) 990 { 991 switch (type) { 992 case CAPTURE_IDLE: 993 return "CAPTURE_IDLE"; 994 case CAPTURE_BUSY: 995 return "CAPTURE_BUSY"; 996 case CAPTURE_ACTIVE: 997 return "CAPTURE_ACTIVE"; 998 case CAPTURE_NO_BUFFER: 999 return "CAPTURE_NO_BUFFER"; 1000 default: 1001 return "INVALID"; 1002 } 1003 } 1004 1005 static const 1006 char *mac_freeze_reason_to_str(enum mac_freeze_capture_reason type) 1007 { 1008 switch (type) { 1009 case FREEZE_REASON_TM: 1010 return "FREEZE_REASON_TM"; 1011 case FREEZE_REASON_FTM: 1012 return "FREEZE_REASON_FTM"; 1013 case FREEZE_REASON_ACK_RESP_TO_TM_FTM: 1014 return "FREEZE_REASON_ACK_RESP_TO_TM_FTM"; 1015 case FREEZE_REASON_TA_RA_TYPE_FILTER: 1016 return "FREEZE_REASON_TA_RA_TYPE_FILTER"; 1017 case FREEZE_REASON_NDPA_NDP: 1018 return "FREEZE_REASON_NDPA_NDP"; 1019 case FREEZE_REASON_ALL_PACKET: 1020 return "FREEZE_REASON_ALL_PACKET"; 1021 default: 1022 return "INVALID"; 1023 } 1024 } 1025 1026 QDF_STATUS ucfg_cfr_rcc_dump_dbg_counters(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 struct cdp_cfr_rcc_stats *cfr_rcc_stats = NULL; 1032 uint8_t stats_cnt; 1033 QDF_STATUS status = QDF_STATUS_SUCCESS; 1034 1035 status = dev_sanity_check(vdev, &pdev, &pcfr); 1036 if (status != QDF_STATUS_SUCCESS) 1037 return status; 1038 1039 psoc = wlan_pdev_get_psoc(pdev); 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 cfr_err("total_tx_evt_cnt = %llu\n", 1047 pcfr->total_tx_evt_cnt); 1048 cfr_err("dbr_evt_cnt = %llu\n", 1049 pcfr->dbr_evt_cnt); 1050 cfr_err("rx_tlv_evt_cnt = %llu\n", 1051 pcfr->rx_tlv_evt_cnt); 1052 cfr_err("release_cnt = %llu\n", 1053 pcfr->release_cnt); 1054 cfr_err("Error cnt:\n"); 1055 cfr_err("flush_dbr_cnt = %llu\n", 1056 pcfr->flush_dbr_cnt); 1057 cfr_err("invalid_dma_length_cnt = %llu\n", 1058 pcfr->invalid_dma_length_cnt); 1059 cfr_err("flush_timeout_dbr_cnt = %llu\n", 1060 pcfr->flush_timeout_dbr_cnt); 1061 cfr_err("tx_peer_status_cfr_fail = %llu\n", 1062 pcfr->tx_peer_status_cfr_fail); 1063 cfr_err("tx_evt_status_cfr_fail = %llu\n", 1064 pcfr->tx_evt_status_cfr_fail); 1065 cfr_err("tx_dbr_cookie_lookup_fail = %llu\n", 1066 pcfr->tx_dbr_cookie_lookup_fail); 1067 cfr_err("PPDU id mismatch for same cookie:\n"); 1068 cfr_err("clear_txrx_event = %llu\n", 1069 pcfr->clear_txrx_event); 1070 cfr_err("cfr_dma_aborts = %llu\n", 1071 pcfr->cfr_dma_aborts); 1072 1073 cfr_rcc_stats = qdf_mem_malloc(sizeof(struct cdp_cfr_rcc_stats)); 1074 if (!cfr_rcc_stats) { 1075 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1076 return QDF_STATUS_E_NOMEM; 1077 } 1078 1079 cdp_get_cfr_dbg_stats(wlan_psoc_get_dp_handle(psoc), 1080 wlan_objmgr_pdev_get_pdev_id(pdev), 1081 cfr_rcc_stats); 1082 1083 cfr_err("bb_captured_channel_cnt: %llu\n", 1084 cfr_rcc_stats->bb_captured_channel_cnt); 1085 cfr_err("bb_captured_timeout_cnt: %llu\n", 1086 cfr_rcc_stats->bb_captured_timeout_cnt); 1087 cfr_err("rx_loc_info_valid_cnt: %llu\n", 1088 cfr_rcc_stats->rx_loc_info_valid_cnt); 1089 1090 cfr_err("Channel capture status:\n"); 1091 for (stats_cnt = 0; stats_cnt < CAPTURE_MAX; stats_cnt++) { 1092 cfr_err("%s = %llu\n", 1093 chan_capture_status_to_str(stats_cnt), 1094 cfr_rcc_stats->chan_capture_status[stats_cnt]); 1095 } 1096 1097 cfr_err("Freeze reason:\n"); 1098 for (stats_cnt = 0; stats_cnt < FREEZE_REASON_MAX; stats_cnt++) { 1099 cfr_err("%s = %llu\n", 1100 mac_freeze_reason_to_str(stats_cnt), 1101 cfr_rcc_stats->reason_cnt[stats_cnt]); 1102 } 1103 1104 qdf_mem_free(cfr_rcc_stats); 1105 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1106 1107 return status; 1108 } 1109 1110 QDF_STATUS ucfg_cfr_rcc_clr_dbg_counters(struct wlan_objmgr_vdev *vdev) 1111 { 1112 struct pdev_cfr *pcfr = NULL; 1113 struct wlan_objmgr_pdev *pdev = NULL; 1114 struct wlan_objmgr_psoc *psoc = NULL; 1115 QDF_STATUS status = QDF_STATUS_SUCCESS; 1116 1117 status = dev_sanity_check(vdev, &pdev, &pcfr); 1118 if (status != QDF_STATUS_SUCCESS) 1119 return status; 1120 1121 psoc = wlan_pdev_get_psoc(pdev); 1122 if (!psoc) { 1123 cfr_err("psoc is null!"); 1124 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1125 return QDF_STATUS_E_NULL_VALUE; 1126 } 1127 cdp_cfr_clr_dbg_stats(wlan_psoc_get_dp_handle(psoc), 1128 wlan_objmgr_pdev_get_pdev_id(pdev)); 1129 1130 pcfr->dbr_evt_cnt = 0; 1131 pcfr->release_cnt = 0; 1132 pcfr->total_tx_evt_cnt = 0; 1133 pcfr->rx_tlv_evt_cnt = 0; 1134 pcfr->flush_dbr_cnt = 0; 1135 pcfr->flush_timeout_dbr_cnt = 0; 1136 pcfr->invalid_dma_length_cnt = 0; 1137 pcfr->clear_txrx_event = 0; 1138 pcfr->cfr_dma_aborts = 0; 1139 pcfr->tx_peer_status_cfr_fail = 0; 1140 pcfr->tx_evt_status_cfr_fail = 0; 1141 pcfr->tx_dbr_cookie_lookup_fail = 0; 1142 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1143 1144 return status; 1145 } 1146 1147 QDF_STATUS ucfg_cfr_rcc_dump_lut(struct wlan_objmgr_vdev *vdev) 1148 { 1149 struct wlan_objmgr_pdev *pdev = NULL; 1150 QDF_STATUS status = QDF_STATUS_SUCCESS; 1151 1152 if (!vdev) { 1153 cfr_err("vdev is NULL"); 1154 return QDF_STATUS_E_INVAL; 1155 } 1156 1157 pdev = wlan_vdev_get_pdev(vdev); 1158 if (!pdev) { 1159 cfr_err("pdev is NULL"); 1160 return QDF_STATUS_E_INVAL; 1161 } 1162 1163 if (wlan_objmgr_pdev_try_get_ref(pdev, WLAN_CFR_ID) != 1164 QDF_STATUS_SUCCESS) { 1165 return QDF_STATUS_E_INVAL; 1166 } 1167 1168 cfr_err("LUT table:"); 1169 tgt_cfr_dump_lut_enh(pdev); 1170 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1171 1172 return status; 1173 } 1174 1175 static void cfr_set_filter(struct wlan_objmgr_pdev *pdev, bool enable, 1176 struct cdp_monitor_filter *filter_val) 1177 { 1178 struct wlan_objmgr_psoc *psoc = wlan_pdev_get_psoc(pdev); 1179 1180 cfr_info("pdev_id=%d\n", wlan_objmgr_pdev_get_pdev_id(pdev)); 1181 1182 cdp_cfr_filter(wlan_psoc_get_dp_handle(psoc), 1183 wlan_objmgr_pdev_get_pdev_id(pdev), 1184 enable, 1185 filter_val); 1186 } 1187 1188 #ifdef WLAN_ENH_CFR_ENABLE 1189 /* 1190 * With the initiation of commit command, this handler will be triggered. 1191 * 1192 * Starts the procedure of forming the TLVs. 1193 * If Host succeeds to send WMI command to FW, after TLV processing, then it 1194 * will save the previous CFR configurations into one instance ta_ra_cfr_cfg, 1195 * called glbl_cfg and update the current config to default state for the 1196 * next commit session. 1197 * 1198 * Finally, reset the counter (modified_in_this_session) to 0 before moving to 1199 * next commit session. 1200 * 1201 */ 1202 1203 QDF_STATUS ucfg_cfr_committed_rcc_config(struct wlan_objmgr_vdev *vdev) 1204 { 1205 struct pdev_cfr *pcfr = NULL; 1206 struct wlan_objmgr_pdev *pdev = NULL; 1207 struct wlan_objmgr_psoc *psoc = NULL; 1208 QDF_STATUS status = QDF_STATUS_SUCCESS; 1209 struct cdp_monitor_filter filter_val = {0}; 1210 1211 status = dev_sanity_check(vdev, &pdev, &pcfr); 1212 if (status != QDF_STATUS_SUCCESS) 1213 return status; 1214 1215 psoc = wlan_pdev_get_psoc(pdev); 1216 1217 if (!psoc) { 1218 cfr_err("psoc is null!"); 1219 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1220 return QDF_STATUS_E_NULL_VALUE; 1221 } 1222 1223 pcfr->rcc_param.vdev_id = wlan_vdev_get_id(vdev); 1224 1225 /* 1226 * If capture mode is valid, then Host: 1227 * Subscribes for PPDU status TLVs in monitor status ring. 1228 * Sets filter type to either FP or MO, based on the capture mode. 1229 * Starts the LUT_AGE_TIMER of 1sec. 1230 * 1231 * If capture mode is disabled, then Host: 1232 * unsubscribes for PPDU status TLVs in monitor status ring. 1233 * Sets filter type to 0. 1234 * Stops the LUT_AGE_TIMER. 1235 * 1236 */ 1237 1238 if (cfr_is_filter_enabled(&pcfr->rcc_param)) { 1239 if (pcfr->cfr_timer_enable) { 1240 cfr_err("Not allowed: Periodic capture is enabled.\n"); 1241 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1242 return QDF_STATUS_E_NOSUPPORT; 1243 } 1244 1245 if (pcfr->rcc_param.m_all_ftm_ack) { 1246 filter_val.mode |= MON_FILTER_PASS | 1247 MON_FILTER_OTHER; 1248 filter_val.fp_mgmt |= FILTER_MGMT_ACTION; 1249 filter_val.mo_mgmt |= FILTER_MGMT_ACTION; 1250 } 1251 1252 if (pcfr->rcc_param.m_ndpa_ndp_all) { 1253 filter_val.mode |= MON_FILTER_PASS | 1254 MON_FILTER_OTHER; 1255 filter_val.fp_ctrl |= FILTER_CTRL_VHT_NDP; 1256 filter_val.mo_ctrl |= FILTER_CTRL_VHT_NDP; 1257 } 1258 1259 if (pcfr->rcc_param.m_all_packet) { 1260 filter_val.mode |= MON_FILTER_PASS | 1261 MON_FILTER_OTHER; 1262 filter_val.fp_mgmt |= FILTER_MGMT_ALL; 1263 filter_val.mo_mgmt |= FILTER_MGMT_ALL; 1264 filter_val.fp_ctrl |= FILTER_CTRL_ALL; 1265 filter_val.mo_ctrl |= FILTER_CTRL_ALL; 1266 filter_val.fp_data |= FILTER_DATA_ALL; 1267 filter_val.mo_data |= FILTER_DATA_ALL; 1268 } 1269 1270 /* 1271 * M_TA_RA in monitor other is as intensive as M_ALL pkt 1272 * Support only FP in M_TA_RA mode 1273 */ 1274 if (pcfr->rcc_param.m_ta_ra_filter) { 1275 filter_val.mode |= MON_FILTER_PASS | 1276 MON_FILTER_OTHER; 1277 filter_val.fp_mgmt |= FILTER_MGMT_ALL; 1278 filter_val.mo_mgmt |= FILTER_MGMT_ALL; 1279 filter_val.fp_ctrl |= FILTER_CTRL_ALL; 1280 filter_val.mo_ctrl |= FILTER_CTRL_ALL; 1281 filter_val.fp_data |= FILTER_DATA_ALL; 1282 filter_val.mo_data |= FILTER_DATA_ALL; 1283 } 1284 1285 if (pcfr->rcc_param.m_directed_ftm) { 1286 filter_val.mode |= MON_FILTER_PASS; 1287 filter_val.fp_mgmt |= FILTER_MGMT_ACTION; 1288 } 1289 1290 if (pcfr->rcc_param.m_ndpa_ndp_directed) { 1291 filter_val.mode |= MON_FILTER_PASS; 1292 filter_val.fp_ctrl |= FILTER_CTRL_VHT_NDP; 1293 } 1294 1295 if (!cdp_get_cfr_rcc(wlan_psoc_get_dp_handle(psoc), 1296 wlan_objmgr_pdev_get_pdev_id(pdev))) 1297 tgt_cfr_start_lut_age_timer(pdev); 1298 cfr_set_filter(pdev, 1, &filter_val); 1299 } else { 1300 if (cdp_get_cfr_rcc(wlan_psoc_get_dp_handle(psoc), 1301 wlan_objmgr_pdev_get_pdev_id(pdev))) 1302 tgt_cfr_stop_lut_age_timer(pdev); 1303 cfr_set_filter(pdev, 0, &filter_val); 1304 } 1305 1306 /* Trigger wmi to start the TLV processing. */ 1307 status = tgt_cfr_config_rcc(pdev, &pcfr->rcc_param); 1308 if (status == QDF_STATUS_SUCCESS) { 1309 cfr_info("CFR commit done\n"); 1310 /* Update global config */ 1311 tgt_cfr_update_global_cfg(pdev); 1312 1313 /* Bring curr_cfg to default state for next commit session */ 1314 tgt_cfr_default_ta_ra_cfg(pdev, &pcfr->rcc_param, 1315 false, MAX_RESET_CFG_ENTRY); 1316 } else { 1317 cfr_err("CFR commit failed"); 1318 } 1319 1320 pcfr->rcc_param.num_grp_tlvs = 0; 1321 pcfr->rcc_param.modified_in_curr_session = 0; 1322 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1323 1324 return status; 1325 } 1326 1327 /* 1328 * This handler is used to enable / disable the capture mode. 1329 * 1330 */ 1331 QDF_STATUS ucfg_cfr_set_rcc_mode(struct wlan_objmgr_vdev *vdev, 1332 enum capture_type mode, uint8_t value) 1333 { 1334 struct pdev_cfr *pcfr = NULL; 1335 struct wlan_objmgr_pdev *pdev = NULL; 1336 QDF_STATUS status = QDF_STATUS_SUCCESS; 1337 1338 status = dev_sanity_check(vdev, &pdev, &pcfr); 1339 if (status != QDF_STATUS_SUCCESS) 1340 return status; 1341 1342 switch (mode) { 1343 case RCC_DIRECTED_FTM_FILTER: 1344 pcfr->rcc_param.m_directed_ftm = value; 1345 break; 1346 case RCC_ALL_FTM_ACK_FILTER: 1347 pcfr->rcc_param.m_all_ftm_ack = value; 1348 break; 1349 case RCC_DIRECTED_NDPA_NDP_FILTER: 1350 pcfr->rcc_param.m_ndpa_ndp_directed = value; 1351 break; 1352 case RCC_NDPA_NDP_ALL_FILTER: 1353 pcfr->rcc_param.m_ndpa_ndp_all = value; 1354 break; 1355 case RCC_TA_RA_FILTER: 1356 pcfr->rcc_param.m_ta_ra_filter = value; 1357 break; 1358 case RCC_ALL_PACKET_FILTER: 1359 pcfr->rcc_param.m_all_packet = value; 1360 break; 1361 case RCC_DIS_ALL_MODE: 1362 pcfr->rcc_param.m_directed_ftm = value; 1363 pcfr->rcc_param.m_all_ftm_ack = value; 1364 pcfr->rcc_param.m_ndpa_ndp_directed = value; 1365 pcfr->rcc_param.m_ndpa_ndp_all = value; 1366 pcfr->rcc_param.m_ta_ra_filter = value; 1367 pcfr->rcc_param.m_all_packet = value; 1368 break; 1369 1370 default: 1371 break; 1372 } 1373 1374 cfr_debug("<CFR_UMAC> Capture mode set by user: 0x%x\n", value); 1375 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1376 1377 return status; 1378 } 1379 #endif 1380 1381 bool ucfg_cfr_get_rcc_enabled(struct wlan_objmgr_vdev *vdev) 1382 { 1383 struct pdev_cfr *pcfr = NULL; 1384 struct wlan_objmgr_pdev *pdev = NULL; 1385 QDF_STATUS status = QDF_STATUS_SUCCESS; 1386 bool rcc_enabled = false; 1387 1388 status = dev_sanity_check(vdev, &pdev, &pcfr); 1389 if (status != QDF_STATUS_SUCCESS) 1390 return false; 1391 1392 rcc_enabled = cfr_is_filter_enabled(&pcfr->rcc_param); 1393 wlan_objmgr_pdev_release_ref(pdev, WLAN_CFR_ID); 1394 1395 return rcc_enabled; 1396 } 1397 1398 #ifdef WLAN_ENH_CFR_ENABLE 1399 QDF_STATUS ucfg_cfr_subscribe_ppdu_desc(struct wlan_objmgr_pdev *pdev, 1400 bool is_subscribe) 1401 { 1402 return tgt_cfr_subscribe_ppdu_desc(pdev, is_subscribe); 1403 } 1404 #endif 1405 1406 #endif 1407