1 /* 2 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. 3 * Copyright (c) 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 /** 21 * DOC: init_deinit_lmac.c 22 * 23 * APIs to get/set target_if params 24 */ 25 #include <qdf_status.h> 26 #include <wlan_objmgr_psoc_obj.h> 27 #include <wlan_objmgr_pdev_obj.h> 28 #include <target_if.h> 29 #include <target_type.h> 30 #include <init_deinit_lmac.h> 31 #include <qdf_module.h> 32 lmac_get_target_cap(struct wlan_objmgr_psoc * psoc)33 struct wlan_psoc_target_capability_info *lmac_get_target_cap( 34 struct wlan_objmgr_psoc *psoc) 35 { 36 struct target_psoc_info *tgt_hdl; 37 38 if (!psoc) { 39 target_if_err("psoc is null"); 40 return NULL; 41 } 42 43 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 44 if (!tgt_hdl) { 45 target_if_err("target_psoc_info is null"); 46 return NULL; 47 } 48 49 return target_psoc_get_target_caps(tgt_hdl); 50 } 51 lmac_get_tgt_res_cfg(struct wlan_objmgr_psoc * psoc)52 target_resource_config *lmac_get_tgt_res_cfg(struct wlan_objmgr_psoc *psoc) 53 { 54 struct target_psoc_info *tgt_hdl; 55 56 if (!psoc) { 57 target_if_err("psoc is null"); 58 return NULL; 59 } 60 61 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 62 if (!tgt_hdl) { 63 target_if_err("target_psoc_info is null"); 64 return NULL; 65 } 66 67 return target_psoc_get_wlan_res_cfg(tgt_hdl); 68 } 69 lmac_get_pdev_idx(struct wlan_objmgr_pdev * pdev)70 int32_t lmac_get_pdev_idx(struct wlan_objmgr_pdev *pdev) 71 { 72 if (!pdev) { 73 target_if_err("pdev is null"); 74 return 0xffffffff; 75 } 76 77 return wlan_objmgr_pdev_get_pdev_id(pdev); 78 } 79 lmac_get_tgt_type(struct wlan_objmgr_psoc * psoc)80 uint32_t lmac_get_tgt_type(struct wlan_objmgr_psoc *psoc) 81 { 82 struct target_psoc_info *tgt_hdl; 83 84 if (!psoc) { 85 target_if_err("psoc is null"); 86 return 0; 87 } 88 89 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 90 if (!tgt_hdl) { 91 target_if_err("target_psoc_info is null"); 92 return 0; 93 } 94 95 return target_psoc_get_target_type(tgt_hdl); 96 } 97 qdf_export_symbol(lmac_get_tgt_type); 98 lmac_get_pdev_target_type(struct wlan_objmgr_pdev * pdev,uint32_t * target_type)99 QDF_STATUS lmac_get_pdev_target_type(struct wlan_objmgr_pdev *pdev, 100 uint32_t *target_type) 101 { 102 struct wlan_objmgr_psoc *psoc; 103 104 psoc = wlan_pdev_get_psoc(pdev); 105 if (!psoc) { 106 target_if_err("psoc is NULL"); 107 return QDF_STATUS_E_FAILURE; 108 } 109 110 *target_type = lmac_get_tgt_type(psoc); 111 return QDF_STATUS_SUCCESS; 112 } 113 qdf_export_symbol(lmac_get_pdev_target_type); 114 lmac_get_tgt_version(struct wlan_objmgr_psoc * psoc)115 uint32_t lmac_get_tgt_version(struct wlan_objmgr_psoc *psoc) 116 { 117 struct target_psoc_info *tgt_hdl; 118 119 if (!psoc) { 120 target_if_err("psoc is null"); 121 return -EINVAL; 122 } 123 124 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 125 if (!tgt_hdl) { 126 target_if_err("target_psoc_info is null"); 127 return -EINVAL; 128 } 129 130 return target_psoc_get_target_ver(tgt_hdl); 131 } 132 qdf_export_symbol(lmac_get_tgt_version); 133 lmac_get_tgt_revision(struct wlan_objmgr_psoc * psoc)134 uint32_t lmac_get_tgt_revision(struct wlan_objmgr_psoc *psoc) 135 { 136 struct target_psoc_info *tgt_hdl; 137 138 if (!psoc) { 139 target_if_err("psoc is null"); 140 return -EINVAL; 141 } 142 143 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 144 if (!tgt_hdl) { 145 target_if_err("target_psoc_info is null"); 146 return -EINVAL; 147 } 148 149 return target_psoc_get_target_rev(tgt_hdl); 150 } 151 qdf_export_symbol(lmac_get_tgt_revision); 152 lmac_is_target_ar900b(struct wlan_objmgr_psoc * psoc)153 bool lmac_is_target_ar900b(struct wlan_objmgr_psoc *psoc) 154 { 155 struct target_psoc_info *tgt_hdl; 156 uint32_t target_type; 157 158 if (!psoc) { 159 target_if_err("psoc is null\n"); 160 return false; 161 } 162 163 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 164 if (!tgt_hdl) { 165 target_if_err("target_psoc_info is null"); 166 return false; 167 } 168 target_type = tgt_hdl->info.target_type; 169 170 switch (target_type) { 171 case TARGET_TYPE_AR900B: 172 case TARGET_TYPE_QCA9984: 173 case TARGET_TYPE_QCA9888: 174 return true; 175 default: 176 return false; 177 } 178 return false; 179 } 180 qdf_export_symbol(lmac_is_target_ar900b); 181 lmac_get_wmi_hdl(struct wlan_objmgr_psoc * psoc)182 struct wmi_unified *lmac_get_wmi_hdl(struct wlan_objmgr_psoc *psoc) 183 { 184 struct target_psoc_info *tgt_hdl; 185 186 if (!psoc) { 187 target_if_err("psoc is null"); 188 return NULL; 189 } 190 191 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 192 if (!tgt_hdl) { 193 target_if_err("target_psoc_info is null"); 194 return NULL; 195 } 196 197 return target_psoc_get_wmi_hdl(tgt_hdl); 198 } 199 qdf_export_symbol(lmac_get_wmi_hdl); 200 lmac_get_wmi_unified_hdl(struct wlan_objmgr_psoc * psoc)201 wmi_unified_t lmac_get_wmi_unified_hdl(struct wlan_objmgr_psoc *psoc) 202 { 203 return (wmi_unified_t)lmac_get_wmi_hdl(psoc); 204 } 205 qdf_export_symbol(lmac_get_wmi_unified_hdl); 206 lmac_get_htc_hdl(struct wlan_objmgr_psoc * psoc)207 HTC_HANDLE lmac_get_htc_hdl(struct wlan_objmgr_psoc *psoc) 208 { 209 struct target_psoc_info *tgt_hdl; 210 211 if (!psoc) { 212 target_if_err("psoc is null"); 213 return NULL; 214 } 215 216 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 217 if (!tgt_hdl) { 218 target_if_err("target_psoc_info is null"); 219 return NULL; 220 } 221 222 return target_psoc_get_htc_hdl(tgt_hdl); 223 } 224 qdf_export_symbol(lmac_get_htc_hdl); 225 lmac_set_htc_hdl(struct wlan_objmgr_psoc * psoc,HTC_HANDLE htc_hdl)226 void lmac_set_htc_hdl(struct wlan_objmgr_psoc *psoc, 227 HTC_HANDLE htc_hdl) 228 { 229 struct target_psoc_info *tgt_hdl; 230 231 if (!psoc) { 232 target_if_err("psoc is null"); 233 return; 234 } 235 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 236 if (!tgt_hdl) { 237 target_if_err("target_psoc_info is null"); 238 return; 239 } 240 241 target_psoc_set_htc_hdl(tgt_hdl, htc_hdl); 242 } 243 lmac_get_hif_hdl(struct wlan_objmgr_psoc * psoc)244 struct hif_opaque_softc *lmac_get_hif_hdl(struct wlan_objmgr_psoc *psoc) 245 { 246 struct target_psoc_info *tgt_hdl; 247 248 if (!psoc) { 249 target_if_err("psoc is null"); 250 return NULL; 251 } 252 253 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 254 if (!tgt_hdl) { 255 target_if_err("target_psoc_info is null"); 256 return NULL; 257 } 258 259 return target_psoc_get_hif_hdl(tgt_hdl); 260 } 261 qdf_export_symbol(lmac_get_hif_hdl); 262 lmac_get_ol_hif_hdl(struct wlan_objmgr_psoc * psoc)263 struct hif_opaque_softc *lmac_get_ol_hif_hdl(struct wlan_objmgr_psoc *psoc) 264 { 265 return (struct hif_opaque_softc *)lmac_get_hif_hdl(psoc); 266 } 267 qdf_export_symbol(lmac_get_ol_hif_hdl); 268 lmac_get_pdev_wmi_handle(struct wlan_objmgr_pdev * pdev)269 struct wmi_unified *lmac_get_pdev_wmi_handle( 270 struct wlan_objmgr_pdev *pdev) 271 { 272 struct target_pdev_info *tgt_hdl; 273 274 if (!pdev) { 275 target_if_err("pdev is null"); 276 return NULL; 277 } 278 279 tgt_hdl = wlan_pdev_get_tgt_if_handle(pdev); 280 if (!tgt_hdl) { 281 target_if_err("target_pdev_info is null"); 282 return NULL; 283 } 284 285 return target_pdev_get_wmi_handle(tgt_hdl); 286 } 287 qdf_export_symbol(lmac_get_pdev_wmi_handle); 288 289 wmi_unified_t lmac_get_pdev_wmi_unified_handle(struct wlan_objmgr_pdev * pdev)290 lmac_get_pdev_wmi_unified_handle(struct wlan_objmgr_pdev *pdev) 291 { 292 return (wmi_unified_t)lmac_get_pdev_wmi_handle(pdev); 293 } 294 lmac_get_num_radios(struct wlan_objmgr_psoc * psoc)295 uint32_t lmac_get_num_radios(struct wlan_objmgr_psoc *psoc) 296 { 297 struct target_psoc_info *tgt_hdl; 298 299 if (!psoc) { 300 target_if_err("psoc is null"); 301 return 0; 302 } 303 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 304 if (!tgt_hdl) { 305 target_if_err("target_psoc_info is null"); 306 return 0; 307 } 308 309 return target_psoc_get_num_radios(tgt_hdl); 310 } 311 qdf_export_symbol(lmac_get_num_radios); 312 lmac_get_psoc_feature_ptr(struct wlan_objmgr_psoc * psoc)313 void *lmac_get_psoc_feature_ptr(struct wlan_objmgr_psoc *psoc) 314 { 315 struct target_psoc_info *tgt_hdl; 316 317 if (!psoc) { 318 target_if_err("psoc is null"); 319 return NULL; 320 } 321 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 322 if (!tgt_hdl) { 323 target_if_err("target_psoc_info is null"); 324 return NULL; 325 } 326 327 return target_psoc_get_feature_ptr(tgt_hdl); 328 } 329 qdf_export_symbol(lmac_get_psoc_feature_ptr); 330 lmac_get_pdev_feature_ptr(struct wlan_objmgr_pdev * pdev)331 void *lmac_get_pdev_feature_ptr(struct wlan_objmgr_pdev *pdev) 332 { 333 struct target_pdev_info *tgt_hdl; 334 335 if (!pdev) { 336 target_if_err("pdev is null"); 337 return NULL; 338 } 339 tgt_hdl = wlan_pdev_get_tgt_if_handle(pdev); 340 if (!tgt_hdl) { 341 target_if_err("target_pdev_info is null"); 342 return NULL; 343 } 344 345 return target_pdev_get_feature_ptr(tgt_hdl); 346 } 347 qdf_export_symbol(lmac_get_pdev_feature_ptr); 348 lmac_get_preferred_hw_mode(struct wlan_objmgr_psoc * psoc)349 enum wmi_host_hw_mode_config_type lmac_get_preferred_hw_mode( 350 struct wlan_objmgr_psoc *psoc) 351 { 352 struct target_psoc_info *tgt_hdl; 353 354 if (!psoc) { 355 target_if_err("psoc is null"); 356 return WMI_HOST_HW_MODE_MAX; 357 } 358 tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc); 359 if (!tgt_hdl) { 360 target_if_err("target_psoc_info is null"); 361 return WMI_HOST_HW_MODE_MAX; 362 } 363 364 return target_psoc_get_preferred_hw_mode(tgt_hdl); 365 } 366 367 qdf_export_symbol(lmac_get_preferred_hw_mode); 368