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