Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Krishna Kumaar Natarajan | 4e9cf39 | 2015-11-20 13:35:05 -0800 | [diff] [blame] | 2 | * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 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 | #include "cds_api.h" |
| 29 | #include "wni_cfg.h" |
| 30 | #include "ani_global.h" |
| 31 | #include "sir_api.h" |
| 32 | #include "sir_params.h" |
| 33 | #include "cfg_api.h" |
| 34 | |
| 35 | #include "sch_api.h" |
| 36 | #include "utils_api.h" |
| 37 | #include "lim_utils.h" |
| 38 | #include "lim_assoc_utils.h" |
| 39 | #include "lim_prop_exts_utils.h" |
| 40 | #include "lim_security_utils.h" |
| 41 | #include "lim_send_messages.h" |
| 42 | #include "lim_send_messages.h" |
| 43 | #include "lim_session_utils.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 44 | #include <lim_ft.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 45 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM |
| 46 | #include "host_diag_core_log.h" |
| 47 | #endif |
| 48 | #include "wma_if.h" |
| 49 | |
| 50 | static void lim_process_mlm_start_req(tpAniSirGlobal, uint32_t *); |
| 51 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 52 | static void lim_process_mlm_oem_data_req(tpAniSirGlobal, uint32_t *); |
| 53 | #endif |
| 54 | static void lim_process_mlm_join_req(tpAniSirGlobal, uint32_t *); |
| 55 | static void lim_process_mlm_auth_req(tpAniSirGlobal, uint32_t *); |
| 56 | static void lim_process_mlm_assoc_req(tpAniSirGlobal, uint32_t *); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 57 | static void lim_process_mlm_disassoc_req(tpAniSirGlobal, uint32_t *); |
| 58 | static void lim_process_mlm_deauth_req(tpAniSirGlobal, uint32_t *); |
| 59 | static void lim_process_mlm_set_keys_req(tpAniSirGlobal, uint32_t *); |
| 60 | |
| 61 | /* MLM Timeout event handler templates */ |
| 62 | static void lim_process_periodic_probe_req_timer(tpAniSirGlobal mac_ctx); |
| 63 | static void lim_process_join_failure_timeout(tpAniSirGlobal); |
| 64 | static void lim_process_auth_failure_timeout(tpAniSirGlobal); |
| 65 | static void lim_process_auth_rsp_timeout(tpAniSirGlobal, uint32_t); |
| 66 | static void lim_process_assoc_failure_timeout(tpAniSirGlobal, uint32_t); |
| 67 | static void lim_process_periodic_join_probe_req_timer(tpAniSirGlobal); |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 68 | static void lim_process_auth_retry_timer(tpAniSirGlobal); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * lim_process_mlm_req_messages() - process mlm request messages |
| 72 | * @mac_ctx: global MAC context |
| 73 | * @msg: mlm request message |
| 74 | * |
| 75 | * This function is called by lim_post_mlm_message(). This |
| 76 | * function handles MLM primitives invoked by SME. |
| 77 | * Depending on the message type, corresponding function will be |
| 78 | * called. |
| 79 | * ASSUMPTIONS: |
| 80 | * 1. Upon receiving Beacon in WT_JOIN_STATE, MLM module invokes |
| 81 | * APIs exposed by Beacon Processing module for setting parameters |
| 82 | * at MAC hardware. |
| 83 | * 2. If attempt to Reassociate with an AP fails, link with current |
| 84 | * AP is restored back. |
| 85 | * |
| 86 | * Return: None |
| 87 | */ |
| 88 | void lim_process_mlm_req_messages(tpAniSirGlobal mac_ctx, tpSirMsgQ msg) |
| 89 | { |
| 90 | MTRACE(mac_trace_msg_rx(mac_ctx, NO_SESSION, msg->type)); |
| 91 | switch (msg->type) { |
| 92 | case LIM_MLM_START_REQ: |
| 93 | lim_process_mlm_start_req(mac_ctx, msg->bodyptr); |
| 94 | break; |
| 95 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 96 | case LIM_MLM_OEM_DATA_REQ: |
| 97 | lim_process_mlm_oem_data_req(mac_ctx, msg->bodyptr); |
| 98 | break; |
| 99 | #endif |
| 100 | case LIM_MLM_JOIN_REQ: |
| 101 | lim_process_mlm_join_req(mac_ctx, msg->bodyptr); |
| 102 | break; |
| 103 | case LIM_MLM_AUTH_REQ: |
| 104 | lim_process_mlm_auth_req(mac_ctx, msg->bodyptr); |
| 105 | break; |
| 106 | case LIM_MLM_ASSOC_REQ: |
| 107 | lim_process_mlm_assoc_req(mac_ctx, msg->bodyptr); |
| 108 | break; |
| 109 | case LIM_MLM_REASSOC_REQ: |
| 110 | lim_process_mlm_reassoc_req(mac_ctx, msg->bodyptr); |
| 111 | break; |
| 112 | case LIM_MLM_DISASSOC_REQ: |
| 113 | lim_process_mlm_disassoc_req(mac_ctx, msg->bodyptr); |
| 114 | break; |
| 115 | case LIM_MLM_DEAUTH_REQ: |
| 116 | lim_process_mlm_deauth_req(mac_ctx, msg->bodyptr); |
| 117 | break; |
| 118 | case LIM_MLM_SETKEYS_REQ: |
| 119 | lim_process_mlm_set_keys_req(mac_ctx, msg->bodyptr); |
| 120 | break; |
| 121 | case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT: |
| 122 | lim_process_periodic_probe_req_timer(mac_ctx); |
| 123 | break; |
| 124 | case SIR_LIM_JOIN_FAIL_TIMEOUT: |
| 125 | lim_process_join_failure_timeout(mac_ctx); |
| 126 | break; |
| 127 | case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT: |
| 128 | lim_process_periodic_join_probe_req_timer(mac_ctx); |
| 129 | break; |
| 130 | case SIR_LIM_AUTH_FAIL_TIMEOUT: |
| 131 | lim_process_auth_failure_timeout(mac_ctx); |
| 132 | break; |
| 133 | case SIR_LIM_AUTH_RSP_TIMEOUT: |
| 134 | lim_process_auth_rsp_timeout(mac_ctx, msg->bodyval); |
| 135 | break; |
| 136 | case SIR_LIM_ASSOC_FAIL_TIMEOUT: |
| 137 | lim_process_assoc_failure_timeout(mac_ctx, msg->bodyval); |
| 138 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 139 | case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT: |
| 140 | lim_process_ft_preauth_rsp_timeout(mac_ctx); |
| 141 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 142 | case SIR_LIM_REMAIN_CHN_TIMEOUT: |
| 143 | lim_process_remain_on_chn_timeout(mac_ctx); |
| 144 | break; |
| 145 | case SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT: |
| 146 | lim_process_insert_single_shot_noa_timeout(mac_ctx); |
| 147 | break; |
| 148 | case SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE: |
| 149 | lim_convert_active_channel_to_passive_channel(mac_ctx); |
| 150 | break; |
| 151 | case SIR_LIM_DISASSOC_ACK_TIMEOUT: |
| 152 | lim_process_disassoc_ack_timeout(mac_ctx); |
| 153 | break; |
| 154 | case SIR_LIM_DEAUTH_ACK_TIMEOUT: |
| 155 | lim_process_deauth_ack_timeout(mac_ctx); |
| 156 | break; |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 157 | case SIR_LIM_AUTH_RETRY_TIMEOUT: |
| 158 | lim_process_auth_retry_timer(mac_ctx); |
| 159 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 160 | case LIM_MLM_TSPEC_REQ: |
| 161 | default: |
| 162 | break; |
| 163 | } /* switch (msg->type) */ |
| 164 | } |
| 165 | |
| 166 | /* WLAN_SUSPEND_LINK Related */ |
| 167 | |
| 168 | /** |
| 169 | * lim_is_link_suspended()- check if link is suspended |
| 170 | * @mac_ctx: global MAC context |
| 171 | * |
| 172 | * This function returns is link is suspended or not. |
| 173 | * Since Suspend link uses init scan, it just returns |
| 174 | * gLimSystemInScanLearnMode flag. |
| 175 | * |
| 176 | * Return: uint8_t(gLimSystemInScanLearnMode flag) |
| 177 | */ |
| 178 | uint8_t lim_is_link_suspended(tpAniSirGlobal mac_ctx) |
| 179 | { |
| 180 | return mac_ctx->lim.gLimSystemInScanLearnMode; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * lim_change_channel_with_callback() - change channel and register callback |
| 185 | * @mac_ctx: global MAC context |
| 186 | * @new_chan: new channel to switch |
| 187 | * @callback: Callback function |
| 188 | * @cbdata: callback data |
| 189 | * @session_entry: PE session pointer |
| 190 | * |
| 191 | * This function is called to change channel and perform off channel operation |
| 192 | * if required. The caller registers a callback to be called at the end of the |
| 193 | * channel change. |
| 194 | * |
| 195 | * Return: None |
| 196 | */ |
| 197 | void |
| 198 | lim_change_channel_with_callback(tpAniSirGlobal mac_ctx, uint8_t new_chan, |
| 199 | CHANGE_CHANNEL_CALLBACK callback, |
| 200 | uint32_t *cbdata, tpPESession session_entry) |
| 201 | { |
| 202 | /* Sanity checks for the current and new channel */ |
Varun Reddy Yeturu | 0e3989a | 2016-04-15 13:30:42 +0530 | [diff] [blame] | 203 | lim_log(mac_ctx, LOG1, FL("Switching channel to %d"), new_chan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 204 | session_entry->channelChangeReasonCode = |
| 205 | LIM_SWITCH_CHANNEL_OPERATION; |
| 206 | |
| 207 | mac_ctx->lim.gpchangeChannelCallback = callback; |
| 208 | mac_ctx->lim.gpchangeChannelData = cbdata; |
| 209 | |
| 210 | lim_send_switch_chnl_params(mac_ctx, new_chan, 0, 0, |
| 211 | CH_WIDTH_20MHZ, session_entry->maxTxPower, |
| 212 | session_entry->peSessionId, false); |
| 213 | |
| 214 | return; |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * lim_covert_channel_scan_type() - switch between ACTIVE and PASSIVE scan type |
| 219 | * @mac_ctx: global MAC context |
| 220 | * @chan_num: channel number to change the scan type |
| 221 | * @passive_to_active: flag to indicate if switch allowed |
| 222 | * |
| 223 | * This function is called to get the list, |
| 224 | * change the channel type and set again. |
| 225 | * NOTE: If a channel is ACTIVE, this function will make it as PASSIVE |
| 226 | * If a channel is PASSIVE, this fucntion will make it as ACTIVE |
| 227 | * |
| 228 | * Return: None |
| 229 | */ |
| 230 | |
| 231 | void lim_covert_channel_scan_type(tpAniSirGlobal mac_ctx, uint8_t chan_num, |
| 232 | bool passive_to_active) |
| 233 | { |
| 234 | |
| 235 | uint32_t i; |
| 236 | uint8_t chan_pair[WNI_CFG_SCAN_CONTROL_LIST_LEN]; |
| 237 | uint32_t len = WNI_CFG_SCAN_CONTROL_LIST_LEN; |
| 238 | tSirRetStatus status; |
| 239 | |
| 240 | status = wlan_cfg_get_str(mac_ctx, WNI_CFG_SCAN_CONTROL_LIST, |
| 241 | chan_pair, &len); |
| 242 | if (eSIR_SUCCESS != status) { |
| 243 | lim_log(mac_ctx, LOGE, FL("Unable to get scan control list")); |
| 244 | return; |
| 245 | } |
| 246 | if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN) { |
| 247 | lim_log(mac_ctx, LOGE, |
| 248 | FL("Invalid scan control list length:%d"), len); |
| 249 | return; |
| 250 | } |
| 251 | for (i = 0; (i + 1) < len; i += 2) { |
| 252 | if (chan_pair[i] != chan_num) /* skip this channel */ |
| 253 | continue; |
| 254 | if ((eSIR_PASSIVE_SCAN == chan_pair[i + 1]) && |
| 255 | true == passive_to_active) { |
| 256 | lim_log(mac_ctx, LOG1, FL |
| 257 | ("Channel %d changed from Passive to Active"), |
| 258 | chan_num); |
| 259 | chan_pair[i + 1] = eSIR_ACTIVE_SCAN; |
| 260 | break; |
| 261 | } |
| 262 | if ((eSIR_ACTIVE_SCAN == chan_pair[i + 1]) && |
| 263 | false == passive_to_active) { |
| 264 | lim_log(mac_ctx, LOG1, FL |
| 265 | ("Channel %d changed from Active to Passive"), |
| 266 | chan_num); |
| 267 | chan_pair[i + 1] = eSIR_PASSIVE_SCAN; |
| 268 | break; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | cfg_set_str_notify(mac_ctx, WNI_CFG_SCAN_CONTROL_LIST, |
| 273 | (uint8_t *) chan_pair, len, false); |
| 274 | return; |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * lim_set_dfs_channel_list() - convert dfs channel list to active channel list |
| 279 | * @mac_ctx: global MAC context. |
| 280 | * @chan_num: channel number |
| 281 | * @dfs_ch_list: list of DFS channels |
| 282 | * |
| 283 | * This function is called to convert DFS channel list to active channel list |
| 284 | * when any beacon is present on that channel. This function store time for |
| 285 | * passive channels which help to know that for how much time channel has been |
| 286 | * passive. |
| 287 | * |
| 288 | * NOTE: If a channel is ACTIVE, it won't store any time |
| 289 | * If a channel is PAssive, it will store time as timestamp |
| 290 | * |
| 291 | * Return: None |
| 292 | */ |
| 293 | void lim_set_dfs_channel_list(tpAniSirGlobal mac_ctx, uint8_t chan_num, |
| 294 | tSirDFSChannelList *dfs_ch_list) |
| 295 | { |
| 296 | bool pass_to_active = true; |
| 297 | |
| 298 | if (!((1 <= chan_num) && (165 >= chan_num))) { |
| 299 | lim_log(mac_ctx, LOGE, FL("Invalid Channel: %d"), chan_num); |
| 300 | return; |
| 301 | } |
| 302 | |
| 303 | if (true == lim_isconnected_on_dfs_channel(chan_num)) { |
| 304 | if (dfs_ch_list->timeStamp[chan_num] == 0) { |
| 305 | /* |
| 306 | * Received first beacon; |
| 307 | * Convert DFS channel to Active channel. |
| 308 | */ |
| 309 | lim_log(mac_ctx, LOG1, |
| 310 | FL("Received first beacon on DFS channel: %d"), |
| 311 | chan_num); |
| 312 | lim_covert_channel_scan_type(mac_ctx, chan_num, |
| 313 | pass_to_active); |
| 314 | } |
| 315 | dfs_ch_list->timeStamp[chan_num] = |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 316 | qdf_mc_timer_get_system_time(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 317 | } else { |
| 318 | lim_log(mac_ctx, LOG1, FL("Channel %d is Active"), chan_num); |
| 319 | return; |
| 320 | } |
| 321 | |
| 322 | if (!tx_timer_running |
| 323 | (&mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer)) { |
| 324 | tx_timer_activate( |
| 325 | &mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer); |
| 326 | } |
| 327 | |
| 328 | return; |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * lim_restore_pre_scan_state() - restore HW state prior to scan |
| 333 | * |
| 334 | * @mac_ctx: global MAC context |
| 335 | * |
| 336 | * This function is called by lim_continue_channel_scan() |
| 337 | * to restore HW state prior to entering 'scan state' |
| 338 | * |
| 339 | * Return: None |
| 340 | */ |
| 341 | void lim_restore_pre_scan_state(tpAniSirGlobal mac_ctx) |
| 342 | { |
| 343 | /* Deactivate MIN/MAX channel timers if running */ |
| 344 | lim_deactivate_and_change_timer(mac_ctx, eLIM_MIN_CHANNEL_TIMER); |
| 345 | lim_deactivate_and_change_timer(mac_ctx, eLIM_MAX_CHANNEL_TIMER); |
| 346 | |
| 347 | mac_ctx->lim.gLimSystemInScanLearnMode = 0; |
| 348 | lim_log(mac_ctx, LOG1, FL("Scan ended, took %llu tu"), |
| 349 | (tx_time_get() - mac_ctx->lim.scanStartTime)); |
| 350 | } |
| 351 | |
| 352 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 353 | /** |
| 354 | * lim_send_hal_oem_data_req() - send oem data request |
| 355 | * @mac_ctx: global MAC context |
| 356 | * |
| 357 | * This function is used to send OEM data request to HAL. |
| 358 | * |
| 359 | * Return: None |
| 360 | */ |
| 361 | void lim_send_hal_oem_data_req(tpAniSirGlobal mac_ctx) |
| 362 | { |
| 363 | tSirMsgQ msg; |
| 364 | tpStartOemDataReq start_oem_data_req = NULL; |
| 365 | tSirRetStatus rc = eSIR_SUCCESS; |
| 366 | tpLimMlmOemDataRsp mlm_oem_data_rsp; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 367 | |
| 368 | if (NULL == mac_ctx->lim.gpLimMlmOemDataReq) { |
| 369 | lim_log(mac_ctx, LOGE, FL("Null pointer")); |
| 370 | goto error; |
| 371 | } |
| 372 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 373 | start_oem_data_req = qdf_mem_malloc(sizeof(*start_oem_data_req)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 374 | if (NULL == start_oem_data_req) { |
| 375 | lim_log(mac_ctx, LOGE, FL |
| 376 | ("Could not allocate memory for start_oem_data_req")); |
| 377 | goto error; |
| 378 | } |
| 379 | |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 380 | start_oem_data_req->data = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 381 | qdf_mem_malloc(mac_ctx->lim.gpLimMlmOemDataReq->data_len); |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 382 | if (!start_oem_data_req->data) { |
| 383 | lim_log(mac_ctx, LOGE, FL("memory allocation failed")); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 384 | qdf_mem_free(start_oem_data_req); |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 385 | goto error; |
| 386 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 387 | |
| 388 | /* Now copy over the information to the OEM DATA REQ to HAL */ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 389 | qdf_copy_macaddr(&start_oem_data_req->selfMacAddr, |
Srinivas Girigowda | 0ee6686 | 2015-09-24 14:03:29 -0700 | [diff] [blame] | 390 | &mac_ctx->lim.gpLimMlmOemDataReq->selfMacAddr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 391 | |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 392 | start_oem_data_req->data_len = |
| 393 | mac_ctx->lim.gpLimMlmOemDataReq->data_len; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 394 | qdf_mem_copy(start_oem_data_req->data, |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 395 | mac_ctx->lim.gpLimMlmOemDataReq->data, |
| 396 | mac_ctx->lim.gpLimMlmOemDataReq->data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 397 | |
| 398 | /* Create the message to be passed to HAL */ |
| 399 | msg.type = WMA_START_OEM_DATA_REQ; |
| 400 | msg.bodyptr = start_oem_data_req; |
| 401 | msg.bodyval = 0; |
| 402 | |
| 403 | SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, false); |
| 404 | MTRACE(mac_trace_msg_tx(mac_ctx, NO_SESSION, msg.type)); |
| 405 | |
| 406 | rc = wma_post_ctrl_msg(mac_ctx, &msg); |
| 407 | if (rc == eSIR_SUCCESS) |
| 408 | return; |
| 409 | |
| 410 | SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 411 | qdf_mem_free(start_oem_data_req->data); |
| 412 | qdf_mem_free(start_oem_data_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 413 | lim_log(mac_ctx, LOGE, |
| 414 | FL("OEM_DATA: posting WMA_START_OEM_DATA_REQ to HAL failed")); |
| 415 | |
| 416 | error: |
| 417 | mac_ctx->lim.gLimMlmState = mac_ctx->lim.gLimPrevMlmState; |
| 418 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, NO_SESSION, |
| 419 | mac_ctx->lim.gLimMlmState)); |
| 420 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 421 | mlm_oem_data_rsp = qdf_mem_malloc(sizeof(tLimMlmOemDataRsp)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 422 | if (NULL == mlm_oem_data_rsp) { |
| 423 | lim_log(mac_ctx->hHdd, LOGP, FL |
| 424 | ("memory allocation for mlm_oem_data_rsp")); |
| 425 | return; |
| 426 | } |
Krishna Kumaar Natarajan | 4e9cf39 | 2015-11-20 13:35:05 -0800 | [diff] [blame] | 427 | mlm_oem_data_rsp->target_rsp = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 428 | |
| 429 | if (NULL != mac_ctx->lim.gpLimMlmOemDataReq) { |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 430 | if (NULL != mac_ctx->lim.gpLimMlmOemDataReq->data) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 431 | qdf_mem_free( |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 432 | mac_ctx->lim.gpLimMlmOemDataReq->data); |
| 433 | mac_ctx->lim.gpLimMlmOemDataReq->data = NULL; |
| 434 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 435 | qdf_mem_free(mac_ctx->lim.gpLimMlmOemDataReq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 436 | mac_ctx->lim.gpLimMlmOemDataReq = NULL; |
| 437 | } |
| 438 | |
| 439 | lim_post_sme_message(mac_ctx, LIM_MLM_OEM_DATA_CNF, |
| 440 | (uint32_t *) mlm_oem_data_rsp); |
| 441 | |
| 442 | return; |
| 443 | } |
| 444 | #endif /* FEATURE_OEM_DATA_SUPPORT */ |
| 445 | |
| 446 | /** |
| 447 | * mlm_add_sta() - MLM add sta |
| 448 | * @mac_ctx: global MAC context |
| 449 | * @sta_param: Add sta params |
| 450 | * @bssid: BSSID |
| 451 | * @ht_capable: HT capability |
| 452 | * @session_entry: PE session entry |
| 453 | * |
| 454 | * This function is called to update station parameters |
| 455 | * |
| 456 | * Return: None |
| 457 | */ |
| 458 | static void mlm_add_sta(tpAniSirGlobal mac_ctx, tpAddStaParams sta_param, |
| 459 | uint8_t *bssid, uint8_t ht_capable, tpPESession session_entry) |
| 460 | { |
| 461 | uint32_t val; |
| 462 | uint32_t self_dot11mode = 0; |
| 463 | |
| 464 | wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_dot11mode); |
| 465 | sta_param->staType = STA_ENTRY_SELF; /* Identifying self */ |
| 466 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 467 | qdf_mem_copy(sta_param->bssId, bssid, sizeof(tSirMacAddr)); |
| 468 | qdf_mem_copy(sta_param->staMac, session_entry->selfMacAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 469 | sizeof(tSirMacAddr)); |
| 470 | |
| 471 | /* Configuration related parameters to be changed to support BT-AMP */ |
| 472 | |
| 473 | if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, |
| 474 | &val)) |
| 475 | lim_log(mac_ctx, LOGP, FL("Couldn't get LISTEN_INTERVAL")); |
| 476 | sta_param->listenInterval = (uint16_t) val; |
| 477 | |
| 478 | if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx, WNI_CFG_SHORT_PREAMBLE, |
| 479 | &val)) |
| 480 | lim_log(mac_ctx, LOGP, FL("Couldn't get SHORT_PREAMBLE")); |
| 481 | sta_param->shortPreambleSupported = (uint8_t) val; |
| 482 | |
| 483 | sta_param->assocId = 0; /* Is SMAC OK with this? */ |
| 484 | sta_param->wmmEnabled = 0; |
| 485 | sta_param->uAPSD = 0; |
| 486 | sta_param->maxSPLen = 0; |
| 487 | sta_param->us32MaxAmpduDuration = 0; |
| 488 | sta_param->maxAmpduSize = 0; /* 0: 8k, 1: 16k,2: 32k,3: 64k, 4:128k */ |
| 489 | |
| 490 | /* For Self STA get the LDPC capability from config.ini */ |
| 491 | sta_param->htLdpcCapable = |
| 492 | (session_entry->txLdpcIniFeatureEnabled & 0x01); |
| 493 | sta_param->vhtLdpcCapable = |
| 494 | ((session_entry->txLdpcIniFeatureEnabled >> 1) & 0x01); |
| 495 | |
| 496 | if (IS_DOT11_MODE_HT(session_entry->dot11mode)) { |
| 497 | sta_param->htCapable = ht_capable; |
| 498 | sta_param->greenFieldCapable = |
| 499 | lim_get_ht_capability(mac_ctx, eHT_GREENFIELD, |
| 500 | session_entry); |
| 501 | sta_param->ch_width = |
| 502 | lim_get_ht_capability(mac_ctx, |
| 503 | eHT_SUPPORTED_CHANNEL_WIDTH_SET, session_entry); |
| 504 | sta_param->mimoPS = |
| 505 | (tSirMacHTMIMOPowerSaveState)lim_get_ht_capability( |
| 506 | mac_ctx, eHT_MIMO_POWER_SAVE, session_entry); |
| 507 | sta_param->rifsMode = |
| 508 | lim_get_ht_capability(mac_ctx, eHT_RIFS_MODE, |
| 509 | session_entry); |
| 510 | sta_param->lsigTxopProtection = |
| 511 | lim_get_ht_capability(mac_ctx, eHT_LSIG_TXOP_PROTECTION, |
| 512 | session_entry); |
| 513 | sta_param->maxAmpduDensity = |
| 514 | lim_get_ht_capability(mac_ctx, eHT_MPDU_DENSITY, |
| 515 | session_entry); |
| 516 | sta_param->maxAmsduSize = |
| 517 | lim_get_ht_capability(mac_ctx, eHT_MAX_AMSDU_LENGTH, |
| 518 | session_entry); |
| 519 | sta_param->fDsssCckMode40Mhz = |
| 520 | lim_get_ht_capability(mac_ctx, eHT_DSSS_CCK_MODE_40MHZ, |
| 521 | session_entry); |
| 522 | sta_param->fShortGI20Mhz = |
| 523 | lim_get_ht_capability(mac_ctx, eHT_SHORT_GI_20MHZ, |
| 524 | session_entry); |
| 525 | sta_param->fShortGI40Mhz = |
| 526 | lim_get_ht_capability(mac_ctx, eHT_SHORT_GI_40MHZ, |
| 527 | session_entry); |
| 528 | } |
| 529 | if (session_entry->vhtCapability) { |
| 530 | sta_param->vhtCapable = true; |
| 531 | sta_param->vhtTxBFCapable = |
| 532 | session_entry->txBFIniFeatureEnabled; |
| 533 | sta_param->vhtTxMUBformeeCapable = session_entry->txMuBformee; |
| 534 | sta_param->enable_su_tx_bformer = |
| 535 | session_entry->enable_su_tx_bformer; |
| 536 | } |
| 537 | /* |
| 538 | * Since this is Self-STA, need to populate Self MAX_AMPDU_SIZE |
| 539 | * capabilities |
| 540 | */ |
| 541 | if (IS_DOT11_MODE_VHT(self_dot11mode)) { |
| 542 | val = 0; /* Default 8K AMPDU size */ |
| 543 | if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx, |
| 544 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, &val)) |
| 545 | lim_log(mac_ctx, LOGE, FL |
| 546 | ("Couldn't get WNI_CFG_VHT_AMPDU_LEN_EXPONENT")); |
| 547 | sta_param->maxAmpduSize = (uint8_t) val; |
| 548 | } |
| 549 | sta_param->enableVhtpAid = session_entry->enableVhtpAid; |
| 550 | sta_param->enableAmpduPs = session_entry->enableAmpduPs; |
| 551 | sta_param->enableHtSmps = session_entry->enableHtSmps; |
| 552 | sta_param->htSmpsconfig = session_entry->htSmpsvalue; |
Archana Ramachandran | fec2481 | 2016-02-16 16:31:56 -0800 | [diff] [blame] | 553 | sta_param->send_smps_action = session_entry->send_smps_action; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 554 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 555 | lim_populate_own_rate_set(mac_ctx, &sta_param->supportedRates, NULL, |
| 556 | false, session_entry, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 557 | |
| 558 | lim_log(mac_ctx, LOGE, FL( |
| 559 | "GF: %d, ChnlWidth: %d, MimoPS: %d, lsigTXOP: %d, dsssCCK: %d," |
| 560 | " SGI20: %d, SGI40%d"), sta_param->greenFieldCapable, |
| 561 | sta_param->ch_width, sta_param->mimoPS, |
| 562 | sta_param->lsigTxopProtection, sta_param->fDsssCckMode40Mhz, |
| 563 | sta_param->fShortGI20Mhz, sta_param->fShortGI40Mhz); |
| 564 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 565 | if (QDF_P2P_GO_MODE == session_entry->pePersona) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 566 | sta_param->p2pCapableSta = 1; |
| 567 | } |
| 568 | |
| 569 | /** |
| 570 | * lim_mlm_add_bss() - HAL interface for WMA_ADD_BSS_REQ |
| 571 | * @mac_ctx: global MAC context |
| 572 | * @mlm_start_req: MLM start request |
| 573 | * @session: PE session entry |
| 574 | * |
| 575 | * Package WMA_ADD_BSS_REQ to HAL, in order to start a BSS |
| 576 | * |
| 577 | * Return: eSIR_SME_SUCCESS on success, other error codes otherwise |
| 578 | */ |
| 579 | tSirResultCodes |
| 580 | lim_mlm_add_bss(tpAniSirGlobal mac_ctx, |
| 581 | tLimMlmStartReq *mlm_start_req, tpPESession session) |
| 582 | { |
| 583 | tSirMsgQ msg_buf; |
| 584 | tpAddBssParams addbss_param = NULL; |
| 585 | uint32_t retcode; |
Sandeep Puligilla | 2111d3c | 2016-02-03 01:46:15 -0800 | [diff] [blame] | 586 | bool is_ch_dfs = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 587 | |
| 588 | /* Package WMA_ADD_BSS_REQ message parameters */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 589 | addbss_param = qdf_mem_malloc(sizeof(tAddBssParams)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 590 | if (NULL == addbss_param) { |
| 591 | lim_log(mac_ctx, LOGE, |
| 592 | FL("Unable to allocate memory during ADD_BSS")); |
| 593 | /* Respond to SME with LIM_MLM_START_CNF */ |
| 594 | return eSIR_MEM_ALLOC_FAILED; |
| 595 | } |
| 596 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 597 | qdf_mem_set(addbss_param, sizeof(tAddBssParams), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 598 | /* Fill in tAddBssParams members */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 599 | qdf_mem_copy(addbss_param->bssId, mlm_start_req->bssId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 600 | sizeof(tSirMacAddr)); |
| 601 | |
| 602 | /* Fill in tAddBssParams selfMacAddr */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 603 | qdf_mem_copy(addbss_param->selfMacAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 604 | session->selfMacAddr, sizeof(tSirMacAddr)); |
| 605 | |
| 606 | addbss_param->bssType = mlm_start_req->bssType; |
Rajeev Kumar | aa262c4 | 2016-04-15 15:41:08 -0700 | [diff] [blame^] | 607 | if ((mlm_start_req->bssType == eSIR_IBSS_MODE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 608 | addbss_param->operMode = BSS_OPERATIONAL_MODE_STA; |
| 609 | } else if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE) { |
| 610 | addbss_param->operMode = BSS_OPERATIONAL_MODE_AP; |
| 611 | } |
| 612 | |
| 613 | addbss_param->shortSlotTimeSupported = session->shortSlotTimeSupported; |
| 614 | addbss_param->beaconInterval = mlm_start_req->beaconPeriod; |
| 615 | addbss_param->dtimPeriod = mlm_start_req->dtimPeriod; |
| 616 | addbss_param->wps_state = mlm_start_req->wps_state; |
| 617 | addbss_param->cfParamSet.cfpCount = mlm_start_req->cfParamSet.cfpCount; |
| 618 | addbss_param->cfParamSet.cfpPeriod = |
| 619 | mlm_start_req->cfParamSet.cfpPeriod; |
| 620 | addbss_param->cfParamSet.cfpMaxDuration = |
| 621 | mlm_start_req->cfParamSet.cfpMaxDuration; |
| 622 | addbss_param->cfParamSet.cfpDurRemaining = |
| 623 | mlm_start_req->cfParamSet.cfpDurRemaining; |
| 624 | |
| 625 | addbss_param->rateSet.numRates = mlm_start_req->rateSet.numRates; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 626 | qdf_mem_copy(addbss_param->rateSet.rate, mlm_start_req->rateSet.rate, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 627 | mlm_start_req->rateSet.numRates); |
| 628 | |
| 629 | addbss_param->nwType = mlm_start_req->nwType; |
| 630 | addbss_param->htCapable = mlm_start_req->htCapable; |
| 631 | addbss_param->vhtCapable = session->vhtCapability; |
| 632 | addbss_param->ch_width = session->ch_width; |
| 633 | addbss_param->ch_center_freq_seg0 = |
| 634 | session->ch_center_freq_seg0; |
| 635 | addbss_param->ch_center_freq_seg1 = |
| 636 | session->ch_center_freq_seg1; |
| 637 | addbss_param->htOperMode = mlm_start_req->htOperMode; |
| 638 | addbss_param->dualCTSProtection = mlm_start_req->dualCTSProtection; |
| 639 | addbss_param->txChannelWidthSet = mlm_start_req->txChannelWidthSet; |
| 640 | |
| 641 | addbss_param->currentOperChannel = mlm_start_req->channelNumber; |
| 642 | #ifdef WLAN_FEATURE_11W |
| 643 | addbss_param->rmfEnabled = session->limRmfEnabled; |
| 644 | #endif |
| 645 | |
| 646 | /* Update PE sessionId */ |
| 647 | addbss_param->sessionId = mlm_start_req->sessionId; |
| 648 | |
| 649 | /* Send the SSID to HAL to enable SSID matching for IBSS */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 650 | qdf_mem_copy(&(addbss_param->ssId.ssId), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 651 | mlm_start_req->ssId.ssId, mlm_start_req->ssId.length); |
| 652 | addbss_param->ssId.length = mlm_start_req->ssId.length; |
| 653 | addbss_param->bHiddenSSIDEn = mlm_start_req->ssidHidden; |
| 654 | lim_log(mac_ctx, LOGE, FL("TRYING TO HIDE SSID %d"), |
| 655 | addbss_param->bHiddenSSIDEn); |
| 656 | /* CR309183. Disable Proxy Probe Rsp. Host handles Probe Requests. Until FW fixed. */ |
| 657 | addbss_param->bProxyProbeRespEn = 0; |
| 658 | addbss_param->obssProtEnabled = mlm_start_req->obssProtEnabled; |
| 659 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 660 | addbss_param->maxTxPower = session->maxTxPower; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 661 | mlm_add_sta(mac_ctx, &addbss_param->staContext, |
| 662 | addbss_param->bssId, addbss_param->htCapable, |
| 663 | session); |
| 664 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 665 | addbss_param->status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 666 | addbss_param->respReqd = 1; |
| 667 | |
| 668 | /* Set a new state for MLME */ |
| 669 | session->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_STATE; |
| 670 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId, |
| 671 | session->limMlmState)); |
| 672 | |
| 673 | /* pass on the session persona to hal */ |
| 674 | addbss_param->halPersona = session->pePersona; |
| 675 | |
Sandeep Puligilla | 2111d3c | 2016-02-03 01:46:15 -0800 | [diff] [blame] | 676 | if (session->ch_width == CH_WIDTH_160MHZ) { |
| 677 | is_ch_dfs = true; |
| 678 | } else if (session->ch_width == CH_WIDTH_80P80MHZ) { |
| 679 | if (cds_get_channel_state(mlm_start_req->channelNumber) == |
| 680 | CHANNEL_STATE_DFS || |
| 681 | cds_get_channel_state(session->ch_center_freq_seg1 - |
| 682 | SIR_80MHZ_START_CENTER_CH_DIFF) == |
| 683 | CHANNEL_STATE_DFS) |
| 684 | is_ch_dfs = true; |
| 685 | } else { |
| 686 | if (cds_get_channel_state(mlm_start_req->channelNumber) == |
| 687 | CHANNEL_STATE_DFS) |
| 688 | is_ch_dfs = true; |
| 689 | } |
| 690 | |
| 691 | addbss_param->bSpectrumMgtEnabled = |
| 692 | session->spectrumMgtEnabled || is_ch_dfs; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 693 | addbss_param->extSetStaKeyParamValid = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 694 | |
| 695 | addbss_param->dot11_mode = session->dot11mode; |
| 696 | addbss_param->nss = session->nss; |
| 697 | lim_log(mac_ctx, LOG2, FL("dot11_mode:%d nss value:%d"), |
| 698 | addbss_param->dot11_mode, addbss_param->nss); |
| 699 | |
| 700 | msg_buf.type = WMA_ADD_BSS_REQ; |
| 701 | msg_buf.reserved = 0; |
| 702 | msg_buf.bodyptr = addbss_param; |
| 703 | msg_buf.bodyval = 0; |
| 704 | MTRACE(mac_trace_msg_tx(mac_ctx, session->peSessionId, msg_buf.type)); |
| 705 | |
| 706 | lim_log(mac_ctx, LOGW, FL("Sending WMA_ADD_BSS_REQ...")); |
| 707 | retcode = wma_post_ctrl_msg(mac_ctx, &msg_buf); |
| 708 | if (eSIR_SUCCESS != retcode) { |
| 709 | lim_log(mac_ctx, LOGE, |
| 710 | FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"), |
| 711 | retcode); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 712 | qdf_mem_free(addbss_param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 713 | return eSIR_SME_HAL_SEND_MESSAGE_FAIL; |
| 714 | } |
| 715 | |
| 716 | return eSIR_SME_SUCCESS; |
| 717 | } |
| 718 | |
| 719 | /** |
| 720 | * lim_process_mlm_start_req() - process MLM_START_REQ message |
| 721 | * |
| 722 | * @mac_ctx: global MAC context |
| 723 | * @msg_buf: Pointer to MLM message buffer |
| 724 | * |
| 725 | * This function is called to process MLM_START_REQ message |
| 726 | * from SME |
| 727 | * 1) MLME receives LIM_MLM_START_REQ from LIM |
| 728 | * 2) MLME sends WMA_ADD_BSS_REQ to HAL |
| 729 | * 3) MLME changes state to eLIM_MLM_WT_ADD_BSS_RSP_STATE |
| 730 | * MLME now waits for HAL to send WMA_ADD_BSS_RSP |
| 731 | * |
| 732 | * Return: None |
| 733 | */ |
| 734 | static void lim_process_mlm_start_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf) |
| 735 | { |
| 736 | tLimMlmStartReq *mlm_start_req; |
| 737 | tLimMlmStartCnf mlm_start_cnf; |
| 738 | tpPESession session = NULL; |
| 739 | |
| 740 | if (msg_buf == NULL) { |
| 741 | lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL")); |
| 742 | return; |
| 743 | } |
| 744 | |
| 745 | mlm_start_req = (tLimMlmStartReq *) msg_buf; |
| 746 | session = pe_find_session_by_session_id(mac_ctx, |
| 747 | mlm_start_req->sessionId); |
| 748 | if (NULL == session) { |
| 749 | lim_log(mac_ctx, LOGP, |
| 750 | FL("Session Does not exist for given sessionID")); |
| 751 | mlm_start_cnf.resultCode = eSIR_SME_REFUSED; |
| 752 | goto end; |
| 753 | } |
| 754 | |
| 755 | if (session->limMlmState != eLIM_MLM_IDLE_STATE) { |
| 756 | /* |
| 757 | * Should not have received Start req in states other than idle. |
| 758 | * Return Start confirm with failure code. |
| 759 | */ |
| 760 | lim_log(mac_ctx, LOGE, |
| 761 | FL("received unexpected MLM_START_REQ in state %X"), |
| 762 | session->limMlmState); |
| 763 | lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState); |
| 764 | mlm_start_cnf.resultCode = |
| 765 | eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED; |
| 766 | goto end; |
| 767 | } |
| 768 | |
| 769 | mlm_start_cnf.resultCode = |
| 770 | lim_mlm_add_bss(mac_ctx, mlm_start_req, session); |
| 771 | |
| 772 | end: |
| 773 | /* Update PE session Id */ |
| 774 | mlm_start_cnf.sessionId = mlm_start_req->sessionId; |
| 775 | |
| 776 | /* Free up buffer allocated for LimMlmScanReq */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 777 | qdf_mem_free(msg_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 778 | |
| 779 | /* |
| 780 | * Respond immediately to LIM, only if MLME has not been |
| 781 | * successfully able to send WMA_ADD_BSS_REQ to HAL. |
| 782 | * Else, LIM_MLM_START_CNF will be sent after receiving |
| 783 | * WMA_ADD_BSS_RSP from HAL |
| 784 | */ |
| 785 | if (eSIR_SME_SUCCESS != mlm_start_cnf.resultCode) |
| 786 | lim_post_sme_message(mac_ctx, LIM_MLM_START_CNF, |
| 787 | (uint32_t *) &mlm_start_cnf); |
| 788 | } |
| 789 | |
| 790 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 791 | /** |
| 792 | * lim_process_mlm_oem_data_req() - process MLM OEM_DATA_REQ message |
| 793 | * @mac_ctx: global MAC context |
| 794 | * @msg_buf: MLM message buffer |
| 795 | * |
| 796 | * This function process MLM OEM_DATA_REQ message. |
| 797 | * |
| 798 | * Return: None |
| 799 | */ |
| 800 | static void lim_process_mlm_oem_data_req(tpAniSirGlobal mac_ctx, |
| 801 | uint32_t *msg_buf) |
| 802 | { |
| 803 | tLimMlmOemDataRsp *mlm_oem_data_rsp; |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 804 | tLimMlmOemDataReq *data_req = (tLimMlmOemDataReq *) msg_buf; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 805 | |
| 806 | if (((mac_ctx->lim.gLimMlmState == eLIM_MLM_IDLE_STATE) || |
| 807 | (mac_ctx->lim.gLimMlmState == eLIM_MLM_JOINED_STATE) || |
| 808 | (mac_ctx->lim.gLimMlmState == eLIM_MLM_AUTHENTICATED_STATE) || |
| 809 | (mac_ctx->lim.gLimMlmState == eLIM_MLM_BSS_STARTED_STATE) || |
| 810 | (mac_ctx->lim.gLimMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE))) { |
| 811 | /* |
| 812 | * Hold onto the oem data request criteria |
| 813 | * Free gpLimMlmOemDataReq to avoid memory leak due to |
| 814 | * second OEM data request |
| 815 | */ |
| 816 | if (mac_ctx->lim.gpLimMlmOemDataReq) { |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 817 | if (mac_ctx->lim.gpLimMlmOemDataReq->data) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 818 | qdf_mem_free( |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 819 | mac_ctx->lim.gpLimMlmOemDataReq->data); |
| 820 | mac_ctx->lim.gpLimMlmOemDataReq->data = |
| 821 | NULL; |
| 822 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 823 | qdf_mem_free(mac_ctx->lim.gpLimMlmOemDataReq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 824 | mac_ctx->lim.gpLimMlmOemDataReq = NULL; |
| 825 | } |
| 826 | |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 827 | mac_ctx->lim.gpLimMlmOemDataReq = data_req; |
| 828 | mac_ctx->lim.gpLimMlmOemDataReq->data = |
| 829 | data_req->data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 830 | mac_ctx->lim.gLimPrevMlmState = mac_ctx->lim.gLimMlmState; |
| 831 | |
| 832 | lim_log(mac_ctx, LOG2, FL("Calling lim_send_hal_oem_data_req")); |
| 833 | lim_send_hal_oem_data_req(mac_ctx); |
| 834 | } else { |
| 835 | /* Should not have received oem data req in other states */ |
| 836 | lim_log(mac_ctx, LOGW, FL |
| 837 | ("unexpected LIM_MLM_OEM_DATA_REQ in invalid state %X"), |
| 838 | mac_ctx->lim.gLimMlmState); |
| 839 | lim_print_mlm_state(mac_ctx, LOGW, mac_ctx->lim.gLimMlmState); |
| 840 | |
| 841 | /* Free up buffer allocated */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 842 | qdf_mem_free(msg_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 843 | |
| 844 | /* Return Meas confirm with INVALID_PARAMETERS */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 845 | mlm_oem_data_rsp = qdf_mem_malloc(sizeof(tLimMlmOemDataRsp)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 846 | if (mlm_oem_data_rsp != NULL) { |
Krishna Kumaar Natarajan | 4e9cf39 | 2015-11-20 13:35:05 -0800 | [diff] [blame] | 847 | mlm_oem_data_rsp->target_rsp = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 848 | lim_post_sme_message(mac_ctx, LIM_MLM_OEM_DATA_CNF, |
| 849 | (uint32_t *) mlm_oem_data_rsp); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 850 | qdf_mem_free(mlm_oem_data_rsp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 851 | } else { |
| 852 | lim_log(mac_ctx, LOGP, FL |
| 853 | ("Could not allocate memory for mlm_oem_data_rsp")); |
| 854 | return; |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | return; |
| 859 | } |
| 860 | #endif /* FEATURE_OEM_DATA_SUPPORT */ |
| 861 | /** |
| 862 | * lim_post_join_set_link_state_callback()- registered callback to perform post |
| 863 | * peer creation operations |
| 864 | * |
| 865 | * @mac: pointer to global mac structure |
| 866 | * @callback_arg: registered callback argument |
| 867 | * @status: peer creation status |
| 868 | * |
| 869 | * this is registered callback function during association to perform |
| 870 | * post peer creation operation based on the peer creation status |
| 871 | * |
| 872 | * Return: none |
| 873 | */ |
| 874 | void lim_post_join_set_link_state_callback(tpAniSirGlobal mac, |
| 875 | void *callback_arg, bool status) |
| 876 | { |
| 877 | uint8_t chan_num, sec_chan_offset; |
| 878 | tpPESession session_entry = (tpPESession) callback_arg; |
| 879 | tLimMlmJoinCnf mlm_join_cnf; |
| 880 | |
| 881 | lim_log(mac, LOG1, FL("Sessionid %d set link state(%d) cb status:%d"), |
| 882 | session_entry->peSessionId, session_entry->limMlmState, |
| 883 | status); |
| 884 | |
| 885 | if (!status) { |
| 886 | lim_log(mac, LOGE, |
| 887 | FL("failed to find pe session for session id:%d"), |
| 888 | session_entry->peSessionId); |
| 889 | goto failure; |
| 890 | } |
| 891 | |
| 892 | chan_num = session_entry->currentOperChannel; |
| 893 | sec_chan_offset = session_entry->htSecondaryChannelOffset; |
| 894 | /* |
| 895 | * store the channel switch session_entry in the lim |
| 896 | * global variable |
| 897 | */ |
| 898 | session_entry->channelChangeReasonCode = |
| 899 | LIM_SWITCH_CHANNEL_JOIN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 900 | session_entry->pLimMlmReassocRetryReq = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 901 | lim_log(mac, LOGE, |
| 902 | FL("[lim_process_mlm_join_req]: suspend link success(%d) " |
| 903 | "on sessionid: %d setting channel to: %d with ch_width :%d " |
| 904 | "and maxtxPower: %d"), status, session_entry->peSessionId, |
| 905 | session_entry->currentOperChannel, |
| 906 | session_entry->ch_width, |
| 907 | session_entry->maxTxPower); |
| 908 | lim_set_channel(mac, session_entry->currentOperChannel, |
| 909 | session_entry->ch_center_freq_seg0, |
| 910 | session_entry->ch_center_freq_seg1, |
| 911 | session_entry->ch_width, |
| 912 | session_entry->maxTxPower, |
| 913 | session_entry->peSessionId); |
| 914 | return; |
| 915 | |
| 916 | failure: |
| 917 | MTRACE(mac_trace(mac, TRACE_CODE_MLM_STATE, session_entry->peSessionId, |
| 918 | session_entry->limMlmState)); |
| 919 | session_entry->limMlmState = eLIM_MLM_IDLE_STATE; |
| 920 | mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE; |
| 921 | mlm_join_cnf.sessionId = session_entry->peSessionId; |
| 922 | mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 923 | lim_post_sme_message(mac, LIM_MLM_JOIN_CNF, (uint32_t *) &mlm_join_cnf); |
| 924 | } |
| 925 | |
| 926 | /** |
| 927 | * lim_process_mlm_post_join_suspend_link() - This function is called after the |
| 928 | * suspend link while joining off channel. |
| 929 | * |
| 930 | * @mac_ctx: Pointer to Global MAC structure |
| 931 | * @status: status of suspend link. |
| 932 | * @ctx: passed while calling suspend link(session) |
| 933 | * |
| 934 | * This function does following: |
| 935 | * Check for suspend state. |
| 936 | * If success, proceed with setting link state to recieve the |
| 937 | * probe response/beacon from intended AP. |
| 938 | * Switch to the APs channel. |
| 939 | * On an error case, send the MLM_JOIN_CNF with error status. |
| 940 | * |
| 941 | * @Return None |
| 942 | */ |
| 943 | static void |
| 944 | lim_process_mlm_post_join_suspend_link(tpAniSirGlobal mac_ctx, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 945 | QDF_STATUS status, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 946 | uint32_t *ctx) |
| 947 | { |
| 948 | tLimMlmJoinCnf mlm_join_cnf; |
| 949 | tpPESession session = (tpPESession) ctx; |
| 950 | tSirLinkState lnk_state; |
| 951 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 952 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 953 | lim_log(mac_ctx, LOGE, |
| 954 | FL("Sessionid %d Suspend link(NOTIFY_BSS) failed. Still proceeding with join"), |
| 955 | session->peSessionId); |
| 956 | } |
| 957 | lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER); |
| 958 | |
| 959 | /* assign appropriate sessionId to the timer object */ |
| 960 | mac_ctx->lim.limTimers.gLimJoinFailureTimer.sessionId = |
| 961 | session->peSessionId; |
| 962 | |
Rajeev Kumar | aa262c4 | 2016-04-15 15:41:08 -0700 | [diff] [blame^] | 963 | lnk_state = eSIR_LINK_PREASSOC_STATE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | lim_log(mac_ctx, LOG1, FL("[lim_process_mlm_join_req]: lnk_state:%d"), |
| 965 | lnk_state); |
| 966 | |
| 967 | if (lim_set_link_state(mac_ctx, lnk_state, |
| 968 | session->pLimMlmJoinReq->bssDescription.bssId, |
| 969 | session->selfMacAddr, |
| 970 | lim_post_join_set_link_state_callback, |
| 971 | session) != eSIR_SUCCESS) { |
| 972 | lim_log(mac_ctx, LOGE, |
| 973 | FL("SessionId:%d lim_set_link_state to eSIR_LINK_PREASSOC_STATE Failed!!"), |
| 974 | session->peSessionId); |
| 975 | lim_print_mac_addr(mac_ctx, |
| 976 | session->pLimMlmJoinReq->bssDescription.bssId, LOGE); |
| 977 | mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE; |
| 978 | session->limMlmState = eLIM_MLM_IDLE_STATE; |
| 979 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, |
| 980 | session->peSessionId, session->limMlmState)); |
| 981 | goto error; |
| 982 | } |
| 983 | |
| 984 | return; |
| 985 | error: |
| 986 | mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE; |
| 987 | mlm_join_cnf.sessionId = session->peSessionId; |
| 988 | mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 989 | lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF, |
| 990 | (uint32_t *) &mlm_join_cnf); |
| 991 | } |
| 992 | |
| 993 | /** |
| 994 | * lim_process_mlm_join_req() - process mlm join request. |
| 995 | * |
| 996 | * @mac_ctx: Pointer to Global MAC structure |
| 997 | * @msg: Pointer to the MLM message buffer |
| 998 | * |
| 999 | * This function is called to process MLM_JOIN_REQ message |
| 1000 | * from SME. It does following: |
| 1001 | * 1) Initialize LIM, HAL, DPH |
| 1002 | * 2) Configure the BSS for which the JOIN REQ was received |
| 1003 | * a) Send WMA_ADD_BSS_REQ to HAL - |
| 1004 | * This will identify the BSS that we are interested in |
| 1005 | * --AND-- |
| 1006 | * Add a STA entry for the AP (in a STA context) |
| 1007 | * b) Wait for WMA_ADD_BSS_RSP |
| 1008 | * c) Send WMA_ADD_STA_REQ to HAL |
| 1009 | * This will add the "local STA" entry to the STA table |
| 1010 | * 3) Continue as before, i.e, |
| 1011 | * a) Send a PROBE REQ |
| 1012 | * b) Wait for PROBE RSP/BEACON containing the SSID that |
| 1013 | * we are interested in |
| 1014 | * c) Then start an AUTH seq |
| 1015 | * d) Followed by the ASSOC seq |
| 1016 | * |
| 1017 | * @Return: None |
| 1018 | */ |
| 1019 | static void lim_process_mlm_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg) |
| 1020 | { |
| 1021 | tLimMlmJoinCnf mlmjoin_cnf; |
| 1022 | uint8_t sessionid; |
| 1023 | tpPESession session; |
| 1024 | |
| 1025 | sessionid = ((tpLimMlmJoinReq) msg)->sessionId; |
| 1026 | |
| 1027 | session = pe_find_session_by_session_id(mac_ctx, sessionid); |
| 1028 | if (NULL == session) { |
| 1029 | lim_log(mac_ctx, LOGE, FL("SessionId:%d does not exist"), |
| 1030 | sessionid); |
| 1031 | goto error; |
| 1032 | } |
| 1033 | |
Rajeev Kumar | aa262c4 | 2016-04-15 15:41:08 -0700 | [diff] [blame^] | 1034 | if (!LIM_IS_AP_ROLE(session) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1035 | ((session->limMlmState == eLIM_MLM_IDLE_STATE) || |
| 1036 | (session->limMlmState == eLIM_MLM_JOINED_STATE)) && |
| 1037 | (SIR_MAC_GET_ESS |
| 1038 | (((tpLimMlmJoinReq) msg)->bssDescription.capabilityInfo) != |
| 1039 | SIR_MAC_GET_IBSS(((tpLimMlmJoinReq) msg)->bssDescription. |
| 1040 | capabilityInfo))) { |
| 1041 | /* Hold onto Join request parameters */ |
| 1042 | |
| 1043 | session->pLimMlmJoinReq = (tpLimMlmJoinReq) msg; |
| 1044 | if (is_lim_session_off_channel(mac_ctx, sessionid)) { |
| 1045 | lim_log(mac_ctx, LOG1, |
| 1046 | "SessionId:%d LimSession is on OffChannel", |
| 1047 | sessionid); |
| 1048 | /* suspend link */ |
| 1049 | lim_log(mac_ctx, LOG1, |
| 1050 | FL("Suspend link, sessionid %d is off channel"), |
| 1051 | sessionid); |
| 1052 | if (lim_is_link_suspended(mac_ctx)) { |
| 1053 | lim_log(mac_ctx, LOGE, FL( |
| 1054 | "link is already suspended, session %d" |
| 1055 | ), sessionid); |
| 1056 | goto error; |
| 1057 | } |
| 1058 | lim_process_mlm_post_join_suspend_link(mac_ctx, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1059 | QDF_STATUS_SUCCESS, (uint32_t *)session); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1060 | } else { |
| 1061 | lim_log(mac_ctx, LOG1, FL("No need to Suspend link")); |
| 1062 | /* |
| 1063 | * No need to Suspend link as LimSession is not |
| 1064 | * off channel, calling |
| 1065 | * lim_process_mlm_post_join_suspend_link with |
| 1066 | * status as SUCCESS. |
| 1067 | */ |
| 1068 | lim_log(mac_ctx, LOG1, |
| 1069 | FL("SessionId:%d Join req on current chan"), |
| 1070 | sessionid); |
| 1071 | lim_process_mlm_post_join_suspend_link(mac_ctx, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1072 | QDF_STATUS_SUCCESS, (uint32_t *)session); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1073 | } |
| 1074 | return; |
| 1075 | } else { |
| 1076 | /** |
| 1077 | * Should not have received JOIN req in states other than |
| 1078 | * Idle state or on AP. |
| 1079 | * Return join confirm with invalid parameters code. |
| 1080 | */ |
| 1081 | lim_log(mac_ctx, LOGE, |
| 1082 | FL("Session:%d Unexpected Join req, role %d state %X"), |
| 1083 | session->peSessionId, GET_LIM_SYSTEM_ROLE(session), |
| 1084 | session->limMlmState); |
| 1085 | lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState); |
| 1086 | } |
| 1087 | |
| 1088 | error: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1089 | qdf_mem_free(msg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1090 | if (session != NULL) |
| 1091 | session->pLimMlmJoinReq = NULL; |
| 1092 | mlmjoin_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE; |
| 1093 | mlmjoin_cnf.sessionId = sessionid; |
| 1094 | mlmjoin_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 1095 | lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF, |
| 1096 | (uint32_t *)&mlmjoin_cnf); |
| 1097 | |
| 1098 | } |
| 1099 | |
| 1100 | /** |
| 1101 | * lim_is_auth_req_expected() - check if auth request is expected |
| 1102 | * |
| 1103 | * @mac_ctx: global MAC context |
| 1104 | * @session: PE session entry |
| 1105 | * |
| 1106 | * This function is called by lim_process_mlm_auth_req to check |
| 1107 | * if auth request is expected. |
| 1108 | * |
| 1109 | * Return: true if expected and false otherwise |
| 1110 | */ |
| 1111 | static bool lim_is_auth_req_expected(tpAniSirGlobal mac_ctx, |
| 1112 | tpPESession session) |
| 1113 | { |
| 1114 | bool flag = false; |
| 1115 | |
| 1116 | /* |
| 1117 | * Expect Auth request only when: |
| 1118 | * 1. STA joined/associated with a BSS or |
| 1119 | * 2. STA is in IBSS mode |
| 1120 | * and STA is going to authenticate with a unicast |
| 1121 | * address and requested authentication algorithm is |
| 1122 | * supported. |
| 1123 | */ |
| 1124 | |
Rajeev Kumar | aa262c4 | 2016-04-15 15:41:08 -0700 | [diff] [blame^] | 1125 | flag = (((LIM_IS_STA_ROLE(session) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1126 | ((session->limMlmState == eLIM_MLM_JOINED_STATE) || |
| 1127 | (session->limMlmState == |
| 1128 | eLIM_MLM_LINK_ESTABLISHED_STATE))) || |
| 1129 | (LIM_IS_IBSS_ROLE(session) && |
| 1130 | (session->limMlmState == |
| 1131 | eLIM_MLM_BSS_STARTED_STATE))) && |
| 1132 | (!lim_is_group_addr(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr)) |
| 1133 | && lim_is_auth_algo_supported(mac_ctx, |
| 1134 | mac_ctx->lim.gpLimMlmAuthReq->authType, session)); |
| 1135 | |
| 1136 | return flag; |
| 1137 | } |
| 1138 | |
| 1139 | /** |
| 1140 | * lim_is_preauth_ctx_exisits() - check if preauth context exists |
| 1141 | * |
| 1142 | * @mac_ctx: global MAC context |
| 1143 | * @session: PE session entry |
| 1144 | * @preauth_node_ptr: pointer to preauth node pointer |
| 1145 | * |
| 1146 | * This function is called by lim_process_mlm_auth_req to check |
| 1147 | * if preauth context already exists |
| 1148 | * |
| 1149 | * Return: true if exists and false otherwise |
| 1150 | */ |
| 1151 | static bool lim_is_preauth_ctx_exists(tpAniSirGlobal mac_ctx, |
| 1152 | tpPESession session, |
| 1153 | struct tLimPreAuthNode **preauth_node_ptr) |
| 1154 | { |
| 1155 | bool fl = false; |
| 1156 | struct tLimPreAuthNode *preauth_node; |
| 1157 | tpDphHashNode stads; |
| 1158 | tSirMacAddr curr_bssid; |
| 1159 | |
| 1160 | preauth_node = *preauth_node_ptr; |
| 1161 | sir_copy_mac_addr(curr_bssid, session->bssId); |
| 1162 | stads = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER, |
| 1163 | &session->dph.dphHashTable); |
| 1164 | preauth_node = lim_search_pre_auth_list(mac_ctx, |
| 1165 | mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr); |
| 1166 | |
Rajeev Kumar | aa262c4 | 2016-04-15 15:41:08 -0700 | [diff] [blame^] | 1167 | fl = (((LIM_IS_STA_ROLE(session)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1168 | (session->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE) && |
| 1169 | ((stads != NULL) && |
| 1170 | (mac_ctx->lim.gpLimMlmAuthReq->authType == |
| 1171 | stads->mlmStaContext.authType)) && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1172 | (!qdf_mem_cmp(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1173 | curr_bssid, sizeof(tSirMacAddr)))) || |
| 1174 | ((preauth_node != NULL) && |
| 1175 | (preauth_node->authType == |
| 1176 | mac_ctx->lim.gpLimMlmAuthReq->authType))); |
| 1177 | |
| 1178 | return fl; |
| 1179 | } |
| 1180 | |
| 1181 | /** |
| 1182 | * lim_process_mlm_auth_req() - process lim auth request |
| 1183 | * |
| 1184 | * @mac_ctx: global MAC context |
| 1185 | * @msg: MLM auth request message |
| 1186 | * |
| 1187 | * This function is called to process MLM_AUTH_REQ message from SME |
| 1188 | * |
| 1189 | * @Return: None |
| 1190 | */ |
| 1191 | static void lim_process_mlm_auth_req(tpAniSirGlobal mac_ctx, uint32_t *msg) |
| 1192 | { |
| 1193 | uint32_t num_preauth_ctx; |
| 1194 | tSirMacAddr curr_bssid; |
| 1195 | tSirMacAuthFrameBody auth_frame_body; |
| 1196 | tLimMlmAuthCnf mlm_auth_cnf; |
| 1197 | struct tLimPreAuthNode *preauth_node = NULL; |
| 1198 | uint8_t session_id; |
| 1199 | tpPESession session; |
| 1200 | |
| 1201 | if (msg == NULL) { |
| 1202 | lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL")); |
| 1203 | return; |
| 1204 | } |
| 1205 | |
| 1206 | mac_ctx->lim.gpLimMlmAuthReq = (tLimMlmAuthReq *) msg; |
| 1207 | session_id = mac_ctx->lim.gpLimMlmAuthReq->sessionId; |
| 1208 | session = pe_find_session_by_session_id(mac_ctx, session_id); |
| 1209 | if (NULL == session) { |
| 1210 | lim_log(mac_ctx, LOGP, FL("SessionId:%d does not exist"), |
| 1211 | session_id); |
| 1212 | return; |
| 1213 | } |
| 1214 | |
| 1215 | lim_log(mac_ctx, LOG1, FL("Process Auth Req sessionID %d Systemrole %d" |
| 1216 | "mlmstate %d from: " MAC_ADDRESS_STR |
| 1217 | " with authtype %d"), session_id, |
| 1218 | GET_LIM_SYSTEM_ROLE(session), session->limMlmState, |
| 1219 | MAC_ADDR_ARRAY(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr), |
| 1220 | mac_ctx->lim.gpLimMlmAuthReq->authType); |
| 1221 | |
| 1222 | sir_copy_mac_addr(curr_bssid, session->bssId); |
| 1223 | |
| 1224 | if (!lim_is_auth_req_expected(mac_ctx, session)) { |
| 1225 | /* |
| 1226 | * Unexpected auth request. |
| 1227 | * Return Auth confirm with Invalid parameters code. |
| 1228 | */ |
| 1229 | mlm_auth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS; |
| 1230 | goto end; |
| 1231 | } |
| 1232 | |
| 1233 | /* |
| 1234 | * This is a request for pre-authentication. Check if there exists |
| 1235 | * context already for the requested peer OR |
| 1236 | * if this request is for the AP we're currently associated with. |
| 1237 | * If yes, return auth confirm immediately when |
| 1238 | * requested auth type is same as the one used before. |
| 1239 | */ |
| 1240 | if (lim_is_preauth_ctx_exists(mac_ctx, session, &preauth_node)) { |
| 1241 | lim_log(mac_ctx, LOG2, |
| 1242 | FL("Already have pre-auth context with peer: " |
| 1243 | MAC_ADDRESS_STR), |
| 1244 | MAC_ADDR_ARRAY(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr)); |
| 1245 | mlm_auth_cnf.resultCode = (tSirResultCodes) |
| 1246 | eSIR_MAC_SUCCESS_STATUS; |
| 1247 | goto end; |
| 1248 | } else { |
| 1249 | if (wlan_cfg_get_int(mac_ctx, WNI_CFG_MAX_NUM_PRE_AUTH, |
| 1250 | (uint32_t *) &num_preauth_ctx) != eSIR_SUCCESS) |
| 1251 | lim_log(mac_ctx, LOGP, |
| 1252 | FL("Could not retrieve NumPreAuthLimit from CFG")); |
| 1253 | |
| 1254 | if (mac_ctx->lim.gLimNumPreAuthContexts == num_preauth_ctx) { |
| 1255 | lim_log(mac_ctx, LOGW, |
| 1256 | FL("Number of pre-auth reached max limit")); |
| 1257 | /* Return Auth confirm with reject code */ |
| 1258 | mlm_auth_cnf.resultCode = |
| 1259 | eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED; |
| 1260 | goto end; |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | /* Delete pre-auth node if exists */ |
| 1265 | if (preauth_node) |
| 1266 | lim_delete_pre_auth_node(mac_ctx, |
| 1267 | mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr); |
| 1268 | |
| 1269 | session->limPrevMlmState = session->limMlmState; |
| 1270 | session->limMlmState = eLIM_MLM_WT_AUTH_FRAME2_STATE; |
| 1271 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId, |
| 1272 | session->limMlmState)); |
| 1273 | |
| 1274 | /* Prepare & send Authentication frame */ |
| 1275 | auth_frame_body.authAlgoNumber = |
| 1276 | (uint8_t) mac_ctx->lim.gpLimMlmAuthReq->authType; |
| 1277 | auth_frame_body.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1; |
| 1278 | auth_frame_body.authStatusCode = 0; |
| 1279 | #ifdef FEATURE_WLAN_DIAG_SUPPORT |
| 1280 | lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_START_EVENT, session, |
| 1281 | eSIR_SUCCESS, auth_frame_body.authStatusCode); |
| 1282 | #endif |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1283 | mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1284 | lim_send_auth_mgmt_frame(mac_ctx, |
| 1285 | &auth_frame_body, mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr, |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1286 | LIM_NO_WEP_IN_FC, session, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1287 | |
| 1288 | /* assign appropriate session_id to the timer object */ |
| 1289 | mac_ctx->lim.limTimers.gLimAuthFailureTimer.sessionId = session_id; |
| 1290 | |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1291 | /* assign appropriate sessionId to the timer object */ |
| 1292 | mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer.sessionId = |
| 1293 | session_id; |
| 1294 | lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1295 | /* Activate Auth failure timer */ |
| 1296 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE, |
| 1297 | session->peSessionId, eLIM_AUTH_FAIL_TIMER)); |
| 1298 | if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimAuthFailureTimer) |
| 1299 | != TX_SUCCESS) { |
| 1300 | /* Could not start Auth failure timer. */ |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1301 | lim_log(mac_ctx, LOGE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1302 | FL("could not start Auth failure timer")); |
| 1303 | /* Cleanup as if auth timer expired */ |
| 1304 | lim_process_auth_failure_timeout(mac_ctx); |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1305 | } else { |
| 1306 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE, |
| 1307 | session->peSessionId, eLIM_AUTH_RETRY_TIMER)); |
| 1308 | /* Activate Auth Retry timer */ |
| 1309 | if (tx_timer_activate |
| 1310 | (&mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer) |
| 1311 | != TX_SUCCESS) |
| 1312 | lim_log(mac_ctx, LOGE, |
| 1313 | FL("could not activate Auth Retry timer")); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1314 | } |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 1315 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1316 | return; |
| 1317 | end: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1318 | qdf_mem_copy((uint8_t *) &mlm_auth_cnf.peerMacAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1319 | (uint8_t *) &mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr, |
| 1320 | sizeof(tSirMacAddr)); |
| 1321 | |
| 1322 | mlm_auth_cnf.authType = mac_ctx->lim.gpLimMlmAuthReq->authType; |
| 1323 | mlm_auth_cnf.sessionId = session_id; |
| 1324 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1325 | qdf_mem_free(mac_ctx->lim.gpLimMlmAuthReq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | mac_ctx->lim.gpLimMlmAuthReq = NULL; |
| 1327 | lim_log(mac_ctx, LOG1, "SessionId:%d LimPostSme LIM_MLM_AUTH_CNF ", |
| 1328 | session_id); |
| 1329 | lim_post_sme_message(mac_ctx, LIM_MLM_AUTH_CNF, |
| 1330 | (uint32_t *) &mlm_auth_cnf); |
| 1331 | } |
| 1332 | |
| 1333 | /** |
| 1334 | * lim_process_mlm_assoc_req() - This function is called to process |
| 1335 | * MLM_ASSOC_REQ message from SME |
| 1336 | * |
| 1337 | * @mac_ctx: Pointer to Global MAC structure |
| 1338 | * @msg_buf: A pointer to the MLM message buffer |
| 1339 | * |
| 1340 | * This function is called to process MLM_ASSOC_REQ message from SME |
| 1341 | * |
| 1342 | * @Return None |
| 1343 | */ |
| 1344 | |
| 1345 | static void lim_process_mlm_assoc_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf) |
| 1346 | { |
| 1347 | tSirMacAddr curr_bssId; |
| 1348 | tLimMlmAssocReq *mlm_assoc_req; |
| 1349 | tLimMlmAssocCnf mlm_assoc_cnf; |
| 1350 | tpPESession session_entry; |
| 1351 | |
| 1352 | if (msg_buf == NULL) { |
| 1353 | lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL")); |
| 1354 | return; |
| 1355 | } |
| 1356 | |
| 1357 | mlm_assoc_req = (tLimMlmAssocReq *) msg_buf; |
| 1358 | session_entry = pe_find_session_by_session_id(mac_ctx, |
| 1359 | mlm_assoc_req->sessionId); |
| 1360 | if (session_entry == NULL) { |
| 1361 | lim_log(mac_ctx, LOGP, |
| 1362 | FL("SessionId:%d Session Does not exist"), |
| 1363 | mlm_assoc_req->sessionId); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1364 | qdf_mem_free(mlm_assoc_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1365 | return; |
| 1366 | } |
| 1367 | |
| 1368 | sir_copy_mac_addr(curr_bssId, session_entry->bssId); |
| 1369 | |
Rajeev Kumar | aa262c4 | 2016-04-15 15:41:08 -0700 | [diff] [blame^] | 1370 | if (!(!LIM_IS_AP_ROLE(session_entry) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1371 | (session_entry->limMlmState == eLIM_MLM_AUTHENTICATED_STATE || |
| 1372 | session_entry->limMlmState == eLIM_MLM_JOINED_STATE) && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1373 | (!qdf_mem_cmp(mlm_assoc_req->peerMacAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1374 | curr_bssId, sizeof(tSirMacAddr))))) { |
| 1375 | /* |
| 1376 | * Received Association request either in invalid state |
| 1377 | * or to a peer MAC entity whose address is different |
| 1378 | * from one that STA is currently joined with or on AP. |
| 1379 | * Return Assoc confirm with Invalid parameters code. |
| 1380 | */ |
| 1381 | lim_log(mac_ctx, LOGW, |
| 1382 | FL("received unexpected MLM_ASSOC_CNF in state %X for role=%d, MAC addr= " |
| 1383 | MAC_ADDRESS_STR), session_entry->limMlmState, |
| 1384 | GET_LIM_SYSTEM_ROLE(session_entry), |
| 1385 | MAC_ADDR_ARRAY(mlm_assoc_req->peerMacAddr)); |
| 1386 | lim_print_mlm_state(mac_ctx, LOGW, session_entry->limMlmState); |
| 1387 | mlm_assoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS; |
| 1388 | mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 1389 | goto end; |
| 1390 | } |
| 1391 | |
| 1392 | /* map the session entry pointer to the AssocFailureTimer */ |
| 1393 | mac_ctx->lim.limTimers.gLimAssocFailureTimer.sessionId = |
| 1394 | mlm_assoc_req->sessionId; |
| 1395 | #ifdef WLAN_FEATURE_11W |
| 1396 | /* |
| 1397 | * Store current MLM state in case ASSOC response returns with |
| 1398 | * TRY_AGAIN_LATER return code. |
| 1399 | */ |
| 1400 | if (session_entry->limRmfEnabled) { |
| 1401 | session_entry->pmfComebackTimerInfo.limPrevMlmState = |
| 1402 | session_entry->limPrevMlmState; |
| 1403 | session_entry->pmfComebackTimerInfo.limMlmState = |
| 1404 | session_entry->limMlmState; |
| 1405 | } |
| 1406 | #endif /* WLAN_FEATURE_11W */ |
| 1407 | |
| 1408 | session_entry->limPrevMlmState = session_entry->limMlmState; |
| 1409 | session_entry->limMlmState = eLIM_MLM_WT_ASSOC_RSP_STATE; |
| 1410 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, |
| 1411 | session_entry->peSessionId, |
| 1412 | session_entry->limMlmState)); |
| 1413 | lim_log(mac_ctx, LOG1, FL("SessionId:%d Sending Assoc_Req Frame"), |
| 1414 | session_entry->peSessionId); |
| 1415 | |
| 1416 | /* Prepare and send Association request frame */ |
| 1417 | lim_send_assoc_req_mgmt_frame(mac_ctx, mlm_assoc_req, session_entry); |
| 1418 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1419 | /* Start association failure timer */ |
| 1420 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE, |
| 1421 | session_entry->peSessionId, eLIM_ASSOC_FAIL_TIMER)); |
| 1422 | if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimAssocFailureTimer) |
| 1423 | != TX_SUCCESS) { |
| 1424 | lim_log(mac_ctx, LOGP, |
| 1425 | FL("SessionId:%d couldn't start Assoc failure timer"), |
| 1426 | session_entry->peSessionId); |
| 1427 | /* Cleanup as if assoc timer expired */ |
| 1428 | lim_process_assoc_failure_timeout(mac_ctx, LIM_ASSOC); |
| 1429 | } |
| 1430 | |
| 1431 | return; |
| 1432 | end: |
| 1433 | /* Update PE session Id */ |
| 1434 | mlm_assoc_cnf.sessionId = mlm_assoc_req->sessionId; |
| 1435 | /* Free up buffer allocated for assocReq */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1436 | qdf_mem_free(mlm_assoc_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1437 | lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF, |
| 1438 | (uint32_t *) &mlm_assoc_cnf); |
| 1439 | } |
| 1440 | |
| 1441 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1442 | * lim_process_mlm_disassoc_req_ntf() - process disassoc request notification |
| 1443 | * |
| 1444 | * @mac_ctx: global MAC context |
| 1445 | * @suspend_status: suspend status |
| 1446 | * @msg: mlm message buffer |
| 1447 | * |
| 1448 | * This function is used to process MLM disassoc notification |
| 1449 | * |
| 1450 | * Return: None |
| 1451 | */ |
| 1452 | static void |
| 1453 | lim_process_mlm_disassoc_req_ntf(tpAniSirGlobal mac_ctx, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1454 | QDF_STATUS suspend_status, uint32_t *msg) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1455 | { |
| 1456 | uint16_t aid; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1457 | struct qdf_mac_addr curr_bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1458 | tpDphHashNode stads; |
| 1459 | tLimMlmDisassocReq *mlm_disassocreq; |
| 1460 | tLimMlmDisassocCnf mlm_disassoccnf; |
| 1461 | tpPESession session; |
| 1462 | extern bool send_disassoc_frame; |
| 1463 | tLimMlmStates mlm_state; |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1464 | tSirSmeDisassocRsp *sme_disassoc_rsp; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1466 | if (QDF_STATUS_SUCCESS != suspend_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1467 | lim_log(mac_ctx, LOGE, FL("Suspend Status is not success %X"), |
| 1468 | suspend_status); |
| 1469 | |
| 1470 | mlm_disassocreq = (tLimMlmDisassocReq *) msg; |
| 1471 | |
| 1472 | session = pe_find_session_by_session_id(mac_ctx, |
| 1473 | mlm_disassocreq->sessionId); |
| 1474 | if (NULL == session) { |
| 1475 | lim_log(mac_ctx, LOGE, |
| 1476 | FL("session does not exist for given sessionId %d"), |
| 1477 | mlm_disassocreq->sessionId); |
| 1478 | mlm_disassoccnf.resultCode = eSIR_SME_INVALID_PARAMETERS; |
| 1479 | goto end; |
| 1480 | } |
| 1481 | |
| 1482 | lim_log(mac_ctx, LOG1, |
| 1483 | FL("Process DisAssoc Req on sessionID %d Systemrole %d" |
| 1484 | "mlmstate %d from: " MAC_ADDRESS_STR), |
| 1485 | mlm_disassocreq->sessionId, GET_LIM_SYSTEM_ROLE(session), |
| 1486 | session->limMlmState, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1487 | MAC_ADDR_ARRAY(mlm_disassocreq->peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1488 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1489 | qdf_mem_copy(curr_bssid.bytes, session->bssId, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1490 | |
| 1491 | switch (GET_LIM_SYSTEM_ROLE(session)) { |
| 1492 | case eLIM_STA_ROLE: |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1493 | if (!qdf_is_macaddr_equal(&mlm_disassocreq->peer_macaddr, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1494 | &curr_bssid)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1495 | lim_log(mac_ctx, LOGW, |
| 1496 | FL("received MLM_DISASSOC_REQ with invalid BSS id")); |
| 1497 | lim_print_mac_addr(mac_ctx, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1498 | mlm_disassocreq->peer_macaddr.bytes, LOGW); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1499 | |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1500 | /* |
| 1501 | * Disassociation response due to host triggered |
| 1502 | * disassociation |
| 1503 | */ |
| 1504 | sme_disassoc_rsp = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1505 | qdf_mem_malloc(sizeof(tSirSmeDisassocRsp)); |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1506 | if (NULL == sme_disassoc_rsp) { |
| 1507 | lim_log(mac_ctx, LOGP, |
| 1508 | FL("memory allocation failed for disassoc rsp")); |
| 1509 | return; |
| 1510 | } |
| 1511 | |
| 1512 | lim_log(mac_ctx, LOG1, |
| 1513 | FL("send disassoc rsp with ret code %d for" MAC_ADDRESS_STR), |
| 1514 | eSIR_SME_DEAUTH_STATUS, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1515 | MAC_ADDR_ARRAY( |
| 1516 | mlm_disassocreq->peer_macaddr.bytes)); |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1517 | |
| 1518 | sme_disassoc_rsp->messageType = eWNI_SME_DISASSOC_RSP; |
| 1519 | sme_disassoc_rsp->length = sizeof(tSirSmeDisassocRsp); |
| 1520 | sme_disassoc_rsp->sessionId = |
| 1521 | mlm_disassocreq->sessionId; |
| 1522 | sme_disassoc_rsp->transactionId = 0; |
| 1523 | sme_disassoc_rsp->statusCode = eSIR_SME_DEAUTH_STATUS; |
| 1524 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1525 | qdf_copy_macaddr(&sme_disassoc_rsp->peer_macaddr, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1526 | &mlm_disassocreq->peer_macaddr); |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1527 | msg = (uint32_t *)sme_disassoc_rsp; |
| 1528 | |
| 1529 | lim_send_sme_disassoc_deauth_ntf(mac_ctx, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1530 | QDF_STATUS_SUCCESS, msg); |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1531 | return; |
| 1532 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1533 | } |
| 1534 | break; |
| 1535 | case eLIM_STA_IN_IBSS_ROLE: |
| 1536 | break; |
| 1537 | case eLIM_AP_ROLE: |
| 1538 | case eLIM_P2P_DEVICE_GO: |
| 1539 | if (true == |
| 1540 | mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) { |
| 1541 | lim_log(mac_ctx, LOGE, |
| 1542 | FL("CAC timer is running, drop disassoc from going out")); |
| 1543 | mlm_disassoccnf.resultCode = eSIR_SME_SUCCESS; |
| 1544 | goto end; |
| 1545 | } |
| 1546 | break; |
| 1547 | default: |
| 1548 | break; |
| 1549 | } /* end switch (GET_LIM_SYSTEM_ROLE(session)) */ |
| 1550 | |
| 1551 | /* |
| 1552 | * Check if there exists a context for the peer entity |
| 1553 | * to be disassociated with. |
| 1554 | */ |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1555 | stads = dph_lookup_hash_entry(mac_ctx, |
| 1556 | mlm_disassocreq->peer_macaddr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1557 | &aid, &session->dph.dphHashTable); |
| 1558 | if (stads) |
| 1559 | mlm_state = stads->mlmStaContext.mlmState; |
| 1560 | |
| 1561 | if ((stads == NULL) || |
| 1562 | (stads && |
| 1563 | ((mlm_state != eLIM_MLM_LINK_ESTABLISHED_STATE) && |
| 1564 | (mlm_state != eLIM_MLM_WT_ASSOC_CNF_STATE) && |
| 1565 | (mlm_state != eLIM_MLM_ASSOCIATED_STATE)))) { |
| 1566 | /* |
| 1567 | * Received LIM_MLM_DISASSOC_REQ for STA that does not |
| 1568 | * have context or in some transit state. |
| 1569 | */ |
| 1570 | lim_log(mac_ctx, LOGW, |
| 1571 | FL("Invalid MLM_DISASSOC_REQ, Addr= " MAC_ADDRESS_STR), |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1572 | MAC_ADDR_ARRAY(mlm_disassocreq->peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1573 | if (stads != NULL) |
| 1574 | lim_log(mac_ctx, LOGE, FL("Sta MlmState : %d"), |
| 1575 | stads->mlmStaContext.mlmState); |
| 1576 | |
| 1577 | /* Prepare and Send LIM_MLM_DISASSOC_CNF */ |
| 1578 | mlm_disassoccnf.resultCode = eSIR_SME_INVALID_PARAMETERS; |
| 1579 | goto end; |
| 1580 | } |
| 1581 | |
| 1582 | stads->mlmStaContext.disassocReason = (tSirMacReasonCodes) |
| 1583 | mlm_disassocreq->reasonCode; |
| 1584 | stads->mlmStaContext.cleanupTrigger = mlm_disassocreq->disassocTrigger; |
| 1585 | |
| 1586 | /* |
| 1587 | * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE |
| 1588 | * This is to address the issue of race condition between |
| 1589 | * disconnect request from the HDD and deauth from AP |
| 1590 | */ |
| 1591 | |
| 1592 | stads->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE; |
| 1593 | |
| 1594 | /* Send Disassociate frame to peer entity */ |
| 1595 | if (send_disassoc_frame && (mlm_disassocreq->reasonCode != |
| 1596 | eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) { |
| 1597 | mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = |
| 1598 | mlm_disassocreq; |
| 1599 | /* |
| 1600 | * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE |
| 1601 | * This is to address the issue of race condition between |
| 1602 | * disconnect request from the HDD and deauth from AP |
| 1603 | */ |
| 1604 | stads->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE; |
| 1605 | |
Edhar, Mahesh Kumar | e3c8d35 | 2015-11-16 12:03:45 +0530 | [diff] [blame] | 1606 | lim_send_disassoc_mgmt_frame(mac_ctx, |
| 1607 | mlm_disassocreq->reasonCode, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1608 | mlm_disassocreq->peer_macaddr.bytes, session, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1609 | /* |
Edhar, Mahesh Kumar | e3c8d35 | 2015-11-16 12:03:45 +0530 | [diff] [blame] | 1610 | * Abort Tx so that data frames won't be sent to the AP |
| 1611 | * after sending Disassoc. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1612 | */ |
Edhar, Mahesh Kumar | e3c8d35 | 2015-11-16 12:03:45 +0530 | [diff] [blame] | 1613 | if (LIM_IS_STA_ROLE(session)) |
| 1614 | wma_tx_abort(session->smeSessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1615 | } else { |
| 1616 | /* Disassoc frame is not sent OTA */ |
| 1617 | send_disassoc_frame = 1; |
| 1618 | /* Receive path cleanup with dummy packet */ |
| 1619 | if (eSIR_SUCCESS != |
| 1620 | lim_cleanup_rx_path(mac_ctx, stads, session)) { |
| 1621 | mlm_disassoccnf.resultCode = |
| 1622 | eSIR_SME_RESOURCES_UNAVAILABLE; |
| 1623 | goto end; |
| 1624 | } |
| 1625 | /* Free up buffer allocated for mlmDisassocReq */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1626 | qdf_mem_free(mlm_disassocreq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1627 | } |
| 1628 | |
| 1629 | return; |
| 1630 | |
| 1631 | end: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1632 | qdf_mem_copy((uint8_t *) &mlm_disassoccnf.peerMacAddr, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1633 | (uint8_t *) mlm_disassocreq->peer_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1634 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1635 | mlm_disassoccnf.aid = mlm_disassocreq->aid; |
| 1636 | mlm_disassoccnf.disassocTrigger = mlm_disassocreq->disassocTrigger; |
| 1637 | |
| 1638 | /* Update PE session ID */ |
| 1639 | mlm_disassoccnf.sessionId = mlm_disassocreq->sessionId; |
| 1640 | |
| 1641 | /* Free up buffer allocated for mlmDisassocReq */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1642 | qdf_mem_free(mlm_disassocreq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1643 | |
| 1644 | lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF, |
| 1645 | (uint32_t *) &mlm_disassoccnf); |
| 1646 | } |
| 1647 | |
| 1648 | /** |
| 1649 | * lim_check_disassoc_deauth_ack_pending() - check if deauth is pending |
| 1650 | * |
| 1651 | * @mac_ctx - global MAC context |
| 1652 | * @sta_mac - station MAC |
| 1653 | * |
| 1654 | * This function checks if diassociation or deauthentication is pending for |
| 1655 | * given station MAC address. |
| 1656 | * |
| 1657 | * Return: true if pending and false otherwise. |
| 1658 | */ |
| 1659 | bool lim_check_disassoc_deauth_ack_pending(tpAniSirGlobal mac_ctx, |
| 1660 | uint8_t *sta_mac) |
| 1661 | { |
| 1662 | tLimMlmDisassocReq *disassoc_req; |
| 1663 | tLimMlmDeauthReq *deauth_req; |
| 1664 | |
| 1665 | disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq; |
| 1666 | deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1667 | if ((disassoc_req && (!qdf_mem_cmp((uint8_t *) sta_mac, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1668 | (uint8_t *) &disassoc_req->peer_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1669 | QDF_MAC_ADDR_SIZE))) || |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1670 | (deauth_req && (!qdf_mem_cmp((uint8_t *) sta_mac, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1671 | (uint8_t *) &deauth_req->peer_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1672 | QDF_MAC_ADDR_SIZE)))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1673 | PELOG1(lim_log(mac_ctx, LOG1, |
| 1674 | FL("Disassoc/Deauth ack pending"));) |
| 1675 | return true; |
| 1676 | } else { |
| 1677 | PELOG1(lim_log(mac_ctx, LOG1, |
| 1678 | FL("Disassoc/Deauth Ack not pending"));) |
| 1679 | return false; |
| 1680 | } |
| 1681 | } |
| 1682 | |
| 1683 | /* |
| 1684 | * lim_clean_up_disassoc_deauth_req() - cleans up pending disassoc or deauth req |
| 1685 | * |
| 1686 | * @mac_ctx: mac_ctx |
| 1687 | * @sta_mac: sta mac address |
| 1688 | * @clean_rx_path: flag to indicate whether to cleanup rx path or not |
| 1689 | * |
| 1690 | * This function cleans up pending disassoc or deauth req |
| 1691 | * |
| 1692 | * Return: void |
| 1693 | */ |
| 1694 | void lim_clean_up_disassoc_deauth_req(tpAniSirGlobal mac_ctx, |
| 1695 | uint8_t *sta_mac, bool clean_rx_path) |
| 1696 | { |
| 1697 | tLimMlmDisassocReq *mlm_disassoc_req; |
| 1698 | tLimMlmDeauthReq *mlm_deauth_req; |
| 1699 | mlm_disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq; |
| 1700 | if (mlm_disassoc_req && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1701 | (!qdf_mem_cmp((uint8_t *) sta_mac, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1702 | (uint8_t *) &mlm_disassoc_req->peer_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1703 | QDF_MAC_ADDR_SIZE))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1704 | if (clean_rx_path) { |
| 1705 | lim_process_disassoc_ack_timeout(mac_ctx); |
| 1706 | } else { |
| 1707 | if (tx_timer_running( |
| 1708 | &mac_ctx->lim.limTimers.gLimDisassocAckTimer)) { |
| 1709 | lim_deactivate_and_change_timer(mac_ctx, |
| 1710 | eLIM_DISASSOC_ACK_TIMER); |
| 1711 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1712 | qdf_mem_free(mlm_disassoc_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1713 | mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = |
| 1714 | NULL; |
| 1715 | } |
| 1716 | } |
| 1717 | |
| 1718 | mlm_deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq; |
| 1719 | if (mlm_deauth_req && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1720 | (!qdf_mem_cmp((uint8_t *) sta_mac, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1721 | (uint8_t *) &mlm_deauth_req->peer_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1722 | QDF_MAC_ADDR_SIZE))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1723 | if (clean_rx_path) { |
| 1724 | lim_process_deauth_ack_timeout(mac_ctx); |
| 1725 | } else { |
| 1726 | if (tx_timer_running( |
| 1727 | &mac_ctx->lim.limTimers.gLimDeauthAckTimer)) { |
| 1728 | lim_deactivate_and_change_timer(mac_ctx, |
| 1729 | eLIM_DEAUTH_ACK_TIMER); |
| 1730 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1731 | qdf_mem_free(mlm_deauth_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1732 | mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = |
| 1733 | NULL; |
| 1734 | } |
| 1735 | } |
| 1736 | } |
| 1737 | |
| 1738 | /* |
| 1739 | * lim_process_disassoc_ack_timeout() - wrapper function around |
| 1740 | * lim_send_disassoc_cnf |
| 1741 | * |
| 1742 | * @mac_ctx: mac_ctx |
| 1743 | * |
| 1744 | * wrapper function around lim_send_disassoc_cnf |
| 1745 | * |
| 1746 | * Return: void |
| 1747 | */ |
| 1748 | void lim_process_disassoc_ack_timeout(tpAniSirGlobal mac_ctx) |
| 1749 | { |
| 1750 | lim_log(mac_ctx, LOG1, FL("")); |
| 1751 | lim_send_disassoc_cnf(mac_ctx); |
| 1752 | } |
| 1753 | |
| 1754 | /** |
| 1755 | * lim_process_mlm_disassoc_req() - This function is called to process |
| 1756 | * MLM_DISASSOC_REQ message from SME |
| 1757 | * |
| 1758 | * @mac_ctx: Pointer to Global MAC structure |
| 1759 | * @msg_buf: A pointer to the MLM message buffer |
| 1760 | * |
| 1761 | * This function is called to process MLM_DISASSOC_REQ message from SME |
| 1762 | * |
| 1763 | * @Return: None |
| 1764 | */ |
| 1765 | static void |
| 1766 | lim_process_mlm_disassoc_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf) |
| 1767 | { |
| 1768 | tLimMlmDisassocReq *mlm_disassoc_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1769 | |
| 1770 | if (msg_buf == NULL) { |
| 1771 | lim_log(mac_ctx, LOGE, |
| 1772 | FL("Buffer is Pointing to NULL")); |
| 1773 | return; |
| 1774 | } |
| 1775 | |
| 1776 | mlm_disassoc_req = (tLimMlmDisassocReq *) msg_buf; |
| 1777 | lim_log(mac_ctx, LOG1, |
| 1778 | FL("Process disassoc req, sessionID %d from: "MAC_ADDRESS_STR), |
| 1779 | mlm_disassoc_req->sessionId, |
Srinivas Girigowda | dd3c513 | 2016-01-05 19:41:27 -0800 | [diff] [blame] | 1780 | MAC_ADDR_ARRAY(mlm_disassoc_req->peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1781 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1782 | lim_process_mlm_disassoc_req_ntf(mac_ctx, QDF_STATUS_SUCCESS, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1783 | (uint32_t *) msg_buf); |
| 1784 | } |
| 1785 | |
| 1786 | /** |
| 1787 | * lim_process_mlm_deauth_req_ntf() - This function is process mlm deauth req |
| 1788 | * notification |
| 1789 | * |
| 1790 | * @mac_ctx: Pointer to Global MAC structure |
| 1791 | * @suspend_status: suspend status |
| 1792 | * @msg_buf: A pointer to the MLM message buffer |
| 1793 | * |
| 1794 | * This function is process mlm deauth req notification |
| 1795 | * |
| 1796 | * @Return: None |
| 1797 | */ |
| 1798 | static void |
| 1799 | lim_process_mlm_deauth_req_ntf(tpAniSirGlobal mac_ctx, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1800 | QDF_STATUS suspend_status, uint32_t *msg_buf) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1801 | { |
| 1802 | uint16_t aid; |
| 1803 | tSirMacAddr curr_bssId; |
| 1804 | tpDphHashNode sta_ds; |
| 1805 | struct tLimPreAuthNode *auth_node; |
| 1806 | tLimMlmDeauthReq *mlm_deauth_req; |
| 1807 | tLimMlmDeauthCnf mlm_deauth_cnf; |
| 1808 | tpPESession session; |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1809 | tSirSmeDeauthRsp *sme_deauth_rsp; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1810 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1811 | if (QDF_STATUS_SUCCESS != suspend_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1812 | lim_log(mac_ctx, LOGE, FL("Suspend Status is not success %X"), |
| 1813 | suspend_status); |
| 1814 | |
| 1815 | mlm_deauth_req = (tLimMlmDeauthReq *) msg_buf; |
| 1816 | session = pe_find_session_by_session_id(mac_ctx, |
| 1817 | mlm_deauth_req->sessionId); |
| 1818 | if (NULL == session) { |
| 1819 | lim_log(mac_ctx, LOGE, |
| 1820 | FL("session does not exist for given sessionId %d"), |
| 1821 | mlm_deauth_req->sessionId); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1822 | qdf_mem_free(mlm_deauth_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1823 | return; |
| 1824 | } |
| 1825 | lim_log(mac_ctx, LOG1, FL("Process Deauth Req on sessionID %d Systemrole %d" |
| 1826 | "mlmstate %d from: " MAC_ADDRESS_STR), |
| 1827 | mlm_deauth_req->sessionId, |
| 1828 | GET_LIM_SYSTEM_ROLE(session), |
| 1829 | session->limMlmState, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1830 | MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1831 | sir_copy_mac_addr(curr_bssId, session->bssId); |
| 1832 | |
| 1833 | switch (GET_LIM_SYSTEM_ROLE(session)) { |
| 1834 | case eLIM_STA_ROLE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1835 | switch (session->limMlmState) { |
| 1836 | case eLIM_MLM_IDLE_STATE: |
| 1837 | /* |
| 1838 | * Attempting to Deauthenticate with a pre-authenticated |
| 1839 | * peer. Deauthetiate with peer if there exists a |
| 1840 | * pre-auth context below. |
| 1841 | */ |
| 1842 | break; |
| 1843 | case eLIM_MLM_AUTHENTICATED_STATE: |
| 1844 | case eLIM_MLM_WT_ASSOC_RSP_STATE: |
| 1845 | case eLIM_MLM_LINK_ESTABLISHED_STATE: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1846 | if (qdf_mem_cmp(mlm_deauth_req->peer_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1847 | curr_bssId, QDF_MAC_ADDR_SIZE)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1848 | lim_log(mac_ctx, LOGE, |
| 1849 | FL("received MLM_DEAUTH_REQ with invalid BSS id " |
| 1850 | "Peer MAC: "MAC_ADDRESS_STR |
| 1851 | " CFG BSSID Addr : "MAC_ADDRESS_STR), |
| 1852 | MAC_ADDR_ARRAY( |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1853 | mlm_deauth_req->peer_macaddr.bytes), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1854 | MAC_ADDR_ARRAY(curr_bssId)); |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1855 | /* |
| 1856 | * Deauthentication response to host triggered |
| 1857 | * deauthentication |
| 1858 | */ |
| 1859 | sme_deauth_rsp = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1860 | qdf_mem_malloc(sizeof(tSirSmeDeauthRsp)); |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1861 | if (NULL == sme_deauth_rsp) { |
| 1862 | lim_log(mac_ctx, LOGP, |
| 1863 | FL("memory allocation failed for deauth rsp")); |
| 1864 | return; |
| 1865 | } |
| 1866 | |
| 1867 | lim_log(mac_ctx, LOG1, |
| 1868 | FL("send deauth rsp with ret code %d for" MAC_ADDRESS_STR), |
| 1869 | eSIR_SME_DEAUTH_STATUS, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1870 | MAC_ADDR_ARRAY( |
| 1871 | mlm_deauth_req->peer_macaddr.bytes)); |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1872 | |
| 1873 | sme_deauth_rsp->messageType = |
| 1874 | eWNI_SME_DEAUTH_RSP; |
| 1875 | sme_deauth_rsp->length = |
| 1876 | sizeof(tSirSmeDeauthRsp); |
| 1877 | sme_deauth_rsp->statusCode = |
| 1878 | eSIR_SME_DEAUTH_STATUS; |
| 1879 | sme_deauth_rsp->sessionId = |
| 1880 | mlm_deauth_req->sessionId; |
| 1881 | sme_deauth_rsp->transactionId = 0; |
| 1882 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1883 | qdf_mem_copy(sme_deauth_rsp->peer_macaddr.bytes, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1884 | mlm_deauth_req->peer_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1885 | QDF_MAC_ADDR_SIZE); |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1886 | |
| 1887 | msg_buf = (uint32_t *)sme_deauth_rsp; |
| 1888 | |
| 1889 | lim_send_sme_disassoc_deauth_ntf(mac_ctx, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1890 | QDF_STATUS_SUCCESS, msg_buf); |
Masti, Narayanraddi | 21bde25 | 2015-10-09 19:39:47 +0530 | [diff] [blame] | 1891 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1892 | } |
| 1893 | |
| 1894 | if ((session->limMlmState == |
| 1895 | eLIM_MLM_AUTHENTICATED_STATE) || |
| 1896 | (session->limMlmState == |
| 1897 | eLIM_MLM_WT_ASSOC_RSP_STATE)) { |
| 1898 | /* Send deauth frame to peer entity */ |
| 1899 | lim_send_deauth_mgmt_frame(mac_ctx, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1900 | mlm_deauth_req->reasonCode, |
| 1901 | mlm_deauth_req->peer_macaddr.bytes, |
| 1902 | session, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1903 | /* Prepare and Send LIM_MLM_DEAUTH_CNF */ |
| 1904 | mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS; |
| 1905 | session->limMlmState = eLIM_MLM_IDLE_STATE; |
| 1906 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, |
| 1907 | session->peSessionId, |
| 1908 | session->limMlmState)); |
| 1909 | goto end; |
| 1910 | } |
| 1911 | break; |
| 1912 | default: |
| 1913 | lim_log(mac_ctx, LOGW, |
| 1914 | FL("received MLM_DEAUTH_REQ with in state %d for peer " |
| 1915 | MAC_ADDRESS_STR), |
| 1916 | session->limMlmState, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1917 | MAC_ADDR_ARRAY( |
| 1918 | mlm_deauth_req->peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1919 | lim_print_mlm_state(mac_ctx, LOGW, |
| 1920 | session->limMlmState); |
| 1921 | /* Prepare and Send LIM_MLM_DEAUTH_CNF */ |
| 1922 | mlm_deauth_cnf.resultCode = |
| 1923 | eSIR_SME_STA_NOT_AUTHENTICATED; |
| 1924 | |
| 1925 | goto end; |
| 1926 | } |
| 1927 | break; |
| 1928 | case eLIM_STA_IN_IBSS_ROLE: |
| 1929 | lim_log(mac_ctx, LOGE, FL("received MLM_DEAUTH_REQ IBSS Mode")); |
| 1930 | mlm_deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS; |
| 1931 | goto end; |
| 1932 | case eLIM_AP_ROLE: |
| 1933 | case eLIM_P2P_DEVICE_GO: |
| 1934 | if (true == |
| 1935 | mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) { |
| 1936 | lim_log(mac_ctx, LOGE, |
| 1937 | FL("CAC timer is running, drop disassoc from going out")); |
| 1938 | mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS; |
| 1939 | goto end; |
| 1940 | } |
| 1941 | break; |
| 1942 | |
| 1943 | default: |
| 1944 | break; |
| 1945 | } /* end switch (GET_LIM_SYSTEM_ROLE(session)) */ |
| 1946 | |
| 1947 | /* |
| 1948 | * Check if there exists a context for the peer entity |
| 1949 | * to be deauthenticated with. |
| 1950 | */ |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1951 | sta_ds = dph_lookup_hash_entry(mac_ctx, |
| 1952 | mlm_deauth_req->peer_macaddr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1953 | &aid, &session->dph.dphHashTable); |
| 1954 | |
| 1955 | if (sta_ds == NULL) { |
| 1956 | /* Check if there exists pre-auth context for this STA */ |
| 1957 | auth_node = lim_search_pre_auth_list(mac_ctx, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1958 | mlm_deauth_req->peer_macaddr.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1959 | if (auth_node == NULL) { |
| 1960 | /* |
| 1961 | * Received DEAUTH REQ for a STA that is neither |
| 1962 | * Associated nor Pre-authenticated. Log error, |
| 1963 | * Prepare and Send LIM_MLM_DEAUTH_CNF |
| 1964 | */ |
| 1965 | lim_log(mac_ctx, LOGW, |
| 1966 | FL("received MLM_DEAUTH_REQ in mlme state %d for STA that " |
| 1967 | "does not have context, Addr=" |
| 1968 | MAC_ADDRESS_STR), |
| 1969 | session->limMlmState, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1970 | MAC_ADDR_ARRAY( |
| 1971 | mlm_deauth_req->peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1972 | mlm_deauth_cnf.resultCode = |
| 1973 | eSIR_SME_STA_NOT_AUTHENTICATED; |
| 1974 | } else { |
| 1975 | mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS; |
| 1976 | /* Delete STA from pre-auth STA list */ |
| 1977 | lim_delete_pre_auth_node(mac_ctx, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1978 | mlm_deauth_req->peer_macaddr.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1979 | /* Send Deauthentication frame to peer entity */ |
| 1980 | lim_send_deauth_mgmt_frame(mac_ctx, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1981 | mlm_deauth_req->reasonCode, |
| 1982 | mlm_deauth_req->peer_macaddr.bytes, |
| 1983 | session, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1984 | } |
| 1985 | goto end; |
| 1986 | } else if ((sta_ds->mlmStaContext.mlmState != |
| 1987 | eLIM_MLM_LINK_ESTABLISHED_STATE) && |
| 1988 | (sta_ds->mlmStaContext.mlmState != |
| 1989 | eLIM_MLM_WT_ASSOC_CNF_STATE)) { |
| 1990 | /* |
| 1991 | * received MLM_DEAUTH_REQ for STA that either has no context or |
| 1992 | * in some transit state |
| 1993 | */ |
| 1994 | lim_log(mac_ctx, LOGW, |
| 1995 | FL("Invalid MLM_DEAUTH_REQ, Addr="MAC_ADDRESS_STR), |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 1996 | MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1997 | /* Prepare and Send LIM_MLM_DEAUTH_CNF */ |
| 1998 | mlm_deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS; |
| 1999 | goto end; |
| 2000 | } |
| 2001 | /* sta_ds->mlmStaContext.rxPurgeReq = 1; */ |
| 2002 | sta_ds->mlmStaContext.disassocReason = (tSirMacReasonCodes) |
| 2003 | mlm_deauth_req->reasonCode; |
| 2004 | sta_ds->mlmStaContext.cleanupTrigger = mlm_deauth_req->deauthTrigger; |
| 2005 | mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = mlm_deauth_req; |
| 2006 | /* |
| 2007 | * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE |
| 2008 | * This is to address the issue of race condition between |
| 2009 | * disconnect request from the HDD and disassoc from |
| 2010 | * inactivity timer. This will make sure that we will not |
| 2011 | * process disassoc if deauth is in progress for the station |
| 2012 | * and thus mlmStaContext.cleanupTrigger will not be overwritten. |
| 2013 | */ |
| 2014 | sta_ds->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE; |
| 2015 | /* Send Deauthentication frame to peer entity */ |
| 2016 | lim_send_deauth_mgmt_frame(mac_ctx, mlm_deauth_req->reasonCode, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 2017 | mlm_deauth_req->peer_macaddr.bytes, |
| 2018 | session, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2019 | return; |
| 2020 | end: |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2021 | qdf_copy_macaddr(&mlm_deauth_cnf.peer_macaddr, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 2022 | &mlm_deauth_req->peer_macaddr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2023 | mlm_deauth_cnf.deauthTrigger = mlm_deauth_req->deauthTrigger; |
| 2024 | mlm_deauth_cnf.aid = mlm_deauth_req->aid; |
| 2025 | mlm_deauth_cnf.sessionId = mlm_deauth_req->sessionId; |
| 2026 | |
| 2027 | /* Free up buffer allocated for mlmDeauthReq */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2028 | qdf_mem_free(mlm_deauth_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2029 | lim_post_sme_message(mac_ctx, |
| 2030 | LIM_MLM_DEAUTH_CNF, (uint32_t *) &mlm_deauth_cnf); |
| 2031 | } |
| 2032 | |
| 2033 | /* |
| 2034 | * lim_process_deauth_ack_timeout() - wrapper function around |
| 2035 | * lim_send_deauth_cnf |
| 2036 | * |
| 2037 | * @mac_ctx: mac_ctx |
| 2038 | * |
| 2039 | * wrapper function around lim_send_deauth_cnf |
| 2040 | * |
| 2041 | * Return: void |
| 2042 | */ |
| 2043 | void lim_process_deauth_ack_timeout(tpAniSirGlobal mac_ctx) |
| 2044 | { |
| 2045 | lim_log(mac_ctx, LOG1, FL("")); |
| 2046 | lim_send_deauth_cnf(mac_ctx); |
| 2047 | } |
| 2048 | |
| 2049 | /* |
| 2050 | * lim_process_mlm_deauth_req() - This function is called to process |
| 2051 | * MLM_DEAUTH_REQ message from SME |
| 2052 | * |
| 2053 | * @mac_ctx: Pointer to Global MAC structure |
| 2054 | * @msg_buf: A pointer to the MLM message buffer |
| 2055 | * |
| 2056 | * This function is called to process MLM_DEAUTH_REQ message from SME |
| 2057 | * |
| 2058 | * @Return: None |
| 2059 | */ |
| 2060 | static void |
| 2061 | lim_process_mlm_deauth_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf) |
| 2062 | { |
| 2063 | tLimMlmDeauthReq *mlm_deauth_req; |
| 2064 | tpPESession session; |
| 2065 | |
| 2066 | if (msg_buf == NULL) { |
| 2067 | PELOGE(lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));) |
| 2068 | return; |
| 2069 | } |
| 2070 | |
| 2071 | mlm_deauth_req = (tLimMlmDeauthReq *) msg_buf; |
| 2072 | lim_log(mac_ctx, LOG1, |
| 2073 | FL("Process Deauth Req on sessionID %d from: " |
| 2074 | MAC_ADDRESS_STR), |
| 2075 | mlm_deauth_req->sessionId, |
Srinivas Girigowda | 9efa10e | 2016-01-04 18:49:40 -0800 | [diff] [blame] | 2076 | MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2077 | |
| 2078 | session = pe_find_session_by_session_id(mac_ctx, |
| 2079 | mlm_deauth_req->sessionId); |
| 2080 | if (NULL == session) { |
| 2081 | lim_log(mac_ctx, LOGE, |
| 2082 | FL("session does not exist for given sessionId %d"), |
| 2083 | mlm_deauth_req->sessionId); |
| 2084 | return; |
| 2085 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2086 | lim_process_mlm_deauth_req_ntf(mac_ctx, QDF_STATUS_SUCCESS, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2087 | (uint32_t *) msg_buf); |
| 2088 | } |
| 2089 | |
| 2090 | /** |
| 2091 | * lim_process_mlm_set_keys_req() - This function is called to process |
| 2092 | * MLM_SETKEYS_REQ message from SME |
| 2093 | * |
| 2094 | * @mac_ctx: Pointer to Global MAC structure |
| 2095 | * @msg_buf: A pointer to the MLM message buffer |
| 2096 | * |
| 2097 | * This function is called to process MLM_SETKEYS_REQ message from SME |
| 2098 | * |
| 2099 | * @Return: None |
| 2100 | */ |
| 2101 | static void |
| 2102 | lim_process_mlm_set_keys_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf) |
| 2103 | { |
| 2104 | uint16_t aid; |
| 2105 | uint16_t sta_idx = 0; |
| 2106 | uint32_t default_key_id = 0; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2107 | struct qdf_mac_addr curr_bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2108 | tpDphHashNode sta_ds; |
| 2109 | tLimMlmSetKeysReq *mlm_set_keys_req; |
| 2110 | tLimMlmSetKeysCnf mlm_set_keys_cnf; |
| 2111 | tpPESession session; |
| 2112 | |
| 2113 | if (msg_buf == NULL) { |
| 2114 | lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL")); |
| 2115 | return; |
| 2116 | } |
| 2117 | |
| 2118 | mlm_set_keys_req = (tLimMlmSetKeysReq *) msg_buf; |
| 2119 | /* Hold onto the SetKeys request parameters */ |
| 2120 | mac_ctx->lim.gpLimMlmSetKeysReq = (void *)mlm_set_keys_req; |
| 2121 | session = pe_find_session_by_session_id(mac_ctx, |
| 2122 | mlm_set_keys_req->sessionId); |
| 2123 | if (NULL == session) { |
| 2124 | lim_log(mac_ctx, LOGE, |
| 2125 | FL("session does not exist for given sessionId")); |
| 2126 | return; |
| 2127 | } |
| 2128 | |
| 2129 | lim_log(mac_ctx, LOGW, |
| 2130 | FL("Received MLM_SETKEYS_REQ with parameters:" |
| 2131 | "AID [%d], ED Type [%d], # Keys [%d] & Peer MAC Addr - "), |
| 2132 | mlm_set_keys_req->aid, mlm_set_keys_req->edType, |
| 2133 | mlm_set_keys_req->numKeys); |
Srinivas Girigowda | d5965c4 | 2015-12-04 13:43:16 -0800 | [diff] [blame] | 2134 | lim_print_mac_addr(mac_ctx, mlm_set_keys_req->peer_macaddr.bytes, LOGW); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2135 | qdf_mem_copy(curr_bssid.bytes, session->bssId, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2136 | |
| 2137 | switch (GET_LIM_SYSTEM_ROLE(session)) { |
| 2138 | case eLIM_STA_ROLE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2139 | /* |
| 2140 | * In case of TDLS, peerMac address need not be BssId. Skip this |
| 2141 | * check if TDLS is enabled. |
| 2142 | */ |
| 2143 | #ifndef FEATURE_WLAN_TDLS |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2144 | if ((!qdf_is_macaddr_broadcast( |
Srinivas Girigowda | d5965c4 | 2015-12-04 13:43:16 -0800 | [diff] [blame] | 2145 | &mlm_set_keys_req->peer_macaddr)) && |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2146 | (!qdf_is_macaddr_equal(&mlm_set_keys_req->peer_macaddr, |
Srinivas Girigowda | d5965c4 | 2015-12-04 13:43:16 -0800 | [diff] [blame] | 2147 | &curr_bssid))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2148 | lim_log(mac_ctx, LOGW, |
| 2149 | FL("Received MLM_SETKEYS_REQ with invalid BSSID" |
| 2150 | MAC_ADDRESS_STR), |
Srinivas Girigowda | d5965c4 | 2015-12-04 13:43:16 -0800 | [diff] [blame] | 2151 | MAC_ADDR_ARRAY(mlm_set_keys_req-> |
| 2152 | peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2153 | /* |
| 2154 | * Prepare and Send LIM_MLM_SETKEYS_CNF with error code |
| 2155 | */ |
| 2156 | mlm_set_keys_cnf.resultCode = |
| 2157 | eSIR_SME_INVALID_PARAMETERS; |
| 2158 | goto end; |
| 2159 | } |
| 2160 | #endif |
| 2161 | break; |
| 2162 | case eLIM_STA_IN_IBSS_ROLE: |
| 2163 | /* |
| 2164 | * update the IBSS PE session encrption type based on the |
| 2165 | * key type |
| 2166 | */ |
| 2167 | session->encryptType = mlm_set_keys_req->edType; |
| 2168 | break; |
| 2169 | default: |
| 2170 | break; |
| 2171 | } |
| 2172 | |
| 2173 | /* |
| 2174 | * Use the "unicast" parameter to determine if the "Group Keys" |
| 2175 | * are being set. |
| 2176 | * mlm_set_keys_req->key.unicast = 0 -> Multicast/broadcast |
| 2177 | * mlm_set_keys_req->key.unicast - 1 -> Unicast keys are being set |
| 2178 | */ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2179 | if (qdf_is_macaddr_broadcast(&mlm_set_keys_req->peer_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2180 | lim_log(mac_ctx, LOG1, FL("Trying to set Group Keys...%d "), |
| 2181 | mlm_set_keys_req->sessionId); |
| 2182 | /* |
| 2183 | * When trying to set Group Keys for any security mode other |
| 2184 | * than WEP, use the STA Index corresponding to the AP... |
| 2185 | */ |
| 2186 | switch (mlm_set_keys_req->edType) { |
| 2187 | case eSIR_ED_CCMP: |
| 2188 | #ifdef WLAN_FEATURE_11W |
| 2189 | case eSIR_ED_AES_128_CMAC: |
| 2190 | #endif |
| 2191 | sta_idx = session->staId; |
| 2192 | break; |
| 2193 | default: |
| 2194 | break; |
| 2195 | } |
| 2196 | } else { |
| 2197 | lim_log(mac_ctx, LOG1, FL("Trying to set Unicast Keys...")); |
| 2198 | /* |
| 2199 | * Check if there exists a context for the |
| 2200 | * peer entity for which keys need to be set. |
| 2201 | */ |
| 2202 | sta_ds = dph_lookup_hash_entry(mac_ctx, |
Srinivas Girigowda | d5965c4 | 2015-12-04 13:43:16 -0800 | [diff] [blame] | 2203 | mlm_set_keys_req->peer_macaddr.bytes, &aid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2204 | &session->dph.dphHashTable); |
| 2205 | if ((sta_ds == NULL) || |
| 2206 | ((sta_ds->mlmStaContext.mlmState != |
| 2207 | eLIM_MLM_LINK_ESTABLISHED_STATE) && |
| 2208 | !LIM_IS_AP_ROLE(session))) { |
| 2209 | /* |
| 2210 | * Received LIM_MLM_SETKEYS_REQ for STA that does not |
| 2211 | * have context or in some transit state. |
| 2212 | */ |
| 2213 | lim_log(mac_ctx, LOG1, |
| 2214 | FL("Invalid MLM_SETKEYS_REQ, Addr = " |
| 2215 | MAC_ADDRESS_STR), |
Srinivas Girigowda | d5965c4 | 2015-12-04 13:43:16 -0800 | [diff] [blame] | 2216 | MAC_ADDR_ARRAY(mlm_set_keys_req-> |
| 2217 | peer_macaddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2218 | /* Prepare and Send LIM_MLM_SETKEYS_CNF */ |
| 2219 | mlm_set_keys_cnf.resultCode = |
| 2220 | eSIR_SME_INVALID_PARAMETERS; |
| 2221 | goto end; |
| 2222 | } else { |
| 2223 | sta_idx = sta_ds->staIndex; |
| 2224 | } |
| 2225 | } |
| 2226 | |
| 2227 | if ((mlm_set_keys_req->numKeys == 0) |
| 2228 | && (mlm_set_keys_req->edType != eSIR_ED_NONE)) { |
| 2229 | /* |
| 2230 | * Broadcast/Multicast Keys (for WEP!!) are NOT sent |
| 2231 | * via this interface!! This indicates to HAL that the WEP Keys |
| 2232 | * need to be extracted from the CFG and applied to hardware |
| 2233 | */ |
| 2234 | default_key_id = 0xff; |
| 2235 | } else if (mlm_set_keys_req->key[0].keyId && |
| 2236 | ((mlm_set_keys_req->edType == eSIR_ED_WEP40) || |
| 2237 | (mlm_set_keys_req->edType == eSIR_ED_WEP104))) { |
| 2238 | /* |
| 2239 | * If the Key Id is non zero and encryption mode is WEP, |
| 2240 | * the key index is coming from the upper layers so that key |
| 2241 | * only need to be used as the default tx key, This is being |
| 2242 | * used only in case of WEP mode in HAL |
| 2243 | */ |
| 2244 | default_key_id = mlm_set_keys_req->key[0].keyId; |
| 2245 | } else { |
| 2246 | default_key_id = 0; |
| 2247 | } |
| 2248 | lim_log(mac_ctx, LOG1, |
| 2249 | FL("Trying to set keys for STA Index [%d], using default_key_id [%d]"), |
| 2250 | sta_idx, default_key_id); |
| 2251 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2252 | if (qdf_is_macaddr_broadcast(&mlm_set_keys_req->peer_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2253 | session->limPrevMlmState = session->limMlmState; |
| 2254 | session->limMlmState = eLIM_MLM_WT_SET_BSS_KEY_STATE; |
| 2255 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, |
| 2256 | session->peSessionId, session->limMlmState)); |
| 2257 | lim_log(mac_ctx, LOG1, FL("Trying to set Group Keys...%d "), |
| 2258 | session->peSessionId); |
| 2259 | /* Package WMA_SET_BSSKEY_REQ message parameters */ |
| 2260 | lim_send_set_bss_key_req(mac_ctx, mlm_set_keys_req, session); |
| 2261 | return; |
| 2262 | } else { |
| 2263 | /* |
| 2264 | * Package WMA_SET_STAKEY_REQ / WMA_SET_STA_BCASTKEY_REQ message |
| 2265 | * parameters |
| 2266 | */ |
| 2267 | lim_send_set_sta_key_req(mac_ctx, mlm_set_keys_req, sta_idx, |
| 2268 | (uint8_t) default_key_id, session, |
| 2269 | true); |
| 2270 | return; |
| 2271 | } |
| 2272 | end: |
| 2273 | mlm_set_keys_cnf.sessionId = mlm_set_keys_req->sessionId; |
| 2274 | lim_post_sme_set_keys_cnf(mac_ctx, mlm_set_keys_req, &mlm_set_keys_cnf); |
| 2275 | } |
| 2276 | |
| 2277 | /** |
| 2278 | * lim_process_periodic_probe_req_timer() - This function is called to process |
| 2279 | * periodic probe request to send during scan. |
| 2280 | * |
| 2281 | * @mac_ctx: Pointer to Global MAC structure |
| 2282 | * |
| 2283 | * This function is called to process periodic probe request to send during scan |
| 2284 | * |
| 2285 | * @Return None |
| 2286 | */ |
| 2287 | static void lim_process_periodic_probe_req_timer(tpAniSirGlobal mac_ctx) |
| 2288 | { |
| 2289 | uint8_t channel_num; |
| 2290 | uint8_t i = 0; |
| 2291 | tLimMlmScanReq *mlm_scan_req; |
| 2292 | tSirRetStatus status = eSIR_SUCCESS; |
| 2293 | TX_TIMER *probe_req_timer = |
| 2294 | &mac_ctx->lim.limTimers.gLimPeriodicProbeReqTimer; |
| 2295 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2296 | if (qdf_mc_timer_get_current_state(&probe_req_timer->qdf_timer) |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 2297 | != QDF_TIMER_STATE_STOPPED) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2298 | lim_log(mac_ctx, LOG1, FL("Invalid state of timer")); |
| 2299 | return; |
| 2300 | } |
| 2301 | |
| 2302 | if (!((mac_ctx->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) |
| 2303 | && (probe_req_timer->sessionId != 0xff) |
| 2304 | && (mac_ctx->lim.probeCounter < mac_ctx->lim.maxProbe))) { |
| 2305 | lim_log(mac_ctx, LOG1, |
| 2306 | FL("received unexpected Periodic scan timeout in state %X"), |
| 2307 | mac_ctx->lim.gLimMlmState); |
| 2308 | return; |
| 2309 | } |
| 2310 | |
| 2311 | mlm_scan_req = mac_ctx->lim.gpLimMlmScanReq; |
| 2312 | lim_log(mac_ctx, LOG1, FL("Scanning : Periodic scanning")); |
| 2313 | mac_ctx->lim.probeCounter++; |
| 2314 | /* Periodic channel timer timed out to send probe request. */ |
| 2315 | channel_num = lim_get_current_scan_channel(mac_ctx); |
| 2316 | do { |
| 2317 | /* |
| 2318 | * Prepare and send Probe Request frame for all the SSIDs |
| 2319 | * present in the saved MLM |
| 2320 | */ |
| 2321 | status = lim_send_probe_req_mgmt_frame(mac_ctx, |
| 2322 | &mlm_scan_req->ssId[i], mlm_scan_req->bssId, |
| 2323 | channel_num, mac_ctx->lim.gSelfMacAddr, |
| 2324 | mlm_scan_req->dot11mode, |
| 2325 | mlm_scan_req->uIEFieldLen, |
| 2326 | (uint8_t *) (mlm_scan_req) + |
| 2327 | mlm_scan_req->uIEFieldOffset); |
| 2328 | if (status != eSIR_SUCCESS) { |
| 2329 | lim_log(mac_ctx, LOGE, |
| 2330 | FL("send ProbeReq failed for SSID %s on channel: %d"), |
| 2331 | mlm_scan_req->ssId[i].ssId, channel_num); |
| 2332 | return; |
| 2333 | } |
| 2334 | i++; |
| 2335 | } while (i < mlm_scan_req->numSsid); |
| 2336 | /* Activate timer again */ |
| 2337 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE, |
| 2338 | probe_req_timer->sessionId, |
| 2339 | eLIM_PERIODIC_PROBE_REQ_TIMER)); |
| 2340 | if (tx_timer_activate(probe_req_timer) != TX_SUCCESS) { |
| 2341 | lim_log(mac_ctx, LOGP, |
| 2342 | FL("could not start periodic probe req timer")); |
| 2343 | return; |
| 2344 | } |
| 2345 | } |
| 2346 | |
| 2347 | /** |
| 2348 | * lim_process_join_failure_timeout() - This function is called to process |
| 2349 | * JoinFailureTimeout |
| 2350 | * |
| 2351 | * @mac_ctx: Pointer to Global MAC structure |
| 2352 | * |
| 2353 | * This function is called to process JoinFailureTimeout |
| 2354 | * |
| 2355 | * @Return None |
| 2356 | */ |
| 2357 | static void lim_process_join_failure_timeout(tpAniSirGlobal mac_ctx) |
| 2358 | { |
| 2359 | tLimMlmJoinCnf mlm_join_cnf; |
| 2360 | uint32_t len; |
| 2361 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM |
| 2362 | host_log_rssi_pkt_type *rssi_log = NULL; |
| 2363 | #endif |
| 2364 | tpPESession session; |
| 2365 | |
| 2366 | session = pe_find_session_by_session_id(mac_ctx, |
| 2367 | mac_ctx->lim.limTimers.gLimJoinFailureTimer.sessionId); |
| 2368 | if (NULL == session) { |
| 2369 | lim_log(mac_ctx, LOGE, |
| 2370 | FL("Session Does not exist for given sessionID")); |
| 2371 | return; |
| 2372 | } |
| 2373 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM |
| 2374 | WLAN_HOST_DIAG_LOG_ALLOC(rssi_log, |
| 2375 | host_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C); |
| 2376 | if (rssi_log) |
| 2377 | rssi_log->rssi = session->rssi; |
| 2378 | WLAN_HOST_DIAG_LOG_REPORT(rssi_log); |
| 2379 | #endif |
| 2380 | |
| 2381 | if (session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE) { |
| 2382 | len = sizeof(tSirMacAddr); |
| 2383 | /* Change timer for future activations */ |
| 2384 | lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER); |
| 2385 | /* Change Periodic probe req timer for future activation */ |
| 2386 | lim_deactivate_and_change_timer(mac_ctx, |
| 2387 | eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER); |
| 2388 | /* Issue MLM join confirm with timeout reason code */ |
| 2389 | lim_log(mac_ctx, LOGE, |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 2390 | FL("Join Failure Timeout, In eLIM_MLM_WT_JOIN_BEACON_STATE session:%d " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2391 | MAC_ADDRESS_STR), |
| 2392 | session->peSessionId, MAC_ADDR_ARRAY(session->bssId)); |
| 2393 | |
| 2394 | mlm_join_cnf.resultCode = eSIR_SME_JOIN_TIMEOUT_RESULT_CODE; |
| 2395 | mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 2396 | session->limMlmState = eLIM_MLM_IDLE_STATE; |
| 2397 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, |
| 2398 | session->peSessionId, session->limMlmState)); |
| 2399 | if (lim_set_link_state(mac_ctx, eSIR_LINK_IDLE_STATE, |
| 2400 | session->bssId, session->selfMacAddr, |
| 2401 | NULL, NULL) != eSIR_SUCCESS) |
| 2402 | lim_log(mac_ctx, LOGE, |
| 2403 | ("Failed to set the LinkState")); |
| 2404 | /* Update PE session Id */ |
| 2405 | mlm_join_cnf.sessionId = session->peSessionId; |
| 2406 | /* Freeup buffer allocated to join request */ |
| 2407 | if (session->pLimMlmJoinReq) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2408 | qdf_mem_free(session->pLimMlmJoinReq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2409 | session->pLimMlmJoinReq = NULL; |
| 2410 | } |
| 2411 | lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF, |
| 2412 | (uint32_t *) &mlm_join_cnf); |
| 2413 | return; |
| 2414 | } else { |
| 2415 | lim_log(mac_ctx, LOGW, |
| 2416 | FL("received unexpected JOIN failure timeout in state %X"), |
| 2417 | session->limMlmState); |
| 2418 | lim_print_mlm_state(mac_ctx, LOGW, session->limMlmState); |
| 2419 | } |
| 2420 | } |
| 2421 | |
| 2422 | /** |
| 2423 | * lim_process_periodic_join_probe_req_timer() - This function is called to |
| 2424 | * process periodic probe request send during joining process. |
| 2425 | * |
| 2426 | * @mac_ctx: Pointer to Global MAC structure |
| 2427 | * |
| 2428 | * This function is called to process periodic probe request send during |
| 2429 | * joining process. |
| 2430 | * |
| 2431 | * @Return None |
| 2432 | */ |
| 2433 | static void lim_process_periodic_join_probe_req_timer(tpAniSirGlobal mac_ctx) |
| 2434 | { |
| 2435 | tpPESession session; |
| 2436 | tSirMacSSid ssid; |
| 2437 | |
| 2438 | session = pe_find_session_by_session_id(mac_ctx, |
| 2439 | mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId); |
| 2440 | if (NULL == session) { |
| 2441 | lim_log(mac_ctx, LOGE, |
| 2442 | FL("session does not exist for given SessionId : %d"), |
| 2443 | mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer. |
| 2444 | sessionId); |
| 2445 | return; |
| 2446 | } |
| 2447 | |
| 2448 | if ((true == |
| 2449 | tx_timer_running(&mac_ctx->lim.limTimers.gLimJoinFailureTimer)) |
| 2450 | && (session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2451 | qdf_mem_copy(ssid.ssId, session->ssId.ssId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2452 | session->ssId.length); |
| 2453 | ssid.length = session->ssId.length; |
| 2454 | lim_send_probe_req_mgmt_frame(mac_ctx, &ssid, |
| 2455 | session->pLimMlmJoinReq->bssDescription.bssId, |
| 2456 | session->currentOperChannel /*chanNum */, |
| 2457 | session->selfMacAddr, session->dot11mode, |
| 2458 | session->pLimJoinReq->addIEScan.length, |
| 2459 | session->pLimJoinReq->addIEScan.addIEdata); |
| 2460 | lim_deactivate_and_change_timer(mac_ctx, |
| 2461 | eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER); |
| 2462 | /* Activate Join Periodic Probe Req timer */ |
| 2463 | if (tx_timer_activate( |
| 2464 | &mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer) != |
| 2465 | TX_SUCCESS) { |
| 2466 | lim_log(mac_ctx, LOGP, |
| 2467 | FL("could not activate Periodic Join req failure timer")); |
| 2468 | return; |
| 2469 | } |
| 2470 | } |
| 2471 | } |
| 2472 | |
| 2473 | /** |
Abhishek Singh | 7d3bc3e | 2016-02-03 17:45:01 +0530 | [diff] [blame] | 2474 | * lim_process_auth_retry_timer()- function to Retry Auth |
| 2475 | * @mac_ctx:pointer to global mac |
| 2476 | * |
| 2477 | * Return: void |
| 2478 | */ |
| 2479 | |
| 2480 | static void lim_process_auth_retry_timer(tpAniSirGlobal mac_ctx) |
| 2481 | { |
| 2482 | tpPESession session_entry; |
| 2483 | |
| 2484 | lim_log(mac_ctx, LOG1, FL("ENTER")); |
| 2485 | |
| 2486 | session_entry = |
| 2487 | pe_find_session_by_session_id(mac_ctx, |
| 2488 | mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer.sessionId); |
| 2489 | if (NULL == session_entry) { |
| 2490 | lim_log(mac_ctx, LOGE, |
| 2491 | FL("session does not exist for given SessionId : %d"), |
| 2492 | mac_ctx->lim.limTimers. |
| 2493 | g_lim_periodic_auth_retry_timer.sessionId); |
| 2494 | return; |
| 2495 | } |
| 2496 | |
| 2497 | if (tx_timer_running(&mac_ctx->lim.limTimers.gLimAuthFailureTimer) && |
| 2498 | (session_entry->limMlmState == eLIM_MLM_WT_AUTH_FRAME2_STATE) && |
| 2499 | (LIM_AUTH_ACK_RCD_SUCCESS != mac_ctx->auth_ack_status)) { |
| 2500 | tSirMacAuthFrameBody auth_frame; |
| 2501 | |
| 2502 | /* |
| 2503 | * Send the auth retry only in case we have received ack failure |
| 2504 | * else just restart the retry timer. |
| 2505 | */ |
| 2506 | if (LIM_AUTH_ACK_RCD_FAILURE == mac_ctx->auth_ack_status) { |
| 2507 | /* Prepare & send Authentication frame */ |
| 2508 | auth_frame.authAlgoNumber = |
| 2509 | (uint8_t) mac_ctx->lim.gpLimMlmAuthReq->authType; |
| 2510 | auth_frame.authTransactionSeqNumber = |
| 2511 | SIR_MAC_AUTH_FRAME_1; |
| 2512 | auth_frame.authStatusCode = 0; |
| 2513 | lim_log(mac_ctx, LOGW, FL("Retry Auth ")); |
| 2514 | mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD; |
| 2515 | lim_send_auth_mgmt_frame(mac_ctx, |
| 2516 | &auth_frame, |
| 2517 | mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr, |
| 2518 | LIM_NO_WEP_IN_FC, session_entry, true); |
| 2519 | } |
| 2520 | |
| 2521 | lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER); |
| 2522 | |
| 2523 | /* Activate Auth Retry timer */ |
| 2524 | if (tx_timer_activate |
| 2525 | (&mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer) |
| 2526 | != TX_SUCCESS) { |
| 2527 | lim_log(mac_ctx, LOGE, |
| 2528 | FL("could not activate Auth Retry failure timer")); |
| 2529 | return; |
| 2530 | } |
| 2531 | } |
| 2532 | return; |
| 2533 | } /*** lim_process_auth_retry_timer() ***/ |
| 2534 | |
| 2535 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2536 | * lim_process_auth_failure_timeout() - This function is called to process Min |
| 2537 | * Channel Timeout during channel scan. |
| 2538 | * |
| 2539 | * @mac_ctx: Pointer to Global MAC structure |
| 2540 | * |
| 2541 | * This function is called to process Min Channel Timeout during channel scan. |
| 2542 | * |
| 2543 | * @Return: None |
| 2544 | */ |
| 2545 | static void lim_process_auth_failure_timeout(tpAniSirGlobal mac_ctx) |
| 2546 | { |
| 2547 | /* fetch the sessionEntry based on the sessionId */ |
| 2548 | tpPESession session; |
| 2549 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM |
| 2550 | host_log_rssi_pkt_type *rssi_log = NULL; |
| 2551 | #endif |
| 2552 | |
| 2553 | session = pe_find_session_by_session_id(mac_ctx, |
| 2554 | mac_ctx->lim.limTimers.gLimAuthFailureTimer.sessionId); |
| 2555 | if (NULL == session) { |
| 2556 | lim_log(mac_ctx, LOGP, |
| 2557 | FL("Session Does not exist for given sessionID")); |
| 2558 | return; |
| 2559 | } |
| 2560 | |
| 2561 | lim_log(mac_ctx, LOGE, |
| 2562 | FL("received AUTH failure timeout in sessionid %d " |
| 2563 | "limMlmstate %X limSmeState %X"), |
| 2564 | session->peSessionId, session->limMlmState, |
| 2565 | session->limSmeState); |
| 2566 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM |
| 2567 | WLAN_HOST_DIAG_LOG_ALLOC(rssi_log, host_log_rssi_pkt_type, |
| 2568 | LOG_WLAN_RSSI_UPDATE_C); |
| 2569 | if (rssi_log) |
| 2570 | rssi_log->rssi = session->rssi; |
| 2571 | WLAN_HOST_DIAG_LOG_REPORT(rssi_log); |
| 2572 | #endif |
| 2573 | |
| 2574 | switch (session->limMlmState) { |
| 2575 | case eLIM_MLM_WT_AUTH_FRAME2_STATE: |
| 2576 | case eLIM_MLM_WT_AUTH_FRAME4_STATE: |
| 2577 | /* |
| 2578 | * Requesting STA did not receive next auth frame before Auth |
| 2579 | * Failure timeout. Issue MLM auth confirm with timeout reason |
| 2580 | * code. Restore default failure timeout |
| 2581 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2582 | if (QDF_P2P_CLIENT_MODE == session->pePersona |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2583 | && session->defaultAuthFailureTimeout) |
| 2584 | cfg_set_int(mac_ctx, |
| 2585 | WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT, |
| 2586 | session->defaultAuthFailureTimeout); |
| 2587 | lim_restore_from_auth_state(mac_ctx, |
| 2588 | eSIR_SME_AUTH_TIMEOUT_RESULT_CODE, |
| 2589 | eSIR_MAC_UNSPEC_FAILURE_REASON, session); |
| 2590 | break; |
| 2591 | default: |
| 2592 | /* |
| 2593 | * Auth failure timer should not have timed out |
| 2594 | * in states other than wt_auth_frame2/4 |
| 2595 | */ |
| 2596 | lim_log(mac_ctx, LOGE, |
| 2597 | FL("received unexpected AUTH failure timeout in state %X"), |
| 2598 | session->limMlmState); |
| 2599 | lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState); |
| 2600 | break; |
| 2601 | } |
| 2602 | } |
| 2603 | |
| 2604 | /** |
| 2605 | * lim_process_auth_rsp_timeout() - This function is called to process Min |
| 2606 | * Channel Timeout during channel scan. |
| 2607 | * |
| 2608 | * @mac_ctx: Pointer to Global MAC structure |
| 2609 | * |
| 2610 | * This function is called to process Min Channel Timeout during channel scan. |
| 2611 | * |
| 2612 | * @Return: None |
| 2613 | */ |
| 2614 | static void |
| 2615 | lim_process_auth_rsp_timeout(tpAniSirGlobal mac_ctx, uint32_t auth_idx) |
| 2616 | { |
| 2617 | struct tLimPreAuthNode *auth_node; |
| 2618 | tpPESession session; |
| 2619 | uint8_t session_id; |
| 2620 | |
| 2621 | auth_node = lim_get_pre_auth_node_from_index(mac_ctx, |
| 2622 | &mac_ctx->lim.gLimPreAuthTimerTable, auth_idx); |
| 2623 | if (NULL == auth_node) { |
| 2624 | lim_log(mac_ctx, LOGW, FL("Invalid auth node")); |
| 2625 | return; |
| 2626 | } |
| 2627 | |
| 2628 | session = pe_find_session_by_bssid(mac_ctx, auth_node->peerMacAddr, |
| 2629 | &session_id); |
| 2630 | if (NULL == session) { |
| 2631 | lim_log(mac_ctx, LOGW, |
| 2632 | FL("session does not exist for given BSSID ")); |
| 2633 | return; |
| 2634 | } |
| 2635 | |
| 2636 | if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) { |
| 2637 | if (auth_node->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE) { |
| 2638 | lim_log(mac_ctx, LOGE, |
| 2639 | FL("received AUTH rsp timeout in unexpected " |
| 2640 | "state for MAC address: " MAC_ADDRESS_STR), |
| 2641 | MAC_ADDR_ARRAY(auth_node->peerMacAddr)); |
| 2642 | } else { |
| 2643 | auth_node->mlmState = eLIM_MLM_AUTH_RSP_TIMEOUT_STATE; |
| 2644 | auth_node->fTimerStarted = 0; |
| 2645 | lim_log(mac_ctx, LOG1, |
| 2646 | FL("AUTH rsp timedout for MAC address " |
| 2647 | MAC_ADDRESS_STR), |
| 2648 | MAC_ADDR_ARRAY(auth_node->peerMacAddr)); |
| 2649 | /* Change timer to reactivate it in future */ |
| 2650 | lim_deactivate_and_change_per_sta_id_timer(mac_ctx, |
| 2651 | eLIM_AUTH_RSP_TIMER, auth_node->authNodeIdx); |
| 2652 | lim_delete_pre_auth_node(mac_ctx, |
| 2653 | auth_node->peerMacAddr); |
| 2654 | } |
| 2655 | } |
| 2656 | } |
| 2657 | |
| 2658 | /** |
| 2659 | * lim_process_assoc_failure_timeout() - This function is called to process Min |
| 2660 | * Channel Timeout during channel scan. |
| 2661 | * |
| 2662 | * @mac_ctx Pointer to Global MAC structure |
| 2663 | * |
| 2664 | * This function is called to process Min Channel Timeout during channel scan. |
| 2665 | * |
| 2666 | * @Return: None |
| 2667 | */ |
| 2668 | static void |
| 2669 | lim_process_assoc_failure_timeout(tpAniSirGlobal mac_ctx, uint32_t msg_type) |
| 2670 | { |
| 2671 | |
| 2672 | tLimMlmAssocCnf mlm_assoc_cnf; |
| 2673 | tpPESession session; |
| 2674 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM |
| 2675 | host_log_rssi_pkt_type *rssi_log = NULL; |
| 2676 | #endif |
| 2677 | /* |
| 2678 | * to fetch the lim/mlm state based on the session_id, use the |
| 2679 | * below sessionEntry |
| 2680 | */ |
| 2681 | uint8_t session_id; |
| 2682 | |
| 2683 | if (msg_type == LIM_ASSOC) |
| 2684 | session_id = |
| 2685 | mac_ctx->lim.limTimers.gLimAssocFailureTimer.sessionId; |
| 2686 | else |
| 2687 | session_id = |
| 2688 | mac_ctx->lim.limTimers.gLimReassocFailureTimer.sessionId; |
| 2689 | |
| 2690 | session = pe_find_session_by_session_id(mac_ctx, session_id); |
| 2691 | if (NULL == session) { |
| 2692 | lim_log(mac_ctx, LOGP, |
| 2693 | FL("Session Does not exist for given sessionID")); |
| 2694 | return; |
| 2695 | } |
| 2696 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM |
| 2697 | WLAN_HOST_DIAG_LOG_ALLOC(rssi_log, |
| 2698 | host_log_rssi_pkt_type, |
| 2699 | LOG_WLAN_RSSI_UPDATE_C); |
| 2700 | if (rssi_log) |
| 2701 | rssi_log->rssi = session->rssi; |
| 2702 | WLAN_HOST_DIAG_LOG_REPORT(rssi_log); |
| 2703 | #endif |
| 2704 | |
| 2705 | lim_log(mac_ctx, LOG1, |
| 2706 | FL("Re/Association Response not received before timeout ")); |
| 2707 | |
Rajeev Kumar | aa262c4 | 2016-04-15 15:41:08 -0700 | [diff] [blame^] | 2708 | if ((LIM_IS_AP_ROLE(session)) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2709 | ((session->limMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) && |
| 2710 | (session->limMlmState != eLIM_MLM_WT_REASSOC_RSP_STATE) && |
| 2711 | (session->limMlmState != eLIM_MLM_WT_FT_REASSOC_RSP_STATE))) { |
| 2712 | /* |
| 2713 | * Re/Assoc failure timer should not have timedout on AP |
| 2714 | * or in a state other than wt_re/assoc_response. |
| 2715 | */ |
| 2716 | lim_log(mac_ctx, LOGW, |
| 2717 | FL("received unexpected REASSOC failure timeout in state %X for role %d"), |
| 2718 | session->limMlmState, |
| 2719 | GET_LIM_SYSTEM_ROLE(session)); |
| 2720 | lim_print_mlm_state(mac_ctx, LOGW, session->limMlmState); |
| 2721 | return; |
| 2722 | } |
| 2723 | |
| 2724 | if ((msg_type == LIM_ASSOC) || ((msg_type == LIM_REASSOC) |
| 2725 | && (session->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE))) { |
| 2726 | lim_log(mac_ctx, LOGE, |
| 2727 | FL("(Re)Assoc Failure Timeout occurred.")); |
| 2728 | session->limMlmState = eLIM_MLM_IDLE_STATE; |
| 2729 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, |
| 2730 | session->peSessionId, session->limMlmState)); |
| 2731 | /* Change timer for future activations */ |
| 2732 | lim_deactivate_and_change_timer(mac_ctx, eLIM_ASSOC_FAIL_TIMER); |
| 2733 | /* |
| 2734 | * Free up buffer allocated for JoinReq held by |
| 2735 | * MLM state machine |
| 2736 | */ |
| 2737 | if (session->pLimMlmJoinReq) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2738 | qdf_mem_free(session->pLimMlmJoinReq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2739 | session->pLimMlmJoinReq = NULL; |
| 2740 | } |
| 2741 | /* To remove the preauth node in case of fail to associate */ |
| 2742 | if (lim_search_pre_auth_list(mac_ctx, session->bssId)) { |
| 2743 | lim_log(mac_ctx, LOG1, |
| 2744 | FL(" delete pre auth node for "MAC_ADDRESS_STR), |
| 2745 | MAC_ADDR_ARRAY(session->bssId)); |
| 2746 | lim_delete_pre_auth_node(mac_ctx, |
| 2747 | session->bssId); |
| 2748 | } |
| 2749 | |
| 2750 | mlm_assoc_cnf.resultCode = eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE; |
| 2751 | mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
| 2752 | /* Update PE session Id */ |
| 2753 | mlm_assoc_cnf.sessionId = session->peSessionId; |
| 2754 | if (msg_type == LIM_ASSOC) { |
| 2755 | lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF, |
| 2756 | (uint32_t *) &mlm_assoc_cnf); |
| 2757 | } else { |
| 2758 | /* |
| 2759 | * Will come here only in case of 11r, Ese FT |
| 2760 | * when reassoc rsp is not received and we |
| 2761 | * receive a reassoc - timesout |
| 2762 | */ |
| 2763 | mlm_assoc_cnf.resultCode = |
| 2764 | eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE; |
| 2765 | lim_post_sme_message(mac_ctx, LIM_MLM_REASSOC_CNF, |
| 2766 | (uint32_t *) &mlm_assoc_cnf); |
| 2767 | } |
| 2768 | } else { |
| 2769 | /* |
| 2770 | * Restore pre-reassoc req state. |
| 2771 | * Set BSSID to currently associated AP address. |
| 2772 | */ |
| 2773 | session->limMlmState = session->limPrevMlmState; |
| 2774 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, |
| 2775 | session->peSessionId, session->limMlmState)); |
| 2776 | lim_restore_pre_reassoc_state(mac_ctx, |
| 2777 | eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE, |
| 2778 | eSIR_MAC_UNSPEC_FAILURE_STATUS, session); |
| 2779 | } |
| 2780 | } |
| 2781 | |
| 2782 | /** |
| 2783 | * lim_complete_mlm_scan() - This function is called to send MLM_SCAN_CNF |
| 2784 | * message to SME state machine. |
| 2785 | * |
| 2786 | * @mac_ctx: Pointer to Global MAC structure |
| 2787 | * @ret_code: Result code to be sent |
| 2788 | * |
| 2789 | * This function is called to send MLM_SCAN_CNF message to SME state machine. |
| 2790 | * |
| 2791 | * @Return: None |
| 2792 | */ |
| 2793 | |
| 2794 | void lim_complete_mlm_scan(tpAniSirGlobal mac_ctx, tSirResultCodes ret_code) |
| 2795 | { |
| 2796 | tLimMlmScanCnf mlm_scan_cnf; |
| 2797 | |
| 2798 | /* Restore previous MLM state */ |
| 2799 | mac_ctx->lim.gLimMlmState = mac_ctx->lim.gLimPrevMlmState; |
| 2800 | MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, NO_SESSION, |
| 2801 | mac_ctx->lim.gLimMlmState)); |
| 2802 | lim_restore_pre_scan_state(mac_ctx); |
| 2803 | /* Free up mac_ctx->lim.gLimMlmScanReq */ |
| 2804 | if (NULL != mac_ctx->lim.gpLimMlmScanReq) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2805 | qdf_mem_free(mac_ctx->lim.gpLimMlmScanReq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2806 | mac_ctx->lim.gpLimMlmScanReq = NULL; |
| 2807 | } |
| 2808 | |
| 2809 | mlm_scan_cnf.resultCode = ret_code; |
| 2810 | lim_post_sme_message(mac_ctx, LIM_MLM_SCAN_CNF, |
| 2811 | (uint32_t *) &mlm_scan_cnf); |
| 2812 | } |
| 2813 | |
| 2814 | /** |
| 2815 | * lim_set_channel() - set channel api for lim |
| 2816 | * |
| 2817 | * @mac_ctx: Pointer to Global MAC structure |
| 2818 | * @channel: power save state |
| 2819 | * @ch_center_freq_seg0: center freq seq 0 |
| 2820 | * @ch_center_freq_seg1: center freq seq 1 |
| 2821 | * @ch_width: channel width |
| 2822 | * @max_tx_power: max tx power |
| 2823 | * @pe_session_id: pe session id |
| 2824 | * |
| 2825 | * set channel api for lim |
| 2826 | * |
| 2827 | * @Return: None |
| 2828 | */ |
| 2829 | void lim_set_channel(tpAniSirGlobal mac_ctx, uint8_t channel, |
| 2830 | uint8_t ch_center_freq_seg0, uint8_t ch_center_freq_seg1, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 2831 | enum phy_ch_width ch_width, int8_t max_tx_power, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2832 | uint8_t pe_session_id) |
| 2833 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2834 | tpPESession pe_session; |
| 2835 | pe_session = pe_find_session_by_session_id(mac_ctx, pe_session_id); |
| 2836 | |
| 2837 | if (NULL == pe_session) { |
| 2838 | lim_log(mac_ctx, LOGP, FL("Invalid PE session = %d"), |
| 2839 | pe_session_id); |
| 2840 | return; |
| 2841 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2842 | lim_send_switch_chnl_params(mac_ctx, channel, ch_center_freq_seg0, |
| 2843 | ch_center_freq_seg1, ch_width, |
| 2844 | max_tx_power, pe_session_id, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2845 | } |