blob: 2f39e45e1897d51dfd4f1d22eea714ce5e94088c [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050
51static void lim_process_mlm_start_req(tpAniSirGlobal, uint32_t *);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052static void lim_process_mlm_join_req(tpAniSirGlobal, uint32_t *);
53static void lim_process_mlm_auth_req(tpAniSirGlobal, uint32_t *);
54static void lim_process_mlm_assoc_req(tpAniSirGlobal, uint32_t *);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055static void lim_process_mlm_disassoc_req(tpAniSirGlobal, uint32_t *);
56static void lim_process_mlm_deauth_req(tpAniSirGlobal, uint32_t *);
57static void lim_process_mlm_set_keys_req(tpAniSirGlobal, uint32_t *);
58
59/* MLM Timeout event handler templates */
60static void lim_process_periodic_probe_req_timer(tpAniSirGlobal mac_ctx);
61static void lim_process_join_failure_timeout(tpAniSirGlobal);
62static void lim_process_auth_failure_timeout(tpAniSirGlobal);
63static void lim_process_auth_rsp_timeout(tpAniSirGlobal, uint32_t);
64static void lim_process_assoc_failure_timeout(tpAniSirGlobal, uint32_t);
65static void lim_process_periodic_join_probe_req_timer(tpAniSirGlobal);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +053066static void lim_process_auth_retry_timer(tpAniSirGlobal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
68/**
69 * lim_process_mlm_req_messages() - process mlm request messages
70 * @mac_ctx: global MAC context
71 * @msg: mlm request message
72 *
73 * This function is called by lim_post_mlm_message(). This
74 * function handles MLM primitives invoked by SME.
75 * Depending on the message type, corresponding function will be
76 * called.
77 * ASSUMPTIONS:
78 * 1. Upon receiving Beacon in WT_JOIN_STATE, MLM module invokes
79 * APIs exposed by Beacon Processing module for setting parameters
80 * at MAC hardware.
81 * 2. If attempt to Reassociate with an AP fails, link with current
82 * AP is restored back.
83 *
84 * Return: None
85 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -080086void lim_process_mlm_req_messages(tpAniSirGlobal mac_ctx,
87 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089 switch (msg->type) {
90 case LIM_MLM_START_REQ:
91 lim_process_mlm_start_req(mac_ctx, msg->bodyptr);
92 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093 case LIM_MLM_JOIN_REQ:
94 lim_process_mlm_join_req(mac_ctx, msg->bodyptr);
95 break;
96 case LIM_MLM_AUTH_REQ:
97 lim_process_mlm_auth_req(mac_ctx, msg->bodyptr);
98 break;
99 case LIM_MLM_ASSOC_REQ:
100 lim_process_mlm_assoc_req(mac_ctx, msg->bodyptr);
101 break;
102 case LIM_MLM_REASSOC_REQ:
103 lim_process_mlm_reassoc_req(mac_ctx, msg->bodyptr);
104 break;
105 case LIM_MLM_DISASSOC_REQ:
106 lim_process_mlm_disassoc_req(mac_ctx, msg->bodyptr);
107 break;
108 case LIM_MLM_DEAUTH_REQ:
109 lim_process_mlm_deauth_req(mac_ctx, msg->bodyptr);
110 break;
111 case LIM_MLM_SETKEYS_REQ:
112 lim_process_mlm_set_keys_req(mac_ctx, msg->bodyptr);
113 break;
114 case SIR_LIM_PERIODIC_PROBE_REQ_TIMEOUT:
115 lim_process_periodic_probe_req_timer(mac_ctx);
116 break;
117 case SIR_LIM_JOIN_FAIL_TIMEOUT:
118 lim_process_join_failure_timeout(mac_ctx);
119 break;
120 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
121 lim_process_periodic_join_probe_req_timer(mac_ctx);
122 break;
123 case SIR_LIM_AUTH_FAIL_TIMEOUT:
124 lim_process_auth_failure_timeout(mac_ctx);
125 break;
126 case SIR_LIM_AUTH_RSP_TIMEOUT:
127 lim_process_auth_rsp_timeout(mac_ctx, msg->bodyval);
128 break;
129 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
130 lim_process_assoc_failure_timeout(mac_ctx, msg->bodyval);
131 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800132 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:
133 lim_process_ft_preauth_rsp_timeout(mac_ctx);
134 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135 case SIR_LIM_REMAIN_CHN_TIMEOUT:
136 lim_process_remain_on_chn_timeout(mac_ctx);
137 break;
138 case SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT:
139 lim_process_insert_single_shot_noa_timeout(mac_ctx);
140 break;
141 case SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE:
142 lim_convert_active_channel_to_passive_channel(mac_ctx);
143 break;
144 case SIR_LIM_DISASSOC_ACK_TIMEOUT:
145 lim_process_disassoc_ack_timeout(mac_ctx);
146 break;
147 case SIR_LIM_DEAUTH_ACK_TIMEOUT:
148 lim_process_deauth_ack_timeout(mac_ctx);
149 break;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530150 case SIR_LIM_AUTH_RETRY_TIMEOUT:
151 lim_process_auth_retry_timer(mac_ctx);
152 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 case LIM_MLM_TSPEC_REQ:
154 default:
155 break;
156 } /* switch (msg->type) */
157}
158
159/* WLAN_SUSPEND_LINK Related */
160
161/**
162 * lim_is_link_suspended()- check if link is suspended
163 * @mac_ctx: global MAC context
164 *
165 * This function returns is link is suspended or not.
166 * Since Suspend link uses init scan, it just returns
167 * gLimSystemInScanLearnMode flag.
168 *
169 * Return: uint8_t(gLimSystemInScanLearnMode flag)
170 */
171uint8_t lim_is_link_suspended(tpAniSirGlobal mac_ctx)
172{
173 return mac_ctx->lim.gLimSystemInScanLearnMode;
174}
175
176/**
177 * lim_change_channel_with_callback() - change channel and register callback
178 * @mac_ctx: global MAC context
179 * @new_chan: new channel to switch
180 * @callback: Callback function
181 * @cbdata: callback data
182 * @session_entry: PE session pointer
183 *
184 * This function is called to change channel and perform off channel operation
185 * if required. The caller registers a callback to be called at the end of the
186 * channel change.
187 *
188 * Return: None
189 */
190void
191lim_change_channel_with_callback(tpAniSirGlobal mac_ctx, uint8_t new_chan,
192 CHANGE_CHANNEL_CALLBACK callback,
193 uint32_t *cbdata, tpPESession session_entry)
194{
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700195 pe_debug("Switching channel to %d", new_chan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196 session_entry->channelChangeReasonCode =
197 LIM_SWITCH_CHANNEL_OPERATION;
198
199 mac_ctx->lim.gpchangeChannelCallback = callback;
200 mac_ctx->lim.gpchangeChannelData = cbdata;
201
202 lim_send_switch_chnl_params(mac_ctx, new_chan, 0, 0,
203 CH_WIDTH_20MHZ, session_entry->maxTxPower,
Arif Hussain671a1902017-03-17 09:08:32 -0700204 session_entry->peSessionId, false, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205
206 return;
207}
208
209/**
210 * lim_covert_channel_scan_type() - switch between ACTIVE and PASSIVE scan type
211 * @mac_ctx: global MAC context
212 * @chan_num: channel number to change the scan type
213 * @passive_to_active: flag to indicate if switch allowed
214 *
215 * This function is called to get the list,
216 * change the channel type and set again.
217 * NOTE: If a channel is ACTIVE, this function will make it as PASSIVE
218 * If a channel is PASSIVE, this fucntion will make it as ACTIVE
219 *
220 * Return: None
221 */
222
223void lim_covert_channel_scan_type(tpAniSirGlobal mac_ctx, uint8_t chan_num,
224 bool passive_to_active)
225{
226
227 uint32_t i;
228 uint8_t chan_pair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
229 uint32_t len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
230 tSirRetStatus status;
231
232 status = wlan_cfg_get_str(mac_ctx, WNI_CFG_SCAN_CONTROL_LIST,
233 chan_pair, &len);
234 if (eSIR_SUCCESS != status) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700235 pe_err("Unable to get scan control list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 return;
237 }
238 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700239 pe_err("Invalid scan control list length: %d", len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 return;
241 }
242 for (i = 0; (i + 1) < len; i += 2) {
243 if (chan_pair[i] != chan_num) /* skip this channel */
244 continue;
245 if ((eSIR_PASSIVE_SCAN == chan_pair[i + 1]) &&
246 true == passive_to_active) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700247 pe_debug("Channel %d changed from Passive to Active",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 chan_num);
249 chan_pair[i + 1] = eSIR_ACTIVE_SCAN;
250 break;
251 }
252 if ((eSIR_ACTIVE_SCAN == chan_pair[i + 1]) &&
253 false == passive_to_active) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700254 pe_debug("Channel %d changed from Active to Passive",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 chan_num);
256 chan_pair[i + 1] = eSIR_PASSIVE_SCAN;
257 break;
258 }
259 }
260
261 cfg_set_str_notify(mac_ctx, WNI_CFG_SCAN_CONTROL_LIST,
262 (uint8_t *) chan_pair, len, false);
263 return;
264}
265
266/**
267 * lim_set_dfs_channel_list() - convert dfs channel list to active channel list
268 * @mac_ctx: global MAC context.
269 * @chan_num: channel number
270 * @dfs_ch_list: list of DFS channels
271 *
272 * This function is called to convert DFS channel list to active channel list
273 * when any beacon is present on that channel. This function store time for
274 * passive channels which help to know that for how much time channel has been
275 * passive.
276 *
277 * NOTE: If a channel is ACTIVE, it won't store any time
278 * If a channel is PAssive, it will store time as timestamp
279 *
280 * Return: None
281 */
282void lim_set_dfs_channel_list(tpAniSirGlobal mac_ctx, uint8_t chan_num,
283 tSirDFSChannelList *dfs_ch_list)
284{
285 bool pass_to_active = true;
286
287 if (!((1 <= chan_num) && (165 >= chan_num))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700288 pe_err("Invalid Channel: %d", chan_num);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289 return;
290 }
291
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700292 if (lim_isconnected_on_dfs_channel(mac_ctx, chan_num)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800293 if (dfs_ch_list->timeStamp[chan_num] == 0) {
294 /*
295 * Received first beacon;
296 * Convert DFS channel to Active channel.
297 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700298 pe_debug("Received first beacon on DFS channel: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 chan_num);
300 lim_covert_channel_scan_type(mac_ctx, chan_num,
301 pass_to_active);
302 }
303 dfs_ch_list->timeStamp[chan_num] =
Anurag Chouhan210db072016-02-22 18:42:15 +0530304 qdf_mc_timer_get_system_time();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 return;
307 }
308
309 if (!tx_timer_running
310 (&mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer)) {
311 tx_timer_activate(
312 &mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer);
313 }
314
315 return;
316}
317
318/**
319 * lim_restore_pre_scan_state() - restore HW state prior to scan
320 *
321 * @mac_ctx: global MAC context
322 *
323 * This function is called by lim_continue_channel_scan()
324 * to restore HW state prior to entering 'scan state'
325 *
326 * Return: None
327 */
328void lim_restore_pre_scan_state(tpAniSirGlobal mac_ctx)
329{
330 /* Deactivate MIN/MAX channel timers if running */
331 lim_deactivate_and_change_timer(mac_ctx, eLIM_MIN_CHANNEL_TIMER);
332 lim_deactivate_and_change_timer(mac_ctx, eLIM_MAX_CHANNEL_TIMER);
333
334 mac_ctx->lim.gLimSystemInScanLearnMode = 0;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700335 pe_debug("Scan ended, took %llu tu",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 (tx_time_get() - mac_ctx->lim.scanStartTime));
337}
338
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339/**
340 * mlm_add_sta() - MLM add sta
341 * @mac_ctx: global MAC context
342 * @sta_param: Add sta params
343 * @bssid: BSSID
344 * @ht_capable: HT capability
345 * @session_entry: PE session entry
346 *
347 * This function is called to update station parameters
348 *
349 * Return: None
350 */
351static void mlm_add_sta(tpAniSirGlobal mac_ctx, tpAddStaParams sta_param,
352 uint8_t *bssid, uint8_t ht_capable, tpPESession session_entry)
353{
354 uint32_t val;
355 uint32_t self_dot11mode = 0;
356
357 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_dot11mode);
358 sta_param->staType = STA_ENTRY_SELF; /* Identifying self */
359
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530360 qdf_mem_copy(sta_param->bssId, bssid, sizeof(tSirMacAddr));
361 qdf_mem_copy(sta_param->staMac, session_entry->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 sizeof(tSirMacAddr));
363
364 /* Configuration related parameters to be changed to support BT-AMP */
365
366 if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL,
367 &val))
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700368 pe_warn("Couldn't get LISTEN_INTERVAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 sta_param->listenInterval = (uint16_t) val;
370
371 if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx, WNI_CFG_SHORT_PREAMBLE,
372 &val))
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700373 pe_warn("Couldn't get SHORT_PREAMBLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374 sta_param->shortPreambleSupported = (uint8_t) val;
375
376 sta_param->assocId = 0; /* Is SMAC OK with this? */
377 sta_param->wmmEnabled = 0;
378 sta_param->uAPSD = 0;
379 sta_param->maxSPLen = 0;
380 sta_param->us32MaxAmpduDuration = 0;
381 sta_param->maxAmpduSize = 0; /* 0: 8k, 1: 16k,2: 32k,3: 64k, 4:128k */
382
383 /* For Self STA get the LDPC capability from config.ini */
384 sta_param->htLdpcCapable =
385 (session_entry->txLdpcIniFeatureEnabled & 0x01);
386 sta_param->vhtLdpcCapable =
387 ((session_entry->txLdpcIniFeatureEnabled >> 1) & 0x01);
388
389 if (IS_DOT11_MODE_HT(session_entry->dot11mode)) {
390 sta_param->htCapable = ht_capable;
391 sta_param->greenFieldCapable =
392 lim_get_ht_capability(mac_ctx, eHT_GREENFIELD,
393 session_entry);
394 sta_param->ch_width =
395 lim_get_ht_capability(mac_ctx,
396 eHT_SUPPORTED_CHANNEL_WIDTH_SET, session_entry);
397 sta_param->mimoPS =
398 (tSirMacHTMIMOPowerSaveState)lim_get_ht_capability(
399 mac_ctx, eHT_MIMO_POWER_SAVE, session_entry);
400 sta_param->rifsMode =
401 lim_get_ht_capability(mac_ctx, eHT_RIFS_MODE,
402 session_entry);
403 sta_param->lsigTxopProtection =
404 lim_get_ht_capability(mac_ctx, eHT_LSIG_TXOP_PROTECTION,
405 session_entry);
406 sta_param->maxAmpduDensity =
407 lim_get_ht_capability(mac_ctx, eHT_MPDU_DENSITY,
408 session_entry);
409 sta_param->maxAmsduSize =
410 lim_get_ht_capability(mac_ctx, eHT_MAX_AMSDU_LENGTH,
411 session_entry);
Deepak Dhamdhere612392c2016-08-28 02:56:51 -0700412 sta_param->max_amsdu_num =
413 lim_get_ht_capability(mac_ctx, eHT_MAX_AMSDU_NUM,
414 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 sta_param->fDsssCckMode40Mhz =
416 lim_get_ht_capability(mac_ctx, eHT_DSSS_CCK_MODE_40MHZ,
417 session_entry);
418 sta_param->fShortGI20Mhz =
419 lim_get_ht_capability(mac_ctx, eHT_SHORT_GI_20MHZ,
420 session_entry);
421 sta_param->fShortGI40Mhz =
422 lim_get_ht_capability(mac_ctx, eHT_SHORT_GI_40MHZ,
423 session_entry);
424 }
425 if (session_entry->vhtCapability) {
426 sta_param->vhtCapable = true;
427 sta_param->vhtTxBFCapable =
Krunal Soni53993f72016-07-08 18:20:03 -0700428 session_entry->vht_config.su_beam_formee;
429 sta_param->vhtTxMUBformeeCapable =
430 session_entry->vht_config.mu_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 sta_param->enable_su_tx_bformer =
Krunal Soni53993f72016-07-08 18:20:03 -0700432 session_entry->vht_config.su_beam_former;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800434
435 if (lim_is_session_he_capable(session_entry))
436 lim_add_self_he_cap(sta_param, session_entry);
437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800438 /*
439 * Since this is Self-STA, need to populate Self MAX_AMPDU_SIZE
440 * capabilities
441 */
442 if (IS_DOT11_MODE_VHT(self_dot11mode)) {
443 val = 0; /* Default 8K AMPDU size */
444 if (eSIR_SUCCESS != wlan_cfg_get_int(mac_ctx,
445 WNI_CFG_VHT_AMPDU_LEN_EXPONENT, &val))
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700446 pe_err("Couldn't get WNI_CFG_VHT_AMPDU_LEN_EXPONENT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447 sta_param->maxAmpduSize = (uint8_t) val;
448 }
449 sta_param->enableVhtpAid = session_entry->enableVhtpAid;
450 sta_param->enableAmpduPs = session_entry->enableAmpduPs;
451 sta_param->enableHtSmps = session_entry->enableHtSmps;
452 sta_param->htSmpsconfig = session_entry->htSmpsvalue;
Archana Ramachandranfec24812016-02-16 16:31:56 -0800453 sta_param->send_smps_action = session_entry->send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455 lim_populate_own_rate_set(mac_ctx, &sta_param->supportedRates, NULL,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -0700456 false, session_entry, NULL, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700458 pe_debug("GF: %d, ChnlWidth: %d, MimoPS: %d, lsigTXOP: %d, dsssCCK: %d,"
459 " SGI20: %d, SGI40%d", sta_param->greenFieldCapable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 sta_param->ch_width, sta_param->mimoPS,
461 sta_param->lsigTxopProtection, sta_param->fDsssCckMode40Mhz,
462 sta_param->fShortGI20Mhz, sta_param->fShortGI40Mhz);
463
Anurag Chouhan6d760662016-02-20 16:05:43 +0530464 if (QDF_P2P_GO_MODE == session_entry->pePersona)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 sta_param->p2pCapableSta = 1;
466}
467
468/**
469 * lim_mlm_add_bss() - HAL interface for WMA_ADD_BSS_REQ
470 * @mac_ctx: global MAC context
471 * @mlm_start_req: MLM start request
472 * @session: PE session entry
473 *
474 * Package WMA_ADD_BSS_REQ to HAL, in order to start a BSS
475 *
476 * Return: eSIR_SME_SUCCESS on success, other error codes otherwise
477 */
478tSirResultCodes
479lim_mlm_add_bss(tpAniSirGlobal mac_ctx,
480 tLimMlmStartReq *mlm_start_req, tpPESession session)
481{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700482 struct scheduler_msg msg_buf = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 tpAddBssParams addbss_param = NULL;
484 uint32_t retcode;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800485 bool is_ch_dfs = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486
487 /* Package WMA_ADD_BSS_REQ message parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530488 addbss_param = qdf_mem_malloc(sizeof(tAddBssParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489 if (NULL == addbss_param) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700490 pe_err("Unable to allocate memory during ADD_BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800491 /* Respond to SME with LIM_MLM_START_CNF */
Srinivas Girigowdad3b31e22017-06-28 00:15:10 -0700492 return eSIR_SME_RESOURCES_UNAVAILABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800493 }
494
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495 /* Fill in tAddBssParams members */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530496 qdf_mem_copy(addbss_param->bssId, mlm_start_req->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800497 sizeof(tSirMacAddr));
498
499 /* Fill in tAddBssParams selfMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530500 qdf_mem_copy(addbss_param->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800501 session->selfMacAddr, sizeof(tSirMacAddr));
502
503 addbss_param->bssType = mlm_start_req->bssType;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700504 if (mlm_start_req->bssType == eSIR_IBSS_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 addbss_param->operMode = BSS_OPERATIONAL_MODE_STA;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700506 else if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 addbss_param->operMode = BSS_OPERATIONAL_MODE_AP;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700508 else if (mlm_start_req->bssType == eSIR_NDI_MODE)
509 addbss_param->operMode = BSS_OPERATIONAL_MODE_NDI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510
511 addbss_param->shortSlotTimeSupported = session->shortSlotTimeSupported;
512 addbss_param->beaconInterval = mlm_start_req->beaconPeriod;
513 addbss_param->dtimPeriod = mlm_start_req->dtimPeriod;
514 addbss_param->wps_state = mlm_start_req->wps_state;
515 addbss_param->cfParamSet.cfpCount = mlm_start_req->cfParamSet.cfpCount;
516 addbss_param->cfParamSet.cfpPeriod =
517 mlm_start_req->cfParamSet.cfpPeriod;
518 addbss_param->cfParamSet.cfpMaxDuration =
519 mlm_start_req->cfParamSet.cfpMaxDuration;
520 addbss_param->cfParamSet.cfpDurRemaining =
521 mlm_start_req->cfParamSet.cfpDurRemaining;
522
523 addbss_param->rateSet.numRates = mlm_start_req->rateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530524 qdf_mem_copy(addbss_param->rateSet.rate, mlm_start_req->rateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 mlm_start_req->rateSet.numRates);
526
527 addbss_param->nwType = mlm_start_req->nwType;
528 addbss_param->htCapable = mlm_start_req->htCapable;
529 addbss_param->vhtCapable = session->vhtCapability;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800530 if (lim_is_session_he_capable(session)) {
531 lim_update_bss_he_capable(mac_ctx, addbss_param);
532 lim_decide_he_op(mac_ctx, addbss_param, session);
533 lim_update_usr_he_cap(mac_ctx, session);
534 }
535
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 addbss_param->ch_width = session->ch_width;
537 addbss_param->ch_center_freq_seg0 =
538 session->ch_center_freq_seg0;
539 addbss_param->ch_center_freq_seg1 =
540 session->ch_center_freq_seg1;
541 addbss_param->htOperMode = mlm_start_req->htOperMode;
542 addbss_param->dualCTSProtection = mlm_start_req->dualCTSProtection;
543 addbss_param->txChannelWidthSet = mlm_start_req->txChannelWidthSet;
544
545 addbss_param->currentOperChannel = mlm_start_req->channelNumber;
546#ifdef WLAN_FEATURE_11W
547 addbss_param->rmfEnabled = session->limRmfEnabled;
548#endif
549
550 /* Update PE sessionId */
551 addbss_param->sessionId = mlm_start_req->sessionId;
552
553 /* Send the SSID to HAL to enable SSID matching for IBSS */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530554 qdf_mem_copy(&(addbss_param->ssId.ssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800555 mlm_start_req->ssId.ssId, mlm_start_req->ssId.length);
556 addbss_param->ssId.length = mlm_start_req->ssId.length;
557 addbss_param->bHiddenSSIDEn = mlm_start_req->ssidHidden;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700558 pe_debug("TRYING TO HIDE SSID %d", addbss_param->bHiddenSSIDEn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800559 /* CR309183. Disable Proxy Probe Rsp. Host handles Probe Requests. Until FW fixed. */
560 addbss_param->bProxyProbeRespEn = 0;
561 addbss_param->obssProtEnabled = mlm_start_req->obssProtEnabled;
562
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563 addbss_param->maxTxPower = session->maxTxPower;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800564
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 mlm_add_sta(mac_ctx, &addbss_param->staContext,
566 addbss_param->bssId, addbss_param->htCapable,
567 session);
568
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530569 addbss_param->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 addbss_param->respReqd = 1;
571
572 /* Set a new state for MLME */
573 session->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_STATE;
574 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId,
575 session->limMlmState));
576
577 /* pass on the session persona to hal */
578 addbss_param->halPersona = session->pePersona;
579
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800580 if (session->ch_width == CH_WIDTH_160MHZ) {
581 is_ch_dfs = true;
582 } else if (session->ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700583 if (wlan_reg_get_channel_state(mac_ctx->pdev,
584 mlm_start_req->channelNumber) ==
585 CHANNEL_STATE_DFS ||
586 wlan_reg_get_channel_state(mac_ctx->pdev,
587 session->ch_center_freq_seg1 -
588 SIR_80MHZ_START_CENTER_CH_DIFF) ==
589 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800590 is_ch_dfs = true;
591 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700592 if (wlan_reg_get_channel_state(mac_ctx->pdev,
593 mlm_start_req->channelNumber) ==
594 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800595 is_ch_dfs = true;
596 }
597
598 addbss_param->bSpectrumMgtEnabled =
599 session->spectrumMgtEnabled || is_ch_dfs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 addbss_param->extSetStaKeyParamValid = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601
602 addbss_param->dot11_mode = session->dot11mode;
603 addbss_param->nss = session->nss;
Arif Hussain671a1902017-03-17 09:08:32 -0700604 addbss_param->cac_duration_ms = mlm_start_req->cac_duration_ms;
605 addbss_param->dfs_regdomain = mlm_start_req->dfs_regdomain;
Kiran Kumar Lokere6a7d1eb2016-05-02 18:31:35 -0700606 if (QDF_IBSS_MODE == addbss_param->halPersona) {
607 addbss_param->nss_2g = mac_ctx->vdev_type_nss_2g.ibss;
608 addbss_param->nss_5g = mac_ctx->vdev_type_nss_5g.ibss;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +0530609 addbss_param->tx_aggregation_size =
610 mac_ctx->roam.configParam.tx_aggregation_size;
611 addbss_param->rx_aggregation_size =
612 mac_ctx->roam.configParam.rx_aggregation_size;
Kiran Kumar Lokere6a7d1eb2016-05-02 18:31:35 -0700613 }
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700614 pe_debug("dot11_mode:%d nss value:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 addbss_param->dot11_mode, addbss_param->nss);
616
Naveen Rawat64e477e2016-05-20 10:34:56 -0700617 if (cds_is_5_mhz_enabled()) {
618 addbss_param->ch_width = CH_WIDTH_5MHZ;
619 addbss_param->staContext.ch_width = CH_WIDTH_5MHZ;
620 } else if (cds_is_10_mhz_enabled()) {
621 addbss_param->ch_width = CH_WIDTH_10MHZ;
622 addbss_param->staContext.ch_width = CH_WIDTH_10MHZ;
623 }
624
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 msg_buf.type = WMA_ADD_BSS_REQ;
626 msg_buf.reserved = 0;
627 msg_buf.bodyptr = addbss_param;
628 msg_buf.bodyval = 0;
629 MTRACE(mac_trace_msg_tx(mac_ctx, session->peSessionId, msg_buf.type));
630
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700631 pe_debug("Sending WMA_ADD_BSS_REQ...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 retcode = wma_post_ctrl_msg(mac_ctx, &msg_buf);
633 if (eSIR_SUCCESS != retcode) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700634 pe_err("Posting ADD_BSS_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 retcode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530636 qdf_mem_free(addbss_param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
638 }
639
640 return eSIR_SME_SUCCESS;
641}
642
643/**
644 * lim_process_mlm_start_req() - process MLM_START_REQ message
645 *
646 * @mac_ctx: global MAC context
647 * @msg_buf: Pointer to MLM message buffer
648 *
649 * This function is called to process MLM_START_REQ message
650 * from SME
651 * 1) MLME receives LIM_MLM_START_REQ from LIM
652 * 2) MLME sends WMA_ADD_BSS_REQ to HAL
653 * 3) MLME changes state to eLIM_MLM_WT_ADD_BSS_RSP_STATE
654 * MLME now waits for HAL to send WMA_ADD_BSS_RSP
655 *
656 * Return: None
657 */
658static void lim_process_mlm_start_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
659{
660 tLimMlmStartReq *mlm_start_req;
661 tLimMlmStartCnf mlm_start_cnf;
662 tpPESession session = NULL;
663
664 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700665 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666 return;
667 }
668
669 mlm_start_req = (tLimMlmStartReq *) msg_buf;
670 session = pe_find_session_by_session_id(mac_ctx,
671 mlm_start_req->sessionId);
672 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700673 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 mlm_start_cnf.resultCode = eSIR_SME_REFUSED;
675 goto end;
676 }
677
678 if (session->limMlmState != eLIM_MLM_IDLE_STATE) {
679 /*
680 * Should not have received Start req in states other than idle.
681 * Return Start confirm with failure code.
682 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700683 pe_err("received unexpected MLM_START_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 session->limMlmState);
685 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
686 mlm_start_cnf.resultCode =
687 eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
688 goto end;
689 }
690
691 mlm_start_cnf.resultCode =
692 lim_mlm_add_bss(mac_ctx, mlm_start_req, session);
693
694end:
695 /* Update PE session Id */
696 mlm_start_cnf.sessionId = mlm_start_req->sessionId;
697
698 /* Free up buffer allocated for LimMlmScanReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530699 qdf_mem_free(msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700
701 /*
702 * Respond immediately to LIM, only if MLME has not been
703 * successfully able to send WMA_ADD_BSS_REQ to HAL.
704 * Else, LIM_MLM_START_CNF will be sent after receiving
705 * WMA_ADD_BSS_RSP from HAL
706 */
707 if (eSIR_SME_SUCCESS != mlm_start_cnf.resultCode)
708 lim_post_sme_message(mac_ctx, LIM_MLM_START_CNF,
709 (uint32_t *) &mlm_start_cnf);
710}
711
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712/**
713 * lim_post_join_set_link_state_callback()- registered callback to perform post
714 * peer creation operations
715 *
716 * @mac: pointer to global mac structure
717 * @callback_arg: registered callback argument
718 * @status: peer creation status
719 *
720 * this is registered callback function during association to perform
721 * post peer creation operation based on the peer creation status
722 *
723 * Return: none
724 */
Jeff Johnson3a4d31e2016-10-07 07:25:04 -0700725static void lim_post_join_set_link_state_callback(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726 void *callback_arg, bool status)
727{
728 uint8_t chan_num, sec_chan_offset;
729 tpPESession session_entry = (tpPESession) callback_arg;
730 tLimMlmJoinCnf mlm_join_cnf;
731
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700732 pe_debug("Sessionid %d set link state(%d) cb status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 session_entry->peSessionId, session_entry->limMlmState,
734 status);
735
736 if (!status) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700737 pe_err("failed to find pe session for session id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 session_entry->peSessionId);
739 goto failure;
740 }
741
742 chan_num = session_entry->currentOperChannel;
743 sec_chan_offset = session_entry->htSecondaryChannelOffset;
744 /*
745 * store the channel switch session_entry in the lim
746 * global variable
747 */
748 session_entry->channelChangeReasonCode =
749 LIM_SWITCH_CHANNEL_JOIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 session_entry->pLimMlmReassocRetryReq = NULL;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700751 pe_debug("[lim_process_mlm_join_req]: suspend link success(%d) "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 "on sessionid: %d setting channel to: %d with ch_width :%d "
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700753 "and maxtxPower: %d", status, session_entry->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 session_entry->currentOperChannel,
755 session_entry->ch_width,
756 session_entry->maxTxPower);
757 lim_set_channel(mac, session_entry->currentOperChannel,
758 session_entry->ch_center_freq_seg0,
759 session_entry->ch_center_freq_seg1,
760 session_entry->ch_width,
761 session_entry->maxTxPower,
Arif Hussain671a1902017-03-17 09:08:32 -0700762 session_entry->peSessionId, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763 return;
764
765failure:
766 MTRACE(mac_trace(mac, TRACE_CODE_MLM_STATE, session_entry->peSessionId,
767 session_entry->limMlmState));
768 session_entry->limMlmState = eLIM_MLM_IDLE_STATE;
769 mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
770 mlm_join_cnf.sessionId = session_entry->peSessionId;
771 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
772 lim_post_sme_message(mac, LIM_MLM_JOIN_CNF, (uint32_t *) &mlm_join_cnf);
773}
774
775/**
776 * lim_process_mlm_post_join_suspend_link() - This function is called after the
777 * suspend link while joining off channel.
778 *
779 * @mac_ctx: Pointer to Global MAC structure
780 * @status: status of suspend link.
781 * @ctx: passed while calling suspend link(session)
782 *
783 * This function does following:
784 * Check for suspend state.
785 * If success, proceed with setting link state to recieve the
786 * probe response/beacon from intended AP.
787 * Switch to the APs channel.
788 * On an error case, send the MLM_JOIN_CNF with error status.
789 *
790 * @Return None
791 */
792static void
793lim_process_mlm_post_join_suspend_link(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530794 QDF_STATUS status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795 uint32_t *ctx)
796{
797 tLimMlmJoinCnf mlm_join_cnf;
798 tpPESession session = (tpPESession) ctx;
799 tSirLinkState lnk_state;
800
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530801 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700802 pe_err("Sessionid %d Suspend link(NOTIFY_BSS) failed. Still proceeding with join",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 session->peSessionId);
804 }
805 lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER);
806
807 /* assign appropriate sessionId to the timer object */
808 mac_ctx->lim.limTimers.gLimJoinFailureTimer.sessionId =
809 session->peSessionId;
810
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700811 lnk_state = eSIR_LINK_PREASSOC_STATE;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700812 pe_debug("[lim_process_mlm_join_req]: lnk_state: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 lnk_state);
814
815 if (lim_set_link_state(mac_ctx, lnk_state,
816 session->pLimMlmJoinReq->bssDescription.bssId,
817 session->selfMacAddr,
818 lim_post_join_set_link_state_callback,
819 session) != eSIR_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700820 pe_err("SessionId:%d lim_set_link_state to eSIR_LINK_PREASSOC_STATE Failed!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 session->peSessionId);
822 lim_print_mac_addr(mac_ctx,
823 session->pLimMlmJoinReq->bssDescription.bssId, LOGE);
824 mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
825 session->limMlmState = eLIM_MLM_IDLE_STATE;
826 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
827 session->peSessionId, session->limMlmState));
828 goto error;
829 }
830
831 return;
832error:
833 mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
834 mlm_join_cnf.sessionId = session->peSessionId;
835 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
836 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
837 (uint32_t *) &mlm_join_cnf);
838}
839
840/**
841 * lim_process_mlm_join_req() - process mlm join request.
842 *
843 * @mac_ctx: Pointer to Global MAC structure
844 * @msg: Pointer to the MLM message buffer
845 *
846 * This function is called to process MLM_JOIN_REQ message
847 * from SME. It does following:
848 * 1) Initialize LIM, HAL, DPH
849 * 2) Configure the BSS for which the JOIN REQ was received
850 * a) Send WMA_ADD_BSS_REQ to HAL -
851 * This will identify the BSS that we are interested in
852 * --AND--
853 * Add a STA entry for the AP (in a STA context)
854 * b) Wait for WMA_ADD_BSS_RSP
855 * c) Send WMA_ADD_STA_REQ to HAL
856 * This will add the "local STA" entry to the STA table
857 * 3) Continue as before, i.e,
858 * a) Send a PROBE REQ
859 * b) Wait for PROBE RSP/BEACON containing the SSID that
860 * we are interested in
861 * c) Then start an AUTH seq
862 * d) Followed by the ASSOC seq
863 *
864 * @Return: None
865 */
866static void lim_process_mlm_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg)
867{
868 tLimMlmJoinCnf mlmjoin_cnf;
869 uint8_t sessionid;
870 tpPESession session;
871
872 sessionid = ((tpLimMlmJoinReq) msg)->sessionId;
873
874 session = pe_find_session_by_session_id(mac_ctx, sessionid);
875 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700876 pe_err("SessionId:%d does not exist", sessionid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 goto error;
878 }
879
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700880 if (!LIM_IS_AP_ROLE(session) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 ((session->limMlmState == eLIM_MLM_IDLE_STATE) ||
882 (session->limMlmState == eLIM_MLM_JOINED_STATE)) &&
883 (SIR_MAC_GET_ESS
884 (((tpLimMlmJoinReq) msg)->bssDescription.capabilityInfo) !=
885 SIR_MAC_GET_IBSS(((tpLimMlmJoinReq) msg)->bssDescription.
886 capabilityInfo))) {
887 /* Hold onto Join request parameters */
888
889 session->pLimMlmJoinReq = (tpLimMlmJoinReq) msg;
890 if (is_lim_session_off_channel(mac_ctx, sessionid)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700891 pe_debug("SessionId:%d LimSession is on OffChannel",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 sessionid);
893 /* suspend link */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700894 pe_debug("Suspend link, sessionid %d is off channel",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 sessionid);
896 if (lim_is_link_suspended(mac_ctx)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700897 pe_err("link is already suspended, session %d",
898 sessionid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 goto error;
900 }
901 lim_process_mlm_post_join_suspend_link(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530902 QDF_STATUS_SUCCESS, (uint32_t *)session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700904 pe_debug("No need to Suspend link");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 /*
906 * No need to Suspend link as LimSession is not
907 * off channel, calling
908 * lim_process_mlm_post_join_suspend_link with
909 * status as SUCCESS.
910 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700911 pe_debug("SessionId:%d Join req on current chan",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 sessionid);
913 lim_process_mlm_post_join_suspend_link(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530914 QDF_STATUS_SUCCESS, (uint32_t *)session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 }
916 return;
917 } else {
918 /**
919 * Should not have received JOIN req in states other than
920 * Idle state or on AP.
921 * Return join confirm with invalid parameters code.
922 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700923 pe_err("Session:%d Unexpected Join req, role %d state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924 session->peSessionId, GET_LIM_SYSTEM_ROLE(session),
925 session->limMlmState);
926 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
927 }
928
929error:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530930 qdf_mem_free(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 if (session != NULL)
932 session->pLimMlmJoinReq = NULL;
933 mlmjoin_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
934 mlmjoin_cnf.sessionId = sessionid;
935 mlmjoin_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
936 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
937 (uint32_t *)&mlmjoin_cnf);
938
939}
940
941/**
942 * lim_is_auth_req_expected() - check if auth request is expected
943 *
944 * @mac_ctx: global MAC context
945 * @session: PE session entry
946 *
947 * This function is called by lim_process_mlm_auth_req to check
948 * if auth request is expected.
949 *
950 * Return: true if expected and false otherwise
951 */
952static bool lim_is_auth_req_expected(tpAniSirGlobal mac_ctx,
953 tpPESession session)
954{
955 bool flag = false;
956
957 /*
958 * Expect Auth request only when:
959 * 1. STA joined/associated with a BSS or
960 * 2. STA is in IBSS mode
961 * and STA is going to authenticate with a unicast
962 * address and requested authentication algorithm is
963 * supported.
964 */
965
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700966 flag = (((LIM_IS_STA_ROLE(session) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 ((session->limMlmState == eLIM_MLM_JOINED_STATE) ||
968 (session->limMlmState ==
969 eLIM_MLM_LINK_ESTABLISHED_STATE))) ||
970 (LIM_IS_IBSS_ROLE(session) &&
971 (session->limMlmState ==
972 eLIM_MLM_BSS_STARTED_STATE))) &&
973 (!lim_is_group_addr(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr))
974 && lim_is_auth_algo_supported(mac_ctx,
975 mac_ctx->lim.gpLimMlmAuthReq->authType, session));
976
977 return flag;
978}
979
980/**
981 * lim_is_preauth_ctx_exisits() - check if preauth context exists
982 *
983 * @mac_ctx: global MAC context
984 * @session: PE session entry
985 * @preauth_node_ptr: pointer to preauth node pointer
986 *
987 * This function is called by lim_process_mlm_auth_req to check
988 * if preauth context already exists
989 *
990 * Return: true if exists and false otherwise
991 */
992static bool lim_is_preauth_ctx_exists(tpAniSirGlobal mac_ctx,
993 tpPESession session,
994 struct tLimPreAuthNode **preauth_node_ptr)
995{
996 bool fl = false;
997 struct tLimPreAuthNode *preauth_node;
998 tpDphHashNode stads;
999 tSirMacAddr curr_bssid;
1000
1001 preauth_node = *preauth_node_ptr;
1002 sir_copy_mac_addr(curr_bssid, session->bssId);
1003 stads = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
1004 &session->dph.dphHashTable);
1005 preauth_node = lim_search_pre_auth_list(mac_ctx,
1006 mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr);
1007
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001008 fl = (((LIM_IS_STA_ROLE(session)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 (session->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE) &&
1010 ((stads != NULL) &&
1011 (mac_ctx->lim.gpLimMlmAuthReq->authType ==
1012 stads->mlmStaContext.authType)) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301013 (!qdf_mem_cmp(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 curr_bssid, sizeof(tSirMacAddr)))) ||
1015 ((preauth_node != NULL) &&
1016 (preauth_node->authType ==
1017 mac_ctx->lim.gpLimMlmAuthReq->authType)));
1018
1019 return fl;
1020}
1021
1022/**
1023 * lim_process_mlm_auth_req() - process lim auth request
1024 *
1025 * @mac_ctx: global MAC context
1026 * @msg: MLM auth request message
1027 *
1028 * This function is called to process MLM_AUTH_REQ message from SME
1029 *
1030 * @Return: None
1031 */
1032static void lim_process_mlm_auth_req(tpAniSirGlobal mac_ctx, uint32_t *msg)
1033{
1034 uint32_t num_preauth_ctx;
1035 tSirMacAddr curr_bssid;
1036 tSirMacAuthFrameBody auth_frame_body;
1037 tLimMlmAuthCnf mlm_auth_cnf;
1038 struct tLimPreAuthNode *preauth_node = NULL;
1039 uint8_t session_id;
1040 tpPESession session;
1041
1042 if (msg == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001043 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 return;
1045 }
1046
1047 mac_ctx->lim.gpLimMlmAuthReq = (tLimMlmAuthReq *) msg;
1048 session_id = mac_ctx->lim.gpLimMlmAuthReq->sessionId;
1049 session = pe_find_session_by_session_id(mac_ctx, session_id);
1050 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001051 pe_err("SessionId:%d does not exist", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 return;
1053 }
1054
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001055 pe_debug("Process Auth Req sessionID %d Systemrole %d"
1056 "mlmstate %d from: " MAC_ADDRESS_STR
1057 " with authtype %d", session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 GET_LIM_SYSTEM_ROLE(session), session->limMlmState,
1059 MAC_ADDR_ARRAY(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr),
1060 mac_ctx->lim.gpLimMlmAuthReq->authType);
1061
1062 sir_copy_mac_addr(curr_bssid, session->bssId);
1063
1064 if (!lim_is_auth_req_expected(mac_ctx, session)) {
1065 /*
1066 * Unexpected auth request.
1067 * Return Auth confirm with Invalid parameters code.
1068 */
1069 mlm_auth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1070 goto end;
1071 }
1072
1073 /*
1074 * This is a request for pre-authentication. Check if there exists
1075 * context already for the requested peer OR
1076 * if this request is for the AP we're currently associated with.
1077 * If yes, return auth confirm immediately when
1078 * requested auth type is same as the one used before.
1079 */
1080 if (lim_is_preauth_ctx_exists(mac_ctx, session, &preauth_node)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001081 pe_debug("Already have pre-auth context with peer: "
1082 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 MAC_ADDR_ARRAY(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr));
1084 mlm_auth_cnf.resultCode = (tSirResultCodes)
1085 eSIR_MAC_SUCCESS_STATUS;
1086 goto end;
1087 } else {
1088 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_MAX_NUM_PRE_AUTH,
1089 (uint32_t *) &num_preauth_ctx) != eSIR_SUCCESS)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001090 pe_warn("Could not retrieve NumPreAuthLimit from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091
1092 if (mac_ctx->lim.gLimNumPreAuthContexts == num_preauth_ctx) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001093 pe_warn("Number of pre-auth reached max limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 /* Return Auth confirm with reject code */
1095 mlm_auth_cnf.resultCode =
1096 eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED;
1097 goto end;
1098 }
1099 }
1100
1101 /* Delete pre-auth node if exists */
1102 if (preauth_node)
1103 lim_delete_pre_auth_node(mac_ctx,
1104 mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr);
1105
1106 session->limPrevMlmState = session->limMlmState;
1107 session->limMlmState = eLIM_MLM_WT_AUTH_FRAME2_STATE;
1108 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId,
1109 session->limMlmState));
1110
1111 /* Prepare & send Authentication frame */
1112 auth_frame_body.authAlgoNumber =
1113 (uint8_t) mac_ctx->lim.gpLimMlmAuthReq->authType;
1114 auth_frame_body.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
1115 auth_frame_body.authStatusCode = 0;
1116#ifdef FEATURE_WLAN_DIAG_SUPPORT
1117 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_START_EVENT, session,
1118 eSIR_SUCCESS, auth_frame_body.authStatusCode);
1119#endif
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301120 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 lim_send_auth_mgmt_frame(mac_ctx,
1122 &auth_frame_body, mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301123 LIM_NO_WEP_IN_FC, session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124
1125 /* assign appropriate session_id to the timer object */
1126 mac_ctx->lim.limTimers.gLimAuthFailureTimer.sessionId = session_id;
1127
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301128 /* assign appropriate sessionId to the timer object */
1129 mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer.sessionId =
1130 session_id;
1131 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132 /* Activate Auth failure timer */
1133 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1134 session->peSessionId, eLIM_AUTH_FAIL_TIMER));
1135 if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimAuthFailureTimer)
1136 != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001137 pe_err("could not start Auth failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 /* Cleanup as if auth timer expired */
1139 lim_process_auth_failure_timeout(mac_ctx);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301140 } else {
1141 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1142 session->peSessionId, eLIM_AUTH_RETRY_TIMER));
1143 /* Activate Auth Retry timer */
1144 if (tx_timer_activate
1145 (&mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer)
1146 != TX_SUCCESS)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001147 pe_err("could not activate Auth Retry timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148 }
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301149
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 return;
1151end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301152 qdf_mem_copy((uint8_t *) &mlm_auth_cnf.peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 (uint8_t *) &mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
1154 sizeof(tSirMacAddr));
1155
1156 mlm_auth_cnf.authType = mac_ctx->lim.gpLimMlmAuthReq->authType;
1157 mlm_auth_cnf.sessionId = session_id;
1158
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301159 qdf_mem_free(mac_ctx->lim.gpLimMlmAuthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 mac_ctx->lim.gpLimMlmAuthReq = NULL;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001161 pe_debug("SessionId:%d LimPostSme LIM_MLM_AUTH_CNF",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162 session_id);
1163 lim_post_sme_message(mac_ctx, LIM_MLM_AUTH_CNF,
1164 (uint32_t *) &mlm_auth_cnf);
1165}
1166
1167/**
1168 * lim_process_mlm_assoc_req() - This function is called to process
1169 * MLM_ASSOC_REQ message from SME
1170 *
1171 * @mac_ctx: Pointer to Global MAC structure
1172 * @msg_buf: A pointer to the MLM message buffer
1173 *
1174 * This function is called to process MLM_ASSOC_REQ message from SME
1175 *
1176 * @Return None
1177 */
1178
1179static void lim_process_mlm_assoc_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1180{
1181 tSirMacAddr curr_bssId;
1182 tLimMlmAssocReq *mlm_assoc_req;
1183 tLimMlmAssocCnf mlm_assoc_cnf;
1184 tpPESession session_entry;
1185
1186 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001187 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188 return;
1189 }
1190
1191 mlm_assoc_req = (tLimMlmAssocReq *) msg_buf;
1192 session_entry = pe_find_session_by_session_id(mac_ctx,
1193 mlm_assoc_req->sessionId);
1194 if (session_entry == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001195 pe_err("SessionId:%d Session Does not exist",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196 mlm_assoc_req->sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301197 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 return;
1199 }
1200
1201 sir_copy_mac_addr(curr_bssId, session_entry->bssId);
1202
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001203 if (!(!LIM_IS_AP_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 (session_entry->limMlmState == eLIM_MLM_AUTHENTICATED_STATE ||
1205 session_entry->limMlmState == eLIM_MLM_JOINED_STATE) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301206 (!qdf_mem_cmp(mlm_assoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207 curr_bssId, sizeof(tSirMacAddr))))) {
1208 /*
1209 * Received Association request either in invalid state
1210 * or to a peer MAC entity whose address is different
1211 * from one that STA is currently joined with or on AP.
1212 * Return Assoc confirm with Invalid parameters code.
1213 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001214 pe_warn("received unexpected MLM_ASSOC_CNF in state %X for role=%d, MAC addr= "
1215 MAC_ADDRESS_STR, session_entry->limMlmState,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 GET_LIM_SYSTEM_ROLE(session_entry),
1217 MAC_ADDR_ARRAY(mlm_assoc_req->peerMacAddr));
1218 lim_print_mlm_state(mac_ctx, LOGW, session_entry->limMlmState);
1219 mlm_assoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1220 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
1221 goto end;
1222 }
1223
1224 /* map the session entry pointer to the AssocFailureTimer */
1225 mac_ctx->lim.limTimers.gLimAssocFailureTimer.sessionId =
1226 mlm_assoc_req->sessionId;
1227#ifdef WLAN_FEATURE_11W
1228 /*
1229 * Store current MLM state in case ASSOC response returns with
1230 * TRY_AGAIN_LATER return code.
1231 */
1232 if (session_entry->limRmfEnabled) {
1233 session_entry->pmfComebackTimerInfo.limPrevMlmState =
1234 session_entry->limPrevMlmState;
1235 session_entry->pmfComebackTimerInfo.limMlmState =
1236 session_entry->limMlmState;
1237 }
1238#endif /* WLAN_FEATURE_11W */
1239
1240 session_entry->limPrevMlmState = session_entry->limMlmState;
1241 session_entry->limMlmState = eLIM_MLM_WT_ASSOC_RSP_STATE;
1242 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
1243 session_entry->peSessionId,
1244 session_entry->limMlmState));
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001245 pe_debug("SessionId:%d Sending Assoc_Req Frame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 session_entry->peSessionId);
1247
1248 /* Prepare and send Association request frame */
1249 lim_send_assoc_req_mgmt_frame(mac_ctx, mlm_assoc_req, session_entry);
1250
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 /* Start association failure timer */
1252 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1253 session_entry->peSessionId, eLIM_ASSOC_FAIL_TIMER));
1254 if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimAssocFailureTimer)
1255 != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001256 pe_warn("SessionId:%d couldn't start Assoc failure timer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257 session_entry->peSessionId);
1258 /* Cleanup as if assoc timer expired */
1259 lim_process_assoc_failure_timeout(mac_ctx, LIM_ASSOC);
1260 }
1261
1262 return;
1263end:
1264 /* Update PE session Id */
1265 mlm_assoc_cnf.sessionId = mlm_assoc_req->sessionId;
1266 /* Free up buffer allocated for assocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301267 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
1269 (uint32_t *) &mlm_assoc_cnf);
1270}
1271
1272/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273 * lim_process_mlm_disassoc_req_ntf() - process disassoc request notification
1274 *
1275 * @mac_ctx: global MAC context
1276 * @suspend_status: suspend status
1277 * @msg: mlm message buffer
1278 *
1279 * This function is used to process MLM disassoc notification
1280 *
1281 * Return: None
1282 */
1283static void
1284lim_process_mlm_disassoc_req_ntf(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301285 QDF_STATUS suspend_status, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286{
1287 uint16_t aid;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301288 struct qdf_mac_addr curr_bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 tpDphHashNode stads;
1290 tLimMlmDisassocReq *mlm_disassocreq;
1291 tLimMlmDisassocCnf mlm_disassoccnf;
1292 tpPESession session;
1293 extern bool send_disassoc_frame;
1294 tLimMlmStates mlm_state;
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301295 tSirSmeDisassocRsp *sme_disassoc_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301297 if (QDF_STATUS_SUCCESS != suspend_status)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001298 pe_err("Suspend Status is not success %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 suspend_status);
1300
1301 mlm_disassocreq = (tLimMlmDisassocReq *) msg;
1302
1303 session = pe_find_session_by_session_id(mac_ctx,
1304 mlm_disassocreq->sessionId);
1305 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001306 pe_err("session does not exist for given sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307 mlm_disassocreq->sessionId);
1308 mlm_disassoccnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1309 goto end;
1310 }
1311
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001312 pe_debug("Process DisAssoc Req on sessionID %d Systemrole %d"
1313 "mlmstate %d from: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 mlm_disassocreq->sessionId, GET_LIM_SYSTEM_ROLE(session),
1315 session->limMlmState,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001316 MAC_ADDR_ARRAY(mlm_disassocreq->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301318 qdf_mem_copy(curr_bssid.bytes, session->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319
1320 switch (GET_LIM_SYSTEM_ROLE(session)) {
1321 case eLIM_STA_ROLE:
Anurag Chouhanc5548422016-02-24 18:33:27 +05301322 if (!qdf_is_macaddr_equal(&mlm_disassocreq->peer_macaddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001323 &curr_bssid)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001324 pe_warn("received MLM_DISASSOC_REQ with invalid BSS id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 lim_print_mac_addr(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001326 mlm_disassocreq->peer_macaddr.bytes, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301328 /*
1329 * Disassociation response due to host triggered
1330 * disassociation
1331 */
1332 sme_disassoc_rsp =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301333 qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301334 if (NULL == sme_disassoc_rsp) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001335 pe_err("memory allocation failed for disassoc rsp");
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301336 return;
1337 }
1338
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001339 pe_debug("send disassoc rsp with ret code %d for" MAC_ADDRESS_STR,
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301340 eSIR_SME_DEAUTH_STATUS,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001341 MAC_ADDR_ARRAY(
1342 mlm_disassocreq->peer_macaddr.bytes));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301343
1344 sme_disassoc_rsp->messageType = eWNI_SME_DISASSOC_RSP;
1345 sme_disassoc_rsp->length = sizeof(tSirSmeDisassocRsp);
1346 sme_disassoc_rsp->sessionId =
1347 mlm_disassocreq->sessionId;
1348 sme_disassoc_rsp->transactionId = 0;
1349 sme_disassoc_rsp->statusCode = eSIR_SME_DEAUTH_STATUS;
1350
Anurag Chouhanc5548422016-02-24 18:33:27 +05301351 qdf_copy_macaddr(&sme_disassoc_rsp->peer_macaddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001352 &mlm_disassocreq->peer_macaddr);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301353 msg = (uint32_t *)sme_disassoc_rsp;
1354
1355 lim_send_sme_disassoc_deauth_ntf(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301356 QDF_STATUS_SUCCESS, msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301357 return;
1358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 }
1360 break;
1361 case eLIM_STA_IN_IBSS_ROLE:
1362 break;
1363 case eLIM_AP_ROLE:
1364 case eLIM_P2P_DEVICE_GO:
1365 if (true ==
1366 mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001367 pe_err("CAC timer is running, drop disassoc from going out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 mlm_disassoccnf.resultCode = eSIR_SME_SUCCESS;
1369 goto end;
1370 }
1371 break;
1372 default:
1373 break;
1374 } /* end switch (GET_LIM_SYSTEM_ROLE(session)) */
1375
1376 /*
1377 * Check if there exists a context for the peer entity
1378 * to be disassociated with.
1379 */
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001380 stads = dph_lookup_hash_entry(mac_ctx,
1381 mlm_disassocreq->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 &aid, &session->dph.dphHashTable);
1383 if (stads)
1384 mlm_state = stads->mlmStaContext.mlmState;
1385
1386 if ((stads == NULL) ||
1387 (stads &&
1388 ((mlm_state != eLIM_MLM_LINK_ESTABLISHED_STATE) &&
1389 (mlm_state != eLIM_MLM_WT_ASSOC_CNF_STATE) &&
1390 (mlm_state != eLIM_MLM_ASSOCIATED_STATE)))) {
1391 /*
1392 * Received LIM_MLM_DISASSOC_REQ for STA that does not
1393 * have context or in some transit state.
1394 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001395 pe_warn("Invalid MLM_DISASSOC_REQ, Addr= " MAC_ADDRESS_STR,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001396 MAC_ADDR_ARRAY(mlm_disassocreq->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 if (stads != NULL)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001398 pe_err("Sta MlmState: %d", stads->mlmStaContext.mlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399
1400 /* Prepare and Send LIM_MLM_DISASSOC_CNF */
1401 mlm_disassoccnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1402 goto end;
1403 }
1404
1405 stads->mlmStaContext.disassocReason = (tSirMacReasonCodes)
1406 mlm_disassocreq->reasonCode;
1407 stads->mlmStaContext.cleanupTrigger = mlm_disassocreq->disassocTrigger;
1408
1409 /*
1410 * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
1411 * This is to address the issue of race condition between
1412 * disconnect request from the HDD and deauth from AP
1413 */
1414
1415 stads->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
1416
1417 /* Send Disassociate frame to peer entity */
1418 if (send_disassoc_frame && (mlm_disassocreq->reasonCode !=
1419 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
1420 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq =
1421 mlm_disassocreq;
1422 /*
1423 * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
1424 * This is to address the issue of race condition between
1425 * disconnect request from the HDD and deauth from AP
1426 */
1427 stads->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
1428
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05301429 lim_send_disassoc_mgmt_frame(mac_ctx,
1430 mlm_disassocreq->reasonCode,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001431 mlm_disassocreq->peer_macaddr.bytes, session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 /*
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05301433 * Abort Tx so that data frames won't be sent to the AP
1434 * after sending Disassoc.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435 */
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05301436 if (LIM_IS_STA_ROLE(session))
1437 wma_tx_abort(session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 } else {
1439 /* Disassoc frame is not sent OTA */
1440 send_disassoc_frame = 1;
1441 /* Receive path cleanup with dummy packet */
1442 if (eSIR_SUCCESS !=
1443 lim_cleanup_rx_path(mac_ctx, stads, session)) {
1444 mlm_disassoccnf.resultCode =
1445 eSIR_SME_RESOURCES_UNAVAILABLE;
1446 goto end;
1447 }
1448 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301449 qdf_mem_free(mlm_disassocreq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450 }
1451
1452 return;
1453
1454end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301455 qdf_mem_copy((uint8_t *) &mlm_disassoccnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001456 (uint8_t *) mlm_disassocreq->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301457 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 mlm_disassoccnf.aid = mlm_disassocreq->aid;
1459 mlm_disassoccnf.disassocTrigger = mlm_disassocreq->disassocTrigger;
1460
1461 /* Update PE session ID */
1462 mlm_disassoccnf.sessionId = mlm_disassocreq->sessionId;
1463
1464 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301465 qdf_mem_free(mlm_disassocreq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466
1467 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
1468 (uint32_t *) &mlm_disassoccnf);
1469}
1470
1471/**
1472 * lim_check_disassoc_deauth_ack_pending() - check if deauth is pending
1473 *
1474 * @mac_ctx - global MAC context
1475 * @sta_mac - station MAC
1476 *
1477 * This function checks if diassociation or deauthentication is pending for
1478 * given station MAC address.
1479 *
1480 * Return: true if pending and false otherwise.
1481 */
1482bool lim_check_disassoc_deauth_ack_pending(tpAniSirGlobal mac_ctx,
1483 uint8_t *sta_mac)
1484{
1485 tLimMlmDisassocReq *disassoc_req;
1486 tLimMlmDeauthReq *deauth_req;
1487
1488 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
1489 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301490 if ((disassoc_req && (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001491 (uint8_t *) &disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301492 QDF_MAC_ADDR_SIZE))) ||
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301493 (deauth_req && (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001494 (uint8_t *) &deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301495 QDF_MAC_ADDR_SIZE)))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001496 pe_debug("Disassoc/Deauth ack pending");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497 return true;
1498 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001499 pe_debug("Disassoc/Deauth Ack not pending");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500 return false;
1501 }
1502}
1503
1504/*
1505 * lim_clean_up_disassoc_deauth_req() - cleans up pending disassoc or deauth req
1506 *
1507 * @mac_ctx: mac_ctx
1508 * @sta_mac: sta mac address
1509 * @clean_rx_path: flag to indicate whether to cleanup rx path or not
1510 *
1511 * This function cleans up pending disassoc or deauth req
1512 *
1513 * Return: void
1514 */
1515void lim_clean_up_disassoc_deauth_req(tpAniSirGlobal mac_ctx,
1516 uint8_t *sta_mac, bool clean_rx_path)
1517{
1518 tLimMlmDisassocReq *mlm_disassoc_req;
1519 tLimMlmDeauthReq *mlm_deauth_req;
1520 mlm_disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
1521 if (mlm_disassoc_req &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301522 (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001523 (uint8_t *) &mlm_disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301524 QDF_MAC_ADDR_SIZE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 if (clean_rx_path) {
1526 lim_process_disassoc_ack_timeout(mac_ctx);
1527 } else {
1528 if (tx_timer_running(
1529 &mac_ctx->lim.limTimers.gLimDisassocAckTimer)) {
1530 lim_deactivate_and_change_timer(mac_ctx,
1531 eLIM_DISASSOC_ACK_TIMER);
1532 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301533 qdf_mem_free(mlm_disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq =
1535 NULL;
1536 }
1537 }
1538
1539 mlm_deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
1540 if (mlm_deauth_req &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301541 (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001542 (uint8_t *) &mlm_deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301543 QDF_MAC_ADDR_SIZE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 if (clean_rx_path) {
1545 lim_process_deauth_ack_timeout(mac_ctx);
1546 } else {
1547 if (tx_timer_running(
1548 &mac_ctx->lim.limTimers.gLimDeauthAckTimer)) {
1549 lim_deactivate_and_change_timer(mac_ctx,
1550 eLIM_DEAUTH_ACK_TIMER);
1551 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301552 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq =
1554 NULL;
1555 }
1556 }
1557}
1558
1559/*
1560 * lim_process_disassoc_ack_timeout() - wrapper function around
1561 * lim_send_disassoc_cnf
1562 *
1563 * @mac_ctx: mac_ctx
1564 *
1565 * wrapper function around lim_send_disassoc_cnf
1566 *
1567 * Return: void
1568 */
1569void lim_process_disassoc_ack_timeout(tpAniSirGlobal mac_ctx)
1570{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 lim_send_disassoc_cnf(mac_ctx);
1572}
1573
1574/**
1575 * lim_process_mlm_disassoc_req() - This function is called to process
1576 * MLM_DISASSOC_REQ message from SME
1577 *
1578 * @mac_ctx: Pointer to Global MAC structure
1579 * @msg_buf: A pointer to the MLM message buffer
1580 *
1581 * This function is called to process MLM_DISASSOC_REQ message from SME
1582 *
1583 * @Return: None
1584 */
1585static void
1586lim_process_mlm_disassoc_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1587{
1588 tLimMlmDisassocReq *mlm_disassoc_req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589
1590 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001591 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 return;
1593 }
1594
1595 mlm_disassoc_req = (tLimMlmDisassocReq *) msg_buf;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001596 pe_debug("Process disassoc req, sessionID %d from: "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 mlm_disassoc_req->sessionId,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001598 MAC_ADDR_ARRAY(mlm_disassoc_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301600 lim_process_mlm_disassoc_req_ntf(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601 (uint32_t *) msg_buf);
1602}
1603
1604/**
1605 * lim_process_mlm_deauth_req_ntf() - This function is process mlm deauth req
1606 * notification
1607 *
1608 * @mac_ctx: Pointer to Global MAC structure
1609 * @suspend_status: suspend status
1610 * @msg_buf: A pointer to the MLM message buffer
1611 *
1612 * This function is process mlm deauth req notification
1613 *
1614 * @Return: None
1615 */
1616static void
1617lim_process_mlm_deauth_req_ntf(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301618 QDF_STATUS suspend_status, uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619{
1620 uint16_t aid;
1621 tSirMacAddr curr_bssId;
1622 tpDphHashNode sta_ds;
1623 struct tLimPreAuthNode *auth_node;
1624 tLimMlmDeauthReq *mlm_deauth_req;
1625 tLimMlmDeauthCnf mlm_deauth_cnf;
1626 tpPESession session;
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301627 tSirSmeDeauthRsp *sme_deauth_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301629 if (QDF_STATUS_SUCCESS != suspend_status)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001630 pe_err("Suspend Status is not success %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631 suspend_status);
1632
1633 mlm_deauth_req = (tLimMlmDeauthReq *) msg_buf;
1634 session = pe_find_session_by_session_id(mac_ctx,
1635 mlm_deauth_req->sessionId);
1636 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001637 pe_err("session does not exist for given sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 mlm_deauth_req->sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301639 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 return;
1641 }
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001642 pe_debug("Process Deauth Req on sessionID %d Systemrole %d"
1643 "mlmstate %d from: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 mlm_deauth_req->sessionId,
1645 GET_LIM_SYSTEM_ROLE(session),
1646 session->limMlmState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001647 MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 sir_copy_mac_addr(curr_bssId, session->bssId);
1649
1650 switch (GET_LIM_SYSTEM_ROLE(session)) {
1651 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 switch (session->limMlmState) {
1653 case eLIM_MLM_IDLE_STATE:
1654 /*
1655 * Attempting to Deauthenticate with a pre-authenticated
1656 * peer. Deauthetiate with peer if there exists a
1657 * pre-auth context below.
1658 */
1659 break;
1660 case eLIM_MLM_AUTHENTICATED_STATE:
1661 case eLIM_MLM_WT_ASSOC_RSP_STATE:
1662 case eLIM_MLM_LINK_ESTABLISHED_STATE:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301663 if (qdf_mem_cmp(mlm_deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301664 curr_bssId, QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001665 pe_err("received MLM_DEAUTH_REQ with invalid BSS id "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 "Peer MAC: "MAC_ADDRESS_STR
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001667 " CFG BSSID Addr : "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001668 MAC_ADDR_ARRAY(
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001669 mlm_deauth_req->peer_macaddr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 MAC_ADDR_ARRAY(curr_bssId));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301671 /*
1672 * Deauthentication response to host triggered
1673 * deauthentication
1674 */
1675 sme_deauth_rsp =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301676 qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301677 if (NULL == sme_deauth_rsp) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001678 pe_err("memory allocation failed for deauth rsp");
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301679 return;
1680 }
1681
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001682 pe_debug("send deauth rsp with ret code %d for" MAC_ADDRESS_STR,
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301683 eSIR_SME_DEAUTH_STATUS,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001684 MAC_ADDR_ARRAY(
1685 mlm_deauth_req->peer_macaddr.bytes));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301686
1687 sme_deauth_rsp->messageType =
1688 eWNI_SME_DEAUTH_RSP;
1689 sme_deauth_rsp->length =
1690 sizeof(tSirSmeDeauthRsp);
1691 sme_deauth_rsp->statusCode =
1692 eSIR_SME_DEAUTH_STATUS;
1693 sme_deauth_rsp->sessionId =
1694 mlm_deauth_req->sessionId;
1695 sme_deauth_rsp->transactionId = 0;
1696
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301697 qdf_mem_copy(sme_deauth_rsp->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001698 mlm_deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301699 QDF_MAC_ADDR_SIZE);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301700
1701 msg_buf = (uint32_t *)sme_deauth_rsp;
1702
1703 lim_send_sme_disassoc_deauth_ntf(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301704 QDF_STATUS_SUCCESS, msg_buf);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301705 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 }
1707
1708 if ((session->limMlmState ==
1709 eLIM_MLM_AUTHENTICATED_STATE) ||
1710 (session->limMlmState ==
1711 eLIM_MLM_WT_ASSOC_RSP_STATE)) {
1712 /* Send deauth frame to peer entity */
1713 lim_send_deauth_mgmt_frame(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001714 mlm_deauth_req->reasonCode,
1715 mlm_deauth_req->peer_macaddr.bytes,
1716 session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 /* Prepare and Send LIM_MLM_DEAUTH_CNF */
1718 mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS;
1719 session->limMlmState = eLIM_MLM_IDLE_STATE;
1720 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
1721 session->peSessionId,
1722 session->limMlmState));
1723 goto end;
1724 }
1725 break;
1726 default:
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001727 pe_warn("received MLM_DEAUTH_REQ with in state %d for peer "
1728 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729 session->limMlmState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001730 MAC_ADDR_ARRAY(
1731 mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 lim_print_mlm_state(mac_ctx, LOGW,
1733 session->limMlmState);
1734 /* Prepare and Send LIM_MLM_DEAUTH_CNF */
1735 mlm_deauth_cnf.resultCode =
1736 eSIR_SME_STA_NOT_AUTHENTICATED;
1737
1738 goto end;
1739 }
1740 break;
1741 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001742 pe_err("received MLM_DEAUTH_REQ IBSS Mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 mlm_deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1744 goto end;
1745 case eLIM_AP_ROLE:
1746 case eLIM_P2P_DEVICE_GO:
1747 if (true ==
1748 mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001749 pe_err("CAC timer is running, drop disassoc from going out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS;
1751 goto end;
1752 }
1753 break;
1754
1755 default:
1756 break;
1757 } /* end switch (GET_LIM_SYSTEM_ROLE(session)) */
1758
1759 /*
1760 * Check if there exists a context for the peer entity
1761 * to be deauthenticated with.
1762 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001763 sta_ds = dph_lookup_hash_entry(mac_ctx,
1764 mlm_deauth_req->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 &aid, &session->dph.dphHashTable);
1766
1767 if (sta_ds == NULL) {
1768 /* Check if there exists pre-auth context for this STA */
1769 auth_node = lim_search_pre_auth_list(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001770 mlm_deauth_req->peer_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 if (auth_node == NULL) {
1772 /*
1773 * Received DEAUTH REQ for a STA that is neither
1774 * Associated nor Pre-authenticated. Log error,
1775 * Prepare and Send LIM_MLM_DEAUTH_CNF
1776 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001777 pe_warn("received MLM_DEAUTH_REQ in mlme state %d for STA that "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 "does not have context, Addr="
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001779 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 session->limMlmState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001781 MAC_ADDR_ARRAY(
1782 mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 mlm_deauth_cnf.resultCode =
1784 eSIR_SME_STA_NOT_AUTHENTICATED;
1785 } else {
1786 mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS;
1787 /* Delete STA from pre-auth STA list */
1788 lim_delete_pre_auth_node(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001789 mlm_deauth_req->peer_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 /* Send Deauthentication frame to peer entity */
1791 lim_send_deauth_mgmt_frame(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001792 mlm_deauth_req->reasonCode,
1793 mlm_deauth_req->peer_macaddr.bytes,
1794 session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 }
1796 goto end;
1797 } else if ((sta_ds->mlmStaContext.mlmState !=
1798 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
1799 (sta_ds->mlmStaContext.mlmState !=
1800 eLIM_MLM_WT_ASSOC_CNF_STATE)) {
1801 /*
1802 * received MLM_DEAUTH_REQ for STA that either has no context or
1803 * in some transit state
1804 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001805 pe_warn("Invalid MLM_DEAUTH_REQ, Addr="MAC_ADDRESS_STR,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001806 MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 /* Prepare and Send LIM_MLM_DEAUTH_CNF */
1808 mlm_deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1809 goto end;
1810 }
1811 /* sta_ds->mlmStaContext.rxPurgeReq = 1; */
1812 sta_ds->mlmStaContext.disassocReason = (tSirMacReasonCodes)
1813 mlm_deauth_req->reasonCode;
1814 sta_ds->mlmStaContext.cleanupTrigger = mlm_deauth_req->deauthTrigger;
1815 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = mlm_deauth_req;
1816 /*
1817 * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
1818 * This is to address the issue of race condition between
1819 * disconnect request from the HDD and disassoc from
1820 * inactivity timer. This will make sure that we will not
1821 * process disassoc if deauth is in progress for the station
1822 * and thus mlmStaContext.cleanupTrigger will not be overwritten.
1823 */
1824 sta_ds->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
1825 /* Send Deauthentication frame to peer entity */
1826 lim_send_deauth_mgmt_frame(mac_ctx, mlm_deauth_req->reasonCode,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001827 mlm_deauth_req->peer_macaddr.bytes,
1828 session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 return;
1830end:
Anurag Chouhanc5548422016-02-24 18:33:27 +05301831 qdf_copy_macaddr(&mlm_deauth_cnf.peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001832 &mlm_deauth_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 mlm_deauth_cnf.deauthTrigger = mlm_deauth_req->deauthTrigger;
1834 mlm_deauth_cnf.aid = mlm_deauth_req->aid;
1835 mlm_deauth_cnf.sessionId = mlm_deauth_req->sessionId;
1836
1837 /* Free up buffer allocated for mlmDeauthReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301838 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 lim_post_sme_message(mac_ctx,
1840 LIM_MLM_DEAUTH_CNF, (uint32_t *) &mlm_deauth_cnf);
1841}
1842
1843/*
1844 * lim_process_deauth_ack_timeout() - wrapper function around
1845 * lim_send_deauth_cnf
1846 *
1847 * @mac_ctx: mac_ctx
1848 *
1849 * wrapper function around lim_send_deauth_cnf
1850 *
1851 * Return: void
1852 */
1853void lim_process_deauth_ack_timeout(tpAniSirGlobal mac_ctx)
1854{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 lim_send_deauth_cnf(mac_ctx);
1856}
1857
1858/*
1859 * lim_process_mlm_deauth_req() - This function is called to process
1860 * MLM_DEAUTH_REQ message from SME
1861 *
1862 * @mac_ctx: Pointer to Global MAC structure
1863 * @msg_buf: A pointer to the MLM message buffer
1864 *
1865 * This function is called to process MLM_DEAUTH_REQ message from SME
1866 *
1867 * @Return: None
1868 */
1869static void
1870lim_process_mlm_deauth_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1871{
1872 tLimMlmDeauthReq *mlm_deauth_req;
1873 tpPESession session;
1874
1875 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001876 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 return;
1878 }
1879
1880 mlm_deauth_req = (tLimMlmDeauthReq *) msg_buf;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001881 pe_debug("Process Deauth Req on sessionID %d from: "
1882 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 mlm_deauth_req->sessionId,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001884 MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885
1886 session = pe_find_session_by_session_id(mac_ctx,
1887 mlm_deauth_req->sessionId);
1888 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001889 pe_err("session does not exist for given sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 mlm_deauth_req->sessionId);
1891 return;
1892 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301893 lim_process_mlm_deauth_req_ntf(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 (uint32_t *) msg_buf);
1895}
1896
1897/**
1898 * lim_process_mlm_set_keys_req() - This function is called to process
1899 * MLM_SETKEYS_REQ message from SME
1900 *
1901 * @mac_ctx: Pointer to Global MAC structure
1902 * @msg_buf: A pointer to the MLM message buffer
1903 *
1904 * This function is called to process MLM_SETKEYS_REQ message from SME
1905 *
1906 * @Return: None
1907 */
1908static void
1909lim_process_mlm_set_keys_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1910{
1911 uint16_t aid;
1912 uint16_t sta_idx = 0;
1913 uint32_t default_key_id = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301914 struct qdf_mac_addr curr_bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 tpDphHashNode sta_ds;
1916 tLimMlmSetKeysReq *mlm_set_keys_req;
1917 tLimMlmSetKeysCnf mlm_set_keys_cnf;
1918 tpPESession session;
1919
1920 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001921 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 return;
1923 }
1924
1925 mlm_set_keys_req = (tLimMlmSetKeysReq *) msg_buf;
1926 /* Hold onto the SetKeys request parameters */
1927 mac_ctx->lim.gpLimMlmSetKeysReq = (void *)mlm_set_keys_req;
1928 session = pe_find_session_by_session_id(mac_ctx,
1929 mlm_set_keys_req->sessionId);
1930 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001931 pe_err("session does not exist for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932 return;
1933 }
1934
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001935 pe_debug("Received MLM_SETKEYS_REQ with parameters:"
1936 "AID [%d], ED Type [%d], # Keys [%d] & Peer MAC Addr - ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 mlm_set_keys_req->aid, mlm_set_keys_req->edType,
1938 mlm_set_keys_req->numKeys);
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07001939 lim_print_mac_addr(mac_ctx, mlm_set_keys_req->peer_macaddr.bytes, LOGD);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301940 qdf_mem_copy(curr_bssid.bytes, session->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941
1942 switch (GET_LIM_SYSTEM_ROLE(session)) {
1943 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 /*
1945 * In case of TDLS, peerMac address need not be BssId. Skip this
1946 * check if TDLS is enabled.
1947 */
1948#ifndef FEATURE_WLAN_TDLS
Anurag Chouhanc5548422016-02-24 18:33:27 +05301949 if ((!qdf_is_macaddr_broadcast(
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001950 &mlm_set_keys_req->peer_macaddr)) &&
Anurag Chouhanc5548422016-02-24 18:33:27 +05301951 (!qdf_is_macaddr_equal(&mlm_set_keys_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001952 &curr_bssid))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001953 pe_debug("Received MLM_SETKEYS_REQ with invalid BSSID"
1954 MAC_ADDRESS_STR,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001955 MAC_ADDR_ARRAY(mlm_set_keys_req->
1956 peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 /*
1958 * Prepare and Send LIM_MLM_SETKEYS_CNF with error code
1959 */
1960 mlm_set_keys_cnf.resultCode =
1961 eSIR_SME_INVALID_PARAMETERS;
1962 goto end;
1963 }
1964#endif
1965 break;
1966 case eLIM_STA_IN_IBSS_ROLE:
1967 /*
1968 * update the IBSS PE session encrption type based on the
1969 * key type
1970 */
1971 session->encryptType = mlm_set_keys_req->edType;
1972 break;
1973 default:
1974 break;
1975 }
1976
1977 /*
1978 * Use the "unicast" parameter to determine if the "Group Keys"
1979 * are being set.
1980 * mlm_set_keys_req->key.unicast = 0 -> Multicast/broadcast
1981 * mlm_set_keys_req->key.unicast - 1 -> Unicast keys are being set
1982 */
Anurag Chouhanc5548422016-02-24 18:33:27 +05301983 if (qdf_is_macaddr_broadcast(&mlm_set_keys_req->peer_macaddr)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001984 pe_debug("Trying to set Group Keys...%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 mlm_set_keys_req->sessionId);
1986 /*
1987 * When trying to set Group Keys for any security mode other
1988 * than WEP, use the STA Index corresponding to the AP...
1989 */
1990 switch (mlm_set_keys_req->edType) {
1991 case eSIR_ED_CCMP:
Mukul Sharma05504ac2017-06-08 12:35:53 +05301992 case eSIR_ED_GCMP:
1993 case eSIR_ED_GCMP_256:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994#ifdef WLAN_FEATURE_11W
1995 case eSIR_ED_AES_128_CMAC:
1996#endif
1997 sta_idx = session->staId;
1998 break;
1999 default:
2000 break;
2001 }
2002 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002003 pe_debug("Trying to set Unicast Keys...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 /*
2005 * Check if there exists a context for the
2006 * peer entity for which keys need to be set.
2007 */
2008 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002009 mlm_set_keys_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 &session->dph.dphHashTable);
2011 if ((sta_ds == NULL) ||
2012 ((sta_ds->mlmStaContext.mlmState !=
2013 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
2014 !LIM_IS_AP_ROLE(session))) {
2015 /*
2016 * Received LIM_MLM_SETKEYS_REQ for STA that does not
2017 * have context or in some transit state.
2018 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002019 pe_debug("Invalid MLM_SETKEYS_REQ, Addr = "
2020 MAC_ADDRESS_STR,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002021 MAC_ADDR_ARRAY(mlm_set_keys_req->
2022 peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 /* Prepare and Send LIM_MLM_SETKEYS_CNF */
2024 mlm_set_keys_cnf.resultCode =
2025 eSIR_SME_INVALID_PARAMETERS;
2026 goto end;
2027 } else {
2028 sta_idx = sta_ds->staIndex;
2029 }
2030 }
2031
2032 if ((mlm_set_keys_req->numKeys == 0)
2033 && (mlm_set_keys_req->edType != eSIR_ED_NONE)) {
2034 /*
2035 * Broadcast/Multicast Keys (for WEP!!) are NOT sent
2036 * via this interface!! This indicates to HAL that the WEP Keys
2037 * need to be extracted from the CFG and applied to hardware
2038 */
2039 default_key_id = 0xff;
2040 } else if (mlm_set_keys_req->key[0].keyId &&
2041 ((mlm_set_keys_req->edType == eSIR_ED_WEP40) ||
2042 (mlm_set_keys_req->edType == eSIR_ED_WEP104))) {
2043 /*
2044 * If the Key Id is non zero and encryption mode is WEP,
2045 * the key index is coming from the upper layers so that key
2046 * only need to be used as the default tx key, This is being
2047 * used only in case of WEP mode in HAL
2048 */
2049 default_key_id = mlm_set_keys_req->key[0].keyId;
2050 } else {
2051 default_key_id = 0;
2052 }
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002053 pe_debug("Trying to set keys for STA Index [%d], using default_key_id [%d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 sta_idx, default_key_id);
2055
Anurag Chouhanc5548422016-02-24 18:33:27 +05302056 if (qdf_is_macaddr_broadcast(&mlm_set_keys_req->peer_macaddr)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057 session->limPrevMlmState = session->limMlmState;
2058 session->limMlmState = eLIM_MLM_WT_SET_BSS_KEY_STATE;
2059 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2060 session->peSessionId, session->limMlmState));
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002061 pe_debug("Trying to set Group Keys...%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 session->peSessionId);
2063 /* Package WMA_SET_BSSKEY_REQ message parameters */
2064 lim_send_set_bss_key_req(mac_ctx, mlm_set_keys_req, session);
2065 return;
2066 } else {
2067 /*
2068 * Package WMA_SET_STAKEY_REQ / WMA_SET_STA_BCASTKEY_REQ message
2069 * parameters
2070 */
2071 lim_send_set_sta_key_req(mac_ctx, mlm_set_keys_req, sta_idx,
2072 (uint8_t) default_key_id, session,
2073 true);
2074 return;
2075 }
2076end:
2077 mlm_set_keys_cnf.sessionId = mlm_set_keys_req->sessionId;
2078 lim_post_sme_set_keys_cnf(mac_ctx, mlm_set_keys_req, &mlm_set_keys_cnf);
2079}
2080
2081/**
2082 * lim_process_periodic_probe_req_timer() - This function is called to process
2083 * periodic probe request to send during scan.
2084 *
2085 * @mac_ctx: Pointer to Global MAC structure
2086 *
2087 * This function is called to process periodic probe request to send during scan
2088 *
2089 * @Return None
2090 */
2091static void lim_process_periodic_probe_req_timer(tpAniSirGlobal mac_ctx)
2092{
2093 uint8_t channel_num;
2094 uint8_t i = 0;
2095 tLimMlmScanReq *mlm_scan_req;
2096 tSirRetStatus status = eSIR_SUCCESS;
2097 TX_TIMER *probe_req_timer =
2098 &mac_ctx->lim.limTimers.gLimPeriodicProbeReqTimer;
2099
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302100 if (qdf_mc_timer_get_current_state(&probe_req_timer->qdf_timer)
Anurag Chouhan210db072016-02-22 18:42:15 +05302101 != QDF_TIMER_STATE_STOPPED) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002102 pe_debug("Invalid state of timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 return;
2104 }
2105
2106 if (!((mac_ctx->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE)
2107 && (probe_req_timer->sessionId != 0xff)
2108 && (mac_ctx->lim.probeCounter < mac_ctx->lim.maxProbe))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002109 pe_debug("received unexpected Periodic scan timeout in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 mac_ctx->lim.gLimMlmState);
2111 return;
2112 }
2113
2114 mlm_scan_req = mac_ctx->lim.gpLimMlmScanReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 mac_ctx->lim.probeCounter++;
2116 /* Periodic channel timer timed out to send probe request. */
2117 channel_num = lim_get_current_scan_channel(mac_ctx);
2118 do {
2119 /*
2120 * Prepare and send Probe Request frame for all the SSIDs
2121 * present in the saved MLM
2122 */
2123 status = lim_send_probe_req_mgmt_frame(mac_ctx,
2124 &mlm_scan_req->ssId[i], mlm_scan_req->bssId,
2125 channel_num, mac_ctx->lim.gSelfMacAddr,
2126 mlm_scan_req->dot11mode,
2127 mlm_scan_req->uIEFieldLen,
2128 (uint8_t *) (mlm_scan_req) +
2129 mlm_scan_req->uIEFieldOffset);
2130 if (status != eSIR_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002131 pe_err("send ProbeReq failed for SSID %s on channel: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 mlm_scan_req->ssId[i].ssId, channel_num);
2133 return;
2134 }
2135 i++;
2136 } while (i < mlm_scan_req->numSsid);
2137 /* Activate timer again */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 if (tx_timer_activate(probe_req_timer) != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002139 pe_warn("could not start periodic probe req timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 return;
2141 }
2142}
2143
2144/**
2145 * lim_process_join_failure_timeout() - This function is called to process
2146 * JoinFailureTimeout
2147 *
2148 * @mac_ctx: Pointer to Global MAC structure
2149 *
2150 * This function is called to process JoinFailureTimeout
2151 *
2152 * @Return None
2153 */
2154static void lim_process_join_failure_timeout(tpAniSirGlobal mac_ctx)
2155{
2156 tLimMlmJoinCnf mlm_join_cnf;
2157 uint32_t len;
2158#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2159 host_log_rssi_pkt_type *rssi_log = NULL;
2160#endif
2161 tpPESession session;
2162
2163 session = pe_find_session_by_session_id(mac_ctx,
2164 mac_ctx->lim.limTimers.gLimJoinFailureTimer.sessionId);
2165 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002166 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 return;
2168 }
2169#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2170 WLAN_HOST_DIAG_LOG_ALLOC(rssi_log,
2171 host_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
2172 if (rssi_log)
2173 rssi_log->rssi = session->rssi;
2174 WLAN_HOST_DIAG_LOG_REPORT(rssi_log);
2175#endif
2176
2177 if (session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE) {
2178 len = sizeof(tSirMacAddr);
2179 /* Change timer for future activations */
2180 lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER);
2181 /* Change Periodic probe req timer for future activation */
2182 lim_deactivate_and_change_timer(mac_ctx,
2183 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
2184 /* Issue MLM join confirm with timeout reason code */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002185 pe_err("Join Failure Timeout, In eLIM_MLM_WT_JOIN_BEACON_STATE session:%d "
2186 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187 session->peSessionId, MAC_ADDR_ARRAY(session->bssId));
2188
2189 mlm_join_cnf.resultCode = eSIR_SME_JOIN_TIMEOUT_RESULT_CODE;
2190 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2191 session->limMlmState = eLIM_MLM_IDLE_STATE;
2192 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2193 session->peSessionId, session->limMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 /* Update PE session Id */
2195 mlm_join_cnf.sessionId = session->peSessionId;
2196 /* Freeup buffer allocated to join request */
2197 if (session->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302198 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 session->pLimMlmJoinReq = NULL;
2200 }
2201 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
2202 (uint32_t *) &mlm_join_cnf);
2203 return;
2204 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002205 pe_warn("received unexpected JOIN failure timeout in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 session->limMlmState);
2207 lim_print_mlm_state(mac_ctx, LOGW, session->limMlmState);
2208 }
2209}
2210
2211/**
2212 * lim_process_periodic_join_probe_req_timer() - This function is called to
2213 * process periodic probe request send during joining process.
2214 *
2215 * @mac_ctx: Pointer to Global MAC structure
2216 *
2217 * This function is called to process periodic probe request send during
2218 * joining process.
2219 *
2220 * @Return None
2221 */
2222static void lim_process_periodic_join_probe_req_timer(tpAniSirGlobal mac_ctx)
2223{
2224 tpPESession session;
2225 tSirMacSSid ssid;
2226
2227 session = pe_find_session_by_session_id(mac_ctx,
2228 mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId);
2229 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002230 pe_err("session does not exist for given SessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer.
2232 sessionId);
2233 return;
2234 }
2235
2236 if ((true ==
2237 tx_timer_running(&mac_ctx->lim.limTimers.gLimJoinFailureTimer))
2238 && (session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302239 qdf_mem_copy(ssid.ssId, session->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 session->ssId.length);
2241 ssid.length = session->ssId.length;
2242 lim_send_probe_req_mgmt_frame(mac_ctx, &ssid,
2243 session->pLimMlmJoinReq->bssDescription.bssId,
2244 session->currentOperChannel /*chanNum */,
2245 session->selfMacAddr, session->dot11mode,
2246 session->pLimJoinReq->addIEScan.length,
2247 session->pLimJoinReq->addIEScan.addIEdata);
2248 lim_deactivate_and_change_timer(mac_ctx,
2249 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
2250 /* Activate Join Periodic Probe Req timer */
2251 if (tx_timer_activate(
2252 &mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer) !=
2253 TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002254 pe_warn("could not activate Periodic Join req failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 return;
2256 }
2257 }
2258}
2259
2260/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302261 * lim_process_auth_retry_timer()- function to Retry Auth
2262 * @mac_ctx:pointer to global mac
2263 *
2264 * Return: void
2265 */
2266
2267static void lim_process_auth_retry_timer(tpAniSirGlobal mac_ctx)
2268{
2269 tpPESession session_entry;
2270
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302271 session_entry =
2272 pe_find_session_by_session_id(mac_ctx,
2273 mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer.sessionId);
2274 if (NULL == session_entry) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002275 pe_err("session does not exist for given SessionId: %d",
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302276 mac_ctx->lim.limTimers.
2277 g_lim_periodic_auth_retry_timer.sessionId);
2278 return;
2279 }
2280
2281 if (tx_timer_running(&mac_ctx->lim.limTimers.gLimAuthFailureTimer) &&
2282 (session_entry->limMlmState == eLIM_MLM_WT_AUTH_FRAME2_STATE) &&
2283 (LIM_AUTH_ACK_RCD_SUCCESS != mac_ctx->auth_ack_status)) {
2284 tSirMacAuthFrameBody auth_frame;
2285
2286 /*
2287 * Send the auth retry only in case we have received ack failure
2288 * else just restart the retry timer.
2289 */
2290 if (LIM_AUTH_ACK_RCD_FAILURE == mac_ctx->auth_ack_status) {
2291 /* Prepare & send Authentication frame */
2292 auth_frame.authAlgoNumber =
2293 (uint8_t) mac_ctx->lim.gpLimMlmAuthReq->authType;
2294 auth_frame.authTransactionSeqNumber =
2295 SIR_MAC_AUTH_FRAME_1;
2296 auth_frame.authStatusCode = 0;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002297 pe_warn("Retry Auth");
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302298 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
2299 lim_send_auth_mgmt_frame(mac_ctx,
2300 &auth_frame,
2301 mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
2302 LIM_NO_WEP_IN_FC, session_entry, true);
2303 }
2304
2305 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2306
2307 /* Activate Auth Retry timer */
2308 if (tx_timer_activate
2309 (&mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer)
2310 != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002311 pe_err("could not activate Auth Retry failure timer");
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302312 return;
2313 }
2314 }
2315 return;
2316} /*** lim_process_auth_retry_timer() ***/
2317
2318/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 * lim_process_auth_failure_timeout() - This function is called to process Min
2320 * Channel Timeout during channel scan.
2321 *
2322 * @mac_ctx: Pointer to Global MAC structure
2323 *
2324 * This function is called to process Min Channel Timeout during channel scan.
2325 *
2326 * @Return: None
2327 */
2328static void lim_process_auth_failure_timeout(tpAniSirGlobal mac_ctx)
2329{
2330 /* fetch the sessionEntry based on the sessionId */
2331 tpPESession session;
2332#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2333 host_log_rssi_pkt_type *rssi_log = NULL;
2334#endif
2335
2336 session = pe_find_session_by_session_id(mac_ctx,
2337 mac_ctx->lim.limTimers.gLimAuthFailureTimer.sessionId);
2338 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002339 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 return;
2341 }
2342
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002343 pe_warn("received AUTH failure timeout in sessionid %d "
2344 "limMlmstate %X limSmeState %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 session->peSessionId, session->limMlmState,
2346 session->limSmeState);
2347#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Padma, Santhosh Kumare7835652016-08-10 19:11:40 +05302348 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_TIMEOUT, session,
2349 0, AUTH_FAILURE_TIMEOUT);
2350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 WLAN_HOST_DIAG_LOG_ALLOC(rssi_log, host_log_rssi_pkt_type,
2352 LOG_WLAN_RSSI_UPDATE_C);
2353 if (rssi_log)
2354 rssi_log->rssi = session->rssi;
2355 WLAN_HOST_DIAG_LOG_REPORT(rssi_log);
2356#endif
2357
2358 switch (session->limMlmState) {
2359 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
2360 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
2361 /*
2362 * Requesting STA did not receive next auth frame before Auth
2363 * Failure timeout. Issue MLM auth confirm with timeout reason
2364 * code. Restore default failure timeout
2365 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302366 if (QDF_P2P_CLIENT_MODE == session->pePersona
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 && session->defaultAuthFailureTimeout)
2368 cfg_set_int(mac_ctx,
2369 WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
2370 session->defaultAuthFailureTimeout);
2371 lim_restore_from_auth_state(mac_ctx,
2372 eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,
2373 eSIR_MAC_UNSPEC_FAILURE_REASON, session);
2374 break;
2375 default:
2376 /*
2377 * Auth failure timer should not have timed out
2378 * in states other than wt_auth_frame2/4
2379 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002380 pe_err("received unexpected AUTH failure timeout in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 session->limMlmState);
2382 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
2383 break;
2384 }
2385}
2386
2387/**
2388 * lim_process_auth_rsp_timeout() - This function is called to process Min
2389 * Channel Timeout during channel scan.
2390 *
2391 * @mac_ctx: Pointer to Global MAC structure
2392 *
2393 * This function is called to process Min Channel Timeout during channel scan.
2394 *
2395 * @Return: None
2396 */
2397static void
2398lim_process_auth_rsp_timeout(tpAniSirGlobal mac_ctx, uint32_t auth_idx)
2399{
2400 struct tLimPreAuthNode *auth_node;
2401 tpPESession session;
2402 uint8_t session_id;
2403
2404 auth_node = lim_get_pre_auth_node_from_index(mac_ctx,
2405 &mac_ctx->lim.gLimPreAuthTimerTable, auth_idx);
2406 if (NULL == auth_node) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002407 pe_warn("Invalid auth node");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 return;
2409 }
2410
2411 session = pe_find_session_by_bssid(mac_ctx, auth_node->peerMacAddr,
2412 &session_id);
2413 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002414 pe_warn("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 return;
2416 }
2417
Padma, Santhosh Kumare7835652016-08-10 19:11:40 +05302418#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2419 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_TIMEOUT,
2420 session, 0, AUTH_RESPONSE_TIMEOUT);
2421#endif
2422
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) {
2424 if (auth_node->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002425 pe_err("received AUTH rsp timeout in unexpected "
2426 "state for MAC address: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 MAC_ADDR_ARRAY(auth_node->peerMacAddr));
2428 } else {
2429 auth_node->mlmState = eLIM_MLM_AUTH_RSP_TIMEOUT_STATE;
2430 auth_node->fTimerStarted = 0;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002431 pe_debug("AUTH rsp timedout for MAC address "
2432 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 MAC_ADDR_ARRAY(auth_node->peerMacAddr));
2434 /* Change timer to reactivate it in future */
2435 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
2436 eLIM_AUTH_RSP_TIMER, auth_node->authNodeIdx);
2437 lim_delete_pre_auth_node(mac_ctx,
2438 auth_node->peerMacAddr);
2439 }
2440 }
2441}
2442
2443/**
2444 * lim_process_assoc_failure_timeout() - This function is called to process Min
2445 * Channel Timeout during channel scan.
2446 *
2447 * @mac_ctx Pointer to Global MAC structure
2448 *
2449 * This function is called to process Min Channel Timeout during channel scan.
2450 *
2451 * @Return: None
2452 */
2453static void
2454lim_process_assoc_failure_timeout(tpAniSirGlobal mac_ctx, uint32_t msg_type)
2455{
2456
2457 tLimMlmAssocCnf mlm_assoc_cnf;
2458 tpPESession session;
2459#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2460 host_log_rssi_pkt_type *rssi_log = NULL;
2461#endif
2462 /*
2463 * to fetch the lim/mlm state based on the session_id, use the
2464 * below sessionEntry
2465 */
2466 uint8_t session_id;
2467
2468 if (msg_type == LIM_ASSOC)
2469 session_id =
2470 mac_ctx->lim.limTimers.gLimAssocFailureTimer.sessionId;
2471 else
2472 session_id =
2473 mac_ctx->lim.limTimers.gLimReassocFailureTimer.sessionId;
2474
2475 session = pe_find_session_by_session_id(mac_ctx, session_id);
2476 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002477 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 return;
2479 }
2480#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Padma, Santhosh Kumare7835652016-08-10 19:11:40 +05302481 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_TIMEOUT,
2482 session, 0, 0);
2483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484 WLAN_HOST_DIAG_LOG_ALLOC(rssi_log,
2485 host_log_rssi_pkt_type,
2486 LOG_WLAN_RSSI_UPDATE_C);
2487 if (rssi_log)
2488 rssi_log->rssi = session->rssi;
2489 WLAN_HOST_DIAG_LOG_REPORT(rssi_log);
2490#endif
2491
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002492 pe_debug("Re/Association Response not received before timeout");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493
Abhishek Singhe36aa822016-04-27 16:55:43 +05302494 /*
2495 * Send Deauth to handle the scenareo where association timeout happened
2496 * when device has missed the assoc resp sent by peer.
2497 * By sending deauth try to clear the session created on peer device.
2498 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002499 pe_info("Sessionid: %d try sending deauth on channel %d to BSSID: "
2500 MAC_ADDRESS_STR, session->peSessionId,
Abhishek Singhe36aa822016-04-27 16:55:43 +05302501 session->currentOperChannel,
2502 MAC_ADDR_ARRAY(session->bssId));
2503 lim_send_deauth_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_REASON,
2504 session->bssId, session, false);
2505
Rajeev Kumaraa262c42016-04-15 15:41:08 -07002506 if ((LIM_IS_AP_ROLE(session)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507 ((session->limMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) &&
2508 (session->limMlmState != eLIM_MLM_WT_REASSOC_RSP_STATE) &&
2509 (session->limMlmState != eLIM_MLM_WT_FT_REASSOC_RSP_STATE))) {
2510 /*
2511 * Re/Assoc failure timer should not have timedout on AP
2512 * or in a state other than wt_re/assoc_response.
2513 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002514 pe_warn("received unexpected REASSOC failure timeout in state %X for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 session->limMlmState,
2516 GET_LIM_SYSTEM_ROLE(session));
2517 lim_print_mlm_state(mac_ctx, LOGW, session->limMlmState);
2518 return;
2519 }
2520
2521 if ((msg_type == LIM_ASSOC) || ((msg_type == LIM_REASSOC)
2522 && (session->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002523 pe_err("(Re)Assoc Failure Timeout occurred");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524 session->limMlmState = eLIM_MLM_IDLE_STATE;
2525 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2526 session->peSessionId, session->limMlmState));
2527 /* Change timer for future activations */
2528 lim_deactivate_and_change_timer(mac_ctx, eLIM_ASSOC_FAIL_TIMER);
2529 /*
2530 * Free up buffer allocated for JoinReq held by
2531 * MLM state machine
2532 */
2533 if (session->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302534 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535 session->pLimMlmJoinReq = NULL;
2536 }
2537 /* To remove the preauth node in case of fail to associate */
2538 if (lim_search_pre_auth_list(mac_ctx, session->bssId)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002539 pe_debug("delete pre auth node for "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 MAC_ADDR_ARRAY(session->bssId));
2541 lim_delete_pre_auth_node(mac_ctx,
2542 session->bssId);
2543 }
2544
2545 mlm_assoc_cnf.resultCode = eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE;
2546 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2547 /* Update PE session Id */
2548 mlm_assoc_cnf.sessionId = session->peSessionId;
2549 if (msg_type == LIM_ASSOC) {
2550 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2551 (uint32_t *) &mlm_assoc_cnf);
2552 } else {
2553 /*
2554 * Will come here only in case of 11r, Ese FT
2555 * when reassoc rsp is not received and we
2556 * receive a reassoc - timesout
2557 */
2558 mlm_assoc_cnf.resultCode =
2559 eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE;
2560 lim_post_sme_message(mac_ctx, LIM_MLM_REASSOC_CNF,
2561 (uint32_t *) &mlm_assoc_cnf);
2562 }
2563 } else {
2564 /*
2565 * Restore pre-reassoc req state.
2566 * Set BSSID to currently associated AP address.
2567 */
2568 session->limMlmState = session->limPrevMlmState;
2569 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2570 session->peSessionId, session->limMlmState));
2571 lim_restore_pre_reassoc_state(mac_ctx,
2572 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE,
2573 eSIR_MAC_UNSPEC_FAILURE_STATUS, session);
2574 }
2575}
2576
2577/**
2578 * lim_complete_mlm_scan() - This function is called to send MLM_SCAN_CNF
2579 * message to SME state machine.
2580 *
2581 * @mac_ctx: Pointer to Global MAC structure
2582 * @ret_code: Result code to be sent
2583 *
2584 * This function is called to send MLM_SCAN_CNF message to SME state machine.
2585 *
2586 * @Return: None
2587 */
2588
2589void lim_complete_mlm_scan(tpAniSirGlobal mac_ctx, tSirResultCodes ret_code)
2590{
2591 tLimMlmScanCnf mlm_scan_cnf;
2592
2593 /* Restore previous MLM state */
2594 mac_ctx->lim.gLimMlmState = mac_ctx->lim.gLimPrevMlmState;
2595 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, NO_SESSION,
2596 mac_ctx->lim.gLimMlmState));
2597 lim_restore_pre_scan_state(mac_ctx);
2598 /* Free up mac_ctx->lim.gLimMlmScanReq */
2599 if (NULL != mac_ctx->lim.gpLimMlmScanReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302600 qdf_mem_free(mac_ctx->lim.gpLimMlmScanReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 mac_ctx->lim.gpLimMlmScanReq = NULL;
2602 }
2603
2604 mlm_scan_cnf.resultCode = ret_code;
2605 lim_post_sme_message(mac_ctx, LIM_MLM_SCAN_CNF,
2606 (uint32_t *) &mlm_scan_cnf);
2607}
2608
2609/**
2610 * lim_set_channel() - set channel api for lim
2611 *
2612 * @mac_ctx: Pointer to Global MAC structure
2613 * @channel: power save state
2614 * @ch_center_freq_seg0: center freq seq 0
2615 * @ch_center_freq_seg1: center freq seq 1
2616 * @ch_width: channel width
2617 * @max_tx_power: max tx power
2618 * @pe_session_id: pe session id
2619 *
2620 * set channel api for lim
2621 *
2622 * @Return: None
2623 */
2624void lim_set_channel(tpAniSirGlobal mac_ctx, uint8_t channel,
2625 uint8_t ch_center_freq_seg0, uint8_t ch_center_freq_seg1,
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002626 enum phy_ch_width ch_width, int8_t max_tx_power,
Arif Hussain671a1902017-03-17 09:08:32 -07002627 uint8_t pe_session_id, uint32_t cac_duration_ms,
2628 uint32_t dfs_regdomain)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 tpPESession pe_session;
2631 pe_session = pe_find_session_by_session_id(mac_ctx, pe_session_id);
2632
2633 if (NULL == pe_session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002634 pe_err("Invalid PE session: %d", pe_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 return;
2636 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 lim_send_switch_chnl_params(mac_ctx, channel, ch_center_freq_seg0,
2638 ch_center_freq_seg1, ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07002639 max_tx_power, pe_session_id, false,
2640 cac_duration_ms, dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641}