Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1 | /* |
Srinivas Dasari | c9e048e | 2019-12-23 00:45:35 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3 | * |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 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 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 19 | /** |
| 20 | * DOC: wlan_policy_mgr_get_set_utils.c |
| 21 | * |
| 22 | * WLAN Concurrenct Connection Management APIs |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | /* Include files */ |
Sourav Mohapatra | 0c1a7f6 | 2017-12-03 11:44:44 +0530 | [diff] [blame] | 27 | #include "target_if.h" |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 28 | #include "wlan_policy_mgr_api.h" |
| 29 | #include "wlan_policy_mgr_i.h" |
| 30 | #include "qdf_types.h" |
| 31 | #include "qdf_trace.h" |
| 32 | #include "wlan_objmgr_global_obj.h" |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 33 | #include "wlan_objmgr_pdev_obj.h" |
| 34 | #include "wlan_objmgr_vdev_obj.h" |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 35 | #include "wlan_nan_api.h" |
| 36 | #include "nan_public_structs.h" |
Jianmin Zhu | e487f79 | 2019-10-15 13:34:34 +0800 | [diff] [blame] | 37 | #include "wlan_reg_services_api.h" |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 38 | |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 39 | /* invalid channel id. */ |
| 40 | #define INVALID_CHANNEL_ID 0 |
| 41 | |
Krunal Soni | 1680e41 | 2018-12-07 19:42:06 +0800 | [diff] [blame] | 42 | QDF_STATUS |
| 43 | policy_mgr_get_allow_mcc_go_diff_bi(struct wlan_objmgr_psoc *psoc, |
| 44 | uint8_t *allow_mcc_go_diff_bi) |
| 45 | { |
| 46 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 47 | |
| 48 | pm_ctx = policy_mgr_get_context(psoc); |
| 49 | if (!pm_ctx) { |
| 50 | policy_mgr_err("pm_ctx is NULL"); |
| 51 | return QDF_STATUS_E_FAILURE; |
| 52 | } |
| 53 | *allow_mcc_go_diff_bi = pm_ctx->cfg.allow_mcc_go_diff_bi; |
| 54 | |
| 55 | return QDF_STATUS_SUCCESS; |
| 56 | } |
| 57 | |
| 58 | QDF_STATUS |
| 59 | policy_mgr_get_enable_overlap_chnl(struct wlan_objmgr_psoc *psoc, |
| 60 | uint8_t *enable_overlap_chnl) |
| 61 | { |
| 62 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 63 | |
| 64 | pm_ctx = policy_mgr_get_context(psoc); |
| 65 | if (!pm_ctx) { |
| 66 | policy_mgr_err("pm_ctx is NULL"); |
| 67 | return QDF_STATUS_E_FAILURE; |
| 68 | } |
| 69 | *enable_overlap_chnl = pm_ctx->cfg.enable_overlap_chnl; |
| 70 | |
| 71 | return QDF_STATUS_SUCCESS; |
| 72 | } |
| 73 | |
gaurank kathpalia | e314029 | 2019-11-12 16:44:31 +0530 | [diff] [blame] | 74 | QDF_STATUS policy_mgr_set_dual_mac_feature(struct wlan_objmgr_psoc *psoc, |
| 75 | uint8_t dual_mac_feature) |
| 76 | { |
| 77 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 78 | |
| 79 | pm_ctx = policy_mgr_get_context(psoc); |
| 80 | if (!pm_ctx) { |
| 81 | policy_mgr_err("pm_ctx is NULL"); |
| 82 | return QDF_STATUS_E_FAILURE; |
| 83 | } |
| 84 | |
| 85 | pm_ctx->cfg.dual_mac_feature = dual_mac_feature; |
| 86 | |
| 87 | return QDF_STATUS_SUCCESS; |
| 88 | } |
| 89 | |
Krunal Soni | 1680e41 | 2018-12-07 19:42:06 +0800 | [diff] [blame] | 90 | QDF_STATUS policy_mgr_get_dual_mac_feature(struct wlan_objmgr_psoc *psoc, |
| 91 | uint8_t *dual_mac_feature) |
| 92 | { |
| 93 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 94 | |
| 95 | pm_ctx = policy_mgr_get_context(psoc); |
| 96 | if (!pm_ctx) { |
| 97 | policy_mgr_err("pm_ctx is NULL"); |
| 98 | return QDF_STATUS_E_FAILURE; |
| 99 | } |
| 100 | *dual_mac_feature = pm_ctx->cfg.dual_mac_feature; |
| 101 | |
| 102 | return QDF_STATUS_SUCCESS; |
| 103 | } |
| 104 | |
| 105 | QDF_STATUS policy_mgr_get_force_1x1(struct wlan_objmgr_psoc *psoc, |
| 106 | uint8_t *force_1x1) |
| 107 | { |
| 108 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 109 | |
| 110 | pm_ctx = policy_mgr_get_context(psoc); |
| 111 | if (!pm_ctx) { |
| 112 | policy_mgr_err("pm_ctx is NULL"); |
| 113 | return QDF_STATUS_E_FAILURE; |
| 114 | } |
| 115 | *force_1x1 = pm_ctx->cfg.is_force_1x1_enable; |
| 116 | |
| 117 | return QDF_STATUS_SUCCESS; |
| 118 | } |
| 119 | |
| 120 | QDF_STATUS |
| 121 | policy_mgr_get_sta_sap_scc_on_dfs_chnl(struct wlan_objmgr_psoc *psoc, |
| 122 | uint8_t *sta_sap_scc_on_dfs_chnl) |
| 123 | { |
| 124 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 125 | |
| 126 | pm_ctx = policy_mgr_get_context(psoc); |
| 127 | if (!pm_ctx) { |
| 128 | policy_mgr_err("pm_ctx is NULL"); |
| 129 | return QDF_STATUS_E_FAILURE; |
| 130 | } |
| 131 | *sta_sap_scc_on_dfs_chnl = pm_ctx->cfg.sta_sap_scc_on_dfs_chnl; |
| 132 | |
| 133 | return QDF_STATUS_SUCCESS; |
| 134 | } |
| 135 | |
Liangwei Dong | 24e3f9b | 2019-04-22 04:35:36 -0400 | [diff] [blame] | 136 | bool |
| 137 | policy_mgr_get_dfs_master_dynamic_enabled( |
| 138 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 139 | { |
| 140 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 141 | bool sta_on_5g = false; |
| 142 | bool sta_on_2g = false; |
| 143 | uint32_t i; |
| 144 | bool enable; |
| 145 | |
| 146 | pm_ctx = policy_mgr_get_context(psoc); |
| 147 | if (!pm_ctx) { |
| 148 | policy_mgr_err("pm_ctx is NULL"); |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | if (!pm_ctx->cfg.sta_sap_scc_on_dfs_chnl) |
| 153 | return true; |
| 154 | if (pm_ctx->cfg.sta_sap_scc_on_dfs_chnl == |
| 155 | PM_STA_SAP_ON_DFS_MASTER_MODE_DISABLED) |
| 156 | return false; |
| 157 | if (pm_ctx->cfg.sta_sap_scc_on_dfs_chnl != |
| 158 | PM_STA_SAP_ON_DFS_MASTER_MODE_FLEX) { |
| 159 | policy_mgr_debug("sta_sap_scc_on_dfs_chnl %d unknown", |
| 160 | pm_ctx->cfg.sta_sap_scc_on_dfs_chnl); |
| 161 | return true; |
| 162 | } |
| 163 | |
| 164 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 165 | for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { |
| 166 | if (!((pm_conc_connection_list[i].vdev_id != vdev_id) && |
| 167 | pm_conc_connection_list[i].in_use && |
| 168 | (pm_conc_connection_list[i].mode == PM_STA_MODE || |
| 169 | pm_conc_connection_list[i].mode == PM_P2P_CLIENT_MODE))) |
| 170 | continue; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 171 | if (WLAN_REG_IS_5GHZ_CH_FREQ(pm_conc_connection_list[i].freq)) |
Liangwei Dong | 24e3f9b | 2019-04-22 04:35:36 -0400 | [diff] [blame] | 172 | sta_on_5g = true; |
| 173 | else |
| 174 | sta_on_2g = true; |
| 175 | } |
| 176 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 177 | |
| 178 | if (policy_mgr_is_hw_dbs_capable(psoc) && !sta_on_5g) |
| 179 | enable = true; |
| 180 | else if (!sta_on_5g && !sta_on_2g) |
| 181 | enable = true; |
| 182 | else |
| 183 | enable = false; |
| 184 | policy_mgr_debug("sta_sap_scc_on_dfs_chnl %d sta_on_2g %d sta_on_5g %d enable %d", |
| 185 | pm_ctx->cfg.sta_sap_scc_on_dfs_chnl, sta_on_2g, |
| 186 | sta_on_5g, enable); |
| 187 | |
| 188 | return enable; |
| 189 | } |
| 190 | |
Krunal Soni | 1680e41 | 2018-12-07 19:42:06 +0800 | [diff] [blame] | 191 | QDF_STATUS |
| 192 | policy_mgr_get_sta_sap_scc_lte_coex_chnl(struct wlan_objmgr_psoc *psoc, |
| 193 | uint8_t *sta_sap_scc_lte_coex) |
| 194 | { |
| 195 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 196 | |
| 197 | pm_ctx = policy_mgr_get_context(psoc); |
| 198 | if (!pm_ctx) { |
| 199 | policy_mgr_err("pm_ctx is NULL"); |
| 200 | return QDF_STATUS_E_FAILURE; |
| 201 | } |
| 202 | *sta_sap_scc_lte_coex = pm_ctx->cfg.sta_sap_scc_on_lte_coex_chnl; |
| 203 | |
| 204 | return QDF_STATUS_SUCCESS; |
| 205 | } |
| 206 | |
| 207 | QDF_STATUS policy_mgr_get_sap_mandt_chnl(struct wlan_objmgr_psoc *psoc, |
| 208 | uint8_t *sap_mandt_chnl) |
| 209 | { |
| 210 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 211 | |
| 212 | pm_ctx = policy_mgr_get_context(psoc); |
| 213 | if (!pm_ctx) { |
| 214 | policy_mgr_err("pm_ctx is NULL"); |
| 215 | return QDF_STATUS_E_FAILURE; |
| 216 | } |
| 217 | *sap_mandt_chnl = pm_ctx->cfg.sap_mandatory_chnl_enable; |
| 218 | |
| 219 | return QDF_STATUS_SUCCESS; |
| 220 | } |
| 221 | |
| 222 | QDF_STATUS |
| 223 | policy_mgr_get_indoor_chnl_marking(struct wlan_objmgr_psoc *psoc, |
| 224 | uint8_t *indoor_chnl_marking) |
| 225 | { |
| 226 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 227 | |
| 228 | pm_ctx = policy_mgr_get_context(psoc); |
| 229 | if (!pm_ctx) { |
| 230 | policy_mgr_err("pm_ctx is NULL"); |
| 231 | return QDF_STATUS_E_FAILURE; |
| 232 | } |
| 233 | *indoor_chnl_marking = pm_ctx->cfg.mark_indoor_chnl_disable; |
| 234 | |
| 235 | return QDF_STATUS_SUCCESS; |
| 236 | } |
| 237 | |
Krunal Soni | 42e98ab | 2018-09-27 18:35:21 -0700 | [diff] [blame] | 238 | QDF_STATUS policy_mgr_get_mcc_scc_switch(struct wlan_objmgr_psoc *psoc, |
| 239 | uint8_t *mcc_scc_switch) |
| 240 | { |
| 241 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 242 | |
| 243 | pm_ctx = policy_mgr_get_context(psoc); |
| 244 | if (!pm_ctx) { |
| 245 | policy_mgr_err("pm_ctx is NULL"); |
| 246 | return QDF_STATUS_E_FAILURE; |
| 247 | } |
| 248 | *mcc_scc_switch = pm_ctx->cfg.mcc_to_scc_switch; |
| 249 | |
| 250 | return QDF_STATUS_SUCCESS; |
| 251 | } |
| 252 | |
| 253 | QDF_STATUS policy_mgr_get_sys_pref(struct wlan_objmgr_psoc *psoc, |
| 254 | uint8_t *sys_pref) |
| 255 | { |
| 256 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 257 | |
| 258 | pm_ctx = policy_mgr_get_context(psoc); |
| 259 | if (!pm_ctx) { |
| 260 | policy_mgr_err("pm_ctx is NULL"); |
| 261 | return QDF_STATUS_E_FAILURE; |
| 262 | } |
| 263 | *sys_pref = pm_ctx->cfg.sys_pref; |
| 264 | |
| 265 | return QDF_STATUS_SUCCESS; |
| 266 | } |
| 267 | |
Krunal Soni | 6dd2208 | 2018-09-27 10:40:24 -0700 | [diff] [blame] | 268 | QDF_STATUS policy_mgr_set_sys_pref(struct wlan_objmgr_psoc *psoc, |
| 269 | uint8_t sys_pref) |
| 270 | { |
| 271 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 272 | |
| 273 | pm_ctx = policy_mgr_get_context(psoc); |
| 274 | if (!pm_ctx) { |
| 275 | policy_mgr_err("pm_ctx is NULL"); |
| 276 | return QDF_STATUS_E_FAILURE; |
| 277 | } |
| 278 | pm_ctx->cfg.sys_pref = sys_pref; |
| 279 | |
| 280 | return QDF_STATUS_SUCCESS; |
| 281 | } |
| 282 | |
Krunal Soni | 42e98ab | 2018-09-27 18:35:21 -0700 | [diff] [blame] | 283 | QDF_STATUS policy_mgr_get_conc_rule1(struct wlan_objmgr_psoc *psoc, |
| 284 | uint8_t *conc_rule1) |
| 285 | { |
| 286 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 287 | |
| 288 | pm_ctx = policy_mgr_get_context(psoc); |
| 289 | if (!pm_ctx) { |
| 290 | policy_mgr_err("pm_ctx is NULL"); |
| 291 | return QDF_STATUS_E_FAILURE; |
| 292 | } |
| 293 | *conc_rule1 = pm_ctx->cfg.conc_rule1; |
| 294 | |
| 295 | return QDF_STATUS_SUCCESS; |
| 296 | } |
| 297 | |
| 298 | QDF_STATUS policy_mgr_get_conc_rule2(struct wlan_objmgr_psoc *psoc, |
| 299 | uint8_t *conc_rule2) |
| 300 | { |
| 301 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 302 | |
| 303 | pm_ctx = policy_mgr_get_context(psoc); |
| 304 | if (!pm_ctx) { |
| 305 | policy_mgr_err("pm_ctx is NULL"); |
| 306 | return QDF_STATUS_E_FAILURE; |
| 307 | } |
| 308 | *conc_rule2 = pm_ctx->cfg.conc_rule2; |
| 309 | |
| 310 | return QDF_STATUS_SUCCESS; |
| 311 | } |
| 312 | |
Krunal Soni | 42e98ab | 2018-09-27 18:35:21 -0700 | [diff] [blame] | 313 | QDF_STATUS policy_mgr_get_chnl_select_plcy(struct wlan_objmgr_psoc *psoc, |
gaurank kathpalia | 34fe0b6 | 2019-11-13 11:08:26 +0530 | [diff] [blame] | 314 | uint32_t *chnl_select_plcy) |
Krunal Soni | 42e98ab | 2018-09-27 18:35:21 -0700 | [diff] [blame] | 315 | { |
| 316 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 317 | |
| 318 | pm_ctx = policy_mgr_get_context(psoc); |
| 319 | if (!pm_ctx) { |
| 320 | policy_mgr_err("pm_ctx is NULL"); |
| 321 | return QDF_STATUS_E_FAILURE; |
| 322 | } |
| 323 | *chnl_select_plcy = pm_ctx->cfg.chnl_select_plcy; |
| 324 | |
| 325 | return QDF_STATUS_SUCCESS; |
| 326 | } |
| 327 | |
gaurank kathpalia | 34fe0b6 | 2019-11-13 11:08:26 +0530 | [diff] [blame] | 328 | QDF_STATUS policy_mgr_set_ch_select_plcy(struct wlan_objmgr_psoc *psoc, |
| 329 | uint32_t ch_select_policy) |
| 330 | { |
| 331 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 332 | |
| 333 | pm_ctx = policy_mgr_get_context(psoc); |
| 334 | if (!pm_ctx) { |
| 335 | policy_mgr_err("pm_ctx is NULL"); |
| 336 | return QDF_STATUS_E_FAILURE; |
| 337 | } |
| 338 | pm_ctx->cfg.chnl_select_plcy = ch_select_policy; |
| 339 | |
| 340 | return QDF_STATUS_SUCCESS; |
| 341 | } |
| 342 | |
Krunal Soni | c9af406 | 2018-09-27 14:31:20 -0700 | [diff] [blame] | 343 | QDF_STATUS policy_mgr_get_mcc_adaptive_sch(struct wlan_objmgr_psoc *psoc, |
| 344 | uint8_t *enable_mcc_adaptive_sch) |
| 345 | { |
| 346 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 347 | |
| 348 | pm_ctx = policy_mgr_get_context(psoc); |
| 349 | if (!pm_ctx) { |
| 350 | policy_mgr_err("pm_ctx is NULL"); |
| 351 | return QDF_STATUS_E_FAILURE; |
| 352 | } |
| 353 | *enable_mcc_adaptive_sch = pm_ctx->cfg.enable_mcc_adaptive_sch; |
| 354 | |
| 355 | return QDF_STATUS_SUCCESS; |
| 356 | } |
Krunal Soni | 42e98ab | 2018-09-27 18:35:21 -0700 | [diff] [blame] | 357 | |
Krunal Soni | dd8bf40 | 2018-09-27 17:34:25 -0700 | [diff] [blame] | 358 | QDF_STATUS policy_mgr_get_sta_cxn_5g_band(struct wlan_objmgr_psoc *psoc, |
| 359 | uint8_t *enable_sta_cxn_5g_band) |
| 360 | { |
| 361 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 362 | |
| 363 | pm_ctx = policy_mgr_get_context(psoc); |
| 364 | if (!pm_ctx) { |
| 365 | policy_mgr_err("pm_ctx is NULL"); |
| 366 | return QDF_STATUS_E_FAILURE; |
| 367 | } |
| 368 | *enable_sta_cxn_5g_band = pm_ctx->cfg.enable_sta_cxn_5g_band; |
| 369 | |
| 370 | return QDF_STATUS_SUCCESS; |
| 371 | } |
| 372 | |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 373 | void policy_mgr_update_new_hw_mode_index(struct wlan_objmgr_psoc *psoc, |
| 374 | uint32_t new_hw_mode_index) |
| 375 | { |
| 376 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 377 | |
| 378 | pm_ctx = policy_mgr_get_context(psoc); |
| 379 | if (!pm_ctx) { |
| 380 | policy_mgr_err("Invalid Context"); |
| 381 | return; |
| 382 | } |
| 383 | pm_ctx->new_hw_mode_index = new_hw_mode_index; |
| 384 | } |
| 385 | |
| 386 | void policy_mgr_update_old_hw_mode_index(struct wlan_objmgr_psoc *psoc, |
| 387 | uint32_t old_hw_mode_index) |
| 388 | { |
| 389 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 390 | |
| 391 | pm_ctx = policy_mgr_get_context(psoc); |
| 392 | if (!pm_ctx) { |
| 393 | policy_mgr_err("Invalid Context"); |
| 394 | return; |
| 395 | } |
| 396 | pm_ctx->old_hw_mode_index = old_hw_mode_index; |
| 397 | } |
| 398 | |
| 399 | void policy_mgr_update_hw_mode_index(struct wlan_objmgr_psoc *psoc, |
| 400 | uint32_t new_hw_mode_index) |
| 401 | { |
| 402 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 403 | |
| 404 | pm_ctx = policy_mgr_get_context(psoc); |
| 405 | if (!pm_ctx) { |
| 406 | policy_mgr_err("Invalid Context"); |
| 407 | return; |
| 408 | } |
| 409 | if (POLICY_MGR_DEFAULT_HW_MODE_INDEX == pm_ctx->new_hw_mode_index) { |
| 410 | pm_ctx->new_hw_mode_index = new_hw_mode_index; |
| 411 | } else { |
| 412 | pm_ctx->old_hw_mode_index = pm_ctx->new_hw_mode_index; |
| 413 | pm_ctx->new_hw_mode_index = new_hw_mode_index; |
| 414 | } |
| 415 | policy_mgr_debug("Updated: old_hw_mode_index:%d new_hw_mode_index:%d", |
| 416 | pm_ctx->old_hw_mode_index, pm_ctx->new_hw_mode_index); |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * policy_mgr_get_num_of_setbits_from_bitmask() - to get num of |
| 421 | * setbits from bitmask |
| 422 | * @mask: given bitmask |
| 423 | * |
| 424 | * This helper function should return number of setbits from bitmask |
| 425 | * |
| 426 | * Return: number of setbits from bitmask |
| 427 | */ |
| 428 | static uint32_t policy_mgr_get_num_of_setbits_from_bitmask(uint32_t mask) |
| 429 | { |
| 430 | uint32_t num_of_setbits = 0; |
| 431 | |
| 432 | while (mask) { |
| 433 | mask &= (mask - 1); |
| 434 | num_of_setbits++; |
| 435 | } |
| 436 | return num_of_setbits; |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * policy_mgr_map_wmi_channel_width_to_hw_mode_bw() - returns |
| 441 | * bandwidth in terms of hw_mode_bandwidth |
| 442 | * @width: bandwidth in terms of wmi_channel_width |
| 443 | * |
| 444 | * This function returns the bandwidth in terms of hw_mode_bandwidth. |
| 445 | * |
| 446 | * Return: BW in terms of hw_mode_bandwidth. |
| 447 | */ |
| 448 | static enum hw_mode_bandwidth policy_mgr_map_wmi_channel_width_to_hw_mode_bw( |
| 449 | wmi_channel_width width) |
| 450 | { |
| 451 | switch (width) { |
| 452 | case WMI_CHAN_WIDTH_20: |
| 453 | return HW_MODE_20_MHZ; |
| 454 | case WMI_CHAN_WIDTH_40: |
| 455 | return HW_MODE_40_MHZ; |
| 456 | case WMI_CHAN_WIDTH_80: |
| 457 | return HW_MODE_80_MHZ; |
| 458 | case WMI_CHAN_WIDTH_160: |
| 459 | return HW_MODE_160_MHZ; |
| 460 | case WMI_CHAN_WIDTH_80P80: |
| 461 | return HW_MODE_80_PLUS_80_MHZ; |
| 462 | case WMI_CHAN_WIDTH_5: |
| 463 | return HW_MODE_5_MHZ; |
| 464 | case WMI_CHAN_WIDTH_10: |
| 465 | return HW_MODE_10_MHZ; |
| 466 | default: |
| 467 | return HW_MODE_BW_NONE; |
| 468 | } |
| 469 | |
| 470 | return HW_MODE_BW_NONE; |
| 471 | } |
| 472 | |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 473 | static void policy_mgr_get_hw_mode_params( |
| 474 | struct wlan_psoc_host_mac_phy_caps *caps, |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 475 | struct policy_mgr_mac_ss_bw_info *info) |
| 476 | { |
| 477 | if (!caps) { |
| 478 | policy_mgr_err("Invalid capabilities"); |
| 479 | return; |
| 480 | } |
| 481 | |
| 482 | info->mac_tx_stream = policy_mgr_get_num_of_setbits_from_bitmask( |
| 483 | QDF_MAX(caps->tx_chain_mask_2G, |
| 484 | caps->tx_chain_mask_5G)); |
| 485 | info->mac_rx_stream = policy_mgr_get_num_of_setbits_from_bitmask( |
| 486 | QDF_MAX(caps->rx_chain_mask_2G, |
| 487 | caps->rx_chain_mask_5G)); |
| 488 | info->mac_bw = policy_mgr_map_wmi_channel_width_to_hw_mode_bw( |
| 489 | QDF_MAX(caps->max_bw_supported_2G, |
| 490 | caps->max_bw_supported_5G)); |
Liangwei Dong | e57b6b7 | 2018-05-21 04:51:47 -0400 | [diff] [blame] | 491 | info->mac_band_cap = caps->supported_bands; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | /** |
| 495 | * policy_mgr_set_hw_mode_params() - sets TX-RX stream, |
| 496 | * bandwidth and DBS in hw_mode_list |
| 497 | * @wma_handle: pointer to wma global structure |
| 498 | * @mac0_ss_bw_info: TX-RX streams, BW for MAC0 |
| 499 | * @mac1_ss_bw_info: TX-RX streams, BW for MAC1 |
Liangwei Dong | e57b6b7 | 2018-05-21 04:51:47 -0400 | [diff] [blame] | 500 | * @pos: refers to hw_mode_list array index |
| 501 | * @hw_mode_id: hw mode id value used by firmware |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 502 | * @dbs_mode: dbs_mode for the dbs_hw_mode |
| 503 | * @sbs_mode: sbs_mode for the sbs_hw_mode |
| 504 | * |
| 505 | * This function sets TX-RX stream, bandwidth and DBS mode in |
| 506 | * hw_mode_list. |
| 507 | * |
| 508 | * Return: none |
| 509 | */ |
| 510 | static void policy_mgr_set_hw_mode_params(struct wlan_objmgr_psoc *psoc, |
| 511 | struct policy_mgr_mac_ss_bw_info mac0_ss_bw_info, |
| 512 | struct policy_mgr_mac_ss_bw_info mac1_ss_bw_info, |
Liangwei Dong | e57b6b7 | 2018-05-21 04:51:47 -0400 | [diff] [blame] | 513 | uint32_t pos, uint32_t hw_mode_id, uint32_t dbs_mode, |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 514 | uint32_t sbs_mode) |
| 515 | { |
| 516 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 517 | |
| 518 | pm_ctx = policy_mgr_get_context(psoc); |
| 519 | if (!pm_ctx) { |
| 520 | policy_mgr_err("Invalid Context"); |
| 521 | return; |
| 522 | } |
| 523 | |
| 524 | POLICY_MGR_HW_MODE_MAC0_TX_STREAMS_SET( |
| 525 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 526 | mac0_ss_bw_info.mac_tx_stream); |
| 527 | POLICY_MGR_HW_MODE_MAC0_RX_STREAMS_SET( |
| 528 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 529 | mac0_ss_bw_info.mac_rx_stream); |
| 530 | POLICY_MGR_HW_MODE_MAC0_BANDWIDTH_SET( |
| 531 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 532 | mac0_ss_bw_info.mac_bw); |
| 533 | POLICY_MGR_HW_MODE_MAC1_TX_STREAMS_SET( |
| 534 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 535 | mac1_ss_bw_info.mac_tx_stream); |
| 536 | POLICY_MGR_HW_MODE_MAC1_RX_STREAMS_SET( |
| 537 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 538 | mac1_ss_bw_info.mac_rx_stream); |
| 539 | POLICY_MGR_HW_MODE_MAC1_BANDWIDTH_SET( |
| 540 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 541 | mac1_ss_bw_info.mac_bw); |
| 542 | POLICY_MGR_HW_MODE_DBS_MODE_SET( |
| 543 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 544 | dbs_mode); |
| 545 | POLICY_MGR_HW_MODE_AGILE_DFS_SET( |
| 546 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 547 | HW_MODE_AGILE_DFS_NONE); |
| 548 | POLICY_MGR_HW_MODE_SBS_MODE_SET( |
| 549 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 550 | sbs_mode); |
Liangwei Dong | e57b6b7 | 2018-05-21 04:51:47 -0400 | [diff] [blame] | 551 | POLICY_MGR_HW_MODE_MAC0_BAND_SET( |
| 552 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 553 | mac0_ss_bw_info.mac_band_cap); |
| 554 | POLICY_MGR_HW_MODE_ID_SET( |
| 555 | pm_ctx->hw_mode.hw_mode_list[pos], |
| 556 | hw_mode_id); |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | QDF_STATUS policy_mgr_update_hw_mode_list(struct wlan_objmgr_psoc *psoc, |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 560 | struct target_psoc_info *tgt_hdl) |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 561 | { |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 562 | struct wlan_psoc_host_mac_phy_caps *tmp; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 563 | uint32_t i, hw_config_type, j = 0; |
| 564 | uint32_t dbs_mode, sbs_mode; |
| 565 | struct policy_mgr_mac_ss_bw_info mac0_ss_bw_info = {0}; |
| 566 | struct policy_mgr_mac_ss_bw_info mac1_ss_bw_info = {0}; |
| 567 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 568 | struct tgt_info *info; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 569 | |
| 570 | pm_ctx = policy_mgr_get_context(psoc); |
| 571 | if (!pm_ctx) { |
| 572 | policy_mgr_err("Invalid Context"); |
| 573 | return QDF_STATUS_E_FAILURE; |
| 574 | } |
| 575 | |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 576 | info = &tgt_hdl->info; |
| 577 | if (!info->service_ext_param.num_hw_modes) { |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 578 | policy_mgr_err("Number of HW modes: %d", |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 579 | info->service_ext_param.num_hw_modes); |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 580 | return QDF_STATUS_E_FAILURE; |
| 581 | } |
| 582 | |
| 583 | /* |
| 584 | * This list was updated as part of service ready event. Re-populate |
| 585 | * HW mode list from the device capabilities. |
| 586 | */ |
| 587 | if (pm_ctx->hw_mode.hw_mode_list) { |
| 588 | qdf_mem_free(pm_ctx->hw_mode.hw_mode_list); |
| 589 | pm_ctx->hw_mode.hw_mode_list = NULL; |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 590 | policy_mgr_debug("DBS list is freed"); |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 591 | } |
| 592 | |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 593 | pm_ctx->num_dbs_hw_modes = info->service_ext_param.num_hw_modes; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 594 | pm_ctx->hw_mode.hw_mode_list = |
| 595 | qdf_mem_malloc(sizeof(*pm_ctx->hw_mode.hw_mode_list) * |
| 596 | pm_ctx->num_dbs_hw_modes); |
| 597 | if (!pm_ctx->hw_mode.hw_mode_list) { |
| 598 | policy_mgr_err("Memory allocation failed for DBS"); |
| 599 | return QDF_STATUS_E_FAILURE; |
| 600 | } |
| 601 | |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 602 | policy_mgr_debug("Updated HW mode list: Num modes:%d", |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 603 | pm_ctx->num_dbs_hw_modes); |
| 604 | |
| 605 | for (i = 0; i < pm_ctx->num_dbs_hw_modes; i++) { |
| 606 | /* Update for MAC0 */ |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 607 | tmp = &info->mac_phy_cap[j++]; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 608 | policy_mgr_get_hw_mode_params(tmp, &mac0_ss_bw_info); |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 609 | hw_config_type = tmp->hw_mode_config_type; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 610 | dbs_mode = HW_MODE_DBS_NONE; |
| 611 | sbs_mode = HW_MODE_SBS_NONE; |
| 612 | mac1_ss_bw_info.mac_tx_stream = 0; |
| 613 | mac1_ss_bw_info.mac_rx_stream = 0; |
| 614 | mac1_ss_bw_info.mac_bw = 0; |
| 615 | |
| 616 | /* SBS and DBS have dual MAC. Upto 2 MACs are considered. */ |
| 617 | if ((hw_config_type == WMI_HW_MODE_DBS) || |
| 618 | (hw_config_type == WMI_HW_MODE_SBS_PASSIVE) || |
| 619 | (hw_config_type == WMI_HW_MODE_SBS)) { |
| 620 | /* Update for MAC1 */ |
Arunk Khandavalli | 24167fc | 2018-02-05 15:42:31 +0530 | [diff] [blame] | 621 | tmp = &info->mac_phy_cap[j++]; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 622 | policy_mgr_get_hw_mode_params(tmp, &mac1_ss_bw_info); |
| 623 | if (hw_config_type == WMI_HW_MODE_DBS) |
| 624 | dbs_mode = HW_MODE_DBS; |
| 625 | if ((hw_config_type == WMI_HW_MODE_SBS_PASSIVE) || |
| 626 | (hw_config_type == WMI_HW_MODE_SBS)) |
| 627 | sbs_mode = HW_MODE_SBS; |
| 628 | } |
| 629 | |
| 630 | /* Updating HW mode list */ |
| 631 | policy_mgr_set_hw_mode_params(psoc, mac0_ss_bw_info, |
Liangwei Dong | e57b6b7 | 2018-05-21 04:51:47 -0400 | [diff] [blame] | 632 | mac1_ss_bw_info, i, tmp->hw_mode_id, dbs_mode, |
| 633 | sbs_mode); |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 634 | } |
| 635 | return QDF_STATUS_SUCCESS; |
| 636 | } |
| 637 | |
| 638 | void policy_mgr_init_dbs_hw_mode(struct wlan_objmgr_psoc *psoc, |
| 639 | uint32_t num_dbs_hw_modes, |
| 640 | uint32_t *ev_wlan_dbs_hw_mode_list) |
| 641 | { |
| 642 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 643 | |
| 644 | pm_ctx = policy_mgr_get_context(psoc); |
| 645 | if (!pm_ctx) { |
| 646 | policy_mgr_err("Invalid Context"); |
| 647 | return; |
| 648 | } |
| 649 | |
| 650 | pm_ctx->num_dbs_hw_modes = num_dbs_hw_modes; |
| 651 | pm_ctx->hw_mode.hw_mode_list = |
| 652 | qdf_mem_malloc(sizeof(*pm_ctx->hw_mode.hw_mode_list) * |
| 653 | pm_ctx->num_dbs_hw_modes); |
| 654 | if (!pm_ctx->hw_mode.hw_mode_list) { |
| 655 | policy_mgr_err("Memory allocation failed for DBS"); |
| 656 | return; |
| 657 | } |
| 658 | qdf_mem_copy(pm_ctx->hw_mode.hw_mode_list, |
| 659 | ev_wlan_dbs_hw_mode_list, |
| 660 | (sizeof(*pm_ctx->hw_mode.hw_mode_list) * |
| 661 | pm_ctx->num_dbs_hw_modes)); |
| 662 | } |
| 663 | |
| 664 | void policy_mgr_dump_dbs_hw_mode(struct wlan_objmgr_psoc *psoc) |
| 665 | { |
| 666 | uint32_t i, param; |
| 667 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 668 | |
| 669 | pm_ctx = policy_mgr_get_context(psoc); |
| 670 | if (!pm_ctx) { |
| 671 | policy_mgr_err("Invalid Context"); |
| 672 | return; |
| 673 | } |
| 674 | |
| 675 | for (i = 0; i < pm_ctx->num_dbs_hw_modes; i++) { |
| 676 | param = pm_ctx->hw_mode.hw_mode_list[i]; |
Liangwei Dong | e57b6b7 | 2018-05-21 04:51:47 -0400 | [diff] [blame] | 677 | policy_mgr_debug("[%d]-MAC0: tx_ss:%d rx_ss:%d bw_idx:%d band_cap:%d", |
| 678 | i, |
| 679 | POLICY_MGR_HW_MODE_MAC0_TX_STREAMS_GET(param), |
| 680 | POLICY_MGR_HW_MODE_MAC0_RX_STREAMS_GET(param), |
| 681 | POLICY_MGR_HW_MODE_MAC0_BANDWIDTH_GET(param), |
| 682 | POLICY_MGR_HW_MODE_MAC0_BAND_GET(param)); |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 683 | policy_mgr_debug("[%d]-MAC1: tx_ss:%d rx_ss:%d bw_idx:%d", |
Liangwei Dong | e57b6b7 | 2018-05-21 04:51:47 -0400 | [diff] [blame] | 684 | i, |
| 685 | POLICY_MGR_HW_MODE_MAC1_TX_STREAMS_GET(param), |
| 686 | POLICY_MGR_HW_MODE_MAC1_RX_STREAMS_GET(param), |
| 687 | POLICY_MGR_HW_MODE_MAC1_BANDWIDTH_GET(param)); |
| 688 | policy_mgr_debug("[%d] DBS:%d SBS:%d hw_mode_id:%d", i, |
| 689 | POLICY_MGR_HW_MODE_DBS_MODE_GET(param), |
| 690 | POLICY_MGR_HW_MODE_SBS_MODE_GET(param), |
| 691 | POLICY_MGR_HW_MODE_ID_GET(param)); |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 692 | } |
| 693 | } |
| 694 | |
| 695 | void policy_mgr_init_dbs_config(struct wlan_objmgr_psoc *psoc, |
| 696 | uint32_t scan_config, uint32_t fw_config) |
| 697 | { |
| 698 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Bala Venkatesh | 9391de3 | 2019-01-25 12:57:20 +0530 | [diff] [blame] | 699 | uint8_t dual_mac_feature; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 700 | |
| 701 | pm_ctx = policy_mgr_get_context(psoc); |
| 702 | if (!pm_ctx) { |
| 703 | policy_mgr_err("Invalid Context"); |
| 704 | return; |
| 705 | } |
| 706 | pm_ctx->dual_mac_cfg.cur_scan_config = 0; |
| 707 | pm_ctx->dual_mac_cfg.cur_fw_mode_config = 0; |
| 708 | |
Bala Venkatesh | 9391de3 | 2019-01-25 12:57:20 +0530 | [diff] [blame] | 709 | dual_mac_feature = pm_ctx->cfg.dual_mac_feature; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 710 | /* If dual mac features are disabled in the INI, we |
| 711 | * need not proceed further |
| 712 | */ |
Bala Venkatesh | 9391de3 | 2019-01-25 12:57:20 +0530 | [diff] [blame] | 713 | if (dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) { |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 714 | policy_mgr_err("Disabling dual mac capabilities"); |
Jeff Johnson | 656fa9a | 2018-05-06 00:15:04 -0700 | [diff] [blame] | 715 | /* All capabilities are initialized to 0. We can return */ |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 716 | goto done; |
| 717 | } |
| 718 | |
| 719 | /* Initialize concurrent_scan_config_bits with default FW value */ |
Tushnim Bhattacharyya | ecc6e10 | 2017-05-26 18:25:56 -0700 | [diff] [blame] | 720 | WMI_DBS_CONC_SCAN_CFG_ASYNC_DBS_SCAN_SET( |
| 721 | pm_ctx->dual_mac_cfg.cur_scan_config, |
| 722 | WMI_DBS_CONC_SCAN_CFG_ASYNC_DBS_SCAN_GET(scan_config)); |
| 723 | WMI_DBS_CONC_SCAN_CFG_SYNC_DBS_SCAN_SET( |
| 724 | pm_ctx->dual_mac_cfg.cur_scan_config, |
| 725 | WMI_DBS_CONC_SCAN_CFG_SYNC_DBS_SCAN_GET(scan_config)); |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 726 | WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_SET( |
| 727 | pm_ctx->dual_mac_cfg.cur_scan_config, |
| 728 | WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_GET(scan_config)); |
| 729 | WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_SET( |
| 730 | pm_ctx->dual_mac_cfg.cur_scan_config, |
| 731 | WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_GET(scan_config)); |
| 732 | WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_SET( |
| 733 | pm_ctx->dual_mac_cfg.cur_scan_config, |
| 734 | WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_GET(scan_config)); |
| 735 | |
| 736 | /* Initialize fw_mode_config_bits with default FW value */ |
| 737 | WMI_DBS_FW_MODE_CFG_DBS_SET( |
| 738 | pm_ctx->dual_mac_cfg.cur_fw_mode_config, |
| 739 | WMI_DBS_FW_MODE_CFG_DBS_GET(fw_config)); |
| 740 | WMI_DBS_FW_MODE_CFG_AGILE_DFS_SET( |
| 741 | pm_ctx->dual_mac_cfg.cur_fw_mode_config, |
| 742 | WMI_DBS_FW_MODE_CFG_AGILE_DFS_GET(fw_config)); |
Tushnim Bhattacharyya | ecc6e10 | 2017-05-26 18:25:56 -0700 | [diff] [blame] | 743 | WMI_DBS_FW_MODE_CFG_DBS_FOR_CXN_SET( |
| 744 | pm_ctx->dual_mac_cfg.cur_fw_mode_config, |
| 745 | WMI_DBS_FW_MODE_CFG_DBS_FOR_CXN_GET(fw_config)); |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 746 | done: |
| 747 | /* Initialize the previous scan/fw mode config */ |
| 748 | pm_ctx->dual_mac_cfg.prev_scan_config = |
| 749 | pm_ctx->dual_mac_cfg.cur_scan_config; |
| 750 | pm_ctx->dual_mac_cfg.prev_fw_mode_config = |
| 751 | pm_ctx->dual_mac_cfg.cur_fw_mode_config; |
| 752 | |
| 753 | policy_mgr_debug("cur_scan_config:%x cur_fw_mode_config:%x", |
| 754 | pm_ctx->dual_mac_cfg.cur_scan_config, |
| 755 | pm_ctx->dual_mac_cfg.cur_fw_mode_config); |
| 756 | } |
| 757 | |
| 758 | void policy_mgr_update_dbs_scan_config(struct wlan_objmgr_psoc *psoc) |
| 759 | { |
| 760 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 761 | |
| 762 | pm_ctx = policy_mgr_get_context(psoc); |
| 763 | if (!pm_ctx) { |
| 764 | policy_mgr_err("Invalid Context"); |
| 765 | return; |
| 766 | } |
| 767 | |
| 768 | pm_ctx->dual_mac_cfg.prev_scan_config = |
| 769 | pm_ctx->dual_mac_cfg.cur_scan_config; |
| 770 | pm_ctx->dual_mac_cfg.cur_scan_config = |
| 771 | pm_ctx->dual_mac_cfg.req_scan_config; |
| 772 | } |
| 773 | |
| 774 | void policy_mgr_update_dbs_fw_config(struct wlan_objmgr_psoc *psoc) |
| 775 | { |
| 776 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 777 | |
| 778 | pm_ctx = policy_mgr_get_context(psoc); |
| 779 | if (!pm_ctx) { |
| 780 | policy_mgr_err("Invalid Context"); |
| 781 | return; |
| 782 | } |
| 783 | |
| 784 | pm_ctx->dual_mac_cfg.prev_fw_mode_config = |
| 785 | pm_ctx->dual_mac_cfg.cur_fw_mode_config; |
| 786 | pm_ctx->dual_mac_cfg.cur_fw_mode_config = |
| 787 | pm_ctx->dual_mac_cfg.req_fw_mode_config; |
| 788 | } |
| 789 | |
| 790 | void policy_mgr_update_dbs_req_config(struct wlan_objmgr_psoc *psoc, |
| 791 | uint32_t scan_config, uint32_t fw_mode_config) |
| 792 | { |
| 793 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 794 | |
| 795 | pm_ctx = policy_mgr_get_context(psoc); |
| 796 | if (!pm_ctx) { |
| 797 | policy_mgr_err("Invalid Context"); |
| 798 | return; |
| 799 | } |
| 800 | pm_ctx->dual_mac_cfg.req_scan_config = scan_config; |
| 801 | pm_ctx->dual_mac_cfg.req_fw_mode_config = fw_mode_config; |
| 802 | } |
| 803 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 804 | bool policy_mgr_get_dbs_plus_agile_scan_config(struct wlan_objmgr_psoc *psoc) |
| 805 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 806 | uint32_t scan_config; |
| 807 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 808 | |
| 809 | if (policy_mgr_is_dual_mac_disabled_in_ini(psoc)) |
| 810 | return false; |
| 811 | |
| 812 | |
| 813 | pm_ctx = policy_mgr_get_context(psoc); |
| 814 | if (!pm_ctx) { |
| 815 | policy_mgr_err("Invalid Context"); |
| 816 | /* We take that it is disabled and proceed */ |
| 817 | return false; |
| 818 | } |
| 819 | scan_config = pm_ctx->dual_mac_cfg.cur_scan_config; |
| 820 | |
| 821 | return WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_GET(scan_config); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | bool policy_mgr_get_single_mac_scan_with_dfs_config( |
| 825 | struct wlan_objmgr_psoc *psoc) |
| 826 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 827 | uint32_t scan_config; |
| 828 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 829 | |
| 830 | if (policy_mgr_is_dual_mac_disabled_in_ini(psoc)) |
| 831 | return false; |
| 832 | |
| 833 | |
| 834 | pm_ctx = policy_mgr_get_context(psoc); |
| 835 | if (!pm_ctx) { |
| 836 | policy_mgr_err("Invalid Context"); |
| 837 | /* We take that it is disabled and proceed */ |
| 838 | return false; |
| 839 | } |
| 840 | scan_config = pm_ctx->dual_mac_cfg.cur_scan_config; |
| 841 | |
| 842 | return WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_GET(scan_config); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | int8_t policy_mgr_get_num_dbs_hw_modes(struct wlan_objmgr_psoc *psoc) |
| 846 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 847 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 848 | |
| 849 | pm_ctx = policy_mgr_get_context(psoc); |
| 850 | if (!pm_ctx) { |
| 851 | policy_mgr_err("Invalid Context"); |
| 852 | return -EINVAL; |
| 853 | } |
| 854 | return pm_ctx->num_dbs_hw_modes; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 855 | } |
| 856 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 857 | bool policy_mgr_find_if_fw_supports_dbs(struct wlan_objmgr_psoc *psoc) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 858 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 859 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Tushnim Bhattacharyya | 5dd541e | 2018-08-30 10:20:31 -0700 | [diff] [blame] | 860 | struct wmi_unified *wmi_handle; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 861 | bool dbs_support; |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 862 | |
| 863 | pm_ctx = policy_mgr_get_context(psoc); |
Sourav Mohapatra | 0c1a7f6 | 2017-12-03 11:44:44 +0530 | [diff] [blame] | 864 | |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 865 | if (!pm_ctx) { |
| 866 | policy_mgr_err("Invalid Context"); |
| 867 | return false; |
| 868 | } |
Tushnim Bhattacharyya | 5dd541e | 2018-08-30 10:20:31 -0700 | [diff] [blame] | 869 | wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); |
Sourav Mohapatra | 0c1a7f6 | 2017-12-03 11:44:44 +0530 | [diff] [blame] | 870 | if (!wmi_handle) { |
Tushnim Bhattacharyya | 5dd541e | 2018-08-30 10:20:31 -0700 | [diff] [blame] | 871 | policy_mgr_debug("Invalid WMI handle"); |
Sourav Mohapatra | 0c1a7f6 | 2017-12-03 11:44:44 +0530 | [diff] [blame] | 872 | return false; |
| 873 | } |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 874 | dbs_support = |
| 875 | wmi_service_enabled(wmi_handle, |
| 876 | wmi_service_dual_band_simultaneous_support); |
Sourav Mohapatra | 0c1a7f6 | 2017-12-03 11:44:44 +0530 | [diff] [blame] | 877 | |
| 878 | /* The agreement with FW is that: To know if the target is DBS |
| 879 | * capable, DBS needs to be supported both in the HW mode list |
| 880 | * and in the service ready event |
| 881 | */ |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 882 | if (!dbs_support) |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 883 | return false; |
| 884 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 885 | return true; |
| 886 | } |
| 887 | |
gaurank kathpalia | e314029 | 2019-11-12 16:44:31 +0530 | [diff] [blame] | 888 | bool policy_mgr_find_if_hwlist_has_dbs(struct wlan_objmgr_psoc *psoc) |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 889 | { |
| 890 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 891 | uint32_t param, i, found = 0; |
| 892 | |
| 893 | pm_ctx = policy_mgr_get_context(psoc); |
| 894 | |
| 895 | if (!pm_ctx) { |
| 896 | policy_mgr_err("Invalid Context"); |
| 897 | return false; |
| 898 | } |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 899 | for (i = 0; i < pm_ctx->num_dbs_hw_modes; i++) { |
| 900 | param = pm_ctx->hw_mode.hw_mode_list[i]; |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 901 | if (POLICY_MGR_HW_MODE_DBS_MODE_GET(param)) { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 902 | found = 1; |
| 903 | break; |
| 904 | } |
| 905 | } |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 906 | if (found) |
| 907 | return true; |
| 908 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 909 | return false; |
| 910 | } |
| 911 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 912 | static bool policy_mgr_find_if_hwlist_has_sbs(struct wlan_objmgr_psoc *psoc) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 913 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 914 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 915 | uint32_t param, i, found = 0; |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 916 | |
| 917 | pm_ctx = policy_mgr_get_context(psoc); |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 918 | |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 919 | if (!pm_ctx) { |
| 920 | policy_mgr_err("Invalid Context"); |
| 921 | return false; |
| 922 | } |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 923 | for (i = 0; i < pm_ctx->num_dbs_hw_modes; i++) { |
| 924 | param = pm_ctx->hw_mode.hw_mode_list[i]; |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 925 | if (POLICY_MGR_HW_MODE_SBS_MODE_GET(param)) { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 926 | found = 1; |
| 927 | break; |
| 928 | } |
| 929 | } |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 930 | if (found) |
| 931 | return true; |
| 932 | |
Archana Ramachandran | 878422f | 2017-03-23 11:34:02 -0700 | [diff] [blame] | 933 | return false; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 934 | } |
| 935 | |
gaurank kathpalia | 6ee1ab4 | 2019-06-19 14:00:30 +0530 | [diff] [blame] | 936 | bool policy_mgr_is_dbs_scan_allowed(struct wlan_objmgr_psoc *psoc) |
| 937 | { |
| 938 | uint8_t dbs_type = DISABLE_DBS_CXN_AND_SCAN; |
| 939 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 940 | |
| 941 | pm_ctx = policy_mgr_get_context(psoc); |
| 942 | if (!pm_ctx) { |
| 943 | policy_mgr_err("Invalid Context"); |
| 944 | return false; |
| 945 | } |
| 946 | |
| 947 | if (!policy_mgr_find_if_fw_supports_dbs(psoc) || |
Abhishek Singh | 48175fd | 2020-01-29 17:03:49 +0530 | [diff] [blame] | 948 | !policy_mgr_find_if_hwlist_has_dbs(psoc)) |
gaurank kathpalia | 6ee1ab4 | 2019-06-19 14:00:30 +0530 | [diff] [blame] | 949 | return false; |
gaurank kathpalia | 6ee1ab4 | 2019-06-19 14:00:30 +0530 | [diff] [blame] | 950 | |
| 951 | policy_mgr_get_dual_mac_feature(psoc, &dbs_type); |
| 952 | /* |
| 953 | * If DBS support for scan is disabled through INI then DBS is not |
| 954 | * supported for scan. |
| 955 | * |
| 956 | * For DBS scan check the INI value explicitly |
| 957 | */ |
| 958 | switch (dbs_type) { |
| 959 | case DISABLE_DBS_CXN_AND_SCAN: |
| 960 | case ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN: |
| 961 | return false; |
| 962 | default: |
| 963 | return true; |
| 964 | } |
| 965 | } |
| 966 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 967 | bool policy_mgr_is_hw_dbs_capable(struct wlan_objmgr_psoc *psoc) |
| 968 | { |
Amruta Kulkarni | 447a326 | 2020-02-05 14:57:04 -0800 | [diff] [blame] | 969 | if (!policy_mgr_is_dbs_enable(psoc)) |
| 970 | return false; |
| 971 | |
| 972 | if (!policy_mgr_find_if_fw_supports_dbs(psoc)) |
| 973 | return false; |
| 974 | |
| 975 | if (!policy_mgr_find_if_hwlist_has_dbs(psoc)) { |
| 976 | policymgr_nofl_debug("HW mode list has no DBS"); |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 977 | return false; |
| 978 | } |
| 979 | |
Amruta Kulkarni | 447a326 | 2020-02-05 14:57:04 -0800 | [diff] [blame] | 980 | return true; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | bool policy_mgr_is_hw_sbs_capable(struct wlan_objmgr_psoc *psoc) |
| 984 | { |
| 985 | if (!policy_mgr_find_if_fw_supports_dbs(psoc)) { |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 986 | return false; |
| 987 | } |
| 988 | |
Amruta Kulkarni | 447a326 | 2020-02-05 14:57:04 -0800 | [diff] [blame] | 989 | if (!policy_mgr_find_if_hwlist_has_sbs(psoc)) { |
| 990 | policymgr_nofl_debug("HW mode list has no SBS"); |
| 991 | return false; |
| 992 | } |
| 993 | |
| 994 | return true; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 995 | } |
| 996 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 997 | QDF_STATUS policy_mgr_get_dbs_hw_modes(struct wlan_objmgr_psoc *psoc, |
| 998 | bool *one_by_one_dbs, bool *two_by_two_dbs) |
| 999 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1000 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1001 | uint32_t i; |
| 1002 | int8_t found_one_by_one = -EINVAL, found_two_by_two = -EINVAL; |
| 1003 | uint32_t conf1_tx_ss, conf1_rx_ss; |
| 1004 | uint32_t conf2_tx_ss, conf2_rx_ss; |
| 1005 | |
| 1006 | *one_by_one_dbs = false; |
| 1007 | *two_by_two_dbs = false; |
| 1008 | |
| 1009 | if (policy_mgr_is_hw_dbs_capable(psoc) == false) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 1010 | policy_mgr_rl_debug("HW is not DBS capable"); |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1011 | /* Caller will understand that DBS is disabled */ |
| 1012 | return QDF_STATUS_SUCCESS; |
| 1013 | |
| 1014 | } |
| 1015 | |
| 1016 | pm_ctx = policy_mgr_get_context(psoc); |
| 1017 | if (!pm_ctx) { |
| 1018 | policy_mgr_err("Invalid Context"); |
| 1019 | return QDF_STATUS_E_FAILURE; |
| 1020 | } |
| 1021 | |
| 1022 | /* To check 1x1 capability */ |
| 1023 | policy_mgr_get_tx_rx_ss_from_config(HW_MODE_SS_1x1, |
| 1024 | &conf1_tx_ss, &conf1_rx_ss); |
| 1025 | /* To check 2x2 capability */ |
| 1026 | policy_mgr_get_tx_rx_ss_from_config(HW_MODE_SS_2x2, |
| 1027 | &conf2_tx_ss, &conf2_rx_ss); |
| 1028 | |
| 1029 | for (i = 0; i < pm_ctx->num_dbs_hw_modes; i++) { |
| 1030 | uint32_t t_conf0_tx_ss, t_conf0_rx_ss; |
| 1031 | uint32_t t_conf1_tx_ss, t_conf1_rx_ss; |
| 1032 | uint32_t dbs_mode; |
| 1033 | |
| 1034 | t_conf0_tx_ss = POLICY_MGR_HW_MODE_MAC0_TX_STREAMS_GET( |
| 1035 | pm_ctx->hw_mode.hw_mode_list[i]); |
| 1036 | t_conf0_rx_ss = POLICY_MGR_HW_MODE_MAC0_RX_STREAMS_GET( |
| 1037 | pm_ctx->hw_mode.hw_mode_list[i]); |
| 1038 | t_conf1_tx_ss = POLICY_MGR_HW_MODE_MAC1_TX_STREAMS_GET( |
| 1039 | pm_ctx->hw_mode.hw_mode_list[i]); |
| 1040 | t_conf1_rx_ss = POLICY_MGR_HW_MODE_MAC1_RX_STREAMS_GET( |
| 1041 | pm_ctx->hw_mode.hw_mode_list[i]); |
| 1042 | dbs_mode = POLICY_MGR_HW_MODE_DBS_MODE_GET( |
| 1043 | pm_ctx->hw_mode.hw_mode_list[i]); |
| 1044 | |
| 1045 | if (((((t_conf0_tx_ss == conf1_tx_ss) && |
| 1046 | (t_conf0_rx_ss == conf1_rx_ss)) || |
| 1047 | ((t_conf1_tx_ss == conf1_tx_ss) && |
| 1048 | (t_conf1_rx_ss == conf1_rx_ss))) && |
| 1049 | (dbs_mode == HW_MODE_DBS)) && |
| 1050 | (found_one_by_one < 0)) { |
| 1051 | found_one_by_one = i; |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1052 | policy_mgr_debug("1x1 hw_mode index %d found", i); |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1053 | /* Once an entry is found, need not check for 1x1 |
| 1054 | * again |
| 1055 | */ |
| 1056 | continue; |
| 1057 | } |
| 1058 | |
| 1059 | if (((((t_conf0_tx_ss == conf2_tx_ss) && |
| 1060 | (t_conf0_rx_ss == conf2_rx_ss)) || |
| 1061 | ((t_conf1_tx_ss == conf2_tx_ss) && |
| 1062 | (t_conf1_rx_ss == conf2_rx_ss))) && |
| 1063 | (dbs_mode == HW_MODE_DBS)) && |
| 1064 | (found_two_by_two < 0)) { |
| 1065 | found_two_by_two = i; |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1066 | policy_mgr_debug("2x2 hw_mode index %d found", i); |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1067 | /* Once an entry is found, need not check for 2x2 |
| 1068 | * again |
| 1069 | */ |
| 1070 | continue; |
| 1071 | } |
| 1072 | } |
| 1073 | |
| 1074 | if (found_one_by_one >= 0) |
| 1075 | *one_by_one_dbs = true; |
| 1076 | if (found_two_by_two >= 0) |
| 1077 | *two_by_two_dbs = true; |
| 1078 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1079 | return QDF_STATUS_SUCCESS; |
| 1080 | } |
| 1081 | |
| 1082 | QDF_STATUS policy_mgr_get_current_hw_mode(struct wlan_objmgr_psoc *psoc, |
| 1083 | struct policy_mgr_hw_mode_params *hw_mode) |
| 1084 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1085 | QDF_STATUS status; |
| 1086 | uint32_t old_hw_index = 0, new_hw_index = 0; |
| 1087 | |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1088 | status = policy_mgr_get_old_and_new_hw_index(psoc, &old_hw_index, |
| 1089 | &new_hw_index); |
| 1090 | if (QDF_STATUS_SUCCESS != status) { |
| 1091 | policy_mgr_err("Failed to get HW mode index"); |
| 1092 | return QDF_STATUS_E_FAILURE; |
| 1093 | } |
| 1094 | |
| 1095 | if (new_hw_index == POLICY_MGR_DEFAULT_HW_MODE_INDEX) { |
| 1096 | policy_mgr_err("HW mode is not yet initialized"); |
| 1097 | return QDF_STATUS_E_FAILURE; |
| 1098 | } |
| 1099 | |
| 1100 | status = policy_mgr_get_hw_mode_from_idx(psoc, new_hw_index, hw_mode); |
| 1101 | if (QDF_STATUS_SUCCESS != status) { |
| 1102 | policy_mgr_err("Failed to get HW mode index"); |
| 1103 | return QDF_STATUS_E_FAILURE; |
| 1104 | } |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1105 | return QDF_STATUS_SUCCESS; |
| 1106 | } |
| 1107 | |
| 1108 | bool policy_mgr_is_current_hwmode_dbs(struct wlan_objmgr_psoc *psoc) |
| 1109 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1110 | struct policy_mgr_hw_mode_params hw_mode; |
| 1111 | |
| 1112 | if (!policy_mgr_is_hw_dbs_capable(psoc)) |
| 1113 | return false; |
| 1114 | if (QDF_STATUS_SUCCESS != |
| 1115 | policy_mgr_get_current_hw_mode(psoc, &hw_mode)) |
| 1116 | return false; |
| 1117 | if (hw_mode.dbs_cap) |
| 1118 | return true; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1119 | return false; |
| 1120 | } |
| 1121 | |
| 1122 | bool policy_mgr_is_dbs_enable(struct wlan_objmgr_psoc *psoc) |
| 1123 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1124 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1125 | |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 1126 | if (policy_mgr_is_dual_mac_disabled_in_ini(psoc)) { |
Amruta Kulkarni | 447a326 | 2020-02-05 14:57:04 -0800 | [diff] [blame] | 1127 | policy_mgr_rl_debug("DBS is disabled from ini"); |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1128 | return false; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 1129 | } |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1130 | |
| 1131 | pm_ctx = policy_mgr_get_context(psoc); |
| 1132 | if (!pm_ctx) { |
| 1133 | policy_mgr_err("Invalid Context"); |
| 1134 | return false; |
| 1135 | } |
| 1136 | |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1137 | if (WMI_DBS_FW_MODE_CFG_DBS_GET( |
| 1138 | pm_ctx->dual_mac_cfg.cur_fw_mode_config)) |
| 1139 | return true; |
| 1140 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1141 | return false; |
| 1142 | } |
| 1143 | |
| 1144 | bool policy_mgr_is_hw_dbs_2x2_capable(struct wlan_objmgr_psoc *psoc) |
| 1145 | { |
Liangwei Dong | 897b439 | 2019-11-05 19:16:02 +0800 | [diff] [blame] | 1146 | struct dbs_nss nss_dbs = {0}; |
Liangwei Dong | 1830013 | 2018-05-25 01:25:24 -0400 | [diff] [blame] | 1147 | uint32_t nss; |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1148 | |
Liangwei Dong | 1830013 | 2018-05-25 01:25:24 -0400 | [diff] [blame] | 1149 | nss = policy_mgr_get_hw_dbs_nss(psoc, &nss_dbs); |
| 1150 | if (nss >= HW_MODE_SS_2x2 && (nss_dbs.mac0_ss == nss_dbs.mac1_ss)) |
| 1151 | return true; |
| 1152 | else |
| 1153 | return false; |
| 1154 | } |
| 1155 | |
Liangwei Dong | 897b439 | 2019-11-05 19:16:02 +0800 | [diff] [blame] | 1156 | bool policy_mgr_is_hw_dbs_required_for_band(struct wlan_objmgr_psoc *psoc, |
| 1157 | enum hw_mode_mac_band_cap band) |
| 1158 | { |
| 1159 | struct dbs_nss nss_dbs = {0}; |
| 1160 | uint32_t nss; |
| 1161 | |
| 1162 | nss = policy_mgr_get_hw_dbs_nss(psoc, &nss_dbs); |
| 1163 | if (nss >= HW_MODE_SS_1x1 && nss_dbs.mac0_ss == nss_dbs.mac1_ss && |
| 1164 | !(nss_dbs.single_mac0_band_cap & band)) |
| 1165 | return true; |
| 1166 | else |
| 1167 | return false; |
| 1168 | } |
| 1169 | |
| 1170 | bool policy_mgr_is_dp_hw_dbs_2x2_capable(struct wlan_objmgr_psoc *psoc) |
| 1171 | { |
| 1172 | return policy_mgr_is_hw_dbs_2x2_capable(psoc) || |
| 1173 | policy_mgr_is_hw_dbs_required_for_band(psoc, |
| 1174 | HW_MODE_MAC_BAND_2G); |
| 1175 | } |
| 1176 | |
Liangwei Dong | 1830013 | 2018-05-25 01:25:24 -0400 | [diff] [blame] | 1177 | /* |
| 1178 | * policy_mgr_is_2x2_1x1_dbs_capable() - check 2x2+1x1 DBS supported or not |
| 1179 | * @psoc: PSOC object data |
| 1180 | * |
| 1181 | * This routine is called to check 2x2 5G + 1x1 2G (DBS1) or |
| 1182 | * 2x2 2G + 1x1 5G (DBS2) support or not. |
| 1183 | * Either DBS1 or DBS2 supported |
| 1184 | * |
| 1185 | * Return: true/false |
| 1186 | */ |
| 1187 | bool policy_mgr_is_2x2_1x1_dbs_capable(struct wlan_objmgr_psoc *psoc) |
| 1188 | { |
| 1189 | struct dbs_nss nss_dbs; |
| 1190 | uint32_t nss; |
| 1191 | |
| 1192 | nss = policy_mgr_get_hw_dbs_nss(psoc, &nss_dbs); |
| 1193 | if (nss >= HW_MODE_SS_2x2 && (nss_dbs.mac0_ss > nss_dbs.mac1_ss)) |
| 1194 | return true; |
| 1195 | else |
| 1196 | return false; |
| 1197 | } |
| 1198 | |
| 1199 | /* |
| 1200 | * policy_mgr_is_2x2_5G_1x1_2G_dbs_capable() - check Genoa DBS1 enabled or not |
| 1201 | * @psoc: PSOC object data |
| 1202 | * |
| 1203 | * This routine is called to check support DBS1 or not. |
| 1204 | * Notes: DBS1: 2x2 5G + 1x1 2G. |
| 1205 | * This function will call policy_mgr_get_hw_mode_idx_from_dbs_hw_list to match |
| 1206 | * the HW mode from hw mode list. The parameters will also be matched to |
| 1207 | * 2x2 5G +2x2 2G HW mode. But firmware will not report 2x2 5G + 2x2 2G alone |
| 1208 | * with 2x2 5G + 1x1 2G at same time. So, it is safe to find DBS1 with |
| 1209 | * policy_mgr_get_hw_mode_idx_from_dbs_hw_list. |
| 1210 | * |
| 1211 | * Return: true/false |
| 1212 | */ |
| 1213 | bool policy_mgr_is_2x2_5G_1x1_2G_dbs_capable(struct wlan_objmgr_psoc *psoc) |
| 1214 | { |
| 1215 | return policy_mgr_is_2x2_1x1_dbs_capable(psoc) && |
| 1216 | (policy_mgr_get_hw_mode_idx_from_dbs_hw_list( |
| 1217 | psoc, |
| 1218 | HW_MODE_SS_2x2, |
| 1219 | HW_MODE_80_MHZ, |
| 1220 | HW_MODE_SS_1x1, HW_MODE_40_MHZ, |
| 1221 | HW_MODE_MAC_BAND_5G, |
| 1222 | HW_MODE_DBS, |
| 1223 | HW_MODE_AGILE_DFS_NONE, |
| 1224 | HW_MODE_SBS_NONE) >= 0); |
| 1225 | } |
| 1226 | |
| 1227 | /* |
| 1228 | * policy_mgr_is_2x2_2G_1x1_5G_dbs_capable() - check Genoa DBS2 enabled or not |
| 1229 | * @psoc: PSOC object data |
| 1230 | * |
| 1231 | * This routine is called to check support DBS2 or not. |
| 1232 | * Notes: DBS2: 2x2 2G + 1x1 5G |
| 1233 | * |
| 1234 | * Return: true/false |
| 1235 | */ |
| 1236 | bool policy_mgr_is_2x2_2G_1x1_5G_dbs_capable(struct wlan_objmgr_psoc *psoc) |
| 1237 | { |
| 1238 | return policy_mgr_is_2x2_1x1_dbs_capable(psoc) && |
| 1239 | (policy_mgr_get_hw_mode_idx_from_dbs_hw_list( |
| 1240 | psoc, |
| 1241 | HW_MODE_SS_2x2, |
| 1242 | HW_MODE_40_MHZ, |
| 1243 | HW_MODE_SS_1x1, HW_MODE_40_MHZ, |
| 1244 | HW_MODE_MAC_BAND_2G, |
| 1245 | HW_MODE_DBS, |
| 1246 | HW_MODE_AGILE_DFS_NONE, |
| 1247 | HW_MODE_SBS_NONE) >= 0); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1248 | } |
| 1249 | |
| 1250 | uint32_t policy_mgr_get_connection_count(struct wlan_objmgr_psoc *psoc) |
| 1251 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1252 | uint32_t conn_index, count = 0; |
| 1253 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1254 | |
| 1255 | pm_ctx = policy_mgr_get_context(psoc); |
| 1256 | if (!pm_ctx) { |
| 1257 | policy_mgr_err("Invalid Context"); |
| 1258 | return count; |
| 1259 | } |
| 1260 | |
| 1261 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1262 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 1263 | conn_index++) { |
| 1264 | if (pm_conc_connection_list[conn_index].in_use) |
| 1265 | count++; |
| 1266 | } |
| 1267 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1268 | |
| 1269 | return count; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1270 | } |
| 1271 | |
Kabilan Kannan | 5125d0f | 2017-05-15 20:28:05 -0700 | [diff] [blame] | 1272 | uint32_t policy_mgr_mode_specific_vdev_id(struct wlan_objmgr_psoc *psoc, |
| 1273 | enum policy_mgr_con_mode mode) |
| 1274 | { |
| 1275 | uint32_t conn_index = 0; |
| 1276 | uint32_t vdev_id = WLAN_INVALID_VDEV_ID; |
| 1277 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1278 | |
| 1279 | pm_ctx = policy_mgr_get_context(psoc); |
| 1280 | if (!pm_ctx) { |
| 1281 | policy_mgr_err("Invalid Context"); |
| 1282 | return vdev_id; |
| 1283 | } |
| 1284 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1285 | /* |
| 1286 | * Note: This gives you the first vdev id of the mode type in a |
| 1287 | * sta+sta or sap+sap or p2p + p2p case |
| 1288 | */ |
| 1289 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 1290 | conn_index++) { |
| 1291 | if ((pm_conc_connection_list[conn_index].mode == mode) && |
| 1292 | pm_conc_connection_list[conn_index].in_use) { |
| 1293 | vdev_id = pm_conc_connection_list[conn_index].vdev_id; |
| 1294 | break; |
| 1295 | } |
| 1296 | } |
| 1297 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1298 | |
| 1299 | return vdev_id; |
| 1300 | } |
| 1301 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1302 | uint32_t policy_mgr_mode_specific_connection_count( |
| 1303 | struct wlan_objmgr_psoc *psoc, |
| 1304 | enum policy_mgr_con_mode mode, |
| 1305 | uint32_t *list) |
| 1306 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1307 | uint32_t conn_index = 0, count = 0; |
| 1308 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1309 | |
| 1310 | pm_ctx = policy_mgr_get_context(psoc); |
| 1311 | if (!pm_ctx) { |
| 1312 | policy_mgr_err("Invalid Context"); |
| 1313 | return count; |
| 1314 | } |
| 1315 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1316 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 1317 | conn_index++) { |
| 1318 | if ((pm_conc_connection_list[conn_index].mode == mode) && |
| 1319 | pm_conc_connection_list[conn_index].in_use) { |
Jeff Johnson | e79b53c | 2019-03-18 14:03:23 -0700 | [diff] [blame] | 1320 | if (list) |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1321 | list[count] = conn_index; |
| 1322 | count++; |
| 1323 | } |
| 1324 | } |
| 1325 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1326 | |
| 1327 | return count; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1328 | } |
| 1329 | |
Nitesh Shah | c26d3bd | 2017-06-07 15:25:07 +0530 | [diff] [blame] | 1330 | QDF_STATUS policy_mgr_check_conn_with_mode_and_vdev_id( |
| 1331 | struct wlan_objmgr_psoc *psoc, enum policy_mgr_con_mode mode, |
| 1332 | uint32_t vdev_id) |
| 1333 | { |
| 1334 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
| 1335 | uint32_t conn_index = 0; |
| 1336 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1337 | |
| 1338 | pm_ctx = policy_mgr_get_context(psoc); |
| 1339 | if (!pm_ctx) { |
| 1340 | policy_mgr_err("Invalid Context"); |
| 1341 | return qdf_status; |
| 1342 | } |
| 1343 | |
| 1344 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1345 | while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { |
| 1346 | if ((pm_conc_connection_list[conn_index].mode == mode) && |
| 1347 | (pm_conc_connection_list[conn_index].vdev_id == vdev_id)) { |
| 1348 | qdf_status = QDF_STATUS_SUCCESS; |
| 1349 | break; |
| 1350 | } |
| 1351 | conn_index++; |
| 1352 | } |
| 1353 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1354 | return qdf_status; |
| 1355 | } |
| 1356 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1357 | void policy_mgr_soc_set_dual_mac_cfg_cb(enum set_hw_mode_status status, |
| 1358 | uint32_t scan_config, |
| 1359 | uint32_t fw_mode_config) |
| 1360 | { |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1361 | policy_mgr_debug("Status:%d for scan_config:%x fw_mode_config:%x", |
Srinivas Girigowda | b031fa6 | 2018-02-15 14:30:05 -0800 | [diff] [blame] | 1362 | status, scan_config, fw_mode_config); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1363 | } |
| 1364 | |
| 1365 | void policy_mgr_set_dual_mac_scan_config(struct wlan_objmgr_psoc *psoc, |
| 1366 | uint8_t dbs_val, |
| 1367 | uint8_t dbs_plus_agile_scan_val, |
| 1368 | uint8_t single_mac_scan_with_dbs_val) |
| 1369 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1370 | struct policy_mgr_dual_mac_config cfg; |
| 1371 | QDF_STATUS status; |
| 1372 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1373 | |
| 1374 | pm_ctx = policy_mgr_get_context(psoc); |
| 1375 | if (!pm_ctx) { |
| 1376 | policy_mgr_err("Invalid Context"); |
| 1377 | return; |
| 1378 | } |
| 1379 | |
| 1380 | /* Any non-zero positive value is treated as 1 */ |
| 1381 | if (dbs_val != 0) |
| 1382 | dbs_val = 1; |
| 1383 | if (dbs_plus_agile_scan_val != 0) |
| 1384 | dbs_plus_agile_scan_val = 1; |
| 1385 | if (single_mac_scan_with_dbs_val != 0) |
| 1386 | single_mac_scan_with_dbs_val = 1; |
| 1387 | |
| 1388 | status = policy_mgr_get_updated_scan_config(psoc, &cfg.scan_config, |
| 1389 | dbs_val, |
| 1390 | dbs_plus_agile_scan_val, |
| 1391 | single_mac_scan_with_dbs_val); |
| 1392 | if (status != QDF_STATUS_SUCCESS) { |
| 1393 | policy_mgr_err("policy_mgr_get_updated_scan_config failed %d", |
| 1394 | status); |
| 1395 | return; |
| 1396 | } |
| 1397 | |
| 1398 | status = policy_mgr_get_updated_fw_mode_config(psoc, |
| 1399 | &cfg.fw_mode_config, |
| 1400 | policy_mgr_get_dbs_config(psoc), |
| 1401 | policy_mgr_get_agile_dfs_config(psoc)); |
| 1402 | if (status != QDF_STATUS_SUCCESS) { |
| 1403 | policy_mgr_err("policy_mgr_get_updated_fw_mode_config failed %d", |
| 1404 | status); |
| 1405 | return; |
| 1406 | } |
| 1407 | |
Srinivas Girigowda | b031fa6 | 2018-02-15 14:30:05 -0800 | [diff] [blame] | 1408 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1409 | |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1410 | policy_mgr_debug("scan_config:%x fw_mode_config:%x", |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1411 | cfg.scan_config, cfg.fw_mode_config); |
| 1412 | |
| 1413 | status = pm_ctx->sme_cbacks.sme_soc_set_dual_mac_config(cfg); |
| 1414 | if (status != QDF_STATUS_SUCCESS) |
| 1415 | policy_mgr_err("sme_soc_set_dual_mac_config failed %d", status); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1416 | } |
| 1417 | |
| 1418 | void policy_mgr_set_dual_mac_fw_mode_config(struct wlan_objmgr_psoc *psoc, |
| 1419 | uint8_t dbs, uint8_t dfs) |
| 1420 | { |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1421 | struct policy_mgr_dual_mac_config cfg; |
| 1422 | QDF_STATUS status; |
| 1423 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1424 | |
| 1425 | pm_ctx = policy_mgr_get_context(psoc); |
| 1426 | if (!pm_ctx) { |
| 1427 | policy_mgr_err("Invalid Context"); |
| 1428 | return; |
| 1429 | } |
| 1430 | |
| 1431 | /* Any non-zero positive value is treated as 1 */ |
| 1432 | if (dbs != 0) |
| 1433 | dbs = 1; |
| 1434 | if (dfs != 0) |
| 1435 | dfs = 1; |
| 1436 | |
| 1437 | status = policy_mgr_get_updated_scan_config(psoc, &cfg.scan_config, |
| 1438 | policy_mgr_get_dbs_scan_config(psoc), |
| 1439 | policy_mgr_get_dbs_plus_agile_scan_config(psoc), |
| 1440 | policy_mgr_get_single_mac_scan_with_dfs_config(psoc)); |
| 1441 | if (status != QDF_STATUS_SUCCESS) { |
| 1442 | policy_mgr_err("policy_mgr_get_updated_scan_config failed %d", |
| 1443 | status); |
| 1444 | return; |
| 1445 | } |
| 1446 | |
| 1447 | status = policy_mgr_get_updated_fw_mode_config(psoc, |
| 1448 | &cfg.fw_mode_config, dbs, dfs); |
| 1449 | if (status != QDF_STATUS_SUCCESS) { |
| 1450 | policy_mgr_err("policy_mgr_get_updated_fw_mode_config failed %d", |
| 1451 | status); |
| 1452 | return; |
| 1453 | } |
| 1454 | |
Srinivas Girigowda | b031fa6 | 2018-02-15 14:30:05 -0800 | [diff] [blame] | 1455 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1456 | |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1457 | policy_mgr_debug("scan_config:%x fw_mode_config:%x", |
Tushnim Bhattacharyya | 58a0b19 | 2017-03-08 09:56:33 -0800 | [diff] [blame] | 1458 | cfg.scan_config, cfg.fw_mode_config); |
| 1459 | |
| 1460 | status = pm_ctx->sme_cbacks.sme_soc_set_dual_mac_config(cfg); |
| 1461 | if (status != QDF_STATUS_SUCCESS) |
| 1462 | policy_mgr_err("sme_soc_set_dual_mac_config failed %d", status); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1463 | } |
| 1464 | |
| 1465 | bool policy_mgr_current_concurrency_is_mcc(struct wlan_objmgr_psoc *psoc) |
| 1466 | { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1467 | uint32_t num_connections = 0; |
| 1468 | bool is_mcc = false; |
| 1469 | |
| 1470 | num_connections = policy_mgr_get_connection_count(psoc); |
| 1471 | |
| 1472 | switch (num_connections) { |
| 1473 | case 1: |
| 1474 | break; |
| 1475 | case 2: |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1476 | if (pm_conc_connection_list[0].freq != |
| 1477 | pm_conc_connection_list[1].freq && |
| 1478 | pm_conc_connection_list[0].mac == |
| 1479 | pm_conc_connection_list[1].mac) { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1480 | is_mcc = true; |
| 1481 | } |
| 1482 | break; |
| 1483 | case 3: |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1484 | if (pm_conc_connection_list[0].freq != |
| 1485 | pm_conc_connection_list[1].freq || |
| 1486 | pm_conc_connection_list[0].freq != |
| 1487 | pm_conc_connection_list[2].freq || |
| 1488 | pm_conc_connection_list[1].freq != |
| 1489 | pm_conc_connection_list[2].freq){ |
| 1490 | is_mcc = true; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1491 | } |
| 1492 | break; |
| 1493 | default: |
Arun Kumar Khandavalli | f4ed406 | 2020-01-20 11:45:09 +0530 | [diff] [blame] | 1494 | policy_mgr_debug("unexpected num_connections value %d", |
| 1495 | num_connections); |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1496 | break; |
| 1497 | } |
| 1498 | |
| 1499 | return is_mcc; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1500 | } |
| 1501 | |
Krishna Reddy | 3c62990 | 2019-07-05 12:42:29 +0530 | [diff] [blame] | 1502 | bool policy_mgr_is_sap_p2pgo_on_dfs(struct wlan_objmgr_psoc *psoc) |
| 1503 | { |
| 1504 | int index, count; |
| 1505 | uint32_t list[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
| 1506 | struct policy_mgr_psoc_priv_obj *pm_ctx = NULL; |
| 1507 | |
| 1508 | if (psoc) |
| 1509 | pm_ctx = policy_mgr_get_context(psoc); |
| 1510 | |
| 1511 | if (!pm_ctx) { |
| 1512 | policy_mgr_err("Invalid Context"); |
| 1513 | return false; |
| 1514 | } |
| 1515 | |
| 1516 | index = 0; |
| 1517 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1518 | count = policy_mgr_mode_specific_connection_count(psoc, |
| 1519 | PM_SAP_MODE, |
| 1520 | list); |
| 1521 | while (index < count) { |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 1522 | if (pm_conc_connection_list[list[index]].ch_flagext & |
| 1523 | (IEEE80211_CHAN_DFS | IEEE80211_CHAN_DFS_CFREQ2)) { |
Krishna Reddy | 3c62990 | 2019-07-05 12:42:29 +0530 | [diff] [blame] | 1524 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1525 | return true; |
| 1526 | } |
| 1527 | index++; |
| 1528 | } |
| 1529 | count = policy_mgr_mode_specific_connection_count(psoc, |
| 1530 | PM_P2P_GO_MODE, |
| 1531 | list); |
| 1532 | index = 0; |
| 1533 | while (index < count) { |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 1534 | if (pm_conc_connection_list[list[index]].ch_flagext & |
| 1535 | (IEEE80211_CHAN_DFS | IEEE80211_CHAN_DFS_CFREQ2)) { |
Krishna Reddy | 3c62990 | 2019-07-05 12:42:29 +0530 | [diff] [blame] | 1536 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1537 | return true; |
| 1538 | } |
| 1539 | index++; |
| 1540 | } |
| 1541 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1542 | return false; |
| 1543 | } |
| 1544 | |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 1545 | /** |
| 1546 | * policy_mgr_set_concurrency_mode() - To set concurrency mode |
| 1547 | * @psoc: PSOC object data |
| 1548 | * @mode: device mode |
| 1549 | * |
| 1550 | * This routine is called to set the concurrency mode |
| 1551 | * |
| 1552 | * Return: NONE |
| 1553 | */ |
| 1554 | void policy_mgr_set_concurrency_mode(struct wlan_objmgr_psoc *psoc, |
Jeff Johnson | 275208b | 2017-11-09 09:54:12 -0800 | [diff] [blame] | 1555 | enum QDF_OPMODE mode) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1556 | { |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 1557 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1558 | |
| 1559 | pm_ctx = policy_mgr_get_context(psoc); |
| 1560 | if (!pm_ctx) { |
| 1561 | policy_mgr_err("Invalid context"); |
| 1562 | return; |
| 1563 | } |
| 1564 | |
| 1565 | switch (mode) { |
| 1566 | case QDF_STA_MODE: |
| 1567 | case QDF_P2P_CLIENT_MODE: |
| 1568 | case QDF_P2P_GO_MODE: |
| 1569 | case QDF_SAP_MODE: |
| 1570 | case QDF_IBSS_MODE: |
| 1571 | case QDF_MONITOR_MODE: |
| 1572 | pm_ctx->concurrency_mode |= (1 << mode); |
| 1573 | pm_ctx->no_of_open_sessions[mode]++; |
| 1574 | break; |
| 1575 | default: |
| 1576 | break; |
| 1577 | } |
| 1578 | |
Arun Kumar Khandavalli | f4ed406 | 2020-01-20 11:45:09 +0530 | [diff] [blame] | 1579 | policy_mgr_debug("concurrency_mode = 0x%x Number of open sessions for mode %d = %d", |
| 1580 | pm_ctx->concurrency_mode, mode, |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 1581 | pm_ctx->no_of_open_sessions[mode]); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1582 | } |
| 1583 | |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 1584 | /** |
| 1585 | * policy_mgr_clear_concurrency_mode() - To clear concurrency mode |
| 1586 | * @psoc: PSOC object data |
| 1587 | * @mode: device mode |
| 1588 | * |
| 1589 | * This routine is called to clear the concurrency mode |
| 1590 | * |
| 1591 | * Return: NONE |
| 1592 | */ |
| 1593 | void policy_mgr_clear_concurrency_mode(struct wlan_objmgr_psoc *psoc, |
Jeff Johnson | 275208b | 2017-11-09 09:54:12 -0800 | [diff] [blame] | 1594 | enum QDF_OPMODE mode) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1595 | { |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 1596 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1597 | |
| 1598 | pm_ctx = policy_mgr_get_context(psoc); |
| 1599 | if (!pm_ctx) { |
| 1600 | policy_mgr_err("Invalid context"); |
| 1601 | return; |
| 1602 | } |
| 1603 | |
| 1604 | switch (mode) { |
| 1605 | case QDF_STA_MODE: |
| 1606 | case QDF_P2P_CLIENT_MODE: |
| 1607 | case QDF_P2P_GO_MODE: |
| 1608 | case QDF_SAP_MODE: |
| 1609 | case QDF_MONITOR_MODE: |
| 1610 | pm_ctx->no_of_open_sessions[mode]--; |
| 1611 | if (!(pm_ctx->no_of_open_sessions[mode])) |
| 1612 | pm_ctx->concurrency_mode &= (~(1 << mode)); |
| 1613 | break; |
| 1614 | default: |
| 1615 | break; |
| 1616 | } |
| 1617 | |
Arun Kumar Khandavalli | f4ed406 | 2020-01-20 11:45:09 +0530 | [diff] [blame] | 1618 | policy_mgr_debug("concurrency_mode = 0x%x Number of open sessions for mode %d = %d", |
| 1619 | pm_ctx->concurrency_mode, mode, |
| 1620 | pm_ctx->no_of_open_sessions[mode]); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1621 | } |
| 1622 | |
| 1623 | void policy_mgr_incr_active_session(struct wlan_objmgr_psoc *psoc, |
Jeff Johnson | 275208b | 2017-11-09 09:54:12 -0800 | [diff] [blame] | 1624 | enum QDF_OPMODE mode, |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1625 | uint8_t session_id) |
| 1626 | { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1627 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 1628 | uint32_t conn_6ghz_flag = 0; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1629 | |
| 1630 | pm_ctx = policy_mgr_get_context(psoc); |
| 1631 | if (!pm_ctx) { |
| 1632 | policy_mgr_err("Invalid Context"); |
| 1633 | return; |
| 1634 | } |
| 1635 | |
| 1636 | /* |
| 1637 | * Need to aquire mutex as entire functionality in this function |
| 1638 | * is in critical section |
| 1639 | */ |
| 1640 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1641 | switch (mode) { |
| 1642 | case QDF_STA_MODE: |
| 1643 | case QDF_P2P_CLIENT_MODE: |
| 1644 | case QDF_P2P_GO_MODE: |
| 1645 | case QDF_SAP_MODE: |
| 1646 | case QDF_IBSS_MODE: |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 1647 | case QDF_NAN_DISC_MODE: |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1648 | pm_ctx->no_of_active_sessions[mode]++; |
| 1649 | break; |
| 1650 | default: |
| 1651 | break; |
| 1652 | } |
| 1653 | |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 1654 | if (mode != QDF_NAN_DISC_MODE && pm_ctx->dp_cbacks.hdd_v2_flow_pool_map) |
Manjunathappa Prakash | cdf1813 | 2018-05-08 19:55:25 -0700 | [diff] [blame] | 1655 | pm_ctx->dp_cbacks.hdd_v2_flow_pool_map(session_id); |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 1656 | if (mode == QDF_SAP_MODE) |
| 1657 | policy_mgr_get_ap_6ghz_capable(psoc, session_id, |
| 1658 | &conn_6ghz_flag); |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1659 | |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1660 | policy_mgr_debug("No.# of active sessions for mode %d = %d", |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1661 | mode, pm_ctx->no_of_active_sessions[mode]); |
Srinivas Dasari | c9e048e | 2019-12-23 00:45:35 +0530 | [diff] [blame] | 1662 | policy_mgr_incr_connection_count(psoc, session_id, mode); |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1663 | if ((policy_mgr_mode_specific_connection_count( |
| 1664 | psoc, PM_STA_MODE, NULL) > 0) && (mode != QDF_STA_MODE)) { |
| 1665 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1666 | policy_mgr_set_pcl_for_existing_combo(psoc, PM_STA_MODE); |
| 1667 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1668 | } |
| 1669 | |
Kabilan Kannan | c81d375 | 2017-02-28 20:28:54 -0800 | [diff] [blame] | 1670 | /* Notify tdls */ |
| 1671 | if (pm_ctx->tdls_cbacks.tdls_notify_increment_session) |
| 1672 | pm_ctx->tdls_cbacks.tdls_notify_increment_session(psoc); |
| 1673 | |
Manjunathappa Prakash | fb82833 | 2017-04-05 15:59:49 -0700 | [diff] [blame] | 1674 | /* |
Manjunathappa Prakash | e51aba7 | 2018-04-15 00:42:41 -0700 | [diff] [blame] | 1675 | * Disable LRO/GRO if P2P or IBSS or SAP connection has come up or |
Manjunathappa Prakash | fb82833 | 2017-04-05 15:59:49 -0700 | [diff] [blame] | 1676 | * there are more than one STA connections |
| 1677 | */ |
| 1678 | if ((policy_mgr_mode_specific_connection_count(psoc, PM_STA_MODE, NULL) > 1) || |
| 1679 | (policy_mgr_mode_specific_connection_count(psoc, PM_SAP_MODE, NULL) > 0) || |
| 1680 | (policy_mgr_mode_specific_connection_count(psoc, PM_P2P_CLIENT_MODE, NULL) > |
| 1681 | 0) || |
| 1682 | (policy_mgr_mode_specific_connection_count(psoc, PM_P2P_GO_MODE, NULL) > 0) || |
| 1683 | (policy_mgr_mode_specific_connection_count(psoc, PM_IBSS_MODE, NULL) > 0)) { |
Jeff Johnson | e79b53c | 2019-03-18 14:03:23 -0700 | [diff] [blame] | 1684 | if (pm_ctx->dp_cbacks.hdd_disable_rx_ol_in_concurrency) |
Manjunathappa Prakash | e51aba7 | 2018-04-15 00:42:41 -0700 | [diff] [blame] | 1685 | pm_ctx->dp_cbacks.hdd_disable_rx_ol_in_concurrency(true); |
Manjunathappa Prakash | fb82833 | 2017-04-05 15:59:49 -0700 | [diff] [blame] | 1686 | }; |
| 1687 | |
Yun Park | ab13177 | 2017-09-26 16:39:17 -0700 | [diff] [blame] | 1688 | /* Enable RPS if SAP interface has come up */ |
| 1689 | if (policy_mgr_mode_specific_connection_count(psoc, PM_SAP_MODE, NULL) |
| 1690 | == 1) { |
Jeff Johnson | e79b53c | 2019-03-18 14:03:23 -0700 | [diff] [blame] | 1691 | if (pm_ctx->dp_cbacks.hdd_set_rx_mode_rps_cb) |
Yun Park | ab13177 | 2017-09-26 16:39:17 -0700 | [diff] [blame] | 1692 | pm_ctx->dp_cbacks.hdd_set_rx_mode_rps_cb(true); |
| 1693 | } |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 1694 | if (mode == QDF_SAP_MODE) |
| 1695 | policy_mgr_init_ap_6ghz_capable(psoc, session_id, |
| 1696 | conn_6ghz_flag); |
Yun Park | ab13177 | 2017-09-26 16:39:17 -0700 | [diff] [blame] | 1697 | |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1698 | policy_mgr_dump_current_concurrency(psoc); |
| 1699 | |
| 1700 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1701 | } |
| 1702 | |
Nitesh Shah | c26d3bd | 2017-06-07 15:25:07 +0530 | [diff] [blame] | 1703 | QDF_STATUS policy_mgr_decr_active_session(struct wlan_objmgr_psoc *psoc, |
Jeff Johnson | 275208b | 2017-11-09 09:54:12 -0800 | [diff] [blame] | 1704 | enum QDF_OPMODE mode, |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1705 | uint8_t session_id) |
| 1706 | { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1707 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Nitesh Shah | c26d3bd | 2017-06-07 15:25:07 +0530 | [diff] [blame] | 1708 | QDF_STATUS qdf_status; |
jiad | c8754ac | 2018-03-30 16:33:59 +0800 | [diff] [blame] | 1709 | bool mcc_mode; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1710 | |
| 1711 | pm_ctx = policy_mgr_get_context(psoc); |
| 1712 | if (!pm_ctx) { |
| 1713 | policy_mgr_err("context is NULL"); |
Nitesh Shah | c26d3bd | 2017-06-07 15:25:07 +0530 | [diff] [blame] | 1714 | return QDF_STATUS_E_EMPTY; |
| 1715 | } |
| 1716 | |
| 1717 | qdf_status = policy_mgr_check_conn_with_mode_and_vdev_id(psoc, |
| 1718 | policy_mgr_convert_device_mode_to_qdf_type(mode), |
| 1719 | session_id); |
| 1720 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Tushnim Bhattacharyya | c05a191 | 2018-09-18 15:53:50 -0700 | [diff] [blame] | 1721 | policy_mgr_debug("No connection with mode:%d vdev_id:%d", |
Nitesh Shah | c26d3bd | 2017-06-07 15:25:07 +0530 | [diff] [blame] | 1722 | policy_mgr_convert_device_mode_to_qdf_type(mode), |
| 1723 | session_id); |
| 1724 | return qdf_status; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1725 | } |
| 1726 | |
| 1727 | switch (mode) { |
| 1728 | case QDF_STA_MODE: |
| 1729 | case QDF_P2P_CLIENT_MODE: |
| 1730 | case QDF_P2P_GO_MODE: |
| 1731 | case QDF_SAP_MODE: |
| 1732 | case QDF_IBSS_MODE: |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 1733 | case QDF_NAN_DISC_MODE: |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1734 | if (pm_ctx->no_of_active_sessions[mode]) |
| 1735 | pm_ctx->no_of_active_sessions[mode]--; |
| 1736 | break; |
| 1737 | default: |
| 1738 | break; |
| 1739 | } |
| 1740 | |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 1741 | if (mode != QDF_NAN_DISC_MODE && |
| 1742 | pm_ctx->dp_cbacks.hdd_v2_flow_pool_unmap) |
Manjunathappa Prakash | cdf1813 | 2018-05-08 19:55:25 -0700 | [diff] [blame] | 1743 | pm_ctx->dp_cbacks.hdd_v2_flow_pool_unmap(session_id); |
| 1744 | |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1745 | policy_mgr_debug("No.# of active sessions for mode %d = %d", |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1746 | mode, pm_ctx->no_of_active_sessions[mode]); |
| 1747 | |
| 1748 | policy_mgr_decr_connection_count(psoc, session_id); |
| 1749 | |
Kabilan Kannan | c81d375 | 2017-02-28 20:28:54 -0800 | [diff] [blame] | 1750 | /* Notify tdls */ |
| 1751 | if (pm_ctx->tdls_cbacks.tdls_notify_decrement_session) |
| 1752 | pm_ctx->tdls_cbacks.tdls_notify_decrement_session(psoc); |
Manjunathappa Prakash | e51aba7 | 2018-04-15 00:42:41 -0700 | [diff] [blame] | 1753 | /* Enable LRO/GRO if there no concurrency */ |
Manjunathappa Prakash | fb82833 | 2017-04-05 15:59:49 -0700 | [diff] [blame] | 1754 | if ((policy_mgr_mode_specific_connection_count(psoc, PM_STA_MODE, NULL) == 1) && |
| 1755 | (policy_mgr_mode_specific_connection_count(psoc, PM_SAP_MODE, NULL) == 0) && |
| 1756 | (policy_mgr_mode_specific_connection_count(psoc, PM_P2P_CLIENT_MODE, NULL) == |
| 1757 | 0) && |
| 1758 | (policy_mgr_mode_specific_connection_count(psoc, PM_P2P_GO_MODE, NULL) == 0) && |
| 1759 | (policy_mgr_mode_specific_connection_count(psoc, PM_IBSS_MODE, NULL) == 0)) { |
Jeff Johnson | e79b53c | 2019-03-18 14:03:23 -0700 | [diff] [blame] | 1760 | if (pm_ctx->dp_cbacks.hdd_disable_rx_ol_in_concurrency) |
Manjunathappa Prakash | e51aba7 | 2018-04-15 00:42:41 -0700 | [diff] [blame] | 1761 | pm_ctx->dp_cbacks.hdd_disable_rx_ol_in_concurrency(false); |
Manjunathappa Prakash | fb82833 | 2017-04-05 15:59:49 -0700 | [diff] [blame] | 1762 | }; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1763 | |
Yun Park | ab13177 | 2017-09-26 16:39:17 -0700 | [diff] [blame] | 1764 | /* Disable RPS if SAP interface has come up */ |
| 1765 | if (policy_mgr_mode_specific_connection_count(psoc, PM_SAP_MODE, NULL) |
| 1766 | == 0) { |
Jeff Johnson | e79b53c | 2019-03-18 14:03:23 -0700 | [diff] [blame] | 1767 | if (pm_ctx->dp_cbacks.hdd_set_rx_mode_rps_cb) |
Yun Park | ab13177 | 2017-09-26 16:39:17 -0700 | [diff] [blame] | 1768 | pm_ctx->dp_cbacks.hdd_set_rx_mode_rps_cb(false); |
| 1769 | } |
| 1770 | |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1771 | policy_mgr_dump_current_concurrency(psoc); |
Nitesh Shah | c26d3bd | 2017-06-07 15:25:07 +0530 | [diff] [blame] | 1772 | |
jiad | c8754ac | 2018-03-30 16:33:59 +0800 | [diff] [blame] | 1773 | /* |
| 1774 | * Check mode of entry being removed. Update mcc_mode only when STA |
| 1775 | * or SAP since IPA only cares about these two |
| 1776 | */ |
| 1777 | if (mode == QDF_STA_MODE || mode == QDF_SAP_MODE) { |
| 1778 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1779 | mcc_mode = policy_mgr_current_concurrency_is_mcc(psoc); |
| 1780 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1781 | |
| 1782 | if (pm_ctx->dp_cbacks.hdd_ipa_set_mcc_mode_cb) |
| 1783 | pm_ctx->dp_cbacks.hdd_ipa_set_mcc_mode_cb(mcc_mode); |
| 1784 | } |
Liangwei Dong | 11019a0 | 2019-05-08 23:32:37 -0400 | [diff] [blame] | 1785 | /* |
| 1786 | * When STA disconnected, we need to move DFS SAP |
| 1787 | * to Non-DFS if g_sta_sap_scc_on_dfs_chan enabled. |
| 1788 | * The same if g_sta_sap_scc_on_lte_coex_chan enabled, |
| 1789 | * need to move SAP on unsafe channel to safe channel. |
| 1790 | * The flag will be checked by |
| 1791 | * policy_mgr_is_sap_restart_required_after_sta_disconnect. |
| 1792 | */ |
| 1793 | if (mode == QDF_STA_MODE || mode == QDF_P2P_CLIENT_MODE) |
| 1794 | pm_ctx->do_sap_unsafe_ch_check = true; |
jiad | c8754ac | 2018-03-30 16:33:59 +0800 | [diff] [blame] | 1795 | |
Nitesh Shah | c26d3bd | 2017-06-07 15:25:07 +0530 | [diff] [blame] | 1796 | return qdf_status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1797 | } |
| 1798 | |
Srinivas Dasari | c9e048e | 2019-12-23 00:45:35 +0530 | [diff] [blame] | 1799 | QDF_STATUS policy_mgr_incr_connection_count(struct wlan_objmgr_psoc *psoc, |
| 1800 | uint32_t vdev_id, |
| 1801 | enum QDF_OPMODE op_mode) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1802 | { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1803 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 1804 | uint32_t conn_index; |
sheenam monga | 4a3f341 | 2019-04-05 12:27:54 +0530 | [diff] [blame] | 1805 | struct policy_mgr_vdev_entry_info conn_table_entry = {0}; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1806 | enum policy_mgr_chain_mode chain_mask = POLICY_MGR_ONE_ONE; |
| 1807 | uint8_t nss_2g = 0, nss_5g = 0; |
| 1808 | enum policy_mgr_con_mode mode; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1809 | uint32_t ch_freq; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1810 | uint32_t nss = 0; |
| 1811 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Yeshwanth Sriram Guntuka | 2854295 | 2018-06-13 11:43:46 +0530 | [diff] [blame] | 1812 | bool update_conn = true; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1813 | |
| 1814 | pm_ctx = policy_mgr_get_context(psoc); |
| 1815 | if (!pm_ctx) { |
| 1816 | policy_mgr_err("context is NULL"); |
| 1817 | return status; |
| 1818 | } |
| 1819 | |
| 1820 | conn_index = policy_mgr_get_connection_count(psoc); |
Krunal Soni | 1c7a1e9 | 2018-09-27 10:55:17 -0700 | [diff] [blame] | 1821 | if (pm_ctx->cfg.max_conc_cxns < conn_index) { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1822 | policy_mgr_err("exceeded max connection limit %d", |
Krunal Soni | 1c7a1e9 | 2018-09-27 10:55:17 -0700 | [diff] [blame] | 1823 | pm_ctx->cfg.max_conc_cxns); |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1824 | return status; |
| 1825 | } |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 1826 | |
Srinivas Dasari | c9e048e | 2019-12-23 00:45:35 +0530 | [diff] [blame] | 1827 | if (op_mode == QDF_NAN_DISC_MODE) { |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 1828 | status = wlan_nan_get_connection_info(psoc, &conn_table_entry); |
| 1829 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1830 | policy_mgr_err("Can't get NAN Connection info"); |
| 1831 | return status; |
| 1832 | } |
| 1833 | } else if (pm_ctx->wma_cbacks.wma_get_connection_info) { |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame] | 1834 | status = pm_ctx->wma_cbacks.wma_get_connection_info( |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1835 | vdev_id, &conn_table_entry); |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame] | 1836 | if (QDF_STATUS_SUCCESS != status) { |
| 1837 | policy_mgr_err("can't find vdev_id %d in connection table", |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1838 | vdev_id); |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame] | 1839 | return status; |
| 1840 | } |
| 1841 | } else { |
| 1842 | policy_mgr_err("wma_get_connection_info is NULL"); |
| 1843 | return QDF_STATUS_E_FAILURE; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1844 | } |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame] | 1845 | |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1846 | mode = policy_mgr_get_mode(conn_table_entry.type, |
| 1847 | conn_table_entry.sub_type); |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1848 | ch_freq = conn_table_entry.mhz; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1849 | status = policy_mgr_get_nss_for_vdev(psoc, mode, &nss_2g, &nss_5g); |
| 1850 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1851 | if ((WLAN_REG_IS_24GHZ_CH_FREQ(ch_freq) && nss_2g > 1) || |
| 1852 | (WLAN_REG_IS_5GHZ_CH_FREQ(ch_freq) && nss_5g > 1)) |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1853 | chain_mask = POLICY_MGR_TWO_TWO; |
| 1854 | else |
| 1855 | chain_mask = POLICY_MGR_ONE_ONE; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1856 | nss = (WLAN_REG_IS_24GHZ_CH_FREQ(ch_freq)) ? nss_2g : nss_5g; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1857 | } else { |
| 1858 | policy_mgr_err("Error in getting nss"); |
| 1859 | } |
| 1860 | |
Yeshwanth Sriram Guntuka | 2854295 | 2018-06-13 11:43:46 +0530 | [diff] [blame] | 1861 | if (mode == PM_STA_MODE || mode == PM_P2P_CLIENT_MODE) |
| 1862 | update_conn = false; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1863 | |
| 1864 | /* add the entry */ |
| 1865 | policy_mgr_update_conc_list(psoc, conn_index, |
| 1866 | mode, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1867 | ch_freq, |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1868 | policy_mgr_get_bw(conn_table_entry.chan_width), |
| 1869 | conn_table_entry.mac_id, |
| 1870 | chain_mask, |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 1871 | nss, vdev_id, true, update_conn, |
| 1872 | conn_table_entry.ch_flagext); |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1873 | policy_mgr_debug("Add at idx:%d vdev %d mac=%d", |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1874 | conn_index, vdev_id, |
| 1875 | conn_table_entry.mac_id); |
| 1876 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1877 | return QDF_STATUS_SUCCESS; |
| 1878 | } |
| 1879 | |
| 1880 | QDF_STATUS policy_mgr_decr_connection_count(struct wlan_objmgr_psoc *psoc, |
| 1881 | uint32_t vdev_id) |
| 1882 | { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1883 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 1884 | uint32_t conn_index = 0, next_conn_index = 0; |
| 1885 | bool found = false; |
| 1886 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1887 | |
| 1888 | pm_ctx = policy_mgr_get_context(psoc); |
| 1889 | if (!pm_ctx) { |
| 1890 | policy_mgr_err("Invalid Context"); |
| 1891 | return status; |
| 1892 | } |
| 1893 | |
| 1894 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1895 | while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { |
| 1896 | if (vdev_id == pm_conc_connection_list[conn_index].vdev_id) { |
| 1897 | /* debug msg */ |
| 1898 | found = true; |
| 1899 | break; |
| 1900 | } |
| 1901 | conn_index++; |
| 1902 | } |
| 1903 | if (!found) { |
| 1904 | policy_mgr_err("can't find vdev_id %d in pm_conc_connection_list", |
| 1905 | vdev_id); |
| 1906 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1907 | return status; |
| 1908 | } |
| 1909 | next_conn_index = conn_index + 1; |
| 1910 | while (PM_CONC_CONNECTION_LIST_VALID_INDEX(next_conn_index)) { |
| 1911 | pm_conc_connection_list[conn_index].vdev_id = |
| 1912 | pm_conc_connection_list[next_conn_index].vdev_id; |
| 1913 | pm_conc_connection_list[conn_index].mode = |
| 1914 | pm_conc_connection_list[next_conn_index].mode; |
| 1915 | pm_conc_connection_list[conn_index].mac = |
| 1916 | pm_conc_connection_list[next_conn_index].mac; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1917 | pm_conc_connection_list[conn_index].freq = |
| 1918 | pm_conc_connection_list[next_conn_index].freq; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1919 | pm_conc_connection_list[conn_index].bw = |
| 1920 | pm_conc_connection_list[next_conn_index].bw; |
| 1921 | pm_conc_connection_list[conn_index].chain_mask = |
| 1922 | pm_conc_connection_list[next_conn_index].chain_mask; |
| 1923 | pm_conc_connection_list[conn_index].original_nss = |
| 1924 | pm_conc_connection_list[next_conn_index].original_nss; |
| 1925 | pm_conc_connection_list[conn_index].in_use = |
| 1926 | pm_conc_connection_list[next_conn_index].in_use; |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 1927 | pm_conc_connection_list[conn_index].ch_flagext = |
| 1928 | pm_conc_connection_list[next_conn_index].ch_flagext; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1929 | conn_index++; |
| 1930 | next_conn_index++; |
| 1931 | } |
| 1932 | |
| 1933 | /* clean up the entry */ |
| 1934 | qdf_mem_zero(&pm_conc_connection_list[next_conn_index - 1], |
| 1935 | sizeof(*pm_conc_connection_list)); |
| 1936 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1937 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1938 | return QDF_STATUS_SUCCESS; |
| 1939 | } |
| 1940 | |
Jeff Johnson | 275208b | 2017-11-09 09:54:12 -0800 | [diff] [blame] | 1941 | bool policy_mgr_map_concurrency_mode(enum QDF_OPMODE *old_mode, |
| 1942 | enum policy_mgr_con_mode *new_mode) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1943 | { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1944 | bool status = true; |
| 1945 | |
| 1946 | switch (*old_mode) { |
| 1947 | |
| 1948 | case QDF_STA_MODE: |
| 1949 | *new_mode = PM_STA_MODE; |
| 1950 | break; |
| 1951 | case QDF_SAP_MODE: |
| 1952 | *new_mode = PM_SAP_MODE; |
| 1953 | break; |
| 1954 | case QDF_P2P_CLIENT_MODE: |
| 1955 | *new_mode = PM_P2P_CLIENT_MODE; |
| 1956 | break; |
| 1957 | case QDF_P2P_GO_MODE: |
| 1958 | *new_mode = PM_P2P_GO_MODE; |
| 1959 | break; |
| 1960 | case QDF_IBSS_MODE: |
| 1961 | *new_mode = PM_IBSS_MODE; |
| 1962 | break; |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 1963 | case QDF_NAN_DISC_MODE: |
| 1964 | *new_mode = PM_NAN_DISC_MODE; |
| 1965 | break; |
Nachiket Kukade | 413c5fa | 2019-02-19 17:57:19 +0530 | [diff] [blame] | 1966 | case QDF_NDI_MODE: |
| 1967 | *new_mode = PM_NDI_MODE; |
| 1968 | break; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1969 | default: |
| 1970 | *new_mode = PM_MAX_NUM_OF_MODE; |
| 1971 | status = false; |
| 1972 | break; |
| 1973 | } |
| 1974 | |
| 1975 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1976 | } |
| 1977 | |
| 1978 | bool policy_mgr_is_ibss_conn_exist(struct wlan_objmgr_psoc *psoc, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1979 | uint32_t *ibss_ch_freq) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1980 | { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1981 | uint32_t count = 0, index = 0; |
| 1982 | uint32_t list[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
| 1983 | bool status = false; |
| 1984 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1985 | |
| 1986 | pm_ctx = policy_mgr_get_context(psoc); |
| 1987 | if (!pm_ctx) { |
| 1988 | policy_mgr_err("Invalid Context"); |
| 1989 | return status; |
| 1990 | } |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 1991 | if (!ibss_ch_freq) { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 1992 | policy_mgr_err("Null pointer error"); |
| 1993 | return false; |
| 1994 | } |
| 1995 | count = policy_mgr_mode_specific_connection_count( |
| 1996 | psoc, PM_IBSS_MODE, list); |
| 1997 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1998 | if (count == 0) { |
| 1999 | /* No IBSS connection */ |
| 2000 | status = false; |
| 2001 | } else if (count == 1) { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2002 | *ibss_ch_freq = pm_conc_connection_list[list[index]].freq; |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 2003 | status = true; |
| 2004 | } else { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2005 | *ibss_ch_freq = pm_conc_connection_list[list[index]].freq; |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 2006 | policy_mgr_debug("Multiple IBSS connections, picking first one"); |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 2007 | status = true; |
| 2008 | } |
| 2009 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2010 | |
| 2011 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2012 | } |
| 2013 | |
Manikandan Mohan | 19f3609 | 2019-08-15 15:54:02 -0700 | [diff] [blame] | 2014 | uint32_t policy_mgr_get_mode_specific_conn_info( |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2015 | struct wlan_objmgr_psoc *psoc, |
| 2016 | uint32_t *ch_freq_list, uint8_t *vdev_id, |
| 2017 | enum policy_mgr_con_mode mode) |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2018 | { |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 2019 | |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 2020 | uint32_t count = 0, index = 0; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2021 | uint32_t list[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2022 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 2023 | |
| 2024 | pm_ctx = policy_mgr_get_context(psoc); |
| 2025 | if (!pm_ctx) { |
| 2026 | policy_mgr_err("Invalid Context"); |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 2027 | return count; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2028 | } |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2029 | if (!ch_freq_list || !vdev_id) { |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2030 | policy_mgr_err("Null pointer error"); |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 2031 | return count; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2032 | } |
| 2033 | |
| 2034 | count = policy_mgr_mode_specific_connection_count( |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 2035 | psoc, mode, list); |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2036 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
Amruta Kulkarni | 447a326 | 2020-02-05 14:57:04 -0800 | [diff] [blame] | 2037 | if (count == 1) { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2038 | *ch_freq_list = pm_conc_connection_list[list[index]].freq; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2039 | *vdev_id = |
| 2040 | pm_conc_connection_list[list[index]].vdev_id; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2041 | } else { |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 2042 | for (index = 0; index < count; index++) { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2043 | ch_freq_list[index] = pm_conc_connection_list[ |
| 2044 | list[index]].freq; |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 2045 | |
| 2046 | vdev_id[index] = |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2047 | pm_conc_connection_list[list[index]].vdev_id; |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 2048 | } |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2049 | } |
| 2050 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2051 | |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 2052 | return count; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 2053 | } |
| 2054 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2055 | bool policy_mgr_max_concurrent_connections_reached( |
| 2056 | struct wlan_objmgr_psoc *psoc) |
| 2057 | { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 2058 | uint8_t i = 0, j = 0; |
| 2059 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 2060 | |
| 2061 | pm_ctx = policy_mgr_get_context(psoc); |
Jeff Johnson | e79b53c | 2019-03-18 14:03:23 -0700 | [diff] [blame] | 2062 | if (pm_ctx) { |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 2063 | for (i = 0; i < QDF_MAX_NO_OF_MODE; i++) |
| 2064 | j += pm_ctx->no_of_active_sessions[i]; |
| 2065 | return j > |
Krunal Soni | 1c7a1e9 | 2018-09-27 10:55:17 -0700 | [diff] [blame] | 2066 | (pm_ctx->cfg.max_conc_cxns - 1); |
Tushnim Bhattacharyya | 9767070 | 2017-03-08 10:06:58 -0800 | [diff] [blame] | 2067 | } |
| 2068 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2069 | return false; |
| 2070 | } |
| 2071 | |
Tushnim Bhattacharyya | d7655ca | 2017-04-26 12:58:42 -0700 | [diff] [blame] | 2072 | static bool policy_mgr_is_sub_20_mhz_enabled(struct wlan_objmgr_psoc *psoc) |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2073 | { |
Tushnim Bhattacharyya | d7655ca | 2017-04-26 12:58:42 -0700 | [diff] [blame] | 2074 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 2075 | |
| 2076 | pm_ctx = policy_mgr_get_context(psoc); |
| 2077 | if (!pm_ctx) { |
| 2078 | policy_mgr_err("Invalid Context"); |
| 2079 | return false; |
| 2080 | } |
| 2081 | |
| 2082 | return pm_ctx->user_cfg.sub_20_mhz_enabled; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2083 | } |
| 2084 | |
Liangwei Dong | 1a18faf | 2018-07-16 06:39:29 -0400 | [diff] [blame] | 2085 | /** |
| 2086 | * policy_mgr_check_privacy_for_new_conn() - Check privacy mode concurrency |
| 2087 | * @pm_ctx: policy_mgr_psoc_priv_obj policy mgr context |
| 2088 | * |
| 2089 | * This routine is called to check vdev security mode allowed in concurrency. |
| 2090 | * At present, WAPI security mode is not allowed to run concurrency with any |
| 2091 | * other vdev. |
| 2092 | * |
| 2093 | * Return: true - allow |
| 2094 | */ |
| 2095 | static bool policy_mgr_check_privacy_for_new_conn( |
| 2096 | struct policy_mgr_psoc_priv_obj *pm_ctx) |
| 2097 | { |
| 2098 | if (!pm_ctx->hdd_cbacks.hdd_wapi_security_sta_exist) |
| 2099 | return true; |
| 2100 | |
| 2101 | if (pm_ctx->hdd_cbacks.hdd_wapi_security_sta_exist() && |
| 2102 | (policy_mgr_get_connection_count(pm_ctx->psoc) > 0)) |
| 2103 | return false; |
| 2104 | |
| 2105 | return true; |
| 2106 | } |
| 2107 | |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2108 | #ifdef FEATURE_FOURTH_CONNECTION |
| 2109 | static bool policy_mgr_is_concurrency_allowed_4_port( |
| 2110 | struct wlan_objmgr_psoc *psoc, |
| 2111 | enum policy_mgr_con_mode mode, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2112 | uint32_t ch_freq, |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2113 | struct policy_mgr_pcl_list pcl) |
| 2114 | { |
| 2115 | uint32_t i; |
| 2116 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
gaurank kathpalia | 7fd92d9 | 2020-02-27 00:02:54 +0530 | [diff] [blame^] | 2117 | uint8_t sap_cnt, go_cnt; |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2118 | |
| 2119 | /* new STA may just have ssid, no channel until bssid assigned */ |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2120 | if (ch_freq == 0 && mode == PM_STA_MODE) |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2121 | return true; |
| 2122 | |
gaurank kathpalia | 7fd92d9 | 2020-02-27 00:02:54 +0530 | [diff] [blame^] | 2123 | sap_cnt = policy_mgr_mode_specific_connection_count(psoc, |
| 2124 | PM_SAP_MODE, NULL); |
| 2125 | |
| 2126 | go_cnt = policy_mgr_mode_specific_connection_count(psoc, |
| 2127 | PM_P2P_GO_MODE, NULL); |
| 2128 | if (sap_cnt || go_cnt) { |
| 2129 | pm_ctx = policy_mgr_get_context(psoc); |
| 2130 | if (!pm_ctx) { |
| 2131 | policy_mgr_err("context is NULL"); |
| 2132 | return false; |
| 2133 | } |
| 2134 | |
| 2135 | if (policy_mgr_get_mcc_to_scc_switch_mode(psoc) != |
| 2136 | QDF_MCC_TO_SCC_SWITCH_FORCE_WITHOUT_DISCONNECTION) { |
| 2137 | policy_mgr_err("couldn't start 4th port for bad force scc cfg"); |
| 2138 | return false; |
| 2139 | } |
| 2140 | if (pm_ctx->cfg.dual_mac_feature || |
| 2141 | !pm_ctx->cfg.sta_sap_scc_on_dfs_chnl || |
| 2142 | !pm_ctx->cfg.sta_sap_scc_on_lte_coex_chnl) { |
| 2143 | policy_mgr_err( |
| 2144 | "Couldn't start 4th port for bad cfg of dual mac, dfs scc, lte coex scc"); |
| 2145 | return false; |
| 2146 | } |
| 2147 | |
| 2148 | for (i = 0; i < pcl.pcl_len; i++) |
| 2149 | if (ch_freq == pcl.pcl_list[i]) |
| 2150 | return true; |
| 2151 | |
| 2152 | policy_mgr_err("4th port failed on ch freq %d with mode %d", |
| 2153 | ch_freq, mode); |
| 2154 | |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2155 | return false; |
| 2156 | } |
| 2157 | |
gaurank kathpalia | 7fd92d9 | 2020-02-27 00:02:54 +0530 | [diff] [blame^] | 2158 | return true; |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2159 | } |
| 2160 | #else |
| 2161 | static inline bool policy_mgr_is_concurrency_allowed_4_port( |
| 2162 | struct wlan_objmgr_psoc *psoc, |
| 2163 | enum policy_mgr_con_mode mode, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2164 | uint32_t ch_freq, |
| 2165 | struct policy_mgr_pcl_list pcl) |
| 2166 | {return false; } |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2167 | #endif |
| 2168 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2169 | /** |
| 2170 | * policy_mgr_allow_multiple_sta_connections() - check whether multiple STA |
| 2171 | * concurrency is allowed and F/W supported |
| 2172 | * @psoc: Pointer to soc |
| 2173 | * @second_sta_freq: 2nd STA channel frequency |
| 2174 | * @first_sta_freq: 1st STA channel frequency |
| 2175 | * |
| 2176 | * Return: true if supports else false. |
| 2177 | */ |
| 2178 | static bool policy_mgr_allow_multiple_sta_connections(struct wlan_objmgr_psoc *psoc, |
| 2179 | uint32_t second_sta_freq, |
| 2180 | uint32_t first_sta_freq) |
| 2181 | { |
| 2182 | struct wmi_unified *wmi_handle; |
| 2183 | |
| 2184 | wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); |
| 2185 | if (!wmi_handle) { |
| 2186 | policy_mgr_debug("Invalid WMI handle"); |
| 2187 | return false; |
| 2188 | } |
| 2189 | if (!wmi_service_enabled(wmi_handle, |
| 2190 | wmi_service_sta_plus_sta_support)) |
| 2191 | return false; |
| 2192 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2193 | return true; |
| 2194 | } |
| 2195 | |
Liangwei Dong | adbb5df | 2019-11-05 13:19:37 +0800 | [diff] [blame] | 2196 | #if defined(CONFIG_BAND_6GHZ) && defined(WLAN_FEATURE_11AX) |
| 2197 | bool policy_mgr_is_6ghz_conc_mode_supported( |
| 2198 | struct wlan_objmgr_psoc *psoc, enum policy_mgr_con_mode mode) |
| 2199 | { |
| 2200 | if (mode == PM_STA_MODE || mode == PM_SAP_MODE) |
| 2201 | return true; |
| 2202 | else |
| 2203 | return false; |
| 2204 | } |
| 2205 | #endif |
| 2206 | |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 2207 | /** |
| 2208 | * policy_mgr_is_6g_channel_allowed() - Check new 6Ghz connection |
| 2209 | * allowed or not |
| 2210 | * @psoc: Pointer to soc |
| 2211 | * @mode: new connection mode |
| 2212 | * @ch_freq: channel freq |
| 2213 | * |
| 2214 | * 1. Only STA/SAP are allowed on 6Ghz. |
| 2215 | * 2. If there is DFS beacon entity existing on 5G band, 5G+6G MCC is not |
| 2216 | * allowed. |
| 2217 | * |
| 2218 | * Return: true if supports else false. |
| 2219 | */ |
| 2220 | static bool policy_mgr_is_6g_channel_allowed( |
| 2221 | struct wlan_objmgr_psoc *psoc, enum policy_mgr_con_mode mode, |
| 2222 | uint32_t ch_freq) |
| 2223 | { |
| 2224 | uint32_t conn_index = 0; |
| 2225 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 2226 | struct policy_mgr_conc_connection_info *conn; |
| 2227 | bool is_dfs; |
| 2228 | |
| 2229 | pm_ctx = policy_mgr_get_context(psoc); |
| 2230 | if (!pm_ctx) { |
| 2231 | policy_mgr_err("Invalid Context"); |
| 2232 | return false; |
| 2233 | } |
| 2234 | if (!WLAN_REG_IS_6GHZ_CHAN_FREQ(ch_freq)) |
| 2235 | return true; |
| 2236 | |
| 2237 | /* Only STA/SAP is supported on 6Ghz currently */ |
| 2238 | if (!policy_mgr_is_6ghz_conc_mode_supported(psoc, mode)) |
| 2239 | return false; |
| 2240 | |
| 2241 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 2242 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 2243 | conn_index++) { |
| 2244 | conn = &pm_conc_connection_list[conn_index]; |
| 2245 | if (!conn->in_use) |
| 2246 | continue; |
| 2247 | is_dfs = (conn->ch_flagext & |
| 2248 | (IEEE80211_CHAN_DFS | IEEE80211_CHAN_DFS_CFREQ2)) && |
| 2249 | WLAN_REG_IS_5GHZ_CH_FREQ(conn->freq); |
| 2250 | if ((conn->mode == PM_SAP_MODE || |
| 2251 | conn->mode == PM_P2P_GO_MODE) && |
| 2252 | is_dfs && ch_freq != conn->freq) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2253 | policy_mgr_rl_debug("don't allow MCC if SAP/GO on DFS channel"); |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 2254 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2255 | return false; |
| 2256 | } |
| 2257 | } |
| 2258 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2259 | |
| 2260 | return true; |
| 2261 | } |
| 2262 | |
Tushnim Bhattacharyya | 0351f17 | 2018-07-31 12:24:57 -0700 | [diff] [blame] | 2263 | bool policy_mgr_is_concurrency_allowed(struct wlan_objmgr_psoc *psoc, |
| 2264 | enum policy_mgr_con_mode mode, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2265 | uint32_t ch_freq, |
Tushnim Bhattacharyya | 0351f17 | 2018-07-31 12:24:57 -0700 | [diff] [blame] | 2266 | enum hw_mode_bandwidth bw) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2267 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2268 | uint32_t num_connections = 0, count = 0, index = 0; |
| 2269 | bool status = false, match = false; |
| 2270 | uint32_t list[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
| 2271 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Bala Venkatesh | 06a4e7c | 2018-06-09 20:19:18 +0530 | [diff] [blame] | 2272 | bool sta_sap_scc_on_dfs_chan; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2273 | uint32_t sta_freq; |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 2274 | enum channel_state chan_state; |
| 2275 | bool is_dfs_ch = false; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2276 | |
| 2277 | pm_ctx = policy_mgr_get_context(psoc); |
| 2278 | if (!pm_ctx) { |
| 2279 | policy_mgr_err("Invalid Context"); |
| 2280 | return status; |
| 2281 | } |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2282 | /* find the current connection state from pm_conc_connection_list*/ |
| 2283 | num_connections = policy_mgr_get_connection_count(psoc); |
| 2284 | |
Tushnim Bhattacharyya | d7655ca | 2017-04-26 12:58:42 -0700 | [diff] [blame] | 2285 | if (num_connections && policy_mgr_is_sub_20_mhz_enabled(psoc)) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2286 | policy_mgr_rl_debug("dont allow concurrency if Sub 20 MHz is enabled"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2287 | status = false; |
| 2288 | goto done; |
| 2289 | } |
| 2290 | |
| 2291 | if (policy_mgr_max_concurrent_connections_reached(psoc)) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2292 | policy_mgr_rl_debug("Reached max concurrent connections: %d", |
| 2293 | pm_ctx->cfg.max_conc_cxns); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2294 | goto done; |
| 2295 | } |
| 2296 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2297 | if (ch_freq) { |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 2298 | chan_state = wlan_reg_get_5g_bonded_channel_state_for_freq( |
| 2299 | pm_ctx->pdev, ch_freq, |
| 2300 | policy_mgr_get_ch_width(bw)); |
| 2301 | if (chan_state == CHANNEL_STATE_DFS) |
| 2302 | is_dfs_ch = true; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2303 | /* don't allow 3rd home channel on same MAC */ |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2304 | if (!policy_mgr_allow_new_home_channel(psoc, mode, ch_freq, |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 2305 | num_connections, |
| 2306 | is_dfs_ch)) |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2307 | goto done; |
| 2308 | |
| 2309 | /* |
| 2310 | * 1) DFS MCC is not yet supported |
| 2311 | * 2) If you already have STA connection on 5G channel then |
| 2312 | * don't allow any other persona to make connection on DFS |
| 2313 | * channel because STA 5G + DFS MCC is not allowed. |
| 2314 | * 3) If STA is on 2G channel and SAP is coming up on |
| 2315 | * DFS channel then allow concurrency but make sure it is |
| 2316 | * going to DBS and send PCL to firmware indicating that |
| 2317 | * don't allow STA to roam to 5G channels. |
Krishna Reddy | 3c62990 | 2019-07-05 12:42:29 +0530 | [diff] [blame] | 2318 | * 4) On a single MAC device, if a SAP/P2PGO is already on a DFS |
| 2319 | * channel, don't allow a 2 channel as it will result |
| 2320 | * in MCC which is not allowed. |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2321 | */ |
| 2322 | if (!policy_mgr_is_5g_channel_allowed(psoc, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2323 | ch_freq, list, PM_P2P_GO_MODE)) |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2324 | goto done; |
| 2325 | if (!policy_mgr_is_5g_channel_allowed(psoc, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2326 | ch_freq, list, PM_SAP_MODE)) |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2327 | goto done; |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 2328 | if (!policy_mgr_is_6g_channel_allowed(psoc, mode, |
| 2329 | ch_freq)) |
| 2330 | goto done; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2331 | |
Bala Venkatesh | 06a4e7c | 2018-06-09 20:19:18 +0530 | [diff] [blame] | 2332 | sta_sap_scc_on_dfs_chan = |
| 2333 | policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan(psoc); |
Bala Venkatesh | 06a4e7c | 2018-06-09 20:19:18 +0530 | [diff] [blame] | 2334 | |
| 2335 | if (!sta_sap_scc_on_dfs_chan && ((mode == PM_P2P_GO_MODE) || |
| 2336 | (mode == PM_SAP_MODE))) { |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 2337 | if (is_dfs_ch) |
Manikandan Mohan | a0bbb51 | 2019-08-15 11:39:26 -0700 | [diff] [blame] | 2338 | match = policy_mgr_disallow_mcc(psoc, |
| 2339 | ch_freq); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2340 | } |
| 2341 | if (true == match) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2342 | policy_mgr_rl_debug("No MCC, SAP/GO about to come up on DFS channel"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2343 | goto done; |
| 2344 | } |
Krishna Reddy | 3c62990 | 2019-07-05 12:42:29 +0530 | [diff] [blame] | 2345 | if ((policy_mgr_is_hw_dbs_capable(psoc) != true) && |
| 2346 | num_connections) { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2347 | if (WLAN_REG_IS_24GHZ_CH_FREQ(ch_freq)) { |
Krishna Reddy | 3c62990 | 2019-07-05 12:42:29 +0530 | [diff] [blame] | 2348 | if (policy_mgr_is_sap_p2pgo_on_dfs(psoc)) { |
Amruta Kulkarni | 447a326 | 2020-02-05 14:57:04 -0800 | [diff] [blame] | 2349 | policy_mgr_rl_debug("MCC not allowed: SAP/P2PGO on DFS"); |
Krishna Reddy | 3c62990 | 2019-07-05 12:42:29 +0530 | [diff] [blame] | 2350 | goto done; |
| 2351 | } |
| 2352 | } |
| 2353 | } |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2354 | } |
| 2355 | |
Jianmin Zhu | e487f79 | 2019-10-15 13:34:34 +0800 | [diff] [blame] | 2356 | /* Check for STA+STA concurrency */ |
Rajeev Kumar Sirasanagandla | 02cf4c9 | 2019-04-02 16:29:30 +0530 | [diff] [blame] | 2357 | count = policy_mgr_mode_specific_connection_count(psoc, PM_STA_MODE, |
| 2358 | list); |
Jianmin Zhu | e487f79 | 2019-10-15 13:34:34 +0800 | [diff] [blame] | 2359 | if (mode == PM_STA_MODE && count) { |
| 2360 | if (count >= 2) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2361 | policy_mgr_rl_debug("3rd STA isn't permitted"); |
Jianmin Zhu | e487f79 | 2019-10-15 13:34:34 +0800 | [diff] [blame] | 2362 | goto done; |
| 2363 | } |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2364 | sta_freq = pm_conc_connection_list[list[0]].freq; |
| 2365 | if (!policy_mgr_allow_multiple_sta_connections(psoc, ch_freq, |
| 2366 | sta_freq)) |
Jianmin Zhu | e487f79 | 2019-10-15 13:34:34 +0800 | [diff] [blame] | 2367 | goto done; |
Rajeev Kumar Sirasanagandla | 02cf4c9 | 2019-04-02 16:29:30 +0530 | [diff] [blame] | 2368 | } |
| 2369 | |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2370 | /* |
| 2371 | * Check all IBSS+STA concurrencies |
| 2372 | * |
| 2373 | * don't allow IBSS + STA MCC |
| 2374 | * don't allow IBSS + STA SCC if IBSS is on DFS channel |
| 2375 | */ |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2376 | if ((PM_IBSS_MODE == mode) && |
| 2377 | (policy_mgr_mode_specific_connection_count(psoc, |
| 2378 | PM_IBSS_MODE, list)) && count) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2379 | policy_mgr_rl_debug("No 2nd IBSS, we already have STA + IBSS"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2380 | goto done; |
| 2381 | } |
| 2382 | if ((PM_IBSS_MODE == mode) && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2383 | (wlan_reg_is_dfs_for_freq(pm_ctx->pdev, ch_freq)) && count) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2384 | policy_mgr_rl_debug("No IBSS + STA SCC/MCC, IBSS is on DFS channel"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2385 | goto done; |
| 2386 | } |
| 2387 | if (PM_IBSS_MODE == mode) { |
| 2388 | if (policy_mgr_is_hw_dbs_capable(psoc) == true) { |
| 2389 | if (num_connections > 1) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2390 | policy_mgr_rl_debug("No IBSS, we have concurrent connections already"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2391 | goto done; |
| 2392 | } |
| 2393 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 2394 | if (PM_STA_MODE != pm_conc_connection_list[0].mode) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2395 | policy_mgr_rl_debug("No IBSS, we've a non-STA connection"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2396 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2397 | goto done; |
| 2398 | } |
| 2399 | /* |
| 2400 | * This logic protects STA and IBSS to come up on same |
| 2401 | * band. If requirement changes then this condition |
| 2402 | * needs to be removed |
| 2403 | */ |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2404 | if (ch_freq && |
| 2405 | pm_conc_connection_list[0].freq != ch_freq && |
| 2406 | WLAN_REG_IS_SAME_BAND_FREQS( |
| 2407 | pm_conc_connection_list[0].freq, ch_freq)) { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2408 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2409 | policy_mgr_rl_debug("No IBSS + STA MCC"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2410 | goto done; |
| 2411 | } |
| 2412 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2413 | } else if (num_connections) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2414 | policy_mgr_rl_debug("No IBSS, we have one connection already"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2415 | goto done; |
| 2416 | } |
| 2417 | } |
| 2418 | |
| 2419 | if ((PM_STA_MODE == mode) && |
| 2420 | (policy_mgr_mode_specific_connection_count(psoc, |
| 2421 | PM_IBSS_MODE, list)) && count) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2422 | policy_mgr_rl_debug("No 2nd STA, we already have STA + IBSS"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2423 | goto done; |
| 2424 | } |
| 2425 | |
| 2426 | if ((PM_STA_MODE == mode) && |
| 2427 | (policy_mgr_mode_specific_connection_count(psoc, |
| 2428 | PM_IBSS_MODE, list))) { |
| 2429 | if (policy_mgr_is_hw_dbs_capable(psoc) == true) { |
| 2430 | if (num_connections > 1) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2431 | policy_mgr_rl_debug("No 2nd STA, we already have IBSS concurrency"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2432 | goto done; |
| 2433 | } |
| 2434 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2435 | if (ch_freq && |
| 2436 | (wlan_reg_is_dfs_for_freq(pm_ctx->pdev, |
| 2437 | pm_conc_connection_list[0].freq)) && |
| 2438 | (WLAN_REG_IS_5GHZ_CH_FREQ(ch_freq))) { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2439 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2440 | policy_mgr_rl_debug("No IBSS + STA SCC/MCC, IBSS is on DFS channel"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2441 | goto done; |
| 2442 | } |
| 2443 | /* |
| 2444 | * This logic protects STA and IBSS to come up on same |
| 2445 | * band. If requirement changes then this condition |
| 2446 | * needs to be removed |
| 2447 | */ |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2448 | if (pm_conc_connection_list[0].freq != ch_freq && |
| 2449 | WLAN_REG_IS_SAME_BAND_FREQS( |
| 2450 | pm_conc_connection_list[0].freq, ch_freq)) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2451 | policy_mgr_rl_debug("No IBSS + STA MCC"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2452 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2453 | goto done; |
| 2454 | } |
| 2455 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2456 | } else { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2457 | policy_mgr_rl_debug("No STA, we have IBSS connection already"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2458 | goto done; |
| 2459 | } |
| 2460 | } |
| 2461 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2462 | if (!policy_mgr_allow_sap_go_concurrency(psoc, mode, ch_freq, |
Jianmin Zhu | e1ebfd0 | 2018-08-21 19:20:28 +0800 | [diff] [blame] | 2463 | WLAN_INVALID_VDEV_ID)) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2464 | policy_mgr_rl_debug("This concurrency combination is not allowed"); |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 2465 | goto done; |
| 2466 | } |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2467 | /* don't allow two P2P GO on same band */ |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2468 | if (ch_freq && mode == PM_P2P_GO_MODE && num_connections) { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2469 | index = 0; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2470 | count = policy_mgr_mode_specific_connection_count( |
| 2471 | psoc, PM_P2P_GO_MODE, list); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2472 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 2473 | while (index < count) { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2474 | if (WLAN_REG_IS_SAME_BAND_FREQS( |
| 2475 | ch_freq, |
| 2476 | pm_conc_connection_list[list[index]].freq)) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2477 | policy_mgr_rl_debug("Don't allow P2P GO on same band"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2478 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2479 | goto done; |
| 2480 | } |
| 2481 | index++; |
| 2482 | } |
| 2483 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2484 | } |
| 2485 | |
Liangwei Dong | 1a18faf | 2018-07-16 06:39:29 -0400 | [diff] [blame] | 2486 | if (!policy_mgr_check_privacy_for_new_conn(pm_ctx)) { |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 2487 | policy_mgr_rl_debug("Don't allow new conn when wapi security conn existing"); |
Liangwei Dong | 1a18faf | 2018-07-16 06:39:29 -0400 | [diff] [blame] | 2488 | goto done; |
| 2489 | } |
| 2490 | |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2491 | status = true; |
| 2492 | |
| 2493 | done: |
| 2494 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2495 | } |
| 2496 | |
Manikandan Mohan | 282c4b6 | 2019-08-14 17:42:22 -0700 | [diff] [blame] | 2497 | bool policy_mgr_allow_concurrency(struct wlan_objmgr_psoc *psoc, |
| 2498 | enum policy_mgr_con_mode mode, |
| 2499 | uint32_t ch_freq, |
| 2500 | enum hw_mode_bandwidth bw) |
Tushnim Bhattacharyya | 0351f17 | 2018-07-31 12:24:57 -0700 | [diff] [blame] | 2501 | { |
| 2502 | QDF_STATUS status; |
| 2503 | struct policy_mgr_pcl_list pcl; |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2504 | bool allowed; |
Tushnim Bhattacharyya | 0351f17 | 2018-07-31 12:24:57 -0700 | [diff] [blame] | 2505 | |
| 2506 | qdf_mem_zero(&pcl, sizeof(pcl)); |
Manikandan Mohan | 19f3609 | 2019-08-15 15:54:02 -0700 | [diff] [blame] | 2507 | status = policy_mgr_get_pcl(psoc, mode, pcl.pcl_list, &pcl.pcl_len, |
| 2508 | pcl.weight_list, |
| 2509 | QDF_ARRAY_SIZE(pcl.weight_list)); |
Tushnim Bhattacharyya | 0351f17 | 2018-07-31 12:24:57 -0700 | [diff] [blame] | 2510 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2511 | policy_mgr_err("disallow connection:%d", status); |
| 2512 | return false; |
| 2513 | } |
| 2514 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2515 | allowed = policy_mgr_is_concurrency_allowed(psoc, mode, ch_freq, bw); |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2516 | |
| 2517 | /* Fourth connection concurrency check */ |
| 2518 | if (allowed && policy_mgr_get_connection_count(psoc) == 3) |
| 2519 | allowed = policy_mgr_is_concurrency_allowed_4_port( |
| 2520 | psoc, |
| 2521 | mode, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2522 | ch_freq, |
Jianmin Zhu | cdb16bd | 2019-05-15 19:33:55 +0800 | [diff] [blame] | 2523 | pcl); |
| 2524 | return allowed; |
Tushnim Bhattacharyya | 0351f17 | 2018-07-31 12:24:57 -0700 | [diff] [blame] | 2525 | } |
| 2526 | |
Manikandan Mohan | 282c4b6 | 2019-08-14 17:42:22 -0700 | [diff] [blame] | 2527 | bool |
| 2528 | policy_mgr_allow_concurrency_csa(struct wlan_objmgr_psoc *psoc, |
| 2529 | enum policy_mgr_con_mode mode, |
| 2530 | uint32_t ch_freq, uint32_t vdev_id, |
| 2531 | bool forced, enum sap_csa_reason_code reason) |
Jianmin Zhu | 687602c | 2018-08-24 17:01:14 +0800 | [diff] [blame] | 2532 | { |
| 2533 | bool allow = false; |
Liangwei Dong | 86ff710 | 2019-07-17 16:44:01 +0800 | [diff] [blame] | 2534 | struct policy_mgr_conc_connection_info |
| 2535 | info[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
Jianmin Zhu | 687602c | 2018-08-24 17:01:14 +0800 | [diff] [blame] | 2536 | uint8_t num_cxn_del = 0; |
Abhishek Singh | 424ca57 | 2019-03-26 11:48:38 +0530 | [diff] [blame] | 2537 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2538 | uint32_t old_ch_freq; |
Liangwei Dong | 86ff710 | 2019-07-17 16:44:01 +0800 | [diff] [blame] | 2539 | QDF_STATUS status; |
Abhishek Singh | 424ca57 | 2019-03-26 11:48:38 +0530 | [diff] [blame] | 2540 | |
| 2541 | pm_ctx = policy_mgr_get_context(psoc); |
| 2542 | if (!pm_ctx) { |
| 2543 | policy_mgr_err("Invalid Context"); |
| 2544 | return allow; |
| 2545 | } |
Liangwei Dong | 86ff710 | 2019-07-17 16:44:01 +0800 | [diff] [blame] | 2546 | policy_mgr_debug("check concurrency_csa vdev:%d ch %d, forced %d, reason %d", |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2547 | vdev_id, ch_freq, forced, reason); |
Liangwei Dong | 86ff710 | 2019-07-17 16:44:01 +0800 | [diff] [blame] | 2548 | |
Manikandan Mohan | a0bbb51 | 2019-08-15 11:39:26 -0700 | [diff] [blame] | 2549 | status = policy_mgr_get_chan_by_session_id(psoc, vdev_id, |
| 2550 | &old_ch_freq); |
Liangwei Dong | 86ff710 | 2019-07-17 16:44:01 +0800 | [diff] [blame] | 2551 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2552 | policy_mgr_err("Failed to get channel for vdev:%d", |
| 2553 | vdev_id); |
| 2554 | return allow; |
| 2555 | } |
| 2556 | qdf_mem_zero(info, sizeof(info)); |
Jianmin Zhu | 687602c | 2018-08-24 17:01:14 +0800 | [diff] [blame] | 2557 | |
| 2558 | /* |
| 2559 | * Store the connection's parameter and temporarily delete it |
| 2560 | * from the concurrency table. This way the allow concurrency |
| 2561 | * check can be used as though a new connection is coming up, |
| 2562 | * after check, restore the connection to concurrency table. |
Liangwei Dong | 86ff710 | 2019-07-17 16:44:01 +0800 | [diff] [blame] | 2563 | * |
| 2564 | * In SAP+SAP SCC case, when LTE unsafe event processing, |
| 2565 | * we should remove the all SAP conn entry on the same ch before |
| 2566 | * do the concurrency check. Otherwise the left SAP on old channel |
| 2567 | * will cause the concurrency check failure because of dual beacon |
| 2568 | * MCC not supported. for the CSA request reason code, |
| 2569 | * PM_CSA_REASON_UNSAFE_CHANNEL, we remove all the SAP |
| 2570 | * entry on old channel before do concurrency check. |
| 2571 | * |
| 2572 | * The assumption is both SAP should move to the new channel later for |
| 2573 | * the reason code. |
Jianmin Zhu | 687602c | 2018-08-24 17:01:14 +0800 | [diff] [blame] | 2574 | */ |
Abhishek Singh | 424ca57 | 2019-03-26 11:48:38 +0530 | [diff] [blame] | 2575 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
Liangwei Dong | 86ff710 | 2019-07-17 16:44:01 +0800 | [diff] [blame] | 2576 | |
| 2577 | if (forced && reason == CSA_REASON_UNSAFE_CHANNEL) |
| 2578 | policy_mgr_store_and_del_conn_info_by_chan_and_mode( |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2579 | psoc, old_ch_freq, mode, info, &num_cxn_del); |
Liangwei Dong | 86ff710 | 2019-07-17 16:44:01 +0800 | [diff] [blame] | 2580 | else |
| 2581 | policy_mgr_store_and_del_conn_info_by_vdev_id( |
| 2582 | psoc, vdev_id, info, &num_cxn_del); |
| 2583 | |
Manikandan Mohan | 282c4b6 | 2019-08-14 17:42:22 -0700 | [diff] [blame] | 2584 | allow = policy_mgr_allow_concurrency(psoc, mode, ch_freq, |
| 2585 | HW_MODE_20_MHZ); |
Jianmin Zhu | 687602c | 2018-08-24 17:01:14 +0800 | [diff] [blame] | 2586 | /* Restore the connection entry */ |
| 2587 | if (num_cxn_del > 0) |
Liangwei Dong | 86ff710 | 2019-07-17 16:44:01 +0800 | [diff] [blame] | 2588 | policy_mgr_restore_deleted_conn_info(psoc, info, num_cxn_del); |
Abhishek Singh | 424ca57 | 2019-03-26 11:48:38 +0530 | [diff] [blame] | 2589 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 2590 | |
| 2591 | if (!allow) |
| 2592 | policy_mgr_err("CSA concurrency check failed"); |
Jianmin Zhu | 687602c | 2018-08-24 17:01:14 +0800 | [diff] [blame] | 2593 | |
| 2594 | return allow; |
| 2595 | } |
| 2596 | |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 2597 | /** |
| 2598 | * policy_mgr_get_concurrency_mode() - return concurrency mode |
| 2599 | * @psoc: PSOC object information |
| 2600 | * |
| 2601 | * This routine is used to retrieve concurrency mode |
| 2602 | * |
| 2603 | * Return: uint32_t value of concurrency mask |
| 2604 | */ |
| 2605 | uint32_t policy_mgr_get_concurrency_mode(struct wlan_objmgr_psoc *psoc) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2606 | { |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 2607 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 2608 | |
| 2609 | pm_ctx = policy_mgr_get_context(psoc); |
| 2610 | if (!pm_ctx) { |
| 2611 | policy_mgr_err("Invalid context"); |
| 2612 | return QDF_STA_MASK; |
| 2613 | } |
| 2614 | |
Arun Kumar Khandavalli | f4ed406 | 2020-01-20 11:45:09 +0530 | [diff] [blame] | 2615 | policy_mgr_debug("concurrency_mode: 0x%x", |
| 2616 | pm_ctx->concurrency_mode); |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 2617 | |
| 2618 | return pm_ctx->concurrency_mode; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2619 | } |
| 2620 | |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 2621 | /** |
| 2622 | * policy_mgr_get_channel_from_scan_result() - to get channel from scan result |
| 2623 | * @psoc: PSOC object information |
| 2624 | * @roam_profile: pointer to roam profile |
| 2625 | * @channel: channel to be filled |
| 2626 | * |
| 2627 | * This routine gets channel which most likely a candidate to which STA |
| 2628 | * will make connection. |
| 2629 | * |
| 2630 | * Return: QDF_STATUS |
| 2631 | */ |
Manikandan Mohan | 282c4b6 | 2019-08-14 17:42:22 -0700 | [diff] [blame] | 2632 | QDF_STATUS policy_mgr_get_channel_from_scan_result( |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2633 | struct wlan_objmgr_psoc *psoc, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2634 | void *roam_profile, uint32_t *ch_freq) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2635 | { |
Tushnim Bhattacharyya | 42b8067 | 2017-08-21 13:01:21 -0700 | [diff] [blame] | 2636 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 2637 | void *scan_cache = NULL; |
| 2638 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 2639 | |
| 2640 | pm_ctx = policy_mgr_get_context(psoc); |
| 2641 | if (!pm_ctx) { |
| 2642 | policy_mgr_err("Invalid context"); |
| 2643 | return QDF_STATUS_E_INVAL; |
| 2644 | } |
| 2645 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2646 | if (!roam_profile || !ch_freq) { |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 2647 | policy_mgr_err("Invalid input parameters"); |
| 2648 | return QDF_STATUS_E_INVAL; |
| 2649 | } |
| 2650 | |
Archana Ramachandran | 658a48d | 2017-03-23 23:30:23 -0700 | [diff] [blame] | 2651 | if (pm_ctx->sme_cbacks.sme_get_ap_channel_from_scan) { |
| 2652 | status = pm_ctx->sme_cbacks.sme_get_ap_channel_from_scan |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2653 | (roam_profile, &scan_cache, ch_freq); |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 2654 | if (status != QDF_STATUS_SUCCESS) { |
| 2655 | policy_mgr_err("Get AP channel failed"); |
| 2656 | return status; |
| 2657 | } |
Archana Ramachandran | 658a48d | 2017-03-23 23:30:23 -0700 | [diff] [blame] | 2658 | } else { |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 2659 | policy_mgr_err("sme_get_ap_channel_from_scan_cache NULL"); |
Tushnim Bhattacharyya | 42b8067 | 2017-08-21 13:01:21 -0700 | [diff] [blame] | 2660 | return QDF_STATUS_E_FAILURE; |
Archana Ramachandran | 658a48d | 2017-03-23 23:30:23 -0700 | [diff] [blame] | 2661 | } |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 2662 | |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 2663 | if (pm_ctx->sme_cbacks.sme_scan_result_purge) |
| 2664 | status = pm_ctx->sme_cbacks.sme_scan_result_purge(scan_cache); |
| 2665 | else |
| 2666 | policy_mgr_err("sme_scan_result_purge NULL"); |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 2667 | |
| 2668 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2669 | } |
| 2670 | |
Archana Ramachandran | 3d9b5cf | 2017-03-10 18:56:44 -0800 | [diff] [blame] | 2671 | QDF_STATUS policy_mgr_set_user_cfg(struct wlan_objmgr_psoc *psoc, |
| 2672 | struct policy_mgr_user_cfg *user_cfg) |
| 2673 | { |
| 2674 | |
| 2675 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 2676 | |
| 2677 | pm_ctx = policy_mgr_get_context(psoc); |
| 2678 | if (!pm_ctx) { |
| 2679 | policy_mgr_err("Invalid context"); |
| 2680 | return QDF_STATUS_E_FAILURE; |
| 2681 | } |
Jeff Johnson | e79b53c | 2019-03-18 14:03:23 -0700 | [diff] [blame] | 2682 | if (!user_cfg) { |
Archana Ramachandran | 3d9b5cf | 2017-03-10 18:56:44 -0800 | [diff] [blame] | 2683 | policy_mgr_err("Invalid User Config"); |
| 2684 | return QDF_STATUS_E_FAILURE; |
| 2685 | } |
| 2686 | |
| 2687 | pm_ctx->user_cfg = *user_cfg; |
Krunal Soni | d4e542b | 2018-09-27 12:40:33 -0700 | [diff] [blame] | 2688 | policy_mgr_debug("dbs_selection_plcy 0x%x", |
| 2689 | pm_ctx->cfg.dbs_selection_plcy); |
Liangwei Dong | ecbf113 | 2018-05-25 05:24:12 -0400 | [diff] [blame] | 2690 | policy_mgr_debug("vdev_priority_list 0x%x", |
Krunal Soni | d4e542b | 2018-09-27 12:40:33 -0700 | [diff] [blame] | 2691 | pm_ctx->cfg.vdev_priority_list); |
Krunal Soni | 6dd2208 | 2018-09-27 10:40:24 -0700 | [diff] [blame] | 2692 | pm_ctx->cur_conc_system_pref = pm_ctx->cfg.sys_pref; |
Ganesh Kondabattini | 2a8c7b0 | 2017-07-10 17:34:36 +0530 | [diff] [blame] | 2693 | |
Archana Ramachandran | 3d9b5cf | 2017-03-10 18:56:44 -0800 | [diff] [blame] | 2694 | return QDF_STATUS_SUCCESS; |
| 2695 | } |
| 2696 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2697 | uint32_t policy_mgr_search_and_check_for_session_conc( |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2698 | struct wlan_objmgr_psoc *psoc, |
| 2699 | uint8_t session_id, |
| 2700 | void *roam_profile) |
| 2701 | { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2702 | uint32_t ch_freq = 0; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2703 | QDF_STATUS status; |
| 2704 | enum policy_mgr_con_mode mode; |
| 2705 | bool ret; |
Tushnim Bhattacharyya | 59cbe5c | 2017-03-24 14:13:52 -0700 | [diff] [blame] | 2706 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2707 | |
Tushnim Bhattacharyya | 59cbe5c | 2017-03-24 14:13:52 -0700 | [diff] [blame] | 2708 | pm_ctx = policy_mgr_get_context(psoc); |
| 2709 | if (!pm_ctx) { |
| 2710 | policy_mgr_err("Invalid Context"); |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2711 | return ch_freq; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2712 | } |
| 2713 | |
Tushnim Bhattacharyya | 59cbe5c | 2017-03-24 14:13:52 -0700 | [diff] [blame] | 2714 | if (pm_ctx->hdd_cbacks.get_mode_for_non_connected_vdev) { |
| 2715 | mode = pm_ctx->hdd_cbacks.get_mode_for_non_connected_vdev( |
| 2716 | psoc, session_id); |
| 2717 | if (PM_MAX_NUM_OF_MODE == mode) { |
| 2718 | policy_mgr_err("Invalid mode"); |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2719 | return ch_freq; |
Tushnim Bhattacharyya | 59cbe5c | 2017-03-24 14:13:52 -0700 | [diff] [blame] | 2720 | } |
| 2721 | } else |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2722 | return ch_freq; |
Tushnim Bhattacharyya | 59cbe5c | 2017-03-24 14:13:52 -0700 | [diff] [blame] | 2723 | |
Manikandan Mohan | 282c4b6 | 2019-08-14 17:42:22 -0700 | [diff] [blame] | 2724 | status = policy_mgr_get_channel_from_scan_result( |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2725 | psoc, roam_profile, &ch_freq); |
| 2726 | if (QDF_STATUS_SUCCESS != status || ch_freq == 0) { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2727 | policy_mgr_err("%s error %d %d", |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2728 | __func__, status, ch_freq); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2729 | return 0; |
| 2730 | } |
| 2731 | |
| 2732 | /* Take care of 160MHz and 80+80Mhz later */ |
Manikandan Mohan | 282c4b6 | 2019-08-14 17:42:22 -0700 | [diff] [blame] | 2733 | ret = policy_mgr_allow_concurrency(psoc, mode, ch_freq, |
| 2734 | HW_MODE_20_MHZ); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2735 | if (false == ret) { |
| 2736 | policy_mgr_err("Connection failed due to conc check fail"); |
| 2737 | return 0; |
| 2738 | } |
| 2739 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2740 | return ch_freq; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2741 | } |
| 2742 | |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 2743 | /** |
| 2744 | * policy_mgr_is_two_connection_mcc() - Check if MCC scenario |
| 2745 | * when there are two connections |
| 2746 | * |
| 2747 | * If if MCC scenario when there are two connections |
| 2748 | * |
| 2749 | * Return: true or false |
| 2750 | */ |
| 2751 | static bool policy_mgr_is_two_connection_mcc(void) |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 2752 | { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2753 | return ((pm_conc_connection_list[0].freq != |
| 2754 | pm_conc_connection_list[1].freq) && |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 2755 | (pm_conc_connection_list[0].mac == |
| 2756 | pm_conc_connection_list[1].mac) && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2757 | (pm_conc_connection_list[0].freq <= |
| 2758 | WLAN_REG_MAX_24GHZ_CHAN_FREQ) && |
| 2759 | (pm_conc_connection_list[1].freq <= |
| 2760 | WLAN_REG_MAX_24GHZ_CHAN_FREQ)) ? true : false; |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 2761 | } |
| 2762 | |
| 2763 | /** |
| 2764 | * policy_mgr_is_three_connection_mcc() - Check if MCC scenario |
| 2765 | * when there are three connections |
| 2766 | * |
| 2767 | * If if MCC scenario when there are three connections |
| 2768 | * |
| 2769 | * Return: true or false |
| 2770 | */ |
| 2771 | static bool policy_mgr_is_three_connection_mcc(void) |
| 2772 | { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2773 | return (((pm_conc_connection_list[0].freq != |
| 2774 | pm_conc_connection_list[1].freq) || |
| 2775 | (pm_conc_connection_list[0].freq != |
| 2776 | pm_conc_connection_list[2].freq) || |
| 2777 | (pm_conc_connection_list[1].freq != |
| 2778 | pm_conc_connection_list[2].freq)) && |
| 2779 | (pm_conc_connection_list[0].freq <= |
| 2780 | WLAN_REG_MAX_24GHZ_CHAN_FREQ) && |
| 2781 | (pm_conc_connection_list[1].freq <= |
| 2782 | WLAN_REG_MAX_24GHZ_CHAN_FREQ) && |
| 2783 | (pm_conc_connection_list[2].freq <= |
| 2784 | WLAN_REG_MAX_24GHZ_CHAN_FREQ)) ? true : false; |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 2785 | } |
| 2786 | |
| 2787 | bool policy_mgr_is_mcc_in_24G(struct wlan_objmgr_psoc *psoc) |
| 2788 | { |
| 2789 | uint32_t num_connections = 0; |
| 2790 | bool is_24G_mcc = false; |
| 2791 | |
| 2792 | num_connections = policy_mgr_get_connection_count(psoc); |
| 2793 | |
| 2794 | switch (num_connections) { |
| 2795 | case 1: |
| 2796 | break; |
| 2797 | case 2: |
| 2798 | if (policy_mgr_is_two_connection_mcc()) |
| 2799 | is_24G_mcc = true; |
| 2800 | break; |
| 2801 | case 3: |
| 2802 | if (policy_mgr_is_three_connection_mcc()) |
| 2803 | is_24G_mcc = true; |
| 2804 | break; |
| 2805 | default: |
| 2806 | policy_mgr_err("unexpected num_connections value %d", |
| 2807 | num_connections); |
| 2808 | break; |
| 2809 | } |
| 2810 | |
| 2811 | return is_24G_mcc; |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 2812 | } |
| 2813 | |
Manikandan Mohan | 7fdb025 | 2019-08-14 16:49:02 -0700 | [diff] [blame] | 2814 | bool policy_mgr_check_for_session_conc(struct wlan_objmgr_psoc *psoc, |
| 2815 | uint8_t session_id, uint32_t ch_freq) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2816 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2817 | enum policy_mgr_con_mode mode; |
| 2818 | bool ret; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 2819 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2820 | |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 2821 | pm_ctx = policy_mgr_get_context(psoc); |
| 2822 | if (!pm_ctx) { |
| 2823 | policy_mgr_err("Invalid Context"); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2824 | return false; |
| 2825 | } |
| 2826 | |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 2827 | if (pm_ctx->hdd_cbacks.get_mode_for_non_connected_vdev) { |
| 2828 | mode = pm_ctx->hdd_cbacks.get_mode_for_non_connected_vdev( |
| 2829 | psoc, session_id); |
| 2830 | if (PM_MAX_NUM_OF_MODE == mode) { |
| 2831 | policy_mgr_err("Invalid mode"); |
| 2832 | return false; |
| 2833 | } |
| 2834 | } else |
| 2835 | return false; |
| 2836 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 2837 | if (ch_freq == 0) { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2838 | policy_mgr_err("Invalid channel number 0"); |
| 2839 | return false; |
| 2840 | } |
| 2841 | |
| 2842 | /* Take care of 160MHz and 80+80Mhz later */ |
Manikandan Mohan | 282c4b6 | 2019-08-14 17:42:22 -0700 | [diff] [blame] | 2843 | ret = policy_mgr_allow_concurrency(psoc, mode, ch_freq, HW_MODE_20_MHZ); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2844 | if (false == ret) { |
| 2845 | policy_mgr_err("Connection failed due to conc check fail"); |
| 2846 | return 0; |
| 2847 | } |
| 2848 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2849 | return true; |
| 2850 | } |
| 2851 | |
Archana Ramachandran | 3d9b5cf | 2017-03-10 18:56:44 -0800 | [diff] [blame] | 2852 | /** |
| 2853 | * policy_mgr_change_mcc_go_beacon_interval() - Change MCC beacon interval |
| 2854 | * @psoc: PSOC object information |
| 2855 | * @vdev_id: vdev id |
| 2856 | * @dev_mode: device mode |
| 2857 | * |
| 2858 | * Updates the beacon parameters of the GO in MCC scenario |
| 2859 | * |
| 2860 | * Return: Success or Failure depending on the overall function behavior |
| 2861 | */ |
Archana Ramachandran | 8e3ee36 | 2017-03-03 20:02:10 -0800 | [diff] [blame] | 2862 | QDF_STATUS policy_mgr_change_mcc_go_beacon_interval( |
| 2863 | struct wlan_objmgr_psoc *psoc, |
Jeff Johnson | 275208b | 2017-11-09 09:54:12 -0800 | [diff] [blame] | 2864 | uint8_t vdev_id, enum QDF_OPMODE dev_mode) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2865 | { |
Archana Ramachandran | 8e3ee36 | 2017-03-03 20:02:10 -0800 | [diff] [blame] | 2866 | QDF_STATUS status; |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 2867 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 2868 | |
| 2869 | pm_ctx = policy_mgr_get_context(psoc); |
| 2870 | if (!pm_ctx) { |
| 2871 | policy_mgr_err("Invalid context"); |
Archana Ramachandran | 8e3ee36 | 2017-03-03 20:02:10 -0800 | [diff] [blame] | 2872 | return QDF_STATUS_E_FAILURE; |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 2873 | } |
| 2874 | |
Arun Kumar Khandavalli | f4ed406 | 2020-01-20 11:45:09 +0530 | [diff] [blame] | 2875 | policy_mgr_debug("UPDATE Beacon Params"); |
Archana Ramachandran | 8e3ee36 | 2017-03-03 20:02:10 -0800 | [diff] [blame] | 2876 | |
| 2877 | if (QDF_SAP_MODE == dev_mode) { |
Archana Ramachandran | 658a48d | 2017-03-23 23:30:23 -0700 | [diff] [blame] | 2878 | if (pm_ctx->sme_cbacks.sme_change_mcc_beacon_interval |
| 2879 | ) { |
| 2880 | status = pm_ctx->sme_cbacks. |
| 2881 | sme_change_mcc_beacon_interval(vdev_id); |
| 2882 | if (status == QDF_STATUS_E_FAILURE) { |
| 2883 | policy_mgr_err("Failed to update Beacon Params"); |
| 2884 | return QDF_STATUS_E_FAILURE; |
| 2885 | } |
| 2886 | } else { |
Archana Ramachandran | 8e3ee36 | 2017-03-03 20:02:10 -0800 | [diff] [blame] | 2887 | policy_mgr_err("sme_change_mcc_beacon_interval callback is NULL"); |
| 2888 | return QDF_STATUS_E_FAILURE; |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 2889 | } |
Archana Ramachandran | 7abbf56 | 2017-03-02 13:14:34 -0800 | [diff] [blame] | 2890 | } |
| 2891 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2892 | return QDF_STATUS_SUCCESS; |
| 2893 | } |
| 2894 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2895 | struct policy_mgr_conc_connection_info *policy_mgr_get_conn_info(uint32_t *len) |
| 2896 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2897 | struct policy_mgr_conc_connection_info *conn_ptr = |
| 2898 | &pm_conc_connection_list[0]; |
| 2899 | *len = MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 2900 | |
| 2901 | return conn_ptr; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2902 | } |
| 2903 | |
| 2904 | enum policy_mgr_con_mode policy_mgr_convert_device_mode_to_qdf_type( |
Jeff Johnson | 275208b | 2017-11-09 09:54:12 -0800 | [diff] [blame] | 2905 | enum QDF_OPMODE device_mode) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2906 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2907 | enum policy_mgr_con_mode mode = PM_MAX_NUM_OF_MODE; |
| 2908 | switch (device_mode) { |
| 2909 | case QDF_STA_MODE: |
| 2910 | mode = PM_STA_MODE; |
| 2911 | break; |
| 2912 | case QDF_P2P_CLIENT_MODE: |
| 2913 | mode = PM_P2P_CLIENT_MODE; |
| 2914 | break; |
| 2915 | case QDF_P2P_GO_MODE: |
| 2916 | mode = PM_P2P_GO_MODE; |
| 2917 | break; |
| 2918 | case QDF_SAP_MODE: |
| 2919 | mode = PM_SAP_MODE; |
| 2920 | break; |
| 2921 | case QDF_IBSS_MODE: |
| 2922 | mode = PM_IBSS_MODE; |
| 2923 | break; |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 2924 | case QDF_NAN_DISC_MODE: |
| 2925 | mode = PM_NAN_DISC_MODE; |
| 2926 | break; |
Nachiket Kukade | 413c5fa | 2019-02-19 17:57:19 +0530 | [diff] [blame] | 2927 | case QDF_NDI_MODE: |
| 2928 | mode = PM_NDI_MODE; |
| 2929 | break; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2930 | default: |
Tushnim Bhattacharyya | c05a191 | 2018-09-18 15:53:50 -0700 | [diff] [blame] | 2931 | policy_mgr_debug("Unsupported mode (%d)", |
| 2932 | device_mode); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 2933 | } |
| 2934 | |
| 2935 | return mode; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 2936 | } |
| 2937 | |
Bala Venkatesh | 28477d3 | 2018-05-07 21:35:55 +0530 | [diff] [blame] | 2938 | enum QDF_OPMODE policy_mgr_get_qdf_mode_from_pm( |
| 2939 | enum policy_mgr_con_mode device_mode) |
| 2940 | { |
| 2941 | enum QDF_OPMODE mode = QDF_MAX_NO_OF_MODE; |
| 2942 | |
| 2943 | switch (device_mode) { |
| 2944 | case PM_STA_MODE: |
| 2945 | mode = QDF_STA_MODE; |
| 2946 | break; |
| 2947 | case PM_SAP_MODE: |
| 2948 | mode = QDF_SAP_MODE; |
| 2949 | break; |
| 2950 | case PM_P2P_CLIENT_MODE: |
| 2951 | mode = QDF_P2P_CLIENT_MODE; |
| 2952 | break; |
| 2953 | case PM_P2P_GO_MODE: |
| 2954 | mode = QDF_P2P_GO_MODE; |
| 2955 | break; |
| 2956 | case PM_IBSS_MODE: |
| 2957 | mode = QDF_IBSS_MODE; |
| 2958 | break; |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 2959 | case PM_NAN_DISC_MODE: |
| 2960 | mode = QDF_NAN_DISC_MODE; |
| 2961 | break; |
Nachiket Kukade | 413c5fa | 2019-02-19 17:57:19 +0530 | [diff] [blame] | 2962 | case PM_NDI_MODE: |
| 2963 | mode = QDF_NDI_MODE; |
| 2964 | break; |
Bala Venkatesh | 28477d3 | 2018-05-07 21:35:55 +0530 | [diff] [blame] | 2965 | default: |
Tushnim Bhattacharyya | c05a191 | 2018-09-18 15:53:50 -0700 | [diff] [blame] | 2966 | policy_mgr_debug("Unsupported policy mgr mode (%d)", |
| 2967 | device_mode); |
Bala Venkatesh | 28477d3 | 2018-05-07 21:35:55 +0530 | [diff] [blame] | 2968 | } |
| 2969 | return mode; |
| 2970 | } |
| 2971 | |
Himanshu Agarwal | 0c738b7 | 2018-01-10 14:21:53 +0530 | [diff] [blame] | 2972 | QDF_STATUS policy_mgr_mode_specific_num_open_sessions( |
| 2973 | struct wlan_objmgr_psoc *psoc, enum QDF_OPMODE mode, |
| 2974 | uint8_t *num_sessions) |
| 2975 | { |
| 2976 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 2977 | |
| 2978 | pm_ctx = policy_mgr_get_context(psoc); |
| 2979 | if (!pm_ctx) { |
| 2980 | policy_mgr_err("Invalid context"); |
| 2981 | return QDF_STATUS_E_FAILURE; |
| 2982 | } |
| 2983 | |
| 2984 | *num_sessions = pm_ctx->no_of_open_sessions[mode]; |
| 2985 | return QDF_STATUS_SUCCESS; |
| 2986 | } |
| 2987 | |
Himanshu Agarwal | 533baa3 | 2018-01-25 16:20:33 +0530 | [diff] [blame] | 2988 | QDF_STATUS policy_mgr_mode_specific_num_active_sessions( |
| 2989 | struct wlan_objmgr_psoc *psoc, enum QDF_OPMODE mode, |
| 2990 | uint8_t *num_sessions) |
| 2991 | { |
| 2992 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 2993 | |
| 2994 | pm_ctx = policy_mgr_get_context(psoc); |
| 2995 | if (!pm_ctx) { |
| 2996 | policy_mgr_err("Invalid context"); |
| 2997 | return QDF_STATUS_E_FAILURE; |
| 2998 | } |
| 2999 | |
| 3000 | *num_sessions = pm_ctx->no_of_active_sessions[mode]; |
| 3001 | return QDF_STATUS_SUCCESS; |
| 3002 | } |
| 3003 | |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 3004 | /** |
| 3005 | * policy_mgr_concurrent_open_sessions_running() - Checks for |
| 3006 | * concurrent open session |
| 3007 | * @psoc: PSOC object information |
| 3008 | * |
| 3009 | * Checks if more than one open session is running for all the allowed modes |
| 3010 | * in the driver |
| 3011 | * |
| 3012 | * Return: True if more than one open session exists, False otherwise |
| 3013 | */ |
| 3014 | bool policy_mgr_concurrent_open_sessions_running( |
| 3015 | struct wlan_objmgr_psoc *psoc) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3016 | { |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 3017 | uint8_t i = 0; |
| 3018 | uint8_t j = 0; |
| 3019 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3020 | |
| 3021 | pm_ctx = policy_mgr_get_context(psoc); |
| 3022 | if (!pm_ctx) { |
| 3023 | policy_mgr_err("Invalid context"); |
| 3024 | return false; |
| 3025 | } |
| 3026 | |
| 3027 | for (i = 0; i < QDF_MAX_NO_OF_MODE; i++) |
| 3028 | j += pm_ctx->no_of_open_sessions[i]; |
| 3029 | |
| 3030 | return j > 1; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3031 | } |
| 3032 | |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 3033 | /** |
| 3034 | * policy_mgr_concurrent_beaconing_sessions_running() - Checks |
| 3035 | * for concurrent beaconing entities |
| 3036 | * @psoc: PSOC object information |
| 3037 | * |
| 3038 | * Checks if multiple beaconing sessions are running i.e., if SAP or GO or IBSS |
| 3039 | * are beaconing together |
| 3040 | * |
| 3041 | * Return: True if multiple entities are beaconing together, False otherwise |
| 3042 | */ |
| 3043 | bool policy_mgr_concurrent_beaconing_sessions_running( |
| 3044 | struct wlan_objmgr_psoc *psoc) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3045 | { |
hqu | eb32063 | 2018-01-17 17:25:25 +0800 | [diff] [blame] | 3046 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3047 | |
| 3048 | pm_ctx = policy_mgr_get_context(psoc); |
| 3049 | if (!pm_ctx) { |
| 3050 | policy_mgr_err("Invalid context"); |
| 3051 | return false; |
| 3052 | } |
| 3053 | |
| 3054 | return (pm_ctx->no_of_open_sessions[QDF_SAP_MODE] + |
| 3055 | pm_ctx->no_of_open_sessions[QDF_P2P_GO_MODE] + |
| 3056 | pm_ctx->no_of_open_sessions[QDF_IBSS_MODE] > 1) ? true : false; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3057 | } |
| 3058 | |
| 3059 | |
| 3060 | void policy_mgr_clear_concurrent_session_count(struct wlan_objmgr_psoc *psoc) |
| 3061 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3062 | uint8_t i = 0; |
| 3063 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3064 | |
| 3065 | pm_ctx = policy_mgr_get_context(psoc); |
Jeff Johnson | e79b53c | 2019-03-18 14:03:23 -0700 | [diff] [blame] | 3066 | if (pm_ctx) { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3067 | for (i = 0; i < QDF_MAX_NO_OF_MODE; i++) |
| 3068 | pm_ctx->no_of_active_sessions[i] = 0; |
| 3069 | } |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3070 | } |
| 3071 | |
| 3072 | bool policy_mgr_is_multiple_active_sta_sessions(struct wlan_objmgr_psoc *psoc) |
| 3073 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3074 | return policy_mgr_mode_specific_connection_count( |
| 3075 | psoc, PM_STA_MODE, NULL) > 1; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3076 | } |
| 3077 | |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 3078 | /** |
| 3079 | * policy_mgr_is_sta_active_connection_exists() - Check if a STA |
| 3080 | * connection is active |
| 3081 | * @psoc: PSOC object information |
| 3082 | * |
| 3083 | * Checks if there is atleast one active STA connection in the driver |
| 3084 | * |
| 3085 | * Return: True if an active STA session is present, False otherwise |
| 3086 | */ |
| 3087 | bool policy_mgr_is_sta_active_connection_exists( |
| 3088 | struct wlan_objmgr_psoc *psoc) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3089 | { |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 3090 | return (!policy_mgr_mode_specific_connection_count( |
Yuanyuan Liu | 0d506a4 | 2018-03-28 18:05:30 -0700 | [diff] [blame] | 3091 | psoc, PM_STA_MODE, NULL)) ? false : true; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3092 | } |
| 3093 | |
| 3094 | bool policy_mgr_is_any_nondfs_chnl_present(struct wlan_objmgr_psoc *psoc, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3095 | uint32_t *ch_freq) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3096 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3097 | bool status = false; |
| 3098 | uint32_t conn_index = 0; |
| 3099 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3100 | |
| 3101 | pm_ctx = policy_mgr_get_context(psoc); |
| 3102 | if (!pm_ctx) { |
| 3103 | policy_mgr_err("Invalid Context"); |
| 3104 | return false; |
| 3105 | } |
| 3106 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3107 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 3108 | conn_index++) { |
| 3109 | if (pm_conc_connection_list[conn_index].in_use && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3110 | !wlan_reg_is_dfs_for_freq(pm_ctx->pdev, |
| 3111 | pm_conc_connection_list[conn_index].freq)) { |
| 3112 | *ch_freq = pm_conc_connection_list[conn_index].freq; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3113 | status = true; |
| 3114 | } |
| 3115 | } |
| 3116 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3117 | |
| 3118 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3119 | } |
| 3120 | |
bings | 3d18e55 | 2019-08-21 18:26:47 +0800 | [diff] [blame] | 3121 | uint32_t policy_mgr_get_dfs_beaconing_session_id( |
| 3122 | struct wlan_objmgr_psoc *psoc) |
| 3123 | { |
| 3124 | uint32_t session_id = WLAN_UMAC_VDEV_ID_MAX; |
| 3125 | struct policy_mgr_conc_connection_info *conn_info; |
| 3126 | uint32_t conn_index = 0; |
| 3127 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3128 | |
| 3129 | pm_ctx = policy_mgr_get_context(psoc); |
| 3130 | if (!pm_ctx) { |
| 3131 | policy_mgr_err("Invalid Context"); |
| 3132 | return session_id; |
| 3133 | } |
| 3134 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3135 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 3136 | conn_index++) { |
| 3137 | conn_info = &pm_conc_connection_list[conn_index]; |
| 3138 | if (conn_info->in_use && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3139 | wlan_reg_chan_has_dfs_attribute_for_freq( |
| 3140 | pm_ctx->pdev, conn_info->freq) && |
bings | 3d18e55 | 2019-08-21 18:26:47 +0800 | [diff] [blame] | 3141 | (conn_info->mode == PM_SAP_MODE || |
| 3142 | conn_info->mode == PM_P2P_GO_MODE)) { |
| 3143 | session_id = |
| 3144 | pm_conc_connection_list[conn_index].vdev_id; |
| 3145 | break; |
| 3146 | } |
| 3147 | } |
| 3148 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3149 | |
| 3150 | return session_id; |
| 3151 | } |
| 3152 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3153 | bool policy_mgr_is_any_dfs_beaconing_session_present( |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3154 | struct wlan_objmgr_psoc *psoc, uint32_t *ch_freq) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3155 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3156 | struct policy_mgr_conc_connection_info *conn_info; |
| 3157 | bool status = false; |
| 3158 | uint32_t conn_index = 0; |
| 3159 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3160 | |
| 3161 | pm_ctx = policy_mgr_get_context(psoc); |
| 3162 | if (!pm_ctx) { |
| 3163 | policy_mgr_err("Invalid Context"); |
| 3164 | return false; |
| 3165 | } |
| 3166 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3167 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 3168 | conn_index++) { |
| 3169 | conn_info = &pm_conc_connection_list[conn_index]; |
| 3170 | if (conn_info->in_use && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3171 | wlan_reg_is_dfs_for_freq(pm_ctx->pdev, conn_info->freq) && |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3172 | (PM_SAP_MODE == conn_info->mode || |
| 3173 | PM_P2P_GO_MODE == conn_info->mode)) { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3174 | *ch_freq = pm_conc_connection_list[conn_index].freq; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3175 | status = true; |
| 3176 | } |
| 3177 | } |
| 3178 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3179 | |
| 3180 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3181 | } |
| 3182 | |
Liangwei Dong | bb0b7f5 | 2019-05-08 23:41:16 -0400 | [diff] [blame] | 3183 | bool policy_mgr_scan_trim_5g_chnls_for_dfs_ap(struct wlan_objmgr_psoc *psoc) |
| 3184 | { |
| 3185 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3186 | uint32_t ap_dfs_ch_freq = 0; |
Liangwei Dong | bb0b7f5 | 2019-05-08 23:41:16 -0400 | [diff] [blame] | 3187 | |
| 3188 | pm_ctx = policy_mgr_get_context(psoc); |
| 3189 | if (!pm_ctx) { |
| 3190 | policy_mgr_err("Invalid Context"); |
| 3191 | return false; |
| 3192 | } |
| 3193 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3194 | policy_mgr_is_any_dfs_beaconing_session_present(psoc, &ap_dfs_ch_freq); |
| 3195 | if (!ap_dfs_ch_freq) |
Liangwei Dong | bb0b7f5 | 2019-05-08 23:41:16 -0400 | [diff] [blame] | 3196 | return false; |
| 3197 | /* |
| 3198 | * 1) if agile & DFS scans are supportet |
| 3199 | * 2) if hardware is DBS capable |
| 3200 | * 3) if current hw mode is non-dbs |
| 3201 | * if all above 3 conditions are true then don't skip any |
| 3202 | * channel from scan list |
| 3203 | */ |
| 3204 | if (policy_mgr_is_hw_dbs_capable(psoc) && |
| 3205 | !policy_mgr_is_current_hwmode_dbs(psoc) && |
| 3206 | policy_mgr_get_dbs_plus_agile_scan_config(psoc) && |
| 3207 | policy_mgr_get_single_mac_scan_with_dfs_config(psoc)) |
| 3208 | return false; |
| 3209 | |
Abhishek Singh | eb63fb9 | 2020-03-03 10:41:37 +0530 | [diff] [blame] | 3210 | policy_mgr_debug("scan skip 5g chan due to dfs ap(ch %d) present", |
| 3211 | ap_dfs_ch_freq); |
Liangwei Dong | bb0b7f5 | 2019-05-08 23:41:16 -0400 | [diff] [blame] | 3212 | |
| 3213 | return true; |
| 3214 | } |
| 3215 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3216 | QDF_STATUS policy_mgr_get_nss_for_vdev(struct wlan_objmgr_psoc *psoc, |
| 3217 | enum policy_mgr_con_mode mode, |
| 3218 | uint8_t *nss_2g, uint8_t *nss_5g) |
| 3219 | { |
Jeff Johnson | 275208b | 2017-11-09 09:54:12 -0800 | [diff] [blame] | 3220 | enum QDF_OPMODE dev_mode; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3221 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3222 | |
Bala Venkatesh | 28477d3 | 2018-05-07 21:35:55 +0530 | [diff] [blame] | 3223 | dev_mode = policy_mgr_get_qdf_mode_from_pm(mode); |
| 3224 | if (dev_mode == QDF_MAX_NO_OF_MODE) |
| 3225 | return QDF_STATUS_E_FAILURE; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3226 | pm_ctx = policy_mgr_get_context(psoc); |
| 3227 | if (!pm_ctx) { |
| 3228 | policy_mgr_err("Invalid Context"); |
| 3229 | return QDF_STATUS_E_FAILURE; |
| 3230 | } |
| 3231 | |
Archana Ramachandran | 658a48d | 2017-03-23 23:30:23 -0700 | [diff] [blame] | 3232 | if (pm_ctx->sme_cbacks.sme_get_nss_for_vdev) { |
| 3233 | pm_ctx->sme_cbacks.sme_get_nss_for_vdev( |
| 3234 | dev_mode, nss_2g, nss_5g); |
| 3235 | |
| 3236 | } else { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3237 | policy_mgr_err("sme_get_nss_for_vdev callback is NULL"); |
| 3238 | return QDF_STATUS_E_FAILURE; |
| 3239 | } |
| 3240 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3241 | return QDF_STATUS_SUCCESS; |
| 3242 | } |
| 3243 | |
| 3244 | void policy_mgr_dump_connection_status_info(struct wlan_objmgr_psoc *psoc) |
| 3245 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3246 | uint32_t i; |
| 3247 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3248 | |
| 3249 | pm_ctx = policy_mgr_get_context(psoc); |
| 3250 | if (!pm_ctx) { |
| 3251 | policy_mgr_err("Invalid Context"); |
| 3252 | return; |
| 3253 | } |
| 3254 | |
| 3255 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3256 | for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 3257 | policy_mgr_debug("%d: use:%d vdev:%d mode:%d mac:%d freq:%d orig chainmask:%d orig nss:%d bw:%d, ch_flags %0X", |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3258 | i, pm_conc_connection_list[i].in_use, |
| 3259 | pm_conc_connection_list[i].vdev_id, |
| 3260 | pm_conc_connection_list[i].mode, |
| 3261 | pm_conc_connection_list[i].mac, |
| 3262 | pm_conc_connection_list[i].freq, |
| 3263 | pm_conc_connection_list[i].chain_mask, |
| 3264 | pm_conc_connection_list[i].original_nss, |
Kiran Kumar Lokere | 5414066 | 2019-11-01 18:42:09 -0700 | [diff] [blame] | 3265 | pm_conc_connection_list[i].bw, |
| 3266 | pm_conc_connection_list[i].ch_flagext); |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3267 | } |
| 3268 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3269 | } |
| 3270 | |
| 3271 | bool policy_mgr_is_any_mode_active_on_band_along_with_session( |
| 3272 | struct wlan_objmgr_psoc *psoc, |
| 3273 | uint8_t session_id, |
| 3274 | enum policy_mgr_band band) |
| 3275 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3276 | uint32_t i; |
| 3277 | bool status = false; |
| 3278 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3279 | |
| 3280 | pm_ctx = policy_mgr_get_context(psoc); |
| 3281 | if (!pm_ctx) { |
| 3282 | policy_mgr_err("Invalid Context"); |
| 3283 | status = false; |
| 3284 | goto send_status; |
| 3285 | } |
| 3286 | |
| 3287 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3288 | for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { |
| 3289 | switch (band) { |
| 3290 | case POLICY_MGR_BAND_24: |
| 3291 | if ((pm_conc_connection_list[i].vdev_id != session_id) |
| 3292 | && (pm_conc_connection_list[i].in_use) && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3293 | (WLAN_REG_IS_24GHZ_CH_FREQ( |
| 3294 | pm_conc_connection_list[i].freq))) { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3295 | status = true; |
| 3296 | goto release_mutex_and_send_status; |
| 3297 | } |
| 3298 | break; |
| 3299 | case POLICY_MGR_BAND_5: |
| 3300 | if ((pm_conc_connection_list[i].vdev_id != session_id) |
| 3301 | && (pm_conc_connection_list[i].in_use) && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3302 | (WLAN_REG_IS_5GHZ_CH_FREQ( |
| 3303 | pm_conc_connection_list[i].freq))) { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3304 | status = true; |
| 3305 | goto release_mutex_and_send_status; |
| 3306 | } |
| 3307 | break; |
| 3308 | default: |
| 3309 | policy_mgr_err("Invalidband option:%d", band); |
| 3310 | status = false; |
| 3311 | goto release_mutex_and_send_status; |
| 3312 | } |
| 3313 | } |
| 3314 | release_mutex_and_send_status: |
| 3315 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3316 | send_status: |
| 3317 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3318 | } |
| 3319 | |
Manikandan Mohan | a0bbb51 | 2019-08-15 11:39:26 -0700 | [diff] [blame] | 3320 | QDF_STATUS policy_mgr_get_chan_by_session_id(struct wlan_objmgr_psoc *psoc, |
| 3321 | uint8_t session_id, |
| 3322 | uint32_t *ch_freq) |
Nitesh Shah | 3ab4384 | 2017-04-26 20:02:34 +0530 | [diff] [blame] | 3323 | { |
| 3324 | uint32_t i; |
| 3325 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3326 | |
| 3327 | pm_ctx = policy_mgr_get_context(psoc); |
| 3328 | if (!pm_ctx) { |
| 3329 | policy_mgr_err("Invalid Context"); |
| 3330 | return QDF_STATUS_E_FAILURE; |
| 3331 | } |
| 3332 | |
| 3333 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3334 | for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { |
| 3335 | if ((pm_conc_connection_list[i].vdev_id == session_id) && |
| 3336 | (pm_conc_connection_list[i].in_use)) { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3337 | *ch_freq = pm_conc_connection_list[i].freq; |
Nitesh Shah | 3ab4384 | 2017-04-26 20:02:34 +0530 | [diff] [blame] | 3338 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3339 | return QDF_STATUS_SUCCESS; |
| 3340 | } |
| 3341 | } |
| 3342 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3343 | |
| 3344 | return QDF_STATUS_E_FAILURE; |
| 3345 | } |
| 3346 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3347 | QDF_STATUS policy_mgr_get_mac_id_by_session_id(struct wlan_objmgr_psoc *psoc, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3348 | uint8_t session_id, |
| 3349 | uint8_t *mac_id) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3350 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3351 | uint32_t i; |
| 3352 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3353 | |
| 3354 | pm_ctx = policy_mgr_get_context(psoc); |
| 3355 | if (!pm_ctx) { |
| 3356 | policy_mgr_err("Invalid Context"); |
| 3357 | return QDF_STATUS_E_FAILURE; |
| 3358 | } |
| 3359 | |
| 3360 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3361 | for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { |
| 3362 | if ((pm_conc_connection_list[i].vdev_id == session_id) && |
| 3363 | (pm_conc_connection_list[i].in_use)) { |
| 3364 | *mac_id = pm_conc_connection_list[i].mac; |
| 3365 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3366 | return QDF_STATUS_SUCCESS; |
| 3367 | } |
| 3368 | } |
| 3369 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3370 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3371 | return QDF_STATUS_E_FAILURE; |
| 3372 | } |
| 3373 | |
| 3374 | QDF_STATUS policy_mgr_get_mcc_session_id_on_mac(struct wlan_objmgr_psoc *psoc, |
| 3375 | uint8_t mac_id, uint8_t session_id, |
| 3376 | uint8_t *mcc_session_id) |
| 3377 | { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3378 | uint32_t i, ch_freq; |
Nitesh Shah | 3ab4384 | 2017-04-26 20:02:34 +0530 | [diff] [blame] | 3379 | QDF_STATUS status; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3380 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3381 | |
| 3382 | pm_ctx = policy_mgr_get_context(psoc); |
| 3383 | if (!pm_ctx) { |
| 3384 | policy_mgr_err("Invalid Context"); |
| 3385 | return QDF_STATUS_E_FAILURE; |
| 3386 | } |
| 3387 | |
Manikandan Mohan | a0bbb51 | 2019-08-15 11:39:26 -0700 | [diff] [blame] | 3388 | status = policy_mgr_get_chan_by_session_id(psoc, session_id, &ch_freq); |
Nitesh Shah | 3ab4384 | 2017-04-26 20:02:34 +0530 | [diff] [blame] | 3389 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3390 | policy_mgr_err("Failed to get channel for session id:%d", |
| 3391 | session_id); |
| 3392 | return QDF_STATUS_E_FAILURE; |
| 3393 | } |
| 3394 | |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3395 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3396 | for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { |
| 3397 | if (pm_conc_connection_list[i].mac != mac_id) |
| 3398 | continue; |
| 3399 | if (pm_conc_connection_list[i].vdev_id == session_id) |
| 3400 | continue; |
| 3401 | /* Inter band or intra band MCC */ |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3402 | if (pm_conc_connection_list[i].freq != ch_freq && |
| 3403 | pm_conc_connection_list[i].in_use) { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3404 | *mcc_session_id = pm_conc_connection_list[i].vdev_id; |
| 3405 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3406 | return QDF_STATUS_SUCCESS; |
| 3407 | } |
| 3408 | } |
| 3409 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3410 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3411 | return QDF_STATUS_E_FAILURE; |
| 3412 | } |
| 3413 | |
Manikandan Mohan | a0bbb51 | 2019-08-15 11:39:26 -0700 | [diff] [blame] | 3414 | uint32_t policy_mgr_get_mcc_operating_channel(struct wlan_objmgr_psoc *psoc, |
| 3415 | uint8_t session_id) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3416 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3417 | uint8_t mac_id, mcc_session_id; |
| 3418 | QDF_STATUS status; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3419 | uint32_t ch_freq; |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3420 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3421 | |
| 3422 | pm_ctx = policy_mgr_get_context(psoc); |
| 3423 | if (!pm_ctx) { |
| 3424 | policy_mgr_err("Invalid Context"); |
| 3425 | return INVALID_CHANNEL_ID; |
| 3426 | } |
| 3427 | |
| 3428 | status = policy_mgr_get_mac_id_by_session_id(psoc, session_id, &mac_id); |
| 3429 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3430 | policy_mgr_err("failed to get MAC ID"); |
| 3431 | return INVALID_CHANNEL_ID; |
| 3432 | } |
| 3433 | |
| 3434 | status = policy_mgr_get_mcc_session_id_on_mac(psoc, mac_id, session_id, |
| 3435 | &mcc_session_id); |
| 3436 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3437 | policy_mgr_err("failed to get MCC session ID"); |
| 3438 | return INVALID_CHANNEL_ID; |
| 3439 | } |
| 3440 | |
Manikandan Mohan | a0bbb51 | 2019-08-15 11:39:26 -0700 | [diff] [blame] | 3441 | status = policy_mgr_get_chan_by_session_id(psoc, mcc_session_id, |
| 3442 | &ch_freq); |
Nitesh Shah | 3ab4384 | 2017-04-26 20:02:34 +0530 | [diff] [blame] | 3443 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3444 | policy_mgr_err("Failed to get channel for MCC session ID:%d", |
| 3445 | mcc_session_id); |
| 3446 | return INVALID_CHANNEL_ID; |
| 3447 | } |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3448 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3449 | return ch_freq; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3450 | } |
| 3451 | |
| 3452 | void policy_mgr_set_do_hw_mode_change_flag(struct wlan_objmgr_psoc *psoc, |
| 3453 | bool flag) |
| 3454 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3455 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3456 | |
| 3457 | pm_ctx = policy_mgr_get_context(psoc); |
| 3458 | if (!pm_ctx) { |
| 3459 | policy_mgr_err("Invalid Context"); |
| 3460 | return; |
| 3461 | } |
| 3462 | |
| 3463 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3464 | pm_ctx->do_hw_mode_change = flag; |
| 3465 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3466 | |
| 3467 | policy_mgr_debug("hw_mode_change_channel:%d", flag); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3468 | } |
| 3469 | |
| 3470 | bool policy_mgr_is_hw_mode_change_after_vdev_up(struct wlan_objmgr_psoc *psoc) |
| 3471 | { |
Tushnim Bhattacharyya | 482d82b | 2017-03-08 10:26:14 -0800 | [diff] [blame] | 3472 | bool flag; |
| 3473 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3474 | |
| 3475 | pm_ctx = policy_mgr_get_context(psoc); |
| 3476 | if (!pm_ctx) { |
| 3477 | policy_mgr_err("Invalid Context"); |
| 3478 | return INVALID_CHANNEL_ID; |
| 3479 | } |
| 3480 | |
| 3481 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3482 | flag = pm_ctx->do_hw_mode_change; |
| 3483 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3484 | |
| 3485 | return flag; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 3486 | } |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 3487 | |
Ajit Pal Singh | c0af3e8 | 2017-05-24 11:58:09 +0530 | [diff] [blame] | 3488 | bool policy_mgr_is_dnsc_set(struct wlan_objmgr_vdev *vdev) |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 3489 | { |
Ajit Pal Singh | c0af3e8 | 2017-05-24 11:58:09 +0530 | [diff] [blame] | 3490 | bool roffchan; |
| 3491 | |
| 3492 | if (!vdev) { |
| 3493 | policy_mgr_err("Invalid parameter"); |
| 3494 | return false; |
| 3495 | } |
| 3496 | |
Ajit Pal Singh | c0af3e8 | 2017-05-24 11:58:09 +0530 | [diff] [blame] | 3497 | roffchan = wlan_vdev_mlme_cap_get(vdev, WLAN_VDEV_C_RESTRICT_OFFCHAN); |
Ajit Pal Singh | c0af3e8 | 2017-05-24 11:58:09 +0530 | [diff] [blame] | 3498 | |
Amruta Kulkarni | 447a326 | 2020-02-05 14:57:04 -0800 | [diff] [blame] | 3499 | if (roffchan) |
| 3500 | policy_mgr_debug("Restrict offchannel is set"); |
Ajit Pal Singh | c0af3e8 | 2017-05-24 11:58:09 +0530 | [diff] [blame] | 3501 | |
| 3502 | return roffchan; |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 3503 | } |
| 3504 | |
Manikandan Mohan | a0bbb51 | 2019-08-15 11:39:26 -0700 | [diff] [blame] | 3505 | QDF_STATUS policy_mgr_is_chan_ok_for_dnbs(struct wlan_objmgr_psoc *psoc, |
| 3506 | uint32_t ch_freq, bool *ok) |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 3507 | { |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 3508 | uint32_t cc_count = 0, i; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3509 | uint32_t op_ch_freq_list[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 3510 | uint8_t vdev_id[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 3511 | struct wlan_objmgr_vdev *vdev; |
| 3512 | |
Wu Gao | 76b5ff5 | 2019-06-21 17:57:05 +0800 | [diff] [blame] | 3513 | if (!ok) { |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 3514 | policy_mgr_err("Invalid parameter"); |
| 3515 | return QDF_STATUS_E_INVAL; |
| 3516 | } |
| 3517 | |
Manikandan Mohan | 19f3609 | 2019-08-15 15:54:02 -0700 | [diff] [blame] | 3518 | cc_count = policy_mgr_get_mode_specific_conn_info( |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3519 | psoc, &op_ch_freq_list[cc_count], |
| 3520 | &vdev_id[cc_count], PM_SAP_MODE); |
Li Feng | dcf4f92 | 2019-08-07 18:28:07 +0800 | [diff] [blame] | 3521 | |
| 3522 | if (cc_count < MAX_NUMBER_OF_CONC_CONNECTIONS) |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3523 | cc_count = cc_count + |
Manikandan Mohan | 19f3609 | 2019-08-15 15:54:02 -0700 | [diff] [blame] | 3524 | policy_mgr_get_mode_specific_conn_info( |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3525 | psoc, &op_ch_freq_list[cc_count], |
| 3526 | &vdev_id[cc_count], PM_P2P_GO_MODE); |
Amruta Kulkarni | 447a326 | 2020-02-05 14:57:04 -0800 | [diff] [blame] | 3527 | |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 3528 | if (!cc_count) { |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 3529 | *ok = true; |
| 3530 | return QDF_STATUS_SUCCESS; |
| 3531 | } |
| 3532 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3533 | if (!ch_freq) { |
Wu Gao | 76b5ff5 | 2019-06-21 17:57:05 +0800 | [diff] [blame] | 3534 | policy_mgr_err("channel is 0, cc count %d", cc_count); |
| 3535 | return QDF_STATUS_E_INVAL; |
| 3536 | } |
| 3537 | |
Li Feng | dcf4f92 | 2019-08-07 18:28:07 +0800 | [diff] [blame] | 3538 | if (cc_count <= MAX_NUMBER_OF_CONC_CONNECTIONS) { |
| 3539 | for (i = 0; i < cc_count; i++) { |
| 3540 | vdev = wlan_objmgr_get_vdev_by_id_from_psoc( |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3541 | psoc, vdev_id[i], WLAN_POLICY_MGR_ID); |
Li Feng | dcf4f92 | 2019-08-07 18:28:07 +0800 | [diff] [blame] | 3542 | if (!vdev) { |
| 3543 | policy_mgr_err("vdev for vdev_id:%d is NULL", |
| 3544 | vdev_id[i]); |
| 3545 | return QDF_STATUS_E_INVAL; |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 3546 | } |
Li Feng | dcf4f92 | 2019-08-07 18:28:07 +0800 | [diff] [blame] | 3547 | |
| 3548 | /** |
| 3549 | * If channel passed is same as AP/GO operating |
| 3550 | * channel, return true. |
| 3551 | * |
| 3552 | * If channel is different from operating channel but |
| 3553 | * in same band, return false. |
| 3554 | * |
| 3555 | * If operating channel in different band |
| 3556 | * (DBS capable), return true. |
| 3557 | * |
| 3558 | * If operating channel in different band |
| 3559 | * (not DBS capable), return false. |
| 3560 | */ |
| 3561 | /* TODO: To be enhanced for SBS */ |
| 3562 | if (policy_mgr_is_dnsc_set(vdev)) { |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3563 | if (op_ch_freq_list[i] == ch_freq) { |
Li Feng | dcf4f92 | 2019-08-07 18:28:07 +0800 | [diff] [blame] | 3564 | *ok = true; |
| 3565 | wlan_objmgr_vdev_release_ref( |
| 3566 | vdev, |
| 3567 | WLAN_POLICY_MGR_ID); |
| 3568 | break; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3569 | } else if (WLAN_REG_IS_SAME_BAND_FREQS( |
| 3570 | op_ch_freq_list[i], ch_freq)) { |
Li Feng | dcf4f92 | 2019-08-07 18:28:07 +0800 | [diff] [blame] | 3571 | *ok = false; |
| 3572 | wlan_objmgr_vdev_release_ref( |
| 3573 | vdev, |
| 3574 | WLAN_POLICY_MGR_ID); |
| 3575 | break; |
| 3576 | } else if (policy_mgr_is_hw_dbs_capable(psoc)) { |
| 3577 | *ok = true; |
| 3578 | wlan_objmgr_vdev_release_ref( |
| 3579 | vdev, |
| 3580 | WLAN_POLICY_MGR_ID); |
| 3581 | break; |
| 3582 | } else { |
| 3583 | *ok = false; |
| 3584 | wlan_objmgr_vdev_release_ref( |
| 3585 | vdev, |
| 3586 | WLAN_POLICY_MGR_ID); |
| 3587 | break; |
| 3588 | } |
| 3589 | } else { |
| 3590 | *ok = true; |
| 3591 | } |
| 3592 | wlan_objmgr_vdev_release_ref(vdev, WLAN_POLICY_MGR_ID); |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 3593 | } |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 3594 | } |
Liangwei Dong | 76659b0 | 2017-12-28 00:34:42 -0500 | [diff] [blame] | 3595 | |
Ajit Pal Singh | c65575e | 2017-04-17 16:49:01 +0530 | [diff] [blame] | 3596 | return QDF_STATUS_SUCCESS; |
| 3597 | } |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3598 | |
Vikrampal | 7e4d4c2 | 2017-05-17 09:36:46 +0530 | [diff] [blame] | 3599 | uint32_t policy_mgr_get_hw_dbs_nss(struct wlan_objmgr_psoc *psoc, |
| 3600 | struct dbs_nss *nss_dbs) |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3601 | { |
| 3602 | int i, param; |
Liangwei Dong | 897b439 | 2019-11-05 19:16:02 +0800 | [diff] [blame] | 3603 | uint32_t dbs, sbs, tx_chain0, rx_chain0, tx_chain1, rx_chain1; |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3604 | uint32_t min_mac0_rf_chains, min_mac1_rf_chains; |
Vikrampal | 7e4d4c2 | 2017-05-17 09:36:46 +0530 | [diff] [blame] | 3605 | uint32_t max_rf_chains, final_max_rf_chains = HW_MODE_SS_0x0; |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3606 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3607 | |
| 3608 | pm_ctx = policy_mgr_get_context(psoc); |
Varun Reddy Yeturu | e23b6bc | 2018-01-08 13:18:41 -0800 | [diff] [blame] | 3609 | if (!pm_ctx) { |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3610 | policy_mgr_err("Invalid Context"); |
Varun Reddy Yeturu | e23b6bc | 2018-01-08 13:18:41 -0800 | [diff] [blame] | 3611 | return final_max_rf_chains; |
| 3612 | } |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3613 | |
Liangwei Dong | 897b439 | 2019-11-05 19:16:02 +0800 | [diff] [blame] | 3614 | nss_dbs->single_mac0_band_cap = 0; |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3615 | for (i = 0; i < pm_ctx->num_dbs_hw_modes; i++) { |
| 3616 | param = pm_ctx->hw_mode.hw_mode_list[i]; |
| 3617 | dbs = POLICY_MGR_HW_MODE_DBS_MODE_GET(param); |
Liangwei Dong | 897b439 | 2019-11-05 19:16:02 +0800 | [diff] [blame] | 3618 | sbs = POLICY_MGR_HW_MODE_SBS_MODE_GET(param); |
| 3619 | |
| 3620 | if (!dbs && !sbs && !nss_dbs->single_mac0_band_cap) |
| 3621 | nss_dbs->single_mac0_band_cap = |
| 3622 | POLICY_MGR_HW_MODE_MAC0_BAND_GET(param); |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3623 | |
| 3624 | if (dbs) { |
| 3625 | tx_chain0 |
| 3626 | = POLICY_MGR_HW_MODE_MAC0_TX_STREAMS_GET(param); |
| 3627 | rx_chain0 |
| 3628 | = POLICY_MGR_HW_MODE_MAC0_RX_STREAMS_GET(param); |
| 3629 | |
| 3630 | tx_chain1 |
| 3631 | = POLICY_MGR_HW_MODE_MAC1_TX_STREAMS_GET(param); |
| 3632 | rx_chain1 |
| 3633 | = POLICY_MGR_HW_MODE_MAC1_RX_STREAMS_GET(param); |
| 3634 | |
| 3635 | min_mac0_rf_chains = QDF_MIN(tx_chain0, rx_chain0); |
| 3636 | min_mac1_rf_chains = QDF_MIN(tx_chain1, rx_chain1); |
| 3637 | |
Vikrampal | 7e4d4c2 | 2017-05-17 09:36:46 +0530 | [diff] [blame] | 3638 | max_rf_chains |
| 3639 | = QDF_MAX(min_mac0_rf_chains, min_mac1_rf_chains); |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3640 | |
Vikrampal | 7e4d4c2 | 2017-05-17 09:36:46 +0530 | [diff] [blame] | 3641 | if (final_max_rf_chains < max_rf_chains) { |
| 3642 | final_max_rf_chains |
| 3643 | = (max_rf_chains == 2) |
| 3644 | ? HW_MODE_SS_2x2 : HW_MODE_SS_1x1; |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3645 | |
Vikrampal | 7e4d4c2 | 2017-05-17 09:36:46 +0530 | [diff] [blame] | 3646 | nss_dbs->mac0_ss |
| 3647 | = (min_mac0_rf_chains == 2) |
| 3648 | ? HW_MODE_SS_2x2 : HW_MODE_SS_1x1; |
| 3649 | |
| 3650 | nss_dbs->mac1_ss |
| 3651 | = (min_mac1_rf_chains == 2) |
| 3652 | ? HW_MODE_SS_2x2 : HW_MODE_SS_1x1; |
| 3653 | } |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3654 | } else { |
| 3655 | continue; |
| 3656 | } |
| 3657 | } |
| 3658 | |
Vikrampal | 7e4d4c2 | 2017-05-17 09:36:46 +0530 | [diff] [blame] | 3659 | return final_max_rf_chains; |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 3660 | } |
Tushnim Bhattacharyya | ecc6e10 | 2017-05-26 18:25:56 -0700 | [diff] [blame] | 3661 | |
| 3662 | bool policy_mgr_is_scan_simultaneous_capable(struct wlan_objmgr_psoc *psoc) |
| 3663 | { |
Bala Venkatesh | 9391de3 | 2019-01-25 12:57:20 +0530 | [diff] [blame] | 3664 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 3665 | |
| 3666 | policy_mgr_get_dual_mac_feature(psoc, &dual_mac_feature); |
| 3667 | if ((dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) || |
| 3668 | (dual_mac_feature == ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN) || |
| 3669 | (dual_mac_feature == |
| 3670 | ENABLE_DBS_CXN_AND_DISABLE_SIMULTANEOUS_SCAN) || |
Yeshwanth Sriram Guntuka | 2a4e082 | 2018-10-29 19:45:57 +0530 | [diff] [blame] | 3671 | !policy_mgr_is_hw_dbs_capable(psoc)) |
Bala Venkatesh | 119ed6b | 2018-03-17 18:48:31 +0530 | [diff] [blame] | 3672 | return false; |
Tushnim Bhattacharyya | ecc6e10 | 2017-05-26 18:25:56 -0700 | [diff] [blame] | 3673 | |
Bala Venkatesh | 119ed6b | 2018-03-17 18:48:31 +0530 | [diff] [blame] | 3674 | return true; |
Tushnim Bhattacharyya | ecc6e10 | 2017-05-26 18:25:56 -0700 | [diff] [blame] | 3675 | } |
| 3676 | |
Ganesh Kondabattini | 2a8c7b0 | 2017-07-10 17:34:36 +0530 | [diff] [blame] | 3677 | void policy_mgr_set_cur_conc_system_pref(struct wlan_objmgr_psoc *psoc, |
| 3678 | uint8_t conc_system_pref) |
| 3679 | { |
| 3680 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3681 | |
| 3682 | pm_ctx = policy_mgr_get_context(psoc); |
| 3683 | |
| 3684 | if (!pm_ctx) { |
| 3685 | policy_mgr_err("Invalid Context"); |
| 3686 | return; |
| 3687 | } |
| 3688 | |
| 3689 | policy_mgr_debug("conc_system_pref %hu", conc_system_pref); |
| 3690 | pm_ctx->cur_conc_system_pref = conc_system_pref; |
| 3691 | } |
| 3692 | |
| 3693 | uint8_t policy_mgr_get_cur_conc_system_pref(struct wlan_objmgr_psoc *psoc) |
| 3694 | { |
| 3695 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3696 | |
| 3697 | pm_ctx = policy_mgr_get_context(psoc); |
| 3698 | if (!pm_ctx) { |
| 3699 | policy_mgr_err("Invalid Context"); |
| 3700 | return PM_THROUGHPUT; |
| 3701 | } |
| 3702 | |
| 3703 | policy_mgr_debug("conc_system_pref %hu", pm_ctx->cur_conc_system_pref); |
| 3704 | return pm_ctx->cur_conc_system_pref; |
| 3705 | } |
| 3706 | |
Tushnim Bhattacharyya | ecc6e10 | 2017-05-26 18:25:56 -0700 | [diff] [blame] | 3707 | QDF_STATUS policy_mgr_get_updated_scan_and_fw_mode_config( |
| 3708 | struct wlan_objmgr_psoc *psoc, uint32_t *scan_config, |
Yeshwanth Sriram Guntuka | 257a5d7 | 2018-02-12 12:24:06 +0530 | [diff] [blame] | 3709 | uint32_t *fw_mode_config, uint32_t dual_mac_disable_ini, |
| 3710 | uint32_t channel_select_logic_conc) |
Tushnim Bhattacharyya | ecc6e10 | 2017-05-26 18:25:56 -0700 | [diff] [blame] | 3711 | { |
| 3712 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3713 | |
| 3714 | pm_ctx = policy_mgr_get_context(psoc); |
| 3715 | if (!pm_ctx) { |
| 3716 | policy_mgr_err("Invalid Context"); |
| 3717 | return QDF_STATUS_E_FAILURE; |
| 3718 | } |
| 3719 | |
| 3720 | *scan_config = pm_ctx->dual_mac_cfg.cur_scan_config; |
| 3721 | *fw_mode_config = pm_ctx->dual_mac_cfg.cur_fw_mode_config; |
| 3722 | switch (dual_mac_disable_ini) { |
| 3723 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN_WITH_ASYNC_SCAN_OFF: |
| 3724 | policy_mgr_debug("dual_mac_disable_ini:%d async/dbs off", |
| 3725 | dual_mac_disable_ini); |
| 3726 | WMI_DBS_CONC_SCAN_CFG_ASYNC_DBS_SCAN_SET(*scan_config, 0); |
| 3727 | WMI_DBS_FW_MODE_CFG_DBS_FOR_CXN_SET(*fw_mode_config, 0); |
| 3728 | break; |
| 3729 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN: |
| 3730 | policy_mgr_debug("dual_mac_disable_ini:%d dbs_cxn off", |
| 3731 | dual_mac_disable_ini); |
| 3732 | WMI_DBS_FW_MODE_CFG_DBS_FOR_CXN_SET(*fw_mode_config, 0); |
| 3733 | break; |
| 3734 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 3735 | policy_mgr_debug("dual_mac_disable_ini:%d async off", |
| 3736 | dual_mac_disable_ini); |
| 3737 | WMI_DBS_CONC_SCAN_CFG_ASYNC_DBS_SCAN_SET(*scan_config, 0); |
| 3738 | break; |
Bala Venkatesh | 119ed6b | 2018-03-17 18:48:31 +0530 | [diff] [blame] | 3739 | case ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN: |
| 3740 | policy_mgr_debug("%s: dual_mac_disable_ini:%d ", __func__, |
| 3741 | dual_mac_disable_ini); |
| 3742 | WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_SET(*scan_config, 0); |
| 3743 | break; |
Tushnim Bhattacharyya | ecc6e10 | 2017-05-26 18:25:56 -0700 | [diff] [blame] | 3744 | default: |
| 3745 | break; |
| 3746 | } |
Yeshwanth Sriram Guntuka | 257a5d7 | 2018-02-12 12:24:06 +0530 | [diff] [blame] | 3747 | |
| 3748 | WMI_DBS_FW_MODE_CFG_DBS_FOR_STA_PLUS_STA_SET(*fw_mode_config, |
| 3749 | PM_CHANNEL_SELECT_LOGIC_STA_STA_GET(channel_select_logic_conc)); |
| 3750 | WMI_DBS_FW_MODE_CFG_DBS_FOR_STA_PLUS_P2P_SET(*fw_mode_config, |
| 3751 | PM_CHANNEL_SELECT_LOGIC_STA_P2P_GET(channel_select_logic_conc)); |
| 3752 | |
Tushnim Bhattacharyya | ecc6e10 | 2017-05-26 18:25:56 -0700 | [diff] [blame] | 3753 | policy_mgr_debug("*scan_config:%x ", *scan_config); |
| 3754 | policy_mgr_debug("*fw_mode_config:%x ", *fw_mode_config); |
| 3755 | |
| 3756 | return QDF_STATUS_SUCCESS; |
| 3757 | } |
Tushnim Bhattacharyya | a2c3b62 | 2017-08-03 16:58:38 -0700 | [diff] [blame] | 3758 | |
| 3759 | bool policy_mgr_is_force_scc(struct wlan_objmgr_psoc *psoc) |
| 3760 | { |
| 3761 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3762 | |
| 3763 | pm_ctx = policy_mgr_get_context(psoc); |
| 3764 | if (!pm_ctx) { |
| 3765 | policy_mgr_err("Invalid Context"); |
| 3766 | return 0; |
| 3767 | } |
| 3768 | |
Krunal Soni | d36b207 | 2018-09-26 17:02:14 -0700 | [diff] [blame] | 3769 | return ((pm_ctx->cfg.mcc_to_scc_switch == |
Tushnim Bhattacharyya | a2c3b62 | 2017-08-03 16:58:38 -0700 | [diff] [blame] | 3770 | QDF_MCC_TO_SCC_SWITCH_FORCE_WITHOUT_DISCONNECTION) || |
Krunal Soni | d36b207 | 2018-09-26 17:02:14 -0700 | [diff] [blame] | 3771 | (pm_ctx->cfg.mcc_to_scc_switch == |
Rachit Kankane | 758528a | 2017-09-15 16:36:33 +0530 | [diff] [blame] | 3772 | QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL) || |
Krunal Soni | d36b207 | 2018-09-26 17:02:14 -0700 | [diff] [blame] | 3773 | (pm_ctx->cfg.mcc_to_scc_switch == |
Bala Venkatesh | 68bdbfa | 2018-06-14 12:28:10 +0530 | [diff] [blame] | 3774 | QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION) || |
Krunal Soni | d36b207 | 2018-09-26 17:02:14 -0700 | [diff] [blame] | 3775 | (pm_ctx->cfg.mcc_to_scc_switch == |
Bala Venkatesh | 68bdbfa | 2018-06-14 12:28:10 +0530 | [diff] [blame] | 3776 | QDF_MCC_TO_SCC_WITH_PREFERRED_BAND)); |
Tushnim Bhattacharyya | a2c3b62 | 2017-08-03 16:58:38 -0700 | [diff] [blame] | 3777 | } |
Ganesh Kondabattini | 8a611c6 | 2017-11-21 15:01:31 +0530 | [diff] [blame] | 3778 | |
| 3779 | bool policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan( |
| 3780 | struct wlan_objmgr_psoc *psoc) |
| 3781 | { |
| 3782 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Krunal Soni | 1680e41 | 2018-12-07 19:42:06 +0800 | [diff] [blame] | 3783 | uint8_t sta_sap_scc_on_dfs_chnl = 0; |
Ganesh Kondabattini | 8a611c6 | 2017-11-21 15:01:31 +0530 | [diff] [blame] | 3784 | bool status = false; |
| 3785 | |
| 3786 | pm_ctx = policy_mgr_get_context(psoc); |
| 3787 | if (!pm_ctx) { |
| 3788 | policy_mgr_err("Invalid Context"); |
| 3789 | return status; |
| 3790 | } |
| 3791 | |
Krunal Soni | 1680e41 | 2018-12-07 19:42:06 +0800 | [diff] [blame] | 3792 | policy_mgr_get_sta_sap_scc_on_dfs_chnl(psoc, |
| 3793 | &sta_sap_scc_on_dfs_chnl); |
| 3794 | if (policy_mgr_is_force_scc(psoc) && sta_sap_scc_on_dfs_chnl) |
Ganesh Kondabattini | 8a611c6 | 2017-11-21 15:01:31 +0530 | [diff] [blame] | 3795 | status = true; |
| 3796 | |
| 3797 | return status; |
| 3798 | } |
Yeshwanth Sriram Guntuka | 067cd3e | 2017-12-14 17:56:04 +0530 | [diff] [blame] | 3799 | |
| 3800 | bool policy_mgr_is_sta_connected_2g(struct wlan_objmgr_psoc *psoc) |
| 3801 | { |
| 3802 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3803 | uint32_t conn_index; |
| 3804 | bool ret = false; |
| 3805 | |
| 3806 | pm_ctx = policy_mgr_get_context(psoc); |
| 3807 | if (!pm_ctx) { |
| 3808 | policy_mgr_err("Invalid Context"); |
| 3809 | return ret; |
| 3810 | } |
| 3811 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3812 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 3813 | conn_index++) { |
| 3814 | if (pm_conc_connection_list[conn_index].mode == PM_STA_MODE && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3815 | pm_conc_connection_list[conn_index].freq <= |
| 3816 | WLAN_REG_MAX_24GHZ_CHAN_FREQ && |
Yeshwanth Sriram Guntuka | 067cd3e | 2017-12-14 17:56:04 +0530 | [diff] [blame] | 3817 | pm_conc_connection_list[conn_index].in_use) |
| 3818 | ret = true; |
| 3819 | } |
| 3820 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3821 | |
| 3822 | return ret; |
| 3823 | } |
Tushnim Bhattacharyya | c7b9769 | 2018-02-21 13:37:00 -0800 | [diff] [blame] | 3824 | |
Yeshwanth Sriram Guntuka | 6a3be16 | 2018-02-23 12:14:46 +0530 | [diff] [blame] | 3825 | uint32_t policy_mgr_get_connection_info(struct wlan_objmgr_psoc *psoc, |
| 3826 | struct connection_info *info) |
| 3827 | { |
| 3828 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3829 | uint32_t conn_index, count = 0; |
| 3830 | |
| 3831 | pm_ctx = policy_mgr_get_context(psoc); |
| 3832 | if (!pm_ctx) { |
| 3833 | policy_mgr_err("Invalid Context"); |
| 3834 | return count; |
| 3835 | } |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 3836 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
Yeshwanth Sriram Guntuka | 6a3be16 | 2018-02-23 12:14:46 +0530 | [diff] [blame] | 3837 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 3838 | conn_index++) { |
| 3839 | if (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { |
| 3840 | info[count].vdev_id = |
| 3841 | pm_conc_connection_list[conn_index].vdev_id; |
| 3842 | info[count].mac_id = |
| 3843 | pm_conc_connection_list[conn_index].mac; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3844 | info[count].channel = wlan_reg_freq_to_chan( |
| 3845 | pm_ctx->pdev, |
| 3846 | pm_conc_connection_list[conn_index].freq); |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 3847 | info[count].ch_freq = |
| 3848 | pm_conc_connection_list[conn_index].freq; |
Yeshwanth Sriram Guntuka | 6a3be16 | 2018-02-23 12:14:46 +0530 | [diff] [blame] | 3849 | count++; |
| 3850 | } |
| 3851 | } |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 3852 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
Yeshwanth Sriram Guntuka | 6a3be16 | 2018-02-23 12:14:46 +0530 | [diff] [blame] | 3853 | |
| 3854 | return count; |
| 3855 | } |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3856 | |
| 3857 | bool policy_mgr_allow_sap_go_concurrency(struct wlan_objmgr_psoc *psoc, |
| 3858 | enum policy_mgr_con_mode mode, |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3859 | uint32_t ch_freq, |
Jianmin Zhu | e1ebfd0 | 2018-08-21 19:20:28 +0800 | [diff] [blame] | 3860 | uint32_t vdev_id) |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3861 | { |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3862 | enum policy_mgr_con_mode con_mode; |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3863 | int id; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3864 | uint32_t vdev, con_freq; |
Jianmin Zhu | e1ebfd0 | 2018-08-21 19:20:28 +0800 | [diff] [blame] | 3865 | bool dbs; |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3866 | |
Jianmin Zhu | e1ebfd0 | 2018-08-21 19:20:28 +0800 | [diff] [blame] | 3867 | if (mode != PM_SAP_MODE && mode != PM_P2P_GO_MODE) |
| 3868 | return true; |
| 3869 | if (policy_mgr_dual_beacon_on_single_mac_mcc_capable(psoc)) |
| 3870 | return true; |
| 3871 | dbs = policy_mgr_is_hw_dbs_capable(psoc); |
| 3872 | for (id = 0; id < MAX_NUMBER_OF_CONC_CONNECTIONS; id++) { |
| 3873 | if (!pm_conc_connection_list[id].in_use) |
| 3874 | continue; |
| 3875 | vdev = pm_conc_connection_list[id].vdev_id; |
| 3876 | if (vdev_id == vdev) |
| 3877 | continue; |
| 3878 | con_mode = pm_conc_connection_list[id].mode; |
| 3879 | if (con_mode != PM_SAP_MODE && con_mode != PM_P2P_GO_MODE) |
| 3880 | continue; |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3881 | con_freq = pm_conc_connection_list[id].freq; |
Jianmin Zhu | e1ebfd0 | 2018-08-21 19:20:28 +0800 | [diff] [blame] | 3882 | if (policy_mgr_dual_beacon_on_single_mac_scc_capable(psoc) && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3883 | (ch_freq == con_freq)) { |
Jianmin Zhu | e1ebfd0 | 2018-08-21 19:20:28 +0800 | [diff] [blame] | 3884 | policy_mgr_debug("SCC enabled, 2 AP on same channel, allow 2nd AP"); |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3885 | return true; |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3886 | } |
Jianmin Zhu | e1ebfd0 | 2018-08-21 19:20:28 +0800 | [diff] [blame] | 3887 | if (!dbs) { |
| 3888 | policy_mgr_debug("DBS unsupported, mcc and scc unsupported too, don't allow 2nd AP"); |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3889 | return false; |
| 3890 | } |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 3891 | if (WLAN_REG_IS_SAME_BAND_FREQS(ch_freq, con_freq)) { |
Jianmin Zhu | e1ebfd0 | 2018-08-21 19:20:28 +0800 | [diff] [blame] | 3892 | policy_mgr_debug("DBS supported, 2 SAP on same band, reject 2nd AP"); |
| 3893 | return false; |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3894 | } |
| 3895 | } |
| 3896 | |
| 3897 | /* Don't block the second interface */ |
| 3898 | return true; |
| 3899 | } |
| 3900 | |
| 3901 | bool policy_mgr_dual_beacon_on_single_mac_scc_capable( |
| 3902 | struct wlan_objmgr_psoc *psoc) |
| 3903 | { |
Tushnim Bhattacharyya | 5dd541e | 2018-08-30 10:20:31 -0700 | [diff] [blame] | 3904 | struct wmi_unified *wmi_handle; |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3905 | |
Tushnim Bhattacharyya | 5dd541e | 2018-08-30 10:20:31 -0700 | [diff] [blame] | 3906 | wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3907 | if (!wmi_handle) { |
| 3908 | policy_mgr_debug("Invalid WMI handle"); |
| 3909 | return false; |
| 3910 | } |
| 3911 | |
| 3912 | if (wmi_service_enabled( |
| 3913 | wmi_handle, |
| 3914 | wmi_service_dual_beacon_on_single_mac_scc_support)) { |
gaurank kathpalia | 59d68af | 2018-08-02 21:23:58 +0530 | [diff] [blame] | 3915 | policy_mgr_debug("Dual beaconing on same channel on single MAC supported"); |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3916 | return true; |
| 3917 | } |
gaurank kathpalia | 59d68af | 2018-08-02 21:23:58 +0530 | [diff] [blame] | 3918 | policy_mgr_debug("Dual beaconing on same channel on single MAC is not supported"); |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3919 | return false; |
| 3920 | } |
| 3921 | |
| 3922 | bool policy_mgr_dual_beacon_on_single_mac_mcc_capable( |
| 3923 | struct wlan_objmgr_psoc *psoc) |
| 3924 | { |
Tushnim Bhattacharyya | 5dd541e | 2018-08-30 10:20:31 -0700 | [diff] [blame] | 3925 | struct wmi_unified *wmi_handle; |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3926 | |
Tushnim Bhattacharyya | 5dd541e | 2018-08-30 10:20:31 -0700 | [diff] [blame] | 3927 | wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3928 | if (!wmi_handle) { |
| 3929 | policy_mgr_debug("Invalid WMI handle"); |
| 3930 | return false; |
| 3931 | } |
| 3932 | |
| 3933 | if (wmi_service_enabled( |
| 3934 | wmi_handle, |
| 3935 | wmi_service_dual_beacon_on_single_mac_mcc_support)) { |
gaurank kathpalia | 59d68af | 2018-08-02 21:23:58 +0530 | [diff] [blame] | 3936 | policy_mgr_debug("Dual beaconing on different channel on single MAC supported"); |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3937 | return true; |
| 3938 | } |
gaurank kathpalia | 59d68af | 2018-08-02 21:23:58 +0530 | [diff] [blame] | 3939 | policy_mgr_debug("Dual beaconing on different channel on single MAC is not supported"); |
Zhu Jianmin | 7f8d1df | 2018-04-19 17:55:30 +0800 | [diff] [blame] | 3940 | return false; |
| 3941 | } |
Zhu Jianmin | 5ac66ef | 2018-06-11 19:03:39 +0800 | [diff] [blame] | 3942 | |
| 3943 | bool policy_mgr_sta_sap_scc_on_lte_coex_chan( |
| 3944 | struct wlan_objmgr_psoc *psoc) |
| 3945 | { |
| 3946 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Krunal Soni | 1680e41 | 2018-12-07 19:42:06 +0800 | [diff] [blame] | 3947 | uint8_t scc_lte_coex = 0; |
Zhu Jianmin | 5ac66ef | 2018-06-11 19:03:39 +0800 | [diff] [blame] | 3948 | |
| 3949 | pm_ctx = policy_mgr_get_context(psoc); |
| 3950 | if (!pm_ctx) { |
| 3951 | policy_mgr_err("Invalid Context"); |
| 3952 | return false; |
| 3953 | } |
Krunal Soni | 1680e41 | 2018-12-07 19:42:06 +0800 | [diff] [blame] | 3954 | policy_mgr_get_sta_sap_scc_lte_coex_chnl(psoc, &scc_lte_coex); |
| 3955 | |
| 3956 | return scc_lte_coex; |
Zhu Jianmin | 5ac66ef | 2018-06-11 19:03:39 +0800 | [diff] [blame] | 3957 | } |
Bala Venkatesh | 85b42f4 | 2018-06-08 12:38:35 +0530 | [diff] [blame] | 3958 | |
Liangwei Dong | 0527617 | 2019-12-27 10:31:46 +0800 | [diff] [blame] | 3959 | #if defined(CONFIG_BAND_6GHZ) && defined(WLAN_FEATURE_11AX) |
| 3960 | void policy_mgr_init_ap_6ghz_capable(struct wlan_objmgr_psoc *psoc, |
| 3961 | uint8_t vdev_id, |
| 3962 | enum conn_6ghz_flag ap_6ghz_capable) |
| 3963 | { |
| 3964 | struct policy_mgr_conc_connection_info *conn_info; |
| 3965 | uint32_t conn_index; |
| 3966 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3967 | enum conn_6ghz_flag conn_6ghz_flag = 0; |
| 3968 | |
| 3969 | pm_ctx = policy_mgr_get_context(psoc); |
| 3970 | if (!pm_ctx) { |
| 3971 | policy_mgr_err("Invalid Context"); |
| 3972 | return; |
| 3973 | } |
| 3974 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 3975 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 3976 | conn_index++) { |
| 3977 | conn_info = &pm_conc_connection_list[conn_index]; |
| 3978 | if (conn_info->in_use && PM_SAP_MODE == conn_info->mode && |
| 3979 | vdev_id == conn_info->vdev_id) { |
| 3980 | conn_info->conn_6ghz_flag = ap_6ghz_capable; |
| 3981 | conn_info->conn_6ghz_flag |= CONN_6GHZ_FLAG_VALID; |
| 3982 | conn_6ghz_flag = conn_info->conn_6ghz_flag; |
| 3983 | break; |
| 3984 | } |
| 3985 | } |
| 3986 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 3987 | policy_mgr_debug("vdev %d init conn_6ghz_flag %x new %x", |
| 3988 | vdev_id, ap_6ghz_capable, conn_6ghz_flag); |
| 3989 | } |
| 3990 | |
| 3991 | void policy_mgr_set_ap_6ghz_capable(struct wlan_objmgr_psoc *psoc, |
| 3992 | uint8_t vdev_id, |
| 3993 | bool set, |
| 3994 | enum conn_6ghz_flag ap_6ghz_capable) |
| 3995 | { |
| 3996 | struct policy_mgr_conc_connection_info *conn_info; |
| 3997 | uint32_t conn_index; |
| 3998 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 3999 | enum conn_6ghz_flag conn_6ghz_flag = 0; |
| 4000 | |
| 4001 | pm_ctx = policy_mgr_get_context(psoc); |
| 4002 | if (!pm_ctx) { |
| 4003 | policy_mgr_err("Invalid Context"); |
| 4004 | return; |
| 4005 | } |
| 4006 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 4007 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 4008 | conn_index++) { |
| 4009 | conn_info = &pm_conc_connection_list[conn_index]; |
| 4010 | if (conn_info->in_use && PM_SAP_MODE == conn_info->mode && |
| 4011 | vdev_id == conn_info->vdev_id) { |
| 4012 | if (set) |
| 4013 | conn_info->conn_6ghz_flag |= ap_6ghz_capable; |
| 4014 | else |
| 4015 | conn_info->conn_6ghz_flag &= ~ap_6ghz_capable; |
| 4016 | conn_info->conn_6ghz_flag |= CONN_6GHZ_FLAG_VALID; |
| 4017 | conn_6ghz_flag = conn_info->conn_6ghz_flag; |
| 4018 | break; |
| 4019 | } |
| 4020 | } |
| 4021 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 4022 | policy_mgr_debug("vdev %d %s conn_6ghz_flag %x new %x", |
| 4023 | vdev_id, set ? "set" : "clr", |
| 4024 | ap_6ghz_capable, conn_6ghz_flag); |
| 4025 | } |
| 4026 | |
| 4027 | bool policy_mgr_get_ap_6ghz_capable(struct wlan_objmgr_psoc *psoc, |
| 4028 | uint8_t vdev_id, |
| 4029 | uint32_t *conn_flag) |
| 4030 | { |
| 4031 | struct policy_mgr_conc_connection_info *conn_info; |
| 4032 | uint32_t conn_index; |
| 4033 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 4034 | enum conn_6ghz_flag conn_6ghz_flag = 0; |
| 4035 | bool is_6g_allowed = false; |
| 4036 | |
| 4037 | if (conn_flag) |
| 4038 | *conn_flag = 0; |
| 4039 | pm_ctx = policy_mgr_get_context(psoc); |
| 4040 | if (!pm_ctx) { |
| 4041 | policy_mgr_err("Invalid Context"); |
| 4042 | return false; |
| 4043 | } |
| 4044 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 4045 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 4046 | conn_index++) { |
| 4047 | conn_info = &pm_conc_connection_list[conn_index]; |
| 4048 | if (conn_info->in_use && PM_SAP_MODE == conn_info->mode && |
| 4049 | vdev_id == conn_info->vdev_id) { |
| 4050 | conn_6ghz_flag = conn_info->conn_6ghz_flag; |
| 4051 | break; |
| 4052 | } |
| 4053 | } |
| 4054 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 4055 | |
| 4056 | /* If the vdev connection is not active, policy mgr will query legacy |
| 4057 | * hdd to get sap acs and security information. |
| 4058 | * The assumption is no legacy client connected for non active |
| 4059 | * connection. |
| 4060 | */ |
| 4061 | if (!(conn_6ghz_flag & CONN_6GHZ_FLAG_VALID) && |
| 4062 | pm_ctx->hdd_cbacks.hdd_get_ap_6ghz_capable) |
| 4063 | conn_6ghz_flag = pm_ctx->hdd_cbacks.hdd_get_ap_6ghz_capable( |
| 4064 | psoc, vdev_id) | |
| 4065 | CONN_6GHZ_FLAG_NO_LEGACY_CLIENT; |
| 4066 | |
| 4067 | if ((conn_6ghz_flag & CONN_6GHZ_CAPABLIE) == CONN_6GHZ_CAPABLIE) |
| 4068 | is_6g_allowed = true; |
| 4069 | policy_mgr_debug("vdev %d conn_6ghz_flag %x 6ghz %s", vdev_id, |
| 4070 | conn_6ghz_flag, is_6g_allowed ? "allowed" : "deny"); |
| 4071 | if (conn_flag) |
| 4072 | *conn_flag = conn_6ghz_flag; |
| 4073 | |
| 4074 | return is_6g_allowed; |
| 4075 | } |
| 4076 | #endif |
| 4077 | |
Manikandan Mohan | a0bbb51 | 2019-08-15 11:39:26 -0700 | [diff] [blame] | 4078 | bool policy_mgr_is_valid_for_channel_switch(struct wlan_objmgr_psoc *psoc, |
| 4079 | uint32_t ch_freq) |
Bala Venkatesh | 85b42f4 | 2018-06-08 12:38:35 +0530 | [diff] [blame] | 4080 | { |
| 4081 | uint32_t sta_sap_scc_on_dfs_chan; |
| 4082 | uint32_t sap_count; |
| 4083 | enum channel_state state; |
| 4084 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 4085 | |
| 4086 | pm_ctx = policy_mgr_get_context(psoc); |
| 4087 | if (!pm_ctx) { |
| 4088 | policy_mgr_err("Invalid Context"); |
| 4089 | return false; |
| 4090 | } |
| 4091 | |
| 4092 | sta_sap_scc_on_dfs_chan = |
| 4093 | policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan(psoc); |
| 4094 | sap_count = policy_mgr_mode_specific_connection_count(psoc, |
| 4095 | PM_SAP_MODE, |
| 4096 | NULL); |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 4097 | state = wlan_reg_get_channel_state_for_freq(pm_ctx->pdev, ch_freq); |
Bala Venkatesh | 85b42f4 | 2018-06-08 12:38:35 +0530 | [diff] [blame] | 4098 | |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 4099 | policy_mgr_debug("sta_sap_scc_on_dfs_chan %u, sap_count %u, ch freq %u, state %u", |
| 4100 | sta_sap_scc_on_dfs_chan, sap_count, ch_freq, state); |
Bala Venkatesh | 85b42f4 | 2018-06-08 12:38:35 +0530 | [diff] [blame] | 4101 | |
| 4102 | if ((state == CHANNEL_STATE_ENABLE) || (sap_count == 0) || |
| 4103 | ((state == CHANNEL_STATE_DFS) && sta_sap_scc_on_dfs_chan)) { |
| 4104 | policy_mgr_debug("Valid channel for channel switch"); |
| 4105 | return true; |
| 4106 | } |
| 4107 | |
| 4108 | policy_mgr_debug("Invalid channel for channel switch"); |
| 4109 | return false; |
| 4110 | } |
Tushnim Bhattacharyya | 9b1636d | 2018-06-27 13:27:11 -0700 | [diff] [blame] | 4111 | |
Manikandan Mohan | a0bbb51 | 2019-08-15 11:39:26 -0700 | [diff] [blame] | 4112 | bool policy_mgr_is_sta_sap_scc(struct wlan_objmgr_psoc *psoc, |
| 4113 | uint32_t sap_freq) |
Tushnim Bhattacharyya | 9b1636d | 2018-06-27 13:27:11 -0700 | [diff] [blame] | 4114 | { |
| 4115 | uint32_t conn_index; |
| 4116 | bool is_scc = false; |
| 4117 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 4118 | |
| 4119 | pm_ctx = policy_mgr_get_context(psoc); |
| 4120 | if (!pm_ctx) { |
| 4121 | policy_mgr_err("Invalid Context"); |
| 4122 | return is_scc; |
| 4123 | } |
| 4124 | |
| 4125 | if (!policy_mgr_mode_specific_connection_count( |
| 4126 | psoc, PM_STA_MODE, NULL)) { |
| 4127 | policy_mgr_debug("There is no STA+SAP conc"); |
| 4128 | return is_scc; |
| 4129 | } |
| 4130 | |
| 4131 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 4132 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 4133 | conn_index++) { |
| 4134 | if (pm_conc_connection_list[conn_index].in_use && |
Manikandan Mohan | 932c11e | 2019-08-14 14:09:08 -0700 | [diff] [blame] | 4135 | (pm_conc_connection_list[conn_index].mode == |
| 4136 | PM_STA_MODE) && (sap_freq == |
| 4137 | pm_conc_connection_list[conn_index].freq)) { |
Tushnim Bhattacharyya | 9b1636d | 2018-06-27 13:27:11 -0700 | [diff] [blame] | 4138 | is_scc = true; |
| 4139 | break; |
| 4140 | } |
| 4141 | } |
| 4142 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 4143 | |
| 4144 | return is_scc; |
| 4145 | } |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 4146 | |
Liangwei Dong | d8ecec3 | 2019-05-09 04:47:47 -0400 | [diff] [blame] | 4147 | bool policy_mgr_go_scc_enforced(struct wlan_objmgr_psoc *psoc) |
| 4148 | { |
| 4149 | uint32_t mcc_to_scc_switch; |
| 4150 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 4151 | |
| 4152 | pm_ctx = policy_mgr_get_context(psoc); |
| 4153 | if (!pm_ctx) { |
| 4154 | policy_mgr_err("Invalid Context"); |
| 4155 | return false; |
| 4156 | } |
| 4157 | mcc_to_scc_switch = policy_mgr_get_mcc_to_scc_switch_mode(psoc); |
| 4158 | if (mcc_to_scc_switch == |
| 4159 | QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION) |
| 4160 | return true; |
| 4161 | |
| 4162 | if (pm_ctx->cfg.go_force_scc && policy_mgr_is_force_scc(psoc)) |
| 4163 | return true; |
| 4164 | |
| 4165 | return false; |
| 4166 | } |
| 4167 | |
Nachiket Kukade | cf94160 | 2018-12-12 14:32:35 +0530 | [diff] [blame] | 4168 | QDF_STATUS policy_mgr_update_nan_vdev_mac_info(struct wlan_objmgr_psoc *psoc, |
| 4169 | uint8_t nan_vdev_id, |
| 4170 | uint8_t mac_id) |
| 4171 | { |
| 4172 | struct policy_mgr_hw_mode_params hw_mode = {0}; |
| 4173 | struct policy_mgr_vdev_mac_map vdev_mac_map = {0}; |
| 4174 | QDF_STATUS status; |
| 4175 | |
| 4176 | vdev_mac_map.vdev_id = nan_vdev_id; |
| 4177 | vdev_mac_map.mac_id = mac_id; |
| 4178 | |
| 4179 | status = policy_mgr_get_current_hw_mode(psoc, &hw_mode); |
| 4180 | |
| 4181 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 4182 | policy_mgr_update_hw_mode_conn_info(psoc, 1, &vdev_mac_map, |
| 4183 | hw_mode); |
| 4184 | |
| 4185 | return status; |
| 4186 | } |
Amruta Kulkarni | 59f6350 | 2019-11-27 16:45:12 -0800 | [diff] [blame] | 4187 | |
| 4188 | bool policy_mgr_is_sap_go_on_2g(struct wlan_objmgr_psoc *psoc) |
| 4189 | { |
| 4190 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 4191 | uint32_t conn_index; |
| 4192 | bool ret = false; |
| 4193 | |
| 4194 | pm_ctx = policy_mgr_get_context(psoc); |
| 4195 | if (!pm_ctx) { |
| 4196 | policy_mgr_err("Invalid Context"); |
| 4197 | return ret; |
| 4198 | } |
| 4199 | |
| 4200 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 4201 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 4202 | conn_index++) { |
| 4203 | if ((pm_conc_connection_list[conn_index].mode == PM_SAP_MODE || |
| 4204 | pm_conc_connection_list[conn_index].mode == PM_P2P_GO_MODE) && |
| 4205 | pm_conc_connection_list[conn_index].freq <= |
| 4206 | WLAN_REG_MAX_24GHZ_CHAN_FREQ && |
| 4207 | pm_conc_connection_list[conn_index].in_use) |
| 4208 | ret = true; |
| 4209 | } |
| 4210 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 4211 | |
| 4212 | return ret; |
| 4213 | } |
| 4214 | |
bings | 00c391f | 2019-12-19 14:58:57 +0800 | [diff] [blame] | 4215 | bool policy_mgr_get_5g_scc_prefer( |
| 4216 | struct wlan_objmgr_psoc *psoc, enum policy_mgr_con_mode mode) |
| 4217 | { |
| 4218 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 4219 | |
| 4220 | pm_ctx = policy_mgr_get_context(psoc); |
| 4221 | if (!pm_ctx) { |
| 4222 | policy_mgr_err("Invalid Context"); |
| 4223 | return false; |
| 4224 | } |
| 4225 | |
| 4226 | return pm_ctx->cfg.prefer_5g_scc_to_dbs & (1 << mode); |
| 4227 | } |