Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wlan_policy_mgr_action.c |
| 30 | * |
| 31 | * WLAN Concurrenct Connection Management APIs |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | /* Include files */ |
| 36 | |
| 37 | #include "wlan_policy_mgr_api.h" |
| 38 | #include "wlan_policy_mgr_tables_no_dbs_i.h" |
| 39 | #include "wlan_policy_mgr_i.h" |
| 40 | #include "qdf_types.h" |
| 41 | #include "qdf_trace.h" |
| 42 | #include "wlan_objmgr_global_obj.h" |
| 43 | |
| 44 | enum policy_mgr_conc_next_action (*policy_mgr_get_current_pref_hw_mode_ptr) |
| 45 | (struct wlan_objmgr_psoc *psoc); |
| 46 | |
| 47 | void policy_mgr_hw_mode_transition_cb(uint32_t old_hw_mode_index, |
| 48 | uint32_t new_hw_mode_index, |
| 49 | uint32_t num_vdev_mac_entries, |
| 50 | struct policy_mgr_vdev_mac_map *vdev_mac_map, |
| 51 | struct wlan_objmgr_psoc *context) |
| 52 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 53 | QDF_STATUS status; |
| 54 | struct policy_mgr_hw_mode_params hw_mode; |
| 55 | uint32_t i; |
| 56 | |
| 57 | if (!vdev_mac_map) { |
| 58 | policy_mgr_err("vdev_mac_map is NULL"); |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | policy_mgr_notice("old_hw_mode_index=%d, new_hw_mode_index=%d", |
| 63 | old_hw_mode_index, new_hw_mode_index); |
| 64 | |
| 65 | for (i = 0; i < num_vdev_mac_entries; i++) |
| 66 | policy_mgr_notice("vdev_id:%d mac_id:%d", |
| 67 | vdev_mac_map[i].vdev_id, |
| 68 | vdev_mac_map[i].mac_id); |
| 69 | |
| 70 | status = policy_mgr_get_hw_mode_from_idx(context, |
| 71 | new_hw_mode_index, &hw_mode); |
| 72 | if (status != QDF_STATUS_SUCCESS) { |
| 73 | policy_mgr_err("Get HW mode failed: %d", status); |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | policy_mgr_notice("MAC0: TxSS:%d, RxSS:%d, Bw:%d", |
| 78 | hw_mode.mac0_tx_ss, hw_mode.mac0_rx_ss, hw_mode.mac0_bw); |
| 79 | policy_mgr_notice("MAC1: TxSS:%d, RxSS:%d, Bw:%d", |
| 80 | hw_mode.mac1_tx_ss, hw_mode.mac1_rx_ss, hw_mode.mac1_bw); |
| 81 | policy_mgr_notice("DBS:%d, Agile DFS:%d, SBS:%d", |
| 82 | hw_mode.dbs_cap, hw_mode.agile_dfs_cap, hw_mode.sbs_cap); |
| 83 | |
| 84 | /* update pm_conc_connection_list */ |
| 85 | policy_mgr_update_hw_mode_conn_info(context, num_vdev_mac_entries, |
| 86 | vdev_mac_map, |
| 87 | hw_mode); |
| 88 | |
| 89 | return; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | QDF_STATUS policy_mgr_pdev_set_hw_mode(struct wlan_objmgr_psoc *psoc, |
| 93 | uint32_t session_id, |
| 94 | enum hw_mode_ss_config mac0_ss, |
| 95 | enum hw_mode_bandwidth mac0_bw, |
| 96 | enum hw_mode_ss_config mac1_ss, |
| 97 | enum hw_mode_bandwidth mac1_bw, |
| 98 | enum hw_mode_dbs_capab dbs, |
| 99 | enum hw_mode_agile_dfs_capab dfs, |
| 100 | enum hw_mode_sbs_capab sbs, |
| 101 | enum policy_mgr_conn_update_reason reason) |
| 102 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 103 | int8_t hw_mode_index; |
| 104 | struct policy_mgr_hw_mode msg; |
| 105 | QDF_STATUS status; |
| 106 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 107 | |
| 108 | pm_ctx = policy_mgr_get_context(psoc); |
| 109 | if (!pm_ctx) { |
| 110 | policy_mgr_err("Invalid context"); |
| 111 | return QDF_STATUS_E_FAILURE; |
| 112 | } |
| 113 | |
| 114 | /* |
| 115 | * if HW is not capable of doing 2x2 or ini config disabled 2x2, don't |
| 116 | * allow to request FW for 2x2 |
| 117 | */ |
Tushnim Bhattacharyya | 68f709d | 2017-03-23 18:00:04 -0700 | [diff] [blame] | 118 | if ((HW_MODE_SS_2x2 == mac0_ss) && (!pm_ctx->user_cfg.enable2x2)) { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 119 | policy_mgr_notice("2x2 is not allowed downgrading to 1x1 for mac0"); |
| 120 | mac0_ss = HW_MODE_SS_1x1; |
| 121 | } |
Tushnim Bhattacharyya | 68f709d | 2017-03-23 18:00:04 -0700 | [diff] [blame] | 122 | if ((HW_MODE_SS_2x2 == mac1_ss) && (!pm_ctx->user_cfg.enable2x2)) { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 123 | policy_mgr_notice("2x2 is not allowed downgrading to 1x1 for mac1"); |
| 124 | mac1_ss = HW_MODE_SS_1x1; |
| 125 | } |
| 126 | |
| 127 | hw_mode_index = policy_mgr_get_hw_mode_idx_from_dbs_hw_list(psoc, |
| 128 | mac0_ss, mac0_bw, mac1_ss, mac1_bw, dbs, dfs, sbs); |
| 129 | if (hw_mode_index < 0) { |
| 130 | policy_mgr_err("Invalid HW mode index obtained"); |
| 131 | return QDF_STATUS_E_FAILURE; |
| 132 | } |
| 133 | |
| 134 | msg.hw_mode_index = hw_mode_index; |
| 135 | msg.set_hw_mode_cb = (void *)policy_mgr_pdev_set_hw_mode_cb; |
| 136 | msg.reason = reason; |
| 137 | msg.session_id = session_id; |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 138 | msg.context = psoc; |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 139 | |
| 140 | policy_mgr_notice("set hw mode to sme: hw_mode_index: %d session:%d reason:%d", |
| 141 | msg.hw_mode_index, msg.session_id, msg.reason); |
| 142 | |
| 143 | status = pm_ctx->sme_cbacks.sme_pdev_set_hw_mode(msg); |
| 144 | if (status != QDF_STATUS_SUCCESS) { |
| 145 | policy_mgr_err("Failed to set hw mode to SME"); |
| 146 | return status; |
| 147 | } |
| 148 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 149 | return QDF_STATUS_SUCCESS; |
| 150 | } |
| 151 | |
| 152 | enum policy_mgr_conc_next_action policy_mgr_need_opportunistic_upgrade( |
| 153 | struct wlan_objmgr_psoc *psoc) |
| 154 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 155 | uint32_t conn_index; |
| 156 | enum policy_mgr_conc_next_action upgrade = PM_NOP; |
| 157 | uint8_t mac = 0; |
| 158 | struct policy_mgr_hw_mode_params hw_mode; |
| 159 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 160 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 161 | |
| 162 | pm_ctx = policy_mgr_get_context(psoc); |
| 163 | if (!pm_ctx) { |
| 164 | policy_mgr_err("Invalid Context"); |
| 165 | goto done; |
| 166 | } |
| 167 | |
| 168 | if (policy_mgr_is_hw_dbs_capable(psoc) == false) { |
| 169 | policy_mgr_err("driver isn't dbs capable, no further action needed"); |
| 170 | goto done; |
| 171 | } |
| 172 | |
| 173 | status = policy_mgr_get_current_hw_mode(psoc, &hw_mode); |
| 174 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 175 | policy_mgr_err("policy_mgr_get_current_hw_mode failed"); |
| 176 | goto done; |
| 177 | } |
| 178 | if (!hw_mode.dbs_cap) { |
| 179 | policy_mgr_notice("current HW mode is non-DBS capable"); |
| 180 | goto done; |
| 181 | } |
| 182 | |
| 183 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 184 | /* Are both mac's still in use */ |
| 185 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 186 | conn_index++) { |
| 187 | policy_mgr_debug("index:%d mac:%d in_use:%d chan:%d org_nss:%d", |
| 188 | conn_index, |
| 189 | pm_conc_connection_list[conn_index].mac, |
| 190 | pm_conc_connection_list[conn_index].in_use, |
| 191 | pm_conc_connection_list[conn_index].chan, |
| 192 | pm_conc_connection_list[conn_index].original_nss); |
| 193 | if ((pm_conc_connection_list[conn_index].mac == 0) && |
| 194 | pm_conc_connection_list[conn_index].in_use) { |
| 195 | mac |= POLICY_MGR_MAC0; |
| 196 | if (POLICY_MGR_MAC0_AND_MAC1 == mac) { |
| 197 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 198 | goto done; |
| 199 | } |
| 200 | } else if ((pm_conc_connection_list[conn_index].mac == 1) && |
| 201 | pm_conc_connection_list[conn_index].in_use) { |
| 202 | mac |= POLICY_MGR_MAC1; |
| 203 | if (POLICY_MGR_MAC0_AND_MAC1 == mac) { |
| 204 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 205 | goto done; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | /* Let's request for single MAC mode */ |
| 210 | upgrade = PM_SINGLE_MAC; |
| 211 | /* Is there any connection had an initial connection with 2x2 */ |
| 212 | for (conn_index = 0; conn_index < MAX_NUMBER_OF_CONC_CONNECTIONS; |
| 213 | conn_index++) { |
| 214 | if ((pm_conc_connection_list[conn_index].original_nss == 2) && |
| 215 | pm_conc_connection_list[conn_index].in_use) { |
| 216 | upgrade = PM_SINGLE_MAC_UPGRADE; |
| 217 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 218 | goto done; |
| 219 | } |
| 220 | } |
| 221 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 222 | |
| 223 | done: |
| 224 | return upgrade; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | QDF_STATUS policy_mgr_update_connection_info(struct wlan_objmgr_psoc *psoc, |
| 228 | uint32_t vdev_id) |
| 229 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 230 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 231 | uint32_t conn_index = 0; |
| 232 | bool found = false; |
| 233 | struct policy_mgr_vdev_entry_info conn_table_entry; |
| 234 | enum policy_mgr_chain_mode chain_mask = POLICY_MGR_ONE_ONE; |
| 235 | uint8_t nss_2g, nss_5g; |
| 236 | enum policy_mgr_con_mode mode; |
| 237 | uint8_t chan; |
| 238 | uint32_t nss = 0; |
| 239 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 240 | |
| 241 | pm_ctx = policy_mgr_get_context(psoc); |
| 242 | if (!pm_ctx) { |
| 243 | policy_mgr_err("Invalid Context"); |
| 244 | return status; |
| 245 | } |
| 246 | |
| 247 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 248 | while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { |
| 249 | if (vdev_id == pm_conc_connection_list[conn_index].vdev_id) { |
| 250 | /* debug msg */ |
| 251 | found = true; |
| 252 | break; |
| 253 | } |
| 254 | conn_index++; |
| 255 | } |
| 256 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 257 | if (!found) { |
| 258 | /* err msg */ |
| 259 | policy_mgr_err("can't find vdev_id %d in pm_conc_connection_list", |
| 260 | vdev_id); |
| 261 | return status; |
| 262 | } |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame^] | 263 | if (pm_ctx->wma_cbacks.wma_get_connection_info) { |
| 264 | status = pm_ctx->wma_cbacks.wma_get_connection_info( |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 265 | vdev_id, &conn_table_entry); |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame^] | 266 | if (QDF_STATUS_SUCCESS != status) { |
| 267 | policy_mgr_err("can't find vdev_id %d in connection table", |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 268 | vdev_id); |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame^] | 269 | return status; |
| 270 | } |
| 271 | } else { |
| 272 | policy_mgr_err("wma_get_connection_info is NULL"); |
| 273 | return QDF_STATUS_E_FAILURE; |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 274 | } |
Tushnim Bhattacharyya | 00ccf11 | 2017-03-28 10:45:08 -0700 | [diff] [blame^] | 275 | |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 276 | mode = policy_mgr_get_mode(conn_table_entry.type, |
| 277 | conn_table_entry.sub_type); |
| 278 | chan = reg_freq_to_chan(conn_table_entry.mhz); |
| 279 | status = policy_mgr_get_nss_for_vdev(psoc, mode, &nss_2g, &nss_5g); |
| 280 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 281 | if ((WLAN_REG_IS_24GHZ_CH(chan) && (nss_2g > 1)) || |
| 282 | (WLAN_REG_IS_5GHZ_CH(chan) && (nss_5g > 1))) |
| 283 | chain_mask = POLICY_MGR_TWO_TWO; |
| 284 | else |
| 285 | chain_mask = POLICY_MGR_ONE_ONE; |
| 286 | nss = (WLAN_REG_IS_24GHZ_CH(chan)) ? nss_2g : nss_5g; |
| 287 | } else { |
| 288 | policy_mgr_err("Error in getting nss"); |
| 289 | } |
| 290 | |
| 291 | policy_mgr_debug("update PM connection table for vdev:%d", vdev_id); |
| 292 | |
| 293 | /* add the entry */ |
| 294 | policy_mgr_update_conc_list(psoc, conn_index, |
| 295 | mode, |
| 296 | chan, |
| 297 | policy_mgr_get_bw(conn_table_entry.chan_width), |
| 298 | conn_table_entry.mac_id, |
| 299 | chain_mask, |
| 300 | nss, vdev_id, true); |
| 301 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 302 | return QDF_STATUS_SUCCESS; |
| 303 | } |
| 304 | |
| 305 | QDF_STATUS policy_mgr_update_and_wait_for_connection_update( |
| 306 | struct wlan_objmgr_psoc *psoc, |
| 307 | uint8_t session_id, |
| 308 | uint8_t channel, |
| 309 | enum policy_mgr_conn_update_reason reason) |
| 310 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 311 | QDF_STATUS status; |
| 312 | |
| 313 | policy_mgr_debug("session:%d channel:%d reason:%d", |
| 314 | session_id, channel, reason); |
| 315 | |
| 316 | status = policy_mgr_reset_connection_update(psoc); |
| 317 | if (QDF_IS_STATUS_ERROR(status)) |
| 318 | policy_mgr_err("clearing event failed"); |
| 319 | |
| 320 | status = policy_mgr_current_connections_update(psoc, |
| 321 | session_id, channel, reason); |
| 322 | if (QDF_STATUS_E_FAILURE == status) { |
| 323 | policy_mgr_err("connections update failed"); |
| 324 | return QDF_STATUS_E_FAILURE; |
| 325 | } |
| 326 | |
| 327 | /* Wait only when status is success */ |
| 328 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 329 | status = policy_mgr_wait_for_connection_update(psoc); |
| 330 | if (QDF_IS_STATUS_ERROR(status)) { |
| 331 | policy_mgr_err("qdf wait for event failed"); |
| 332 | return QDF_STATUS_E_FAILURE; |
| 333 | } |
| 334 | } |
| 335 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 336 | return QDF_STATUS_SUCCESS; |
| 337 | } |
| 338 | |
| 339 | QDF_STATUS policy_mgr_current_connections_update(struct wlan_objmgr_psoc *psoc, |
| 340 | uint32_t session_id, |
| 341 | uint8_t channel, |
| 342 | enum policy_mgr_conn_update_reason reason) |
| 343 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 344 | enum policy_mgr_conc_next_action next_action = PM_NOP; |
| 345 | uint32_t num_connections = 0; |
| 346 | enum policy_mgr_one_connection_mode second_index = 0; |
| 347 | enum policy_mgr_two_connection_mode third_index = 0; |
| 348 | enum policy_mgr_band band; |
| 349 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 350 | |
| 351 | if (policy_mgr_is_hw_dbs_capable(psoc) == false) { |
| 352 | policy_mgr_err("driver isn't dbs capable, no further action needed"); |
| 353 | return QDF_STATUS_E_NOSUPPORT; |
| 354 | } |
| 355 | if (WLAN_REG_IS_24GHZ_CH(channel)) |
| 356 | band = POLICY_MGR_BAND_24; |
| 357 | else |
| 358 | band = POLICY_MGR_BAND_5; |
| 359 | |
| 360 | num_connections = policy_mgr_get_connection_count(psoc); |
| 361 | |
| 362 | policy_mgr_debug("num_connections=%d channel=%d", |
| 363 | num_connections, channel); |
| 364 | |
| 365 | switch (num_connections) { |
| 366 | case 0: |
| 367 | if (band == POLICY_MGR_BAND_24) |
| 368 | if (policy_mgr_is_hw_dbs_2x2_capable(psoc)) |
| 369 | next_action = PM_DBS; |
| 370 | else |
| 371 | next_action = PM_NOP; |
| 372 | else |
| 373 | next_action = PM_NOP; |
| 374 | break; |
| 375 | case 1: |
| 376 | second_index = |
| 377 | policy_mgr_get_second_connection_pcl_table_index(psoc); |
| 378 | if (PM_MAX_ONE_CONNECTION_MODE == second_index) { |
| 379 | policy_mgr_err( |
| 380 | "couldn't find index for 2nd connection next action table"); |
| 381 | goto done; |
| 382 | } |
| 383 | next_action = |
| 384 | (*next_action_two_connection_table)[second_index][band]; |
| 385 | break; |
| 386 | case 2: |
| 387 | third_index = |
| 388 | policy_mgr_get_third_connection_pcl_table_index(psoc); |
| 389 | if (PM_MAX_TWO_CONNECTION_MODE == third_index) { |
| 390 | policy_mgr_err( |
| 391 | "couldn't find index for 3rd connection next action table"); |
| 392 | goto done; |
| 393 | } |
| 394 | next_action = (*next_action_three_connection_table) |
| 395 | [third_index][band]; |
| 396 | break; |
| 397 | default: |
| 398 | policy_mgr_err("unexpected num_connections value %d", |
| 399 | num_connections); |
| 400 | break; |
| 401 | } |
| 402 | |
| 403 | if (PM_NOP != next_action) |
| 404 | status = policy_mgr_next_actions(psoc, session_id, |
| 405 | next_action, reason); |
| 406 | else |
| 407 | status = QDF_STATUS_E_NOSUPPORT; |
| 408 | |
| 409 | policy_mgr_debug( |
| 410 | "idx2=%d idx3=%d next_action=%d, band=%d status=%d reason=%d session_id=%d", |
| 411 | second_index, third_index, next_action, band, status, |
| 412 | reason, session_id); |
| 413 | |
| 414 | done: |
| 415 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | QDF_STATUS policy_mgr_next_actions(struct wlan_objmgr_psoc *psoc, |
| 419 | uint32_t session_id, |
| 420 | enum policy_mgr_conc_next_action action, |
| 421 | enum policy_mgr_conn_update_reason reason) |
| 422 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 423 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 424 | struct policy_mgr_hw_mode_params hw_mode; |
| 425 | |
| 426 | if (policy_mgr_is_hw_dbs_capable(psoc) == false) { |
| 427 | policy_mgr_err("driver isn't dbs capable, no further action needed"); |
| 428 | return QDF_STATUS_E_NOSUPPORT; |
| 429 | } |
| 430 | |
| 431 | /* check for the current HW index to see if really need any action */ |
| 432 | status = policy_mgr_get_current_hw_mode(psoc, &hw_mode); |
| 433 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 434 | policy_mgr_err("policy_mgr_get_current_hw_mode failed"); |
| 435 | return status; |
| 436 | } |
| 437 | /** |
| 438 | * if already in DBS no need to request DBS. Might be needed |
| 439 | * to extend the logic when multiple dbs HW mode is available |
| 440 | */ |
| 441 | if ((((PM_DBS_DOWNGRADE == action) || (PM_DBS == action) || |
| 442 | (PM_DBS_UPGRADE == action)) |
| 443 | && hw_mode.dbs_cap)) { |
| 444 | policy_mgr_err("driver is already in %s mode, no further action needed", |
| 445 | (hw_mode.dbs_cap) ? "dbs" : "non dbs"); |
| 446 | return QDF_STATUS_E_ALREADY; |
| 447 | } |
| 448 | |
| 449 | if ((PM_SBS == action) || (action == PM_SBS_DOWNGRADE)) { |
| 450 | if (!policy_mgr_is_hw_sbs_capable(psoc)) { |
| 451 | /* No action */ |
| 452 | policy_mgr_notice("firmware is not sbs capable"); |
| 453 | return QDF_STATUS_SUCCESS; |
| 454 | } |
| 455 | /* check if current mode is already SBS nothing to be |
| 456 | * done |
| 457 | */ |
| 458 | |
| 459 | } |
| 460 | |
| 461 | switch (action) { |
| 462 | case PM_DBS_DOWNGRADE: |
| 463 | /* |
| 464 | * check if we have a beaconing entity that is using 2x2. If yes, |
| 465 | * update the beacon template & notify FW. Once FW confirms |
| 466 | * beacon updated, send down the HW mode change req |
| 467 | */ |
| 468 | status = policy_mgr_complete_action(psoc, POLICY_MGR_RX_NSS_1, |
| 469 | PM_DBS, reason, session_id); |
| 470 | break; |
| 471 | case PM_DBS: |
| 472 | if (policy_mgr_is_hw_dbs_2x2_capable(psoc)) |
| 473 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 474 | HW_MODE_SS_2x2, |
| 475 | HW_MODE_80_MHZ, |
| 476 | HW_MODE_SS_2x2, HW_MODE_40_MHZ, |
| 477 | HW_MODE_DBS, |
| 478 | HW_MODE_AGILE_DFS_NONE, |
| 479 | HW_MODE_SBS_NONE, |
| 480 | reason); |
| 481 | else |
| 482 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 483 | HW_MODE_SS_1x1, |
| 484 | HW_MODE_80_MHZ, |
| 485 | HW_MODE_SS_1x1, HW_MODE_40_MHZ, |
| 486 | HW_MODE_DBS, |
| 487 | HW_MODE_AGILE_DFS_NONE, |
| 488 | HW_MODE_SBS_NONE, |
| 489 | reason); |
| 490 | break; |
| 491 | case PM_SINGLE_MAC_UPGRADE: |
| 492 | /* |
| 493 | * change the HW mode first before the NSS upgrade |
| 494 | */ |
| 495 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 496 | HW_MODE_SS_2x2, |
| 497 | HW_MODE_80_MHZ, |
| 498 | HW_MODE_SS_0x0, HW_MODE_BW_NONE, |
| 499 | HW_MODE_DBS_NONE, |
| 500 | HW_MODE_AGILE_DFS_NONE, |
| 501 | HW_MODE_SBS_NONE, |
| 502 | reason); |
| 503 | /* |
| 504 | * check if we have a beaconing entity that advertised 2x2 |
| 505 | * intially. If yes, update the beacon template & notify FW. |
| 506 | * Once FW confirms beacon updated, send the HW mode change req |
| 507 | */ |
| 508 | status = policy_mgr_complete_action(psoc, POLICY_MGR_RX_NSS_2, |
| 509 | PM_SINGLE_MAC, reason, session_id); |
| 510 | break; |
| 511 | case PM_SINGLE_MAC: |
| 512 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 513 | HW_MODE_SS_2x2, |
| 514 | HW_MODE_80_MHZ, |
| 515 | HW_MODE_SS_0x0, HW_MODE_BW_NONE, |
| 516 | HW_MODE_DBS_NONE, |
| 517 | HW_MODE_AGILE_DFS_NONE, |
| 518 | HW_MODE_SBS_NONE, |
| 519 | reason); |
| 520 | break; |
| 521 | case PM_DBS_UPGRADE: |
| 522 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 523 | HW_MODE_SS_2x2, |
| 524 | HW_MODE_80_MHZ, |
| 525 | HW_MODE_SS_2x2, HW_MODE_80_MHZ, |
| 526 | HW_MODE_DBS, |
| 527 | HW_MODE_AGILE_DFS_NONE, |
| 528 | HW_MODE_SBS_NONE, |
| 529 | reason); |
| 530 | |
| 531 | status = policy_mgr_complete_action(psoc, POLICY_MGR_RX_NSS_2, |
| 532 | PM_DBS, reason, session_id); |
| 533 | break; |
| 534 | case PM_SBS_DOWNGRADE: |
| 535 | status = policy_mgr_complete_action(psoc, POLICY_MGR_RX_NSS_1, |
| 536 | PM_SBS, reason, session_id); |
| 537 | break; |
| 538 | case PM_SBS: |
| 539 | status = policy_mgr_pdev_set_hw_mode(psoc, session_id, |
| 540 | HW_MODE_SS_1x1, |
| 541 | HW_MODE_80_MHZ, |
| 542 | HW_MODE_SS_1x1, HW_MODE_80_MHZ, |
| 543 | HW_MODE_DBS, |
| 544 | HW_MODE_AGILE_DFS_NONE, |
| 545 | HW_MODE_SBS, |
| 546 | reason); |
| 547 | break; |
| 548 | default: |
| 549 | policy_mgr_err("unexpected action value %d", action); |
| 550 | status = QDF_STATUS_E_FAILURE; |
| 551 | break; |
| 552 | } |
| 553 | |
| 554 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | QDF_STATUS policy_mgr_handle_conc_multiport(struct wlan_objmgr_psoc *psoc, |
| 558 | uint8_t session_id, uint8_t channel) |
| 559 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 560 | QDF_STATUS status; |
| 561 | |
| 562 | if (!policy_mgr_check_for_session_conc(psoc, session_id, channel)) { |
| 563 | policy_mgr_err("Conc not allowed for the session %d", |
| 564 | session_id); |
| 565 | return QDF_STATUS_E_FAILURE; |
| 566 | } |
| 567 | |
| 568 | status = policy_mgr_reset_connection_update(psoc); |
| 569 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 570 | policy_mgr_err("clearing event failed"); |
| 571 | |
| 572 | status = policy_mgr_current_connections_update(psoc, session_id, |
| 573 | channel, |
| 574 | POLICY_MGR_UPDATE_REASON_NORMAL_STA); |
| 575 | if (QDF_STATUS_E_FAILURE == status) { |
| 576 | policy_mgr_err("connections update failed"); |
| 577 | return status; |
| 578 | } |
| 579 | |
| 580 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 584 | /** |
| 585 | * policy_mgr_is_restart_sap_allowed() - Check if restart SAP |
| 586 | * allowed during SCC -> MCC switch |
| 587 | * @psoc: PSOC object data |
| 588 | * @mcc_to_scc_switch: MCC to SCC switch enabled user config |
| 589 | * |
| 590 | * Check if restart SAP allowed during SCC->MCC switch |
| 591 | * |
| 592 | * Restart: true or false |
| 593 | */ |
| 594 | static bool policy_mgr_is_restart_sap_allowed( |
| 595 | struct wlan_objmgr_psoc *psoc, |
| 596 | uint32_t mcc_to_scc_switch) |
| 597 | { |
| 598 | if ((mcc_to_scc_switch == QDF_MCC_TO_SCC_SWITCH_DISABLE) || |
| 599 | !(policy_mgr_concurrent_open_sessions_running(psoc) && |
| 600 | (policy_mgr_get_concurrency_mode(psoc) == |
| 601 | (QDF_STA_MASK | QDF_SAP_MASK)))) { |
| 602 | policy_mgr_err("MCC switch disabled or not concurrent STA/SAP"); |
| 603 | return false; |
| 604 | } |
| 605 | return true; |
| 606 | } |
| 607 | |
| 608 | /** |
| 609 | * policy_mgr_is_sap_channel_change_without_restart() - Check if |
| 610 | * SAP channel change allowed without restart |
| 611 | * @mcc_to_scc_switch: MCC to SCC switch enabled user config |
| 612 | * |
| 613 | * Check if SAP channel change allowed without restart |
| 614 | * |
| 615 | * Restart: true or false |
| 616 | */ |
| 617 | static bool policy_mgr_is_sap_channel_change_without_restart( |
| 618 | uint32_t mcc_to_scc_switch) { |
| 619 | if (mcc_to_scc_switch == |
| 620 | QDF_MCC_TO_SCC_SWITCH_FORCE_WITHOUT_DISCONNECTION || |
| 621 | mcc_to_scc_switch == |
| 622 | QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL) { |
| 623 | policy_mgr_info("SAP chan change without restart allowed"); |
| 624 | return true; |
| 625 | } |
| 626 | return false; |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * policy_mgr_check_sta_ap_concurrent_ch_intf() - Restart SAP in STA-AP case |
| 631 | * @data: Pointer check concurrent channel work data |
| 632 | * |
| 633 | * Restarts the SAP interface in STA-AP concurrency scenario |
| 634 | * |
| 635 | * Restart: None |
| 636 | */ |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 637 | void policy_mgr_check_sta_ap_concurrent_ch_intf(void *data) |
| 638 | { |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 639 | struct wlan_objmgr_psoc *psoc = |
| 640 | (struct wlan_objmgr_psoc *) data; |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 641 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 642 | uint32_t mcc_to_scc_switch; |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 643 | QDF_STATUS status; |
| 644 | uint8_t channel, sec_ch; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 645 | uint8_t operating_channel, vdev_id; |
| 646 | bool restart_sap; |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 647 | |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 648 | |
| 649 | pm_ctx = policy_mgr_get_context(psoc); |
| 650 | if (!pm_ctx) { |
| 651 | policy_mgr_err("Invalid context"); |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 652 | return; |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 653 | } |
| 654 | mcc_to_scc_switch = |
| 655 | policy_mgr_mcc_to_scc_switch_mode_in_user_cfg(psoc); |
| 656 | |
| 657 | policy_mgr_info("Concurrent open sessions running: %d", |
| 658 | policy_mgr_concurrent_open_sessions_running(psoc)); |
| 659 | |
| 660 | if (!policy_mgr_is_restart_sap_allowed(psoc, mcc_to_scc_switch)) |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 661 | return; |
| 662 | |
| 663 | if (!policy_mgr_get_sap_conn_info(psoc, |
| 664 | &operating_channel, |
| 665 | &vdev_id)) { |
| 666 | policy_mgr_err("Could not retrieve SAP channel & vdev id"); |
| 667 | return; |
| 668 | } |
| 669 | |
| 670 | restart_sap = policy_mgr_is_sap_channel_change_without_restart( |
| 671 | mcc_to_scc_switch) ? false : true; |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 672 | |
Archana Ramachandran | 631fd9f | 2017-03-19 18:51:30 -0700 | [diff] [blame] | 673 | if (!pm_ctx->hdd_cbacks.wlan_hdd_get_channel_for_sap_restart) { |
| 674 | policy_mgr_err("SAP restart get channel callback in NULL"); |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 675 | return; |
Archana Ramachandran | 631fd9f | 2017-03-19 18:51:30 -0700 | [diff] [blame] | 676 | } |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 677 | status = pm_ctx->hdd_cbacks. |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 678 | wlan_hdd_get_channel_for_sap_restart(psoc, vdev_id, |
| 679 | &channel, &sec_ch, restart_sap); |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 680 | if (status != QDF_STATUS_SUCCESS) { |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 681 | policy_mgr_err("Failed to switch SAP channel"); |
| 682 | return; |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 683 | } |
| 684 | |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 685 | policy_mgr_info("SAP restarts due to MCC->SCC switch, old chan :%d new chan: %d", |
| 686 | operating_channel, channel); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 687 | } |
| 688 | |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 689 | /** |
| 690 | * policy_mgr_check_concurrent_intf_and_restart_sap() - Check |
| 691 | * concurrent change intf |
| 692 | * @psoc: PSOC object information |
| 693 | * @operation_channel: operation channel |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 694 | * @vdev_id: vdev id of SAP |
Archana Ramachandran | 107d378 | 2017-03-06 17:07:44 -0800 | [diff] [blame] | 695 | * |
| 696 | * Checks the concurrent change interface and restarts SAP |
| 697 | * |
| 698 | * Return: None |
| 699 | */ |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 700 | void policy_mgr_check_concurrent_intf_and_restart_sap( |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 701 | struct wlan_objmgr_psoc *psoc) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 702 | { |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 703 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 704 | uint32_t mcc_to_scc_switch; |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 705 | uint8_t operating_channel, vdev_id; |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 706 | |
| 707 | pm_ctx = policy_mgr_get_context(psoc); |
| 708 | if (!pm_ctx) { |
| 709 | policy_mgr_err("Invalid context"); |
| 710 | return; |
| 711 | } |
| 712 | |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 713 | if (!policy_mgr_get_sap_conn_info(psoc, |
| 714 | &operating_channel, |
| 715 | &vdev_id)) { |
| 716 | policy_mgr_err("Could not retrieve SAP channel & vdev id"); |
| 717 | return; |
| 718 | } |
| 719 | |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 720 | mcc_to_scc_switch = |
| 721 | policy_mgr_mcc_to_scc_switch_mode_in_user_cfg(psoc); |
| 722 | policy_mgr_info("MCC to SCC switch: %d chan: %d", |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 723 | mcc_to_scc_switch, operating_channel); |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 724 | if ((mcc_to_scc_switch != QDF_MCC_TO_SCC_SWITCH_DISABLE) |
| 725 | #ifdef FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE |
| 726 | && !wlan_reg_is_dfs_ch(psoc, |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 727 | operating_channel) |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 728 | #endif |
| 729 | ) { |
| 730 | qdf_create_work(0, &pm_ctx->sta_ap_intf_check_work, |
Archana Ramachandran | 6199b64 | 2017-03-20 13:31:36 -0700 | [diff] [blame] | 731 | policy_mgr_check_sta_ap_concurrent_ch_intf, |
| 732 | psoc); |
Archana Ramachandran | 266613f | 2017-03-13 16:36:55 -0700 | [diff] [blame] | 733 | qdf_sched_work(0, &pm_ctx->sta_ap_intf_check_work); |
| 734 | policy_mgr_info("Checking for Concurrent Change interference"); |
| 735 | } |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 736 | } |
| 737 | #endif /* FEATURE_WLAN_MCC_TO_SCC_SWITCH */ |
| 738 | |
| 739 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 740 | /** |
| 741 | * policy_mgr_change_sap_channel_with_csa() - Move SAP channel using (E)CSA |
| 742 | * @psoc: PSOC object information |
| 743 | * @vdev_id: Vdev id |
| 744 | * @channel: Channel to change |
| 745 | * @ch_width: channel width to change |
| 746 | * |
| 747 | * Invoke the callback function to change SAP channel using (E)CSA |
| 748 | * |
| 749 | * Return: None |
| 750 | */ |
| 751 | void policy_mgr_change_sap_channel_with_csa(struct wlan_objmgr_psoc *psoc, |
| 752 | uint8_t vdev_id, uint32_t channel, |
| 753 | uint32_t ch_width) |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 754 | { |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 755 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 756 | |
| 757 | pm_ctx = policy_mgr_get_context(psoc); |
| 758 | if (!pm_ctx) { |
| 759 | policy_mgr_err("Invalid context"); |
| 760 | return; |
| 761 | } |
| 762 | |
Archana Ramachandran | 544ce17 | 2017-03-14 15:12:09 -0700 | [diff] [blame] | 763 | if (pm_ctx->hdd_cbacks.sap_restart_chan_switch_cb) { |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 764 | policy_mgr_info("SAP change change without restart"); |
Archana Ramachandran | 631fd9f | 2017-03-19 18:51:30 -0700 | [diff] [blame] | 765 | pm_ctx->hdd_cbacks.sap_restart_chan_switch_cb(psoc, |
| 766 | vdev_id, channel, ch_width); |
Archana Ramachandran | 0edce25 | 2017-03-06 14:36:29 -0800 | [diff] [blame] | 767 | } |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 768 | } |
| 769 | #endif |
| 770 | |
| 771 | QDF_STATUS policy_mgr_wait_for_connection_update(struct wlan_objmgr_psoc *psoc) |
| 772 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 773 | QDF_STATUS status; |
| 774 | struct policy_mgr_psoc_priv_obj *policy_mgr_context; |
| 775 | |
| 776 | policy_mgr_context = policy_mgr_get_context(psoc); |
| 777 | if (!policy_mgr_context) { |
| 778 | policy_mgr_err("Invalid context"); |
| 779 | return QDF_STATUS_E_FAILURE; |
| 780 | } |
| 781 | |
| 782 | status = qdf_wait_single_event( |
| 783 | &policy_mgr_context->connection_update_done_evt, |
| 784 | CONNECTION_UPDATE_TIMEOUT); |
| 785 | |
| 786 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 787 | policy_mgr_err("wait for event failed"); |
| 788 | return QDF_STATUS_E_FAILURE; |
| 789 | } |
| 790 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 791 | return QDF_STATUS_SUCCESS; |
| 792 | } |
| 793 | |
| 794 | QDF_STATUS policy_mgr_reset_connection_update(struct wlan_objmgr_psoc *psoc) |
| 795 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 796 | QDF_STATUS status; |
| 797 | struct policy_mgr_psoc_priv_obj *policy_mgr_context; |
| 798 | |
| 799 | policy_mgr_context = policy_mgr_get_context(psoc); |
| 800 | if (!policy_mgr_context) { |
| 801 | policy_mgr_err("Invalid context"); |
| 802 | return QDF_STATUS_E_FAILURE; |
| 803 | } |
| 804 | |
| 805 | status = qdf_event_reset( |
| 806 | &policy_mgr_context->connection_update_done_evt); |
| 807 | |
| 808 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 809 | policy_mgr_err("clear event failed"); |
| 810 | return QDF_STATUS_E_FAILURE; |
| 811 | } |
| 812 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 813 | return QDF_STATUS_SUCCESS; |
| 814 | } |
| 815 | |
| 816 | QDF_STATUS policy_mgr_set_connection_update(struct wlan_objmgr_psoc *psoc) |
| 817 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 818 | QDF_STATUS status; |
| 819 | struct policy_mgr_psoc_priv_obj *policy_mgr_context; |
| 820 | |
| 821 | policy_mgr_context = policy_mgr_get_context(psoc); |
| 822 | if (!policy_mgr_context) { |
| 823 | policy_mgr_err("Invalid context"); |
| 824 | return QDF_STATUS_E_FAILURE; |
| 825 | } |
| 826 | |
| 827 | status = qdf_event_set(&policy_mgr_context->connection_update_done_evt); |
| 828 | |
| 829 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 830 | policy_mgr_err("set event failed"); |
| 831 | return QDF_STATUS_E_FAILURE; |
| 832 | } |
| 833 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 834 | return QDF_STATUS_SUCCESS; |
| 835 | } |
| 836 | |
| 837 | QDF_STATUS policy_mgr_restart_opportunistic_timer( |
| 838 | struct wlan_objmgr_psoc *psoc, bool check_state) |
| 839 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 840 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 841 | struct policy_mgr_psoc_priv_obj *policy_mgr_ctx; |
| 842 | |
| 843 | policy_mgr_ctx = policy_mgr_get_context(psoc); |
| 844 | if (!policy_mgr_ctx) { |
| 845 | policy_mgr_err("Invalid context"); |
| 846 | return status; |
| 847 | } |
| 848 | |
| 849 | if (check_state && |
| 850 | QDF_TIMER_STATE_RUNNING != |
| 851 | policy_mgr_ctx->dbs_opportunistic_timer.state) |
| 852 | return status; |
| 853 | |
| 854 | qdf_mc_timer_stop(&policy_mgr_ctx->dbs_opportunistic_timer); |
| 855 | |
| 856 | status = qdf_mc_timer_start( |
| 857 | &policy_mgr_ctx->dbs_opportunistic_timer, |
| 858 | DBS_OPPORTUNISTIC_TIME * 1000); |
| 859 | |
| 860 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 861 | policy_mgr_err("failed to start opportunistic timer"); |
| 862 | return status; |
| 863 | } |
| 864 | |
| 865 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 866 | } |
| 867 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 868 | QDF_STATUS policy_mgr_set_hw_mode_on_channel_switch( |
| 869 | struct wlan_objmgr_psoc *psoc, uint8_t session_id) |
| 870 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 871 | QDF_STATUS status = QDF_STATUS_E_FAILURE, qdf_status; |
| 872 | enum policy_mgr_conc_next_action action; |
| 873 | |
| 874 | if (!policy_mgr_is_hw_dbs_capable(psoc)) { |
| 875 | policy_mgr_err("PM/DBS is disabled"); |
| 876 | return status; |
| 877 | } |
| 878 | |
| 879 | action = (*policy_mgr_get_current_pref_hw_mode_ptr)(psoc); |
| 880 | if ((action != PM_DBS_DOWNGRADE) && |
| 881 | (action != PM_SINGLE_MAC_UPGRADE)) { |
| 882 | policy_mgr_err("Invalid action: %d", action); |
| 883 | status = QDF_STATUS_SUCCESS; |
| 884 | goto done; |
| 885 | } |
| 886 | |
| 887 | policy_mgr_notice("action:%d session id:%d", action, session_id); |
| 888 | |
| 889 | /* Opportunistic timer is started, PM will check if MCC upgrade can be |
| 890 | * done on timer expiry. This avoids any possible ping pong effect |
| 891 | * as well. |
| 892 | */ |
| 893 | if (action == PM_SINGLE_MAC_UPGRADE) { |
| 894 | qdf_status = policy_mgr_restart_opportunistic_timer( |
| 895 | psoc, false); |
| 896 | if (QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 897 | policy_mgr_notice("opportunistic timer for MCC upgrade"); |
| 898 | goto done; |
| 899 | } |
| 900 | |
| 901 | /* For DBS, we want to move right away to DBS mode */ |
| 902 | status = policy_mgr_next_actions(psoc, session_id, action, |
| 903 | POLICY_MGR_UPDATE_REASON_CHANNEL_SWITCH); |
| 904 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 905 | policy_mgr_err("no set hw mode command was issued"); |
| 906 | goto done; |
| 907 | } |
| 908 | done: |
| 909 | /* success must be returned only when a set hw mode was done */ |
| 910 | return status; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 911 | } |
| 912 | |
| 913 | void policy_mgr_checkn_update_hw_mode_single_mac_mode( |
| 914 | struct wlan_objmgr_psoc *psoc, uint8_t channel) |
| 915 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 916 | uint8_t i; |
| 917 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 918 | |
| 919 | pm_ctx = policy_mgr_get_context(psoc); |
| 920 | if (!pm_ctx) { |
| 921 | policy_mgr_err("Invalid Context"); |
| 922 | return; |
| 923 | } |
| 924 | |
| 925 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 926 | for (i = 0; i < MAX_NUMBER_OF_CONC_CONNECTIONS; i++) { |
| 927 | if (pm_conc_connection_list[i].in_use) |
| 928 | if (!WLAN_REG_IS_SAME_BAND_CHANNELS(channel, |
| 929 | pm_conc_connection_list[i].chan)) { |
| 930 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 931 | policy_mgr_notice("DBS required"); |
| 932 | return; |
| 933 | } |
| 934 | } |
| 935 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 936 | |
| 937 | if (QDF_TIMER_STATE_RUNNING == |
| 938 | pm_ctx->dbs_opportunistic_timer.state) |
| 939 | qdf_mc_timer_stop(&pm_ctx->dbs_opportunistic_timer); |
| 940 | |
| 941 | pm_dbs_opportunistic_timer_handler((void *)psoc); |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 942 | } |
| 943 | |
Tushnim Bhattacharyya | e9c1e42 | 2017-03-13 10:27:10 -0700 | [diff] [blame] | 944 | void policy_mgr_set_hw_mode_change_in_progress( |
| 945 | struct wlan_objmgr_psoc *psoc, enum policy_mgr_hw_mode_change value) |
| 946 | { |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 947 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 948 | |
| 949 | pm_ctx = policy_mgr_get_context(psoc); |
| 950 | if (!pm_ctx) { |
| 951 | policy_mgr_err("Invalid Context"); |
| 952 | return; |
| 953 | } |
| 954 | |
| 955 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 956 | pm_ctx->hw_mode_change_in_progress = value; |
| 957 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 958 | |
| 959 | policy_mgr_debug("hw_mode_change_in_progress:%d", value); |
Tushnim Bhattacharyya | e9c1e42 | 2017-03-13 10:27:10 -0700 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | enum policy_mgr_hw_mode_change policy_mgr_is_hw_mode_change_in_progress( |
| 963 | struct wlan_objmgr_psoc *psoc) |
| 964 | { |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 965 | enum policy_mgr_hw_mode_change value; |
| 966 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 967 | |
| 968 | value = POLICY_MGR_HW_MODE_NOT_IN_PROGRESS; |
| 969 | |
| 970 | pm_ctx = policy_mgr_get_context(psoc); |
| 971 | if (!pm_ctx) { |
| 972 | policy_mgr_err("Invalid Context"); |
| 973 | return value; |
| 974 | } |
| 975 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 976 | value = pm_ctx->hw_mode_change_in_progress; |
| 977 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 978 | |
| 979 | return value; |
Tushnim Bhattacharyya | e9c1e42 | 2017-03-13 10:27:10 -0700 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | enum policy_mgr_hw_mode_change policy_mgr_get_hw_mode_change_from_hw_mode_index( |
| 983 | struct wlan_objmgr_psoc *psoc, uint32_t hw_mode_index) |
| 984 | { |
Tushnim Bhattacharyya | 7051ad0 | 2017-03-23 11:16:40 -0700 | [diff] [blame] | 985 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 986 | uint32_t param = 0; |
| 987 | enum policy_mgr_hw_mode_change value |
| 988 | = POLICY_MGR_HW_MODE_NOT_IN_PROGRESS; |
| 989 | |
| 990 | pm_ctx = policy_mgr_get_context(psoc); |
| 991 | if (!pm_ctx) { |
| 992 | policy_mgr_err("Invalid Context"); |
| 993 | return value; |
| 994 | } |
| 995 | |
| 996 | policy_mgr_info("HW param: %x", param); |
| 997 | param = pm_ctx->hw_mode.hw_mode_list[hw_mode_index]; |
| 998 | if (POLICY_MGR_HW_MODE_DBS_MODE_GET(param)) { |
| 999 | policy_mgr_info("DBS is requested with HW (%d)", |
| 1000 | hw_mode_index); |
| 1001 | value = POLICY_MGR_DBS_IN_PROGRESS; |
| 1002 | goto ret_value; |
| 1003 | } |
| 1004 | |
| 1005 | if (POLICY_MGR_HW_MODE_SBS_MODE_GET(param)) { |
| 1006 | policy_mgr_info("SBS is requested with HW (%d)", |
| 1007 | hw_mode_index); |
| 1008 | value = POLICY_MGR_SBS_IN_PROGRESS; |
| 1009 | goto ret_value; |
| 1010 | } |
| 1011 | |
| 1012 | value = POLICY_MGR_SMM_IN_PROGRESS; |
| 1013 | policy_mgr_info("SMM is requested with HW (%d)", hw_mode_index); |
| 1014 | |
| 1015 | ret_value: |
| 1016 | return value; |
Tushnim Bhattacharyya | e9c1e42 | 2017-03-13 10:27:10 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1019 | #ifdef MPC_UT_FRAMEWORK |
| 1020 | QDF_STATUS policy_mgr_update_connection_info_utfw( |
| 1021 | struct wlan_objmgr_psoc *psoc, |
| 1022 | uint32_t vdev_id, uint32_t tx_streams, uint32_t rx_streams, |
| 1023 | uint32_t chain_mask, uint32_t type, uint32_t sub_type, |
| 1024 | uint32_t channelid, uint32_t mac_id) |
| 1025 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1026 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 1027 | uint32_t conn_index = 0, found = 0; |
| 1028 | struct policy_mgr_psoc_priv_obj *pm_ctx; |
| 1029 | |
| 1030 | pm_ctx = policy_mgr_get_context(psoc); |
| 1031 | if (!pm_ctx) { |
| 1032 | policy_mgr_err("Invalid Context"); |
| 1033 | return status; |
| 1034 | } |
| 1035 | |
| 1036 | qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); |
| 1037 | while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { |
| 1038 | if (vdev_id == pm_conc_connection_list[conn_index].vdev_id) { |
| 1039 | /* debug msg */ |
| 1040 | found = 1; |
| 1041 | break; |
| 1042 | } |
| 1043 | conn_index++; |
| 1044 | } |
| 1045 | qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); |
| 1046 | if (!found) { |
| 1047 | /* err msg */ |
| 1048 | policy_mgr_err("can't find vdev_id %d in pm_conc_connection_list", |
| 1049 | vdev_id); |
| 1050 | return status; |
| 1051 | } |
| 1052 | policy_mgr_notice("--> updating entry at index[%d]", conn_index); |
| 1053 | |
| 1054 | policy_mgr_update_conc_list(psoc, conn_index, |
| 1055 | policy_mgr_get_mode(type, sub_type), |
| 1056 | channelid, HW_MODE_20_MHZ, |
| 1057 | mac_id, chain_mask, 0, vdev_id, true); |
| 1058 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1059 | return QDF_STATUS_SUCCESS; |
| 1060 | } |
| 1061 | |
| 1062 | QDF_STATUS policy_mgr_incr_connection_count_utfw(struct wlan_objmgr_psoc *psoc, |
| 1063 | uint32_t vdev_id, uint32_t tx_streams, uint32_t rx_streams, |
| 1064 | uint32_t chain_mask, uint32_t type, uint32_t sub_type, |
| 1065 | uint32_t channelid, uint32_t mac_id) |
| 1066 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1067 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 1068 | uint32_t conn_index = 0; |
| 1069 | |
| 1070 | conn_index = policy_mgr_get_connection_count(psoc); |
| 1071 | if (MAX_NUMBER_OF_CONC_CONNECTIONS <= conn_index) { |
| 1072 | /* err msg */ |
| 1073 | policy_mgr_err("exceeded max connection limit %d", |
| 1074 | MAX_NUMBER_OF_CONC_CONNECTIONS); |
| 1075 | return status; |
| 1076 | } |
| 1077 | policy_mgr_notice("--> filling entry at index[%d]", conn_index); |
| 1078 | |
| 1079 | policy_mgr_update_conc_list(psoc, conn_index, |
| 1080 | policy_mgr_get_mode(type, sub_type), |
| 1081 | channelid, HW_MODE_20_MHZ, |
| 1082 | mac_id, chain_mask, 0, vdev_id, true); |
| 1083 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1084 | return QDF_STATUS_SUCCESS; |
| 1085 | } |
| 1086 | |
| 1087 | QDF_STATUS policy_mgr_decr_connection_count_utfw(struct wlan_objmgr_psoc *psoc, |
| 1088 | uint32_t del_all, uint32_t vdev_id) |
| 1089 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1090 | QDF_STATUS status; |
| 1091 | |
| 1092 | if (del_all) { |
| 1093 | status = policy_mgr_psoc_enable(psoc); |
| 1094 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1095 | policy_mgr_err("Policy manager initialization failed"); |
| 1096 | return QDF_STATUS_E_FAILURE; |
| 1097 | } |
| 1098 | } else { |
| 1099 | policy_mgr_decr_connection_count(psoc, vdev_id); |
| 1100 | } |
| 1101 | |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1102 | return QDF_STATUS_SUCCESS; |
| 1103 | } |
| 1104 | |
| 1105 | enum policy_mgr_pcl_type policy_mgr_get_pcl_from_first_conn_table( |
| 1106 | enum policy_mgr_con_mode type, |
| 1107 | enum policy_mgr_conc_priority_mode sys_pref) |
| 1108 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1109 | if ((sys_pref >= PM_MAX_CONC_PRIORITY_MODE) || |
| 1110 | (type >= PM_MAX_NUM_OF_MODE)) |
| 1111 | return PM_MAX_PCL_TYPE; |
| 1112 | return first_connection_pcl_table[type][sys_pref]; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | enum policy_mgr_pcl_type policy_mgr_get_pcl_from_second_conn_table( |
| 1116 | enum policy_mgr_one_connection_mode idx, enum policy_mgr_con_mode type, |
| 1117 | enum policy_mgr_conc_priority_mode sys_pref, uint8_t dbs_capable) |
| 1118 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1119 | if ((idx >= PM_MAX_ONE_CONNECTION_MODE) || |
| 1120 | (sys_pref >= PM_MAX_CONC_PRIORITY_MODE) || |
| 1121 | (type >= PM_MAX_NUM_OF_MODE)) |
| 1122 | return PM_MAX_PCL_TYPE; |
| 1123 | if (dbs_capable) |
| 1124 | return (*second_connection_pcl_dbs_table)[idx][type][sys_pref]; |
| 1125 | else |
| 1126 | return second_connection_pcl_nodbs_table[idx][type][sys_pref]; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1127 | } |
| 1128 | |
| 1129 | enum policy_mgr_pcl_type policy_mgr_get_pcl_from_third_conn_table( |
| 1130 | enum policy_mgr_two_connection_mode idx, enum policy_mgr_con_mode type, |
| 1131 | enum policy_mgr_conc_priority_mode sys_pref, uint8_t dbs_capable) |
| 1132 | { |
Tushnim Bhattacharyya | 5ae4c43 | 2017-03-08 09:15:15 -0800 | [diff] [blame] | 1133 | if ((idx >= PM_MAX_TWO_CONNECTION_MODE) || |
| 1134 | (sys_pref >= PM_MAX_CONC_PRIORITY_MODE) || |
| 1135 | (type >= PM_MAX_NUM_OF_MODE)) |
| 1136 | return PM_MAX_PCL_TYPE; |
| 1137 | if (dbs_capable) |
| 1138 | return (*third_connection_pcl_dbs_table)[idx][type][sys_pref]; |
| 1139 | else |
| 1140 | return third_connection_pcl_nodbs_table[idx][type][sys_pref]; |
Tushnim Bhattacharyya | 6a8f07f | 2017-02-15 16:59:48 -0800 | [diff] [blame] | 1141 | } |
| 1142 | #endif |