Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1 | /* |
Varun Reddy Yeturu | e23b6bc | 2018-01-08 13:18:41 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 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_action.c |
| 21 | * |
| 22 | * WLAN Concurrenct Connection Management APIs |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | /* Include files */ |
| 27 | |
| 28 | #include "wlan_policy_mgr_api.h" |
| 29 | #include "wlan_policy_mgr_tables_no_dbs_i.h" |
| 30 | #include "wlan_policy_mgr_i.h" |
| 31 | #include "qdf_types.h" |
| 32 | #include "qdf_trace.h" |
| 33 | #include "wlan_objmgr_global_obj.h" |
| 34 | |
| 35 | enum policy_mgr_conc_next_action (*policy_mgr_get_current_pref_hw_mode_ptr) |
| 36 | (struct wlan_objmgr_psoc *psoc); |
| 37 | |
| 38 | void policy_mgr_hw_mode_transition_cb(uint32_t old_hw_mode_index, |
| 39 | uint32_t new_hw_mode_index, |
| 40 | uint32_t num_vdev_mac_entries, |
| 41 | struct policy_mgr_vdev_mac_map *vdev_mac_map, |
| 42 | struct wlan_objmgr_psoc *context) |
| 43 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 44 | QDF_STATUS status; |
| 45 | struct policy_mgr_hw_mode_params hw_mode; |
| 46 | uint32_t i; |
Yeshwanth Sriram Guntuka | 6a3be16 | 2018-02-23 12:14:46 +0530 | [diff] [blame] | 47 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 48 | |
| 49 | pm_ctx = policy_mgr_get_context(context); |
| 50 | if (!pm_ctx) { |
| 51 | policy_mgr_err("Invalid context"); |
| 52 | return; |
| 53 | } |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 54 | |
| 55 | if (!vdev_mac_map) { |
| 56 | policy_mgr_err("vdev_mac_map is NULL"); |
| 57 | return; |
| 58 | } |
| 59 | |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 60 | policy_mgr_debug("old_hw_mode_index=%d, new_hw_mode_index=%d", |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 61 | old_hw_mode_index, new_hw_mode_index); |
| 62 | |
| 63 | for (i = 0; i < num_vdev_mac_entries; i++) |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 64 | policy_mgr_debug("vdev_id:%d mac_id:%d", |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 65 | vdev_mac_map[i].vdev_id, |
| 66 | vdev_mac_map[i].mac_id); |
| 67 | |
| 68 | status = policy_mgr_get_hw_mode_from_idx(context, |
| 69 | new_hw_mode_index, &hw_mode); |
| 70 | if (status != QDF_STATUS_SUCCESS) { |
| 71 | policy_mgr_err("Get HW mode failed: %d", status); |
| 72 | return; |
| 73 | } |
| 74 | |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 75 | policy_mgr_debug("MAC0: TxSS:%d, RxSS:%d, Bw:%d", |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 76 | hw_mode.mac0_tx_ss, hw_mode.mac0_rx_ss, hw_mode.mac0_bw); |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 77 | policy_mgr_debug("MAC1: TxSS:%d, RxSS:%d, Bw:%d", |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 78 | hw_mode.mac1_tx_ss, hw_mode.mac1_rx_ss, hw_mode.mac1_bw); |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 79 | policy_mgr_debug("DBS:%d, Agile DFS:%d, SBS:%d", |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 80 | hw_mode.dbs_cap, hw_mode.agile_dfs_cap, hw_mode.sbs_cap); |
| 81 | |
| 82 | /* update pm_conc_connection_list */ |
| 83 | policy_mgr_update_hw_mode_conn_info(context, num_vdev_mac_entries, |
| 84 | vdev_mac_map, |
| 85 | hw_mode); |
| 86 | |
Yeshwanth Sriram Guntuka | 6a3be16 | 2018-02-23 12:14:46 +0530 | [diff] [blame] | 87 | if (pm_ctx->mode_change_cb) |
| 88 | pm_ctx->mode_change_cb(); |
| 89 | |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 90 | return; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | QDF_STATUS policy_mgr_pdev_set_hw_mode(struct wlan_objmgr_psoc *psoc, |
| 94 | uint32_t session_id, |
| 95 | enum hw_mode_ss_config mac0_ss, |
| 96 | enum hw_mode_bandwidth mac0_bw, |
| 97 | enum hw_mode_ss_config mac1_ss, |
| 98 | enum hw_mode_bandwidth mac1_bw, |
| 99 | enum hw_mode_dbs_capab dbs, |
| 100 | enum hw_mode_agile_dfs_capab dfs, |
| 101 | enum hw_mode_sbs_capab sbs, |
Tushnim Bhattacharyya | 9420656 | 2017-11-15 15:30:07 -0800 | [diff] [blame] | 102 | enum policy_mgr_conn_update_reason reason, |
| 103 | uint8_t next_action) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 104 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 105 | int8_t hw_mode_index; |
| 106 | struct policy_mgr_hw_mode msg; |
| 107 | QDF_STATUS status; |
| 108 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 109 | |
| 110 | pm_ctx = policy_mgr_get_context(psoc); |
| 111 | if (!pm_ctx) { |
| 112 | policy_mgr_err("Invalid context"); |
| 113 | return QDF_STATUS_E_FAILURE; |
| 114 | } |
| 115 | |
| 116 | /* |
| 117 | * if HW is not capable of doing 2x2 or ini config disabled 2x2, don't |
| 118 | * allow to request FW for 2x2 |
| 119 | */ |
Tushnim Bhattacharyya | 68f709d | 2017-03-23 18:00:04 -0700 | [diff] [blame] | 120 | if ((HW_MODE_SS_2x2 == mac0_ss) && (!pm_ctx->user_cfg.enable2x2)) { |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 121 | policy_mgr_debug("2x2 is not allowed downgrading to 1x1 for mac0"); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 122 | mac0_ss = HW_MODE_SS_1x1; |
| 123 | } |
Tushnim Bhattacharyya | 68f709d | 2017-03-23 18:00:04 -0700 | [diff] [blame] | 124 | if ((HW_MODE_SS_2x2 == mac1_ss) && (!pm_ctx->user_cfg.enable2x2)) { |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 125 | policy_mgr_debug("2x2 is not allowed downgrading to 1x1 for mac1"); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 126 | mac1_ss = HW_MODE_SS_1x1; |
| 127 | } |
| 128 | |
| 129 | hw_mode_index = policy_mgr_get_hw_mode_idx_from_dbs_hw_list(psoc, |
| 130 | mac0_ss, mac0_bw, mac1_ss, mac1_bw, dbs, dfs, sbs); |
| 131 | if (hw_mode_index < 0) { |
| 132 | policy_mgr_err("Invalid HW mode index obtained"); |
| 133 | return QDF_STATUS_E_FAILURE; |
| 134 | } |
| 135 | |
| 136 | msg.hw_mode_index = hw_mode_index; |
| 137 | msg.set_hw_mode_cb = (void *)policy_mgr_pdev_set_hw_mode_cb; |
| 138 | msg.reason = reason; |
| 139 | msg.session_id = session_id; |
Tushnim Bhattacharyya | 9420656 | 2017-11-15 15:30:07 -0800 | [diff] [blame] | 140 | msg.next_action = next_action; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 141 | msg.context = psoc; |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 142 | |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 143 | policy_mgr_debug("set hw mode to sme: hw_mode_index: %d session:%d reason:%d", |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 144 | msg.hw_mode_index, msg.session_id, msg.reason); |
| 145 | |
| 146 | status = pm_ctx->sme_cbacks.sme_pdev_set_hw_mode(msg); |
| 147 | if (status != QDF_STATUS_SUCCESS) { |
| 148 | policy_mgr_err("Failed to set hw mode to SME"); |
| 149 | return status; |
| 150 | } |
| 151 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 152 | return QDF_STATUS_SUCCESS; |
| 153 | } |
| 154 | |
| 155 | enum policy_mgr_conc_next_action policy_mgr_need_opportunistic_upgrade( |
| 156 | struct wlan_objmgr_psoc *psoc) |
| 157 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 158 | uint32_t conn_index; |
| 159 | enum policy_mgr_conc_next_action upgrade = PM_NOP; |
| 160 | uint8_t mac = 0; |
| 161 | struct policy_mgr_hw_mode_params hw_mode; |
| 162 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 163 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 164 | |
| 165 | pm_ctx = policy_mgr_get_context(psoc); |
| 166 | if (!pm_ctx) { |
| 167 | policy_mgr_err("Invalid Context"); |
| 168 | goto done; |
| 169 | } |
| 170 | |
| 171 | if (policy_mgr_is_hw_dbs_capable(psoc) == false) { |
| 172 | policy_mgr_err("driver isn't dbs capable, no further action needed"); |
| 173 | goto done; |
| 174 | } |
| 175 | |
| 176 | status = policy_mgr_get_current_hw_mode(psoc, &hw_mode); |
| 177 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 178 | policy_mgr_err("policy_mgr_get_current_hw_mode failed"); |
| 179 | goto done; |
| 180 | } |
| 181 | if (!hw_mode.dbs_cap) { |
| 182 | policy_mgr_notice("current HW mode is non-DBS capable"); |
| 183 | goto done; |
| 184 | } |
| 185 | |
| 186 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 187 | /* Are both mac's still in use */ |
| 188 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 189 | conn_index++) { |
| 190 | policy_mgr_debug("index:%d mac:%d in_use:%d chan:%d org_nss:%d", |
| 191 | conn_index, |
| 192 | pm_conc_connection_list[conn_index].mac, |
| 193 | pm_conc_connection_list[conn_index].in_use, |
| 194 | pm_conc_connection_list[conn_index].chan, |
| 195 | pm_conc_connection_list[conn_index].original_nss); |
| 196 | if ((pm_conc_connection_list[conn_index].mac == 0) && |
| 197 | pm_conc_connection_list[conn_index].in_use) { |
| 198 | mac |= POLICY_MGR_MAC0; |
| 199 | if (POLICY_MGR_MAC0_AND_MAC1 == mac) { |
| 200 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 201 | goto done; |
| 202 | } |
| 203 | } else if ((pm_conc_connection_list[conn_index].mac == 1) && |
| 204 | pm_conc_connection_list[conn_index].in_use) { |
| 205 | mac |= POLICY_MGR_MAC1; |
Archana Ramachandran | 944f1fd | 2017-06-02 16:48:17 -0700 | [diff] [blame] | 206 | if (policy_mgr_is_hw_dbs_2x2_capable(psoc) && |
| 207 | WLAN_REG_IS_24GHZ_CH( |
| 208 | pm_conc_connection_list[conn_index].chan) |
| 209 | ) { |
| 210 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 211 | policy_mgr_debug("2X2 DBS capable with 2.4 GHZ connection"); |
| 212 | goto done; |
| 213 | } |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 214 | if (POLICY_MGR_MAC0_AND_MAC1 == mac) { |
| 215 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 216 | goto done; |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | /* Let's request for single MAC mode */ |
| 221 | upgrade = PM_SINGLE_MAC; |
| 222 | /* Is there any connection had an initial connection with 2x2 */ |
| 223 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 224 | conn_index++) { |
| 225 | if ((pm_conc_connection_list[conn_index].original_nss == 2) && |
| 226 | pm_conc_connection_list[conn_index].in_use) { |
| 227 | upgrade = PM_SINGLE_MAC_UPGRADE; |
| 228 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 229 | goto done; |
| 230 | } |
| 231 | } |
| 232 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 233 | |
| 234 | done: |
| 235 | return upgrade; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | QDF_STATUS policy_mgr_update_connection_info(struct wlan_objmgr_psoc *psoc, |
| 239 | uint32_t vdev_id) |
| 240 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 241 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 242 | uint32_t conn_index = 0; |
| 243 | bool found = false; |
| 244 | struct policy_mgr_vdev_entry_info conn_table_entry; |
| 245 | enum policy_mgr_chain_mode chain_mask = POLICY_MGR_ONE_ONE; |
| 246 | uint8_t nss_2g, nss_5g; |
| 247 | enum policy_mgr_con_mode mode; |
| 248 | uint8_t chan; |
| 249 | uint32_t nss = 0; |
| 250 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 251 | |
| 252 | pm_ctx = policy_mgr_get_context(psoc); |
| 253 | if (!pm_ctx) { |
| 254 | policy_mgr_err("Invalid Context"); |
| 255 | return status; |
| 256 | } |
| 257 | |
| 258 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 259 | while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { |
| 260 | if (vdev_id == pm_conc_connection_list[conn_index].vdev_id) { |
| 261 | /* debug msg */ |
| 262 | found = true; |
| 263 | break; |
| 264 | } |
| 265 | conn_index++; |
| 266 | } |
| 267 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 268 | if (!found) { |
| 269 | /* err msg */ |
| 270 | policy_mgr_err("can't find vdev_id %d in pm_conc_connection_list", |
| 271 | vdev_id); |
| 272 | return status; |
| 273 | } |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame] | 274 | if (pm_ctx->wma_cbacks.wma_get_connection_info) { |
| 275 | status = pm_ctx->wma_cbacks.wma_get_connection_info( |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 276 | vdev_id, &conn_table_entry); |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame] | 277 | if (QDF_STATUS_SUCCESS != status) { |
| 278 | policy_mgr_err("can't find vdev_id %d in connection table", |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 279 | vdev_id); |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame] | 280 | return status; |
| 281 | } |
| 282 | } else { |
| 283 | policy_mgr_err("wma_get_connection_info is NULL"); |
| 284 | return QDF_STATUS_E_FAILURE; |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 285 | } |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame] | 286 | |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 287 | mode = policy_mgr_get_mode(conn_table_entry.type, |
| 288 | conn_table_entry.sub_type); |
Tushnim Bhattacharyya | ce237d6 | 2017-04-05 12:52:36 -0700 | [diff] [blame] | 289 | chan = wlan_reg_freq_to_chan(pm_ctx->pdev, conn_table_entry.mhz); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 290 | status = policy_mgr_get_nss_for_vdev(psoc, mode, &nss_2g, &nss_5g); |
| 291 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 292 | if ((WLAN_REG_IS_24GHZ_CH(chan) && (nss_2g > 1)) || |
| 293 | (WLAN_REG_IS_5GHZ_CH(chan) && (nss_5g > 1))) |
| 294 | chain_mask = POLICY_MGR_TWO_TWO; |
| 295 | else |
| 296 | chain_mask = POLICY_MGR_ONE_ONE; |
| 297 | nss = (WLAN_REG_IS_24GHZ_CH(chan)) ? nss_2g : nss_5g; |
| 298 | } else { |
| 299 | policy_mgr_err("Error in getting nss"); |
| 300 | } |
| 301 | |
| 302 | policy_mgr_debug("update PM connection table for vdev:%d", vdev_id); |
| 303 | |
| 304 | /* add the entry */ |
| 305 | policy_mgr_update_conc_list(psoc, conn_index, |
| 306 | mode, |
| 307 | chan, |
| 308 | policy_mgr_get_bw(conn_table_entry.chan_width), |
| 309 | conn_table_entry.mac_id, |
| 310 | chain_mask, |
| 311 | nss, vdev_id, true); |
| 312 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 313 | return QDF_STATUS_SUCCESS; |
| 314 | } |
| 315 | |
| 316 | QDF_STATUS policy_mgr_update_and_wait_for_connection_update( |
| 317 | struct wlan_objmgr_psoc *psoc, |
| 318 | uint8_t session_id, |
| 319 | uint8_t channel, |
| 320 | enum policy_mgr_conn_update_reason reason) |
| 321 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 322 | QDF_STATUS status; |
| 323 | |
| 324 | policy_mgr_debug("session:%d channel:%d reason:%d", |
| 325 | session_id, channel, reason); |
| 326 | |
| 327 | status = policy_mgr_reset_connection_update(psoc); |
| 328 | if (QDF_IS_STATUS_ERROR(status)) |
| 329 | policy_mgr_err("clearing event failed"); |
| 330 | |
| 331 | status = policy_mgr_current_connections_update(psoc, |
| 332 | session_id, channel, reason); |
| 333 | if (QDF_STATUS_E_FAILURE == status) { |
| 334 | policy_mgr_err("connections update failed"); |
| 335 | return QDF_STATUS_E_FAILURE; |
| 336 | } |
| 337 | |
| 338 | /* Wait only when status is success */ |
| 339 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 340 | status = policy_mgr_wait_for_connection_update(psoc); |
| 341 | if (QDF_IS_STATUS_ERROR(status)) { |
| 342 | policy_mgr_err("qdf wait for event failed"); |
| 343 | return QDF_STATUS_E_FAILURE; |
| 344 | } |
| 345 | } |
| 346 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 347 | return QDF_STATUS_SUCCESS; |
| 348 | } |
| 349 | |
Yeshwanth Sriram Guntuka | 71e5ae6 | 2018-02-12 13:30:23 +0530 | [diff] [blame] | 350 | /** |
| 351 | * policy_mgr_is_dbs_allowed_for_concurrency() - If dbs is allowed for current |
| 352 | * concurreny |
| 353 | * @new_conn_mode: new connection mode |
| 354 | * |
| 355 | * When a new connection is about to come up, check if dbs is allowed for |
| 356 | * STA+STA or STA+P2P |
| 357 | * |
| 358 | * Return: true if dbs is allowed for STA+STA or STA+P2P else false |
| 359 | */ |
Bala Venkatesh | 28477d3 | 2018-05-07 21:35:55 +0530 | [diff] [blame^] | 360 | bool policy_mgr_is_dbs_allowed_for_concurrency( |
| 361 | struct wlan_objmgr_psoc *psoc, enum QDF_OPMODE new_conn_mode) |
Yeshwanth Sriram Guntuka | 71e5ae6 | 2018-02-12 13:30:23 +0530 | [diff] [blame] | 362 | { |
| 363 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 364 | uint32_t count, dbs_for_sta_sta, dbs_for_sta_p2p; |
Yeshwanth Sriram Guntuka | 71e5ae6 | 2018-02-12 13:30:23 +0530 | [diff] [blame] | 365 | bool ret = true; |
| 366 | |
| 367 | pm_ctx = policy_mgr_get_context(psoc); |
| 368 | if (!pm_ctx) { |
| 369 | policy_mgr_err("Invalid context"); |
| 370 | return ret; |
| 371 | } |
| 372 | |
| 373 | count = policy_mgr_get_connection_count(psoc); |
Yeshwanth Sriram Guntuka | 71e5ae6 | 2018-02-12 13:30:23 +0530 | [diff] [blame] | 374 | |
| 375 | if (count != 1 || new_conn_mode == QDF_MAX_NO_OF_MODE) |
| 376 | return ret; |
| 377 | |
| 378 | dbs_for_sta_sta = PM_CHANNEL_SELECT_LOGIC_STA_STA_GET(pm_ctx->user_cfg. |
| 379 | channel_select_logic_conc); |
| 380 | dbs_for_sta_p2p = PM_CHANNEL_SELECT_LOGIC_STA_P2P_GET(pm_ctx->user_cfg. |
| 381 | channel_select_logic_conc); |
| 382 | |
| 383 | switch (pm_conc_connection_list[0].mode) { |
| 384 | case PM_STA_MODE: |
| 385 | switch (new_conn_mode) { |
| 386 | case QDF_STA_MODE: |
| 387 | if (!dbs_for_sta_sta) |
| 388 | return false; |
| 389 | break; |
| 390 | case QDF_P2P_DEVICE_MODE: |
| 391 | case QDF_P2P_CLIENT_MODE: |
| 392 | case QDF_P2P_GO_MODE: |
| 393 | if (!dbs_for_sta_p2p) |
| 394 | return false; |
| 395 | break; |
| 396 | default: |
| 397 | break; |
| 398 | } |
| 399 | break; |
| 400 | case PM_P2P_CLIENT_MODE: |
| 401 | case PM_P2P_GO_MODE: |
| 402 | switch (new_conn_mode) { |
| 403 | case QDF_STA_MODE: |
| 404 | if (!dbs_for_sta_p2p) |
| 405 | return false; |
| 406 | break; |
| 407 | default: |
| 408 | break; |
| 409 | } |
| 410 | break; |
| 411 | default: |
| 412 | break; |
| 413 | } |
| 414 | |
| 415 | return ret; |
| 416 | } |
| 417 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 418 | QDF_STATUS policy_mgr_current_connections_update(struct wlan_objmgr_psoc *psoc, |
| 419 | uint32_t session_id, |
| 420 | uint8_t channel, |
| 421 | enum policy_mgr_conn_update_reason reason) |
| 422 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 423 | enum policy_mgr_conc_next_action next_action = PM_NOP; |
| 424 | uint32_t num_connections = 0; |
| 425 | enum policy_mgr_one_connection_mode second_index = 0; |
| 426 | enum policy_mgr_two_connection_mode third_index = 0; |
| 427 | enum policy_mgr_band band; |
| 428 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Bala Venkatesh | 28477d3 | 2018-05-07 21:35:55 +0530 | [diff] [blame^] | 429 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 430 | enum QDF_OPMODE new_conn_mode = QDF_MAX_NO_OF_MODE; |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 431 | |
| 432 | if (policy_mgr_is_hw_dbs_capable(psoc) == false) { |
| 433 | policy_mgr_err("driver isn't dbs capable, no further action needed"); |
| 434 | return QDF_STATUS_E_NOSUPPORT; |
| 435 | } |
| 436 | if (WLAN_REG_IS_24GHZ_CH(channel)) |
| 437 | band = POLICY_MGR_BAND_24; |
| 438 | else |
| 439 | band = POLICY_MGR_BAND_5; |
| 440 | |
| 441 | num_connections = policy_mgr_get_connection_count(psoc); |
| 442 | |
| 443 | policy_mgr_debug("num_connections=%d channel=%d", |
| 444 | num_connections, channel); |
| 445 | |
| 446 | switch (num_connections) { |
| 447 | case 0: |
| 448 | if (band == POLICY_MGR_BAND_24) |
| 449 | if (policy_mgr_is_hw_dbs_2x2_capable(psoc)) |
| 450 | next_action = PM_DBS; |
| 451 | else |
| 452 | next_action = PM_NOP; |
| 453 | else |
| 454 | next_action = PM_NOP; |
| 455 | break; |
| 456 | case 1: |
| 457 | second_index = |
| 458 | policy_mgr_get_second_connection_pcl_table_index(psoc); |
| 459 | if (PM_MAX_ONE_CONNECTION_MODE == second_index) { |
| 460 | policy_mgr_err( |
| 461 | "couldn't find index for 2nd connection next action table"); |
| 462 | goto done; |
| 463 | } |
| 464 | next_action = |
| 465 | (*next_action_two_connection_table)[second_index][band]; |
| 466 | break; |
| 467 | case 2: |
| 468 | third_index = |
| 469 | policy_mgr_get_third_connection_pcl_table_index(psoc); |
| 470 | if (PM_MAX_TWO_CONNECTION_MODE == third_index) { |
| 471 | policy_mgr_err( |
| 472 | "couldn't find index for 3rd connection next action table"); |
| 473 | goto done; |
| 474 | } |
| 475 | next_action = (*next_action_three_connection_table) |
| 476 | [third_index][band]; |
| 477 | break; |
| 478 | default: |
| 479 | policy_mgr_err("unexpected num_connections value %d", |
| 480 | num_connections); |
| 481 | break; |
| 482 | } |
| 483 | |
Bala Venkatesh | 28477d3 | 2018-05-07 21:35:55 +0530 | [diff] [blame^] | 484 | pm_ctx = policy_mgr_get_context(psoc); |
| 485 | if (!pm_ctx) { |
| 486 | policy_mgr_err("Invalid context"); |
| 487 | goto done; |
| 488 | } |
| 489 | |
| 490 | if (pm_ctx->hdd_cbacks.hdd_get_device_mode) |
| 491 | new_conn_mode = pm_ctx->hdd_cbacks. |
| 492 | hdd_get_device_mode(session_id); |
| 493 | |
Yeshwanth Sriram Guntuka | 71e5ae6 | 2018-02-12 13:30:23 +0530 | [diff] [blame] | 494 | /* |
| 495 | * Based on channel_select_logic_conc ini, hw mode is set |
| 496 | * when second connection is about to come up that results |
| 497 | * in STA+STA and STA+P2P concurrency. |
| 498 | * 1) If MCC is set and if current hw mode is dbs, hw mode |
| 499 | * should be set to single mac for above concurrency. |
| 500 | * 2) If MCC is set and if current hw mode is not dbs, hw |
| 501 | * mode change is not required. |
| 502 | */ |
| 503 | if (policy_mgr_is_current_hwmode_dbs(psoc) && |
Bala Venkatesh | 28477d3 | 2018-05-07 21:35:55 +0530 | [diff] [blame^] | 504 | !policy_mgr_is_dbs_allowed_for_concurrency(psoc, new_conn_mode)) |
Yeshwanth Sriram Guntuka | 71e5ae6 | 2018-02-12 13:30:23 +0530 | [diff] [blame] | 505 | next_action = PM_SINGLE_MAC; |
| 506 | else if (!policy_mgr_is_current_hwmode_dbs(psoc) && |
Bala Venkatesh | 28477d3 | 2018-05-07 21:35:55 +0530 | [diff] [blame^] | 507 | !policy_mgr_is_dbs_allowed_for_concurrency(psoc, new_conn_mode)) |
Yeshwanth Sriram Guntuka | 71e5ae6 | 2018-02-12 13:30:23 +0530 | [diff] [blame] | 508 | next_action = PM_NOP; |
| 509 | |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 510 | if (PM_NOP != next_action) |
| 511 | status = policy_mgr_next_actions(psoc, session_id, |
| 512 | next_action, reason); |
| 513 | else |
| 514 | status = QDF_STATUS_E_NOSUPPORT; |
| 515 | |
| 516 | policy_mgr_debug( |
| 517 | "idx2=%d idx3=%d next_action=%d, band=%d status=%d reason=%d session_id=%d", |
| 518 | second_index, third_index, next_action, band, status, |
| 519 | reason, session_id); |
| 520 | |
| 521 | done: |
| 522 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | QDF_STATUS policy_mgr_next_actions(struct wlan_objmgr_psoc *psoc, |
| 526 | uint32_t session_id, |
| 527 | enum policy_mgr_conc_next_action action, |
| 528 | enum policy_mgr_conn_update_reason reason) |
| 529 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 530 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 531 | struct policy_mgr_hw_mode_params hw_mode; |
Varun Reddy Yeturu | e23b6bc | 2018-01-08 13:18:41 -0800 | [diff] [blame] | 532 | struct dbs_nss nss_dbs = {0}; |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 533 | |
| 534 | if (policy_mgr_is_hw_dbs_capable(psoc) == false) { |
| 535 | policy_mgr_err("driver isn't dbs capable, no further action needed"); |
| 536 | return QDF_STATUS_E_NOSUPPORT; |
| 537 | } |
| 538 | |
| 539 | /* check for the current HW index to see if really need any action */ |
| 540 | status = policy_mgr_get_current_hw_mode(psoc, &hw_mode); |
| 541 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 542 | policy_mgr_err("policy_mgr_get_current_hw_mode failed"); |
| 543 | return status; |
| 544 | } |
| 545 | /** |
| 546 | * if already in DBS no need to request DBS. Might be needed |
| 547 | * to extend the logic when multiple dbs HW mode is available |
| 548 | */ |
| 549 | if ((((PM_DBS_DOWNGRADE == action) || (PM_DBS == action) || |
| 550 | (PM_DBS_UPGRADE == action)) |
| 551 | && hw_mode.dbs_cap)) { |
| 552 | policy_mgr_err("driver is already in %s mode, no further action needed", |
| 553 | (hw_mode.dbs_cap) ? "dbs" : "non dbs"); |
| 554 | return QDF_STATUS_E_ALREADY; |
| 555 | } |
| 556 | |
| 557 | if ((PM_SBS == action) || (action == PM_SBS_DOWNGRADE)) { |
| 558 | if (!policy_mgr_is_hw_sbs_capable(psoc)) { |
| 559 | /* No action */ |
| 560 | policy_mgr_notice("firmware is not sbs capable"); |
Tushnim Bhattacharyya | fe51170 | 2017-04-24 15:21:59 -0700 | [diff] [blame] | 561 | return QDF_STATUS_E_NOSUPPORT; |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 562 | } |
| 563 | /* check if current mode is already SBS nothing to be |
| 564 | * done |
| 565 | */ |
| 566 | |
| 567 | } |
| 568 | |
| 569 | switch (action) { |
| 570 | case PM_DBS_DOWNGRADE: |
| 571 | /* |
| 572 | * check if we have a beaconing entity that is using 2x2. If yes, |
| 573 | * update the beacon template & notify FW. Once FW confirms |
| 574 | * beacon updated, send down the HW mode change req |
| 575 | */ |
| 576 | status = policy_mgr_complete_action(psoc, POLICY_MGR_RX_NSS_1, |
| 577 | PM_DBS, reason, session_id); |
| 578 | break; |
| 579 | case PM_DBS: |
Vikrampal | 31eb12c | 2017-04-28 17:44:30 +0530 | [diff] [blame] | 580 | (void)policy_mgr_get_hw_dbs_nss(psoc, &nss_dbs); |
| 581 | |
| 582 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 583 | nss_dbs.mac0_ss, |
| 584 | HW_MODE_80_MHZ, |
| 585 | nss_dbs.mac1_ss, |
| 586 | HW_MODE_40_MHZ, |
| 587 | HW_MODE_DBS, |
| 588 | HW_MODE_AGILE_DFS_NONE, |
| 589 | HW_MODE_SBS_NONE, |
Tushnim Bhattacharyya | 9420656 | 2017-11-15 15:30:07 -0800 | [diff] [blame] | 590 | reason, PM_NOP); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 591 | break; |
| 592 | case PM_SINGLE_MAC_UPGRADE: |
| 593 | /* |
| 594 | * change the HW mode first before the NSS upgrade |
| 595 | */ |
| 596 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 597 | HW_MODE_SS_2x2, |
| 598 | HW_MODE_80_MHZ, |
| 599 | HW_MODE_SS_0x0, HW_MODE_BW_NONE, |
| 600 | HW_MODE_DBS_NONE, |
| 601 | HW_MODE_AGILE_DFS_NONE, |
| 602 | HW_MODE_SBS_NONE, |
Tushnim Bhattacharyya | 9420656 | 2017-11-15 15:30:07 -0800 | [diff] [blame] | 603 | reason, PM_UPGRADE); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 604 | break; |
| 605 | case PM_SINGLE_MAC: |
| 606 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 607 | HW_MODE_SS_2x2, |
| 608 | HW_MODE_80_MHZ, |
| 609 | HW_MODE_SS_0x0, HW_MODE_BW_NONE, |
| 610 | HW_MODE_DBS_NONE, |
| 611 | HW_MODE_AGILE_DFS_NONE, |
| 612 | HW_MODE_SBS_NONE, |
Tushnim Bhattacharyya | 9420656 | 2017-11-15 15:30:07 -0800 | [diff] [blame] | 613 | reason, PM_NOP); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 614 | break; |
| 615 | case PM_DBS_UPGRADE: |
| 616 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 617 | HW_MODE_SS_2x2, |
| 618 | HW_MODE_80_MHZ, |
| 619 | HW_MODE_SS_2x2, HW_MODE_80_MHZ, |
| 620 | HW_MODE_DBS, |
| 621 | HW_MODE_AGILE_DFS_NONE, |
| 622 | HW_MODE_SBS_NONE, |
Tushnim Bhattacharyya | 9420656 | 2017-11-15 15:30:07 -0800 | [diff] [blame] | 623 | reason, PM_UPGRADE); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 624 | break; |
| 625 | case PM_SBS_DOWNGRADE: |
| 626 | status = policy_mgr_complete_action(psoc, POLICY_MGR_RX_NSS_1, |
| 627 | PM_SBS, reason, session_id); |
| 628 | break; |
| 629 | case PM_SBS: |
| 630 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 631 | HW_MODE_SS_1x1, |
| 632 | HW_MODE_80_MHZ, |
| 633 | HW_MODE_SS_1x1, HW_MODE_80_MHZ, |
| 634 | HW_MODE_DBS, |
| 635 | HW_MODE_AGILE_DFS_NONE, |
| 636 | HW_MODE_SBS, |
Tushnim Bhattacharyya | 9420656 | 2017-11-15 15:30:07 -0800 | [diff] [blame] | 637 | reason, PM_NOP); |
| 638 | break; |
| 639 | case PM_DOWNGRADE: |
| 640 | /* |
| 641 | * check if we have a beaconing entity that advertised 2x2 |
| 642 | * intially. If yes, update the beacon template & notify FW. |
| 643 | */ |
| 644 | status = policy_mgr_nss_update(psoc, POLICY_MGR_RX_NSS_1, |
| 645 | PM_NOP, reason); |
| 646 | break; |
| 647 | case PM_UPGRADE: |
| 648 | /* |
| 649 | * check if we have a beaconing entity that advertised 2x2 |
| 650 | * intially. If yes, update the beacon template & notify FW. |
| 651 | */ |
| 652 | status = policy_mgr_nss_update(psoc, POLICY_MGR_RX_NSS_2, |
| 653 | PM_NOP, reason); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 654 | break; |
| 655 | default: |
| 656 | policy_mgr_err("unexpected action value %d", action); |
| 657 | status = QDF_STATUS_E_FAILURE; |
| 658 | break; |
| 659 | } |
| 660 | |
| 661 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | QDF_STATUS policy_mgr_handle_conc_multiport(struct wlan_objmgr_psoc *psoc, |
| 665 | uint8_t session_id, uint8_t channel) |
| 666 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 667 | QDF_STATUS status; |
| 668 | |
| 669 | if (!policy_mgr_check_for_session_conc(psoc, session_id, channel)) { |
| 670 | policy_mgr_err("Conc not allowed for the session %d", |
| 671 | session_id); |
| 672 | return QDF_STATUS_E_FAILURE; |
| 673 | } |
| 674 | |
| 675 | status = policy_mgr_reset_connection_update(psoc); |
| 676 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 677 | policy_mgr_err("clearing event failed"); |
| 678 | |
| 679 | status = policy_mgr_current_connections_update(psoc, session_id, |
| 680 | channel, |
| 681 | POLICY_MGR_UPDATE_REASON_NORMAL_STA); |
| 682 | if (QDF_STATUS_E_FAILURE == status) { |
| 683 | policy_mgr_err("connections update failed"); |
| 684 | return status; |
| 685 | } |
| 686 | |
| 687 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 691 | /** |
| 692 | * policy_mgr_is_restart_sap_allowed() - Check if restart SAP |
| 693 | * allowed during SCC -> MCC switch |
| 694 | * @psoc: PSOC object data |
| 695 | * @mcc_to_scc_switch: MCC to SCC switch enabled user config |
| 696 | * |
| 697 | * Check if restart SAP allowed during SCC->MCC switch |
| 698 | * |
| 699 | * Restart: true or false |
| 700 | */ |
| 701 | static bool policy_mgr_is_restart_sap_allowed( |
| 702 | struct wlan_objmgr_psoc *psoc, |
| 703 | uint32_t mcc_to_scc_switch) |
| 704 | { |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 705 | uint32_t sta_ap_bit_mask = QDF_STA_MASK | QDF_SAP_MASK; |
| 706 | uint32_t sta_go_bit_mask = QDF_STA_MASK | QDF_P2P_GO_MASK; |
| 707 | |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 708 | if ((mcc_to_scc_switch == QDF_MCC_TO_SCC_SWITCH_DISABLE) || |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 709 | !policy_mgr_concurrent_open_sessions_running(psoc) || |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 710 | !(((policy_mgr_get_concurrency_mode(psoc) & sta_ap_bit_mask) |
| 711 | == sta_ap_bit_mask) || |
Tushnim Bhattacharyya | b7f8396 | 2018-06-14 17:56:38 -0700 | [diff] [blame] | 712 | ((mcc_to_scc_switch == |
| 713 | QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION) && |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 714 | ((policy_mgr_get_concurrency_mode(psoc) & sta_go_bit_mask) |
Tushnim Bhattacharyya | b7f8396 | 2018-06-14 17:56:38 -0700 | [diff] [blame] | 715 | == sta_go_bit_mask)))) { |
Ajit Pal Singh | c1246b1 | 2017-06-16 11:36:12 +0530 | [diff] [blame] | 716 | policy_mgr_err("MCC switch disabled or not concurrent STA/SAP, STA/GO"); |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 717 | return false; |
| 718 | } |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 719 | |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 720 | return true; |
| 721 | } |
| 722 | |
Tushnim Bhattacharyya | 08a8339 | 2017-06-28 13:28:49 -0700 | [diff] [blame] | 723 | bool policy_mgr_is_safe_channel(struct wlan_objmgr_psoc *psoc, |
| 724 | uint8_t channel) |
| 725 | { |
| 726 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 727 | bool is_safe = true; |
| 728 | uint8_t j; |
| 729 | |
| 730 | pm_ctx = policy_mgr_get_context(psoc); |
| 731 | if (!pm_ctx) { |
| 732 | policy_mgr_err("Invalid context"); |
| 733 | return is_safe; |
| 734 | } |
| 735 | |
| 736 | |
| 737 | if (pm_ctx->unsafe_channel_count == 0) { |
| 738 | policy_mgr_debug("There are no unsafe channels"); |
| 739 | return is_safe; |
| 740 | } |
| 741 | |
| 742 | for (j = 0; j < pm_ctx->unsafe_channel_count; j++) { |
| 743 | if (channel == pm_ctx->unsafe_channel_list[j]) { |
| 744 | is_safe = false; |
| 745 | policy_mgr_warn("CH %d is not safe", channel); |
| 746 | break; |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | return is_safe; |
| 751 | } |
| 752 | |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 753 | /** |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 754 | * policy_mgr_check_sta_ap_concurrent_ch_intf() - Restart SAP in STA-AP case |
| 755 | * @data: Pointer check concurrent channel work data |
| 756 | * |
| 757 | * Restarts the SAP interface in STA-AP concurrency scenario |
| 758 | * |
| 759 | * Restart: None |
| 760 | */ |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 761 | void policy_mgr_check_sta_ap_concurrent_ch_intf(void *data) |
| 762 | { |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 763 | struct wlan_objmgr_psoc *psoc; |
| 764 | struct policy_mgr_psoc_priv_obj *pm_ctx = NULL; |
| 765 | struct sta_ap_intf_check_work_ctx *work_info = NULL; |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 766 | uint32_t mcc_to_scc_switch, cc_count = 0, i; |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 767 | QDF_STATUS status; |
| 768 | uint8_t channel, sec_ch; |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 769 | uint8_t operating_channel[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
| 770 | uint8_t vdev_id[MAX_NUMBER_OF_CONC_CONNECTIONS]; |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 771 | |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 772 | work_info = (struct sta_ap_intf_check_work_ctx *) data; |
| 773 | if (!work_info) { |
| 774 | policy_mgr_err("Invalid work_info"); |
| 775 | goto end; |
| 776 | } |
| 777 | |
| 778 | psoc = work_info->psoc; |
| 779 | if (!psoc) { |
| 780 | policy_mgr_err("Invalid psoc"); |
| 781 | goto end; |
| 782 | } |
| 783 | |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 784 | pm_ctx = policy_mgr_get_context(psoc); |
| 785 | if (!pm_ctx) { |
| 786 | policy_mgr_err("Invalid context"); |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 787 | goto end; |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 788 | } |
| 789 | mcc_to_scc_switch = |
| 790 | policy_mgr_mcc_to_scc_switch_mode_in_user_cfg(psoc); |
| 791 | |
| 792 | policy_mgr_info("Concurrent open sessions running: %d", |
| 793 | policy_mgr_concurrent_open_sessions_running(psoc)); |
| 794 | |
| 795 | if (!policy_mgr_is_restart_sap_allowed(psoc, mcc_to_scc_switch)) |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 796 | goto end; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 797 | |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 798 | cc_count = policy_mgr_get_mode_specific_conn_info(psoc, |
| 799 | &operating_channel[cc_count], |
| 800 | &vdev_id[cc_count], |
| 801 | PM_SAP_MODE); |
| 802 | policy_mgr_debug("Number of concurrent SAP: %d", cc_count); |
| 803 | cc_count = cc_count + policy_mgr_get_mode_specific_conn_info(psoc, |
| 804 | &operating_channel[cc_count], |
| 805 | &vdev_id[cc_count], |
| 806 | PM_P2P_GO_MODE); |
| 807 | policy_mgr_debug("Number of beaconing entities (SAP + GO):%d", |
| 808 | cc_count); |
| 809 | if (!cc_count) { |
Ajit Pal Singh | c1246b1 | 2017-06-16 11:36:12 +0530 | [diff] [blame] | 810 | policy_mgr_err("Could not retrieve SAP/GO operating channel&vdevid"); |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 811 | goto end; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 812 | } |
| 813 | |
Archana Ramachandran | 631fd9f | 2017-03-19 18:51:30 -0700 | [diff] [blame] | 814 | if (!pm_ctx->hdd_cbacks.wlan_hdd_get_channel_for_sap_restart) { |
| 815 | policy_mgr_err("SAP restart get channel callback in NULL"); |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 816 | goto end; |
Archana Ramachandran | 631fd9f | 2017-03-19 18:51:30 -0700 | [diff] [blame] | 817 | } |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 818 | for (i = 0; i < cc_count; i++) { |
| 819 | status = pm_ctx->hdd_cbacks. |
| 820 | wlan_hdd_get_channel_for_sap_restart(psoc, |
| 821 | vdev_id[i], &channel, &sec_ch); |
| 822 | if (status == QDF_STATUS_SUCCESS) { |
| 823 | policy_mgr_info("SAP restarts due to MCC->SCC switch, old chan :%d new chan: %d" |
| 824 | , operating_channel[i], channel); |
| 825 | break; |
| 826 | } |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 827 | } |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 828 | if (status != QDF_STATUS_SUCCESS) |
| 829 | policy_mgr_err("Failed to switch SAP channel"); |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 830 | end: |
| 831 | if (work_info) { |
| 832 | qdf_mem_free(work_info); |
| 833 | if (pm_ctx) |
| 834 | pm_ctx->sta_ap_intf_check_work_info = NULL; |
| 835 | } |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 836 | } |
| 837 | |
Tushnim Bhattacharyya | 08a8339 | 2017-06-28 13:28:49 -0700 | [diff] [blame] | 838 | static bool policy_mgr_valid_sta_channel_check(struct wlan_objmgr_psoc *psoc, |
| 839 | uint8_t sta_channel) |
| 840 | { |
| 841 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 842 | |
| 843 | pm_ctx = policy_mgr_get_context(psoc); |
| 844 | if (!pm_ctx) { |
| 845 | policy_mgr_err("Invalid context"); |
| 846 | return false; |
| 847 | } |
| 848 | |
Ganesh Kondabattini | 8a611c6 | 2017-11-21 15:01:31 +0530 | [diff] [blame] | 849 | if ((wlan_reg_is_dfs_ch(pm_ctx->pdev, sta_channel) && |
| 850 | (!policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan(psoc))) || |
Tushnim Bhattacharyya | 08a8339 | 2017-06-28 13:28:49 -0700 | [diff] [blame] | 851 | wlan_reg_is_passive_or_disable_ch(pm_ctx->pdev, sta_channel) || |
Ganesh Kondabattini | 8a611c6 | 2017-11-21 15:01:31 +0530 | [diff] [blame] | 852 | !policy_mgr_is_safe_channel(psoc, sta_channel)) { |
Tushnim Bhattacharyya | 08a8339 | 2017-06-28 13:28:49 -0700 | [diff] [blame] | 853 | if (policy_mgr_is_hw_dbs_capable(psoc)) |
| 854 | return true; |
| 855 | else |
| 856 | return false; |
Ganesh Kondabattini | 8a611c6 | 2017-11-21 15:01:31 +0530 | [diff] [blame] | 857 | } |
Tushnim Bhattacharyya | 08a8339 | 2017-06-28 13:28:49 -0700 | [diff] [blame] | 858 | else |
| 859 | return true; |
| 860 | } |
| 861 | |
Tushnim Bhattacharyya | a2c3b62 | 2017-08-03 16:58:38 -0700 | [diff] [blame] | 862 | QDF_STATUS policy_mgr_valid_sap_conc_channel_check( |
| 863 | struct wlan_objmgr_psoc *psoc, uint8_t *con_ch, uint8_t sap_ch) |
| 864 | { |
| 865 | uint8_t channel = *con_ch; |
| 866 | uint8_t temp_channel = 0; |
| 867 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 868 | |
| 869 | pm_ctx = policy_mgr_get_context(psoc); |
| 870 | if (!pm_ctx) { |
| 871 | policy_mgr_err("Invalid context"); |
| 872 | return QDF_STATUS_E_FAILURE; |
| 873 | } |
| 874 | |
| 875 | /* |
| 876 | * if force SCC is set, Check if conc channel is DFS |
| 877 | * or passive or part of LTE avoided channel list. |
| 878 | * In that case move SAP to other band if DBS is supported, |
| 879 | * return otherwise |
| 880 | */ |
| 881 | if (!policy_mgr_is_force_scc(psoc)) |
| 882 | return QDF_STATUS_SUCCESS; |
| 883 | |
| 884 | /* |
| 885 | * if interference is 0, check if it is DBS case. If DBS case |
| 886 | * return from here. If SCC, check further if SAP can move to |
| 887 | * STA's channel. |
| 888 | */ |
| 889 | if (!channel && |
| 890 | (sap_ch != policy_mgr_mode_specific_get_channel( |
| 891 | psoc, PM_STA_MODE))) |
| 892 | return QDF_STATUS_SUCCESS; |
| 893 | else if (!channel) |
| 894 | channel = sap_ch; |
| 895 | |
| 896 | if (policy_mgr_valid_sta_channel_check(psoc, channel)) { |
| 897 | if (wlan_reg_is_dfs_ch(pm_ctx->pdev, channel) || |
Zhu Jianmin | 5ac66ef | 2018-06-11 19:03:39 +0800 | [diff] [blame] | 898 | wlan_reg_is_passive_or_disable_ch( |
Tushnim Bhattacharyya | a2c3b62 | 2017-08-03 16:58:38 -0700 | [diff] [blame] | 899 | pm_ctx->pdev, channel) || |
Zhu Jianmin | 5ac66ef | 2018-06-11 19:03:39 +0800 | [diff] [blame] | 900 | !(policy_mgr_sta_sap_scc_on_lte_coex_chan(psoc) || |
| 901 | policy_mgr_is_safe_channel(psoc, channel))) { |
Tushnim Bhattacharyya | a2c3b62 | 2017-08-03 16:58:38 -0700 | [diff] [blame] | 902 | if (policy_mgr_is_hw_dbs_capable(psoc)) { |
| 903 | temp_channel = |
| 904 | policy_mgr_get_alternate_channel_for_sap(psoc); |
| 905 | policy_mgr_debug("temp_channel is %d", |
| 906 | temp_channel); |
| 907 | if (temp_channel) { |
| 908 | channel = temp_channel; |
| 909 | } else { |
| 910 | if (WLAN_REG_IS_5GHZ_CH(channel)) |
| 911 | channel = PM_24_GHZ_CHANNEL_6; |
| 912 | else |
| 913 | channel = PM_5_GHZ_CHANNEL_36; |
| 914 | } |
| 915 | if (!policy_mgr_is_safe_channel( |
| 916 | psoc, channel)) { |
| 917 | policy_mgr_warn( |
| 918 | "Can't have concurrency on %d as it is not safe", |
| 919 | channel); |
| 920 | return QDF_STATUS_E_FAILURE; |
| 921 | } |
| 922 | } else { |
| 923 | policy_mgr_warn("Can't have concurrency on %d", |
| 924 | channel); |
| 925 | return QDF_STATUS_E_FAILURE; |
| 926 | } |
| 927 | } |
| 928 | } |
| 929 | |
| 930 | if (channel != sap_ch) |
| 931 | *con_ch = channel; |
| 932 | |
| 933 | return QDF_STATUS_SUCCESS; |
| 934 | } |
| 935 | |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 936 | /** |
| 937 | * policy_mgr_check_concurrent_intf_and_restart_sap() - Check |
| 938 | * concurrent change intf |
| 939 | * @psoc: PSOC object information |
| 940 | * @operation_channel: operation channel |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 941 | * @vdev_id: vdev id of SAP |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 942 | * |
| 943 | * Checks the concurrent change interface and restarts SAP |
| 944 | * |
| 945 | * Return: None |
| 946 | */ |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 947 | void policy_mgr_check_concurrent_intf_and_restart_sap( |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 948 | struct wlan_objmgr_psoc *psoc) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 949 | { |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 950 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 951 | uint32_t mcc_to_scc_switch; |
Tushnim Bhattacharyya | f8417d1 | 2018-05-08 15:31:21 -0700 | [diff] [blame] | 952 | uint8_t operating_channel[MAX_NUMBER_OF_CONC_CONNECTIONS] = {0}; |
| 953 | uint8_t vdev_id[MAX_NUMBER_OF_CONC_CONNECTIONS] = {0}; |
| 954 | uint32_t cc_count = 0; |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 955 | |
| 956 | pm_ctx = policy_mgr_get_context(psoc); |
| 957 | if (!pm_ctx) { |
| 958 | policy_mgr_err("Invalid context"); |
| 959 | return; |
| 960 | } |
| 961 | |
Tushnim Bhattacharyya | f8417d1 | 2018-05-08 15:31:21 -0700 | [diff] [blame] | 962 | /* |
| 963 | * force SCC with STA+STA+SAP will need some additional logic |
| 964 | */ |
| 965 | cc_count = policy_mgr_get_mode_specific_conn_info(psoc, |
| 966 | &operating_channel[cc_count], |
| 967 | &vdev_id[cc_count], PM_STA_MODE); |
| 968 | if (!cc_count) { |
Rachit Kankane | a07e4b9 | 2017-09-15 19:38:49 +0530 | [diff] [blame] | 969 | policy_mgr_err("Could not get STA operating channel&vdevid"); |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 970 | return; |
| 971 | } |
| 972 | |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 973 | mcc_to_scc_switch = |
| 974 | policy_mgr_mcc_to_scc_switch_mode_in_user_cfg(psoc); |
| 975 | policy_mgr_info("MCC to SCC switch: %d chan: %d", |
Tushnim Bhattacharyya | f8417d1 | 2018-05-08 15:31:21 -0700 | [diff] [blame] | 976 | mcc_to_scc_switch, operating_channel[0]); |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 977 | |
| 978 | if (!policy_mgr_is_restart_sap_allowed(psoc, mcc_to_scc_switch)) { |
| 979 | policy_mgr_debug( |
| 980 | "No action taken at check_concurrent_intf_and_restart_sap"); |
| 981 | return; |
| 982 | } |
| 983 | |
Tushnim Bhattacharyya | 08a8339 | 2017-06-28 13:28:49 -0700 | [diff] [blame] | 984 | if ((mcc_to_scc_switch != QDF_MCC_TO_SCC_SWITCH_DISABLE) && |
Tushnim Bhattacharyya | f8417d1 | 2018-05-08 15:31:21 -0700 | [diff] [blame] | 985 | policy_mgr_valid_sta_channel_check(psoc, operating_channel[0]) |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 986 | && !pm_ctx->sta_ap_intf_check_work_info) { |
| 987 | struct sta_ap_intf_check_work_ctx *work_info; |
| 988 | work_info = qdf_mem_malloc( |
| 989 | sizeof(struct sta_ap_intf_check_work_ctx)); |
| 990 | pm_ctx->sta_ap_intf_check_work_info = work_info; |
| 991 | if (work_info) { |
| 992 | work_info->psoc = psoc; |
| 993 | qdf_create_work(0, &pm_ctx->sta_ap_intf_check_work, |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 994 | policy_mgr_check_sta_ap_concurrent_ch_intf, |
Tushnim Bhattacharyya | 8d185eb | 2017-06-30 17:40:49 -0700 | [diff] [blame] | 995 | work_info); |
| 996 | qdf_sched_work(0, &pm_ctx->sta_ap_intf_check_work); |
| 997 | policy_mgr_info( |
| 998 | "Checking for Concurrent Change interference"); |
| 999 | } |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 1000 | } |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1001 | } |
| 1002 | #endif /* FEATURE_WLAN_MCC_TO_SCC_SWITCH */ |
| 1003 | |
| 1004 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 1005 | /** |
| 1006 | * policy_mgr_change_sap_channel_with_csa() - Move SAP channel using (E)CSA |
| 1007 | * @psoc: PSOC object information |
| 1008 | * @vdev_id: Vdev id |
| 1009 | * @channel: Channel to change |
| 1010 | * @ch_width: channel width to change |
Min Liu | c5b1043 | 2018-01-19 18:01:44 +0800 | [diff] [blame] | 1011 | * @forced: Force to switch channel, ignore SCC/MCC check |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 1012 | * |
| 1013 | * Invoke the callback function to change SAP channel using (E)CSA |
| 1014 | * |
| 1015 | * Return: None |
| 1016 | */ |
| 1017 | void policy_mgr_change_sap_channel_with_csa(struct wlan_objmgr_psoc *psoc, |
| 1018 | uint8_t vdev_id, uint32_t channel, |
Min Liu | c5b1043 | 2018-01-19 18:01:44 +0800 | [diff] [blame] | 1019 | uint32_t ch_width, |
| 1020 | bool forced) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1021 | { |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 1022 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1023 | |
| 1024 | pm_ctx = policy_mgr_get_context(psoc); |
| 1025 | if (!pm_ctx) { |
| 1026 | policy_mgr_err("Invalid context"); |
| 1027 | return; |
| 1028 | } |
| 1029 | |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 1030 | if (pm_ctx->hdd_cbacks.sap_restart_chan_switch_cb) { |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 1031 | policy_mgr_info("SAP change change without restart"); |
Archana Ramachandran | 631fd9f | 2017-03-19 18:51:30 -0700 | [diff] [blame] | 1032 | pm_ctx->hdd_cbacks.sap_restart_chan_switch_cb(psoc, |
Min Liu | c5b1043 | 2018-01-19 18:01:44 +0800 | [diff] [blame] | 1033 | vdev_id, channel, ch_width, forced); |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 1034 | } |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1035 | } |
| 1036 | #endif |
| 1037 | |
| 1038 | QDF_STATUS policy_mgr_wait_for_connection_update(struct wlan_objmgr_psoc *psoc) |
| 1039 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1040 | QDF_STATUS status; |
| 1041 | struct policy_mgr_psoc_priv_obj *policy_mgr_context; |
| 1042 | |
| 1043 | policy_mgr_context = policy_mgr_get_context(psoc); |
| 1044 | if (!policy_mgr_context) { |
| 1045 | policy_mgr_err("Invalid context"); |
| 1046 | return QDF_STATUS_E_FAILURE; |
| 1047 | } |
| 1048 | |
| 1049 | status = qdf_wait_single_event( |
| 1050 | &policy_mgr_context->connection_update_done_evt, |
| 1051 | CONNECTION_UPDATE_TIMEOUT); |
| 1052 | |
| 1053 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1054 | policy_mgr_err("wait for event failed"); |
| 1055 | return QDF_STATUS_E_FAILURE; |
| 1056 | } |
| 1057 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1058 | return QDF_STATUS_SUCCESS; |
| 1059 | } |
| 1060 | |
| 1061 | QDF_STATUS policy_mgr_reset_connection_update(struct wlan_objmgr_psoc *psoc) |
| 1062 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1063 | QDF_STATUS status; |
| 1064 | struct policy_mgr_psoc_priv_obj *policy_mgr_context; |
| 1065 | |
| 1066 | policy_mgr_context = policy_mgr_get_context(psoc); |
| 1067 | if (!policy_mgr_context) { |
| 1068 | policy_mgr_err("Invalid context"); |
| 1069 | return QDF_STATUS_E_FAILURE; |
| 1070 | } |
| 1071 | |
| 1072 | status = qdf_event_reset( |
| 1073 | &policy_mgr_context->connection_update_done_evt); |
| 1074 | |
| 1075 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1076 | policy_mgr_err("clear event failed"); |
| 1077 | return QDF_STATUS_E_FAILURE; |
| 1078 | } |
| 1079 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1080 | return QDF_STATUS_SUCCESS; |
| 1081 | } |
| 1082 | |
| 1083 | QDF_STATUS policy_mgr_set_connection_update(struct wlan_objmgr_psoc *psoc) |
| 1084 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1085 | QDF_STATUS status; |
| 1086 | struct policy_mgr_psoc_priv_obj *policy_mgr_context; |
| 1087 | |
| 1088 | policy_mgr_context = policy_mgr_get_context(psoc); |
| 1089 | if (!policy_mgr_context) { |
| 1090 | policy_mgr_err("Invalid context"); |
| 1091 | return QDF_STATUS_E_FAILURE; |
| 1092 | } |
| 1093 | |
| 1094 | status = qdf_event_set(&policy_mgr_context->connection_update_done_evt); |
| 1095 | |
| 1096 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1097 | policy_mgr_err("set event failed"); |
| 1098 | return QDF_STATUS_E_FAILURE; |
| 1099 | } |
| 1100 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1101 | return QDF_STATUS_SUCCESS; |
| 1102 | } |
| 1103 | |
Tushnim Bhattacharyya | 3b9ff37 | 2017-12-27 13:57:24 -0800 | [diff] [blame] | 1104 | QDF_STATUS policy_mgr_set_opportunistic_update(struct wlan_objmgr_psoc *psoc) |
| 1105 | { |
| 1106 | QDF_STATUS status; |
| 1107 | struct policy_mgr_psoc_priv_obj *policy_mgr_context; |
| 1108 | |
| 1109 | policy_mgr_context = policy_mgr_get_context(psoc); |
| 1110 | if (!policy_mgr_context) { |
| 1111 | policy_mgr_err("Invalid context"); |
| 1112 | return QDF_STATUS_E_FAILURE; |
| 1113 | } |
| 1114 | |
| 1115 | status = qdf_event_set( |
| 1116 | &policy_mgr_context->opportunistic_update_done_evt); |
| 1117 | |
| 1118 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1119 | policy_mgr_err("set event failed"); |
| 1120 | return QDF_STATUS_E_FAILURE; |
| 1121 | } |
| 1122 | |
| 1123 | return QDF_STATUS_SUCCESS; |
| 1124 | } |
| 1125 | |
Himanshu Agarwal | 70a52d9 | 2018-05-04 14:37:48 +0530 | [diff] [blame] | 1126 | QDF_STATUS policy_mgr_stop_opportunistic_timer(struct wlan_objmgr_psoc *psoc) |
| 1127 | { |
| 1128 | struct policy_mgr_psoc_priv_obj *policy_mgr_ctx; |
| 1129 | |
| 1130 | policy_mgr_ctx = policy_mgr_get_context(psoc); |
| 1131 | if (!policy_mgr_ctx) { |
| 1132 | policy_mgr_err("Invalid context"); |
| 1133 | return QDF_STATUS_E_FAILURE; |
| 1134 | } |
| 1135 | |
| 1136 | if (policy_mgr_ctx->dbs_opportunistic_timer.state != |
| 1137 | QDF_TIMER_STATE_RUNNING) |
| 1138 | return QDF_STATUS_SUCCESS; |
| 1139 | |
| 1140 | qdf_mc_timer_stop(&policy_mgr_ctx->dbs_opportunistic_timer); |
| 1141 | return QDF_STATUS_SUCCESS; |
| 1142 | } |
| 1143 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1144 | QDF_STATUS policy_mgr_restart_opportunistic_timer( |
| 1145 | struct wlan_objmgr_psoc *psoc, bool check_state) |
| 1146 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1147 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 1148 | struct policy_mgr_psoc_priv_obj *policy_mgr_ctx; |
| 1149 | |
| 1150 | policy_mgr_ctx = policy_mgr_get_context(psoc); |
| 1151 | if (!policy_mgr_ctx) { |
| 1152 | policy_mgr_err("Invalid context"); |
| 1153 | return status; |
| 1154 | } |
| 1155 | |
| 1156 | if (check_state && |
| 1157 | QDF_TIMER_STATE_RUNNING != |
| 1158 | policy_mgr_ctx->dbs_opportunistic_timer.state) |
| 1159 | return status; |
| 1160 | |
| 1161 | qdf_mc_timer_stop(&policy_mgr_ctx->dbs_opportunistic_timer); |
| 1162 | |
| 1163 | status = qdf_mc_timer_start( |
| 1164 | &policy_mgr_ctx->dbs_opportunistic_timer, |
| 1165 | DBS_OPPORTUNISTIC_TIME * 1000); |
| 1166 | |
| 1167 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1168 | policy_mgr_err("failed to start opportunistic timer"); |
| 1169 | return status; |
| 1170 | } |
| 1171 | |
| 1172 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1173 | } |
| 1174 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1175 | QDF_STATUS policy_mgr_set_hw_mode_on_channel_switch( |
| 1176 | struct wlan_objmgr_psoc *psoc, uint8_t session_id) |
| 1177 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1178 | QDF_STATUS status = QDF_STATUS_E_FAILURE, qdf_status; |
| 1179 | enum policy_mgr_conc_next_action action; |
| 1180 | |
| 1181 | if (!policy_mgr_is_hw_dbs_capable(psoc)) { |
| 1182 | policy_mgr_err("PM/DBS is disabled"); |
| 1183 | return status; |
| 1184 | } |
| 1185 | |
| 1186 | action = (*policy_mgr_get_current_pref_hw_mode_ptr)(psoc); |
| 1187 | if ((action != PM_DBS_DOWNGRADE) && |
| 1188 | (action != PM_SINGLE_MAC_UPGRADE)) { |
| 1189 | policy_mgr_err("Invalid action: %d", action); |
| 1190 | status = QDF_STATUS_SUCCESS; |
| 1191 | goto done; |
| 1192 | } |
| 1193 | |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1194 | policy_mgr_debug("action:%d session id:%d", action, session_id); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1195 | |
| 1196 | /* Opportunistic timer is started, PM will check if MCC upgrade can be |
| 1197 | * done on timer expiry. This avoids any possible ping pong effect |
| 1198 | * as well. |
| 1199 | */ |
| 1200 | if (action == PM_SINGLE_MAC_UPGRADE) { |
| 1201 | qdf_status = policy_mgr_restart_opportunistic_timer( |
| 1202 | psoc, false); |
| 1203 | if (QDF_IS_STATUS_SUCCESS(qdf_status)) |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1204 | policy_mgr_debug("opportunistic timer for MCC upgrade"); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1205 | goto done; |
| 1206 | } |
| 1207 | |
| 1208 | /* For DBS, we want to move right away to DBS mode */ |
| 1209 | status = policy_mgr_next_actions(psoc, session_id, action, |
| 1210 | POLICY_MGR_UPDATE_REASON_CHANNEL_SWITCH); |
| 1211 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1212 | policy_mgr_err("no set hw mode command was issued"); |
| 1213 | goto done; |
| 1214 | } |
| 1215 | done: |
| 1216 | /* success must be returned only when a set hw mode was done */ |
| 1217 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1218 | } |
| 1219 | |
| 1220 | void policy_mgr_checkn_update_hw_mode_single_mac_mode( |
| 1221 | struct wlan_objmgr_psoc *psoc, uint8_t channel) |
| 1222 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1223 | uint8_t i; |
| 1224 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1225 | |
| 1226 | pm_ctx = policy_mgr_get_context(psoc); |
| 1227 | if (!pm_ctx) { |
| 1228 | policy_mgr_err("Invalid Context"); |
| 1229 | return; |
| 1230 | } |
| 1231 | |
| 1232 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1233 | for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { |
| 1234 | if (pm_conc_connection_list[i].in_use) |
| 1235 | if (!WLAN_REG_IS_SAME_BAND_CHANNELS(channel, |
| 1236 | pm_conc_connection_list[i].chan)) { |
| 1237 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1238 | policy_mgr_debug("DBS required"); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1239 | return; |
| 1240 | } |
| 1241 | } |
| 1242 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1243 | |
| 1244 | if (QDF_TIMER_STATE_RUNNING == |
| 1245 | pm_ctx->dbs_opportunistic_timer.state) |
| 1246 | qdf_mc_timer_stop(&pm_ctx->dbs_opportunistic_timer); |
| 1247 | |
| 1248 | pm_dbs_opportunistic_timer_handler((void *)psoc); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1249 | } |
| 1250 | |
Tushnim Bhattacharyya | bdda582 | 2017-10-25 16:33:06 -0700 | [diff] [blame] | 1251 | void policy_mgr_check_and_stop_opportunistic_timer( |
Tushnim Bhattacharyya | 3b9ff37 | 2017-12-27 13:57:24 -0800 | [diff] [blame] | 1252 | struct wlan_objmgr_psoc *psoc, uint8_t id) |
Tushnim Bhattacharyya | bdda582 | 2017-10-25 16:33:06 -0700 | [diff] [blame] | 1253 | { |
| 1254 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
Tushnim Bhattacharyya | 3b9ff37 | 2017-12-27 13:57:24 -0800 | [diff] [blame] | 1255 | enum policy_mgr_conc_next_action action = PM_NOP; |
| 1256 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Tushnim Bhattacharyya | bdda582 | 2017-10-25 16:33:06 -0700 | [diff] [blame] | 1257 | |
| 1258 | pm_ctx = policy_mgr_get_context(psoc); |
| 1259 | if (!pm_ctx) { |
| 1260 | policy_mgr_err("Invalid Context"); |
| 1261 | return; |
| 1262 | } |
| 1263 | if (QDF_TIMER_STATE_RUNNING == |
| 1264 | pm_ctx->dbs_opportunistic_timer.state) { |
| 1265 | qdf_mc_timer_stop(&pm_ctx->dbs_opportunistic_timer); |
Tushnim Bhattacharyya | 3b9ff37 | 2017-12-27 13:57:24 -0800 | [diff] [blame] | 1266 | action = policy_mgr_need_opportunistic_upgrade(psoc); |
| 1267 | if (action) { |
Krunal Soni | 4943b90 | 2018-01-05 17:36:40 -0800 | [diff] [blame] | 1268 | qdf_event_reset(&pm_ctx->opportunistic_update_done_evt); |
Tushnim Bhattacharyya | 3b9ff37 | 2017-12-27 13:57:24 -0800 | [diff] [blame] | 1269 | status = policy_mgr_next_actions(psoc, id, action, |
| 1270 | POLICY_MGR_UPDATE_REASON_OPPORTUNISTIC); |
| 1271 | if (status != QDF_STATUS_SUCCESS) { |
| 1272 | policy_mgr_err("Failed in policy_mgr_next_actions"); |
| 1273 | return; |
| 1274 | } |
| 1275 | status = qdf_wait_single_event( |
| 1276 | &pm_ctx->opportunistic_update_done_evt, |
| 1277 | CONNECTION_UPDATE_TIMEOUT); |
| 1278 | |
| 1279 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1280 | policy_mgr_err("wait for event failed"); |
| 1281 | return; |
| 1282 | } |
| 1283 | } |
Tushnim Bhattacharyya | bdda582 | 2017-10-25 16:33:06 -0700 | [diff] [blame] | 1284 | } |
| 1285 | } |
| 1286 | |
Tushnim Bhattacharyya | e9c1e42 | 2017-03-13 10:27:10 -0700 | [diff] [blame] | 1287 | void policy_mgr_set_hw_mode_change_in_progress( |
| 1288 | struct wlan_objmgr_psoc *psoc, enum policy_mgr_hw_mode_change value) |
| 1289 | { |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 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 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1299 | pm_ctx->hw_mode_change_in_progress = value; |
| 1300 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1301 | |
| 1302 | policy_mgr_debug("hw_mode_change_in_progress:%d", value); |
Tushnim Bhattacharyya | e9c1e42 | 2017-03-13 10:27:10 -0700 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | enum policy_mgr_hw_mode_change policy_mgr_is_hw_mode_change_in_progress( |
| 1306 | struct wlan_objmgr_psoc *psoc) |
| 1307 | { |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 1308 | enum policy_mgr_hw_mode_change value; |
| 1309 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1310 | |
| 1311 | value = POLICY_MGR_HW_MODE_NOT_IN_PROGRESS; |
| 1312 | |
| 1313 | pm_ctx = policy_mgr_get_context(psoc); |
| 1314 | if (!pm_ctx) { |
| 1315 | policy_mgr_err("Invalid Context"); |
| 1316 | return value; |
| 1317 | } |
| 1318 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1319 | value = pm_ctx->hw_mode_change_in_progress; |
| 1320 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1321 | |
| 1322 | return value; |
Tushnim Bhattacharyya | e9c1e42 | 2017-03-13 10:27:10 -0700 | [diff] [blame] | 1323 | } |
| 1324 | |
| 1325 | enum policy_mgr_hw_mode_change policy_mgr_get_hw_mode_change_from_hw_mode_index( |
| 1326 | struct wlan_objmgr_psoc *psoc, uint32_t hw_mode_index) |
| 1327 | { |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 1328 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1329 | uint32_t param = 0; |
| 1330 | enum policy_mgr_hw_mode_change value |
| 1331 | = POLICY_MGR_HW_MODE_NOT_IN_PROGRESS; |
| 1332 | |
| 1333 | pm_ctx = policy_mgr_get_context(psoc); |
| 1334 | if (!pm_ctx) { |
| 1335 | policy_mgr_err("Invalid Context"); |
| 1336 | return value; |
| 1337 | } |
| 1338 | |
| 1339 | policy_mgr_info("HW param: %x", param); |
| 1340 | param = pm_ctx->hw_mode.hw_mode_list[hw_mode_index]; |
| 1341 | if (POLICY_MGR_HW_MODE_DBS_MODE_GET(param)) { |
| 1342 | policy_mgr_info("DBS is requested with HW (%d)", |
| 1343 | hw_mode_index); |
| 1344 | value = POLICY_MGR_DBS_IN_PROGRESS; |
| 1345 | goto ret_value; |
| 1346 | } |
| 1347 | |
| 1348 | if (POLICY_MGR_HW_MODE_SBS_MODE_GET(param)) { |
| 1349 | policy_mgr_info("SBS is requested with HW (%d)", |
| 1350 | hw_mode_index); |
| 1351 | value = POLICY_MGR_SBS_IN_PROGRESS; |
| 1352 | goto ret_value; |
| 1353 | } |
| 1354 | |
| 1355 | value = POLICY_MGR_SMM_IN_PROGRESS; |
| 1356 | policy_mgr_info("SMM is requested with HW (%d)", hw_mode_index); |
| 1357 | |
| 1358 | ret_value: |
| 1359 | return value; |
Tushnim Bhattacharyya | e9c1e42 | 2017-03-13 10:27:10 -0700 | [diff] [blame] | 1360 | } |
| 1361 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1362 | #ifdef MPC_UT_FRAMEWORK |
| 1363 | QDF_STATUS policy_mgr_update_connection_info_utfw( |
| 1364 | struct wlan_objmgr_psoc *psoc, |
| 1365 | uint32_t vdev_id, uint32_t tx_streams, uint32_t rx_streams, |
| 1366 | uint32_t chain_mask, uint32_t type, uint32_t sub_type, |
| 1367 | uint32_t channelid, uint32_t mac_id) |
| 1368 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1369 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 1370 | uint32_t conn_index = 0, found = 0; |
| 1371 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1372 | |
| 1373 | pm_ctx = policy_mgr_get_context(psoc); |
| 1374 | if (!pm_ctx) { |
| 1375 | policy_mgr_err("Invalid Context"); |
| 1376 | return status; |
| 1377 | } |
| 1378 | |
| 1379 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1380 | while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { |
| 1381 | if (vdev_id == pm_conc_connection_list[conn_index].vdev_id) { |
| 1382 | /* debug msg */ |
| 1383 | found = 1; |
| 1384 | break; |
| 1385 | } |
| 1386 | conn_index++; |
| 1387 | } |
| 1388 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1389 | if (!found) { |
| 1390 | /* err msg */ |
| 1391 | policy_mgr_err("can't find vdev_id %d in pm_conc_connection_list", |
| 1392 | vdev_id); |
| 1393 | return status; |
| 1394 | } |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1395 | policy_mgr_debug("--> updating entry at index[%d]", conn_index); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1396 | |
| 1397 | policy_mgr_update_conc_list(psoc, conn_index, |
| 1398 | policy_mgr_get_mode(type, sub_type), |
| 1399 | channelid, HW_MODE_20_MHZ, |
| 1400 | mac_id, chain_mask, 0, vdev_id, true); |
| 1401 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1402 | return QDF_STATUS_SUCCESS; |
| 1403 | } |
| 1404 | |
| 1405 | QDF_STATUS policy_mgr_incr_connection_count_utfw(struct wlan_objmgr_psoc *psoc, |
| 1406 | uint32_t vdev_id, uint32_t tx_streams, uint32_t rx_streams, |
| 1407 | uint32_t chain_mask, uint32_t type, uint32_t sub_type, |
| 1408 | uint32_t channelid, uint32_t mac_id) |
| 1409 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1410 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 1411 | uint32_t conn_index = 0; |
| 1412 | |
| 1413 | conn_index = policy_mgr_get_connection_count(psoc); |
| 1414 | if (MAX_NUMBER_OF_CONC_CONNECTIONS <= conn_index) { |
| 1415 | /* err msg */ |
| 1416 | policy_mgr_err("exceeded max connection limit %d", |
| 1417 | MAX_NUMBER_OF_CONC_CONNECTIONS); |
| 1418 | return status; |
| 1419 | } |
Tushnim Bhattacharyya | 8b60ebb | 2017-08-17 14:53:07 -0700 | [diff] [blame] | 1420 | policy_mgr_debug("--> filling entry at index[%d]", conn_index); |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1421 | |
| 1422 | policy_mgr_update_conc_list(psoc, conn_index, |
| 1423 | policy_mgr_get_mode(type, sub_type), |
| 1424 | channelid, HW_MODE_20_MHZ, |
| 1425 | mac_id, chain_mask, 0, vdev_id, true); |
| 1426 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1427 | return QDF_STATUS_SUCCESS; |
| 1428 | } |
| 1429 | |
| 1430 | QDF_STATUS policy_mgr_decr_connection_count_utfw(struct wlan_objmgr_psoc *psoc, |
| 1431 | uint32_t del_all, uint32_t vdev_id) |
| 1432 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1433 | QDF_STATUS status; |
| 1434 | |
| 1435 | if (del_all) { |
| 1436 | status = policy_mgr_psoc_enable(psoc); |
| 1437 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1438 | policy_mgr_err("Policy manager initialization failed"); |
| 1439 | return QDF_STATUS_E_FAILURE; |
| 1440 | } |
| 1441 | } else { |
| 1442 | policy_mgr_decr_connection_count(psoc, vdev_id); |
| 1443 | } |
| 1444 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1445 | return QDF_STATUS_SUCCESS; |
| 1446 | } |
| 1447 | |
| 1448 | enum policy_mgr_pcl_type policy_mgr_get_pcl_from_first_conn_table( |
| 1449 | enum policy_mgr_con_mode type, |
| 1450 | enum policy_mgr_conc_priority_mode sys_pref) |
| 1451 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1452 | if ((sys_pref >= PM_MAX_CONC_PRIORITY_MODE) || |
| 1453 | (type >= PM_MAX_NUM_OF_MODE)) |
| 1454 | return PM_MAX_PCL_TYPE; |
| 1455 | return first_connection_pcl_table[type][sys_pref]; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1456 | } |
| 1457 | |
| 1458 | enum policy_mgr_pcl_type policy_mgr_get_pcl_from_second_conn_table( |
| 1459 | enum policy_mgr_one_connection_mode idx, enum policy_mgr_con_mode type, |
| 1460 | enum policy_mgr_conc_priority_mode sys_pref, uint8_t dbs_capable) |
| 1461 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1462 | if ((idx >= PM_MAX_ONE_CONNECTION_MODE) || |
| 1463 | (sys_pref >= PM_MAX_CONC_PRIORITY_MODE) || |
| 1464 | (type >= PM_MAX_NUM_OF_MODE)) |
| 1465 | return PM_MAX_PCL_TYPE; |
| 1466 | if (dbs_capable) |
| 1467 | return (*second_connection_pcl_dbs_table)[idx][type][sys_pref]; |
| 1468 | else |
| 1469 | return second_connection_pcl_nodbs_table[idx][type][sys_pref]; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1470 | } |
| 1471 | |
| 1472 | enum policy_mgr_pcl_type policy_mgr_get_pcl_from_third_conn_table( |
| 1473 | enum policy_mgr_two_connection_mode idx, enum policy_mgr_con_mode type, |
| 1474 | enum policy_mgr_conc_priority_mode sys_pref, uint8_t dbs_capable) |
| 1475 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1476 | if ((idx >= PM_MAX_TWO_CONNECTION_MODE) || |
| 1477 | (sys_pref >= PM_MAX_CONC_PRIORITY_MODE) || |
| 1478 | (type >= PM_MAX_NUM_OF_MODE)) |
| 1479 | return PM_MAX_PCL_TYPE; |
| 1480 | if (dbs_capable) |
| 1481 | return (*third_connection_pcl_dbs_table)[idx][type][sys_pref]; |
| 1482 | else |
| 1483 | return third_connection_pcl_nodbs_table[idx][type][sys_pref]; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1484 | } |
| 1485 | #endif |