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