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