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