blob: 43eec84b6f0b8b3cc41c4d0a68e161a395af197f [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jingxiang Ge4168a232018-01-03 18:47:15 +08002 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019#include "cds_api.h"
20#include "wni_cfg.h"
21#include "ani_global.h"
22#include "sir_api.h"
23#include "sir_params.h"
24#include "cfg_api.h"
Arif Hussain43e09712018-09-18 19:31:57 -070025#include "cfg_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080026#include "sch_api.h"
27#include "utils_api.h"
28#include "lim_utils.h"
29#include "lim_assoc_utils.h"
30#include "lim_prop_exts_utils.h"
31#include "lim_security_utils.h"
32#include "lim_send_messages.h"
33#include "lim_send_messages.h"
34#include "lim_session_utils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080035#include <lim_ft.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
37#include "host_diag_core_log.h"
38#endif
39#include "wma_if.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070040#include "wlan_reg_services_api.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053041#include "lim_process_fils.h"
Pragaspathi Thilagaraj48d273c2018-08-31 00:53:02 +053042#include "wlan_mlme_public_struct.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043
Jeff Johnson9320c1e2018-12-02 13:09:20 -080044static void lim_process_mlm_auth_req(struct mac_context *, uint32_t *);
45static void lim_process_mlm_assoc_req(struct mac_context *, uint32_t *);
46static void lim_process_mlm_disassoc_req(struct mac_context *, uint32_t *);
47static void lim_process_mlm_set_keys_req(struct mac_context *, uint32_t *);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048
49/* MLM Timeout event handler templates */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080050static void lim_process_auth_rsp_timeout(struct mac_context *, uint32_t);
51static void lim_process_periodic_join_probe_req_timer(struct mac_context *);
52static void lim_process_auth_retry_timer(struct mac_context *);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053
54/**
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +053055 * lim_process_sae_auth_timeout() - This function is called to process sae
56 * auth timeout
57 * @mac_ctx: Pointer to Global MAC structure
58 *
59 * @Return: None
60 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080061static void lim_process_sae_auth_timeout(struct mac_context *mac_ctx)
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +053062{
Jeff Johnsona7071e62018-11-18 22:55:45 -080063 struct pe_session *session;
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +053064
65 session = pe_find_session_by_session_id(mac_ctx,
66 mac_ctx->lim.limTimers.sae_auth_timer.sessionId);
67 if (session == NULL) {
68 pe_err("Session does not exist for given session id");
69 return;
70 }
71
72 pe_warn("SAE auth timeout sessionid %d mlmstate %X SmeState %X",
73 session->peSessionId, session->limMlmState,
74 session->limSmeState);
75
76 switch (session->limMlmState) {
77 case eLIM_MLM_WT_SAE_AUTH_STATE:
78 /*
79 * SAE authentication is not completed. Restore from
80 * auth state.
81 */
82 if (session->pePersona == QDF_STA_MODE)
83 lim_restore_from_auth_state(mac_ctx,
84 eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,
85 eSIR_MAC_UNSPEC_FAILURE_REASON, session);
86 break;
87 default:
88 /* SAE authentication is timed out in unexpected state */
89 pe_err("received unexpected SAE auth timeout in state %X",
90 session->limMlmState);
91 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
92 break;
93 }
94}
95
96/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097 * lim_process_mlm_req_messages() - process mlm request messages
98 * @mac_ctx: global MAC context
99 * @msg: mlm request message
100 *
101 * This function is called by lim_post_mlm_message(). This
102 * function handles MLM primitives invoked by SME.
103 * Depending on the message type, corresponding function will be
104 * called.
105 * ASSUMPTIONS:
106 * 1. Upon receiving Beacon in WT_JOIN_STATE, MLM module invokes
107 * APIs exposed by Beacon Processing module for setting parameters
108 * at MAC hardware.
109 * 2. If attempt to Reassociate with an AP fails, link with current
110 * AP is restored back.
111 *
112 * Return: None
113 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800114void lim_process_mlm_req_messages(struct mac_context *mac_ctx,
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800115 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117 switch (msg->type) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118 case LIM_MLM_AUTH_REQ:
119 lim_process_mlm_auth_req(mac_ctx, msg->bodyptr);
120 break;
121 case LIM_MLM_ASSOC_REQ:
122 lim_process_mlm_assoc_req(mac_ctx, msg->bodyptr);
123 break;
124 case LIM_MLM_REASSOC_REQ:
125 lim_process_mlm_reassoc_req(mac_ctx, msg->bodyptr);
126 break;
127 case LIM_MLM_DISASSOC_REQ:
128 lim_process_mlm_disassoc_req(mac_ctx, msg->bodyptr);
129 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130 case LIM_MLM_SETKEYS_REQ:
131 lim_process_mlm_set_keys_req(mac_ctx, msg->bodyptr);
132 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 case SIR_LIM_JOIN_FAIL_TIMEOUT:
134 lim_process_join_failure_timeout(mac_ctx);
135 break;
136 case SIR_LIM_PERIODIC_JOIN_PROBE_REQ_TIMEOUT:
137 lim_process_periodic_join_probe_req_timer(mac_ctx);
138 break;
139 case SIR_LIM_AUTH_FAIL_TIMEOUT:
140 lim_process_auth_failure_timeout(mac_ctx);
141 break;
142 case SIR_LIM_AUTH_RSP_TIMEOUT:
143 lim_process_auth_rsp_timeout(mac_ctx, msg->bodyval);
144 break;
145 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
146 lim_process_assoc_failure_timeout(mac_ctx, msg->bodyval);
147 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:
149 lim_process_ft_preauth_rsp_timeout(mac_ctx);
150 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 case SIR_LIM_CONVERT_ACTIVE_CHANNEL_TO_PASSIVE:
152 lim_convert_active_channel_to_passive_channel(mac_ctx);
153 break;
154 case SIR_LIM_DISASSOC_ACK_TIMEOUT:
155 lim_process_disassoc_ack_timeout(mac_ctx);
156 break;
157 case SIR_LIM_DEAUTH_ACK_TIMEOUT:
158 lim_process_deauth_ack_timeout(mac_ctx);
159 break;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530160 case SIR_LIM_AUTH_RETRY_TIMEOUT:
161 lim_process_auth_retry_timer(mac_ctx);
162 break;
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +0530163 case SIR_LIM_AUTH_SAE_TIMEOUT:
164 lim_process_sae_auth_timeout(mac_ctx);
165 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 case LIM_MLM_TSPEC_REQ:
167 default:
168 break;
169 } /* switch (msg->type) */
170}
171
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173 * lim_covert_channel_scan_type() - switch between ACTIVE and PASSIVE scan type
174 * @mac_ctx: global MAC context
175 * @chan_num: channel number to change the scan type
176 * @passive_to_active: flag to indicate if switch allowed
177 *
178 * This function is called to get the list,
179 * change the channel type and set again.
180 * NOTE: If a channel is ACTIVE, this function will make it as PASSIVE
Jeff Johnson47d75242018-05-12 15:58:53 -0700181 * If a channel is PASSIVE, this function will make it as ACTIVE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 *
183 * Return: None
184 */
185
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800186void lim_covert_channel_scan_type(struct mac_context *mac_ctx, uint8_t chan_num,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 bool passive_to_active)
188{
189
190 uint32_t i;
191 uint8_t chan_pair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
192 uint32_t len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700193 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194
195 status = wlan_cfg_get_str(mac_ctx, WNI_CFG_SCAN_CONTROL_LIST,
196 chan_pair, &len);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700197 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700198 pe_err("Unable to get scan control list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 return;
200 }
201 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700202 pe_err("Invalid scan control list length: %d", len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 return;
204 }
205 for (i = 0; (i + 1) < len; i += 2) {
206 if (chan_pair[i] != chan_num) /* skip this channel */
207 continue;
208 if ((eSIR_PASSIVE_SCAN == chan_pair[i + 1]) &&
209 true == passive_to_active) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700210 pe_debug("Channel %d changed from Passive to Active",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211 chan_num);
212 chan_pair[i + 1] = eSIR_ACTIVE_SCAN;
213 break;
214 }
215 if ((eSIR_ACTIVE_SCAN == chan_pair[i + 1]) &&
216 false == passive_to_active) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700217 pe_debug("Channel %d changed from Active to Passive",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218 chan_num);
219 chan_pair[i + 1] = eSIR_PASSIVE_SCAN;
220 break;
221 }
222 }
223
224 cfg_set_str_notify(mac_ctx, WNI_CFG_SCAN_CONTROL_LIST,
225 (uint8_t *) chan_pair, len, false);
226 return;
227}
228
229/**
230 * lim_set_dfs_channel_list() - convert dfs channel list to active channel list
231 * @mac_ctx: global MAC context.
232 * @chan_num: channel number
233 * @dfs_ch_list: list of DFS channels
234 *
235 * This function is called to convert DFS channel list to active channel list
236 * when any beacon is present on that channel. This function store time for
237 * passive channels which help to know that for how much time channel has been
238 * passive.
239 *
240 * NOTE: If a channel is ACTIVE, it won't store any time
241 * If a channel is PAssive, it will store time as timestamp
242 *
243 * Return: None
244 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800245void lim_set_dfs_channel_list(struct mac_context *mac_ctx, uint8_t chan_num,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 tSirDFSChannelList *dfs_ch_list)
247{
248 bool pass_to_active = true;
249
250 if (!((1 <= chan_num) && (165 >= chan_num))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700251 pe_err("Invalid Channel: %d", chan_num);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 return;
253 }
254
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700255 if (lim_isconnected_on_dfs_channel(mac_ctx, chan_num)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 if (dfs_ch_list->timeStamp[chan_num] == 0) {
257 /*
258 * Received first beacon;
259 * Convert DFS channel to Active channel.
260 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700261 pe_debug("Received first beacon on DFS channel: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262 chan_num);
263 lim_covert_channel_scan_type(mac_ctx, chan_num,
264 pass_to_active);
265 }
266 dfs_ch_list->timeStamp[chan_num] =
Anurag Chouhan210db072016-02-22 18:42:15 +0530267 qdf_mc_timer_get_system_time();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269 return;
270 }
271
272 if (!tx_timer_running
273 (&mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer)) {
274 tx_timer_activate(
275 &mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer);
276 }
277
278 return;
279}
280
281/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282 * mlm_add_sta() - MLM add sta
283 * @mac_ctx: global MAC context
284 * @sta_param: Add sta params
285 * @bssid: BSSID
286 * @ht_capable: HT capability
287 * @session_entry: PE session entry
288 *
289 * This function is called to update station parameters
290 *
291 * Return: None
292 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800293static void mlm_add_sta(struct mac_context *mac_ctx, tpAddStaParams sta_param,
Jeff Johnsona7071e62018-11-18 22:55:45 -0800294 uint8_t *bssid, uint8_t ht_capable, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295{
296 uint32_t val;
297 uint32_t self_dot11mode = 0;
298
299 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_dot11mode);
300 sta_param->staType = STA_ENTRY_SELF; /* Identifying self */
301
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530302 qdf_mem_copy(sta_param->bssId, bssid, sizeof(tSirMacAddr));
303 qdf_mem_copy(sta_param->staMac, session_entry->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 sizeof(tSirMacAddr));
305
306 /* Configuration related parameters to be changed to support BT-AMP */
307
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530308 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309 sta_param->listenInterval = (uint16_t) val;
310
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +0530311 sta_param->shortPreambleSupported =
312 mac_ctx->mlme_cfg->ht_caps.short_preamble;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313
314 sta_param->assocId = 0; /* Is SMAC OK with this? */
315 sta_param->wmmEnabled = 0;
316 sta_param->uAPSD = 0;
317 sta_param->maxSPLen = 0;
318 sta_param->us32MaxAmpduDuration = 0;
319 sta_param->maxAmpduSize = 0; /* 0: 8k, 1: 16k,2: 32k,3: 64k, 4:128k */
320
321 /* For Self STA get the LDPC capability from config.ini */
322 sta_param->htLdpcCapable =
323 (session_entry->txLdpcIniFeatureEnabled & 0x01);
324 sta_param->vhtLdpcCapable =
325 ((session_entry->txLdpcIniFeatureEnabled >> 1) & 0x01);
326
327 if (IS_DOT11_MODE_HT(session_entry->dot11mode)) {
328 sta_param->htCapable = ht_capable;
329 sta_param->greenFieldCapable =
330 lim_get_ht_capability(mac_ctx, eHT_GREENFIELD,
331 session_entry);
332 sta_param->ch_width =
333 lim_get_ht_capability(mac_ctx,
334 eHT_SUPPORTED_CHANNEL_WIDTH_SET, session_entry);
335 sta_param->mimoPS =
336 (tSirMacHTMIMOPowerSaveState)lim_get_ht_capability(
337 mac_ctx, eHT_MIMO_POWER_SAVE, session_entry);
338 sta_param->rifsMode =
339 lim_get_ht_capability(mac_ctx, eHT_RIFS_MODE,
340 session_entry);
341 sta_param->lsigTxopProtection =
342 lim_get_ht_capability(mac_ctx, eHT_LSIG_TXOP_PROTECTION,
343 session_entry);
344 sta_param->maxAmpduDensity =
345 lim_get_ht_capability(mac_ctx, eHT_MPDU_DENSITY,
346 session_entry);
347 sta_param->maxAmsduSize =
348 lim_get_ht_capability(mac_ctx, eHT_MAX_AMSDU_LENGTH,
349 session_entry);
Deepak Dhamdhere612392c2016-08-28 02:56:51 -0700350 sta_param->max_amsdu_num =
351 lim_get_ht_capability(mac_ctx, eHT_MAX_AMSDU_NUM,
352 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 sta_param->fDsssCckMode40Mhz =
354 lim_get_ht_capability(mac_ctx, eHT_DSSS_CCK_MODE_40MHZ,
355 session_entry);
356 sta_param->fShortGI20Mhz =
357 lim_get_ht_capability(mac_ctx, eHT_SHORT_GI_20MHZ,
358 session_entry);
359 sta_param->fShortGI40Mhz =
360 lim_get_ht_capability(mac_ctx, eHT_SHORT_GI_40MHZ,
361 session_entry);
362 }
363 if (session_entry->vhtCapability) {
364 sta_param->vhtCapable = true;
365 sta_param->vhtTxBFCapable =
Krunal Soni53993f72016-07-08 18:20:03 -0700366 session_entry->vht_config.su_beam_formee;
367 sta_param->vhtTxMUBformeeCapable =
368 session_entry->vht_config.mu_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 sta_param->enable_su_tx_bformer =
Krunal Soni53993f72016-07-08 18:20:03 -0700370 session_entry->vht_config.su_beam_former;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800372
373 if (lim_is_session_he_capable(session_entry))
374 lim_add_self_he_cap(sta_param, session_entry);
375
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 /*
377 * Since this is Self-STA, need to populate Self MAX_AMPDU_SIZE
378 * capabilities
379 */
380 if (IS_DOT11_MODE_VHT(self_dot11mode)) {
Abhinav Kumarb074f2f2018-09-15 15:32:11 +0530381 sta_param->maxAmpduSize =
382 mac_ctx->mlme_cfg->vht_caps.vht_cap_info.ampdu_len_exponent;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 }
384 sta_param->enableVhtpAid = session_entry->enableVhtpAid;
385 sta_param->enableAmpduPs = session_entry->enableAmpduPs;
386 sta_param->enableHtSmps = session_entry->enableHtSmps;
387 sta_param->htSmpsconfig = session_entry->htSmpsvalue;
Archana Ramachandranfec24812016-02-16 16:31:56 -0800388 sta_param->send_smps_action = session_entry->send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 lim_populate_own_rate_set(mac_ctx, &sta_param->supportedRates, NULL,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -0700391 false, session_entry, NULL, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700393 pe_debug("GF: %d, ChnlWidth: %d, MimoPS: %d, lsigTXOP: %d, dsssCCK: %d,"
394 " SGI20: %d, SGI40%d", sta_param->greenFieldCapable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 sta_param->ch_width, sta_param->mimoPS,
396 sta_param->lsigTxopProtection, sta_param->fDsssCckMode40Mhz,
397 sta_param->fShortGI20Mhz, sta_param->fShortGI40Mhz);
398
Anurag Chouhan6d760662016-02-20 16:05:43 +0530399 if (QDF_P2P_GO_MODE == session_entry->pePersona)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400 sta_param->p2pCapableSta = 1;
401}
402
403/**
404 * lim_mlm_add_bss() - HAL interface for WMA_ADD_BSS_REQ
405 * @mac_ctx: global MAC context
406 * @mlm_start_req: MLM start request
407 * @session: PE session entry
408 *
409 * Package WMA_ADD_BSS_REQ to HAL, in order to start a BSS
410 *
411 * Return: eSIR_SME_SUCCESS on success, other error codes otherwise
412 */
413tSirResultCodes
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800414lim_mlm_add_bss(struct mac_context *mac_ctx,
Jeff Johnsona7071e62018-11-18 22:55:45 -0800415 tLimMlmStartReq *mlm_start_req, struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700417 struct scheduler_msg msg_buf = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 tpAddBssParams addbss_param = NULL;
Pragaspathi Thilagaraj48d273c2018-08-31 00:53:02 +0530419 struct wlan_mlme_qos *qos_aggr = &mac_ctx->mlme_cfg->qos_mlme_params;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420 uint32_t retcode;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800421 bool is_ch_dfs = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422
423 /* Package WMA_ADD_BSS_REQ message parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530424 addbss_param = qdf_mem_malloc(sizeof(tAddBssParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700425 if (!addbss_param)
Srinivas Girigowdad3b31e22017-06-28 00:15:10 -0700426 return eSIR_SME_RESOURCES_UNAVAILABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 /* Fill in tAddBssParams members */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530429 qdf_mem_copy(addbss_param->bssId, mlm_start_req->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 sizeof(tSirMacAddr));
431
432 /* Fill in tAddBssParams selfMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530433 qdf_mem_copy(addbss_param->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 session->selfMacAddr, sizeof(tSirMacAddr));
435
436 addbss_param->bssType = mlm_start_req->bssType;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700437 if (mlm_start_req->bssType == eSIR_IBSS_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800438 addbss_param->operMode = BSS_OPERATIONAL_MODE_STA;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700439 else if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 addbss_param->operMode = BSS_OPERATIONAL_MODE_AP;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700441 else if (mlm_start_req->bssType == eSIR_NDI_MODE)
442 addbss_param->operMode = BSS_OPERATIONAL_MODE_NDI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443
444 addbss_param->shortSlotTimeSupported = session->shortSlotTimeSupported;
445 addbss_param->beaconInterval = mlm_start_req->beaconPeriod;
446 addbss_param->dtimPeriod = mlm_start_req->dtimPeriod;
447 addbss_param->wps_state = mlm_start_req->wps_state;
448 addbss_param->cfParamSet.cfpCount = mlm_start_req->cfParamSet.cfpCount;
449 addbss_param->cfParamSet.cfpPeriod =
450 mlm_start_req->cfParamSet.cfpPeriod;
451 addbss_param->cfParamSet.cfpMaxDuration =
452 mlm_start_req->cfParamSet.cfpMaxDuration;
453 addbss_param->cfParamSet.cfpDurRemaining =
454 mlm_start_req->cfParamSet.cfpDurRemaining;
455
456 addbss_param->rateSet.numRates = mlm_start_req->rateSet.numRates;
Arif Hussaincb312922018-05-01 14:41:15 -0700457 if (addbss_param->rateSet.numRates > SIR_MAC_RATESET_EID_MAX) {
458 pe_warn("num of sup rates %d exceeding the limit %d, resetting",
459 addbss_param->rateSet.numRates,
460 SIR_MAC_RATESET_EID_MAX);
461 addbss_param->rateSet.numRates = SIR_MAC_RATESET_EID_MAX;
462 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530463 qdf_mem_copy(addbss_param->rateSet.rate, mlm_start_req->rateSet.rate,
Tushnim Bhattacharyya6deb27f2018-06-05 13:19:06 -0700464 addbss_param->rateSet.numRates);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465
466 addbss_param->nwType = mlm_start_req->nwType;
467 addbss_param->htCapable = mlm_start_req->htCapable;
468 addbss_param->vhtCapable = session->vhtCapability;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800469 if (lim_is_session_he_capable(session)) {
470 lim_update_bss_he_capable(mac_ctx, addbss_param);
471 lim_decide_he_op(mac_ctx, addbss_param, session);
472 lim_update_usr_he_cap(mac_ctx, session);
473 }
474
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 addbss_param->ch_width = session->ch_width;
476 addbss_param->ch_center_freq_seg0 =
477 session->ch_center_freq_seg0;
478 addbss_param->ch_center_freq_seg1 =
479 session->ch_center_freq_seg1;
480 addbss_param->htOperMode = mlm_start_req->htOperMode;
481 addbss_param->dualCTSProtection = mlm_start_req->dualCTSProtection;
482 addbss_param->txChannelWidthSet = mlm_start_req->txChannelWidthSet;
483
484 addbss_param->currentOperChannel = mlm_start_req->channelNumber;
485#ifdef WLAN_FEATURE_11W
486 addbss_param->rmfEnabled = session->limRmfEnabled;
487#endif
488
489 /* Update PE sessionId */
490 addbss_param->sessionId = mlm_start_req->sessionId;
491
492 /* Send the SSID to HAL to enable SSID matching for IBSS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800493 addbss_param->ssId.length = mlm_start_req->ssId.length;
Arif Hussaincb312922018-05-01 14:41:15 -0700494 if (addbss_param->ssId.length > SIR_MAC_MAX_SSID_LENGTH) {
495 pe_err("Invalid ssid length %d, max length allowed %d",
496 addbss_param->ssId.length,
497 SIR_MAC_MAX_SSID_LENGTH);
498 qdf_mem_free(addbss_param);
499 return eSIR_SME_INVALID_PARAMETERS;
500 }
501 qdf_mem_copy(addbss_param->ssId.ssId,
502 mlm_start_req->ssId.ssId, addbss_param->ssId.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 addbss_param->bHiddenSSIDEn = mlm_start_req->ssidHidden;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700504 pe_debug("TRYING TO HIDE SSID %d", addbss_param->bHiddenSSIDEn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 /* CR309183. Disable Proxy Probe Rsp. Host handles Probe Requests. Until FW fixed. */
506 addbss_param->bProxyProbeRespEn = 0;
507 addbss_param->obssProtEnabled = mlm_start_req->obssProtEnabled;
508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 addbss_param->maxTxPower = session->maxTxPower;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800510
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 mlm_add_sta(mac_ctx, &addbss_param->staContext,
512 addbss_param->bssId, addbss_param->htCapable,
513 session);
514
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530515 addbss_param->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 addbss_param->respReqd = 1;
517
518 /* Set a new state for MLME */
519 session->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_STATE;
520 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId,
521 session->limMlmState));
522
523 /* pass on the session persona to hal */
524 addbss_param->halPersona = session->pePersona;
525
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800526 if (session->ch_width == CH_WIDTH_160MHZ) {
527 is_ch_dfs = true;
528 } else if (session->ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700529 if (wlan_reg_get_channel_state(mac_ctx->pdev,
530 mlm_start_req->channelNumber) ==
531 CHANNEL_STATE_DFS ||
532 wlan_reg_get_channel_state(mac_ctx->pdev,
533 session->ch_center_freq_seg1 -
534 SIR_80MHZ_START_CENTER_CH_DIFF) ==
535 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800536 is_ch_dfs = true;
537 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700538 if (wlan_reg_get_channel_state(mac_ctx->pdev,
539 mlm_start_req->channelNumber) ==
540 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -0800541 is_ch_dfs = true;
542 }
543
544 addbss_param->bSpectrumMgtEnabled =
545 session->spectrumMgtEnabled || is_ch_dfs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546 addbss_param->extSetStaKeyParamValid = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547
548 addbss_param->dot11_mode = session->dot11mode;
549 addbss_param->nss = session->nss;
Arif Hussain671a1902017-03-17 09:08:32 -0700550 addbss_param->cac_duration_ms = mlm_start_req->cac_duration_ms;
551 addbss_param->dfs_regdomain = mlm_start_req->dfs_regdomain;
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800552 addbss_param->beacon_tx_rate = session->beacon_tx_rate;
Kiran Kumar Lokere6a7d1eb2016-05-02 18:31:35 -0700553 if (QDF_IBSS_MODE == addbss_param->halPersona) {
Pragaspathi Thilagaraj48d273c2018-08-31 00:53:02 +0530554 if (!(mac_ctx->mlme_cfg)) {
555 pe_err("Mlme cfg NULL");
556 return eSIR_SME_INVALID_PARAMETERS;
557 }
Kiran Kumar Lokere6a7d1eb2016-05-02 18:31:35 -0700558 addbss_param->nss_2g = mac_ctx->vdev_type_nss_2g.ibss;
559 addbss_param->nss_5g = mac_ctx->vdev_type_nss_5g.ibss;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +0530560 addbss_param->tx_aggregation_size =
Pragaspathi Thilagaraj48d273c2018-08-31 00:53:02 +0530561 qos_aggr->tx_aggregation_size;
Paul Zhangee09f8e2018-04-23 16:11:32 +0800562 addbss_param->tx_aggregation_size_be =
Pragaspathi Thilagaraj48d273c2018-08-31 00:53:02 +0530563 qos_aggr->tx_aggregation_size_be;
Paul Zhangee09f8e2018-04-23 16:11:32 +0800564 addbss_param->tx_aggregation_size_bk =
Pragaspathi Thilagaraj48d273c2018-08-31 00:53:02 +0530565 qos_aggr->tx_aggregation_size_bk;
Paul Zhangee09f8e2018-04-23 16:11:32 +0800566 addbss_param->tx_aggregation_size_vi =
Pragaspathi Thilagaraj48d273c2018-08-31 00:53:02 +0530567 qos_aggr->tx_aggregation_size_vi;
Paul Zhangee09f8e2018-04-23 16:11:32 +0800568 addbss_param->tx_aggregation_size_vo =
Pragaspathi Thilagaraj48d273c2018-08-31 00:53:02 +0530569 qos_aggr->tx_aggregation_size_vo;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +0530570 addbss_param->rx_aggregation_size =
Pragaspathi Thilagaraj48d273c2018-08-31 00:53:02 +0530571 qos_aggr->rx_aggregation_size;
Kiran Kumar Lokere6a7d1eb2016-05-02 18:31:35 -0700572 }
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700573 pe_debug("dot11_mode:%d nss value:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 addbss_param->dot11_mode, addbss_param->nss);
575
Naveen Rawat64e477e2016-05-20 10:34:56 -0700576 if (cds_is_5_mhz_enabled()) {
577 addbss_param->ch_width = CH_WIDTH_5MHZ;
578 addbss_param->staContext.ch_width = CH_WIDTH_5MHZ;
579 } else if (cds_is_10_mhz_enabled()) {
580 addbss_param->ch_width = CH_WIDTH_10MHZ;
581 addbss_param->staContext.ch_width = CH_WIDTH_10MHZ;
582 }
583
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800584 msg_buf.type = WMA_ADD_BSS_REQ;
585 msg_buf.reserved = 0;
586 msg_buf.bodyptr = addbss_param;
587 msg_buf.bodyval = 0;
588 MTRACE(mac_trace_msg_tx(mac_ctx, session->peSessionId, msg_buf.type));
589
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700590 pe_debug("Sending WMA_ADD_BSS_REQ...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 retcode = wma_post_ctrl_msg(mac_ctx, &msg_buf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700592 if (QDF_STATUS_SUCCESS != retcode) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700593 pe_err("Posting ADD_BSS_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 retcode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530595 qdf_mem_free(addbss_param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 return eSIR_SME_HAL_SEND_MESSAGE_FAIL;
597 }
598
599 return eSIR_SME_SUCCESS;
600}
601
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800602void lim_process_mlm_start_req(struct mac_context *mac_ctx,
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530603 tLimMlmStartReq *mlm_start_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800605 tLimMlmStartCnf mlm_start_cnf;
Jeff Johnsona7071e62018-11-18 22:55:45 -0800606 struct pe_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530608 if (!mlm_start_req) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700609 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 return;
611 }
612
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 session = pe_find_session_by_session_id(mac_ctx,
614 mlm_start_req->sessionId);
615 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700616 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 mlm_start_cnf.resultCode = eSIR_SME_REFUSED;
618 goto end;
619 }
620
621 if (session->limMlmState != eLIM_MLM_IDLE_STATE) {
622 /*
623 * Should not have received Start req in states other than idle.
624 * Return Start confirm with failure code.
625 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700626 pe_err("received unexpected MLM_START_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627 session->limMlmState);
628 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
629 mlm_start_cnf.resultCode =
630 eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
631 goto end;
632 }
633
634 mlm_start_cnf.resultCode =
635 lim_mlm_add_bss(mac_ctx, mlm_start_req, session);
636
637end:
638 /* Update PE session Id */
639 mlm_start_cnf.sessionId = mlm_start_req->sessionId;
640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641 /*
642 * Respond immediately to LIM, only if MLME has not been
643 * successfully able to send WMA_ADD_BSS_REQ to HAL.
644 * Else, LIM_MLM_START_CNF will be sent after receiving
645 * WMA_ADD_BSS_RSP from HAL
646 */
647 if (eSIR_SME_SUCCESS != mlm_start_cnf.resultCode)
Abhishek Singh1df50882018-08-30 18:04:29 +0530648 lim_send_start_bss_confirm(mac_ctx, &mlm_start_cnf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649}
650
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651/**
652 * lim_post_join_set_link_state_callback()- registered callback to perform post
653 * peer creation operations
654 *
655 * @mac: pointer to global mac structure
656 * @callback_arg: registered callback argument
657 * @status: peer creation status
658 *
659 * this is registered callback function during association to perform
660 * post peer creation operation based on the peer creation status
661 *
662 * Return: none
663 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800664static void lim_post_join_set_link_state_callback(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665 void *callback_arg, bool status)
666{
667 uint8_t chan_num, sec_chan_offset;
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +0530668 struct session_params *session_cb_param =
669 (struct session_params *)callback_arg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 tLimMlmJoinCnf mlm_join_cnf;
671
Jeff Johnsona7071e62018-11-18 22:55:45 -0800672 struct pe_session *session_entry = pe_find_session_by_session_id(mac,
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +0530673 session_cb_param->session_id);
674 if (!session_entry) {
675 pe_err("sessionId:%d does not exist",
676 session_cb_param->session_id);
677 qdf_mem_free(session_cb_param);
678 return;
679 }
680
681 qdf_mem_free(session_cb_param);
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700682 pe_debug("Sessionid %d set link state(%d) cb status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 session_entry->peSessionId, session_entry->limMlmState,
684 status);
685
686 if (!status) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700687 pe_err("failed to find pe session for session id:%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 session_entry->peSessionId);
689 goto failure;
690 }
691
692 chan_num = session_entry->currentOperChannel;
693 sec_chan_offset = session_entry->htSecondaryChannelOffset;
694 /*
695 * store the channel switch session_entry in the lim
696 * global variable
697 */
698 session_entry->channelChangeReasonCode =
699 LIM_SWITCH_CHANNEL_JOIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 session_entry->pLimMlmReassocRetryReq = NULL;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700701 pe_debug("[lim_process_mlm_join_req]: suspend link success(%d) "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 "on sessionid: %d setting channel to: %d with ch_width :%d "
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700703 "and maxtxPower: %d", status, session_entry->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 session_entry->currentOperChannel,
705 session_entry->ch_width,
706 session_entry->maxTxPower);
707 lim_set_channel(mac, session_entry->currentOperChannel,
708 session_entry->ch_center_freq_seg0,
709 session_entry->ch_center_freq_seg1,
710 session_entry->ch_width,
711 session_entry->maxTxPower,
Arif Hussain671a1902017-03-17 09:08:32 -0700712 session_entry->peSessionId, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713 return;
714
715failure:
716 MTRACE(mac_trace(mac, TRACE_CODE_MLM_STATE, session_entry->peSessionId,
717 session_entry->limMlmState));
718 session_entry->limMlmState = eLIM_MLM_IDLE_STATE;
Varun Reddy Yeturua47f08f2018-08-07 14:45:31 -0700719 mlm_join_cnf.resultCode = eSIR_SME_PEER_CREATE_FAILED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720 mlm_join_cnf.sessionId = session_entry->peSessionId;
721 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
722 lim_post_sme_message(mac, LIM_MLM_JOIN_CNF, (uint32_t *) &mlm_join_cnf);
723}
724
725/**
726 * lim_process_mlm_post_join_suspend_link() - This function is called after the
727 * suspend link while joining off channel.
728 *
729 * @mac_ctx: Pointer to Global MAC structure
730 * @status: status of suspend link.
731 * @ctx: passed while calling suspend link(session)
732 *
733 * This function does following:
734 * Check for suspend state.
Jeff Johnson4ceed382018-05-06 16:24:57 -0700735 * If success, proceed with setting link state to receive the
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 * probe response/beacon from intended AP.
737 * Switch to the APs channel.
738 * On an error case, send the MLM_JOIN_CNF with error status.
739 *
740 * @Return None
741 */
742static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800743lim_process_mlm_post_join_suspend_link(struct mac_context *mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530744 QDF_STATUS status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 uint32_t *ctx)
746{
747 tLimMlmJoinCnf mlm_join_cnf;
Jeff Johnsona7071e62018-11-18 22:55:45 -0800748 struct pe_session *session = (struct pe_session *) ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 tSirLinkState lnk_state;
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +0530750 struct session_params *pe_session_param = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530752 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700753 pe_err("Sessionid %d Suspend link(NOTIFY_BSS) failed. Still proceeding with join",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 session->peSessionId);
755 }
756 lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER);
757
758 /* assign appropriate sessionId to the timer object */
759 mac_ctx->lim.limTimers.gLimJoinFailureTimer.sessionId =
760 session->peSessionId;
761
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700762 lnk_state = eSIR_LINK_PREASSOC_STATE;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700763 pe_debug("[lim_process_mlm_join_req]: lnk_state: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 lnk_state);
765
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +0530766 pe_session_param = qdf_mem_malloc(sizeof(struct session_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700767 if (!pe_session_param)
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +0530768 goto error;
Arif Hussainf5b6c412018-10-10 19:41:09 -0700769
770 pe_session_param->session_id = session->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771 if (lim_set_link_state(mac_ctx, lnk_state,
772 session->pLimMlmJoinReq->bssDescription.bssId,
773 session->selfMacAddr,
774 lim_post_join_set_link_state_callback,
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +0530775 pe_session_param) != QDF_STATUS_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700776 pe_err("SessionId:%d lim_set_link_state to eSIR_LINK_PREASSOC_STATE Failed!!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777 session->peSessionId);
778 lim_print_mac_addr(mac_ctx,
779 session->pLimMlmJoinReq->bssDescription.bssId, LOGE);
780 mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
781 session->limMlmState = eLIM_MLM_IDLE_STATE;
782 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
783 session->peSessionId, session->limMlmState));
Pragaspathi Thilagaraj210362a2018-07-31 19:08:19 +0530784 qdf_mem_free(pe_session_param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 goto error;
786 }
787
788 return;
789error:
790 mlm_join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
791 mlm_join_cnf.sessionId = session->peSessionId;
792 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
793 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
794 (uint32_t *) &mlm_join_cnf);
795}
796
797/**
798 * lim_process_mlm_join_req() - process mlm join request.
799 *
800 * @mac_ctx: Pointer to Global MAC structure
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -0700801 * @mlm_join_req: Pointer to the mlme join request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 *
803 * This function is called to process MLM_JOIN_REQ message
804 * from SME. It does following:
805 * 1) Initialize LIM, HAL, DPH
806 * 2) Configure the BSS for which the JOIN REQ was received
807 * a) Send WMA_ADD_BSS_REQ to HAL -
808 * This will identify the BSS that we are interested in
809 * --AND--
810 * Add a STA entry for the AP (in a STA context)
811 * b) Wait for WMA_ADD_BSS_RSP
812 * c) Send WMA_ADD_STA_REQ to HAL
813 * This will add the "local STA" entry to the STA table
814 * 3) Continue as before, i.e,
815 * a) Send a PROBE REQ
816 * b) Wait for PROBE RSP/BEACON containing the SSID that
817 * we are interested in
818 * c) Then start an AUTH seq
819 * d) Followed by the ASSOC seq
820 *
821 * @Return: None
822 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800823void lim_process_mlm_join_req(struct mac_context *mac_ctx,
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -0700824 tLimMlmJoinReq *mlm_join_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825{
826 tLimMlmJoinCnf mlmjoin_cnf;
827 uint8_t sessionid;
Jeff Johnsona7071e62018-11-18 22:55:45 -0800828 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -0700830 sessionid = mlm_join_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831
832 session = pe_find_session_by_session_id(mac_ctx, sessionid);
833 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700834 pe_err("SessionId:%d does not exist", sessionid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 goto error;
836 }
837
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700838 if (!LIM_IS_AP_ROLE(session) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 ((session->limMlmState == eLIM_MLM_IDLE_STATE) ||
840 (session->limMlmState == eLIM_MLM_JOINED_STATE)) &&
841 (SIR_MAC_GET_ESS
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -0700842 (mlm_join_req->bssDescription.capabilityInfo) !=
843 SIR_MAC_GET_IBSS(mlm_join_req->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 capabilityInfo))) {
845 /* Hold onto Join request parameters */
846
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -0700847 session->pLimMlmJoinReq = mlm_join_req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 if (is_lim_session_off_channel(mac_ctx, sessionid)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700849 pe_debug("SessionId:%d LimSession is on OffChannel",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 sessionid);
851 /* suspend link */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700852 pe_debug("Suspend link, sessionid %d is off channel",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 sessionid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 lim_process_mlm_post_join_suspend_link(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530855 QDF_STATUS_SUCCESS, (uint32_t *)session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700857 pe_debug("No need to Suspend link");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 /*
859 * No need to Suspend link as LimSession is not
860 * off channel, calling
861 * lim_process_mlm_post_join_suspend_link with
862 * status as SUCCESS.
863 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700864 pe_debug("SessionId:%d Join req on current chan",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 sessionid);
866 lim_process_mlm_post_join_suspend_link(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530867 QDF_STATUS_SUCCESS, (uint32_t *)session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 }
869 return;
870 } else {
871 /**
872 * Should not have received JOIN req in states other than
873 * Idle state or on AP.
874 * Return join confirm with invalid parameters code.
875 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -0700876 pe_err("Session:%d Unexpected Join req, role %d state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 session->peSessionId, GET_LIM_SYSTEM_ROLE(session),
878 session->limMlmState);
879 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
880 }
881
882error:
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -0700883 qdf_mem_free(mlm_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 if (session != NULL)
885 session->pLimMlmJoinReq = NULL;
886 mlmjoin_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
887 mlmjoin_cnf.sessionId = sessionid;
888 mlmjoin_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
889 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
890 (uint32_t *)&mlmjoin_cnf);
891
892}
893
894/**
895 * lim_is_auth_req_expected() - check if auth request is expected
896 *
897 * @mac_ctx: global MAC context
898 * @session: PE session entry
899 *
900 * This function is called by lim_process_mlm_auth_req to check
901 * if auth request is expected.
902 *
903 * Return: true if expected and false otherwise
904 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800905static bool lim_is_auth_req_expected(struct mac_context *mac_ctx,
Jeff Johnsona7071e62018-11-18 22:55:45 -0800906 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907{
908 bool flag = false;
909
910 /*
911 * Expect Auth request only when:
912 * 1. STA joined/associated with a BSS or
913 * 2. STA is in IBSS mode
914 * and STA is going to authenticate with a unicast
915 * address and requested authentication algorithm is
916 * supported.
917 */
918
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700919 flag = (((LIM_IS_STA_ROLE(session) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 ((session->limMlmState == eLIM_MLM_JOINED_STATE) ||
921 (session->limMlmState ==
922 eLIM_MLM_LINK_ESTABLISHED_STATE))) ||
923 (LIM_IS_IBSS_ROLE(session) &&
924 (session->limMlmState ==
925 eLIM_MLM_BSS_STARTED_STATE))) &&
926 (!lim_is_group_addr(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr))
927 && lim_is_auth_algo_supported(mac_ctx,
928 mac_ctx->lim.gpLimMlmAuthReq->authType, session));
929
930 return flag;
931}
932
933/**
934 * lim_is_preauth_ctx_exisits() - check if preauth context exists
935 *
936 * @mac_ctx: global MAC context
937 * @session: PE session entry
938 * @preauth_node_ptr: pointer to preauth node pointer
939 *
940 * This function is called by lim_process_mlm_auth_req to check
941 * if preauth context already exists
942 *
943 * Return: true if exists and false otherwise
944 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800945static bool lim_is_preauth_ctx_exists(struct mac_context *mac_ctx,
Jeff Johnsona7071e62018-11-18 22:55:45 -0800946 struct pe_session *session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 struct tLimPreAuthNode **preauth_node_ptr)
948{
949 bool fl = false;
950 struct tLimPreAuthNode *preauth_node;
951 tpDphHashNode stads;
952 tSirMacAddr curr_bssid;
953
954 preauth_node = *preauth_node_ptr;
955 sir_copy_mac_addr(curr_bssid, session->bssId);
956 stads = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
957 &session->dph.dphHashTable);
958 preauth_node = lim_search_pre_auth_list(mac_ctx,
959 mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr);
960
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700961 fl = (((LIM_IS_STA_ROLE(session)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 (session->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE) &&
963 ((stads != NULL) &&
964 (mac_ctx->lim.gpLimMlmAuthReq->authType ==
965 stads->mlmStaContext.authType)) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530966 (!qdf_mem_cmp(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 curr_bssid, sizeof(tSirMacAddr)))) ||
968 ((preauth_node != NULL) &&
969 (preauth_node->authType ==
970 mac_ctx->lim.gpLimMlmAuthReq->authType)));
971
972 return fl;
973}
974
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +0530975#ifdef WLAN_FEATURE_SAE
976/**
977 * lim_process_mlm_auth_req_sae() - Handle SAE authentication
978 * @mac_ctx: global MAC context
979 * @session: PE session entry
980 *
981 * This function is called by lim_process_mlm_auth_req to handle SAE
982 * authentication.
983 *
984 * Return: QDF_STATUS
985 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800986static QDF_STATUS lim_process_mlm_auth_req_sae(struct mac_context *mac_ctx,
Jeff Johnsona7071e62018-11-18 22:55:45 -0800987 struct pe_session *session)
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +0530988{
989 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
990 struct sir_sae_info *sae_info;
991 struct scheduler_msg msg = {0};
992
993 sae_info = qdf_mem_malloc(sizeof(*sae_info));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700994 if (!sae_info)
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +0530995 return QDF_STATUS_E_FAILURE;
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +0530996
997 sae_info->msg_type = eWNI_SME_TRIGGER_SAE;
998 sae_info->msg_len = sizeof(*sae_info);
999 sae_info->vdev_id = session->smeSessionId;
1000
1001 qdf_mem_copy(sae_info->peer_mac_addr.bytes,
1002 session->bssId,
1003 QDF_MAC_ADDR_SIZE);
1004
1005 sae_info->ssid.length = session->ssId.length;
1006 qdf_mem_copy(sae_info->ssid.ssId,
1007 session->ssId.ssId,
1008 session->ssId.length);
1009
1010 pe_debug("vdev_id %d ssid %.*s "MAC_ADDRESS_STR"",
1011 sae_info->vdev_id,
1012 sae_info->ssid.length,
1013 sae_info->ssid.ssId,
1014 MAC_ADDR_ARRAY(sae_info->peer_mac_addr.bytes));
1015
1016 msg.type = eWNI_SME_TRIGGER_SAE;
1017 msg.bodyptr = sae_info;
1018 msg.bodyval = 0;
1019
1020 qdf_status = mac_ctx->lim.sme_msg_callback(mac_ctx, &msg);
1021 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
1022 pe_err("SAE failed for AUTH frame");
1023 qdf_mem_free(sae_info);
1024 return qdf_status;
1025 }
1026 session->limMlmState = eLIM_MLM_WT_SAE_AUTH_STATE;
1027
1028 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId,
1029 session->limMlmState));
1030
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +05301031 mac_ctx->lim.limTimers.sae_auth_timer.sessionId =
1032 session->peSessionId;
1033
1034 /* Activate SAE auth timer */
1035 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1036 session->peSessionId, eLIM_AUTH_SAE_TIMER));
1037 if (tx_timer_activate(&mac_ctx->lim.limTimers.sae_auth_timer)
1038 != TX_SUCCESS) {
1039 pe_err("could not start Auth SAE timer");
1040 }
1041
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +05301042 return qdf_status;
1043}
1044#else
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001045static QDF_STATUS lim_process_mlm_auth_req_sae(struct mac_context *mac_ctx,
Jeff Johnsona7071e62018-11-18 22:55:45 -08001046 struct pe_session *session)
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +05301047{
1048 return QDF_STATUS_E_NOSUPPORT;
1049}
1050#endif
1051
1052
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053/**
1054 * lim_process_mlm_auth_req() - process lim auth request
1055 *
1056 * @mac_ctx: global MAC context
1057 * @msg: MLM auth request message
1058 *
1059 * This function is called to process MLM_AUTH_REQ message from SME
1060 *
1061 * @Return: None
1062 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001063static void lim_process_mlm_auth_req(struct mac_context *mac_ctx, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064{
1065 uint32_t num_preauth_ctx;
1066 tSirMacAddr curr_bssid;
1067 tSirMacAuthFrameBody auth_frame_body;
1068 tLimMlmAuthCnf mlm_auth_cnf;
1069 struct tLimPreAuthNode *preauth_node = NULL;
1070 uint8_t session_id;
Jeff Johnsona7071e62018-11-18 22:55:45 -08001071 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072
1073 if (msg == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001074 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 return;
1076 }
1077
1078 mac_ctx->lim.gpLimMlmAuthReq = (tLimMlmAuthReq *) msg;
1079 session_id = mac_ctx->lim.gpLimMlmAuthReq->sessionId;
1080 session = pe_find_session_by_session_id(mac_ctx, session_id);
1081 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001082 pe_err("SessionId:%d does not exist", session_id);
Krunal Soni7d787082017-11-07 10:30:11 -08001083 qdf_mem_free(msg);
1084 mac_ctx->lim.gpLimMlmAuthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 return;
1086 }
1087
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001088 pe_debug("Process Auth Req sessionID %d Systemrole %d"
1089 "mlmstate %d from: " MAC_ADDRESS_STR
1090 " with authtype %d", session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 GET_LIM_SYSTEM_ROLE(session), session->limMlmState,
1092 MAC_ADDR_ARRAY(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr),
1093 mac_ctx->lim.gpLimMlmAuthReq->authType);
1094
1095 sir_copy_mac_addr(curr_bssid, session->bssId);
1096
1097 if (!lim_is_auth_req_expected(mac_ctx, session)) {
1098 /*
1099 * Unexpected auth request.
1100 * Return Auth confirm with Invalid parameters code.
1101 */
1102 mlm_auth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1103 goto end;
1104 }
1105
1106 /*
1107 * This is a request for pre-authentication. Check if there exists
1108 * context already for the requested peer OR
1109 * if this request is for the AP we're currently associated with.
1110 * If yes, return auth confirm immediately when
1111 * requested auth type is same as the one used before.
1112 */
1113 if (lim_is_preauth_ctx_exists(mac_ctx, session, &preauth_node)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001114 pe_debug("Already have pre-auth context with peer: "
1115 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001116 MAC_ADDR_ARRAY(mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr));
1117 mlm_auth_cnf.resultCode = (tSirResultCodes)
1118 eSIR_MAC_SUCCESS_STATUS;
1119 goto end;
1120 } else {
Wu Gaoca416ff2018-09-17 11:05:07 +08001121 num_preauth_ctx = mac_ctx->mlme_cfg->lfr.max_num_pre_auth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122 if (mac_ctx->lim.gLimNumPreAuthContexts == num_preauth_ctx) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001123 pe_warn("Number of pre-auth reached max limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 /* Return Auth confirm with reject code */
1125 mlm_auth_cnf.resultCode =
1126 eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED;
1127 goto end;
1128 }
1129 }
1130
1131 /* Delete pre-auth node if exists */
1132 if (preauth_node)
1133 lim_delete_pre_auth_node(mac_ctx,
1134 mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr);
1135
1136 session->limPrevMlmState = session->limMlmState;
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +05301137
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301138 if ((mac_ctx->lim.gpLimMlmAuthReq->authType == eSIR_AUTH_TYPE_SAE) &&
1139 !session->sae_pmk_cached) {
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +05301140 if (lim_process_mlm_auth_req_sae(mac_ctx, session) !=
1141 QDF_STATUS_SUCCESS) {
1142 mlm_auth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1143 goto end;
1144 } else {
1145 pe_debug("lim_process_mlm_auth_req_sae is successful");
Abhinav Kumar85561672018-04-17 12:48:51 +05301146 lim_diag_event_report(mac_ctx,
1147 WLAN_PE_DIAG_AUTH_ALGO_NUM,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001148 session, QDF_STATUS_SUCCESS,
Abhinav Kumar85561672018-04-17 12:48:51 +05301149 eSIR_AUTH_TYPE_SAE);
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +05301150 return;
1151 }
1152 } else
1153 session->limMlmState = eLIM_MLM_WT_AUTH_FRAME2_STATE;
1154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE, session->peSessionId,
1156 session->limMlmState));
1157
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301158 /* Mark auth algo as open when auth type is SAE and PMK is cached */
1159 if ((mac_ctx->lim.gpLimMlmAuthReq->authType == eSIR_AUTH_TYPE_SAE) &&
1160 session->sae_pmk_cached) {
1161 auth_frame_body.authAlgoNumber = eSIR_OPEN_SYSTEM;
1162 } else {
1163 auth_frame_body.authAlgoNumber =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164 (uint8_t) mac_ctx->lim.gpLimMlmAuthReq->authType;
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301165 }
Abhinav Kumar85561672018-04-17 12:48:51 +05301166 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ALGO_NUM, session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001167 QDF_STATUS_SUCCESS, auth_frame_body.authAlgoNumber);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301168
1169 /* Prepare & send Authentication frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 auth_frame_body.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
1171 auth_frame_body.authStatusCode = 0;
1172#ifdef FEATURE_WLAN_DIAG_SUPPORT
1173 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_START_EVENT, session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001174 QDF_STATUS_SUCCESS, auth_frame_body.authStatusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175#endif
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301176 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 lim_send_auth_mgmt_frame(mac_ctx,
1178 &auth_frame_body, mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301179 LIM_NO_WEP_IN_FC, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180
1181 /* assign appropriate session_id to the timer object */
1182 mac_ctx->lim.limTimers.gLimAuthFailureTimer.sessionId = session_id;
1183
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301184 /* assign appropriate sessionId to the timer object */
1185 mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer.sessionId =
1186 session_id;
1187 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188 /* Activate Auth failure timer */
1189 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1190 session->peSessionId, eLIM_AUTH_FAIL_TIMER));
Bala Venkatesh41837792018-11-01 18:22:13 +05301191 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_FAIL_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimAuthFailureTimer)
1193 != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001194 pe_err("could not start Auth failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195 /* Cleanup as if auth timer expired */
1196 lim_process_auth_failure_timeout(mac_ctx);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301197 } else {
1198 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1199 session->peSessionId, eLIM_AUTH_RETRY_TIMER));
1200 /* Activate Auth Retry timer */
1201 if (tx_timer_activate
1202 (&mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer)
1203 != TX_SUCCESS)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001204 pe_err("could not activate Auth Retry timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205 }
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05301206
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207 return;
1208end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301209 qdf_mem_copy((uint8_t *) &mlm_auth_cnf.peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 (uint8_t *) &mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
1211 sizeof(tSirMacAddr));
1212
1213 mlm_auth_cnf.authType = mac_ctx->lim.gpLimMlmAuthReq->authType;
1214 mlm_auth_cnf.sessionId = session_id;
1215
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301216 qdf_mem_free(mac_ctx->lim.gpLimMlmAuthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 mac_ctx->lim.gpLimMlmAuthReq = NULL;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001218 pe_debug("SessionId:%d LimPostSme LIM_MLM_AUTH_CNF",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 session_id);
1220 lim_post_sme_message(mac_ctx, LIM_MLM_AUTH_CNF,
1221 (uint32_t *) &mlm_auth_cnf);
1222}
1223
1224/**
1225 * lim_process_mlm_assoc_req() - This function is called to process
1226 * MLM_ASSOC_REQ message from SME
1227 *
1228 * @mac_ctx: Pointer to Global MAC structure
1229 * @msg_buf: A pointer to the MLM message buffer
1230 *
1231 * This function is called to process MLM_ASSOC_REQ message from SME
1232 *
1233 * @Return None
1234 */
1235
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001236static void lim_process_mlm_assoc_req(struct mac_context *mac_ctx, uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237{
1238 tSirMacAddr curr_bssId;
1239 tLimMlmAssocReq *mlm_assoc_req;
1240 tLimMlmAssocCnf mlm_assoc_cnf;
Jeff Johnsona7071e62018-11-18 22:55:45 -08001241 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242
1243 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001244 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 return;
1246 }
1247
1248 mlm_assoc_req = (tLimMlmAssocReq *) msg_buf;
1249 session_entry = pe_find_session_by_session_id(mac_ctx,
1250 mlm_assoc_req->sessionId);
1251 if (session_entry == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001252 pe_err("SessionId:%d Session Does not exist",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 mlm_assoc_req->sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301254 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255 return;
1256 }
1257
1258 sir_copy_mac_addr(curr_bssId, session_entry->bssId);
1259
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001260 if (!(!LIM_IS_AP_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 (session_entry->limMlmState == eLIM_MLM_AUTHENTICATED_STATE ||
1262 session_entry->limMlmState == eLIM_MLM_JOINED_STATE) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301263 (!qdf_mem_cmp(mlm_assoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 curr_bssId, sizeof(tSirMacAddr))))) {
1265 /*
1266 * Received Association request either in invalid state
1267 * or to a peer MAC entity whose address is different
1268 * from one that STA is currently joined with or on AP.
1269 * Return Assoc confirm with Invalid parameters code.
1270 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001271 pe_warn("received unexpected MLM_ASSOC_CNF in state %X for role=%d, MAC addr= "
1272 MAC_ADDRESS_STR, session_entry->limMlmState,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273 GET_LIM_SYSTEM_ROLE(session_entry),
1274 MAC_ADDR_ARRAY(mlm_assoc_req->peerMacAddr));
1275 lim_print_mlm_state(mac_ctx, LOGW, session_entry->limMlmState);
1276 mlm_assoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1277 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
1278 goto end;
1279 }
1280
1281 /* map the session entry pointer to the AssocFailureTimer */
1282 mac_ctx->lim.limTimers.gLimAssocFailureTimer.sessionId =
1283 mlm_assoc_req->sessionId;
1284#ifdef WLAN_FEATURE_11W
1285 /*
1286 * Store current MLM state in case ASSOC response returns with
1287 * TRY_AGAIN_LATER return code.
1288 */
1289 if (session_entry->limRmfEnabled) {
Jeff Johnson4a07a9b2018-11-21 23:51:02 -08001290 session_entry->pmfComebackTimerInfo.lim_prev_mlm_state =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291 session_entry->limPrevMlmState;
Jeff Johnson4a07a9b2018-11-21 23:51:02 -08001292 session_entry->pmfComebackTimerInfo.lim_mlm_state =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 session_entry->limMlmState;
1294 }
1295#endif /* WLAN_FEATURE_11W */
1296
1297 session_entry->limPrevMlmState = session_entry->limMlmState;
1298 session_entry->limMlmState = eLIM_MLM_WT_ASSOC_RSP_STATE;
1299 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
1300 session_entry->peSessionId,
1301 session_entry->limMlmState));
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001302 pe_debug("SessionId:%d Sending Assoc_Req Frame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 session_entry->peSessionId);
1304
1305 /* Prepare and send Association request frame */
1306 lim_send_assoc_req_mgmt_frame(mac_ctx, mlm_assoc_req, session_entry);
1307
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 /* Start association failure timer */
1309 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
1310 session_entry->peSessionId, eLIM_ASSOC_FAIL_TIMER));
1311 if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimAssocFailureTimer)
1312 != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001313 pe_warn("SessionId:%d couldn't start Assoc failure timer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 session_entry->peSessionId);
1315 /* Cleanup as if assoc timer expired */
1316 lim_process_assoc_failure_timeout(mac_ctx, LIM_ASSOC);
1317 }
1318
1319 return;
1320end:
1321 /* Update PE session Id */
1322 mlm_assoc_cnf.sessionId = mlm_assoc_req->sessionId;
1323 /* Free up buffer allocated for assocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301324 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
1326 (uint32_t *) &mlm_assoc_cnf);
1327}
1328
1329/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 * lim_process_mlm_disassoc_req_ntf() - process disassoc request notification
1331 *
1332 * @mac_ctx: global MAC context
1333 * @suspend_status: suspend status
1334 * @msg: mlm message buffer
1335 *
1336 * This function is used to process MLM disassoc notification
1337 *
1338 * Return: None
1339 */
1340static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001341lim_process_mlm_disassoc_req_ntf(struct mac_context *mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301342 QDF_STATUS suspend_status, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343{
1344 uint16_t aid;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301345 struct qdf_mac_addr curr_bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 tpDphHashNode stads;
1347 tLimMlmDisassocReq *mlm_disassocreq;
1348 tLimMlmDisassocCnf mlm_disassoccnf;
Jeff Johnsona7071e62018-11-18 22:55:45 -08001349 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 extern bool send_disassoc_frame;
1351 tLimMlmStates mlm_state;
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301352 tSirSmeDisassocRsp *sme_disassoc_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301354 if (QDF_STATUS_SUCCESS != suspend_status)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001355 pe_err("Suspend Status is not success %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 suspend_status);
1357
1358 mlm_disassocreq = (tLimMlmDisassocReq *) msg;
1359
1360 session = pe_find_session_by_session_id(mac_ctx,
1361 mlm_disassocreq->sessionId);
1362 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001363 pe_err("session does not exist for given sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364 mlm_disassocreq->sessionId);
1365 mlm_disassoccnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1366 goto end;
1367 }
1368
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001369 pe_debug("Process DisAssoc Req on sessionID %d Systemrole %d"
1370 "mlmstate %d from: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371 mlm_disassocreq->sessionId, GET_LIM_SYSTEM_ROLE(session),
1372 session->limMlmState,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001373 MAC_ADDR_ARRAY(mlm_disassocreq->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301375 qdf_mem_copy(curr_bssid.bytes, session->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376
1377 switch (GET_LIM_SYSTEM_ROLE(session)) {
1378 case eLIM_STA_ROLE:
Anurag Chouhanc5548422016-02-24 18:33:27 +05301379 if (!qdf_is_macaddr_equal(&mlm_disassocreq->peer_macaddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001380 &curr_bssid)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001381 pe_warn("received MLM_DISASSOC_REQ with invalid BSS id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 lim_print_mac_addr(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001383 mlm_disassocreq->peer_macaddr.bytes, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301385 /*
1386 * Disassociation response due to host triggered
1387 * disassociation
1388 */
1389 sme_disassoc_rsp =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301390 qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001391 if (!sme_disassoc_rsp) {
Vignesh Viswanathana842b942018-02-16 16:02:50 +05301392 qdf_mem_free(mlm_disassocreq);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301393 return;
1394 }
1395
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001396 pe_debug("send disassoc rsp with ret code %d for" MAC_ADDRESS_STR,
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301397 eSIR_SME_DEAUTH_STATUS,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001398 MAC_ADDR_ARRAY(
1399 mlm_disassocreq->peer_macaddr.bytes));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301400
1401 sme_disassoc_rsp->messageType = eWNI_SME_DISASSOC_RSP;
1402 sme_disassoc_rsp->length = sizeof(tSirSmeDisassocRsp);
1403 sme_disassoc_rsp->sessionId =
1404 mlm_disassocreq->sessionId;
1405 sme_disassoc_rsp->transactionId = 0;
1406 sme_disassoc_rsp->statusCode = eSIR_SME_DEAUTH_STATUS;
1407
Anurag Chouhanc5548422016-02-24 18:33:27 +05301408 qdf_copy_macaddr(&sme_disassoc_rsp->peer_macaddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001409 &mlm_disassocreq->peer_macaddr);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301410 msg = (uint32_t *)sme_disassoc_rsp;
1411
1412 lim_send_sme_disassoc_deauth_ntf(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301413 QDF_STATUS_SUCCESS, msg);
Vignesh Viswanathana842b942018-02-16 16:02:50 +05301414 qdf_mem_free(mlm_disassocreq);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301415 return;
1416
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 }
1418 break;
1419 case eLIM_STA_IN_IBSS_ROLE:
1420 break;
1421 case eLIM_AP_ROLE:
1422 case eLIM_P2P_DEVICE_GO:
1423 if (true ==
1424 mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001425 pe_err("CAC timer is running, drop disassoc from going out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 mlm_disassoccnf.resultCode = eSIR_SME_SUCCESS;
1427 goto end;
1428 }
1429 break;
1430 default:
1431 break;
1432 } /* end switch (GET_LIM_SYSTEM_ROLE(session)) */
1433
1434 /*
1435 * Check if there exists a context for the peer entity
1436 * to be disassociated with.
1437 */
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001438 stads = dph_lookup_hash_entry(mac_ctx,
1439 mlm_disassocreq->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 &aid, &session->dph.dphHashTable);
1441 if (stads)
1442 mlm_state = stads->mlmStaContext.mlmState;
1443
1444 if ((stads == NULL) ||
1445 (stads &&
1446 ((mlm_state != eLIM_MLM_LINK_ESTABLISHED_STATE) &&
1447 (mlm_state != eLIM_MLM_WT_ASSOC_CNF_STATE) &&
1448 (mlm_state != eLIM_MLM_ASSOCIATED_STATE)))) {
1449 /*
1450 * Received LIM_MLM_DISASSOC_REQ for STA that does not
1451 * have context or in some transit state.
1452 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001453 pe_warn("Invalid MLM_DISASSOC_REQ, Addr= " MAC_ADDRESS_STR,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001454 MAC_ADDR_ARRAY(mlm_disassocreq->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455 if (stads != NULL)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001456 pe_err("Sta MlmState: %d", stads->mlmStaContext.mlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457
1458 /* Prepare and Send LIM_MLM_DISASSOC_CNF */
1459 mlm_disassoccnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1460 goto end;
1461 }
1462
1463 stads->mlmStaContext.disassocReason = (tSirMacReasonCodes)
1464 mlm_disassocreq->reasonCode;
1465 stads->mlmStaContext.cleanupTrigger = mlm_disassocreq->disassocTrigger;
1466
1467 /*
1468 * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
1469 * This is to address the issue of race condition between
1470 * disconnect request from the HDD and deauth from AP
1471 */
1472
1473 stads->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
1474
1475 /* Send Disassociate frame to peer entity */
1476 if (send_disassoc_frame && (mlm_disassocreq->reasonCode !=
1477 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Vignesh Viswanathana842b942018-02-16 16:02:50 +05301478 if (mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq) {
1479 pe_err("pMlmDisassocReq is not NULL, freeing");
1480 qdf_mem_free(mac_ctx->lim.limDisassocDeauthCnfReq.
1481 pMlmDisassocReq);
1482 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq =
1484 mlm_disassocreq;
1485 /*
1486 * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
1487 * This is to address the issue of race condition between
1488 * disconnect request from the HDD and deauth from AP
1489 */
1490 stads->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
1491
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05301492 lim_send_disassoc_mgmt_frame(mac_ctx,
1493 mlm_disassocreq->reasonCode,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001494 mlm_disassocreq->peer_macaddr.bytes, session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495 /*
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05301496 * Abort Tx so that data frames won't be sent to the AP
1497 * after sending Disassoc.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 */
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05301499 if (LIM_IS_STA_ROLE(session))
1500 wma_tx_abort(session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 } else {
1502 /* Disassoc frame is not sent OTA */
1503 send_disassoc_frame = 1;
1504 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001505 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 lim_cleanup_rx_path(mac_ctx, stads, session)) {
1507 mlm_disassoccnf.resultCode =
1508 eSIR_SME_RESOURCES_UNAVAILABLE;
1509 goto end;
1510 }
1511 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301512 qdf_mem_free(mlm_disassocreq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 }
1514
1515 return;
1516
1517end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301518 qdf_mem_copy((uint8_t *) &mlm_disassoccnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001519 (uint8_t *) mlm_disassocreq->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301520 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 mlm_disassoccnf.aid = mlm_disassocreq->aid;
1522 mlm_disassoccnf.disassocTrigger = mlm_disassocreq->disassocTrigger;
1523
1524 /* Update PE session ID */
1525 mlm_disassoccnf.sessionId = mlm_disassocreq->sessionId;
1526
1527 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301528 qdf_mem_free(mlm_disassocreq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529
1530 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
1531 (uint32_t *) &mlm_disassoccnf);
1532}
1533
1534/**
1535 * lim_check_disassoc_deauth_ack_pending() - check if deauth is pending
1536 *
1537 * @mac_ctx - global MAC context
1538 * @sta_mac - station MAC
1539 *
1540 * This function checks if diassociation or deauthentication is pending for
1541 * given station MAC address.
1542 *
1543 * Return: true if pending and false otherwise.
1544 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001545bool lim_check_disassoc_deauth_ack_pending(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 uint8_t *sta_mac)
1547{
1548 tLimMlmDisassocReq *disassoc_req;
1549 tLimMlmDeauthReq *deauth_req;
1550
1551 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
1552 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301553 if ((disassoc_req && (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001554 (uint8_t *) &disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301555 QDF_MAC_ADDR_SIZE))) ||
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301556 (deauth_req && (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001557 (uint8_t *) &deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301558 QDF_MAC_ADDR_SIZE)))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001559 pe_debug("Disassoc/Deauth ack pending");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 return true;
1561 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001562 pe_debug("Disassoc/Deauth Ack not pending");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 return false;
1564 }
1565}
1566
1567/*
1568 * lim_clean_up_disassoc_deauth_req() - cleans up pending disassoc or deauth req
1569 *
1570 * @mac_ctx: mac_ctx
1571 * @sta_mac: sta mac address
1572 * @clean_rx_path: flag to indicate whether to cleanup rx path or not
1573 *
1574 * This function cleans up pending disassoc or deauth req
1575 *
1576 * Return: void
1577 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001578void lim_clean_up_disassoc_deauth_req(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 uint8_t *sta_mac, bool clean_rx_path)
1580{
1581 tLimMlmDisassocReq *mlm_disassoc_req;
1582 tLimMlmDeauthReq *mlm_deauth_req;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001583
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584 mlm_disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
1585 if (mlm_disassoc_req &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301586 (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001587 (uint8_t *) &mlm_disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301588 QDF_MAC_ADDR_SIZE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589 if (clean_rx_path) {
1590 lim_process_disassoc_ack_timeout(mac_ctx);
1591 } else {
1592 if (tx_timer_running(
1593 &mac_ctx->lim.limTimers.gLimDisassocAckTimer)) {
1594 lim_deactivate_and_change_timer(mac_ctx,
1595 eLIM_DISASSOC_ACK_TIMER);
1596 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301597 qdf_mem_free(mlm_disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq =
1599 NULL;
1600 }
1601 }
1602
1603 mlm_deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
1604 if (mlm_deauth_req &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301605 (!qdf_mem_cmp((uint8_t *) sta_mac,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001606 (uint8_t *) &mlm_deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301607 QDF_MAC_ADDR_SIZE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 if (clean_rx_path) {
1609 lim_process_deauth_ack_timeout(mac_ctx);
1610 } else {
1611 if (tx_timer_running(
1612 &mac_ctx->lim.limTimers.gLimDeauthAckTimer)) {
1613 lim_deactivate_and_change_timer(mac_ctx,
1614 eLIM_DEAUTH_ACK_TIMER);
1615 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301616 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq =
1618 NULL;
1619 }
1620 }
1621}
1622
1623/*
1624 * lim_process_disassoc_ack_timeout() - wrapper function around
1625 * lim_send_disassoc_cnf
1626 *
1627 * @mac_ctx: mac_ctx
1628 *
1629 * wrapper function around lim_send_disassoc_cnf
1630 *
1631 * Return: void
1632 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001633void lim_process_disassoc_ack_timeout(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 lim_send_disassoc_cnf(mac_ctx);
1636}
1637
1638/**
1639 * lim_process_mlm_disassoc_req() - This function is called to process
1640 * MLM_DISASSOC_REQ message from SME
1641 *
1642 * @mac_ctx: Pointer to Global MAC structure
1643 * @msg_buf: A pointer to the MLM message buffer
1644 *
1645 * This function is called to process MLM_DISASSOC_REQ message from SME
1646 *
1647 * @Return: None
1648 */
1649static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001650lim_process_mlm_disassoc_req(struct mac_context *mac_ctx, uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651{
1652 tLimMlmDisassocReq *mlm_disassoc_req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653
1654 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001655 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 return;
1657 }
1658
1659 mlm_disassoc_req = (tLimMlmDisassocReq *) msg_buf;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001660 pe_debug("Process disassoc req, sessionID %d from: "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 mlm_disassoc_req->sessionId,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08001662 MAC_ADDR_ARRAY(mlm_disassoc_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301664 lim_process_mlm_disassoc_req_ntf(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 (uint32_t *) msg_buf);
1666}
1667
1668/**
1669 * lim_process_mlm_deauth_req_ntf() - This function is process mlm deauth req
1670 * notification
1671 *
1672 * @mac_ctx: Pointer to Global MAC structure
1673 * @suspend_status: suspend status
1674 * @msg_buf: A pointer to the MLM message buffer
1675 *
1676 * This function is process mlm deauth req notification
1677 *
1678 * @Return: None
1679 */
1680static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001681lim_process_mlm_deauth_req_ntf(struct mac_context *mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301682 QDF_STATUS suspend_status, uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683{
1684 uint16_t aid;
1685 tSirMacAddr curr_bssId;
1686 tpDphHashNode sta_ds;
1687 struct tLimPreAuthNode *auth_node;
1688 tLimMlmDeauthReq *mlm_deauth_req;
1689 tLimMlmDeauthCnf mlm_deauth_cnf;
Jeff Johnsona7071e62018-11-18 22:55:45 -08001690 struct pe_session *session;
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301691 tSirSmeDeauthRsp *sme_deauth_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301693 if (QDF_STATUS_SUCCESS != suspend_status)
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001694 pe_err("Suspend Status is not success %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 suspend_status);
1696
1697 mlm_deauth_req = (tLimMlmDeauthReq *) msg_buf;
1698 session = pe_find_session_by_session_id(mac_ctx,
1699 mlm_deauth_req->sessionId);
1700 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001701 pe_err("session does not exist for given sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 mlm_deauth_req->sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301703 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 return;
1705 }
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001706 pe_debug("Process Deauth Req on sessionID %d Systemrole %d"
1707 "mlmstate %d from: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 mlm_deauth_req->sessionId,
1709 GET_LIM_SYSTEM_ROLE(session),
1710 session->limMlmState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001711 MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 sir_copy_mac_addr(curr_bssId, session->bssId);
1713
1714 switch (GET_LIM_SYSTEM_ROLE(session)) {
1715 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 switch (session->limMlmState) {
1717 case eLIM_MLM_IDLE_STATE:
1718 /*
1719 * Attempting to Deauthenticate with a pre-authenticated
1720 * peer. Deauthetiate with peer if there exists a
1721 * pre-auth context below.
1722 */
1723 break;
1724 case eLIM_MLM_AUTHENTICATED_STATE:
1725 case eLIM_MLM_WT_ASSOC_RSP_STATE:
1726 case eLIM_MLM_LINK_ESTABLISHED_STATE:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301727 if (qdf_mem_cmp(mlm_deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301728 curr_bssId, QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001729 pe_err("received MLM_DEAUTH_REQ with invalid BSS id "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 "Peer MAC: "MAC_ADDRESS_STR
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001731 " CFG BSSID Addr : "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 MAC_ADDR_ARRAY(
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001733 mlm_deauth_req->peer_macaddr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 MAC_ADDR_ARRAY(curr_bssId));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301735 /*
1736 * Deauthentication response to host triggered
1737 * deauthentication
1738 */
1739 sme_deauth_rsp =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301740 qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001741 if (!sme_deauth_rsp) {
Vignesh Viswanathana842b942018-02-16 16:02:50 +05301742 qdf_mem_free(mlm_deauth_req);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301743 return;
1744 }
1745
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001746 pe_debug("send deauth rsp with ret code %d for" MAC_ADDRESS_STR,
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301747 eSIR_SME_DEAUTH_STATUS,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001748 MAC_ADDR_ARRAY(
1749 mlm_deauth_req->peer_macaddr.bytes));
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301750
1751 sme_deauth_rsp->messageType =
1752 eWNI_SME_DEAUTH_RSP;
1753 sme_deauth_rsp->length =
1754 sizeof(tSirSmeDeauthRsp);
1755 sme_deauth_rsp->statusCode =
1756 eSIR_SME_DEAUTH_STATUS;
1757 sme_deauth_rsp->sessionId =
1758 mlm_deauth_req->sessionId;
1759 sme_deauth_rsp->transactionId = 0;
1760
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301761 qdf_mem_copy(sme_deauth_rsp->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001762 mlm_deauth_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301763 QDF_MAC_ADDR_SIZE);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301764
1765 msg_buf = (uint32_t *)sme_deauth_rsp;
1766
1767 lim_send_sme_disassoc_deauth_ntf(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301768 QDF_STATUS_SUCCESS, msg_buf);
Vignesh Viswanathana842b942018-02-16 16:02:50 +05301769 qdf_mem_free(mlm_deauth_req);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301770 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 }
1772
1773 if ((session->limMlmState ==
1774 eLIM_MLM_AUTHENTICATED_STATE) ||
1775 (session->limMlmState ==
1776 eLIM_MLM_WT_ASSOC_RSP_STATE)) {
1777 /* Send deauth frame to peer entity */
1778 lim_send_deauth_mgmt_frame(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001779 mlm_deauth_req->reasonCode,
1780 mlm_deauth_req->peer_macaddr.bytes,
1781 session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 /* Prepare and Send LIM_MLM_DEAUTH_CNF */
1783 mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS;
1784 session->limMlmState = eLIM_MLM_IDLE_STATE;
1785 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
1786 session->peSessionId,
1787 session->limMlmState));
1788 goto end;
1789 }
1790 break;
1791 default:
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001792 pe_warn("received MLM_DEAUTH_REQ with in state %d for peer "
1793 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 session->limMlmState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001795 MAC_ADDR_ARRAY(
1796 mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 lim_print_mlm_state(mac_ctx, LOGW,
1798 session->limMlmState);
1799 /* Prepare and Send LIM_MLM_DEAUTH_CNF */
1800 mlm_deauth_cnf.resultCode =
1801 eSIR_SME_STA_NOT_AUTHENTICATED;
1802
1803 goto end;
1804 }
1805 break;
1806 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001807 pe_err("received MLM_DEAUTH_REQ IBSS Mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 mlm_deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1809 goto end;
1810 case eLIM_AP_ROLE:
1811 case eLIM_P2P_DEVICE_GO:
1812 if (true ==
1813 mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001814 pe_err("CAC timer is running, drop disassoc from going out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815 mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS;
1816 goto end;
1817 }
1818 break;
1819
1820 default:
1821 break;
1822 } /* end switch (GET_LIM_SYSTEM_ROLE(session)) */
1823
1824 /*
1825 * Check if there exists a context for the peer entity
1826 * to be deauthenticated with.
1827 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001828 sta_ds = dph_lookup_hash_entry(mac_ctx,
1829 mlm_deauth_req->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 &aid, &session->dph.dphHashTable);
1831
1832 if (sta_ds == NULL) {
1833 /* Check if there exists pre-auth context for this STA */
1834 auth_node = lim_search_pre_auth_list(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001835 mlm_deauth_req->peer_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836 if (auth_node == NULL) {
1837 /*
1838 * Received DEAUTH REQ for a STA that is neither
1839 * Associated nor Pre-authenticated. Log error,
1840 * Prepare and Send LIM_MLM_DEAUTH_CNF
1841 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001842 pe_warn("received MLM_DEAUTH_REQ in mlme state %d for STA that "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 "does not have context, Addr="
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001844 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 session->limMlmState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001846 MAC_ADDR_ARRAY(
1847 mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 mlm_deauth_cnf.resultCode =
1849 eSIR_SME_STA_NOT_AUTHENTICATED;
1850 } else {
1851 mlm_deauth_cnf.resultCode = eSIR_SME_SUCCESS;
1852 /* Delete STA from pre-auth STA list */
1853 lim_delete_pre_auth_node(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001854 mlm_deauth_req->peer_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 /* Send Deauthentication frame to peer entity */
1856 lim_send_deauth_mgmt_frame(mac_ctx,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001857 mlm_deauth_req->reasonCode,
1858 mlm_deauth_req->peer_macaddr.bytes,
1859 session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 }
1861 goto end;
1862 } else if ((sta_ds->mlmStaContext.mlmState !=
1863 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
1864 (sta_ds->mlmStaContext.mlmState !=
1865 eLIM_MLM_WT_ASSOC_CNF_STATE)) {
1866 /*
1867 * received MLM_DEAUTH_REQ for STA that either has no context or
1868 * in some transit state
1869 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001870 pe_warn("Invalid MLM_DEAUTH_REQ, Addr="MAC_ADDRESS_STR,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001871 MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 /* Prepare and Send LIM_MLM_DEAUTH_CNF */
1873 mlm_deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
1874 goto end;
1875 }
1876 /* sta_ds->mlmStaContext.rxPurgeReq = 1; */
1877 sta_ds->mlmStaContext.disassocReason = (tSirMacReasonCodes)
1878 mlm_deauth_req->reasonCode;
1879 sta_ds->mlmStaContext.cleanupTrigger = mlm_deauth_req->deauthTrigger;
Vignesh Viswanathana842b942018-02-16 16:02:50 +05301880
1881 if (mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq) {
1882 pe_err("pMlmDeauthReq is not NULL, freeing");
1883 qdf_mem_free(mac_ctx->lim.limDisassocDeauthCnfReq.
1884 pMlmDeauthReq);
1885 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = mlm_deauth_req;
Vignesh Viswanathana842b942018-02-16 16:02:50 +05301887
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 /*
1889 * Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE
1890 * This is to address the issue of race condition between
1891 * disconnect request from the HDD and disassoc from
1892 * inactivity timer. This will make sure that we will not
1893 * process disassoc if deauth is in progress for the station
1894 * and thus mlmStaContext.cleanupTrigger will not be overwritten.
1895 */
1896 sta_ds->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
1897 /* Send Deauthentication frame to peer entity */
1898 lim_send_deauth_mgmt_frame(mac_ctx, mlm_deauth_req->reasonCode,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001899 mlm_deauth_req->peer_macaddr.bytes,
1900 session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 return;
1902end:
Anurag Chouhanc5548422016-02-24 18:33:27 +05301903 qdf_copy_macaddr(&mlm_deauth_cnf.peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001904 &mlm_deauth_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905 mlm_deauth_cnf.deauthTrigger = mlm_deauth_req->deauthTrigger;
1906 mlm_deauth_cnf.aid = mlm_deauth_req->aid;
1907 mlm_deauth_cnf.sessionId = mlm_deauth_req->sessionId;
1908
1909 /* Free up buffer allocated for mlmDeauthReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301910 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 lim_post_sme_message(mac_ctx,
1912 LIM_MLM_DEAUTH_CNF, (uint32_t *) &mlm_deauth_cnf);
1913}
1914
1915/*
1916 * lim_process_deauth_ack_timeout() - wrapper function around
1917 * lim_send_deauth_cnf
1918 *
1919 * @mac_ctx: mac_ctx
1920 *
1921 * wrapper function around lim_send_deauth_cnf
1922 *
1923 * Return: void
1924 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001925void lim_process_deauth_ack_timeout(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 lim_send_deauth_cnf(mac_ctx);
1928}
1929
1930/*
1931 * lim_process_mlm_deauth_req() - This function is called to process
1932 * MLM_DEAUTH_REQ message from SME
1933 *
1934 * @mac_ctx: Pointer to Global MAC structure
1935 * @msg_buf: A pointer to the MLM message buffer
1936 *
1937 * This function is called to process MLM_DEAUTH_REQ message from SME
1938 *
1939 * @Return: None
1940 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001941void lim_process_mlm_deauth_req(struct mac_context *mac_ctx, uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942{
1943 tLimMlmDeauthReq *mlm_deauth_req;
Jeff Johnsona7071e62018-11-18 22:55:45 -08001944 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945
1946 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001947 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 return;
1949 }
1950
1951 mlm_deauth_req = (tLimMlmDeauthReq *) msg_buf;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001952 pe_debug("Process Deauth Req on sessionID %d from: "
1953 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 mlm_deauth_req->sessionId,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08001955 MAC_ADDR_ARRAY(mlm_deauth_req->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956
1957 session = pe_find_session_by_session_id(mac_ctx,
1958 mlm_deauth_req->sessionId);
1959 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001960 pe_err("session does not exist for given sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 mlm_deauth_req->sessionId);
Krunal Sonif7387bd2017-11-06 15:48:01 -08001962 qdf_mem_free(mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 return;
1964 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301965 lim_process_mlm_deauth_req_ntf(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 (uint32_t *) msg_buf);
1967}
1968
1969/**
1970 * lim_process_mlm_set_keys_req() - This function is called to process
1971 * MLM_SETKEYS_REQ message from SME
1972 *
1973 * @mac_ctx: Pointer to Global MAC structure
1974 * @msg_buf: A pointer to the MLM message buffer
1975 *
1976 * This function is called to process MLM_SETKEYS_REQ message from SME
1977 *
1978 * @Return: None
1979 */
1980static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001981lim_process_mlm_set_keys_req(struct mac_context *mac_ctx, uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982{
1983 uint16_t aid;
1984 uint16_t sta_idx = 0;
1985 uint32_t default_key_id = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301986 struct qdf_mac_addr curr_bssid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 tpDphHashNode sta_ds;
1988 tLimMlmSetKeysReq *mlm_set_keys_req;
1989 tLimMlmSetKeysCnf mlm_set_keys_cnf;
Jeff Johnsona7071e62018-11-18 22:55:45 -08001990 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991
1992 if (msg_buf == NULL) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07001993 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 return;
1995 }
1996
1997 mlm_set_keys_req = (tLimMlmSetKeysReq *) msg_buf;
Jingxiang Ge4168a232018-01-03 18:47:15 +08001998 if (mac_ctx->lim.gpLimMlmSetKeysReq != NULL) {
1999 qdf_mem_free(mac_ctx->lim.gpLimMlmSetKeysReq);
2000 mac_ctx->lim.gpLimMlmSetKeysReq = NULL;
2001 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 /* Hold onto the SetKeys request parameters */
2003 mac_ctx->lim.gpLimMlmSetKeysReq = (void *)mlm_set_keys_req;
2004 session = pe_find_session_by_session_id(mac_ctx,
2005 mlm_set_keys_req->sessionId);
2006 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002007 pe_err("session does not exist for given sessionId");
Krunal Soni7d787082017-11-07 10:30:11 -08002008 qdf_mem_free(mlm_set_keys_req);
2009 mac_ctx->lim.gpLimMlmSetKeysReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 return;
2011 }
2012
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002013 pe_debug("Received MLM_SETKEYS_REQ with parameters:"
2014 "AID [%d], ED Type [%d], # Keys [%d] & Peer MAC Addr - ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 mlm_set_keys_req->aid, mlm_set_keys_req->edType,
2016 mlm_set_keys_req->numKeys);
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07002017 lim_print_mac_addr(mac_ctx, mlm_set_keys_req->peer_macaddr.bytes, LOGD);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302018 qdf_mem_copy(curr_bssid.bytes, session->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019
2020 switch (GET_LIM_SYSTEM_ROLE(session)) {
2021 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 /*
2023 * In case of TDLS, peerMac address need not be BssId. Skip this
2024 * check if TDLS is enabled.
2025 */
2026#ifndef FEATURE_WLAN_TDLS
Anurag Chouhanc5548422016-02-24 18:33:27 +05302027 if ((!qdf_is_macaddr_broadcast(
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002028 &mlm_set_keys_req->peer_macaddr)) &&
Anurag Chouhanc5548422016-02-24 18:33:27 +05302029 (!qdf_is_macaddr_equal(&mlm_set_keys_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002030 &curr_bssid))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002031 pe_debug("Received MLM_SETKEYS_REQ with invalid BSSID"
2032 MAC_ADDRESS_STR,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002033 MAC_ADDR_ARRAY(mlm_set_keys_req->
2034 peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 /*
2036 * Prepare and Send LIM_MLM_SETKEYS_CNF with error code
2037 */
2038 mlm_set_keys_cnf.resultCode =
2039 eSIR_SME_INVALID_PARAMETERS;
2040 goto end;
2041 }
2042#endif
2043 break;
2044 case eLIM_STA_IN_IBSS_ROLE:
2045 /*
2046 * update the IBSS PE session encrption type based on the
2047 * key type
2048 */
2049 session->encryptType = mlm_set_keys_req->edType;
2050 break;
2051 default:
2052 break;
2053 }
2054
2055 /*
2056 * Use the "unicast" parameter to determine if the "Group Keys"
2057 * are being set.
2058 * mlm_set_keys_req->key.unicast = 0 -> Multicast/broadcast
2059 * mlm_set_keys_req->key.unicast - 1 -> Unicast keys are being set
2060 */
Anurag Chouhanc5548422016-02-24 18:33:27 +05302061 if (qdf_is_macaddr_broadcast(&mlm_set_keys_req->peer_macaddr)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002062 pe_debug("Trying to set Group Keys...%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 mlm_set_keys_req->sessionId);
2064 /*
2065 * When trying to set Group Keys for any security mode other
2066 * than WEP, use the STA Index corresponding to the AP...
2067 */
2068 switch (mlm_set_keys_req->edType) {
2069 case eSIR_ED_CCMP:
Mukul Sharma05504ac2017-06-08 12:35:53 +05302070 case eSIR_ED_GCMP:
2071 case eSIR_ED_GCMP_256:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072#ifdef WLAN_FEATURE_11W
2073 case eSIR_ED_AES_128_CMAC:
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05302074 case eSIR_ED_AES_GMAC_128:
2075 case eSIR_ED_AES_GMAC_256:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076#endif
2077 sta_idx = session->staId;
2078 break;
2079 default:
2080 break;
2081 }
2082 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002083 pe_debug("Trying to set Unicast Keys...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 /*
2085 * Check if there exists a context for the
2086 * peer entity for which keys need to be set.
2087 */
2088 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002089 mlm_set_keys_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 &session->dph.dphHashTable);
2091 if ((sta_ds == NULL) ||
2092 ((sta_ds->mlmStaContext.mlmState !=
2093 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
2094 !LIM_IS_AP_ROLE(session))) {
2095 /*
2096 * Received LIM_MLM_SETKEYS_REQ for STA that does not
2097 * have context or in some transit state.
2098 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002099 pe_debug("Invalid MLM_SETKEYS_REQ, Addr = "
2100 MAC_ADDRESS_STR,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002101 MAC_ADDR_ARRAY(mlm_set_keys_req->
2102 peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 /* Prepare and Send LIM_MLM_SETKEYS_CNF */
2104 mlm_set_keys_cnf.resultCode =
2105 eSIR_SME_INVALID_PARAMETERS;
2106 goto end;
2107 } else {
2108 sta_idx = sta_ds->staIndex;
2109 }
2110 }
2111
2112 if ((mlm_set_keys_req->numKeys == 0)
2113 && (mlm_set_keys_req->edType != eSIR_ED_NONE)) {
2114 /*
2115 * Broadcast/Multicast Keys (for WEP!!) are NOT sent
2116 * via this interface!! This indicates to HAL that the WEP Keys
2117 * need to be extracted from the CFG and applied to hardware
2118 */
2119 default_key_id = 0xff;
2120 } else if (mlm_set_keys_req->key[0].keyId &&
2121 ((mlm_set_keys_req->edType == eSIR_ED_WEP40) ||
2122 (mlm_set_keys_req->edType == eSIR_ED_WEP104))) {
2123 /*
2124 * If the Key Id is non zero and encryption mode is WEP,
2125 * the key index is coming from the upper layers so that key
2126 * only need to be used as the default tx key, This is being
2127 * used only in case of WEP mode in HAL
2128 */
2129 default_key_id = mlm_set_keys_req->key[0].keyId;
2130 } else {
2131 default_key_id = 0;
2132 }
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002133 pe_debug("Trying to set keys for STA Index [%d], using default_key_id [%d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 sta_idx, default_key_id);
2135
Anurag Chouhanc5548422016-02-24 18:33:27 +05302136 if (qdf_is_macaddr_broadcast(&mlm_set_keys_req->peer_macaddr)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 session->limPrevMlmState = session->limMlmState;
2138 session->limMlmState = eLIM_MLM_WT_SET_BSS_KEY_STATE;
2139 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2140 session->peSessionId, session->limMlmState));
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002141 pe_debug("Trying to set Group Keys...%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 session->peSessionId);
2143 /* Package WMA_SET_BSSKEY_REQ message parameters */
2144 lim_send_set_bss_key_req(mac_ctx, mlm_set_keys_req, session);
2145 return;
2146 } else {
2147 /*
2148 * Package WMA_SET_STAKEY_REQ / WMA_SET_STA_BCASTKEY_REQ message
2149 * parameters
2150 */
2151 lim_send_set_sta_key_req(mac_ctx, mlm_set_keys_req, sta_idx,
2152 (uint8_t) default_key_id, session,
2153 true);
2154 return;
2155 }
2156end:
2157 mlm_set_keys_cnf.sessionId = mlm_set_keys_req->sessionId;
2158 lim_post_sme_set_keys_cnf(mac_ctx, mlm_set_keys_req, &mlm_set_keys_cnf);
2159}
Sandeep Puligilla06ae8902018-04-16 19:02:47 -07002160
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002161void lim_process_join_failure_timeout(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162{
2163 tLimMlmJoinCnf mlm_join_cnf;
2164 uint32_t len;
2165#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2166 host_log_rssi_pkt_type *rssi_log = NULL;
2167#endif
Jeff Johnsona7071e62018-11-18 22:55:45 -08002168 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169
2170 session = pe_find_session_by_session_id(mac_ctx,
2171 mac_ctx->lim.limTimers.gLimJoinFailureTimer.sessionId);
2172 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002173 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174 return;
2175 }
2176#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2177 WLAN_HOST_DIAG_LOG_ALLOC(rssi_log,
2178 host_log_rssi_pkt_type, LOG_WLAN_RSSI_UPDATE_C);
2179 if (rssi_log)
2180 rssi_log->rssi = session->rssi;
2181 WLAN_HOST_DIAG_LOG_REPORT(rssi_log);
2182#endif
2183
2184 if (session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE) {
2185 len = sizeof(tSirMacAddr);
2186 /* Change timer for future activations */
2187 lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER);
2188 /* Change Periodic probe req timer for future activation */
2189 lim_deactivate_and_change_timer(mac_ctx,
2190 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
2191 /* Issue MLM join confirm with timeout reason code */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002192 pe_err("Join Failure Timeout, In eLIM_MLM_WT_JOIN_BEACON_STATE session:%d "
2193 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 session->peSessionId, MAC_ADDR_ARRAY(session->bssId));
2195
2196 mlm_join_cnf.resultCode = eSIR_SME_JOIN_TIMEOUT_RESULT_CODE;
2197 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2198 session->limMlmState = eLIM_MLM_IDLE_STATE;
2199 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2200 session->peSessionId, session->limMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 /* Update PE session Id */
2202 mlm_join_cnf.sessionId = session->peSessionId;
2203 /* Freeup buffer allocated to join request */
2204 if (session->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302205 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 session->pLimMlmJoinReq = NULL;
2207 }
2208 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
2209 (uint32_t *) &mlm_join_cnf);
2210 return;
2211 } else {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002212 pe_warn("received unexpected JOIN failure timeout in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 session->limMlmState);
2214 lim_print_mlm_state(mac_ctx, LOGW, session->limMlmState);
2215 }
2216}
2217
2218/**
2219 * lim_process_periodic_join_probe_req_timer() - This function is called to
2220 * process periodic probe request send during joining process.
2221 *
2222 * @mac_ctx: Pointer to Global MAC structure
2223 *
2224 * This function is called to process periodic probe request send during
2225 * joining process.
2226 *
2227 * @Return None
2228 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002229static void lim_process_periodic_join_probe_req_timer(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230{
Jeff Johnsona7071e62018-11-18 22:55:45 -08002231 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 tSirMacSSid ssid;
2233
2234 session = pe_find_session_by_session_id(mac_ctx,
2235 mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId);
2236 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002237 pe_err("session does not exist for given SessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer.
2239 sessionId);
2240 return;
2241 }
2242
2243 if ((true ==
2244 tx_timer_running(&mac_ctx->lim.limTimers.gLimJoinFailureTimer))
2245 && (session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302246 qdf_mem_copy(ssid.ssId, session->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 session->ssId.length);
2248 ssid.length = session->ssId.length;
2249 lim_send_probe_req_mgmt_frame(mac_ctx, &ssid,
2250 session->pLimMlmJoinReq->bssDescription.bssId,
2251 session->currentOperChannel /*chanNum */,
2252 session->selfMacAddr, session->dot11mode,
Sandeep Puligilla06ae8902018-04-16 19:02:47 -07002253 &session->pLimJoinReq->addIEScan.length,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 session->pLimJoinReq->addIEScan.addIEdata);
2255 lim_deactivate_and_change_timer(mac_ctx,
2256 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
2257 /* Activate Join Periodic Probe Req timer */
2258 if (tx_timer_activate(
2259 &mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer) !=
2260 TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002261 pe_warn("could not activate Periodic Join req failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262 return;
2263 }
2264 }
2265}
2266
2267/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302268 * lim_process_auth_retry_timer()- function to Retry Auth
2269 * @mac_ctx:pointer to global mac
2270 *
2271 * Return: void
2272 */
2273
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002274static void lim_process_auth_retry_timer(struct mac_context *mac_ctx)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302275{
Jeff Johnsona7071e62018-11-18 22:55:45 -08002276 struct pe_session * session_entry;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302277
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302278 session_entry =
2279 pe_find_session_by_session_id(mac_ctx,
2280 mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer.sessionId);
2281 if (NULL == session_entry) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002282 pe_err("session does not exist for given SessionId: %d",
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302283 mac_ctx->lim.limTimers.
2284 g_lim_periodic_auth_retry_timer.sessionId);
2285 return;
2286 }
2287
2288 if (tx_timer_running(&mac_ctx->lim.limTimers.gLimAuthFailureTimer) &&
2289 (session_entry->limMlmState == eLIM_MLM_WT_AUTH_FRAME2_STATE) &&
2290 (LIM_AUTH_ACK_RCD_SUCCESS != mac_ctx->auth_ack_status)) {
2291 tSirMacAuthFrameBody auth_frame;
2292
2293 /*
2294 * Send the auth retry only in case we have received ack failure
2295 * else just restart the retry timer.
2296 */
2297 if (LIM_AUTH_ACK_RCD_FAILURE == mac_ctx->auth_ack_status) {
2298 /* Prepare & send Authentication frame */
2299 auth_frame.authAlgoNumber =
2300 (uint8_t) mac_ctx->lim.gpLimMlmAuthReq->authType;
2301 auth_frame.authTransactionSeqNumber =
2302 SIR_MAC_AUTH_FRAME_1;
2303 auth_frame.authStatusCode = 0;
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002304 pe_debug("Retry Auth");
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302305 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302306 lim_increase_fils_sequence_number(session_entry);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302307 lim_send_auth_mgmt_frame(mac_ctx,
2308 &auth_frame,
2309 mac_ctx->lim.gpLimMlmAuthReq->peerMacAddr,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302310 LIM_NO_WEP_IN_FC, session_entry);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302311 }
2312
2313 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2314
2315 /* Activate Auth Retry timer */
2316 if (tx_timer_activate
2317 (&mac_ctx->lim.limTimers.g_lim_periodic_auth_retry_timer)
2318 != TX_SUCCESS) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002319 pe_err("could not activate Auth Retry failure timer");
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302320 return;
2321 }
2322 }
2323 return;
2324} /*** lim_process_auth_retry_timer() ***/
2325
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002326void lim_process_auth_failure_timeout(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002328 /* fetch the pe_session based on the sessionId */
Jeff Johnsona7071e62018-11-18 22:55:45 -08002329 struct pe_session *session;
Arif Hussain43e09712018-09-18 19:31:57 -07002330 uint32_t val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2332 host_log_rssi_pkt_type *rssi_log = NULL;
2333#endif
2334
2335 session = pe_find_session_by_session_id(mac_ctx,
2336 mac_ctx->lim.limTimers.gLimAuthFailureTimer.sessionId);
2337 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002338 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 return;
2340 }
2341
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002342 pe_warn("received AUTH failure timeout in sessionid %d "
2343 "limMlmstate %X limSmeState %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 session->peSessionId, session->limMlmState,
2345 session->limSmeState);
2346#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Padma, Santhosh Kumare7835652016-08-10 19:11:40 +05302347 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_TIMEOUT, session,
2348 0, AUTH_FAILURE_TIMEOUT);
2349
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 WLAN_HOST_DIAG_LOG_ALLOC(rssi_log, host_log_rssi_pkt_type,
2351 LOG_WLAN_RSSI_UPDATE_C);
2352 if (rssi_log)
2353 rssi_log->rssi = session->rssi;
2354 WLAN_HOST_DIAG_LOG_REPORT(rssi_log);
2355#endif
2356
2357 switch (session->limMlmState) {
2358 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
2359 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
2360 /*
2361 * Requesting STA did not receive next auth frame before Auth
2362 * Failure timeout. Issue MLM auth confirm with timeout reason
2363 * code. Restore default failure timeout
2364 */
Arif Hussain43e09712018-09-18 19:31:57 -07002365 if (QDF_P2P_CLIENT_MODE == session->pePersona &&
2366 session->defaultAuthFailureTimeout) {
2367 if (cfg_in_range(CFG_AUTH_FAILURE_TIMEOUT,
2368 session->defaultAuthFailureTimeout)) {
2369 val = session->defaultAuthFailureTimeout;
2370 } else {
2371 val = cfg_default(CFG_AUTH_FAILURE_TIMEOUT);
2372 session->defaultAuthFailureTimeout = val;
2373 }
2374 mac_ctx->mlme_cfg->timeouts.auth_failure_timeout = val;
2375 }
2376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 lim_restore_from_auth_state(mac_ctx,
2378 eSIR_SME_AUTH_TIMEOUT_RESULT_CODE,
2379 eSIR_MAC_UNSPEC_FAILURE_REASON, session);
2380 break;
2381 default:
2382 /*
2383 * Auth failure timer should not have timed out
2384 * in states other than wt_auth_frame2/4
2385 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002386 pe_err("received unexpected AUTH failure timeout in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 session->limMlmState);
2388 lim_print_mlm_state(mac_ctx, LOGE, session->limMlmState);
2389 break;
2390 }
2391}
2392
2393/**
2394 * lim_process_auth_rsp_timeout() - This function is called to process Min
2395 * Channel Timeout during channel scan.
2396 *
2397 * @mac_ctx: Pointer to Global MAC structure
2398 *
2399 * This function is called to process Min Channel Timeout during channel scan.
2400 *
2401 * @Return: None
2402 */
2403static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002404lim_process_auth_rsp_timeout(struct mac_context *mac_ctx, uint32_t auth_idx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405{
2406 struct tLimPreAuthNode *auth_node;
Jeff Johnsona7071e62018-11-18 22:55:45 -08002407 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 uint8_t session_id;
2409
2410 auth_node = lim_get_pre_auth_node_from_index(mac_ctx,
2411 &mac_ctx->lim.gLimPreAuthTimerTable, auth_idx);
2412 if (NULL == auth_node) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002413 pe_warn("Invalid auth node");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 return;
2415 }
2416
2417 session = pe_find_session_by_bssid(mac_ctx, auth_node->peerMacAddr,
2418 &session_id);
2419 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002420 pe_warn("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 return;
2422 }
2423
Padma, Santhosh Kumare7835652016-08-10 19:11:40 +05302424#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2425 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_TIMEOUT,
2426 session, 0, AUTH_RESPONSE_TIMEOUT);
2427#endif
2428
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) {
2430 if (auth_node->mlmState != eLIM_MLM_WT_AUTH_FRAME3_STATE) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002431 pe_err("received AUTH rsp timeout in unexpected "
2432 "state for MAC address: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 MAC_ADDR_ARRAY(auth_node->peerMacAddr));
2434 } else {
2435 auth_node->mlmState = eLIM_MLM_AUTH_RSP_TIMEOUT_STATE;
2436 auth_node->fTimerStarted = 0;
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002437 pe_debug("AUTH rsp timedout for MAC address "
2438 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 MAC_ADDR_ARRAY(auth_node->peerMacAddr));
2440 /* Change timer to reactivate it in future */
2441 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
2442 eLIM_AUTH_RSP_TIMER, auth_node->authNodeIdx);
2443 lim_delete_pre_auth_node(mac_ctx,
2444 auth_node->peerMacAddr);
2445 }
2446 }
2447}
2448
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002449void lim_process_assoc_failure_timeout(struct mac_context *mac_ctx,
Abhishek Singh6a730172017-12-29 14:07:21 +05302450 uint32_t msg_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451{
2452
2453 tLimMlmAssocCnf mlm_assoc_cnf;
Jeff Johnsona7071e62018-11-18 22:55:45 -08002454 struct pe_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
2456 host_log_rssi_pkt_type *rssi_log = NULL;
2457#endif
2458 /*
2459 * to fetch the lim/mlm state based on the session_id, use the
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002460 * below pe_session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 */
2462 uint8_t session_id;
2463
2464 if (msg_type == LIM_ASSOC)
2465 session_id =
2466 mac_ctx->lim.limTimers.gLimAssocFailureTimer.sessionId;
2467 else
2468 session_id =
2469 mac_ctx->lim.limTimers.gLimReassocFailureTimer.sessionId;
2470
2471 session = pe_find_session_by_session_id(mac_ctx, session_id);
2472 if (NULL == session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002473 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 return;
2475 }
2476#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Padma, Santhosh Kumare7835652016-08-10 19:11:40 +05302477 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_TIMEOUT,
2478 session, 0, 0);
2479
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 WLAN_HOST_DIAG_LOG_ALLOC(rssi_log,
2481 host_log_rssi_pkt_type,
2482 LOG_WLAN_RSSI_UPDATE_C);
2483 if (rssi_log)
2484 rssi_log->rssi = session->rssi;
2485 WLAN_HOST_DIAG_LOG_REPORT(rssi_log);
2486#endif
2487
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002488 pe_debug("Re/Association Response not received before timeout");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489
Abhishek Singhe36aa822016-04-27 16:55:43 +05302490 /*
2491 * Send Deauth to handle the scenareo where association timeout happened
2492 * when device has missed the assoc resp sent by peer.
2493 * By sending deauth try to clear the session created on peer device.
2494 */
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002495 pe_debug("Sessionid: %d try sending deauth on channel %d to BSSID: "
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002496 MAC_ADDRESS_STR, session->peSessionId,
Abhishek Singhe36aa822016-04-27 16:55:43 +05302497 session->currentOperChannel,
2498 MAC_ADDR_ARRAY(session->bssId));
2499 lim_send_deauth_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_REASON,
2500 session->bssId, session, false);
2501
Rajeev Kumaraa262c42016-04-15 15:41:08 -07002502 if ((LIM_IS_AP_ROLE(session)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 ((session->limMlmState != eLIM_MLM_WT_ASSOC_RSP_STATE) &&
2504 (session->limMlmState != eLIM_MLM_WT_REASSOC_RSP_STATE) &&
2505 (session->limMlmState != eLIM_MLM_WT_FT_REASSOC_RSP_STATE))) {
2506 /*
2507 * Re/Assoc failure timer should not have timedout on AP
2508 * or in a state other than wt_re/assoc_response.
2509 */
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002510 pe_warn("received unexpected REASSOC failure timeout in state %X for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511 session->limMlmState,
2512 GET_LIM_SYSTEM_ROLE(session));
2513 lim_print_mlm_state(mac_ctx, LOGW, session->limMlmState);
2514 return;
2515 }
2516
2517 if ((msg_type == LIM_ASSOC) || ((msg_type == LIM_REASSOC)
2518 && (session->limMlmState == eLIM_MLM_WT_FT_REASSOC_RSP_STATE))) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002519 pe_err("(Re)Assoc Failure Timeout occurred");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 session->limMlmState = eLIM_MLM_IDLE_STATE;
2521 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2522 session->peSessionId, session->limMlmState));
2523 /* Change timer for future activations */
2524 lim_deactivate_and_change_timer(mac_ctx, eLIM_ASSOC_FAIL_TIMER);
2525 /*
2526 * Free up buffer allocated for JoinReq held by
2527 * MLM state machine
2528 */
2529 if (session->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302530 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531 session->pLimMlmJoinReq = NULL;
2532 }
2533 /* To remove the preauth node in case of fail to associate */
2534 if (lim_search_pre_auth_list(mac_ctx, session->bssId)) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002535 pe_debug("delete pre auth node for "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 MAC_ADDR_ARRAY(session->bssId));
2537 lim_delete_pre_auth_node(mac_ctx,
2538 session->bssId);
2539 }
2540
2541 mlm_assoc_cnf.resultCode = eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE;
2542 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
2543 /* Update PE session Id */
2544 mlm_assoc_cnf.sessionId = session->peSessionId;
2545 if (msg_type == LIM_ASSOC) {
2546 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2547 (uint32_t *) &mlm_assoc_cnf);
2548 } else {
2549 /*
2550 * Will come here only in case of 11r, Ese FT
2551 * when reassoc rsp is not received and we
2552 * receive a reassoc - timesout
2553 */
2554 mlm_assoc_cnf.resultCode =
2555 eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE;
2556 lim_post_sme_message(mac_ctx, LIM_MLM_REASSOC_CNF,
2557 (uint32_t *) &mlm_assoc_cnf);
2558 }
2559 } else {
2560 /*
2561 * Restore pre-reassoc req state.
2562 * Set BSSID to currently associated AP address.
2563 */
2564 session->limMlmState = session->limPrevMlmState;
2565 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2566 session->peSessionId, session->limMlmState));
2567 lim_restore_pre_reassoc_state(mac_ctx,
2568 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE,
2569 eSIR_MAC_UNSPEC_FAILURE_STATUS, session);
2570 }
2571}
2572
2573/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 * lim_set_channel() - set channel api for lim
2575 *
2576 * @mac_ctx: Pointer to Global MAC structure
2577 * @channel: power save state
2578 * @ch_center_freq_seg0: center freq seq 0
2579 * @ch_center_freq_seg1: center freq seq 1
2580 * @ch_width: channel width
2581 * @max_tx_power: max tx power
2582 * @pe_session_id: pe session id
2583 *
2584 * set channel api for lim
2585 *
2586 * @Return: None
2587 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002588void lim_set_channel(struct mac_context *mac_ctx, uint8_t channel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 uint8_t ch_center_freq_seg0, uint8_t ch_center_freq_seg1,
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002590 enum phy_ch_width ch_width, int8_t max_tx_power,
Arif Hussain671a1902017-03-17 09:08:32 -07002591 uint8_t pe_session_id, uint32_t cac_duration_ms,
2592 uint32_t dfs_regdomain)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593{
Jeff Johnsona7071e62018-11-18 22:55:45 -08002594 struct pe_session *pe_session;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 pe_session = pe_find_session_by_session_id(mac_ctx, pe_session_id);
2597
2598 if (NULL == pe_session) {
Srinivas Girigowdaf5b000d2017-03-26 18:30:59 -07002599 pe_err("Invalid PE session: %d", pe_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 return;
2601 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 lim_send_switch_chnl_params(mac_ctx, channel, ch_center_freq_seg0,
2603 ch_center_freq_seg1, ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07002604 max_tx_power, pe_session_id, false,
2605 cac_duration_ms, dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606}