1 /* 2 * Copyright (c) 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 /** 20 * DOC : target_if_cfr_adrastea.c 21 * 22 * Target interface of CFR for Adrastea implementation 23 * 24 */ 25 26 #include <cdp_txrx_ctrl.h> 27 #include <qdf_nbuf.h> 28 #include "target_if_cfr.h" 29 #include "init_deinit_lmac.h" 30 #include <wlan_objmgr_psoc_obj.h> 31 #include "wlan_cfr_utils_api.h" 32 #include "target_if_cfr_adrastea.h" 33 #include "cfg_ucfg_api.h" 34 #include "cfr_cfg.h" 35 #include <target_if.h> 36 37 #ifdef WLAN_CFR_ADRASTEA 38 QDF_STATUS cfr_adrastea_init_pdev(struct wlan_objmgr_psoc *psoc, 39 struct wlan_objmgr_pdev *pdev) 40 { 41 struct pdev_cfr *cfr_pdev; 42 struct psoc_cfr *cfr_psoc; 43 struct wmi_unified *wmi_handle = NULL; 44 struct target_psoc_info *tgt_hdl; 45 struct tgt_info *info; 46 bool cfr_capable; 47 int num_mem_chunks, idx; 48 u32 *read_index; 49 50 if (!psoc || !pdev) { 51 cfr_err("null pdev or psoc"); 52 return QDF_STATUS_E_FAILURE; 53 } 54 55 cfr_pdev = wlan_objmgr_pdev_get_comp_private_obj( 56 pdev, WLAN_UMAC_COMP_CFR); 57 if (!cfr_pdev) { 58 cfr_err("null pdev cfr"); 59 return QDF_STATUS_E_FAILURE; 60 } 61 62 cfr_psoc = wlan_objmgr_psoc_get_comp_private_obj( 63 psoc, WLAN_UMAC_COMP_CFR); 64 65 if (!cfr_psoc) { 66 cfr_err("null psoc cfr"); 67 return QDF_STATUS_E_FAILURE; 68 } 69 70 if (wlan_cfr_is_feature_disabled(pdev)) { 71 cfr_pdev->is_cfr_capable = 0; 72 cfr_psoc->is_cfr_capable = 0; 73 cfr_info("cfr disabled"); 74 return QDF_STATUS_SUCCESS; 75 } 76 77 wmi_handle = lmac_get_pdev_wmi_handle(pdev); 78 if (!wmi_handle) { 79 cfr_err("null wmi handle"); 80 return QDF_STATUS_E_FAILURE; 81 } 82 83 cfr_capable = wmi_service_enabled(wmi_handle, 84 wmi_service_cfr_capture_support); 85 cfr_pdev->is_cfr_capable = cfr_capable; 86 cfr_psoc->is_cfr_capable = cfr_capable; 87 cfr_pdev->chip_type = CFR_CAPTURE_RADIO_ADRASTEA; 88 cfr_pdev->cfr_max_sta_count = MAX_CFR_ENABLED_CLIENTS; 89 cfr_pdev->subbuf_size = STREAMFS_MAX_SUBBUF_ADRASTEA; 90 cfr_pdev->num_subbufs = STREAMFS_NUM_BUF_SUBBUF_ADRASTEA; 91 cfr_pdev->pdev_obj = pdev; 92 cfr_psoc->psoc_obj = psoc; 93 94 if (!cfr_capable) { 95 cfr_err("FW doesn't support CFR"); 96 return QDF_STATUS_SUCCESS; 97 } 98 99 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 100 101 info = &(tgt_hdl->info); 102 num_mem_chunks = info->num_mem_chunks; 103 104 /* 105 * Copy the host mem chunk info allocated during init 106 * for CFR capture in cfr pdev 107 */ 108 for (idx = 0; idx < num_mem_chunks; idx++) { 109 if (info->mem_chunks[idx].req_id == 110 CFR_CAPTURE_HOST_MEM_REQ_ID) { 111 cfr_pdev->cfr_mem_chunk.vaddr = 112 info->mem_chunks[idx].vaddr; 113 cfr_pdev->cfr_mem_chunk.paddr = 114 info->mem_chunks[idx].paddr; 115 cfr_pdev->cfr_mem_chunk.req_id = 116 info->mem_chunks[idx].req_id; 117 cfr_pdev->cfr_mem_chunk.len = info->mem_chunks[idx].len; 118 119 /* Initialize the read index with default value */ 120 read_index = (u32 *)info->mem_chunks[idx].vaddr; 121 (*read_index) = CFR_HOST_MEM_READ_INDEX_DEFAULT; 122 break; 123 } 124 } 125 126 if (idx == num_mem_chunks) { 127 cfr_err("Host mem chunks for CFR req id not allocated\n"); 128 cfr_pdev->is_cfr_capable = 0; 129 cfr_psoc->is_cfr_capable = 0; 130 return QDF_STATUS_SUCCESS; 131 } 132 133 return QDF_STATUS_SUCCESS; 134 } 135 136 QDF_STATUS cfr_adrastea_deinit_pdev(struct wlan_objmgr_psoc *psoc, 137 struct wlan_objmgr_pdev *pdev) 138 { 139 struct pdev_cfr *pcfr; 140 141 if (!psoc || !pdev) { 142 cfr_err("null pdev or psoc"); 143 return QDF_STATUS_E_FAILURE; 144 } 145 146 pcfr = wlan_objmgr_pdev_get_comp_private_obj( 147 pdev, WLAN_UMAC_COMP_CFR); 148 if (!pcfr) { 149 cfr_err("null pdev cfr"); 150 return QDF_STATUS_E_FAILURE; 151 } 152 153 if (!pcfr->is_cfr_capable) { 154 cfr_info("cfr disabled or FW not support"); 155 return QDF_STATUS_SUCCESS; 156 } 157 158 qdf_mem_zero(&pcfr->cfr_mem_chunk, 159 sizeof(struct cfr_wmi_host_mem_chunk)); 160 161 return QDF_STATUS_SUCCESS; 162 } 163 #endif 164