blob: c290d09763905393f6e0fc065a000cdfd2b7d779 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
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 Dhavali7090c5f2015-11-02 17:55:19 -080044#include <lim_ft.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
46#include "host_diag_core_log.h"
47#endif
48#include "wma_if.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070049#include "wlan_reg_services_api.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053050#include "lim_process_fils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051
52static void lim_process_mlm_start_req(tpAniSirGlobal, uint32_t *);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053static void lim_process_mlm_join_req(tpAniSirGlobal, uint32_t *);
54static void lim_process_mlm_auth_req(tpAniSirGlobal, uint32_t *);
55static void lim_process_mlm_assoc_req(tpAniSirGlobal, uint32_t *);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056static void lim_process_mlm_disassoc_req(tpAniSirGlobal, uint32_t *);
57static void lim_process_mlm_deauth_req(tpAniSirGlobal, uint32_t *);
58static void lim_process_mlm_set_keys_req(tpAniSirGlobal, uint32_t *);
59
60/* MLM Timeout event handler templates */
61static void lim_process_periodic_probe_req_timer(tpAniSirGlobal mac_ctx);
62static void lim_process_join_failure_timeout(tpAniSirGlobal);
63static void lim_process_auth_failure_timeout(tpAniSirGlobal);
64static void lim_process_auth_rsp_timeout(tpAniSirGlobal, uint32_t);
65static void lim_process_assoc_failure_timeout(tpAniSirGlobal, uint32_t);
66static void lim_process_periodic_join_probe_req_timer(tpAniSirGlobal);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +053067static void lim_process_auth_retry_timer(tpAniSirGlobal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
69/**
70 * lim_process_mlm_req_messages() - process mlm request messages
71 * @mac_ctx: global MAC context
72 * @msg: mlm request message
73 *
74 * This function is called by lim_post_mlm_message(). This
75 * function handles MLM primitives invoked by SME.
76 * Depending on the message type, corresponding function will be
77 * called.
78 * ASSUMPTIONS:
79 * 1. Upon receiving Beacon in WT_JOIN_STATE, MLM module invokes
80 * APIs exposed by Beacon Processing module for setting parameters
81 * at MAC hardware.
82 * 2. If attempt to Reassociate with an AP fails, link with current
83 * AP is restored back.
84 *
85 * Return: None
86 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -080087void lim_process_mlm_req_messages(tpAniSirGlobal mac_ctx,
88 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090 switch (msg->type) {
91 case LIM_MLM_START_REQ:
92 lim_process_mlm_start_req(mac_ctx, msg->bodyptr);
93 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094 case LIM_MLM_JOIN_REQ:
95 lim_process_mlm_join_req(mac_ctx, msg->bodyptr);
96 break;
97 case LIM_MLM_AUTH_REQ:
98 lim_process_mlm_auth_req(mac_ctx, msg->bodyptr);
99 break;
100 case LIM_MLM_ASSOC_REQ:
101 lim_process_mlm_assoc_req(mac_ctx, msg->bodyptr);
102 break;
103 case LIM_MLM_REASSOC_REQ:
104 lim_process_mlm_reassoc_req(mac_ctx, msg->bodyptr);
105 break;
106 case LIM_MLM_DISASSOC_REQ:
107 lim_process_mlm_disassoc_req(mac_ctx, msg->bodyptr);
108 break;
109 case LIM_MLM_DEAUTH_REQ:
110 lim_process_mlm_deauth_req(mac_ctx, msg->bodyptr);
111 break;
112 case LIM_MLM_SETKEYS_REQ:
113 lim_process_mlm_set_keys_req(mac_ctx, msg->bodyptr);
114 break;
115 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
116 lim_process_periodic_probe_req_timer(mac_ctx);
117 break;
118 case SIR_LIM_JOIN_FAIL_TIMEOUT:
119 lim_process_join_failure_timeout(mac_ctx);
120 break;
121 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
122 lim_process_periodic_join_probe_req_timer(mac_ctx);
123 break;
124 case SIR_LIM_AUTH_FAIL_TIMEOUT:
125 lim_process_auth_failure_timeout(mac_ctx);
126 break;
127 case SIR_LIM_AUTH_RSP_TIMEOUT:
128 lim_process_auth_rsp_timeout(mac_ctx, msg->bodyval);
129 break;
130 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
131 lim_process_assoc_failure_timeout(mac_ctx, msg->bodyval);
132 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:
134 lim_process_ft_preauth_rsp_timeout(mac_ctx);
135 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800136 case SIR_LIM_REMAIN_CHN_TIMEOUT:
137 lim_process_remain_on_chn_timeout(mac_ctx);
138 break;
139 case SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT:
140 lim_process_insert_single_shot_noa_timeout(mac_ctx);
141 break;
142 case SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE:
143 lim_convert_active_channel_to_passive_channel(mac_ctx);
144 break;
145 case SIR_LIM_DISASSOC_ACK_TIMEOUT:
146 lim_process_disassoc_ack_timeout(mac_ctx);
147 break;
148 case SIR_LIM_DEAUTH_ACK_TIMEOUT:
149 lim_process_deauth_ack_timeout(mac_ctx);
150 break;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530151 case SIR_LIM_AUTH_RETRY_TIMEOUT:
152 lim_process_auth_retry_timer(mac_ctx);
153 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 case LIM_MLM_TSPEC_REQ:
155 default:
156 break;
157 } /* switch (msg->type) */
158}
159
160/* WLAN_SUSPEND_LINK Related */
161
162/**
163 * lim_is_link_suspended()- check if link is suspended
164 * @mac_ctx: global MAC context
165 *
166 * This function returns is link is suspended or not.
167 * Since Suspend link uses init scan, it just returns
168 * gLimSystemInScanLearnMode flag.
169 *
170 * Return: uint8_t(gLimSystemInScanLearnMode flag)
171 */
172uint8_t lim_is_link_suspended(tpAniSirGlobal mac_ctx)
173{
174 return mac_ctx->lim.gLimSystemInScanLearnMode;
175}
176
177/**
178 * lim_change_channel_with_callback() - change channel and register callback
179 * @mac_ctx: global MAC context
180 * @new_chan: new channel to switch
181 * @callback: Callback function
182 * @cbdata: callback data
183 * @session_entry: PE session pointer
184 *
185 * This function is called to change channel and perform off channel operation
186 * if required. The caller registers a callback to be called at the end of the
187 * channel change.
188 *
189 * Return: None
190 */
191void
192lim_change_channel_with_callback(tpAniSirGlobal mac_ctx, uint8_t new_chan,
193 CHANGE_CHANNEL_CALLBACK callback,
194 uint32_t *cbdata, tpPESession session_entry)
195{
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700196 pe_debug("Switching channel to %d", new_chan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197 session_entry->channelChangeReasonCode =
198 LIM_SWITCH_CHANNEL_OPERATION;
199
200 mac_ctx->lim.gpchangeChannelCallback = callback;
201 mac_ctx->lim.gpchangeChannelData = cbdata;
202
203 lim_send_switch_chnl_params(mac_ctx, new_chan, 0, 0,
204 CH_WIDTH_20MHZ, session_entry->maxTxPower,
Arif Hussain671a1902017-03-17 09:08:32 -0700205 session_entry->peSessionId, false, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206
207 return;
208}
209
210/**
211 * lim_covert_channel_scan_type() - switch between ACTIVE and PASSIVE scan type
212 * @mac_ctx: global MAC context
213 * @chan_num: channel number to change the scan type
214 * @passive_to_active: flag to indicate if switch allowed
215 *
216 * This function is called to get the list,
217 * change the channel type and set again.
218 * NOTE: If a channel is ACTIVE, this function will make it as PASSIVE
219 * If a channel is PASSIVE, this fucntion will make it as ACTIVE
220 *
221 * Return: None
222 */
223
224void lim_covert_channel_scan_type(tpAniSirGlobal mac_ctx, uint8_t chan_num,
225 bool passive_to_active)
226{
227
228 uint32_t i;
229 uint8_t chan_pair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
230 uint32_t len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
231 tSirRetStatus status;
232
233 status = wlan_cfg_get_str(mac_ctx, WNI_CFG_SCAN_CONTROL_LIST,
234 chan_pair, &len);
235 if (eSIR_SUCCESS != status) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700236 pe_err("Unable to get scan control list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237 return;
238 }
239 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700240 pe_err("Invalid scan control list length: %d", len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 return;
242 }
243 for (i = 0; (i + 1) < len; i += 2) {
244 if (chan_pair[i] != chan_num) /* skip this channel */
245 continue;
246 if ((eSIR_PASSIVE_SCAN == chan_pair[i + 1]) &&
247 true == passive_to_active) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700248 pe_debug("Channel %d changed from Passive to Active",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 chan_num);
250 chan_pair[i + 1] = eSIR_ACTIVE_SCAN;
251 break;
252 }
253 if ((eSIR_ACTIVE_SCAN == chan_pair[i + 1]) &&
254 false == passive_to_active) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700255 pe_debug("Channel %d changed from Active to Passive",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 chan_num);
257 chan_pair[i + 1] = eSIR_PASSIVE_SCAN;
258 break;
259 }
260 }
261
262 cfg_set_str_notify(mac_ctx, WNI_CFG_SCAN_CONTROL_LIST,
263 (uint8_t *) chan_pair, len, false);
264 return;
265}
266
267/**
268 * lim_set_dfs_channel_list() - convert dfs channel list to active channel list
269 * @mac_ctx: global MAC context.
270 * @chan_num: channel number
271 * @dfs_ch_list: list of DFS channels
272 *
273 * This function is called to convert DFS channel list to active channel list
274 * when any beacon is present on that channel. This function store time for
275 * passive channels which help to know that for how much time channel has been
276 * passive.
277 *
278 * NOTE: If a channel is ACTIVE, it won't store any time
279 * If a channel is PAssive, it will store time as timestamp
280 *
281 * Return: None
282 */
283void lim_set_dfs_channel_list(tpAniSirGlobal mac_ctx, uint8_t chan_num,
284 tSirDFSChannelList *dfs_ch_list)
285{
286 bool pass_to_active = true;
287
288 if (!((1 <= chan_num) && (165 >= chan_num))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700289 pe_err("Invalid Channel: %d", chan_num);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800290 return;
291 }
292
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700293 if (lim_isconnected_on_dfs_channel(mac_ctx, chan_num)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 if (dfs_ch_list->timeStamp[chan_num] == 0) {
295 /*
296 * Received first beacon;
297 * Convert DFS channel to Active channel.
298 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700299 pe_debug("Received first beacon on DFS channel: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 chan_num);
301 lim_covert_channel_scan_type(mac_ctx, chan_num,
302 pass_to_active);
303 }
304 dfs_ch_list->timeStamp[chan_num] =
Anurag Chouhan210db072016-02-22 18:42:15 +0530305 qdf_mc_timer_get_system_time();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 return;
308 }
309
310 if (!tx_timer_running
311 (&mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer)) {
312 tx_timer_activate(
313 &mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer);
314 }
315
316 return;
317}
318
319/**
320 * lim_restore_pre_scan_state() - restore HW state prior to scan
321 *
322 * @mac_ctx: global MAC context
323 *
324 * This function is called by lim_continue_channel_scan()
325 * to restore HW state prior to entering 'scan state'
326 *
327 * Return: None
328 */
329void lim_restore_pre_scan_state(tpAniSirGlobal mac_ctx)
330{
331 /* Deactivate MIN/MAX channel timers if running */
332 lim_deactivate_and_change_timer(mac_ctx, eLIM_MIN_CHANNEL_TIMER);
333 lim_deactivate_and_change_timer(mac_ctx, eLIM_MAX_CHANNEL_TIMER);
334
335 mac_ctx->lim.gLimSystemInScanLearnMode = 0;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700336 pe_debug("Scan ended, took %llu tu",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 (tx_time_get() - mac_ctx->lim.scanStartTime));
338}
339
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340/**
341 * mlm_add_sta() - MLM add sta
342 * @mac_ctx: global MAC context
343 * @sta_param: Add sta params
344 * @bssid: BSSID
345 * @ht_capable: HT capability
346 * @session_entry: PE session entry
347 *
348 * This function is called to update station parameters
349 *
350 * Return: None
351 */
352static void mlm_add_sta(tpAniSirGlobal mac_ctx, tpAddStaParams sta_param,
353 uint8_t *bssid, uint8_t ht_capable, tpPESession session_entry)
354{
355 uint32_t val;
356 uint32_t self_dot11mode = 0;
357
358 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_dot11mode);
359 sta_param->staType = STA_ENTRY_SELF; /* Identifying self */
360
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530361 qdf_mem_copy(sta_param->bssId, bssid, sizeof(tSirMacAddr));
362 qdf_mem_copy(sta_param->staMac, session_entry->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 sizeof(tSirMacAddr));
364
365 /* Configuration related parameters to be changed to support BT-AMP */
366
367 if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL,
368 &val))
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700369 pe_warn("Couldn't get LISTEN_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800370 sta_param->listenInterval = (uint16_t) val;
371
372 if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx, WNI_CFG_SHORT_PREAMBLE,
373 &val))
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700374 pe_warn("Couldn't get SHORT_PREAMBLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 sta_param->shortPreambleSupported = (uint8_t) val;
376
377 sta_param->assocId = 0; /* Is SMAC OK with this? */
378 sta_param->wmmEnabled = 0;
379 sta_param->uAPSD = 0;
380 sta_param->maxSPLen = 0;
381 sta_param->us32MaxAmpduDuration = 0;
382 sta_param->maxAmpduSize = 0; /* 0: 8k, 1: 16k,2: 32k,3: 64k, 4:128k */
383
384 /* For Self STA get the LDPC capability from config.ini */
385 sta_param->htLdpcCapable =
386 (session_entry->txLdpcIniFeatureEnabled & 0x01);
387 sta_param->vhtLdpcCapable =
388 ((session_entry->txLdpcIniFeatureEnabled >> 1) & 0x01);
389
390 if (IS_DOT11_MODE_HT(session_entry->dot11mode)) {
391 sta_param->htCapable = ht_capable;
392 sta_param->greenFieldCapable =
393 lim_get_ht_capability(mac_ctx, eHT_GREENFIELD,
394 session_entry);
395 sta_param->ch_width =
396 lim_get_ht_capability(mac_ctx,
397 eHT_SUPPORTED_CHANNEL_WIDTH_SET, session_entry);
398 sta_param->mimoPS =
399 (tSirMacHTMIMOPowerSaveState)lim_get_ht_capability(
400 mac_ctx, eHT_MIMO_POWER_SAVE, session_entry);
401 sta_param->rifsMode =
402 lim_get_ht_capability(mac_ctx, eHT_RIFS_MODE,
403 session_entry);
404 sta_param->lsigTxopProtection =
405 lim_get_ht_capability(mac_ctx, eHT_LSIG_TXOP_PROTECTION,
406 session_entry);
407 sta_param->maxAmpduDensity =
408 lim_get_ht_capability(mac_ctx, eHT_MPDU_DENSITY,
409 session_entry);
410 sta_param->maxAmsduSize =
411 lim_get_ht_capability(mac_ctx, eHT_MAX_AMSDU_LENGTH,
412 session_entry);
Deepak Dhamdhere612392c2016-08-28 02:56:51 -0700413 sta_param->max_amsdu_num =
414 lim_get_ht_capability(mac_ctx, eHT_MAX_AMSDU_NUM,
415 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 sta_param->fDsssCckMode40Mhz =
417 lim_get_ht_capability(mac_ctx, eHT_DSSS_CCK_MODE_40MHZ,
418 session_entry);
419 sta_param->fShortGI20Mhz =
420 lim_get_ht_capability(mac_ctx, eHT_SHORT_GI_20MHZ,
421 session_entry);
422 sta_param->fShortGI40Mhz =
423 lim_get_ht_capability(mac_ctx, eHT_SHORT_GI_40MHZ,
424 session_entry);
425 }
426 if (session_entry->vhtCapability) {
427 sta_param->vhtCapable = true;
428 sta_param->vhtTxBFCapable =
Krunal Soni53993f72016-07-08 18:20:03 -0700429 session_entry->vht_config.su_beam_formee;
430 sta_param->vhtTxMUBformeeCapable =
431 session_entry->vht_config.mu_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 sta_param->enable_su_tx_bformer =
Krunal Soni53993f72016-07-08 18:20:03 -0700433 session_entry->vht_config.su_beam_former;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800435
436 if (lim_is_session_he_capable(session_entry))
437 lim_add_self_he_cap(sta_param, session_entry);
438
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 /*
440 * Since this is Self-STA, need to populate Self MAX_AMPDU_SIZE
441 * capabilities
442 */
443 if (IS_DOT11_MODE_VHT(self_dot11mode)) {
444 val = 0; /* Default 8K AMPDU size */
445 if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx,
446 WNI_CFG_VHT_AMPDU_LEN_EXPONENT, &val))
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700447 pe_err("Couldn't get WNI_CFG_VHT_AMPDU_LEN_EXPONENT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 sta_param->maxAmpduSize = (uint8_t) val;
449 }
450 sta_param->enableVhtpAid = session_entry->enableVhtpAid;
451 sta_param->enableAmpduPs = session_entry->enableAmpduPs;
452 sta_param->enableHtSmps = session_entry->enableHtSmps;
453 sta_param->htSmpsconfig = session_entry->htSmpsvalue;
Archana Ramachandranfec24812016-02-16 16:31:56 -0800454 sta_param->send_smps_action = session_entry->send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456 lim_populate_own_rate_set(mac_ctx, &sta_param->supportedRates, NULL,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -0700457 false, session_entry, NULL, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700459 pe_debug("GF: %d, ChnlWidth: %d, MimoPS: %d, lsigTXOP: %d, dsssCCK: %d,"
460 " SGI20: %d, SGI40%d", sta_param->greenFieldCapable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 sta_param->ch_width, sta_param->mimoPS,
462 sta_param->lsigTxopProtection, sta_param->fDsssCckMode40Mhz,
463 sta_param->fShortGI20Mhz, sta_param->fShortGI40Mhz);
464
Anurag Chouhan6d760662016-02-20 16:05:43 +0530465 if (QDF_P2P_GO_MODE == session_entry->pePersona)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 sta_param->p2pCapableSta = 1;
467}
468
469/**
470 * lim_mlm_add_bss() - HAL interface for WMA_ADD_BSS_REQ
471 * @mac_ctx: global MAC context
472 * @mlm_start_req: MLM start request
473 * @session: PE session entry
474 *
475 * Package WMA_ADD_BSS_REQ to HAL, in order to start a BSS
476 *
477 * Return: eSIR_SME_SUCCESS on success, other error codes otherwise
478 */
479tSirResultCodes
480lim_mlm_add_bss(tpAniSirGlobal mac_ctx,
481 tLimMlmStartReq *mlm_start_req, tpPESession session)
482{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700483 struct scheduler_msg msg_buf = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484 tpAddBssParams addbss_param = NULL;
485 uint32_t retcode;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800486 bool is_ch_dfs = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487
488 /* Package WMA_ADD_BSS_REQ message parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530489 addbss_param = qdf_mem_malloc(sizeof(tAddBssParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490 if (NULL == addbss_param) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700491 pe_err("Unable to allocate memory during ADD_BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 /* Respond to SME with LIM_MLM_START_CNF */
Srinivas Girigowdad3b31e22017-06-28 00:15:10 -0700493 return eSIR_SME_RESOURCES_UNAVAILABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 }
495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496 /* Fill in tAddBssParams members */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530497 qdf_mem_copy(addbss_param->bssId, mlm_start_req->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 sizeof(tSirMacAddr));
499
500 /* Fill in tAddBssParams selfMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530501 qdf_mem_copy(addbss_param->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 session->selfMacAddr, sizeof(tSirMacAddr));
503
504 addbss_param->bssType = mlm_start_req->bssType;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700505 if (mlm_start_req->bssType == eSIR_IBSS_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 addbss_param->operMode = BSS_OPERATIONAL_MODE_STA;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700507 else if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508 addbss_param->operMode = BSS_OPERATIONAL_MODE_AP;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700509 else if (mlm_start_req->bssType == eSIR_NDI_MODE)
510 addbss_param->operMode = BSS_OPERATIONAL_MODE_NDI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511
512 addbss_param->shortSlotTimeSupported = session->shortSlotTimeSupported;
513 addbss_param->beaconInterval = mlm_start_req->beaconPeriod;
514 addbss_param->dtimPeriod = mlm_start_req->dtimPeriod;
515 addbss_param->wps_state = mlm_start_req->wps_state;
516 addbss_param->cfParamSet.cfpCount = mlm_start_req->cfParamSet.cfpCount;
517 addbss_param->cfParamSet.cfpPeriod =
518 mlm_start_req->cfParamSet.cfpPeriod;
519 addbss_param->cfParamSet.cfpMaxDuration =
520 mlm_start_req->cfParamSet.cfpMaxDuration;
521 addbss_param->cfParamSet.cfpDurRemaining =
522 mlm_start_req->cfParamSet.cfpDurRemaining;
523
524 addbss_param->rateSet.numRates = mlm_start_req->rateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530525 qdf_mem_copy(addbss_param->rateSet.rate, mlm_start_req->rateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800526 mlm_start_req->rateSet.numRates);
527
528 addbss_param->nwType = mlm_start_req->nwType;
529 addbss_param->htCapable = mlm_start_req->htCapable;
530 addbss_param->vhtCapable = session->vhtCapability;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800531 if (lim_is_session_he_capable(session)) {
532 lim_update_bss_he_capable(mac_ctx, addbss_param);
533 lim_decide_he_op(mac_ctx, addbss_param, session);
534 lim_update_usr_he_cap(mac_ctx, session);
535 }
536
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537 addbss_param->ch_width = session->ch_width;
538 addbss_param->ch_center_freq_seg0 =
539 session->ch_center_freq_seg0;
540 addbss_param->ch_center_freq_seg1 =
541 session->ch_center_freq_seg1;
542 addbss_param->htOperMode = mlm_start_req->htOperMode;
543 addbss_param->dualCTSProtection = mlm_start_req->dualCTSProtection;
544 addbss_param->txChannelWidthSet = mlm_start_req->txChannelWidthSet;
545
546 addbss_param->currentOperChannel = mlm_start_req->channelNumber;
547#ifdef WLAN_FEATURE_11W
548 addbss_param->rmfEnabled = session->limRmfEnabled;
549#endif
550
551 /* Update PE sessionId */
552 addbss_param->sessionId = mlm_start_req->sessionId;
553
554 /* Send the SSID to HAL to enable SSID matching for IBSS */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530555 qdf_mem_copy(&(addbss_param->ssId.ssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 mlm_start_req->ssId.ssId, mlm_start_req->ssId.length);
557 addbss_param->ssId.length = mlm_start_req->ssId.length;
558 addbss_param->bHiddenSSIDEn = mlm_start_req->ssidHidden;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700559 pe_debug("TRYING TO HIDE SSID %d", addbss_param->bHiddenSSIDEn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560 /* CR309183. Disable Proxy Probe Rsp. Host handles Probe Requests. Until FW fixed. */
561 addbss_param->bProxyProbeRespEn = 0;
562 addbss_param->obssProtEnabled = mlm_start_req->obssProtEnabled;
563
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564 addbss_param->maxTxPower = session->maxTxPower;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800565
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566 mlm_add_sta(mac_ctx, &addbss_param->staContext,
567 addbss_param->bssId, addbss_param->htCapable,
568 session);
569
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530570 addbss_param->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 addbss_param->respReqd = 1;
572
573 /* Set a new state for MLME */
574 session->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_STATE;
575 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId,
576 session->limMlmState));
577
578 /* pass on the session persona to hal */
579 addbss_param->halPersona = session->pePersona;
580
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800581 if (session->ch_width == CH_WIDTH_160MHZ) {
582 is_ch_dfs = true;
583 } else if (session->ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700584 if (wlan_reg_get_channel_state(mac_ctx->pdev,
585 mlm_start_req->channelNumber) ==
586 CHANNEL_STATE_DFS ||
587 wlan_reg_get_channel_state(mac_ctx->pdev,
588 session->ch_center_freq_seg1 -
589 SIR_80MHZ_START_CENTER_CH_DIFF) ==
590 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800591 is_ch_dfs = true;
592 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700593 if (wlan_reg_get_channel_state(mac_ctx->pdev,
594 mlm_start_req->channelNumber) ==
595 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800596 is_ch_dfs = true;
597 }
598
599 addbss_param->bSpectrumMgtEnabled =
600 session->spectrumMgtEnabled || is_ch_dfs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601 addbss_param->extSetStaKeyParamValid = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800602
603 addbss_param->dot11_mode = session->dot11mode;
604 addbss_param->nss = session->nss;
Arif Hussain671a1902017-03-17 09:08:32 -0700605 addbss_param->cac_duration_ms = mlm_start_req->cac_duration_ms;
606 addbss_param->dfs_regdomain = mlm_start_req->dfs_regdomain;
Kiran Kumar Lokere6a7d1eb2016-05-02 18:31:35 -0700607 if (QDF_IBSS_MODE == addbss_param->halPersona) {
608 addbss_param->nss_2g = mac_ctx->vdev_type_nss_2g.ibss;
609 addbss_param->nss_5g = mac_ctx->vdev_type_nss_5g.ibss;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +0530610 addbss_param->tx_aggregation_size =
611 mac_ctx->roam.configParam.tx_aggregation_size;
612 addbss_param->rx_aggregation_size =
613 mac_ctx->roam.configParam.rx_aggregation_size;
Kiran Kumar Lokere6a7d1eb2016-05-02 18:31:35 -0700614 }
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700615 pe_debug("dot11_mode:%d nss value:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616 addbss_param->dot11_mode, addbss_param->nss);
617
Naveen Rawat64e477e2016-05-20 10:34:56 -0700618 if (cds_is_5_mhz_enabled()) {
619 addbss_param->ch_width = CH_WIDTH_5MHZ;
620 addbss_param->staContext.ch_width = CH_WIDTH_5MHZ;
621 } else if (cds_is_10_mhz_enabled()) {
622 addbss_param->ch_width = CH_WIDTH_10MHZ;
623 addbss_param->staContext.ch_width = CH_WIDTH_10MHZ;
624 }
625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800626 msg_buf.type = WMA_ADD_BSS_REQ;
627 msg_buf.reserved = 0;
628 msg_buf.bodyptr = addbss_param;
629 msg_buf.bodyval = 0;
630 MTRACE(mac_trace_msg_tx(mac_ctx, session->peSessionId, msg_buf.type));
631
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700632 pe_debug("Sending WMA_ADD_BSS_REQ...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 retcode = wma_post_ctrl_msg(mac_ctx, &msg_buf);
634 if (eSIR_SUCCESS != retcode) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700635 pe_err("Posting ADD_BSS_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 retcode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530637 qdf_mem_free(addbss_param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
639 }
640
641 return eSIR_SME_SUCCESS;
642}
643
644/**
645 * lim_process_mlm_start_req() - process MLM_START_REQ message
646 *
647 * @mac_ctx: global MAC context
648 * @msg_buf: Pointer to MLM message buffer
649 *
650 * This function is called to process MLM_START_REQ message
651 * from SME
652 * 1) MLME receives LIM_MLM_START_REQ from LIM
653 * 2) MLME sends WMA_ADD_BSS_REQ to HAL
654 * 3) MLME changes state to eLIM_MLM_WT_ADD_BSS_RSP_STATE
655 * MLME now waits for HAL to send WMA_ADD_BSS_RSP
656 *
657 * Return: None
658 */
659static void lim_process_mlm_start_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
660{
661 tLimMlmStartReq *mlm_start_req;
662 tLimMlmStartCnf mlm_start_cnf;
663 tpPESession session = NULL;
664
665 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700666 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 return;
668 }
669
670 mlm_start_req = (tLimMlmStartReq *) msg_buf;
671 session = pe_find_session_by_session_id(mac_ctx,
672 mlm_start_req->sessionId);
673 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700674 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 mlm_start_cnf.resultCode = eSIR_SME_REFUSED;
676 goto end;
677 }
678
679 if (session->limMlmState != eLIM_MLM_IDLE_STATE) {
680 /*
681 * Should not have received Start req in states other than idle.
682 * Return Start confirm with failure code.
683 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700684 pe_err("received unexpected MLM_START_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685 session->limMlmState);
686 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
687 mlm_start_cnf.resultCode =
688 eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
689 goto end;
690 }
691
692 mlm_start_cnf.resultCode =
693 lim_mlm_add_bss(mac_ctx, mlm_start_req, session);
694
695end:
696 /* Update PE session Id */
697 mlm_start_cnf.sessionId = mlm_start_req->sessionId;
698
699 /* Free up buffer allocated for LimMlmScanReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530700 qdf_mem_free(msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701
702 /*
703 * Respond immediately to LIM, only if MLME has not been
704 * successfully able to send WMA_ADD_BSS_REQ to HAL.
705 * Else, LIM_MLM_START_CNF will be sent after receiving
706 * WMA_ADD_BSS_RSP from HAL
707 */
708 if (eSIR_SME_SUCCESS != mlm_start_cnf.resultCode)
709 lim_post_sme_message(mac_ctx, LIM_MLM_START_CNF,
710 (uint32_t *) &mlm_start_cnf);
711}
712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713/**
714 * lim_post_join_set_link_state_callback()- registered callback to perform post
715 * peer creation operations
716 *
717 * @mac: pointer to global mac structure
718 * @callback_arg: registered callback argument
719 * @status: peer creation status
720 *
721 * this is registered callback function during association to perform
722 * post peer creation operation based on the peer creation status
723 *
724 * Return: none
725 */
Jeff Johnson3a4d31e2016-10-07 07:25:04 -0700726static void lim_post_join_set_link_state_callback(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727 void *callback_arg, bool status)
728{
729 uint8_t chan_num, sec_chan_offset;
730 tpPESession session_entry = (tpPESession) callback_arg;
731 tLimMlmJoinCnf mlm_join_cnf;
732
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700733 pe_debug("Sessionid %d set link state(%d) cb status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 session_entry->peSessionId, session_entry->limMlmState,
735 status);
736
737 if (!status) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700738 pe_err("failed to find pe session for session id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 session_entry->peSessionId);
740 goto failure;
741 }
742
743 chan_num = session_entry->currentOperChannel;
744 sec_chan_offset = session_entry->htSecondaryChannelOffset;
745 /*
746 * store the channel switch session_entry in the lim
747 * global variable
748 */
749 session_entry->channelChangeReasonCode =
750 LIM_SWITCH_CHANNEL_JOIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 session_entry->pLimMlmReassocRetryReq = NULL;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700752 pe_debug("[lim_process_mlm_join_req]: suspend link success(%d) "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753 "on sessionid: %d setting channel to: %d with ch_width :%d "
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700754 "and maxtxPower: %d", status, session_entry->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 session_entry->currentOperChannel,
756 session_entry->ch_width,
757 session_entry->maxTxPower);
758 lim_set_channel(mac, session_entry->currentOperChannel,
759 session_entry->ch_center_freq_seg0,
760 session_entry->ch_center_freq_seg1,
761 session_entry->ch_width,
762 session_entry->maxTxPower,
Arif Hussain671a1902017-03-17 09:08:32 -0700763 session_entry->peSessionId, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 return;
765
766failure:
767 MTRACE(mac_trace(mac, TRACE_CODE_MLM_STATE, session_entry->peSessionId,
768 session_entry->limMlmState));
769 session_entry->limMlmState = eLIM_MLM_IDLE_STATE;
770 mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
771 mlm_join_cnf.sessionId = session_entry->peSessionId;
772 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
773 lim_post_sme_message(mac, LIM_MLM_JOIN_CNF, (uint32_t *) &mlm_join_cnf);
774}
775
776/**
777 * lim_process_mlm_post_join_suspend_link() - This function is called after the
778 * suspend link while joining off channel.
779 *
780 * @mac_ctx: Pointer to Global MAC structure
781 * @status: status of suspend link.
782 * @ctx: passed while calling suspend link(session)
783 *
784 * This function does following:
785 * Check for suspend state.
786 * If success, proceed with setting link state to recieve the
787 * probe response/beacon from intended AP.
788 * Switch to the APs channel.
789 * On an error case, send the MLM_JOIN_CNF with error status.
790 *
791 * @Return None
792 */
793static void
794lim_process_mlm_post_join_suspend_link(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530795 QDF_STATUS status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 uint32_t *ctx)
797{
798 tLimMlmJoinCnf mlm_join_cnf;
799 tpPESession session = (tpPESession) ctx;
800 tSirLinkState lnk_state;
801
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530802 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700803 pe_err("Sessionid %d Suspend link(NOTIFY_BSS) failed. Still proceeding with join",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 session->peSessionId);
805 }
806 lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER);
807
808 /* assign appropriate sessionId to the timer object */
809 mac_ctx->lim.limTimers.gLimJoinFailureTimer.sessionId =
810 session->peSessionId;
811
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700812 lnk_state = eSIR_LINK_PREASSOC_STATE;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700813 pe_debug("[lim_process_mlm_join_req]: lnk_state: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 lnk_state);
815
816 if (lim_set_link_state(mac_ctx, lnk_state,
817 session->pLimMlmJoinReq->bssDescription.bssId,
818 session->selfMacAddr,
819 lim_post_join_set_link_state_callback,
820 session) != eSIR_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700821 pe_err("SessionId:%d lim_set_link_state to eSIR_LINK_PREASSOC_STATE Failed!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 session->peSessionId);
823 lim_print_mac_addr(mac_ctx,
824 session->pLimMlmJoinReq->bssDescription.bssId, LOGE);
825 mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
826 session->limMlmState = eLIM_MLM_IDLE_STATE;
827 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
828 session->peSessionId, session->limMlmState));
829 goto error;
830 }
831
832 return;
833error:
834 mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
835 mlm_join_cnf.sessionId = session->peSessionId;
836 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
837 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
838 (uint32_t *) &mlm_join_cnf);
839}
840
841/**
842 * lim_process_mlm_join_req() - process mlm join request.
843 *
844 * @mac_ctx: Pointer to Global MAC structure
845 * @msg: Pointer to the MLM message buffer
846 *
847 * This function is called to process MLM_JOIN_REQ message
848 * from SME. It does following:
849 * 1) Initialize LIM, HAL, DPH
850 * 2) Configure the BSS for which the JOIN REQ was received
851 * a) Send WMA_ADD_BSS_REQ to HAL -
852 * This will identify the BSS that we are interested in
853 * --AND--
854 * Add a STA entry for the AP (in a STA context)
855 * b) Wait for WMA_ADD_BSS_RSP
856 * c) Send WMA_ADD_STA_REQ to HAL
857 * This will add the "local STA" entry to the STA table
858 * 3) Continue as before, i.e,
859 * a) Send a PROBE REQ
860 * b) Wait for PROBE RSP/BEACON containing the SSID that
861 * we are interested in
862 * c) Then start an AUTH seq
863 * d) Followed by the ASSOC seq
864 *
865 * @Return: None
866 */
867static void lim_process_mlm_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg)
868{
869 tLimMlmJoinCnf mlmjoin_cnf;
870 uint8_t sessionid;
871 tpPESession session;
872
873 sessionid = ((tpLimMlmJoinReq) msg)->sessionId;
874
875 session = pe_find_session_by_session_id(mac_ctx, sessionid);
876 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700877 pe_err("SessionId:%d does not exist", sessionid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 goto error;
879 }
880
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700881 if (!LIM_IS_AP_ROLE(session) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 ((session->limMlmState == eLIM_MLM_IDLE_STATE) ||
883 (session->limMlmState == eLIM_MLM_JOINED_STATE)) &&
884 (SIR_MAC_GET_ESS
885 (((tpLimMlmJoinReq) msg)->bssDescription.capabilityInfo) !=
886 SIR_MAC_GET_IBSS(((tpLimMlmJoinReq) msg)->bssDescription.
887 capabilityInfo))) {
888 /* Hold onto Join request parameters */
889
890 session->pLimMlmJoinReq = (tpLimMlmJoinReq) msg;
891 if (is_lim_session_off_channel(mac_ctx, sessionid)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700892 pe_debug("SessionId:%d LimSession is on OffChannel",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 sessionid);
894 /* suspend link */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700895 pe_debug("Suspend link, sessionid %d is off channel",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 sessionid);
897 if (lim_is_link_suspended(mac_ctx)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700898 pe_err("link is already suspended, session %d",
899 sessionid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 goto error;
901 }
902 lim_process_mlm_post_join_suspend_link(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530903 QDF_STATUS_SUCCESS, (uint32_t *)session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700905 pe_debug("No need to Suspend link");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 /*
907 * No need to Suspend link as LimSession is not
908 * off channel, calling
909 * lim_process_mlm_post_join_suspend_link with
910 * status as SUCCESS.
911 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700912 pe_debug("SessionId:%d Join req on current chan",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 sessionid);
914 lim_process_mlm_post_join_suspend_link(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530915 QDF_STATUS_SUCCESS, (uint32_t *)session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 }
917 return;
918 } else {
919 /**
920 * Should not have received JOIN req in states other than
921 * Idle state or on AP.
922 * Return join confirm with invalid parameters code.
923 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700924 pe_err("Session:%d Unexpected Join req, role %d state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925 session->peSessionId, GET_LIM_SYSTEM_ROLE(session),
926 session->limMlmState);
927 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
928 }
929
930error:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530931 qdf_mem_free(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 if (session != NULL)
933 session->pLimMlmJoinReq = NULL;
934 mlmjoin_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
935 mlmjoin_cnf.sessionId = sessionid;
936 mlmjoin_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
937 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
938 (uint32_t *)&mlmjoin_cnf);
939
940}
941
942/**
943 * lim_is_auth_req_expected() - check if auth request is expected
944 *
945 * @mac_ctx: global MAC context
946 * @session: PE session entry
947 *
948 * This function is called by lim_process_mlm_auth_req to check
949 * if auth request is expected.
950 *
951 * Return: true if expected and false otherwise
952 */
953static bool lim_is_auth_req_expected(tpAniSirGlobal mac_ctx,
954 tpPESession session)
955{
956 bool flag = false;
957
958 /*
959 * Expect Auth request only when:
960 * 1. STA joined/associated with a BSS or
961 * 2. STA is in IBSS mode
962 * and STA is going to authenticate with a unicast
963 * address and requested authentication algorithm is
964 * supported.
965 */
966
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700967 flag = (((LIM_IS_STA_ROLE(session) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 ((session->limMlmState == eLIM_MLM_JOINED_STATE) ||
969 (session->limMlmState ==
970 eLIM_MLM_LINK_ESTABLISHED_STATE))) ||
971 (LIM_IS_IBSS_ROLE(session) &&
972 (session->limMlmState ==
973 eLIM_MLM_BSS_STARTED_STATE))) &&
974 (!lim_is_group_addr(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr))
975 && lim_is_auth_algo_supported(mac_ctx,
976 mac_ctx->lim.gpLimMlmAuthReq->authType, session));
977
978 return flag;
979}
980
981/**
982 * lim_is_preauth_ctx_exisits() - check if preauth context exists
983 *
984 * @mac_ctx: global MAC context
985 * @session: PE session entry
986 * @preauth_node_ptr: pointer to preauth node pointer
987 *
988 * This function is called by lim_process_mlm_auth_req to check
989 * if preauth context already exists
990 *
991 * Return: true if exists and false otherwise
992 */
993static bool lim_is_preauth_ctx_exists(tpAniSirGlobal mac_ctx,
994 tpPESession session,
995 struct tLimPreAuthNode **preauth_node_ptr)
996{
997 bool fl = false;
998 struct tLimPreAuthNode *preauth_node;
999 tpDphHashNode stads;
1000 tSirMacAddr curr_bssid;
1001
1002 preauth_node = *preauth_node_ptr;
1003 sir_copy_mac_addr(curr_bssid, session->bssId);
1004 stads = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
1005 &session->dph.dphHashTable);
1006 preauth_node = lim_search_pre_auth_list(mac_ctx,
1007 mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr);
1008
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001009 fl = (((LIM_IS_STA_ROLE(session)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 (session->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE) &&
1011 ((stads != NULL) &&
1012 (mac_ctx->lim.gpLimMlmAuthReq->authType ==
1013 stads->mlmStaContext.authType)) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301014 (!qdf_mem_cmp(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 curr_bssid, sizeof(tSirMacAddr)))) ||
1016 ((preauth_node != NULL) &&
1017 (preauth_node->authType ==
1018 mac_ctx->lim.gpLimMlmAuthReq->authType)));
1019
1020 return fl;
1021}
1022
1023/**
1024 * lim_process_mlm_auth_req() - process lim auth request
1025 *
1026 * @mac_ctx: global MAC context
1027 * @msg: MLM auth request message
1028 *
1029 * This function is called to process MLM_AUTH_REQ message from SME
1030 *
1031 * @Return: None
1032 */
1033static void lim_process_mlm_auth_req(tpAniSirGlobal mac_ctx, uint32_t *msg)
1034{
1035 uint32_t num_preauth_ctx;
1036 tSirMacAddr curr_bssid;
1037 tSirMacAuthFrameBody auth_frame_body;
1038 tLimMlmAuthCnf mlm_auth_cnf;
1039 struct tLimPreAuthNode *preauth_node = NULL;
1040 uint8_t session_id;
1041 tpPESession session;
1042
1043 if (msg == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001044 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 return;
1046 }
1047
1048 mac_ctx->lim.gpLimMlmAuthReq = (tLimMlmAuthReq *) msg;
1049 session_id = mac_ctx->lim.gpLimMlmAuthReq->sessionId;
1050 session = pe_find_session_by_session_id(mac_ctx, session_id);
1051 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001052 pe_err("SessionId:%d does not exist", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 return;
1054 }
1055
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001056 pe_debug("Process Auth Req sessionID %d Systemrole %d"
1057 "mlmstate %d from: " MAC_ADDRESS_STR
1058 " with authtype %d", session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 GET_LIM_SYSTEM_ROLE(session), session->limMlmState,
1060 MAC_ADDR_ARRAY(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr),
1061 mac_ctx->lim.gpLimMlmAuthReq->authType);
1062
1063 sir_copy_mac_addr(curr_bssid, session->bssId);
1064
1065 if (!lim_is_auth_req_expected(mac_ctx, session)) {
1066 /*
1067 * Unexpected auth request.
1068 * Return Auth confirm with Invalid parameters code.
1069 */
1070 mlm_auth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1071 goto end;
1072 }
1073
1074 /*
1075 * This is a request for pre-authentication. Check if there exists
1076 * context already for the requested peer OR
1077 * if this request is for the AP we're currently associated with.
1078 * If yes, return auth confirm immediately when
1079 * requested auth type is same as the one used before.
1080 */
1081 if (lim_is_preauth_ctx_exists(mac_ctx, session, &preauth_node)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001082 pe_debug("Already have pre-auth context with peer: "
1083 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 MAC_ADDR_ARRAY(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr));
1085 mlm_auth_cnf.resultCode = (tSirResultCodes)
1086 eSIR_MAC_SUCCESS_STATUS;
1087 goto end;
1088 } else {
1089 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_MAX_NUM_PRE_AUTH,
1090 (uint32_t *) &num_preauth_ctx) != eSIR_SUCCESS)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001091 pe_warn("Could not retrieve NumPreAuthLimit from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092
1093 if (mac_ctx->lim.gLimNumPreAuthContexts == num_preauth_ctx) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001094 pe_warn("Number of pre-auth reached max limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 /* Return Auth confirm with reject code */
1096 mlm_auth_cnf.resultCode =
1097 eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED;
1098 goto end;
1099 }
1100 }
1101
1102 /* Delete pre-auth node if exists */
1103 if (preauth_node)
1104 lim_delete_pre_auth_node(mac_ctx,
1105 mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr);
1106
1107 session->limPrevMlmState = session->limMlmState;
1108 session->limMlmState = eLIM_MLM_WT_AUTH_FRAME2_STATE;
1109 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId,
1110 session->limMlmState));
1111
1112 /* Prepare & send Authentication frame */
1113 auth_frame_body.authAlgoNumber =
1114 (uint8_t) mac_ctx->lim.gpLimMlmAuthReq->authType;
1115 auth_frame_body.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
1116 auth_frame_body.authStatusCode = 0;
1117#ifdef FEATURE_WLAN_DIAG_SUPPORT
1118 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_START_EVENT, session,
1119 eSIR_SUCCESS, auth_frame_body.authStatusCode);
1120#endif
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301121 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122 lim_send_auth_mgmt_frame(mac_ctx,
1123 &auth_frame_body, mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301124 LIM_NO_WEP_IN_FC, session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125
1126 /* assign appropriate session_id to the timer object */
1127 mac_ctx->lim.limTimers.gLimAuthFailureTimer.sessionId = session_id;
1128
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301129 /* assign appropriate sessionId to the timer object */
1130 mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer.sessionId =
1131 session_id;
1132 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133 /* Activate Auth failure timer */
1134 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1135 session->peSessionId, eLIM_AUTH_FAIL_TIMER));
1136 if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimAuthFailureTimer)
1137 != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001138 pe_err("could not start Auth failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 /* Cleanup as if auth timer expired */
1140 lim_process_auth_failure_timeout(mac_ctx);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301141 } else {
1142 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1143 session->peSessionId, eLIM_AUTH_RETRY_TIMER));
1144 /* Activate Auth Retry timer */
1145 if (tx_timer_activate
1146 (&mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer)
1147 != TX_SUCCESS)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001148 pe_err("could not activate Auth Retry timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 }
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 return;
1152end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301153 qdf_mem_copy((uint8_t *) &mlm_auth_cnf.peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 (uint8_t *) &mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
1155 sizeof(tSirMacAddr));
1156
1157 mlm_auth_cnf.authType = mac_ctx->lim.gpLimMlmAuthReq->authType;
1158 mlm_auth_cnf.sessionId = session_id;
1159
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301160 qdf_mem_free(mac_ctx->lim.gpLimMlmAuthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001161 mac_ctx->lim.gpLimMlmAuthReq = NULL;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001162 pe_debug("SessionId:%d LimPostSme LIM_MLM_AUTH_CNF",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163 session_id);
1164 lim_post_sme_message(mac_ctx, LIM_MLM_AUTH_CNF,
1165 (uint32_t *) &mlm_auth_cnf);
1166}
1167
1168/**
1169 * lim_process_mlm_assoc_req() - This function is called to process
1170 * MLM_ASSOC_REQ message from SME
1171 *
1172 * @mac_ctx: Pointer to Global MAC structure
1173 * @msg_buf: A pointer to the MLM message buffer
1174 *
1175 * This function is called to process MLM_ASSOC_REQ message from SME
1176 *
1177 * @Return None
1178 */
1179
1180static void lim_process_mlm_assoc_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1181{
1182 tSirMacAddr curr_bssId;
1183 tLimMlmAssocReq *mlm_assoc_req;
1184 tLimMlmAssocCnf mlm_assoc_cnf;
1185 tpPESession session_entry;
1186
1187 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001188 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189 return;
1190 }
1191
1192 mlm_assoc_req = (tLimMlmAssocReq *) msg_buf;
1193 session_entry = pe_find_session_by_session_id(mac_ctx,
1194 mlm_assoc_req->sessionId);
1195 if (session_entry == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001196 pe_err("SessionId:%d Session Does not exist",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 mlm_assoc_req->sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301198 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001199 return;
1200 }
1201
1202 sir_copy_mac_addr(curr_bssId, session_entry->bssId);
1203
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001204 if (!(!LIM_IS_AP_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205 (session_entry->limMlmState == eLIM_MLM_AUTHENTICATED_STATE ||
1206 session_entry->limMlmState == eLIM_MLM_JOINED_STATE) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301207 (!qdf_mem_cmp(mlm_assoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208 curr_bssId, sizeof(tSirMacAddr))))) {
1209 /*
1210 * Received Association request either in invalid state
1211 * or to a peer MAC entity whose address is different
1212 * from one that STA is currently joined with or on AP.
1213 * Return Assoc confirm with Invalid parameters code.
1214 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001215 pe_warn("received unexpected MLM_ASSOC_CNF in state %X for role=%d, MAC addr= "
1216 MAC_ADDRESS_STR, session_entry->limMlmState,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 GET_LIM_SYSTEM_ROLE(session_entry),
1218 MAC_ADDR_ARRAY(mlm_assoc_req->peerMacAddr));
1219 lim_print_mlm_state(mac_ctx, LOGW, session_entry->limMlmState);
1220 mlm_assoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1221 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
1222 goto end;
1223 }
1224
1225 /* map the session entry pointer to the AssocFailureTimer */
1226 mac_ctx->lim.limTimers.gLimAssocFailureTimer.sessionId =
1227 mlm_assoc_req->sessionId;
1228#ifdef WLAN_FEATURE_11W
1229 /*
1230 * Store current MLM state in case ASSOC response returns with
1231 * TRY_AGAIN_LATER return code.
1232 */
1233 if (session_entry->limRmfEnabled) {
1234 session_entry->pmfComebackTimerInfo.limPrevMlmState =
1235 session_entry->limPrevMlmState;
1236 session_entry->pmfComebackTimerInfo.limMlmState =
1237 session_entry->limMlmState;
1238 }
1239#endif /* WLAN_FEATURE_11W */
1240
1241 session_entry->limPrevMlmState = session_entry->limMlmState;
1242 session_entry->limMlmState = eLIM_MLM_WT_ASSOC_RSP_STATE;
1243 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
1244 session_entry->peSessionId,
1245 session_entry->limMlmState));
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001246 pe_debug("SessionId:%d Sending Assoc_Req Frame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 session_entry->peSessionId);
1248
1249 /* Prepare and send Association request frame */
1250 lim_send_assoc_req_mgmt_frame(mac_ctx, mlm_assoc_req, session_entry);
1251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 /* Start association failure timer */
1253 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1254 session_entry->peSessionId, eLIM_ASSOC_FAIL_TIMER));
1255 if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimAssocFailureTimer)
1256 != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001257 pe_warn("SessionId:%d couldn't start Assoc failure timer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 session_entry->peSessionId);
1259 /* Cleanup as if assoc timer expired */
1260 lim_process_assoc_failure_timeout(mac_ctx, LIM_ASSOC);
1261 }
1262
1263 return;
1264end:
1265 /* Update PE session Id */
1266 mlm_assoc_cnf.sessionId = mlm_assoc_req->sessionId;
1267 /* Free up buffer allocated for assocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301268 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
1270 (uint32_t *) &mlm_assoc_cnf);
1271}
1272
1273/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 * lim_process_mlm_disassoc_req_ntf() - process disassoc request notification
1275 *
1276 * @mac_ctx: global MAC context
1277 * @suspend_status: suspend status
1278 * @msg: mlm message buffer
1279 *
1280 * This function is used to process MLM disassoc notification
1281 *
1282 * Return: None
1283 */
1284static void
1285lim_process_mlm_disassoc_req_ntf(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301286 QDF_STATUS suspend_status, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287{
1288 uint16_t aid;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301289 struct qdf_mac_addr curr_bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 tpDphHashNode stads;
1291 tLimMlmDisassocReq *mlm_disassocreq;
1292 tLimMlmDisassocCnf mlm_disassoccnf;
1293 tpPESession session;
1294 extern bool send_disassoc_frame;
1295 tLimMlmStates mlm_state;
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301296 tSirSmeDisassocRsp *sme_disassoc_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301298 if (QDF_STATUS_SUCCESS != suspend_status)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001299 pe_err("Suspend Status is not success %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 suspend_status);
1301
1302 mlm_disassocreq = (tLimMlmDisassocReq *) msg;
1303
1304 session = pe_find_session_by_session_id(mac_ctx,
1305 mlm_disassocreq->sessionId);
1306 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001307 pe_err("session does not exist for given sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 mlm_disassocreq->sessionId);
1309 mlm_disassoccnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1310 goto end;
1311 }
1312
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001313 pe_debug("Process DisAssoc Req on sessionID %d Systemrole %d"
1314 "mlmstate %d from: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 mlm_disassocreq->sessionId, GET_LIM_SYSTEM_ROLE(session),
1316 session->limMlmState,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001317 MAC_ADDR_ARRAY(mlm_disassocreq->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301319 qdf_mem_copy(curr_bssid.bytes, session->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320
1321 switch (GET_LIM_SYSTEM_ROLE(session)) {
1322 case eLIM_STA_ROLE:
Anurag Chouhanc5548422016-02-24 18:33:27 +05301323 if (!qdf_is_macaddr_equal(&mlm_disassocreq->peer_macaddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001324 &curr_bssid)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001325 pe_warn("received MLM_DISASSOC_REQ with invalid BSS id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326 lim_print_mac_addr(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001327 mlm_disassocreq->peer_macaddr.bytes, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301329 /*
1330 * Disassociation response due to host triggered
1331 * disassociation
1332 */
1333 sme_disassoc_rsp =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301334 qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301335 if (NULL == sme_disassoc_rsp) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001336 pe_err("memory allocation failed for disassoc rsp");
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301337 return;
1338 }
1339
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001340 pe_debug("send disassoc rsp with ret code %d for" MAC_ADDRESS_STR,
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301341 eSIR_SME_DEAUTH_STATUS,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001342 MAC_ADDR_ARRAY(
1343 mlm_disassocreq->peer_macaddr.bytes));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301344
1345 sme_disassoc_rsp->messageType = eWNI_SME_DISASSOC_RSP;
1346 sme_disassoc_rsp->length = sizeof(tSirSmeDisassocRsp);
1347 sme_disassoc_rsp->sessionId =
1348 mlm_disassocreq->sessionId;
1349 sme_disassoc_rsp->transactionId = 0;
1350 sme_disassoc_rsp->statusCode = eSIR_SME_DEAUTH_STATUS;
1351
Anurag Chouhanc5548422016-02-24 18:33:27 +05301352 qdf_copy_macaddr(&sme_disassoc_rsp->peer_macaddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001353 &mlm_disassocreq->peer_macaddr);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301354 msg = (uint32_t *)sme_disassoc_rsp;
1355
1356 lim_send_sme_disassoc_deauth_ntf(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301357 QDF_STATUS_SUCCESS, msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301358 return;
1359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 }
1361 break;
1362 case eLIM_STA_IN_IBSS_ROLE:
1363 break;
1364 case eLIM_AP_ROLE:
1365 case eLIM_P2P_DEVICE_GO:
1366 if (true ==
1367 mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001368 pe_err("CAC timer is running, drop disassoc from going out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 mlm_disassoccnf.resultCode = eSIR_SME_SUCCESS;
1370 goto end;
1371 }
1372 break;
1373 default:
1374 break;
1375 } /* end switch (GET_LIM_SYSTEM_ROLE(session)) */
1376
1377 /*
1378 * Check if there exists a context for the peer entity
1379 * to be disassociated with.
1380 */
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001381 stads = dph_lookup_hash_entry(mac_ctx,
1382 mlm_disassocreq->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 &aid, &session->dph.dphHashTable);
1384 if (stads)
1385 mlm_state = stads->mlmStaContext.mlmState;
1386
1387 if ((stads == NULL) ||
1388 (stads &&
1389 ((mlm_state != eLIM_MLM_LINK_ESTABLISHED_STATE) &&
1390 (mlm_state != eLIM_MLM_WT_ASSOC_CNF_STATE) &&
1391 (mlm_state != eLIM_MLM_ASSOCIATED_STATE)))) {
1392 /*
1393 * Received LIM_MLM_DISASSOC_REQ for STA that does not
1394 * have context or in some transit state.
1395 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001396 pe_warn("Invalid MLM_DISASSOC_REQ, Addr= " MAC_ADDRESS_STR,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001397 MAC_ADDR_ARRAY(mlm_disassocreq->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 if (stads != NULL)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001399 pe_err("Sta MlmState: %d", stads->mlmStaContext.mlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400
1401 /* Prepare and Send LIM_MLM_DISASSOC_CNF */
1402 mlm_disassoccnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1403 goto end;
1404 }
1405
1406 stads->mlmStaContext.disassocReason = (tSirMacReasonCodes)
1407 mlm_disassocreq->reasonCode;
1408 stads->mlmStaContext.cleanupTrigger = mlm_disassocreq->disassocTrigger;
1409
1410 /*
1411 * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
1412 * This is to address the issue of race condition between
1413 * disconnect request from the HDD and deauth from AP
1414 */
1415
1416 stads->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
1417
1418 /* Send Disassociate frame to peer entity */
1419 if (send_disassoc_frame && (mlm_disassocreq->reasonCode !=
1420 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
1421 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq =
1422 mlm_disassocreq;
1423 /*
1424 * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
1425 * This is to address the issue of race condition between
1426 * disconnect request from the HDD and deauth from AP
1427 */
1428 stads->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
1429
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05301430 lim_send_disassoc_mgmt_frame(mac_ctx,
1431 mlm_disassocreq->reasonCode,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001432 mlm_disassocreq->peer_macaddr.bytes, session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 /*
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05301434 * Abort Tx so that data frames won't be sent to the AP
1435 * after sending Disassoc.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 */
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05301437 if (LIM_IS_STA_ROLE(session))
1438 wma_tx_abort(session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 } else {
1440 /* Disassoc frame is not sent OTA */
1441 send_disassoc_frame = 1;
1442 /* Receive path cleanup with dummy packet */
1443 if (eSIR_SUCCESS !=
1444 lim_cleanup_rx_path(mac_ctx, stads, session)) {
1445 mlm_disassoccnf.resultCode =
1446 eSIR_SME_RESOURCES_UNAVAILABLE;
1447 goto end;
1448 }
1449 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301450 qdf_mem_free(mlm_disassocreq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451 }
1452
1453 return;
1454
1455end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301456 qdf_mem_copy((uint8_t *) &mlm_disassoccnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001457 (uint8_t *) mlm_disassocreq->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301458 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 mlm_disassoccnf.aid = mlm_disassocreq->aid;
1460 mlm_disassoccnf.disassocTrigger = mlm_disassocreq->disassocTrigger;
1461
1462 /* Update PE session ID */
1463 mlm_disassoccnf.sessionId = mlm_disassocreq->sessionId;
1464
1465 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301466 qdf_mem_free(mlm_disassocreq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467
1468 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
1469 (uint32_t *) &mlm_disassoccnf);
1470}
1471
1472/**
1473 * lim_check_disassoc_deauth_ack_pending() - check if deauth is pending
1474 *
1475 * @mac_ctx - global MAC context
1476 * @sta_mac - station MAC
1477 *
1478 * This function checks if diassociation or deauthentication is pending for
1479 * given station MAC address.
1480 *
1481 * Return: true if pending and false otherwise.
1482 */
1483bool lim_check_disassoc_deauth_ack_pending(tpAniSirGlobal mac_ctx,
1484 uint8_t *sta_mac)
1485{
1486 tLimMlmDisassocReq *disassoc_req;
1487 tLimMlmDeauthReq *deauth_req;
1488
1489 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
1490 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301491 if ((disassoc_req && (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001492 (uint8_t *) &disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301493 QDF_MAC_ADDR_SIZE))) ||
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301494 (deauth_req && (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001495 (uint8_t *) &deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301496 QDF_MAC_ADDR_SIZE)))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001497 pe_debug("Disassoc/Deauth ack pending");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 return true;
1499 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001500 pe_debug("Disassoc/Deauth Ack not pending");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 return false;
1502 }
1503}
1504
1505/*
1506 * lim_clean_up_disassoc_deauth_req() - cleans up pending disassoc or deauth req
1507 *
1508 * @mac_ctx: mac_ctx
1509 * @sta_mac: sta mac address
1510 * @clean_rx_path: flag to indicate whether to cleanup rx path or not
1511 *
1512 * This function cleans up pending disassoc or deauth req
1513 *
1514 * Return: void
1515 */
1516void lim_clean_up_disassoc_deauth_req(tpAniSirGlobal mac_ctx,
1517 uint8_t *sta_mac, bool clean_rx_path)
1518{
1519 tLimMlmDisassocReq *mlm_disassoc_req;
1520 tLimMlmDeauthReq *mlm_deauth_req;
1521 mlm_disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
1522 if (mlm_disassoc_req &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301523 (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001524 (uint8_t *) &mlm_disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301525 QDF_MAC_ADDR_SIZE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 if (clean_rx_path) {
1527 lim_process_disassoc_ack_timeout(mac_ctx);
1528 } else {
1529 if (tx_timer_running(
1530 &mac_ctx->lim.limTimers.gLimDisassocAckTimer)) {
1531 lim_deactivate_and_change_timer(mac_ctx,
1532 eLIM_DISASSOC_ACK_TIMER);
1533 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301534 qdf_mem_free(mlm_disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq =
1536 NULL;
1537 }
1538 }
1539
1540 mlm_deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
1541 if (mlm_deauth_req &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301542 (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001543 (uint8_t *) &mlm_deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301544 QDF_MAC_ADDR_SIZE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 if (clean_rx_path) {
1546 lim_process_deauth_ack_timeout(mac_ctx);
1547 } else {
1548 if (tx_timer_running(
1549 &mac_ctx->lim.limTimers.gLimDeauthAckTimer)) {
1550 lim_deactivate_and_change_timer(mac_ctx,
1551 eLIM_DEAUTH_ACK_TIMER);
1552 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301553 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq =
1555 NULL;
1556 }
1557 }
1558}
1559
1560/*
1561 * lim_process_disassoc_ack_timeout() - wrapper function around
1562 * lim_send_disassoc_cnf
1563 *
1564 * @mac_ctx: mac_ctx
1565 *
1566 * wrapper function around lim_send_disassoc_cnf
1567 *
1568 * Return: void
1569 */
1570void lim_process_disassoc_ack_timeout(tpAniSirGlobal mac_ctx)
1571{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 lim_send_disassoc_cnf(mac_ctx);
1573}
1574
1575/**
1576 * lim_process_mlm_disassoc_req() - This function is called to process
1577 * MLM_DISASSOC_REQ message from SME
1578 *
1579 * @mac_ctx: Pointer to Global MAC structure
1580 * @msg_buf: A pointer to the MLM message buffer
1581 *
1582 * This function is called to process MLM_DISASSOC_REQ message from SME
1583 *
1584 * @Return: None
1585 */
1586static void
1587lim_process_mlm_disassoc_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1588{
1589 tLimMlmDisassocReq *mlm_disassoc_req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590
1591 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001592 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 return;
1594 }
1595
1596 mlm_disassoc_req = (tLimMlmDisassocReq *) msg_buf;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001597 pe_debug("Process disassoc req, sessionID %d from: "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 mlm_disassoc_req->sessionId,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001599 MAC_ADDR_ARRAY(mlm_disassoc_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301601 lim_process_mlm_disassoc_req_ntf(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602 (uint32_t *) msg_buf);
1603}
1604
1605/**
1606 * lim_process_mlm_deauth_req_ntf() - This function is process mlm deauth req
1607 * notification
1608 *
1609 * @mac_ctx: Pointer to Global MAC structure
1610 * @suspend_status: suspend status
1611 * @msg_buf: A pointer to the MLM message buffer
1612 *
1613 * This function is process mlm deauth req notification
1614 *
1615 * @Return: None
1616 */
1617static void
1618lim_process_mlm_deauth_req_ntf(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301619 QDF_STATUS suspend_status, uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620{
1621 uint16_t aid;
1622 tSirMacAddr curr_bssId;
1623 tpDphHashNode sta_ds;
1624 struct tLimPreAuthNode *auth_node;
1625 tLimMlmDeauthReq *mlm_deauth_req;
1626 tLimMlmDeauthCnf mlm_deauth_cnf;
1627 tpPESession session;
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301628 tSirSmeDeauthRsp *sme_deauth_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301630 if (QDF_STATUS_SUCCESS != suspend_status)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001631 pe_err("Suspend Status is not success %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 suspend_status);
1633
1634 mlm_deauth_req = (tLimMlmDeauthReq *) msg_buf;
1635 session = pe_find_session_by_session_id(mac_ctx,
1636 mlm_deauth_req->sessionId);
1637 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001638 pe_err("session does not exist for given sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 mlm_deauth_req->sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301640 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 return;
1642 }
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001643 pe_debug("Process Deauth Req on sessionID %d Systemrole %d"
1644 "mlmstate %d from: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 mlm_deauth_req->sessionId,
1646 GET_LIM_SYSTEM_ROLE(session),
1647 session->limMlmState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001648 MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 sir_copy_mac_addr(curr_bssId, session->bssId);
1650
1651 switch (GET_LIM_SYSTEM_ROLE(session)) {
1652 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 switch (session->limMlmState) {
1654 case eLIM_MLM_IDLE_STATE:
1655 /*
1656 * Attempting to Deauthenticate with a pre-authenticated
1657 * peer. Deauthetiate with peer if there exists a
1658 * pre-auth context below.
1659 */
1660 break;
1661 case eLIM_MLM_AUTHENTICATED_STATE:
1662 case eLIM_MLM_WT_ASSOC_RSP_STATE:
1663 case eLIM_MLM_LINK_ESTABLISHED_STATE:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301664 if (qdf_mem_cmp(mlm_deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301665 curr_bssId, QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001666 pe_err("received MLM_DEAUTH_REQ with invalid BSS id "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 "Peer MAC: "MAC_ADDRESS_STR
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001668 " CFG BSSID Addr : "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 MAC_ADDR_ARRAY(
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001670 mlm_deauth_req->peer_macaddr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 MAC_ADDR_ARRAY(curr_bssId));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301672 /*
1673 * Deauthentication response to host triggered
1674 * deauthentication
1675 */
1676 sme_deauth_rsp =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301677 qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301678 if (NULL == sme_deauth_rsp) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001679 pe_err("memory allocation failed for deauth rsp");
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301680 return;
1681 }
1682
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001683 pe_debug("send deauth rsp with ret code %d for" MAC_ADDRESS_STR,
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301684 eSIR_SME_DEAUTH_STATUS,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001685 MAC_ADDR_ARRAY(
1686 mlm_deauth_req->peer_macaddr.bytes));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301687
1688 sme_deauth_rsp->messageType =
1689 eWNI_SME_DEAUTH_RSP;
1690 sme_deauth_rsp->length =
1691 sizeof(tSirSmeDeauthRsp);
1692 sme_deauth_rsp->statusCode =
1693 eSIR_SME_DEAUTH_STATUS;
1694 sme_deauth_rsp->sessionId =
1695 mlm_deauth_req->sessionId;
1696 sme_deauth_rsp->transactionId = 0;
1697
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301698 qdf_mem_copy(sme_deauth_rsp->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001699 mlm_deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301700 QDF_MAC_ADDR_SIZE);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301701
1702 msg_buf = (uint32_t *)sme_deauth_rsp;
1703
1704 lim_send_sme_disassoc_deauth_ntf(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301705 QDF_STATUS_SUCCESS, msg_buf);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301706 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 }
1708
1709 if ((session->limMlmState ==
1710 eLIM_MLM_AUTHENTICATED_STATE) ||
1711 (session->limMlmState ==
1712 eLIM_MLM_WT_ASSOC_RSP_STATE)) {
1713 /* Send deauth frame to peer entity */
1714 lim_send_deauth_mgmt_frame(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001715 mlm_deauth_req->reasonCode,
1716 mlm_deauth_req->peer_macaddr.bytes,
1717 session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 /* Prepare and Send LIM_MLM_DEAUTH_CNF */
1719 mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS;
1720 session->limMlmState = eLIM_MLM_IDLE_STATE;
1721 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
1722 session->peSessionId,
1723 session->limMlmState));
1724 goto end;
1725 }
1726 break;
1727 default:
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001728 pe_warn("received MLM_DEAUTH_REQ with in state %d for peer "
1729 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 session->limMlmState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001731 MAC_ADDR_ARRAY(
1732 mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 lim_print_mlm_state(mac_ctx, LOGW,
1734 session->limMlmState);
1735 /* Prepare and Send LIM_MLM_DEAUTH_CNF */
1736 mlm_deauth_cnf.resultCode =
1737 eSIR_SME_STA_NOT_AUTHENTICATED;
1738
1739 goto end;
1740 }
1741 break;
1742 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001743 pe_err("received MLM_DEAUTH_REQ IBSS Mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 mlm_deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1745 goto end;
1746 case eLIM_AP_ROLE:
1747 case eLIM_P2P_DEVICE_GO:
1748 if (true ==
1749 mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001750 pe_err("CAC timer is running, drop disassoc from going out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS;
1752 goto end;
1753 }
1754 break;
1755
1756 default:
1757 break;
1758 } /* end switch (GET_LIM_SYSTEM_ROLE(session)) */
1759
1760 /*
1761 * Check if there exists a context for the peer entity
1762 * to be deauthenticated with.
1763 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001764 sta_ds = dph_lookup_hash_entry(mac_ctx,
1765 mlm_deauth_req->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766 &aid, &session->dph.dphHashTable);
1767
1768 if (sta_ds == NULL) {
1769 /* Check if there exists pre-auth context for this STA */
1770 auth_node = lim_search_pre_auth_list(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001771 mlm_deauth_req->peer_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 if (auth_node == NULL) {
1773 /*
1774 * Received DEAUTH REQ for a STA that is neither
1775 * Associated nor Pre-authenticated. Log error,
1776 * Prepare and Send LIM_MLM_DEAUTH_CNF
1777 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001778 pe_warn("received MLM_DEAUTH_REQ in mlme state %d for STA that "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 "does not have context, Addr="
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001780 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 session->limMlmState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001782 MAC_ADDR_ARRAY(
1783 mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 mlm_deauth_cnf.resultCode =
1785 eSIR_SME_STA_NOT_AUTHENTICATED;
1786 } else {
1787 mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS;
1788 /* Delete STA from pre-auth STA list */
1789 lim_delete_pre_auth_node(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001790 mlm_deauth_req->peer_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 /* Send Deauthentication frame to peer entity */
1792 lim_send_deauth_mgmt_frame(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001793 mlm_deauth_req->reasonCode,
1794 mlm_deauth_req->peer_macaddr.bytes,
1795 session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 }
1797 goto end;
1798 } else if ((sta_ds->mlmStaContext.mlmState !=
1799 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
1800 (sta_ds->mlmStaContext.mlmState !=
1801 eLIM_MLM_WT_ASSOC_CNF_STATE)) {
1802 /*
1803 * received MLM_DEAUTH_REQ for STA that either has no context or
1804 * in some transit state
1805 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001806 pe_warn("Invalid MLM_DEAUTH_REQ, Addr="MAC_ADDRESS_STR,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001807 MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 /* Prepare and Send LIM_MLM_DEAUTH_CNF */
1809 mlm_deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1810 goto end;
1811 }
1812 /* sta_ds->mlmStaContext.rxPurgeReq = 1; */
1813 sta_ds->mlmStaContext.disassocReason = (tSirMacReasonCodes)
1814 mlm_deauth_req->reasonCode;
1815 sta_ds->mlmStaContext.cleanupTrigger = mlm_deauth_req->deauthTrigger;
1816 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = mlm_deauth_req;
1817 /*
1818 * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
1819 * This is to address the issue of race condition between
1820 * disconnect request from the HDD and disassoc from
1821 * inactivity timer. This will make sure that we will not
1822 * process disassoc if deauth is in progress for the station
1823 * and thus mlmStaContext.cleanupTrigger will not be overwritten.
1824 */
1825 sta_ds->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
1826 /* Send Deauthentication frame to peer entity */
1827 lim_send_deauth_mgmt_frame(mac_ctx, mlm_deauth_req->reasonCode,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001828 mlm_deauth_req->peer_macaddr.bytes,
1829 session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 return;
1831end:
Anurag Chouhanc5548422016-02-24 18:33:27 +05301832 qdf_copy_macaddr(&mlm_deauth_cnf.peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001833 &mlm_deauth_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 mlm_deauth_cnf.deauthTrigger = mlm_deauth_req->deauthTrigger;
1835 mlm_deauth_cnf.aid = mlm_deauth_req->aid;
1836 mlm_deauth_cnf.sessionId = mlm_deauth_req->sessionId;
1837
1838 /* Free up buffer allocated for mlmDeauthReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301839 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 lim_post_sme_message(mac_ctx,
1841 LIM_MLM_DEAUTH_CNF, (uint32_t *) &mlm_deauth_cnf);
1842}
1843
1844/*
1845 * lim_process_deauth_ack_timeout() - wrapper function around
1846 * lim_send_deauth_cnf
1847 *
1848 * @mac_ctx: mac_ctx
1849 *
1850 * wrapper function around lim_send_deauth_cnf
1851 *
1852 * Return: void
1853 */
1854void lim_process_deauth_ack_timeout(tpAniSirGlobal mac_ctx)
1855{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 lim_send_deauth_cnf(mac_ctx);
1857}
1858
1859/*
1860 * lim_process_mlm_deauth_req() - This function is called to process
1861 * MLM_DEAUTH_REQ message from SME
1862 *
1863 * @mac_ctx: Pointer to Global MAC structure
1864 * @msg_buf: A pointer to the MLM message buffer
1865 *
1866 * This function is called to process MLM_DEAUTH_REQ message from SME
1867 *
1868 * @Return: None
1869 */
1870static void
1871lim_process_mlm_deauth_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1872{
1873 tLimMlmDeauthReq *mlm_deauth_req;
1874 tpPESession session;
1875
1876 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001877 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 return;
1879 }
1880
1881 mlm_deauth_req = (tLimMlmDeauthReq *) msg_buf;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001882 pe_debug("Process Deauth Req on sessionID %d from: "
1883 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 mlm_deauth_req->sessionId,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001885 MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886
1887 session = pe_find_session_by_session_id(mac_ctx,
1888 mlm_deauth_req->sessionId);
1889 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001890 pe_err("session does not exist for given sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 mlm_deauth_req->sessionId);
1892 return;
1893 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301894 lim_process_mlm_deauth_req_ntf(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 (uint32_t *) msg_buf);
1896}
1897
1898/**
1899 * lim_process_mlm_set_keys_req() - This function is called to process
1900 * MLM_SETKEYS_REQ message from SME
1901 *
1902 * @mac_ctx: Pointer to Global MAC structure
1903 * @msg_buf: A pointer to the MLM message buffer
1904 *
1905 * This function is called to process MLM_SETKEYS_REQ message from SME
1906 *
1907 * @Return: None
1908 */
1909static void
1910lim_process_mlm_set_keys_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1911{
1912 uint16_t aid;
1913 uint16_t sta_idx = 0;
1914 uint32_t default_key_id = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301915 struct qdf_mac_addr curr_bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 tpDphHashNode sta_ds;
1917 tLimMlmSetKeysReq *mlm_set_keys_req;
1918 tLimMlmSetKeysCnf mlm_set_keys_cnf;
1919 tpPESession session;
1920
1921 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001922 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 return;
1924 }
1925
1926 mlm_set_keys_req = (tLimMlmSetKeysReq *) msg_buf;
1927 /* Hold onto the SetKeys request parameters */
1928 mac_ctx->lim.gpLimMlmSetKeysReq = (void *)mlm_set_keys_req;
1929 session = pe_find_session_by_session_id(mac_ctx,
1930 mlm_set_keys_req->sessionId);
1931 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001932 pe_err("session does not exist for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 return;
1934 }
1935
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001936 pe_debug("Received MLM_SETKEYS_REQ with parameters:"
1937 "AID [%d], ED Type [%d], # Keys [%d] & Peer MAC Addr - ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 mlm_set_keys_req->aid, mlm_set_keys_req->edType,
1939 mlm_set_keys_req->numKeys);
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07001940 lim_print_mac_addr(mac_ctx, mlm_set_keys_req->peer_macaddr.bytes, LOGD);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301941 qdf_mem_copy(curr_bssid.bytes, session->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942
1943 switch (GET_LIM_SYSTEM_ROLE(session)) {
1944 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 /*
1946 * In case of TDLS, peerMac address need not be BssId. Skip this
1947 * check if TDLS is enabled.
1948 */
1949#ifndef FEATURE_WLAN_TDLS
Anurag Chouhanc5548422016-02-24 18:33:27 +05301950 if ((!qdf_is_macaddr_broadcast(
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001951 &mlm_set_keys_req->peer_macaddr)) &&
Anurag Chouhanc5548422016-02-24 18:33:27 +05301952 (!qdf_is_macaddr_equal(&mlm_set_keys_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001953 &curr_bssid))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001954 pe_debug("Received MLM_SETKEYS_REQ with invalid BSSID"
1955 MAC_ADDRESS_STR,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001956 MAC_ADDR_ARRAY(mlm_set_keys_req->
1957 peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 /*
1959 * Prepare and Send LIM_MLM_SETKEYS_CNF with error code
1960 */
1961 mlm_set_keys_cnf.resultCode =
1962 eSIR_SME_INVALID_PARAMETERS;
1963 goto end;
1964 }
1965#endif
1966 break;
1967 case eLIM_STA_IN_IBSS_ROLE:
1968 /*
1969 * update the IBSS PE session encrption type based on the
1970 * key type
1971 */
1972 session->encryptType = mlm_set_keys_req->edType;
1973 break;
1974 default:
1975 break;
1976 }
1977
1978 /*
1979 * Use the "unicast" parameter to determine if the "Group Keys"
1980 * are being set.
1981 * mlm_set_keys_req->key.unicast = 0 -> Multicast/broadcast
1982 * mlm_set_keys_req->key.unicast - 1 -> Unicast keys are being set
1983 */
Anurag Chouhanc5548422016-02-24 18:33:27 +05301984 if (qdf_is_macaddr_broadcast(&mlm_set_keys_req->peer_macaddr)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001985 pe_debug("Trying to set Group Keys...%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 mlm_set_keys_req->sessionId);
1987 /*
1988 * When trying to set Group Keys for any security mode other
1989 * than WEP, use the STA Index corresponding to the AP...
1990 */
1991 switch (mlm_set_keys_req->edType) {
1992 case eSIR_ED_CCMP:
Mukul Sharma05504ac2017-06-08 12:35:53 +05301993 case eSIR_ED_GCMP:
1994 case eSIR_ED_GCMP_256:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995#ifdef WLAN_FEATURE_11W
1996 case eSIR_ED_AES_128_CMAC:
1997#endif
1998 sta_idx = session->staId;
1999 break;
2000 default:
2001 break;
2002 }
2003 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002004 pe_debug("Trying to set Unicast Keys...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005 /*
2006 * Check if there exists a context for the
2007 * peer entity for which keys need to be set.
2008 */
2009 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002010 mlm_set_keys_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 &session->dph.dphHashTable);
2012 if ((sta_ds == NULL) ||
2013 ((sta_ds->mlmStaContext.mlmState !=
2014 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
2015 !LIM_IS_AP_ROLE(session))) {
2016 /*
2017 * Received LIM_MLM_SETKEYS_REQ for STA that does not
2018 * have context or in some transit state.
2019 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002020 pe_debug("Invalid MLM_SETKEYS_REQ, Addr = "
2021 MAC_ADDRESS_STR,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002022 MAC_ADDR_ARRAY(mlm_set_keys_req->
2023 peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 /* Prepare and Send LIM_MLM_SETKEYS_CNF */
2025 mlm_set_keys_cnf.resultCode =
2026 eSIR_SME_INVALID_PARAMETERS;
2027 goto end;
2028 } else {
2029 sta_idx = sta_ds->staIndex;
2030 }
2031 }
2032
2033 if ((mlm_set_keys_req->numKeys == 0)
2034 && (mlm_set_keys_req->edType != eSIR_ED_NONE)) {
2035 /*
2036 * Broadcast/Multicast Keys (for WEP!!) are NOT sent
2037 * via this interface!! This indicates to HAL that the WEP Keys
2038 * need to be extracted from the CFG and applied to hardware
2039 */
2040 default_key_id = 0xff;
2041 } else if (mlm_set_keys_req->key[0].keyId &&
2042 ((mlm_set_keys_req->edType == eSIR_ED_WEP40) ||
2043 (mlm_set_keys_req->edType == eSIR_ED_WEP104))) {
2044 /*
2045 * If the Key Id is non zero and encryption mode is WEP,
2046 * the key index is coming from the upper layers so that key
2047 * only need to be used as the default tx key, This is being
2048 * used only in case of WEP mode in HAL
2049 */
2050 default_key_id = mlm_set_keys_req->key[0].keyId;
2051 } else {
2052 default_key_id = 0;
2053 }
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002054 pe_debug("Trying to set keys for STA Index [%d], using default_key_id [%d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055 sta_idx, default_key_id);
2056
Anurag Chouhanc5548422016-02-24 18:33:27 +05302057 if (qdf_is_macaddr_broadcast(&mlm_set_keys_req->peer_macaddr)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 session->limPrevMlmState = session->limMlmState;
2059 session->limMlmState = eLIM_MLM_WT_SET_BSS_KEY_STATE;
2060 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2061 session->peSessionId, session->limMlmState));
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002062 pe_debug("Trying to set Group Keys...%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 session->peSessionId);
2064 /* Package WMA_SET_BSSKEY_REQ message parameters */
2065 lim_send_set_bss_key_req(mac_ctx, mlm_set_keys_req, session);
2066 return;
2067 } else {
2068 /*
2069 * Package WMA_SET_STAKEY_REQ / WMA_SET_STA_BCASTKEY_REQ message
2070 * parameters
2071 */
2072 lim_send_set_sta_key_req(mac_ctx, mlm_set_keys_req, sta_idx,
2073 (uint8_t) default_key_id, session,
2074 true);
2075 return;
2076 }
2077end:
2078 mlm_set_keys_cnf.sessionId = mlm_set_keys_req->sessionId;
2079 lim_post_sme_set_keys_cnf(mac_ctx, mlm_set_keys_req, &mlm_set_keys_cnf);
2080}
2081
2082/**
2083 * lim_process_periodic_probe_req_timer() - This function is called to process
2084 * periodic probe request to send during scan.
2085 *
2086 * @mac_ctx: Pointer to Global MAC structure
2087 *
2088 * This function is called to process periodic probe request to send during scan
2089 *
2090 * @Return None
2091 */
2092static void lim_process_periodic_probe_req_timer(tpAniSirGlobal mac_ctx)
2093{
2094 uint8_t channel_num;
2095 uint8_t i = 0;
2096 tLimMlmScanReq *mlm_scan_req;
2097 tSirRetStatus status = eSIR_SUCCESS;
2098 TX_TIMER *probe_req_timer =
2099 &mac_ctx->lim.limTimers.gLimPeriodicProbeReqTimer;
2100
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302101 if (qdf_mc_timer_get_current_state(&probe_req_timer->qdf_timer)
Anurag Chouhan210db072016-02-22 18:42:15 +05302102 != QDF_TIMER_STATE_STOPPED) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002103 pe_debug("Invalid state of timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 return;
2105 }
2106
2107 if (!((mac_ctx->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE)
2108 && (probe_req_timer->sessionId != 0xff)
2109 && (mac_ctx->lim.probeCounter < mac_ctx->lim.maxProbe))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002110 pe_debug("received unexpected Periodic scan timeout in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111 mac_ctx->lim.gLimMlmState);
2112 return;
2113 }
2114
2115 mlm_scan_req = mac_ctx->lim.gpLimMlmScanReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116 mac_ctx->lim.probeCounter++;
2117 /* Periodic channel timer timed out to send probe request. */
2118 channel_num = lim_get_current_scan_channel(mac_ctx);
2119 do {
2120 /*
2121 * Prepare and send Probe Request frame for all the SSIDs
2122 * present in the saved MLM
2123 */
2124 status = lim_send_probe_req_mgmt_frame(mac_ctx,
2125 &mlm_scan_req->ssId[i], mlm_scan_req->bssId,
2126 channel_num, mac_ctx->lim.gSelfMacAddr,
2127 mlm_scan_req->dot11mode,
2128 mlm_scan_req->uIEFieldLen,
2129 (uint8_t *) (mlm_scan_req) +
2130 mlm_scan_req->uIEFieldOffset);
2131 if (status != eSIR_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002132 pe_err("send ProbeReq failed for SSID %s on channel: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 mlm_scan_req->ssId[i].ssId, channel_num);
2134 return;
2135 }
2136 i++;
2137 } while (i < mlm_scan_req->numSsid);
2138 /* Activate timer again */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 if (tx_timer_activate(probe_req_timer) != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002140 pe_warn("could not start periodic probe req timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 return;
2142 }
2143}
2144
2145/**
2146 * lim_process_join_failure_timeout() - This function is called to process
2147 * JoinFailureTimeout
2148 *
2149 * @mac_ctx: Pointer to Global MAC structure
2150 *
2151 * This function is called to process JoinFailureTimeout
2152 *
2153 * @Return None
2154 */
2155static void lim_process_join_failure_timeout(tpAniSirGlobal mac_ctx)
2156{
2157 tLimMlmJoinCnf mlm_join_cnf;
2158 uint32_t len;
2159#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2160 host_log_rssi_pkt_type *rssi_log = NULL;
2161#endif
2162 tpPESession session;
2163
2164 session = pe_find_session_by_session_id(mac_ctx,
2165 mac_ctx->lim.limTimers.gLimJoinFailureTimer.sessionId);
2166 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002167 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 return;
2169 }
2170#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2171 WLAN_HOST_DIAG_LOG_ALLOC(rssi_log,
2172 host_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
2173 if (rssi_log)
2174 rssi_log->rssi = session->rssi;
2175 WLAN_HOST_DIAG_LOG_REPORT(rssi_log);
2176#endif
2177
2178 if (session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE) {
2179 len = sizeof(tSirMacAddr);
2180 /* Change timer for future activations */
2181 lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER);
2182 /* Change Periodic probe req timer for future activation */
2183 lim_deactivate_and_change_timer(mac_ctx,
2184 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
2185 /* Issue MLM join confirm with timeout reason code */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002186 pe_err("Join Failure Timeout, In eLIM_MLM_WT_JOIN_BEACON_STATE session:%d "
2187 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 session->peSessionId, MAC_ADDR_ARRAY(session->bssId));
2189
2190 mlm_join_cnf.resultCode = eSIR_SME_JOIN_TIMEOUT_RESULT_CODE;
2191 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2192 session->limMlmState = eLIM_MLM_IDLE_STATE;
2193 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2194 session->peSessionId, session->limMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002195 /* Update PE session Id */
2196 mlm_join_cnf.sessionId = session->peSessionId;
2197 /* Freeup buffer allocated to join request */
2198 if (session->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302199 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 session->pLimMlmJoinReq = NULL;
2201 }
2202 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
2203 (uint32_t *) &mlm_join_cnf);
2204 return;
2205 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002206 pe_warn("received unexpected JOIN failure timeout in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207 session->limMlmState);
2208 lim_print_mlm_state(mac_ctx, LOGW, session->limMlmState);
2209 }
2210}
2211
2212/**
2213 * lim_process_periodic_join_probe_req_timer() - This function is called to
2214 * process periodic probe request send during joining process.
2215 *
2216 * @mac_ctx: Pointer to Global MAC structure
2217 *
2218 * This function is called to process periodic probe request send during
2219 * joining process.
2220 *
2221 * @Return None
2222 */
2223static void lim_process_periodic_join_probe_req_timer(tpAniSirGlobal mac_ctx)
2224{
2225 tpPESession session;
2226 tSirMacSSid ssid;
2227
2228 session = pe_find_session_by_session_id(mac_ctx,
2229 mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId);
2230 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002231 pe_err("session does not exist for given SessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer.
2233 sessionId);
2234 return;
2235 }
2236
2237 if ((true ==
2238 tx_timer_running(&mac_ctx->lim.limTimers.gLimJoinFailureTimer))
2239 && (session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302240 qdf_mem_copy(ssid.ssId, session->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 session->ssId.length);
2242 ssid.length = session->ssId.length;
2243 lim_send_probe_req_mgmt_frame(mac_ctx, &ssid,
2244 session->pLimMlmJoinReq->bssDescription.bssId,
2245 session->currentOperChannel /*chanNum */,
2246 session->selfMacAddr, session->dot11mode,
2247 session->pLimJoinReq->addIEScan.length,
2248 session->pLimJoinReq->addIEScan.addIEdata);
2249 lim_deactivate_and_change_timer(mac_ctx,
2250 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
2251 /* Activate Join Periodic Probe Req timer */
2252 if (tx_timer_activate(
2253 &mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer) !=
2254 TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002255 pe_warn("could not activate Periodic Join req failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256 return;
2257 }
2258 }
2259}
2260
2261/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302262 * lim_process_auth_retry_timer()- function to Retry Auth
2263 * @mac_ctx:pointer to global mac
2264 *
2265 * Return: void
2266 */
2267
2268static void lim_process_auth_retry_timer(tpAniSirGlobal mac_ctx)
2269{
2270 tpPESession session_entry;
2271
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302272 session_entry =
2273 pe_find_session_by_session_id(mac_ctx,
2274 mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer.sessionId);
2275 if (NULL == session_entry) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002276 pe_err("session does not exist for given SessionId: %d",
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302277 mac_ctx->lim.limTimers.
2278 g_lim_periodic_auth_retry_timer.sessionId);
2279 return;
2280 }
2281
2282 if (tx_timer_running(&mac_ctx->lim.limTimers.gLimAuthFailureTimer) &&
2283 (session_entry->limMlmState == eLIM_MLM_WT_AUTH_FRAME2_STATE) &&
2284 (LIM_AUTH_ACK_RCD_SUCCESS != mac_ctx->auth_ack_status)) {
2285 tSirMacAuthFrameBody auth_frame;
2286
2287 /*
2288 * Send the auth retry only in case we have received ack failure
2289 * else just restart the retry timer.
2290 */
2291 if (LIM_AUTH_ACK_RCD_FAILURE == mac_ctx->auth_ack_status) {
2292 /* Prepare & send Authentication frame */
2293 auth_frame.authAlgoNumber =
2294 (uint8_t) mac_ctx->lim.gpLimMlmAuthReq->authType;
2295 auth_frame.authTransactionSeqNumber =
2296 SIR_MAC_AUTH_FRAME_1;
2297 auth_frame.authStatusCode = 0;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002298 pe_warn("Retry Auth");
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302299 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302300 lim_increase_fils_sequence_number(session_entry);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302301 lim_send_auth_mgmt_frame(mac_ctx,
2302 &auth_frame,
2303 mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
2304 LIM_NO_WEP_IN_FC, session_entry, true);
2305 }
2306
2307 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2308
2309 /* Activate Auth Retry timer */
2310 if (tx_timer_activate
2311 (&mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer)
2312 != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002313 pe_err("could not activate Auth Retry failure timer");
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302314 return;
2315 }
2316 }
2317 return;
2318} /*** lim_process_auth_retry_timer() ***/
2319
2320/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 * lim_process_auth_failure_timeout() - This function is called to process Min
2322 * Channel Timeout during channel scan.
2323 *
2324 * @mac_ctx: Pointer to Global MAC structure
2325 *
2326 * This function is called to process Min Channel Timeout during channel scan.
2327 *
2328 * @Return: None
2329 */
2330static void lim_process_auth_failure_timeout(tpAniSirGlobal mac_ctx)
2331{
2332 /* fetch the sessionEntry based on the sessionId */
2333 tpPESession session;
2334#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2335 host_log_rssi_pkt_type *rssi_log = NULL;
2336#endif
2337
2338 session = pe_find_session_by_session_id(mac_ctx,
2339 mac_ctx->lim.limTimers.gLimAuthFailureTimer.sessionId);
2340 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002341 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 return;
2343 }
2344
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002345 pe_warn("received AUTH failure timeout in sessionid %d "
2346 "limMlmstate %X limSmeState %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 session->peSessionId, session->limMlmState,
2348 session->limSmeState);
2349#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Padma, Santhosh Kumare7835652016-08-10 19:11:40 +05302350 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_TIMEOUT, session,
2351 0, AUTH_FAILURE_TIMEOUT);
2352
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353 WLAN_HOST_DIAG_LOG_ALLOC(rssi_log, host_log_rssi_pkt_type,
2354 LOG_WLAN_RSSI_UPDATE_C);
2355 if (rssi_log)
2356 rssi_log->rssi = session->rssi;
2357 WLAN_HOST_DIAG_LOG_REPORT(rssi_log);
2358#endif
2359
2360 switch (session->limMlmState) {
2361 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
2362 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
2363 /*
2364 * Requesting STA did not receive next auth frame before Auth
2365 * Failure timeout. Issue MLM auth confirm with timeout reason
2366 * code. Restore default failure timeout
2367 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302368 if (QDF_P2P_CLIENT_MODE == session->pePersona
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369 && session->defaultAuthFailureTimeout)
2370 cfg_set_int(mac_ctx,
2371 WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
2372 session->defaultAuthFailureTimeout);
2373 lim_restore_from_auth_state(mac_ctx,
2374 eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,
2375 eSIR_MAC_UNSPEC_FAILURE_REASON, session);
2376 break;
2377 default:
2378 /*
2379 * Auth failure timer should not have timed out
2380 * in states other than wt_auth_frame2/4
2381 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002382 pe_err("received unexpected AUTH failure timeout in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 session->limMlmState);
2384 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
2385 break;
2386 }
2387}
2388
2389/**
2390 * lim_process_auth_rsp_timeout() - This function is called to process Min
2391 * Channel Timeout during channel scan.
2392 *
2393 * @mac_ctx: Pointer to Global MAC structure
2394 *
2395 * This function is called to process Min Channel Timeout during channel scan.
2396 *
2397 * @Return: None
2398 */
2399static void
2400lim_process_auth_rsp_timeout(tpAniSirGlobal mac_ctx, uint32_t auth_idx)
2401{
2402 struct tLimPreAuthNode *auth_node;
2403 tpPESession session;
2404 uint8_t session_id;
2405
2406 auth_node = lim_get_pre_auth_node_from_index(mac_ctx,
2407 &mac_ctx->lim.gLimPreAuthTimerTable, auth_idx);
2408 if (NULL == auth_node) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002409 pe_warn("Invalid auth node");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 return;
2411 }
2412
2413 session = pe_find_session_by_bssid(mac_ctx, auth_node->peerMacAddr,
2414 &session_id);
2415 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002416 pe_warn("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 return;
2418 }
2419
Padma, Santhosh Kumare7835652016-08-10 19:11:40 +05302420#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2421 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_TIMEOUT,
2422 session, 0, AUTH_RESPONSE_TIMEOUT);
2423#endif
2424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) {
2426 if (auth_node->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002427 pe_err("received AUTH rsp timeout in unexpected "
2428 "state for MAC address: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 MAC_ADDR_ARRAY(auth_node->peerMacAddr));
2430 } else {
2431 auth_node->mlmState = eLIM_MLM_AUTH_RSP_TIMEOUT_STATE;
2432 auth_node->fTimerStarted = 0;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002433 pe_debug("AUTH rsp timedout for MAC address "
2434 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 MAC_ADDR_ARRAY(auth_node->peerMacAddr));
2436 /* Change timer to reactivate it in future */
2437 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
2438 eLIM_AUTH_RSP_TIMER, auth_node->authNodeIdx);
2439 lim_delete_pre_auth_node(mac_ctx,
2440 auth_node->peerMacAddr);
2441 }
2442 }
2443}
2444
2445/**
2446 * lim_process_assoc_failure_timeout() - This function is called to process Min
2447 * Channel Timeout during channel scan.
2448 *
2449 * @mac_ctx Pointer to Global MAC structure
2450 *
2451 * This function is called to process Min Channel Timeout during channel scan.
2452 *
2453 * @Return: None
2454 */
2455static void
2456lim_process_assoc_failure_timeout(tpAniSirGlobal mac_ctx, uint32_t msg_type)
2457{
2458
2459 tLimMlmAssocCnf mlm_assoc_cnf;
2460 tpPESession session;
2461#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2462 host_log_rssi_pkt_type *rssi_log = NULL;
2463#endif
2464 /*
2465 * to fetch the lim/mlm state based on the session_id, use the
2466 * below sessionEntry
2467 */
2468 uint8_t session_id;
2469
2470 if (msg_type == LIM_ASSOC)
2471 session_id =
2472 mac_ctx->lim.limTimers.gLimAssocFailureTimer.sessionId;
2473 else
2474 session_id =
2475 mac_ctx->lim.limTimers.gLimReassocFailureTimer.sessionId;
2476
2477 session = pe_find_session_by_session_id(mac_ctx, session_id);
2478 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002479 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 return;
2481 }
2482#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Padma, Santhosh Kumare7835652016-08-10 19:11:40 +05302483 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_TIMEOUT,
2484 session, 0, 0);
2485
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 WLAN_HOST_DIAG_LOG_ALLOC(rssi_log,
2487 host_log_rssi_pkt_type,
2488 LOG_WLAN_RSSI_UPDATE_C);
2489 if (rssi_log)
2490 rssi_log->rssi = session->rssi;
2491 WLAN_HOST_DIAG_LOG_REPORT(rssi_log);
2492#endif
2493
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002494 pe_debug("Re/Association Response not received before timeout");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495
Abhishek Singhe36aa822016-04-27 16:55:43 +05302496 /*
2497 * Send Deauth to handle the scenareo where association timeout happened
2498 * when device has missed the assoc resp sent by peer.
2499 * By sending deauth try to clear the session created on peer device.
2500 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002501 pe_info("Sessionid: %d try sending deauth on channel %d to BSSID: "
2502 MAC_ADDRESS_STR, session->peSessionId,
Abhishek Singhe36aa822016-04-27 16:55:43 +05302503 session->currentOperChannel,
2504 MAC_ADDR_ARRAY(session->bssId));
2505 lim_send_deauth_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_REASON,
2506 session->bssId, session, false);
2507
Rajeev Kumaraa262c42016-04-15 15:41:08 -07002508 if ((LIM_IS_AP_ROLE(session)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 ((session->limMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) &&
2510 (session->limMlmState != eLIM_MLM_WT_REASSOC_RSP_STATE) &&
2511 (session->limMlmState != eLIM_MLM_WT_FT_REASSOC_RSP_STATE))) {
2512 /*
2513 * Re/Assoc failure timer should not have timedout on AP
2514 * or in a state other than wt_re/assoc_response.
2515 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002516 pe_warn("received unexpected REASSOC failure timeout in state %X for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 session->limMlmState,
2518 GET_LIM_SYSTEM_ROLE(session));
2519 lim_print_mlm_state(mac_ctx, LOGW, session->limMlmState);
2520 return;
2521 }
2522
2523 if ((msg_type == LIM_ASSOC) || ((msg_type == LIM_REASSOC)
2524 && (session->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002525 pe_err("(Re)Assoc Failure Timeout occurred");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526 session->limMlmState = eLIM_MLM_IDLE_STATE;
2527 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2528 session->peSessionId, session->limMlmState));
2529 /* Change timer for future activations */
2530 lim_deactivate_and_change_timer(mac_ctx, eLIM_ASSOC_FAIL_TIMER);
2531 /*
2532 * Free up buffer allocated for JoinReq held by
2533 * MLM state machine
2534 */
2535 if (session->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302536 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 session->pLimMlmJoinReq = NULL;
2538 }
2539 /* To remove the preauth node in case of fail to associate */
2540 if (lim_search_pre_auth_list(mac_ctx, session->bssId)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002541 pe_debug("delete pre auth node for "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 MAC_ADDR_ARRAY(session->bssId));
2543 lim_delete_pre_auth_node(mac_ctx,
2544 session->bssId);
2545 }
2546
2547 mlm_assoc_cnf.resultCode = eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE;
2548 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2549 /* Update PE session Id */
2550 mlm_assoc_cnf.sessionId = session->peSessionId;
2551 if (msg_type == LIM_ASSOC) {
2552 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2553 (uint32_t *) &mlm_assoc_cnf);
2554 } else {
2555 /*
2556 * Will come here only in case of 11r, Ese FT
2557 * when reassoc rsp is not received and we
2558 * receive a reassoc - timesout
2559 */
2560 mlm_assoc_cnf.resultCode =
2561 eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE;
2562 lim_post_sme_message(mac_ctx, LIM_MLM_REASSOC_CNF,
2563 (uint32_t *) &mlm_assoc_cnf);
2564 }
2565 } else {
2566 /*
2567 * Restore pre-reassoc req state.
2568 * Set BSSID to currently associated AP address.
2569 */
2570 session->limMlmState = session->limPrevMlmState;
2571 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2572 session->peSessionId, session->limMlmState));
2573 lim_restore_pre_reassoc_state(mac_ctx,
2574 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE,
2575 eSIR_MAC_UNSPEC_FAILURE_STATUS, session);
2576 }
2577}
2578
2579/**
2580 * lim_complete_mlm_scan() - This function is called to send MLM_SCAN_CNF
2581 * message to SME state machine.
2582 *
2583 * @mac_ctx: Pointer to Global MAC structure
2584 * @ret_code: Result code to be sent
2585 *
2586 * This function is called to send MLM_SCAN_CNF message to SME state machine.
2587 *
2588 * @Return: None
2589 */
2590
2591void lim_complete_mlm_scan(tpAniSirGlobal mac_ctx, tSirResultCodes ret_code)
2592{
2593 tLimMlmScanCnf mlm_scan_cnf;
2594
2595 /* Restore previous MLM state */
2596 mac_ctx->lim.gLimMlmState = mac_ctx->lim.gLimPrevMlmState;
2597 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, NO_SESSION,
2598 mac_ctx->lim.gLimMlmState));
2599 lim_restore_pre_scan_state(mac_ctx);
2600 /* Free up mac_ctx->lim.gLimMlmScanReq */
2601 if (NULL != mac_ctx->lim.gpLimMlmScanReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302602 qdf_mem_free(mac_ctx->lim.gpLimMlmScanReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 mac_ctx->lim.gpLimMlmScanReq = NULL;
2604 }
2605
2606 mlm_scan_cnf.resultCode = ret_code;
2607 lim_post_sme_message(mac_ctx, LIM_MLM_SCAN_CNF,
2608 (uint32_t *) &mlm_scan_cnf);
2609}
2610
2611/**
2612 * lim_set_channel() - set channel api for lim
2613 *
2614 * @mac_ctx: Pointer to Global MAC structure
2615 * @channel: power save state
2616 * @ch_center_freq_seg0: center freq seq 0
2617 * @ch_center_freq_seg1: center freq seq 1
2618 * @ch_width: channel width
2619 * @max_tx_power: max tx power
2620 * @pe_session_id: pe session id
2621 *
2622 * set channel api for lim
2623 *
2624 * @Return: None
2625 */
2626void lim_set_channel(tpAniSirGlobal mac_ctx, uint8_t channel,
2627 uint8_t ch_center_freq_seg0, uint8_t ch_center_freq_seg1,
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002628 enum phy_ch_width ch_width, int8_t max_tx_power,
Arif Hussain671a1902017-03-17 09:08:32 -07002629 uint8_t pe_session_id, uint32_t cac_duration_ms,
2630 uint32_t dfs_regdomain)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 tpPESession pe_session;
2633 pe_session = pe_find_session_by_session_id(mac_ctx, pe_session_id);
2634
2635 if (NULL == pe_session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002636 pe_err("Invalid PE session: %d", pe_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 return;
2638 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 lim_send_switch_chnl_params(mac_ctx, channel, ch_center_freq_seg0,
2640 ch_center_freq_seg1, ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07002641 max_tx_power, pe_session_id, false,
2642 cac_duration_ms, dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643}