1 /* 2 * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #include <target_if_cfr.h> 21 #include <wlan_tgt_def_config.h> 22 #include <target_type.h> 23 #include <hif_hw_version.h> 24 #include <target_if.h> 25 #include <wlan_lmac_if_def.h> 26 #include <wlan_osif_priv.h> 27 #include <init_deinit_lmac.h> 28 #include <wlan_cfr_utils_api.h> 29 #include <wlan_objmgr_pdev_obj.h> 30 #include <target_if_cfr_enh.h> 31 #ifdef CFR_USE_FIXED_FOLDER 32 #include "target_if_cfr_6490.h" 33 #include "target_if_cfr_adrastea.h" 34 #include "wlan_reg_services_api.h" 35 #else 36 #include <target_if_cfr_dbr.h> 37 #endif 38 39 int target_if_cfr_stop_capture(struct wlan_objmgr_pdev *pdev, 40 struct wlan_objmgr_peer *peer) 41 { 42 struct peer_cfr *pe; 43 struct peer_cfr_params param = {0}; 44 struct wmi_unified *pdev_wmi_handle = NULL; 45 struct wlan_objmgr_vdev *vdev = {0}; 46 struct pdev_cfr *pdev_cfrobj; 47 int retv = 0; 48 49 pe = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_UMAC_COMP_CFR); 50 if (pe == NULL) 51 return -EINVAL; 52 53 pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev); 54 if (!pdev_wmi_handle) { 55 cfr_err("pdev wmi handle NULL"); 56 return -EINVAL; 57 } 58 vdev = wlan_peer_get_vdev(peer); 59 60 qdf_mem_set(¶m, sizeof(param), 0); 61 62 param.request = PEER_CFR_CAPTURE_DISABLE; 63 param.macaddr = wlan_peer_get_macaddr(peer); 64 param.vdev_id = wlan_vdev_get_id(vdev); 65 66 param.periodicity = pe->period; 67 param.bandwidth = pe->bandwidth; 68 param.capture_method = pe->capture_method; 69 70 retv = wmi_unified_send_peer_cfr_capture_cmd(pdev_wmi_handle, ¶m); 71 72 pdev_cfrobj = wlan_objmgr_pdev_get_comp_private_obj(pdev, 73 WLAN_UMAC_COMP_CFR); 74 if (!pdev_cfrobj) { 75 cfr_err("pdev object for CFR is null"); 76 return -EINVAL; 77 } 78 cfr_err("CFR capture stats for this capture:"); 79 cfr_err("DBR event count = %llu, Tx event count = %llu " 80 "Release count = %llu", 81 pdev_cfrobj->dbr_evt_cnt, pdev_cfrobj->tx_evt_cnt, 82 pdev_cfrobj->release_cnt); 83 cfr_err("tx_peer_status_cfr_fail = %llu", 84 pdev_cfrobj->tx_peer_status_cfr_fail = 0); 85 cfr_err("tx_evt_status_cfr_fail = %llu", 86 pdev_cfrobj->tx_evt_status_cfr_fail); 87 cfr_err("tx_dbr_cookie_lookup_fail = %llu", 88 pdev_cfrobj->tx_dbr_cookie_lookup_fail); 89 90 pdev_cfrobj->dbr_evt_cnt = 0; 91 pdev_cfrobj->tx_evt_cnt = 0; 92 pdev_cfrobj->release_cnt = 0; 93 pdev_cfrobj->tx_peer_status_cfr_fail = 0; 94 pdev_cfrobj->tx_evt_status_cfr_fail = 0; 95 pdev_cfrobj->tx_dbr_cookie_lookup_fail = 0; 96 97 return retv; 98 } 99 100 int target_if_cfr_start_capture(struct wlan_objmgr_pdev *pdev, 101 struct wlan_objmgr_peer *peer, 102 struct cfr_capture_params *cfr_params) 103 { 104 struct peer_cfr_params param = {0}; 105 struct wmi_unified *pdev_wmi_handle = NULL; 106 struct wlan_objmgr_vdev *vdev; 107 int retv = 0; 108 109 pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev); 110 if (!pdev_wmi_handle) { 111 cfr_err("pdev wmi handle NULL"); 112 return -EINVAL; 113 } 114 vdev = wlan_peer_get_vdev(peer); 115 qdf_mem_set(¶m, sizeof(param), 0); 116 117 param.request = PEER_CFR_CAPTURE_ENABLE; 118 param.macaddr = wlan_peer_get_macaddr(peer); 119 param.vdev_id = wlan_vdev_get_id(vdev); 120 121 param.periodicity = cfr_params->period; 122 param.bandwidth = cfr_params->bandwidth; 123 param.capture_method = cfr_params->method; 124 125 retv = wmi_unified_send_peer_cfr_capture_cmd(pdev_wmi_handle, ¶m); 126 return retv; 127 } 128 129 #ifdef ENABLE_HOST_TO_TARGET_CONVERSION 130 int target_if_cfr_periodic_peer_cfr_enable(struct wlan_objmgr_pdev *pdev, 131 uint32_t param_value) 132 { 133 struct pdev_params pparam; 134 uint32_t pdev_id; 135 struct wmi_unified *pdev_wmi_handle = NULL; 136 137 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 138 if (pdev_id < 0) 139 return -EINVAL; 140 141 pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev); 142 if (!pdev_wmi_handle) { 143 cfr_err("pdev wmi handle NULL"); 144 return -EINVAL; 145 } 146 qdf_mem_set(&pparam, sizeof(pparam), 0); 147 pparam.param_id = wmi_pdev_param_per_peer_prd_cfr_enable; 148 pparam.param_value = param_value; 149 150 return wmi_unified_pdev_param_send(pdev_wmi_handle, 151 &pparam, pdev_id); 152 } 153 #else 154 int target_if_cfr_periodic_peer_cfr_enable(struct wlan_objmgr_pdev *pdev, 155 uint32_t param_value) 156 { 157 struct pdev_params pparam; 158 uint32_t pdev_id; 159 struct wmi_unified *pdev_wmi_handle = NULL; 160 161 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); 162 if (pdev_id < 0) 163 return -EINVAL; 164 165 pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev); 166 if (!pdev_wmi_handle) { 167 cfr_err("pdev wmi handle NULL"); 168 return -EINVAL; 169 } 170 qdf_mem_set(&pparam, sizeof(pparam), 0); 171 pparam.param_id = WMI_PDEV_PARAM_PER_PEER_PERIODIC_CFR_ENABLE; 172 pparam.param_value = param_value; 173 174 return wmi_unified_pdev_param_send(pdev_wmi_handle, 175 &pparam, pdev_id); 176 } 177 #endif 178 179 int target_if_cfr_enable_cfr_timer(struct wlan_objmgr_pdev *pdev, 180 uint32_t cfr_timer) 181 { 182 struct pdev_cfr *pa; 183 int retval; 184 185 pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR); 186 if (pa == NULL) 187 return QDF_STATUS_E_FAILURE; 188 189 if (!cfr_timer) { 190 /* disable periodic cfr capture */ 191 retval = 192 target_if_cfr_periodic_peer_cfr_enable(pdev, 193 WMI_HOST_PEER_CFR_TIMER_DISABLE); 194 195 if (retval == QDF_STATUS_SUCCESS) 196 pa->cfr_timer_enable = 0; 197 } else { 198 /* enable periodic cfr capture (default base timer is 10ms ) */ 199 retval = 200 target_if_cfr_periodic_peer_cfr_enable(pdev, 201 WMI_HOST_PEER_CFR_TIMER_ENABLE); 202 203 if (retval == QDF_STATUS_SUCCESS) 204 pa->cfr_timer_enable = 1; 205 } 206 207 return retval; 208 } 209 210 int target_if_cfr_get_target_type(struct wlan_objmgr_psoc *psoc) 211 { 212 uint32_t target_type = 0; 213 struct wlan_lmac_if_target_tx_ops *target_type_tx_ops; 214 struct wlan_lmac_if_tx_ops *tx_ops; 215 216 tx_ops = wlan_psoc_get_lmac_if_txops(psoc); 217 if (!tx_ops) { 218 cfr_err("tx_ops is NULL"); 219 return target_type; 220 } 221 target_type_tx_ops = &tx_ops->target_tx_ops; 222 223 if (target_type_tx_ops->tgt_get_tgt_type) 224 target_type = target_type_tx_ops->tgt_get_tgt_type(psoc); 225 226 return target_type; 227 } 228 229 void target_if_cfr_fill_header(struct csi_cfr_header *hdr, 230 bool is_wifi_2_0, 231 uint32_t target_type, 232 bool is_rcc) 233 { 234 hdr->cmn.start_magic_num = 0xDEADBEAF; 235 hdr->cmn.vendorid = 0x8cfdf0; 236 hdr->cmn.pltform_type = CFR_PLATFORM_TYPE_ARM; 237 hdr->cmn.cfr_metadata_len = CFR_META_DATA_LEN; 238 hdr->cmn.cfr_data_version = CFR_DATA_VERSION_1; 239 hdr->cmn.host_real_ts = qdf_ktime_to_ns(qdf_ktime_real_get()); 240 241 if (target_type == TARGET_TYPE_QCA8074V2) { 242 hdr->cmn.cfr_metadata_version = CFR_META_VERSION_8; 243 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_HKV2; 244 } else if (target_type == TARGET_TYPE_QCA9574) { 245 hdr->cmn.cfr_metadata_version = CFR_META_VERSION_8; 246 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_ALDER; 247 } else { 248 if (target_type == TARGET_TYPE_QCN9000) 249 hdr->cmn.cfr_metadata_version = CFR_META_VERSION_9; 250 else if (target_type == TARGET_TYPE_QCN9224 || 251 target_type == TARGET_TYPE_QCA6490 || 252 target_type == TARGET_TYPE_QCA6750 || 253 target_type == TARGET_TYPE_KIWI || 254 target_type == TARGET_TYPE_MANGO) 255 hdr->cmn.cfr_metadata_version = CFR_META_VERSION_7; 256 else if ((target_type == TARGET_TYPE_QCA6018) || 257 ((target_type == TARGET_TYPE_QCA5018) && (!is_rcc))) 258 hdr->cmn.cfr_metadata_version = CFR_META_VERSION_5; 259 else 260 hdr->cmn.cfr_metadata_version = CFR_META_VERSION_3; 261 262 if (target_type == TARGET_TYPE_QCN9000) 263 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_PINE; 264 else if (target_type == TARGET_TYPE_QCA5018) 265 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_MAPLE; 266 else if (target_type == TARGET_TYPE_QCN6122) 267 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_SPRUCE; 268 else if (target_type == TARGET_TYPE_QCN9224) 269 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_WAIKIKI; 270 else if (target_type == TARGET_TYPE_QCA6490) 271 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_HSP; 272 else if (target_type == TARGET_TYPE_QCA6750) 273 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_MOSELLE; 274 else if (target_type == TARGET_TYPE_KIWI) 275 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_KIWI; 276 else if (target_type == TARGET_TYPE_MANGO) 277 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_MANGO; 278 else 279 hdr->cmn.chip_type = CFR_CAPTURE_RADIO_CYP; 280 } 281 } 282 283 #ifdef CFR_USE_FIXED_FOLDER 284 static QDF_STATUS target_if_cfr_init_target(struct wlan_objmgr_psoc *psoc, 285 struct wlan_objmgr_pdev *pdev, 286 uint32_t target) 287 { 288 struct pdev_cfr *cfr_pdev; 289 struct psoc_cfr *cfr_psoc; 290 struct wmi_unified *wmi_handle = NULL; 291 bool cfr_capable; 292 QDF_STATUS status; 293 294 if (!psoc || !pdev) { 295 cfr_err("null pdev or psoc"); 296 return QDF_STATUS_E_FAILURE; 297 } 298 299 cfr_pdev = wlan_objmgr_pdev_get_comp_private_obj(pdev, 300 WLAN_UMAC_COMP_CFR); 301 if (!cfr_pdev) { 302 cfr_err("null pdev cfr"); 303 return QDF_STATUS_E_FAILURE; 304 } 305 306 cfr_psoc = wlan_objmgr_psoc_get_comp_private_obj(psoc, 307 WLAN_UMAC_COMP_CFR); 308 309 if (!cfr_psoc) { 310 cfr_err("null psoc cfr"); 311 return QDF_STATUS_E_FAILURE; 312 } 313 314 wmi_handle = lmac_get_pdev_wmi_handle(pdev); 315 if (!wmi_handle) { 316 cfr_err("null wmi handle"); 317 return QDF_STATUS_E_FAILURE; 318 } 319 320 if (wlan_cfr_is_feature_disabled(pdev)) { 321 cfr_pdev->is_cfr_capable = 0; 322 cfr_psoc->is_cfr_capable = 0; 323 cfr_info("cfr disabled"); 324 return QDF_STATUS_SUCCESS; 325 } 326 327 cfr_capable = wmi_service_enabled(wmi_handle, 328 wmi_service_cfr_capture_support); 329 cfr_pdev->is_cfr_capable = cfr_capable; 330 cfr_psoc->is_cfr_capable = cfr_capable; 331 if (!cfr_capable) { 332 cfr_err("FW doesn't support CFR"); 333 return QDF_STATUS_SUCCESS; 334 } 335 336 status = cfr_enh_init_pdev(psoc, pdev); 337 if (target == TARGET_TYPE_QCA6490) 338 cfr_pdev->chip_type = CFR_CAPTURE_RADIO_HSP; 339 else if (target == TARGET_TYPE_QCA6750) 340 cfr_pdev->chip_type = CFR_CAPTURE_RADIO_MOSELLE; 341 else if (target == TARGET_TYPE_KIWI) 342 cfr_pdev->chip_type = CFR_CAPTURE_RADIO_KIWI; 343 else if (target == TARGET_TYPE_MANGO) 344 cfr_pdev->chip_type = CFR_CAPTURE_RADIO_MANGO; 345 346 return status; 347 } 348 349 static QDF_STATUS target_if_cfr_deinit_target(struct wlan_objmgr_psoc *psoc, 350 struct wlan_objmgr_pdev *pdev) 351 { 352 struct pdev_cfr *pcfr; 353 354 if (!psoc || !pdev) { 355 cfr_err("null pdev or psoc"); 356 return QDF_STATUS_E_FAILURE; 357 } 358 359 pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev, 360 WLAN_UMAC_COMP_CFR); 361 if (!pcfr) { 362 cfr_err("null pdev cfr"); 363 return QDF_STATUS_E_FAILURE; 364 } 365 366 if (!pcfr->is_cfr_capable) { 367 cfr_info("cfr disabled or FW not support"); 368 return QDF_STATUS_SUCCESS; 369 } 370 371 return cfr_enh_deinit_pdev(psoc, pdev); 372 } 373 374 QDF_STATUS 375 target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc, 376 struct wlan_objmgr_pdev *pdev) 377 { 378 uint32_t target_type; 379 QDF_STATUS status; 380 381 target_type = target_if_cfr_get_target_type(psoc); 382 383 if (target_type == TARGET_TYPE_QCA6490 || 384 target_type == TARGET_TYPE_QCA6750 || 385 target_type == TARGET_TYPE_KIWI || 386 target_type == TARGET_TYPE_MANGO) { 387 status = target_if_cfr_init_target(psoc, 388 pdev, target_type); 389 } else if (target_type == TARGET_TYPE_ADRASTEA) { 390 status = cfr_adrastea_init_pdev(psoc, pdev); 391 } else { 392 cfr_info("unsupport chip"); 393 status = QDF_STATUS_SUCCESS; 394 } 395 396 return status; 397 } 398 399 QDF_STATUS 400 target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc, 401 struct wlan_objmgr_pdev *pdev) 402 { 403 uint32_t target_type; 404 QDF_STATUS status; 405 406 target_type = target_if_cfr_get_target_type(psoc); 407 408 if (target_type == TARGET_TYPE_QCA6490 || 409 target_type == TARGET_TYPE_QCA6750 || 410 target_type == TARGET_TYPE_KIWI || 411 target_type == TARGET_TYPE_MANGO) { 412 status = target_if_cfr_deinit_target(psoc, pdev); 413 } else if (target_type == TARGET_TYPE_ADRASTEA) { 414 status = cfr_adrastea_deinit_pdev(psoc, pdev); 415 } else { 416 cfr_info("unsupport chip"); 417 status = QDF_STATUS_SUCCESS; 418 } 419 420 return status; 421 } 422 #else 423 QDF_STATUS 424 target_if_cfr_init_pdev(struct wlan_objmgr_psoc *psoc, 425 struct wlan_objmgr_pdev *pdev) 426 { 427 uint32_t target_type; 428 struct pdev_cfr *pa; 429 struct psoc_cfr *cfr_sc; 430 431 if (wlan_cfr_is_feature_disabled(pdev)) { 432 cfr_err("cfr is disabled"); 433 return QDF_STATUS_E_NOSUPPORT; 434 } 435 436 pa = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR); 437 if (pa == NULL) 438 return QDF_STATUS_E_FAILURE; 439 440 /* Reset unassociated entries for every init */ 441 qdf_mem_zero(&pa->unassoc_pool[0], MAX_CFR_ENABLED_CLIENTS * 442 sizeof(struct unassoc_pool_entry)); 443 444 cfr_sc = wlan_objmgr_psoc_get_comp_private_obj(psoc, 445 WLAN_UMAC_COMP_CFR); 446 447 if (cfr_sc == NULL) 448 return QDF_STATUS_E_FAILURE; 449 450 target_type = target_if_cfr_get_target_type(psoc); 451 452 if ((target_type == TARGET_TYPE_QCA8074V2) || 453 (target_type == TARGET_TYPE_QCA9574)) { 454 pa->is_cfr_capable = cfr_sc->is_cfr_capable; 455 return cfr_dbr_init_pdev(psoc, pdev); 456 } else if ((target_type == TARGET_TYPE_QCA6018) || 457 (target_type == TARGET_TYPE_QCN9000) || 458 (target_type == TARGET_TYPE_QCN6122) || 459 (target_type == TARGET_TYPE_QCA5018) || 460 (target_type == TARGET_TYPE_QCN9224)) { 461 pa->is_cfr_capable = cfr_sc->is_cfr_capable; 462 return cfr_enh_init_pdev(psoc, pdev); 463 } else 464 return QDF_STATUS_E_NOSUPPORT; 465 } 466 467 QDF_STATUS 468 target_if_cfr_deinit_pdev(struct wlan_objmgr_psoc *psoc, 469 struct wlan_objmgr_pdev *pdev) 470 { 471 uint32_t target_type; 472 473 if (wlan_cfr_is_feature_disabled(pdev)) { 474 cfr_err("cfr is disabled"); 475 return QDF_STATUS_E_NOSUPPORT; 476 } 477 478 target_type = target_if_cfr_get_target_type(psoc); 479 480 if ((target_type == TARGET_TYPE_QCA8074V2) || 481 (target_type == TARGET_TYPE_QCA9574)) { 482 return cfr_dbr_deinit_pdev(psoc, pdev); 483 } else if ((target_type == TARGET_TYPE_QCA6018) || 484 (target_type == TARGET_TYPE_QCN9000) || 485 (target_type == TARGET_TYPE_QCN6122) || 486 (target_type == TARGET_TYPE_QCA5018) || 487 (target_type == TARGET_TYPE_QCN9224)) { 488 return cfr_enh_deinit_pdev(psoc, pdev); 489 } else 490 return QDF_STATUS_E_NOSUPPORT; 491 } 492 #endif 493 494 #ifdef WLAN_ENH_CFR_ENABLE 495 #if defined(QCA_WIFI_QCA6490) || defined(QCA_WIFI_KIWI) 496 static uint8_t target_if_cfr_get_mac_id(struct wlan_objmgr_pdev *pdev) 497 { 498 struct wlan_objmgr_vdev *vdev; 499 struct wlan_channel *bss_chan; 500 struct pdev_cfr *pcfr; 501 uint8_t mac_id = 0; 502 503 if (!pdev) { 504 cfr_err("null pdev"); 505 return mac_id; 506 } 507 508 mac_id = wlan_objmgr_pdev_get_pdev_id(pdev); 509 pcfr = wlan_objmgr_pdev_get_comp_private_obj(pdev, WLAN_UMAC_COMP_CFR); 510 if (!pcfr) { 511 cfr_err("null pcfr"); 512 return mac_id; 513 } 514 515 if (pcfr->rcc_param.vdev_id == CFR_INVALID_VDEV_ID) 516 return mac_id; 517 518 vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, 519 pcfr->rcc_param.vdev_id, 520 WLAN_CFR_ID); 521 if (!vdev) { 522 cfr_err("null vdev"); 523 return mac_id; 524 } 525 526 bss_chan = wlan_vdev_mlme_get_bss_chan(vdev); 527 if (!bss_chan) { 528 cfr_info("null bss chan"); 529 wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID); 530 return mac_id; 531 } 532 533 cfr_debug("bss freq %d", bss_chan->ch_freq); 534 if (wlan_reg_is_24ghz_ch_freq(bss_chan->ch_freq)) 535 mac_id = CFR_MAC_ID_24G; 536 else 537 mac_id = CFR_MAC_ID_5G; 538 539 pcfr->rcc_param.srng_id = mac_id; 540 wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID); 541 542 return mac_id; 543 } 544 545 static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev) 546 { 547 return target_if_cfr_get_mac_id(pdev); 548 } 549 #else 550 static uint8_t target_if_cfr_get_pdev_id(struct wlan_objmgr_pdev *pdev) 551 { 552 return wlan_objmgr_pdev_get_pdev_id(pdev); 553 } 554 #endif /* QCA_WIFI_QCA6490 || QCA_WIFI_KIWI */ 555 556 QDF_STATUS target_if_cfr_config_rcc(struct wlan_objmgr_pdev *pdev, 557 struct cfr_rcc_param *rcc_info) 558 { 559 QDF_STATUS status; 560 struct wmi_unified *pdev_wmi_handle = NULL; 561 562 pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev); 563 if (!pdev_wmi_handle) { 564 cfr_err("pdev_wmi_handle is null"); 565 return QDF_STATUS_E_NULL_VALUE; 566 } 567 568 rcc_info->pdev_id = target_if_cfr_get_pdev_id(pdev); 569 rcc_info->num_grp_tlvs = 570 count_set_bits(rcc_info->modified_in_curr_session); 571 572 status = wmi_unified_send_cfr_rcc_cmd(pdev_wmi_handle, rcc_info); 573 return status; 574 } 575 576 void target_if_cfr_default_ta_ra_config(struct cfr_rcc_param *rcc_info, 577 bool allvalid, uint16_t reset_cfg) 578 { 579 struct ta_ra_cfr_cfg *curr_cfg = NULL; 580 int grp_id; 581 unsigned long bitmap = reset_cfg; 582 uint8_t def_mac[QDF_MAC_ADDR_SIZE] = {0xFF, 0xFF, 0xFF, 583 0xFF, 0xFF, 0xFF}; 584 uint8_t null_mac[QDF_MAC_ADDR_SIZE] = {0x00, 0x00, 0x00, 585 0x00, 0x00, 0x00}; 586 587 for (grp_id = 0; grp_id < MAX_TA_RA_ENTRIES; grp_id++) { 588 if (qdf_test_bit(grp_id, &bitmap)) { 589 curr_cfg = &rcc_info->curr[grp_id]; 590 qdf_mem_copy(curr_cfg->tx_addr, 591 null_mac, QDF_MAC_ADDR_SIZE); 592 qdf_mem_copy(curr_cfg->tx_addr_mask, 593 def_mac, QDF_MAC_ADDR_SIZE); 594 qdf_mem_copy(curr_cfg->rx_addr, 595 null_mac, QDF_MAC_ADDR_SIZE); 596 qdf_mem_copy(curr_cfg->rx_addr_mask, 597 def_mac, QDF_MAC_ADDR_SIZE); 598 curr_cfg->bw = 0xf; 599 curr_cfg->nss = 0xff; 600 curr_cfg->mgmt_subtype_filter = 0; 601 curr_cfg->ctrl_subtype_filter = 0; 602 curr_cfg->data_subtype_filter = 0; 603 if (!allvalid) { 604 curr_cfg->valid_ta = 0; 605 curr_cfg->valid_ta_mask = 0; 606 curr_cfg->valid_ra = 0; 607 curr_cfg->valid_ra_mask = 0; 608 curr_cfg->valid_bw_mask = 0; 609 curr_cfg->valid_nss_mask = 0; 610 curr_cfg->valid_mgmt_subtype = 0; 611 curr_cfg->valid_ctrl_subtype = 0; 612 curr_cfg->valid_data_subtype = 0; 613 } else { 614 curr_cfg->valid_ta = 1; 615 curr_cfg->valid_ta_mask = 1; 616 curr_cfg->valid_ra = 1; 617 curr_cfg->valid_ra_mask = 1; 618 curr_cfg->valid_bw_mask = 1; 619 curr_cfg->valid_nss_mask = 1; 620 curr_cfg->valid_mgmt_subtype = 1; 621 curr_cfg->valid_ctrl_subtype = 1; 622 curr_cfg->valid_data_subtype = 1; 623 } 624 } 625 } 626 } 627 #endif 628 629 #ifdef WLAN_ENH_CFR_ENABLE 630 #ifdef CFR_USE_FIXED_FOLDER 631 static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops) 632 { 633 tx_ops->cfr_tx_ops.cfr_subscribe_ppdu_desc = 634 target_if_cfr_subscribe_ppdu_desc; 635 } 636 #else 637 static void target_if_enh_cfr_add_ops(struct wlan_lmac_if_tx_ops *tx_ops) 638 { 639 } 640 #endif /* CFR_USE_FIXED_FOLDER */ 641 static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) 642 { 643 tx_ops->cfr_tx_ops.cfr_config_rcc = 644 target_if_cfr_config_rcc; 645 tx_ops->cfr_tx_ops.cfr_start_lut_timer = 646 target_if_cfr_start_lut_age_timer; 647 tx_ops->cfr_tx_ops.cfr_stop_lut_timer = 648 target_if_cfr_stop_lut_age_timer; 649 tx_ops->cfr_tx_ops.cfr_default_ta_ra_cfg = 650 target_if_cfr_default_ta_ra_config; 651 tx_ops->cfr_tx_ops.cfr_dump_lut_enh = 652 target_if_cfr_dump_lut_enh; 653 tx_ops->cfr_tx_ops.cfr_rx_tlv_process = 654 target_if_cfr_rx_tlv_process; 655 tx_ops->cfr_tx_ops.cfr_update_global_cfg = 656 target_if_cfr_update_global_cfg; 657 target_if_enh_cfr_add_ops(tx_ops); 658 } 659 #else 660 static void target_if_enh_cfr_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) 661 { 662 } 663 #endif 664 665 void target_if_cfr_tx_ops_register(struct wlan_lmac_if_tx_ops *tx_ops) 666 { 667 tx_ops->cfr_tx_ops.cfr_init_pdev = 668 target_if_cfr_init_pdev; 669 tx_ops->cfr_tx_ops.cfr_deinit_pdev = 670 target_if_cfr_deinit_pdev; 671 tx_ops->cfr_tx_ops.cfr_enable_cfr_timer = 672 target_if_cfr_enable_cfr_timer; 673 tx_ops->cfr_tx_ops.cfr_start_capture = 674 target_if_cfr_start_capture; 675 tx_ops->cfr_tx_ops.cfr_stop_capture = 676 target_if_cfr_stop_capture; 677 target_if_enh_cfr_tx_ops(tx_ops); 678 } 679 680 void target_if_cfr_set_cfr_support(struct wlan_objmgr_psoc *psoc, 681 uint8_t value) 682 { 683 struct wlan_lmac_if_rx_ops *rx_ops; 684 685 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 686 if (!rx_ops) { 687 cfr_err("rx_ops is NULL"); 688 return; 689 } 690 if (rx_ops->cfr_rx_ops.cfr_support_set) 691 rx_ops->cfr_rx_ops.cfr_support_set(psoc, value); 692 } 693 694 QDF_STATUS 695 target_if_cfr_set_capture_count_support(struct wlan_objmgr_psoc *psoc, 696 uint8_t value) 697 { 698 struct wlan_lmac_if_rx_ops *rx_ops; 699 700 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 701 if (!rx_ops) { 702 cfr_err("rx_ops is NULL"); 703 return QDF_STATUS_E_INVAL; 704 } 705 706 if (rx_ops->cfr_rx_ops.cfr_capture_count_support_set) 707 return rx_ops->cfr_rx_ops.cfr_capture_count_support_set( 708 psoc, value); 709 710 return QDF_STATUS_E_INVAL; 711 } 712 713 QDF_STATUS 714 target_if_cfr_set_mo_marking_support(struct wlan_objmgr_psoc *psoc, 715 uint8_t value) 716 { 717 struct wlan_lmac_if_rx_ops *rx_ops; 718 719 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 720 if (!rx_ops) { 721 cfr_err("rx_ops is NULL"); 722 return QDF_STATUS_E_INVAL; 723 } 724 725 if (rx_ops->cfr_rx_ops.cfr_mo_marking_support_set) 726 return rx_ops->cfr_rx_ops.cfr_mo_marking_support_set( 727 psoc, value); 728 729 return QDF_STATUS_E_INVAL; 730 } 731 732 QDF_STATUS 733 target_if_cfr_set_aoa_for_rcc_support(struct wlan_objmgr_psoc *psoc, 734 uint8_t value) 735 { 736 struct wlan_lmac_if_rx_ops *rx_ops; 737 738 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 739 if (!rx_ops) { 740 cfr_err("rx_ops is NULL"); 741 return QDF_STATUS_E_INVAL; 742 } 743 744 if (rx_ops->cfr_rx_ops.cfr_aoa_for_rcc_support_set) 745 return rx_ops->cfr_rx_ops.cfr_aoa_for_rcc_support_set( 746 psoc, value); 747 748 return QDF_STATUS_E_INVAL; 749 } 750 751 void target_if_cfr_info_send(struct wlan_objmgr_pdev *pdev, void *head, 752 size_t hlen, void *data, size_t dlen, void *tail, 753 size_t tlen) 754 { 755 struct wlan_objmgr_psoc *psoc; 756 struct wlan_lmac_if_rx_ops *rx_ops; 757 758 psoc = wlan_pdev_get_psoc(pdev); 759 760 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 761 if (!rx_ops) { 762 cfr_err("rx_ops is NULL"); 763 return; 764 } 765 if (rx_ops->cfr_rx_ops.cfr_info_send) 766 rx_ops->cfr_rx_ops.cfr_info_send(pdev, head, hlen, data, dlen, 767 tail, tlen); 768 } 769