blob: b4d81f7ea72b199f289968e2b88aa42aae188f1d [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302 * Copyright (c) 2012-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 "wni_api.h"
20#include "wni_cfg.h"
21#include "cfg_api.h"
22#include "sir_api.h"
23#include "sch_api.h"
24#include "utils_api.h"
25#include "lim_utils.h"
26#include "lim_assoc_utils.h"
27#include "lim_security_utils.h"
28#include "lim_ser_des_utils.h"
29#include "lim_timer_utils.h"
30#include "lim_send_messages.h"
31#include "lim_admit_control.h"
32#include "lim_send_messages.h"
33#include "lim_ibss_peer_mgmt.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080034#include "lim_ft.h"
35#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#include "lim_session.h"
37#include "lim_session_utils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039#include "wma_types.h"
40#include "cds_utils.h"
41#include "lim_types.h"
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -080042#include "wlan_policy_mgr_api.h"
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070043#include "nan_datapath.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070044#include "wlan_reg_services_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045
46#define MAX_SUPPORTED_PEERS_WEP 16
47
Jeff Johnson9320c1e2018-12-02 13:09:20 -080048void lim_process_mlm_join_cnf(struct mac_context *, uint32_t *);
49void lim_process_mlm_auth_cnf(struct mac_context *, uint32_t *);
50void lim_process_mlm_assoc_ind(struct mac_context *, uint32_t *);
51void lim_process_mlm_assoc_cnf(struct mac_context *, uint32_t *);
52void lim_process_mlm_reassoc_ind(struct mac_context *, uint32_t *);
53void lim_process_mlm_set_keys_cnf(struct mac_context *, uint32_t *);
54void lim_process_mlm_disassoc_ind(struct mac_context *, uint32_t *);
55void lim_process_mlm_disassoc_cnf(struct mac_context *, uint32_t *);
56static void lim_process_mlm_deauth_ind(struct mac_context *, tLimMlmDeauthInd *);
57void lim_process_mlm_deauth_cnf(struct mac_context *, uint32_t *);
58void lim_process_mlm_purge_sta_ind(struct mac_context *, uint32_t *);
59void lim_get_session_info(struct mac_context *mac, uint8_t *, uint8_t *,
Rajeev Kumaraa262c42016-04-15 15:41:08 -070060 uint16_t *);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061/**
62 * lim_process_mlm_rsp_messages()
63 *
64 ***FUNCTION:
65 * This function is called to processes various MLM response (CNF/IND
66 * messages from MLM State machine.
67 *
68 ***LOGIC:
69 *
70 ***ASSUMPTIONS:
71 *
72 ***NOTE:
73 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -080074 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075 * @param msgType Indicates the MLM message type
76 * @param *pMsgBuf A pointer to the MLM message buffer
77 *
78 * @return None
79 */
80void
Jeff Johnson9320c1e2018-12-02 13:09:20 -080081lim_process_mlm_rsp_messages(struct mac_context *mac, uint32_t msgType,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082 uint32_t *pMsgBuf)
83{
84
85 if (pMsgBuf == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -070086 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087 return;
88 }
Jeff Johnsonb97bdce2018-11-22 12:27:32 -080089 MTRACE(mac_trace(mac, TRACE_CODE_TX_LIM_MSG, 0, msgType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090 switch (msgType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 case LIM_MLM_AUTH_CNF:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -080092 lim_process_mlm_auth_cnf(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093 break;
94 case LIM_MLM_ASSOC_CNF:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -080095 lim_process_mlm_assoc_cnf(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096 break;
97 case LIM_MLM_START_CNF:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -080098 lim_process_mlm_start_cnf(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099 break;
100 case LIM_MLM_JOIN_CNF:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800101 lim_process_mlm_join_cnf(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102 break;
103 case LIM_MLM_ASSOC_IND:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800104 lim_process_mlm_assoc_ind(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800105 break;
106 case LIM_MLM_REASSOC_CNF:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800107 lim_process_mlm_reassoc_cnf(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108 break;
109 case LIM_MLM_DISASSOC_CNF:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800110 lim_process_mlm_disassoc_cnf(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 break;
112 case LIM_MLM_DISASSOC_IND:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800113 lim_process_mlm_disassoc_ind(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 break;
115 case LIM_MLM_PURGE_STA_IND:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800116 lim_process_mlm_purge_sta_ind(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117 break;
118 case LIM_MLM_DEAUTH_CNF:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800119 lim_process_mlm_deauth_cnf(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120 break;
121 case LIM_MLM_DEAUTH_IND:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800122 lim_process_mlm_deauth_ind(mac, (tLimMlmDeauthInd *)pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123 break;
124 case LIM_MLM_SETKEYS_CNF:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800125 lim_process_mlm_set_keys_cnf(mac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800126 break;
127 case LIM_MLM_TSPEC_CNF:
128 break;
129 default:
130 break;
131 } /* switch (msgType) */
132 return;
133} /*** end lim_process_mlm_rsp_messages() ***/
134
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135/**
136 * lim_process_mlm_start_cnf()
137 *
138 ***FUNCTION:
139 * This function is called to processes MLM_START_CNF
140 * message from MLM State machine.
141 *
142 ***LOGIC:
143 *
144 ***ASSUMPTIONS:
145 *
146 ***NOTE:
147 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800148 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 * @param pMsgBuf A pointer to the MLM message buffer
150 *
151 * @return None
152 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800153void lim_process_mlm_start_cnf(struct mac_context *mac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154{
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800155 struct pe_session *pe_session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 tLimMlmStartCnf *pLimMlmStartCnf;
157 uint8_t smesessionId;
158 uint16_t smetransactionId;
159 uint8_t channelId;
Sandeep Puligilla949eaa72015-12-17 18:43:52 -0800160 uint8_t send_bcon_ind = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161
162 if (pMsgBuf == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700163 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 return;
165 }
166 pLimMlmStartCnf = (tLimMlmStartCnf *) pMsgBuf;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800167 pe_session = pe_find_session_by_session_id(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 pLimMlmStartCnf->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800169 if (pe_session == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700170 pe_err("Session does Not exist with given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 return;
172 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800173 smesessionId = pe_session->smeSessionId;
174 smetransactionId = pe_session->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800176 if (pe_session->limSmeState != eLIM_SME_WT_START_BSS_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 /*
178 * Should not have received Start confirm from MLM
179 * in other states. Log error.
180 */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700181 pe_err("received unexpected MLM_START_CNF in state %X",
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800182 pe_session->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 return;
184 }
185 if (((tLimMlmStartCnf *) pMsgBuf)->resultCode == eSIR_SME_SUCCESS) {
186
187 /*
188 * Update global SME state so that Beacon Generation
189 * module starts writing Beacon frames into TFP's
190 * Beacon file register.
191 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800192 pe_session->limSmeState = eLIM_SME_NORMAL_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800194 (mac, TRACE_CODE_SME_STATE, pe_session->peSessionId,
195 pe_session->limSmeState));
196 if (pe_session->bssType == eSIR_INFRA_AP_MODE)
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700197 pe_debug("*** Started BSS in INFRA AP SIDE***");
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800198 else if (pe_session->bssType == eSIR_NDI_MODE)
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700199 pe_debug("*** Started BSS in NDI mode ***");
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700200 else
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700201 pe_debug("*** Started BSS ***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202 } else {
203 /* Start BSS is a failure */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800204 pe_delete_session(mac, pe_session);
205 pe_session = NULL;
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700206 pe_err("Start BSS Failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 }
208 /* Send response to Host */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800209 lim_send_sme_start_bss_rsp(mac, eWNI_SME_START_BSS_RSP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210 ((tLimMlmStartCnf *)pMsgBuf)->resultCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800211 pe_session, smesessionId, smetransactionId);
212 if ((pe_session != NULL) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 (((tLimMlmStartCnf *) pMsgBuf)->resultCode ==
214 eSIR_SME_SUCCESS)) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800215 channelId = pe_session->pLimStartBssReq->channelId;
216 lim_ndi_mlme_vdev_up_transition(pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217
218 /* We should start beacon transmission only if the channel
219 * on which we are operating is non-DFS until the channel
220 * availability check is done. The PE will receive an explicit
221 * request from upper layers to start the beacon transmission
222 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800223 if (!(LIM_IS_IBSS_ROLE(pe_session) ||
224 (LIM_IS_AP_ROLE(pe_session))))
Sandeep Puligilla949eaa72015-12-17 18:43:52 -0800225 return;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800226 if (pe_session->ch_width == CH_WIDTH_160MHZ) {
Sandeep Puligilla949eaa72015-12-17 18:43:52 -0800227 send_bcon_ind = false;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800228 } else if (pe_session->ch_width == CH_WIDTH_80P80MHZ) {
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800229 if ((wlan_reg_get_channel_state(mac->pdev, channelId)
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700230 != CHANNEL_STATE_DFS) &&
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800231 (wlan_reg_get_channel_state(mac->pdev,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800232 pe_session->ch_center_freq_seg1 -
Sandeep Puligilla949eaa72015-12-17 18:43:52 -0800233 SIR_80MHZ_START_CENTER_CH_DIFF) !=
234 CHANNEL_STATE_DFS))
235 send_bcon_ind = true;
236 } else {
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800237 if (wlan_reg_get_channel_state(mac->pdev, channelId)
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700238 != CHANNEL_STATE_DFS)
Sandeep Puligilla949eaa72015-12-17 18:43:52 -0800239 send_bcon_ind = true;
240 }
241 if (send_bcon_ind) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 /* Configure beacon and send beacons to HAL */
Abhishek Singh5d8d7332017-08-10 15:15:24 +0530243 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 FL("Start Beacon with ssid %s Ch %d"),
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800245 pe_session->ssId.ssId,
246 pe_session->currentOperChannel);
247 lim_send_beacon(mac, pe_session);
248 lim_enable_obss_detection_config(mac, pe_session);
249 lim_send_obss_color_collision_cfg(mac, pe_session,
Arif Hussain05fb4872018-01-03 16:02:55 -0800250 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251 }
252 }
253}
254
255/*** end lim_process_mlm_start_cnf() ***/
256
257/**
258 * lim_process_mlm_join_cnf() - Processes join confirmation
259 * @mac_ctx: Pointer to Global MAC structure
260 * @msg: A pointer to the MLM message buffer
261 *
262 * This Function handles the join confirmation message
263 * LIM_MLM_JOIN_CNF.
264 *
265 * Return: None
266 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800267void lim_process_mlm_join_cnf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268 uint32_t *msg)
269{
270 tSirResultCodes result_code;
271 tLimMlmJoinCnf *join_cnf;
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -0800272 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273
274 join_cnf = (tLimMlmJoinCnf *) msg;
275 session_entry = pe_find_session_by_session_id(mac_ctx,
276 join_cnf->sessionId);
277 if (session_entry == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700278 pe_err("SessionId:%d does not exist", join_cnf->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 return;
280 }
281
282 if (session_entry->limSmeState != eLIM_SME_WT_JOIN_STATE) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700283 pe_err("received unexpected MLM_JOIN_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 session_entry->limSmeState);
285 return;
286 }
287
288 result_code = ((tLimMlmJoinCnf *) msg)->resultCode;
289 /* Process Join confirm from MLM */
290 if (result_code == eSIR_SME_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700291 pe_debug("***SessionId:%d Joined ESS ***",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 join_cnf->sessionId);
293 /* Setup hardware upfront */
294 if (lim_sta_send_add_bss_pre_assoc(mac_ctx, false,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700295 session_entry) == QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296 return;
297 else
298 result_code = eSIR_SME_REFUSED;
299 }
300
301 /* Join failure */
302 session_entry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
303 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
304 session_entry->peSessionId,
305 session_entry->limSmeState));
306 /* Send Join response to Host */
307 lim_handle_sme_join_result(mac_ctx, result_code,
308 ((tLimMlmJoinCnf *) msg)->protStatusCode, session_entry);
309 return;
310}
311
312/**
313 * lim_send_mlm_assoc_req() - Association request will be processed
314 * mac_ctx: Pointer to Global MAC structure
315 * session_entry: Pointer to session etnry
316 *
317 * This function is sends ASSOC request MLM message to MLM State machine.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800318 * ASSOC request packet would be by picking parameters from pe_session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 * automatically based on the current state of MLM state machine.
320 * ASSUMPTIONS:
321 * this function is called in middle of connection state machine and is
322 * expected to be called after auth cnf has been received or after ASSOC rsp
323 * with TRY_AGAIN_LATER was received and required time has elapsed after that.
324 *
325 * Return: None
326 */
327
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800328static void lim_send_mlm_assoc_req(struct mac_context *mac_ctx,
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -0800329 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330{
331 tLimMlmAssocReq *assoc_req;
332 uint32_t val;
333 uint16_t caps;
334 uint32_t tele_bcn = 0;
335 tpSirMacCapabilityInfo cap_info;
336
337 /* Successful MAC based authentication. Trigger Association with BSS */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700338 pe_debug("SessionId: %d Authenticated with BSS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 session_entry->peSessionId);
340
341 if (NULL == session_entry->pLimJoinReq) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700342 pe_err("Join Request is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343 /* No need to Assert. JOIN timeout will handle this error */
344 return;
345 }
346
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530347 assoc_req = qdf_mem_malloc(sizeof(tLimMlmAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 if (NULL == assoc_req) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700349 pe_err("call to AllocateMemory failed for mlmAssocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350 return;
351 }
352 val = sizeof(tSirMacAddr);
353 sir_copy_mac_addr(assoc_req->peerMacAddr, session_entry->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354
355 if (cfg_get_capability_info(mac_ctx, &caps, session_entry)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700356 != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357 /* Could not get Capabilities value from CFG.*/
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700358 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359
360 /* Clear spectrum management bit if AP doesn't support it */
361 if (!(session_entry->pLimJoinReq->bssDescription.capabilityInfo &
362 LIM_SPECTRUM_MANAGEMENT_BIT_MASK))
363 /*
364 * AP doesn't support spectrum management
365 * clear spectrum management bit
366 */
367 caps &= (~LIM_SPECTRUM_MANAGEMENT_BIT_MASK);
368
Hu Wangc8bccea2016-11-02 11:09:34 +0800369 /* Clear rrm bit if AP doesn't support it */
370 if (!(session_entry->pLimJoinReq->bssDescription.capabilityInfo &
371 LIM_RRM_BIT_MASK))
372 caps &= (~LIM_RRM_BIT_MASK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373
374 /* Clear short preamble bit if AP does not support it */
375 if (!(session_entry->pLimJoinReq->bssDescription.capabilityInfo &
376 (LIM_SHORT_PREAMBLE_BIT_MASK))) {
377 caps &= (~LIM_SHORT_PREAMBLE_BIT_MASK);
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700378 pe_debug("Clearing short preamble:no AP support");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 }
380
381 /* Clear immediate block ack bit if AP does not support it */
382 if (!(session_entry->pLimJoinReq->bssDescription.capabilityInfo &
383 (LIM_IMMEDIATE_BLOCK_ACK_MASK))) {
384 caps &= (~LIM_IMMEDIATE_BLOCK_ACK_MASK);
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700385 pe_debug("Clearing Immed Blk Ack:no AP support");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 }
387
388 assoc_req->capabilityInfo = caps;
389 cap_info = ((tpSirMacCapabilityInfo) &assoc_req->capabilityInfo);
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700390 pe_debug("Capabilities to be used in AssocReq=0x%X,"
391 "privacy bit=%x shortSlotTime %x", caps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392 cap_info->privacy,
393 cap_info->shortSlotTime);
394
395 /*
396 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530397 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 */
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530399 tele_bcn = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
400 if (tele_bcn)
401 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
402 else
403 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405#ifdef FEATURE_WLAN_DIAG_SUPPORT
406 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700407 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408#endif
409 assoc_req->listenInterval = (uint16_t) val;
410 /* Update PE session ID */
411 assoc_req->sessionId = session_entry->peSessionId;
412 session_entry->limPrevSmeState = session_entry->limSmeState;
413 session_entry->limSmeState = eLIM_SME_WT_ASSOC_STATE;
414 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
415 session_entry->peSessionId, session_entry->limSmeState));
416 lim_post_mlm_message(mac_ctx, LIM_MLM_ASSOC_REQ,
417 (uint32_t *) assoc_req);
418}
419
420#ifdef WLAN_FEATURE_11W
421/**
422 * lim_pmf_comeback_timer_callback() -PMF callback handler
423 * @context: Timer context
424 *
425 * This function is called to processes the PMF comeback
426 * callback
427 *
428 * Return: None
429 */
430void lim_pmf_comeback_timer_callback(void *context)
431{
Jeff Johnson4a07a9b2018-11-21 23:51:02 -0800432 struct comeback_timer_info *info = context;
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800433 struct mac_context *mac_ctx = info->mac;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800434 struct pe_session *pe_session = &mac_ctx->lim.gpSession[info->session_id];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700436 pe_err("comeback later timer expired. sending MLM ASSOC req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 /* set MLM state such that ASSOC REQ packet will be sent out */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800438 pe_session->limPrevMlmState = info->lim_prev_mlm_state;
439 pe_session->limMlmState = info->lim_mlm_state;
440 lim_send_mlm_assoc_req(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441}
442#endif /* WLAN_FEATURE_11W */
443
444/**
445 * lim_process_mlm_auth_cnf()-Process Auth confirmation
446 * @mac_ctx: Pointer to Global MAC structure
447 * @msg: A pointer to the MLM message buffer
448 *
449 * This function is called to processes MLM_AUTH_CNF
450 * message from MLM State machine.
451 *
452 * Return: None
453 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800454void lim_process_mlm_auth_cnf(struct mac_context *mac_ctx, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455{
Naveen Rawat7e7af3c2017-09-06 14:36:56 -0700456 tAniAuthType auth_type, auth_mode;
457 tLimMlmAuthReq *auth_req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 tLimMlmAuthCnf *auth_cnf;
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -0800459 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460
461 if (msg == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700462 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463 return;
464 }
465 auth_cnf = (tLimMlmAuthCnf *) msg;
466 session_entry = pe_find_session_by_session_id(mac_ctx,
467 auth_cnf->sessionId);
468 if (session_entry == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700469 pe_err("SessionId:%d session doesn't exist",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 auth_cnf->sessionId);
471 return;
472 }
473
474 if ((session_entry->limSmeState != eLIM_SME_WT_AUTH_STATE &&
475 session_entry->limSmeState != eLIM_SME_WT_PRE_AUTH_STATE) ||
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700476 LIM_IS_AP_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 /**
478 * Should not have received AUTH confirm
479 * from MLM in other states or on AP.
480 * Log error
481 */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700482 pe_err("SessionId:%d received MLM_AUTH_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 session_entry->peSessionId, session_entry->limSmeState);
484 return;
485 }
486
Selvaraj, Sridhar9cee77f2016-06-22 21:47:52 +0530487 if (auth_cnf->resultCode == eSIR_SME_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488 if (session_entry->limSmeState == eLIM_SME_WT_AUTH_STATE) {
489 lim_send_mlm_assoc_req(mac_ctx, session_entry);
490 } else {
491 /*
492 * Successful Pre-authentication. Send
493 * Pre-auth response to host
494 */
495 session_entry->limSmeState =
496 session_entry->limPrevSmeState;
497 MTRACE(mac_trace
498 (mac_ctx, TRACE_CODE_SME_STATE,
499 session_entry->peSessionId,
500 session_entry->limSmeState));
501 }
502 /* Return for success case */
503 return;
504 }
505 /*
506 * Failure case handle:
507 * Process AUTH confirm from MLM
508 */
Pragaspathi Thilagarajda3b5e22018-09-23 01:55:57 +0530509 if (session_entry->limSmeState == eLIM_SME_WT_AUTH_STATE)
510 auth_type = mac_ctx->mlme_cfg->wep_params.auth_type;
511 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512 auth_type = mac_ctx->lim.gLimPreAuthType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513
514 if ((auth_type == eSIR_AUTO_SWITCH) &&
Selvaraj, Sridhar9cee77f2016-06-22 21:47:52 +0530515 (auth_cnf->authType == eSIR_SHARED_KEY) &&
516 ((eSIR_MAC_AUTH_ALGO_NOT_SUPPORTED_STATUS ==
517 auth_cnf->protStatusCode) ||
518 (auth_cnf->resultCode == eSIR_SME_AUTH_TIMEOUT_RESULT_CODE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 /*
Rajeev Kumar437c9212016-04-14 15:26:59 -0700520 * When shared authentication fails with reason
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 * code "13" and authType set to 'auto switch',
Rajeev Kumar437c9212016-04-14 15:26:59 -0700522 * Try with open Authentication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523 */
Naveen Rawat7e7af3c2017-09-06 14:36:56 -0700524 auth_mode = eSIR_OPEN_SYSTEM;
525 /* Trigger MAC based Authentication */
526 auth_req = qdf_mem_malloc(sizeof(tLimMlmAuthReq));
527 if (NULL == auth_req) {
528 pe_err("mlmAuthReq :Memory alloc failed");
529 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 }
Naveen Rawat7e7af3c2017-09-06 14:36:56 -0700531 if (session_entry->limSmeState ==
532 eLIM_SME_WT_AUTH_STATE) {
533 sir_copy_mac_addr(auth_req->peerMacAddr,
534 session_entry->bssId);
535 } else {
536 qdf_mem_copy((uint8_t *)&auth_req->peerMacAddr,
537 (uint8_t *)&mac_ctx->lim.gLimPreAuthPeerAddr,
538 sizeof(tSirMacAddr));
539 }
540 auth_req->authType = auth_mode;
541 /* Update PE session Id */
542 auth_req->sessionId = auth_cnf->sessionId;
Naveen Rawat7e7af3c2017-09-06 14:36:56 -0700543 lim_post_mlm_message(mac_ctx, LIM_MLM_AUTH_REQ,
544 (uint32_t *) auth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 return;
546 } else {
547 /* MAC based authentication failure */
548 if (session_entry->limSmeState ==
549 eLIM_SME_WT_AUTH_STATE) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700550 pe_err("Auth Failure occurred");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 session_entry->limSmeState =
552 eLIM_SME_JOIN_FAILURE_STATE;
553 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
554 session_entry->peSessionId,
555 session_entry->limSmeState));
556 session_entry->limMlmState =
557 eLIM_MLM_IDLE_STATE;
558 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
559 session_entry->peSessionId,
560 session_entry->limMlmState));
561 /*
562 * Need to send Join response with
563 * auth failure to Host.
564 */
565 lim_handle_sme_join_result(mac_ctx,
Selvaraj, Sridhar9cee77f2016-06-22 21:47:52 +0530566 auth_cnf->resultCode,
567 auth_cnf->protStatusCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 session_entry);
569 } else {
570 /*
571 * Pre-authentication failure.
572 * Send Pre-auth failure response to host
573 */
574 session_entry->limSmeState =
575 session_entry->limPrevSmeState;
576 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
577 session_entry->peSessionId,
578 session_entry->limSmeState));
579 }
580 }
581}
582
583/**
584 * lim_process_mlm_assoc_cnf() - Process association confirmation
585 * @mac_ctx: Pointer to Global MAC structure
586 * @msg: A pointer to the MLM message buffer
587 *
588 * This function is called to processes MLM_ASSOC_CNF
589 * message from MLM State machine.
590 *
591 * Return: None
592 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800593void lim_process_mlm_assoc_cnf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 uint32_t *msg)
595{
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -0800596 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 tLimMlmAssocCnf *assoc_cnf;
598
599 if (msg == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700600 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601 return;
602 }
603 assoc_cnf = (tLimMlmAssocCnf *) msg;
604 session_entry = pe_find_session_by_session_id(mac_ctx,
605 assoc_cnf->sessionId);
606 if (session_entry == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700607 pe_err("SessionId:%d Session does not exist",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 assoc_cnf->sessionId);
609 return;
610 }
611 if (session_entry->limSmeState != eLIM_SME_WT_ASSOC_STATE ||
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700612 LIM_IS_AP_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 /*
614 * Should not have received Assocication confirm
615 * from MLM in other states OR on AP.
616 * Log error
617 */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700618 pe_err("SessionId:%d Received MLM_ASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 session_entry->peSessionId, session_entry->limSmeState);
620 return;
621 }
622 if (((tLimMlmAssocCnf *) msg)->resultCode != eSIR_SME_SUCCESS) {
623 /* Association failure */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700624 pe_err("SessionId:%d Association failure resultCode: %d limSmeState:%d",
Hanumantha Reddy Pothula6677a332016-09-12 14:35:03 +0530625 session_entry->peSessionId,
626 ((tLimMlmAssocCnf *) msg)->resultCode,
627 session_entry->limSmeState);
628
629 /* If driver gets deauth when its waiting for ADD_STA_RSP then
630 * we need to do DEL_STA followed by DEL_BSS. So based on below
631 * reason-code here we decide whether to do only DEL_BSS or
632 * DEL_STA + DEL_BSS.
633 */
634 if (((tLimMlmAssocCnf *) msg)->resultCode !=
635 eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA)
636 session_entry->limSmeState =
637 eLIM_SME_JOIN_FAILURE_STATE;
638
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
640 session_entry->peSessionId, mac_ctx->lim.gLimSmeState));
641 /*
642 * Need to send Join response with
643 * Association failure to Host.
644 */
645 lim_handle_sme_join_result(mac_ctx,
646 ((tLimMlmAssocCnf *) msg)->resultCode,
647 ((tLimMlmAssocCnf *) msg)->protStatusCode,
648 session_entry);
649 } else {
650 /* Successful Association */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700651 pe_debug("SessionId:%d Associated with BSS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 session_entry->peSessionId);
653 session_entry->limSmeState = eLIM_SME_LINK_EST_STATE;
654 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
655 session_entry->peSessionId,
656 session_entry->limSmeState));
657 /**
658 * Need to send Join response with
659 * Association success to Host.
660 */
661 lim_handle_sme_join_result(mac_ctx,
662 ((tLimMlmAssocCnf *) msg)->resultCode,
663 ((tLimMlmAssocCnf *) msg)->protStatusCode,
664 session_entry);
665 }
666}
667
668/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 * lim_fill_assoc_ind_params() - Initialize association indication
670 * mac_ctx: Pointer to Global MAC structure
671 * assoc_ind: PE association indication structure
672 * sme_assoc_ind: SME association indication
673 * session_entry: PE session entry
674 *
675 * This function is called to initialzie the association
676 * indication strucutre to process association indication.
677 *
678 * Return: None
679 */
680
Jeff Johnsona0495a62016-10-07 07:25:58 -0700681static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800682lim_fill_assoc_ind_params(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 tpLimMlmAssocInd assoc_ind, tSirSmeAssocInd *sme_assoc_ind,
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -0800684 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685{
686 sme_assoc_ind->length = sizeof(tSirSmeAssocInd);
687 sme_assoc_ind->sessionId = session_entry->smeSessionId;
688
689 /* Required for indicating the frames to upper layer */
690 sme_assoc_ind->assocReqLength = assoc_ind->assocReqLength;
691 sme_assoc_ind->assocReqPtr = assoc_ind->assocReqPtr;
692
693 sme_assoc_ind->beaconPtr = session_entry->beacon;
694 sme_assoc_ind->beaconLength = session_entry->bcnLen;
695
696 /* Fill in peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530697 qdf_mem_copy(sme_assoc_ind->peerMacAddr, assoc_ind->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 sizeof(tSirMacAddr));
699
700 /* Fill in aid */
701 sme_assoc_ind->aid = assoc_ind->aid;
702 /* Fill in bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530703 qdf_mem_copy(sme_assoc_ind->bssId, session_entry->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 sizeof(tSirMacAddr));
705 /* Fill in authType */
706 sme_assoc_ind->authType = assoc_ind->authType;
707 /* Fill in ssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530708 qdf_mem_copy((uint8_t *) &sme_assoc_ind->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 (uint8_t *) &(assoc_ind->ssId), assoc_ind->ssId.length + 1);
710 sme_assoc_ind->rsnIE.length = assoc_ind->rsnIE.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530711 qdf_mem_copy((uint8_t *) &sme_assoc_ind->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 (uint8_t *) &(assoc_ind->rsnIE.rsnIEdata),
713 assoc_ind->rsnIE.length);
714
715#ifdef FEATURE_WLAN_WAPI
716 sme_assoc_ind->wapiIE.length = assoc_ind->wapiIE.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530717 qdf_mem_copy((uint8_t *) &sme_assoc_ind->wapiIE.wapiIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718 (uint8_t *) &(assoc_ind->wapiIE.wapiIEdata),
719 assoc_ind->wapiIE.length);
720#endif
721 sme_assoc_ind->addIE.length = assoc_ind->addIE.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530722 qdf_mem_copy((uint8_t *) &sme_assoc_ind->addIE.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 (uint8_t *) &(assoc_ind->addIE.addIEdata),
724 assoc_ind->addIE.length);
725
726 /* Copy the new TITAN capabilities */
727 sme_assoc_ind->spectrumMgtIndicator = assoc_ind->spectrumMgtIndicator;
Srinivas Girigowda74a66d62017-06-21 23:28:25 -0700728 if (assoc_ind->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 sme_assoc_ind->powerCap.minTxPower =
730 assoc_ind->powerCap.minTxPower;
731 sme_assoc_ind->powerCap.maxTxPower =
732 assoc_ind->powerCap.maxTxPower;
733 sme_assoc_ind->supportedChannels.numChnl =
734 assoc_ind->supportedChannels.numChnl;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530735 qdf_mem_copy((uint8_t *) &sme_assoc_ind->supportedChannels.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 channelList,
737 (uint8_t *) &(assoc_ind->supportedChannels.channelList),
738 assoc_ind->supportedChannels.numChnl);
739 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530740 qdf_mem_copy(&sme_assoc_ind->chan_info, &assoc_ind->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 sizeof(tSirSmeChanInfo));
742 /* Fill in WmmInfo */
743 sme_assoc_ind->wmmEnabledSta = assoc_ind->WmmStaInfoPresent;
Will Huang558f8082017-05-31 16:22:24 +0800744 sme_assoc_ind->ampdu = assoc_ind->ampdu;
745 sme_assoc_ind->sgi_enable = assoc_ind->sgi_enable;
746 sme_assoc_ind->tx_stbc = assoc_ind->tx_stbc;
747 sme_assoc_ind->rx_stbc = assoc_ind->rx_stbc;
748 sme_assoc_ind->ch_width = assoc_ind->ch_width;
749 sme_assoc_ind->mode = assoc_ind->mode;
750 sme_assoc_ind->max_supp_idx = assoc_ind->max_supp_idx;
751 sme_assoc_ind->max_ext_idx = assoc_ind->max_ext_idx;
752 sme_assoc_ind->max_mcs_idx = assoc_ind->max_mcs_idx;
753 sme_assoc_ind->rx_mcs_map = assoc_ind->rx_mcs_map;
754 sme_assoc_ind->tx_mcs_map = assoc_ind->tx_mcs_map;
gaolez7bb1e742017-03-21 16:37:38 +0800755 sme_assoc_ind->ecsa_capable = assoc_ind->ecsa_capable;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530756
757 if (assoc_ind->ht_caps.present)
758 sme_assoc_ind->HTCaps = assoc_ind->ht_caps;
759 if (assoc_ind->vht_caps.present)
760 sme_assoc_ind->VHTCaps = assoc_ind->vht_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761}
762
763/**
764 * lim_process_mlm_assoc_ind()
765 *
766 ***FUNCTION:
767 * This function is called to processes MLM_ASSOC_IND
768 * message from MLM State machine.
769 *
770 ***LOGIC:
771 *
772 ***ASSUMPTIONS:
773 *
774 ***NOTE:
775 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800776 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777 * @param pMsgBuf A pointer to the MLM message buffer
778 *
779 * @return None
780 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800781void lim_process_mlm_assoc_ind(struct mac_context *mac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782{
783 uint32_t len;
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700784 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 tSirSmeAssocInd *pSirSmeAssocInd;
786 tpDphHashNode pStaDs = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800787 struct pe_session *pe_session;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700788
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789 if (pMsgBuf == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700790 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 return;
792 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800793 pe_session = pe_find_session_by_session_id(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 ((tpLimMlmAssocInd) pMsgBuf)->
795 sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800796 if (pe_session == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700797 pe_err("Session Does not exist for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 return;
799 }
800 /* / Inform Host of STA association */
801 len = sizeof(tSirSmeAssocInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530802 pSirSmeAssocInd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 if (NULL == pSirSmeAssocInd) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700804 pe_err("call to AllocateMemory failed for eWNI_SME_ASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 return;
806 }
807
808 pSirSmeAssocInd->messageType = eWNI_SME_ASSOC_IND;
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800809 lim_fill_assoc_ind_params(mac, (tpLimMlmAssocInd) pMsgBuf,
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700810 pSirSmeAssocInd,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800811 pe_session);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700812 msg.type = eWNI_SME_ASSOC_IND;
813 msg.bodyptr = pSirSmeAssocInd;
814 msg.bodyval = 0;
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800815 pStaDs = dph_get_hash_entry(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 ((tpLimMlmAssocInd) pMsgBuf)->aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800817 &pe_session->dph.dphHashTable);
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700818 if (!pStaDs) {
819 pe_err("MLM AssocInd: Station context no longer valid (aid %d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 ((tpLimMlmAssocInd) pMsgBuf)->aid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530821 qdf_mem_free(pSirSmeAssocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822
823 return;
824 }
825 pSirSmeAssocInd->staId = pStaDs->staIndex;
826 pSirSmeAssocInd->reassocReq = pStaDs->mlmStaContext.subType;
827 pSirSmeAssocInd->timingMeasCap = pStaDs->timingMeasCap;
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800828 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800829 pe_session->peSessionId, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800831 lim_diag_event_report(mac, WLAN_PE_DIAG_ASSOC_IND_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832 0);
833#endif /* FEATURE_WLAN_DIAG_SUPPORT */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700834 pe_debug("Create CNF_WAIT_TIMER after received LIM_MLM_ASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 /*
836 ** turn on a timer to detect the loss of ASSOC CNF
837 **/
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800838 lim_activate_cnf_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 (uint16_t) ((tpLimMlmAssocInd) pMsgBuf)->aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800840 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800842 mac->lim.sme_msg_callback(mac, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843} /*** end lim_process_mlm_assoc_ind() ***/
844
845/**
846 * lim_process_mlm_disassoc_ind()
847 *
848 ***FUNCTION:
849 * This function is called to processes MLM_DISASSOC_IND
850 * message from MLM State machine.
851 *
852 ***LOGIC:
853 *
854 ***ASSUMPTIONS:
855 *
856 ***NOTE:
857 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -0800858 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 * @param pMsgBuf A pointer to the MLM message buffer
860 *
861 * @return None
862 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800863void lim_process_mlm_disassoc_ind(struct mac_context *mac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864{
865 tLimMlmDisassocInd *pMlmDisassocInd;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800866 struct pe_session *pe_session;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 pMlmDisassocInd = (tLimMlmDisassocInd *) pMsgBuf;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800869 pe_session = pe_find_session_by_session_id(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 pMlmDisassocInd->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800871 if (pe_session == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700872 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 return;
874 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800875 switch (GET_LIM_SYSTEM_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 case eLIM_STA_IN_IBSS_ROLE:
877 break;
878 case eLIM_STA_ROLE:
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800879 pe_session->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800881 (mac, TRACE_CODE_SME_STATE, pe_session->peSessionId,
882 pe_session->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 break;
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700884 default: /* eLIM_AP_ROLE */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700885 pe_debug("*** Peer staId=%d Disassociated ***",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 pMlmDisassocInd->aid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 /* Send SME_DISASOC_IND after Polaris cleanup */
888 /* (after receiving LIM_MLM_PURGE_STA_IND) */
889 break;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800890 } /* end switch (GET_LIM_SYSTEM_ROLE(pe_session)) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891} /*** end lim_process_mlm_disassoc_ind() ***/
892
893/**
894 * lim_process_mlm_disassoc_cnf() - Processes disassociation
895 * @mac_ctx: Pointer to Global MAC structure
896 * @msg: A pointer to the MLM message buffer
897 *
898 * This function is called to processes MLM_DISASSOC_CNF
899 * message from MLM State machine.
900 *
901 * Return: None
902 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800903void lim_process_mlm_disassoc_cnf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 uint32_t *msg)
905{
906 tSirResultCodes result_code;
907 tLimMlmDisassocCnf *disassoc_cnf;
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -0800908 struct pe_session *session_entry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 disassoc_cnf = (tLimMlmDisassocCnf *) msg;
911
912 session_entry =
913 pe_find_session_by_session_id(mac_ctx, disassoc_cnf->sessionId);
914 if (session_entry == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700915 pe_err("session Does not exist for given session Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 return;
917 }
918 result_code = (tSirResultCodes)(disassoc_cnf->disassocTrigger ==
919 eLIM_LINK_MONITORING_DISASSOC) ?
920 eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE :
921 disassoc_cnf->resultCode;
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700922 if (LIM_IS_STA_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923 /* Disassociate Confirm from MLM */
924 if ((session_entry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
925 && (session_entry->limSmeState !=
926 eLIM_SME_WT_DEAUTH_STATE)) {
927 /*
928 * Should not have received
929 * Disassocate confirm
930 * from MLM in other states.Log error
931 */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -0700932 pe_err("received MLM_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 session_entry->limSmeState);
934 return;
935 }
936 if (mac_ctx->lim.gLimRspReqd)
937 mac_ctx->lim.gLimRspReqd = false;
938 if (disassoc_cnf->disassocTrigger ==
939 eLIM_PROMISCUOUS_MODE_DISASSOC) {
940 if (disassoc_cnf->resultCode != eSIR_SME_SUCCESS)
941 session_entry->limSmeState =
942 session_entry->limPrevSmeState;
943 else
944 session_entry->limSmeState =
945 eLIM_SME_OFFLINE_STATE;
946 MTRACE(mac_trace
947 (mac_ctx, TRACE_CODE_SME_STATE,
948 session_entry->peSessionId,
949 session_entry->limSmeState));
950 } else {
951 if (disassoc_cnf->resultCode != eSIR_SME_SUCCESS)
952 session_entry->limSmeState =
953 session_entry->limPrevSmeState;
954 else
955 session_entry->limSmeState =
956 eLIM_SME_IDLE_STATE;
957 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
958 session_entry->peSessionId,
959 session_entry->limSmeState));
960 lim_send_sme_disassoc_ntf(mac_ctx,
961 disassoc_cnf->peerMacAddr, result_code,
962 disassoc_cnf->disassocTrigger,
963 disassoc_cnf->aid, session_entry->smeSessionId,
964 session_entry->transactionId, session_entry);
965 }
Rajeev Kumaraa262c42016-04-15 15:41:08 -0700966 } else if (LIM_IS_AP_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 lim_send_sme_disassoc_ntf(mac_ctx, disassoc_cnf->peerMacAddr,
968 result_code, disassoc_cnf->disassocTrigger,
969 disassoc_cnf->aid, session_entry->smeSessionId,
970 session_entry->transactionId, session_entry);
971 }
972}
973
974/**
Arif Hussain0627e2f2018-04-30 17:07:21 -0700975 * lim_process_mlm_deauth_ind() - processes MLM_DEAUTH_IND
976 * @mac_ctx: global mac structure
977 * @deauth_ind: deauth indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 * This function is called to processes MLM_DEAUTH_IND
980 * message from MLM State machine.
981 *
Arif Hussain0627e2f2018-04-30 17:07:21 -0700982 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800984static void lim_process_mlm_deauth_ind(struct mac_context *mac_ctx,
Arif Hussain0627e2f2018-04-30 17:07:21 -0700985 tLimMlmDeauthInd *deauth_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986{
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -0800987 struct pe_session *session;
Arif Hussain0627e2f2018-04-30 17:07:21 -0700988 uint8_t session_id;
989 enum eLimSystemRole role;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700990
Arif Hussain0627e2f2018-04-30 17:07:21 -0700991 if (!deauth_ind) {
992 pe_err("deauth_ind is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 return;
994 }
Arif Hussain0627e2f2018-04-30 17:07:21 -0700995 session = pe_find_session_by_bssid(mac_ctx,
996 deauth_ind->peerMacAddr,
997 &session_id);
998 if (!session) {
999 pe_err("session does not exist for Addr:" MAC_ADDRESS_STR,
1000 MAC_ADDR_ARRAY(deauth_ind->peerMacAddr));
1001 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 }
Arif Hussain0627e2f2018-04-30 17:07:21 -07001003 role = GET_LIM_SYSTEM_ROLE(session);
1004 pe_debug("*** Received Deauthentication from staId=%d role=%d***",
1005 deauth_ind->aid, role);
1006 if (role == eLIM_STA_ROLE) {
1007 session->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
1008 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1009 session->peSessionId, session->limSmeState));
1010 }
1011}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012
1013/**
1014 * lim_process_mlm_deauth_cnf()
1015 *
1016 ***FUNCTION:
1017 * This function is called to processes MLM_DEAUTH_CNF
1018 * message from MLM State machine.
1019 *
1020 ***LOGIC:
1021 *
1022 ***ASSUMPTIONS:
1023 *
1024 ***NOTE:
1025 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001026 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 * @param pMsgBuf A pointer to the MLM message buffer
1028 *
1029 * @return None
1030 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001031void lim_process_mlm_deauth_cnf(struct mac_context *mac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032{
1033 uint16_t aid;
1034 tSirResultCodes resultCode;
1035 tLimMlmDeauthCnf *pMlmDeauthCnf;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001036 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037
1038 if (pMsgBuf == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001039 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 return;
1041 }
1042 pMlmDeauthCnf = (tLimMlmDeauthCnf *) pMsgBuf;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001043 pe_session = pe_find_session_by_session_id(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 pMlmDeauthCnf->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001045 if (pe_session == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001046 pe_err("session does not exist for given session Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 return;
1048 }
1049
1050 resultCode = (tSirResultCodes)
1051 (pMlmDeauthCnf->deauthTrigger ==
1052 eLIM_LINK_MONITORING_DEAUTH) ?
1053 eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE :
1054 pMlmDeauthCnf->resultCode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001055 aid = LIM_IS_AP_ROLE(pe_session) ? pMlmDeauthCnf->aid : 1;
1056 if (LIM_IS_STA_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 /* Deauth Confirm from MLM */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001058 if ((pe_session->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
1059 && pe_session->limSmeState !=
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05301060 eLIM_SME_WT_DEAUTH_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061 /**
1062 * Should not have received Deauth confirm
1063 * from MLM in other states.
1064 * Log error
1065 */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001066 pe_err("received unexpected MLM_DEAUTH_CNF in state %X",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001067 pe_session->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 return;
1069 }
1070 if (pMlmDeauthCnf->resultCode == eSIR_SME_SUCCESS) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001071 pe_session->limSmeState = eLIM_SME_IDLE_STATE;
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001072 pe_debug("*** Deauthenticated with BSS ***");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 } else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001074 pe_session->limSmeState =
1075 pe_session->limPrevSmeState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001077 (mac, TRACE_CODE_SME_STATE, pe_session->peSessionId,
1078 pe_session->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001080 if (mac->lim.gLimRspReqd)
1081 mac->lim.gLimRspReqd = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 }
1083 /* On STA or on BASIC AP, send SME_DEAUTH_RSP to host */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001084 lim_send_sme_deauth_ntf(mac, pMlmDeauthCnf->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 resultCode,
1086 pMlmDeauthCnf->deauthTrigger,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001087 aid, pe_session->smeSessionId,
1088 pe_session->transactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089} /*** end lim_process_mlm_deauth_cnf() ***/
1090
1091/**
1092 * lim_process_mlm_purge_sta_ind()
1093 *
1094 ***FUNCTION:
1095 * This function is called to processes MLM_PURGE_STA_IND
1096 * message from MLM State machine.
1097 *
1098 ***LOGIC:
1099 *
1100 ***ASSUMPTIONS:
1101 *
1102 ***NOTE:
1103 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001104 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105 * @param pMsgBuf A pointer to the MLM message buffer
1106 *
1107 * @return None
1108 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001109void lim_process_mlm_purge_sta_ind(struct mac_context *mac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110{
1111 tSirResultCodes resultCode;
1112 tpLimMlmPurgeStaInd pMlmPurgeStaInd;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001113 struct pe_session *pe_session;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001114
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115 if (pMsgBuf == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001116 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117 return;
1118 }
1119 pMlmPurgeStaInd = (tpLimMlmPurgeStaInd) pMsgBuf;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001120 pe_session = pe_find_session_by_session_id(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 pMlmPurgeStaInd->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001122 if (pe_session == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001123 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 return;
1125 }
1126 /* Purge STA indication from MLM */
1127 resultCode = (tSirResultCodes) pMlmPurgeStaInd->reasonCode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001128 switch (GET_LIM_SYSTEM_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129 case eLIM_STA_IN_IBSS_ROLE:
1130 break;
1131 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132 default: /* eLIM_AP_ROLE */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001133 if (LIM_IS_STA_ROLE(pe_session) &&
1134 (pe_session->limSmeState !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135 eLIM_SME_WT_DISASSOC_STATE) &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001136 (pe_session->limSmeState != eLIM_SME_WT_DEAUTH_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 /**
1138 * Should not have received
1139 * Purge STA indication
1140 * from MLM in other states.
1141 * Log error
1142 */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001143 pe_err("received unexpected MLM_PURGE_STA_IND in state %X",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001144 pe_session->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 break;
1146 }
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001147 pe_debug("*** Cleanup completed for staId=%d ***",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148 pMlmPurgeStaInd->aid);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001149 if (LIM_IS_STA_ROLE(pe_session)) {
1150 pe_session->limSmeState = eLIM_SME_IDLE_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 MTRACE(mac_trace
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001152 (mac, TRACE_CODE_SME_STATE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001153 pe_session->peSessionId,
1154 pe_session->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155
1156 }
1157 if (pMlmPurgeStaInd->purgeTrigger == eLIM_PEER_ENTITY_DEAUTH) {
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001158 lim_send_sme_deauth_ntf(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001159 pMlmPurgeStaInd->peerMacAddr,
1160 resultCode,
1161 pMlmPurgeStaInd->purgeTrigger,
1162 pMlmPurgeStaInd->aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001163 pe_session->smeSessionId,
1164 pe_session->transactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001165 } else
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001166 lim_send_sme_disassoc_ntf(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167 pMlmPurgeStaInd->peerMacAddr,
1168 resultCode,
1169 pMlmPurgeStaInd->purgeTrigger,
1170 pMlmPurgeStaInd->aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001171 pe_session->smeSessionId,
1172 pe_session->transactionId,
1173 pe_session);
1174 } /* end switch (GET_LIM_SYSTEM_ROLE(pe_session)) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175} /*** end lim_process_mlm_purge_sta_ind() ***/
1176
1177/**
1178 * lim_process_mlm_set_keys_cnf()
1179 *
1180 ***FUNCTION:
1181 * This function is called to processes MLM_SETKEYS_CNF
1182 * message from MLM State machine.
1183 *
1184 ***LOGIC:
1185 *
1186 ***ASSUMPTIONS:
1187 *
1188 ***NOTE:
1189 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001190 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 * @param pMsgBuf A pointer to the MLM message buffer
1192 *
1193 * @return None
1194 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001195void lim_process_mlm_set_keys_cnf(struct mac_context *mac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196{
1197 /* Prepare and send SME_SETCONTEXT_RSP message */
1198 tLimMlmSetKeysCnf *pMlmSetKeysCnf;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001199 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200 uint16_t aid;
1201 tpDphHashNode sta_ds;
1202
1203 if (pMsgBuf == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001204 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205 return;
1206 }
1207 pMlmSetKeysCnf = (tLimMlmSetKeysCnf *) pMsgBuf;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001208 pe_session = pe_find_session_by_session_id(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 pMlmSetKeysCnf->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001210 if (pe_session == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001211 pe_err("session does not exist for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 return;
1213 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001214 pe_session->is_key_installed = 0;
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001215 pe_debug("Received MLM_SETKEYS_CNF with resultCode = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 pMlmSetKeysCnf->resultCode);
1217 /* if the status is success keys are installed in the
1218 * Firmware so we can set the protection bit
1219 */
1220 if (eSIR_SME_SUCCESS == pMlmSetKeysCnf->resultCode) {
Deepak Dhamdhere07168162016-10-19 20:45:20 -07001221 if (pMlmSetKeysCnf->key_len_nonzero)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001222 pe_session->is_key_installed = 1;
1223 if (LIM_IS_AP_ROLE(pe_session)) {
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001224 sta_ds = dph_lookup_hash_entry(mac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001225 pMlmSetKeysCnf->peer_macaddr.bytes,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001226 &aid, &pe_session->dph.dphHashTable);
Deepak Dhamdhere07168162016-10-19 20:45:20 -07001227 if (sta_ds != NULL && pMlmSetKeysCnf->key_len_nonzero)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228 sta_ds->is_key_installed = 1;
1229 }
1230 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001231 pe_debug("is_key_installed = %d", pe_session->is_key_installed);
Deepak Dhamdhere07168162016-10-19 20:45:20 -07001232
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001233 lim_send_sme_set_context_rsp(mac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08001234 pMlmSetKeysCnf->peer_macaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 1,
1236 (tSirResultCodes) pMlmSetKeysCnf->resultCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001237 pe_session, pe_session->smeSessionId,
1238 pe_session->transactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239} /*** end lim_process_mlm_set_keys_cnf() ***/
1240
1241/**
yeshwanth sriram guntuka7419da72017-01-19 21:17:30 +05301242 * lim_join_result_callback() - Callback to handle join rsp
1243 * @mac: Pointer to Global MAC structure
1244 * @param: callback argument
1245 * @status: status
1246 *
1247 * This callback function is used to delete PE session
1248 * entry and send join response to sme.
1249 *
1250 * Return: None
1251 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001252static void lim_join_result_callback(struct mac_context *mac, void *param,
yeshwanth sriram guntuka7419da72017-01-19 21:17:30 +05301253 bool status)
1254{
1255 join_params *link_state_params = (join_params *) param;
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08001256 struct pe_session *session;
yeshwanth sriram guntuka7419da72017-01-19 21:17:30 +05301257 uint8_t sme_session_id;
1258 uint16_t sme_trans_id;
1259
1260 if (!link_state_params) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001261 pe_err("Link state params is NULL");
yeshwanth sriram guntuka7419da72017-01-19 21:17:30 +05301262 return;
1263 }
1264 session = pe_find_session_by_session_id(mac, link_state_params->
1265 pe_session_id);
1266 if (!session) {
1267 qdf_mem_free(link_state_params);
1268 return;
1269 }
1270 sme_session_id = session->smeSessionId;
1271 sme_trans_id = session->transactionId;
1272 lim_send_sme_join_reassoc_rsp(mac, eWNI_SME_JOIN_RSP,
1273 link_state_params->result_code,
1274 link_state_params->prot_status_code,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301275 session, sme_session_id, sme_trans_id);
yeshwanth sriram guntuka7419da72017-01-19 21:17:30 +05301276 pe_delete_session(mac, session);
1277 qdf_mem_free(link_state_params);
1278}
1279
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07001280#ifdef CONFIG_VDEV_SM
1281QDF_STATUS lim_sta_send_down_link(join_params *param)
1282{
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08001283 struct pe_session *session;
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001284 struct mac_context *mac_ctx;
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07001285 tpDphHashNode sta_ds = NULL;
1286
1287 if (!param) {
1288 pe_err("param is NULL");
1289 return QDF_STATUS_E_INVAL;
1290 }
1291
1292 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
1293 if (!mac_ctx) {
1294 pe_err("Mac context is NULL");
1295 return QDF_STATUS_E_INVAL;
1296 }
1297 session = pe_find_session_by_session_id(mac_ctx, param->pe_session_id);
1298 if (!session) {
1299 pe_err("session is NULL");
1300 return QDF_STATUS_E_INVAL;
1301 }
1302
1303 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
1304 &session->dph.dphHashTable);
1305 if (sta_ds) {
1306 sta_ds->mlmStaContext.disassocReason =
1307 eSIR_MAC_UNSPEC_FAILURE_REASON;
1308 sta_ds->mlmStaContext.cleanupTrigger =
1309 eLIM_JOIN_FAILURE;
1310 sta_ds->mlmStaContext.resultCode = param->result_code;
1311 sta_ds->mlmStaContext.protStatusCode = param->prot_status_code;
1312 /*
1313 * FIX_ME: at the end of lim_cleanup_rx_path,
1314 * make sure PE is sending eWNI_SME_JOIN_RSP
1315 * to SME
1316 */
1317 lim_cleanup_rx_path(mac_ctx, sta_ds, session);
1318 qdf_mem_free(session->pLimJoinReq);
1319 session->pLimJoinReq = NULL;
1320 /* Cleanup if add bss failed */
1321 if (session->add_bss_failed) {
1322 dph_delete_hash_entry(mac_ctx,
1323 sta_ds->staAddr, sta_ds->assocId,
1324 &session->dph.dphHashTable);
1325 goto error;
1326 }
1327 return QDF_STATUS_SUCCESS;
1328 }
1329 qdf_mem_free(session->pLimJoinReq);
1330 session->pLimJoinReq = NULL;
1331
1332error:
1333 /*
1334 * Delete the session if JOIN failure occurred.
1335 * if the peer is not created, then there is no
1336 * need to send down the set link state which will
1337 * try to delete the peer. Instead a join response
1338 * failure should be sent to the upper layers.
1339 */
1340 if (param->result_code != eSIR_SME_PEER_CREATE_FAILED) {
1341 join_params *link_state_arg;
1342
1343 link_state_arg = qdf_mem_malloc(sizeof(*link_state_arg));
1344 if (link_state_arg) {
1345 link_state_arg->result_code = param->result_code;
1346 link_state_arg->prot_status_code =
1347 param->prot_status_code;
1348 link_state_arg->pe_session_id = session->peSessionId;
1349 }
1350 if (lim_set_link_state(mac_ctx, eSIR_LINK_DOWN_STATE,
1351 session->bssId,
1352 session->selfMacAddr,
1353 lim_join_result_callback,
1354 link_state_arg) != QDF_STATUS_SUCCESS) {
1355 qdf_mem_free(link_state_arg);
1356 pe_err("Failed to set the LinkState");
1357 }
1358 return QDF_STATUS_SUCCESS;
1359 }
1360
1361
1362 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP,
1363 param->result_code,
1364 param->prot_status_code,
1365 session, session->smeSessionId,
1366 session->transactionId);
1367 return QDF_STATUS_SUCCESS;
1368}
1369
yeshwanth sriram guntuka7419da72017-01-19 21:17:30 +05301370/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371 * lim_handle_sme_join_result() - Handles sme join result
1372 * @mac_ctx: Pointer to Global MAC structure
1373 * @result_code: Failure code to be sent
1374 * @prot_status_code : Protocol status code
1375 * @session_entry: PE session handle
1376 *
1377 * This function is called to process join/auth/assoc failures
1378 * upon receiving MLM_JOIN/AUTH/ASSOC_CNF with a failure code or
1379 * MLM_ASSOC_CNF with a success code in case of STA role and
1380 * MLM_JOIN_CNF with success in case of STA in IBSS role.
1381 *
1382 * Return: None
1383 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001384void lim_handle_sme_join_result(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 tSirResultCodes result_code, uint16_t prot_status_code,
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08001386 struct pe_session *session)
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07001387{
1388 join_params param;
1389 QDF_STATUS status;
1390
1391 if (!session) {
1392 pe_err("session is NULL");
1393 return;
1394 }
1395 if (result_code == eSIR_SME_SUCCESS)
1396 return lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP,
1397 result_code,
1398 prot_status_code, session,
1399 session->smeSessionId,
1400 session->transactionId);
1401
1402 param.result_code = result_code;
1403 param.prot_status_code = prot_status_code;
1404 param.pe_session_id = session->peSessionId;
1405
1406 mlme_set_connection_fail(session->vdev, true);
1407 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1408 WLAN_VDEV_SM_EV_CONNECTION_FAIL,
1409 sizeof(param), &param);
1410 return;
1411}
1412#else
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001413void lim_handle_sme_join_result(struct mac_context *mac_ctx,
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07001414 tSirResultCodes result_code, uint16_t prot_status_code,
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08001415 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416{
1417 tpDphHashNode sta_ds = NULL;
1418 uint8_t sme_session_id;
1419 uint16_t sme_trans_id;
yeshwanth sriram guntuka7419da72017-01-19 21:17:30 +05301420 join_params *param = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421
1422 if (session_entry == NULL) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001423 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 return;
1425 }
1426 sme_session_id = session_entry->smeSessionId;
1427 sme_trans_id = session_entry->transactionId;
1428 /*
1429 * When associations is failed , delete the session created
1430 * and pass NULL to limsendsmeJoinReassocRsp()
1431 */
1432 if (result_code != eSIR_SME_SUCCESS) {
1433 sta_ds =
1434 dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
1435 &session_entry->dph.dphHashTable);
1436 if (sta_ds != NULL) {
1437 sta_ds->mlmStaContext.disassocReason =
1438 eSIR_MAC_UNSPEC_FAILURE_REASON;
1439 sta_ds->mlmStaContext.cleanupTrigger =
1440 eLIM_JOIN_FAILURE;
1441 sta_ds->mlmStaContext.resultCode = result_code;
1442 sta_ds->mlmStaContext.protStatusCode = prot_status_code;
1443 /*
1444 * FIX_ME: at the end of lim_cleanup_rx_path,
1445 * make sure PE is sending eWNI_SME_JOIN_RSP
1446 * to SME
1447 */
1448 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
Naveen Rawat2d57a0d2016-10-21 15:59:54 -07001449 qdf_mem_free(session_entry->pLimJoinReq);
1450 session_entry->pLimJoinReq = NULL;
Abhishek Singh96bda8e2015-12-03 16:45:35 +05301451 /* Cleanup if add bss failed */
1452 if (session_entry->add_bss_failed) {
1453 dph_delete_hash_entry(mac_ctx,
1454 sta_ds->staAddr, sta_ds->assocId,
1455 &session_entry->dph.dphHashTable);
1456 goto error;
1457 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 return;
1459 }
Naveen Rawat2d57a0d2016-10-21 15:59:54 -07001460 qdf_mem_free(session_entry->pLimJoinReq);
1461 session_entry->pLimJoinReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 }
Abhishek Singh96bda8e2015-12-03 16:45:35 +05301463error:
Varun Reddy Yeturua47f08f2018-08-07 14:45:31 -07001464 /* Delete the session if JOIN failure occurred.
1465 * if the peer is not created, then there is no
1466 * need to send down the set link state which will
1467 * try to delete the peer. Instead a join response
1468 * failure should be sent to the upper layers.
1469 */
1470 if (result_code != eSIR_SME_SUCCESS &&
1471 result_code != eSIR_SME_PEER_CREATE_FAILED) {
yeshwanth sriram guntuka7419da72017-01-19 21:17:30 +05301472 param = qdf_mem_malloc(sizeof(join_params));
1473 if (param != NULL) {
1474 param->result_code = result_code;
1475 param->prot_status_code = prot_status_code;
1476 param->pe_session_id = session_entry->peSessionId;
1477 }
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07001478 if (lim_set_link_state(mac_ctx, eSIR_LINK_DOWN_STATE,
1479 session_entry->bssId,
1480 session_entry->selfMacAddr,
1481 lim_join_result_callback,
1482 param) != QDF_STATUS_SUCCESS) {
Krishna Kumaar Natarajanfc8c3632017-05-24 17:09:40 -07001483 qdf_mem_free(param);
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001484 pe_err("Failed to set the LinkState");
Krishna Kumaar Natarajanfc8c3632017-05-24 17:09:40 -07001485 }
yeshwanth sriram guntuka7419da72017-01-19 21:17:30 +05301486 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 }
1488
1489 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, result_code,
1490 prot_status_code, session_entry, sme_session_id, sme_trans_id);
1491}
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07001492#endif
1493
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494
1495/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 * lim_process_mlm_add_sta_rsp()
1497 *
1498 ***FUNCTION:
1499 * This function is called to process a WMA_ADD_STA_RSP from HAL.
1500 * Upon receipt of this message from HAL, MLME -
1501 * > Determines the "state" in which this message was received
1502 * > Forwards it to the appropriate callback
1503 *
1504 ***ASSUMPTIONS:
1505 *
1506 ***NOTE:
1507 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001508 * @param mac Pointer to Global MAC structure
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001509 * @param struct scheduler_msg The MsgQ header, which contains the
1510 * response buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 *
1512 * @return None
1513 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001514void lim_process_mlm_add_sta_rsp(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001515 struct scheduler_msg *limMsgQ,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001516 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517{
1518 /* we need to process the deferred message since the initiating req. there might be nested request. */
1519 /* in the case of nested request the new request initiated from the response will take care of resetting */
1520 /* the deffered flag. */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001521 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001522 if (LIM_IS_AP_ROLE(pe_session)) {
1523 lim_process_ap_mlm_add_sta_rsp(mac, limMsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 return;
1525 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001526 lim_process_sta_mlm_add_sta_rsp(mac, limMsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527}
1528
1529/**
1530 * lim_process_sta_mlm_add_sta_rsp () - Process add sta response
1531 * @mac_ctx: Pointer to mac context
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001532 * @msg: struct scheduler_msg *an Message structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 * @session_entry: PE session entry
1534 *
1535 * Process ADD STA response sent from WMA and posts results
1536 * to SME.
1537 *
1538 * Return: Null
1539 */
1540
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001541void lim_process_sta_mlm_add_sta_rsp(struct mac_context *mac_ctx,
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08001542 struct scheduler_msg *msg, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543{
1544 tLimMlmAssocCnf mlm_assoc_cnf;
1545 tpDphHashNode sta_ds;
1546 uint32_t msg_type = LIM_MLM_ASSOC_CNF;
1547 tpAddStaParams add_sta_params = (tpAddStaParams) msg->bodyptr;
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08001548 struct pe_session *ft_session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 uint8_t ft_session_id;
1550
1551 if (NULL == add_sta_params) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001552 pe_err("Encountered NULL Pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 return;
1554 }
1555
1556 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
1557 msg_type = LIM_MLM_REASSOC_CNF;
1558
1559 if (true == session_entry->fDeauthReceived) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001560 pe_err("Received Deauth frame in ADD_STA_RESP state");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301561 if (QDF_STATUS_SUCCESS == add_sta_params->status) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001562 pe_err("ADD_STA success, send update result code with eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA staIdx: %d limMlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 add_sta_params->staIdx,
1564 session_entry->limMlmState);
1565
1566 if (session_entry->limSmeState ==
1567 eLIM_SME_WT_REASSOC_STATE)
1568 msg_type = LIM_MLM_REASSOC_CNF;
1569 /*
1570 * We are sending result code
1571 * eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA which
1572 * will trigger proper cleanup (DEL_STA/DEL_BSS both
1573 * required) in either assoc cnf or reassoc cnf handler.
1574 */
1575 mlm_assoc_cnf.resultCode =
1576 eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA;
Abhishek Singhac2be142015-12-03 16:16:25 +05301577 mlm_assoc_cnf.protStatusCode =
1578 eSIR_MAC_UNSPEC_FAILURE_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 session_entry->staId = add_sta_params->staIdx;
1580 goto end;
1581 }
1582 }
1583
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301584 if (QDF_STATUS_SUCCESS == add_sta_params->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 if (eLIM_MLM_WT_ADD_STA_RSP_STATE !=
1586 session_entry->limMlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001587 pe_err("Received WMA_ADD_STA_RSP in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 session_entry->limMlmState);
1589 mlm_assoc_cnf.resultCode =
1590 (tSirResultCodes) eSIR_SME_REFUSED;
1591 goto end;
1592 }
1593 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 /* check if we have keys(PTK)to install in case of 11r */
1595 tpftPEContext ft_ctx = &session_entry->ftPEContext;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 ft_session = pe_find_session_by_bssid(mac_ctx,
1598 session_entry->limReAssocbssId, &ft_session_id);
1599 if (ft_session != NULL &&
1600 ft_ctx->PreAuthKeyInfo.extSetStaKeyParamValid
1601 == true) {
1602 tpLimMlmSetKeysReq pMlmStaKeys =
1603 &ft_ctx->PreAuthKeyInfo.extSetStaKeyParam;
1604 lim_send_set_sta_key_req(mac_ctx, pMlmStaKeys,
1605 0, 0, ft_session, false);
1606 ft_ctx->PreAuthKeyInfo.extSetStaKeyParamValid =
1607 false;
1608 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609 }
1610 /*
1611 * Update the DPH Hash Entry for this STA
1612 * with proper state info
1613 */
1614 sta_ds =
1615 dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
1616 &session_entry->dph.dphHashTable);
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301617 if (NULL != sta_ds) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 sta_ds->mlmStaContext.mlmState =
1619 eLIM_MLM_LINK_ESTABLISHED_STATE;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301620 sta_ds->nss = add_sta_params->nss;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301621 } else
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001622 pe_warn("Fail to get DPH Hash Entry for AID - %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 DPH_STA_HASH_INDEX_PEER);
1624 session_entry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1625 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
1626 session_entry->peSessionId,
1627 session_entry->limMlmState));
1628 /*
1629 * Storing the self StaIndex(Generated by HAL) in
1630 * session context, instead of storing it in DPH Hash
1631 * entry for Self STA.
1632 * DPH entry for the self STA stores the sta index for
1633 * the BSS entry to which the STA is associated
1634 */
1635 session_entry->staId = add_sta_params->staIdx;
1636
1637#ifdef WLAN_DEBUG
1638 mac_ctx->lim.gLimNumLinkEsts++;
1639#endif
1640#ifdef FEATURE_WLAN_TDLS
1641 /* initialize TDLS peer related data */
1642 lim_init_tdls_data(mac_ctx, session_entry);
1643#endif
1644 /*
1645 * Return Assoc confirm to SME with success
1646 * FIXME - Need the correct ASSOC RSP code to
1647 * be passed in here
1648 */
1649 mlm_assoc_cnf.resultCode = (tSirResultCodes) eSIR_SME_SUCCESS;
Arif Hussain05fb4872018-01-03 16:02:55 -08001650 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
1651 OBSS_COLOR_COLLISION_DETECTION);
Kiran Kumar Lokereb52cfc82018-10-08 21:54:38 -07001652 if (lim_is_session_he_capable(session_entry)) {
1653 if (mac_ctx->usr_cfg_mu_edca_params) {
1654 pe_debug("Send user cfg MU EDCA params to FW");
1655 lim_send_edca_params(mac_ctx,
1656 mac_ctx->usr_mu_edca_params,
1657 sta_ds->bssId, true);
1658 } else if (session_entry->mu_edca_present) {
1659 pe_debug("Send MU EDCA params to FW");
1660 lim_send_edca_params(mac_ctx,
1661 session_entry->ap_mu_edca_params,
1662 sta_ds->bssId, true);
1663 }
1664 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 } else {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001666 pe_err("ADD_STA failed!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
1668 mlm_assoc_cnf.resultCode =
1669 (tSirResultCodes) eSIR_SME_FT_REASSOC_FAILURE;
1670 else
1671 mlm_assoc_cnf.resultCode =
1672 (tSirResultCodes) eSIR_SME_REFUSED;
Abhishek Singhac2be142015-12-03 16:16:25 +05301673 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 }
1675end:
1676 if (NULL != msg->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301677 qdf_mem_free(add_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 msg->bodyptr = NULL;
1679 }
1680 /* Updating PE session Id */
1681 mlm_assoc_cnf.sessionId = session_entry->peSessionId;
1682 lim_post_sme_message(mac_ctx, msg_type, (uint32_t *) &mlm_assoc_cnf);
1683 if (true == session_entry->fDeauthReceived)
1684 session_entry->fDeauthReceived = false;
1685 return;
1686}
1687
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001688void lim_process_mlm_del_bss_rsp(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001689 struct scheduler_msg *limMsgQ,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001690 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691{
1692 /* we need to process the deferred message since the initiating req. there might be nested request. */
1693 /* in the case of nested request the new request initiated from the response will take care of resetting */
1694 /* the deffered flag. */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001695 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
1696 mac->sys.gSysFrameCount[SIR_MAC_MGMT_FRAME][SIR_MAC_MGMT_DEAUTH] = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001698 if (LIM_IS_AP_ROLE(pe_session) &&
1699 (pe_session->statypeForBss == STA_ENTRY_SELF)) {
1700 lim_process_ap_mlm_del_bss_rsp(mac, limMsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001701 return;
1702 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001703 lim_process_sta_mlm_del_bss_rsp(mac, limMsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704
1705#ifdef WLAN_FEATURE_11W
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001706 if (pe_session->limRmfEnabled) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001707 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001708 lim_send_exclude_unencrypt_ind(mac, true, pe_session)) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001709 pe_err("Could not send down Exclude Unencrypted Indication!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 }
1711 }
1712#endif
1713}
1714
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001715void lim_process_sta_mlm_del_bss_rsp(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001716 struct scheduler_msg *limMsgQ,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001717 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718{
1719 tpDeleteBssParams pDelBssParams = (tpDeleteBssParams) limMsgQ->bodyptr;
1720 tpDphHashNode pStaDs =
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001721 dph_get_hash_entry(mac, DPH_STA_HASH_INDEX_PEER,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001722 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
1724
1725 if (NULL == pDelBssParams) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001726 pe_err("Invalid body pointer in message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 goto end;
1728 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301729 if (QDF_STATUS_SUCCESS == pDelBssParams->status) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001730 pe_debug("STA received the DEL_BSS_RSP for BSSID: %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 pDelBssParams->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 if (lim_set_link_state
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001733 (mac, eSIR_LINK_IDLE_STATE, pe_session->bssId,
1734 pe_session->selfMacAddr, NULL,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001735 NULL) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001736 pe_err("Failure in setting link state to IDLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 statusCode = eSIR_SME_REFUSED;
1738 goto end;
1739 }
1740 if (pStaDs == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001741 pe_err("DPH Entry for STA 1 missing");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 statusCode = eSIR_SME_REFUSED;
1743 goto end;
1744 }
1745 if (eLIM_MLM_WT_DEL_BSS_RSP_STATE !=
1746 pStaDs->mlmStaContext.mlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001747 pe_err("Received unexpected WMA_DEL_BSS_RSP in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 pStaDs->mlmStaContext.mlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 statusCode = eSIR_SME_REFUSED;
1750 goto end;
1751 }
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001752 pe_debug("STA AssocID %d MAC", pStaDs->assocId);
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001753 lim_print_mac_addr(mac, pStaDs->staAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 } else {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001755 pe_err("DEL BSS failed!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 statusCode = eSIR_SME_STOP_BSS_FAILURE;
1757 }
1758end:
1759 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301760 qdf_mem_free(pDelBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761 limMsgQ->bodyptr = NULL;
1762 }
1763 if (pStaDs == NULL)
1764 return;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001765 if ((LIM_IS_STA_ROLE(pe_session)) &&
1766 (pe_session->limSmeState !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 eLIM_SME_WT_DISASSOC_STATE &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001768 pe_session->limSmeState !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 eLIM_SME_WT_DEAUTH_STATE) &&
1770 pStaDs->mlmStaContext.cleanupTrigger !=
1771 eLIM_JOIN_FAILURE) {
1772 /** The Case where the DelBss is invoked from
1773 * context of other than normal DisAssoc / Deauth OR
1774 * as part of Join Failure.
1775 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001776 lim_handle_del_bss_in_re_assoc_context(mac, pStaDs, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 return;
1778 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001779 lim_prepare_and_send_del_sta_cnf(mac, pStaDs, statusCode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 return;
1781}
1782
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001783void lim_process_ap_mlm_del_bss_rsp(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001784 struct scheduler_msg *limMsgQ,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001785 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786{
1787 tSirResultCodes rc = eSIR_SME_SUCCESS;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001788 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 tpDeleteBssParams pDelBss = (tpDeleteBssParams) limMsgQ->bodyptr;
1790 tSirMacAddr nullBssid = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
1791
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001792 if (pe_session == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001793 pe_err("Session entry passed is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 if (pDelBss != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301795 qdf_mem_free(pDelBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 limMsgQ->bodyptr = NULL;
1797 }
1798 return;
1799 }
1800
1801 if (pDelBss == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001802 pe_err("BSS: DEL_BSS_RSP with no body!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 rc = eSIR_SME_REFUSED;
1804 goto end;
1805 }
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001806 mac->lim.gLimMlmState = eLIM_MLM_IDLE_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 MTRACE(mac_trace
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001808 (mac, TRACE_CODE_MLM_STATE, NO_SESSION,
1809 mac->lim.gLimMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001811 if (eLIM_MLM_WT_DEL_BSS_RSP_STATE != pe_session->limMlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001812 pe_err("Received unexpected WMA_DEL_BSS_RSP in state %X",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001813 pe_session->limMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 rc = eSIR_SME_REFUSED;
1815 goto end;
1816 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301817 if (pDelBss->status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001818 pe_err("BSS: DEL_BSS_RSP error (%x) Bss %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 pDelBss->status, pDelBss->bssIdx);
1820 rc = eSIR_SME_STOP_BSS_FAILURE;
1821 goto end;
1822 }
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001823 status = lim_set_link_state(mac, eSIR_LINK_IDLE_STATE, nullBssid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001824 pe_session->selfMacAddr, NULL, NULL);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001825 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 rc = eSIR_SME_REFUSED;
1827 goto end;
1828 }
1829 /** Softmac may send all the buffered packets right after resuming the transmission hence
1830 * to occupy the medium during non channel occupancy period. So resume the transmission after
1831 * HAL gives back the response.
1832 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001833 dph_hash_table_class_init(mac, &pe_session->dph.dphHashTable);
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001834 lim_delete_pre_auth_list(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 /* Initialize number of associated stations during cleanup */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001836 pe_session->gLimNumOfCurrentSTAs = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837end:
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08001838 lim_send_sme_rsp(mac, eWNI_SME_STOP_BSS_RSP, rc,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001839 pe_session->smeSessionId,
1840 pe_session->transactionId);
1841 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842
1843 if (pDelBss != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301844 qdf_mem_free(pDelBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 limMsgQ->bodyptr = NULL;
1846 }
1847}
1848
1849/**
1850 * lim_process_mlm_del_sta_rsp() - Process DEL STA response
1851 * @mac_ctx: Pointer to Global MAC structure
1852 * @msg: The MsgQ header, which contains the response buffer
1853 *
1854 * This function is called to process a WMA_DEL_STA_RSP from
1855 * WMA Upon receipt of this message from FW.
1856 *
1857 * Return: None
1858 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001859void lim_process_mlm_del_sta_rsp(struct mac_context *mac_ctx,
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001860 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861{
1862 /*
1863 * we need to process the deferred message since the
1864 * initiating req. there might be nested request
1865 * in the case of nested request the new request
1866 * initiated from the response will take care of resetting
1867 * the deffered flag.
1868 */
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08001869 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 tpDeleteStaParams del_sta_params;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 del_sta_params = (tpDeleteStaParams) msg->bodyptr;
1873 if (NULL == del_sta_params) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001874 pe_err("null pointer del_sta_params msg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875 return;
1876 }
1877 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
1878
1879 session_entry = pe_find_session_by_session_id(mac_ctx,
1880 del_sta_params->sessionId);
1881 if (NULL == session_entry) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001882 pe_err("Session Doesn't exist: %d",
Peng Xu66162de2016-02-11 17:01:20 -08001883 del_sta_params->sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301884 qdf_mem_free(del_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885 msg->bodyptr = NULL;
1886 return;
1887 }
1888
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001889 if (LIM_IS_AP_ROLE(session_entry)) {
1890 lim_process_ap_mlm_del_sta_rsp(mac_ctx, msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 session_entry);
1892 return;
1893 }
Abhishek Singh3df76612017-05-16 14:05:32 +05301894 if (LIM_IS_IBSS_ROLE(session_entry)) {
1895 lim_process_ibss_del_sta_rsp(mac_ctx, msg,
1896 session_entry);
1897 return;
1898 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07001899 if (LIM_IS_NDI_ROLE(session_entry)) {
1900 lim_process_ndi_del_sta_rsp(mac_ctx, msg, session_entry);
1901 return;
1902 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 lim_process_sta_mlm_del_sta_rsp(mac_ctx, msg, session_entry);
1904}
1905
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301906/**
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001907 * lim_process_ap_mlm_del_sta_rsp() - Process WMA_DEL_STA_RSP
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301908 * @mac_ctx: Global pointer to MAC context
1909 * @msg: Received message
1910 * @session_entry: Session entry
1911 *
Rajeev Kumaraa262c42016-04-15 15:41:08 -07001912 * Process WMA_DEL_STA_RSP for AP role
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301913 *
1914 * Retunrn: None
1915 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001916void lim_process_ap_mlm_del_sta_rsp(struct mac_context *mac_ctx,
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001917 struct scheduler_msg *msg,
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08001918 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001919{
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301920 tpDeleteStaParams del_sta_params = (tpDeleteStaParams) msg->bodyptr;
1921 tpDphHashNode sta_ds;
1922 tSirResultCodes status_code = eSIR_SME_SUCCESS;
1923
1924 if (msg->bodyptr == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001925 pe_err("msg->bodyptr NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926 return;
1927 }
1928
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301929 sta_ds = dph_get_hash_entry(mac_ctx, del_sta_params->assocId,
1930 &session_entry->dph.dphHashTable);
1931 if (sta_ds == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001932 pe_err("DPH Entry for STA %X missing",
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301933 del_sta_params->assocId);
1934 status_code = eSIR_SME_REFUSED;
1935 qdf_mem_free(del_sta_params);
1936 msg->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 return;
1938 }
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001939 pe_debug("Received del Sta Rsp in StaD MlmState: %d",
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301940 sta_ds->mlmStaContext.mlmState);
1941 if (QDF_STATUS_SUCCESS != del_sta_params->status) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001942 pe_warn("DEL STA failed!");
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301943 status_code = eSIR_SME_REFUSED;
1944 goto end;
1945 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001947 pe_warn("AP received the DEL_STA_RSP for assocID: %X",
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301948 del_sta_params->assocId);
1949 if ((eLIM_MLM_WT_DEL_STA_RSP_STATE != sta_ds->mlmStaContext.mlmState) &&
1950 (eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
1951 sta_ds->mlmStaContext.mlmState)) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001952 pe_err("Received unexpected WMA_DEL_STA_RSP in state %s for staId %d assocId %d",
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301953 lim_mlm_state_str(sta_ds->mlmStaContext.mlmState),
1954 sta_ds->staIndex, sta_ds->assocId);
1955 status_code = eSIR_SME_REFUSED;
1956 goto end;
1957 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001959 pe_debug("Deleted STA AssocID %d staId %d MAC",
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301960 sta_ds->assocId, sta_ds->staIndex);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301961 lim_print_mac_addr(mac_ctx, sta_ds->staAddr, LOGD);
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301962 if (eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE ==
1963 sta_ds->mlmStaContext.mlmState) {
1964 qdf_mem_free(del_sta_params);
1965 msg->bodyptr = NULL;
1966 if (lim_add_sta(mac_ctx, sta_ds, false, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001967 QDF_STATUS_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07001968 pe_err("could not Add STA with assocId: %d",
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301969 sta_ds->assocId);
1970 /*
1971 * delete the TS if it has already been added.
1972 * send the response with error status.
1973 */
1974 if (sta_ds->qos.addtsPresent) {
1975 tpLimTspecInfo pTspecInfo;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001976
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001977 if (QDF_STATUS_SUCCESS ==
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301978 lim_tspec_find_by_assoc_id(mac_ctx,
1979 sta_ds->assocId,
1980 &sta_ds->qos.addts.tspec,
1981 &mac_ctx->lim.tspecInfo[0],
1982 &pTspecInfo)) {
1983 lim_admit_control_delete_ts(mac_ctx,
1984 sta_ds->assocId,
1985 &sta_ds->qos.addts.tspec.tsinfo,
1986 NULL,
1987 &pTspecInfo->idx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 }
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301990 lim_reject_association(mac_ctx, sta_ds->staAddr,
1991 sta_ds->mlmStaContext.subType, true,
1992 sta_ds->mlmStaContext.authType, sta_ds->assocId,
1993 true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001994 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301995 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 }
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05301997 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 }
1999end:
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05302000 qdf_mem_free(del_sta_params);
2001 msg->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 if (eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
Sreelakshmi Konamkic43ee5b2016-03-09 14:28:05 +05302003 sta_ds->mlmStaContext.mlmState) {
2004 lim_prepare_and_send_del_sta_cnf(mac_ctx, sta_ds, status_code,
2005 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 }
2007 return;
2008}
2009
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002010void lim_process_sta_mlm_del_sta_rsp(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002011 struct scheduler_msg *limMsgQ,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002012 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013{
2014 tSirResultCodes statusCode = eSIR_SME_SUCCESS;
2015 tpDeleteStaParams pDelStaParams = (tpDeleteStaParams) limMsgQ->bodyptr;
2016 tpDphHashNode pStaDs = NULL;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002017#ifdef CONFIG_VDEV_SM
2018 QDF_STATUS status;
2019#endif
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 if (NULL == pDelStaParams) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002022 pe_err("Encountered NULL Pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 goto end;
2024 }
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002025 pe_debug("Del STA RSP received. Status: %d AssocID: %d",
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07002026 pDelStaParams->status, pDelStaParams->assocId);
2027
Padma, Santhosh Kumar4eb79082017-02-24 16:00:20 +05302028#ifdef FEATURE_WLAN_TDLS
2029 if (pDelStaParams->staType == STA_ENTRY_TDLS_PEER) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002030 pe_debug("TDLS Del STA RSP received");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002031 lim_process_tdls_del_sta_rsp(mac, limMsgQ, pe_session);
Padma, Santhosh Kumar4eb79082017-02-24 16:00:20 +05302032 return;
2033 }
2034#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302035 if (QDF_STATUS_SUCCESS != pDelStaParams->status)
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002036 pe_err("Del STA failed! Status:%d, proceeding with Del BSS",
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07002037 pDelStaParams->status);
2038
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002039 pStaDs = dph_get_hash_entry(mac, DPH_STA_HASH_INDEX_PEER,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002040 &pe_session->dph.dphHashTable);
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07002041 if (pStaDs == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002042 pe_err("DPH Entry for STA %X missing",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 pDelStaParams->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 statusCode = eSIR_SME_REFUSED;
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07002045 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002047 if (eLIM_MLM_WT_DEL_STA_RSP_STATE != pe_session->limMlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002048 pe_err("Received unexpected WDA_DELETE_STA_RSP in state %s",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002049 lim_mlm_state_str(pe_session->limMlmState));
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07002050 statusCode = eSIR_SME_REFUSED;
2051 goto end;
2052 }
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002053 pe_debug("STA AssocID %d MAC", pStaDs->assocId);
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002054 lim_print_mac_addr(mac, pStaDs->staAddr, LOGD);
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07002055 /*
2056 * we must complete all cleanup related to delSta before
2057 * calling limDelBSS.
2058 */
2059 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302060 qdf_mem_free(pDelStaParams);
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07002061 limMsgQ->bodyptr = NULL;
2062 }
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002063#ifdef CONFIG_VDEV_SM
2064 status =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002065 wlan_vdev_mlme_sm_deliver_evt(pe_session->vdev,
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002066 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002067 sizeof(*pe_session),
2068 pe_session);
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002069 if (QDF_IS_STATUS_ERROR(status)) {
2070 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002071 pe_session->smeSessionId);
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002072 }
2073#else
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07002074 /* Proceed to do DelBSS even if DelSta resulted in failure */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002075 statusCode = (tSirResultCodes)lim_del_bss(mac, pStaDs, 0,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002076 pe_session);
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002077#endif
2078
Vidyullatha Kanchanapallydcd3b5a2015-08-14 16:54:08 -07002079 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080end:
2081 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302082 qdf_mem_free(pDelStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 limMsgQ->bodyptr = NULL;
2084 }
2085 return;
2086}
2087
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002088void lim_process_ap_mlm_add_sta_rsp(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002089 struct scheduler_msg *limMsgQ,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002090 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091{
2092 tpAddStaParams pAddStaParams = (tpAddStaParams) limMsgQ->bodyptr;
2093 tpDphHashNode pStaDs = NULL;
2094
2095 if (NULL == pAddStaParams) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002096 pe_err("Invalid body pointer in message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 goto end;
2098 }
2099
2100 pStaDs =
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002101 dph_get_hash_entry(mac, pAddStaParams->assocId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002102 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 if (pStaDs == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002104 pe_err("DPH Entry for STA %X missing", pAddStaParams->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 goto end;
2106 }
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 if (eLIM_MLM_WT_ADD_STA_RSP_STATE != pStaDs->mlmStaContext.mlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002109 pe_err("Received unexpected WMA_ADD_STA_RSP in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 pStaDs->mlmStaContext.mlmState);
2111 goto end;
2112 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302113 if (QDF_STATUS_SUCCESS != pAddStaParams->status) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002114 pe_err("Error! rcvd delSta rsp from HAL with status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 pAddStaParams->status);
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002116 lim_reject_association(mac, pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 pStaDs->mlmStaContext.subType,
2118 true, pStaDs->mlmStaContext.authType,
2119 pStaDs->assocId, true,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002121 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 goto end;
2123 }
2124 pStaDs->bssId = pAddStaParams->bssIdx;
2125 pStaDs->staIndex = pAddStaParams->staIdx;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05302126 pStaDs->nss = pAddStaParams->nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 /* if the AssocRsp frame is not acknowledged, then keep alive timer will take care of the state */
2128 pStaDs->valid = 1;
2129 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ASSOC_CNF_STATE;
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002130 pe_debug("AddStaRsp Success.STA AssocID %d staId %d MAC",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 pStaDs->assocId, pStaDs->staIndex);
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002132 lim_print_mac_addr(mac, pStaDs->staAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133
2134 /* For BTAMP-AP, the flow sequence shall be:
2135 * 1) PE sends eWNI_SME_ASSOC_IND to SME
2136 * 2) PE receives eWNI_SME_ASSOC_CNF from SME
2137 * 3) BTAMP-AP sends Re/Association Response to BTAMP-STA
2138 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002139 lim_send_mlm_assoc_ind(mac, pStaDs, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 /* fall though to reclaim the original Add STA Response message */
2141end:
2142 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302143 qdf_mem_free(pAddStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 limMsgQ->bodyptr = NULL;
2145 }
2146 return;
2147}
2148
2149/**
2150 * lim_process_ap_mlm_add_bss_rsp()
2151 *
2152 ***FUNCTION:
2153 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2154 * Upon receipt of this message from HAL, MLME -
2155 * > Validates the result of WMA_ADD_BSS_REQ
2156 * > Init other remaining LIM variables
2157 * > Init the AID pool, for that BSSID
2158 * > Init the Pre-AUTH list, for that BSSID
2159 * > Create LIM timers, specific to that BSSID
2160 * > Init DPH related parameters that are specific to that BSSID
2161 * > TODO - When do we do the actual change channel?
2162 *
2163 ***LOGIC:
2164 * SME sends eWNI_SME_START_BSS_REQ to LIM
2165 * LIM sends LIM_MLM_START_REQ to MLME
2166 * MLME sends WMA_ADD_BSS_REQ to HAL
2167 * HAL responds with WMA_ADD_BSS_RSP to MLME
2168 * MLME responds with LIM_MLM_START_CNF to LIM
2169 * LIM responds with eWNI_SME_START_BSS_RSP to SME
2170 *
2171 ***ASSUMPTIONS:
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002172 * struct scheduler_msg.body is allocated by MLME during
2173 * lim_process_mlm_start_req
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002174 * struct scheduler_msg.body will now be freed by this routine
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 *
2176 ***NOTE:
2177 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002178 * @param mac Pointer to Global MAC structure
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002179 * @param struct scheduler_msg The MsgQ header, which contains
2180 * the response buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 *
2182 * @return None
2183 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002184static void lim_process_ap_mlm_add_bss_rsp(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002185 struct scheduler_msg *limMsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186{
2187 tLimMlmStartCnf mlmStartCnf;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002188 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 uint8_t isWepEnabled = false;
2190 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 if (NULL == pAddBssParams) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002193 pe_err("Encountered NULL Pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 goto end;
2195 }
2196 /* TBD: free the memory before returning, do it for all places where lookup fails. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002197 pe_session = pe_find_session_by_session_id(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 pAddBssParams->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002199 if (pe_session == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002200 pe_err("session does not exist for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 if (NULL != pAddBssParams) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302202 qdf_mem_free(pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 limMsgQ->bodyptr = NULL;
2204 }
2205 return;
2206 }
2207 /* Update PE session Id */
2208 mlmStartCnf.sessionId = pAddBssParams->sessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302209 if (QDF_STATUS_SUCCESS == pAddBssParams->status) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002210 pe_debug("WMA_ADD_BSS_RSP returned with QDF_STATUS_SUCCESS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 if (lim_set_link_state
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002212 (mac, eSIR_LINK_AP_STATE, pe_session->bssId,
2213 pe_session->selfMacAddr, NULL,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002214 NULL) != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 goto end;
2216 /* Set MLME state */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002217 pe_session->limMlmState = eLIM_MLM_BSS_STARTED_STATE;
2218 pe_session->chainMask = pAddBssParams->chainMask;
2219 pe_session->smpsMode = pAddBssParams->smpsMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002221 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
2222 pe_session->limMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 if (eSIR_IBSS_MODE == pAddBssParams->bssType) {
2224 /** IBSS is 'active' when we receive
2225 * Beacon frames from other STAs that are part of same IBSS.
2226 * Mark internal state as inactive until then.
2227 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002228 pe_session->limIbssActive = false;
2229 pe_session->statypeForBss = STA_ENTRY_PEER; /* to know session created for self/peer */
2230 limResetHBPktCount(pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002232 pe_session->bssIdx = (uint8_t) pAddBssParams->bssIdx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002234 pe_session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235
2236 if (eSIR_INFRA_AP_MODE == pAddBssParams->bssType)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002237 pe_session->limSystemRole = eLIM_AP_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002239 pe_session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
2240 sch_edca_profile_update(mac, pe_session);
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002241 lim_init_pre_auth_list(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 /* Check the SAP security configuration.If configured to
2243 * WEP then max clients supported is 16
2244 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002245 if (pe_session->privacy) {
2246 if ((pe_session->gStartBssRSNIe.present)
2247 || (pe_session->gStartBssWPAIe.present))
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002248 pe_debug("WPA/WPA2 SAP configuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 else {
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002250 if (mac->mlme_cfg->sap_cfg.assoc_sta_limit >
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 MAX_SUPPORTED_PEERS_WEP) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002252 pe_debug("WEP SAP Configuration");
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002253 mac->mlme_cfg->sap_cfg.assoc_sta_limit
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302254 = MAX_SUPPORTED_PEERS_WEP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 isWepEnabled = true;
2256 }
2257 }
2258 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002259 lim_init_peer_idxpool(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260
2261 /* Start OLBC timer */
2262 if (tx_timer_activate
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002263 (&mac->lim.limTimers.gLimUpdateOlbcCacheTimer) !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264 TX_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002265 pe_err("tx_timer_activate failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266 }
2267
2268 /* Apply previously set configuration at HW */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002269 lim_apply_configuration(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270
2271 /* In lim_apply_configuration gLimAssocStaLimit is assigned from cfg.
2272 * So update the value to 16 in case SoftAP is configured in WEP.
2273 */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002274 if ((mac->mlme_cfg->sap_cfg.assoc_sta_limit >
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302275 MAX_SUPPORTED_PEERS_WEP)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 && (isWepEnabled))
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002277 mac->mlme_cfg->sap_cfg.assoc_sta_limit =
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302278 MAX_SUPPORTED_PEERS_WEP;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002279 pe_session->staId = pAddBssParams->staContext.staIdx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
2281 } else {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002282 pe_err("WMA_ADD_BSS_REQ failed with status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 pAddBssParams->status);
2284 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
2285 }
Abhishek Singh1df50882018-08-30 18:04:29 +05302286
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002287 lim_send_start_bss_confirm(mac, &mlmStartCnf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288end:
2289 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302290 qdf_mem_free(pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 limMsgQ->bodyptr = NULL;
2292 }
2293}
2294
2295/**
2296 * lim_process_ibss_mlm_add_bss_rsp()
2297 *
2298 ***FUNCTION:
2299 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2300 * Upon receipt of this message from HAL, MLME -
2301 * > Validates the result of WMA_ADD_BSS_REQ
2302 * > Init other remaining LIM variables
2303 * > Init the AID pool, for that BSSID
2304 * > Init the Pre-AUTH list, for that BSSID
2305 * > Create LIM timers, specific to that BSSID
2306 * > Init DPH related parameters that are specific to that BSSID
2307 * > TODO - When do we do the actual change channel?
2308 *
2309 ***LOGIC:
2310 * SME sends eWNI_SME_START_BSS_REQ to LIM
2311 * LIM sends LIM_MLM_START_REQ to MLME
2312 * MLME sends WMA_ADD_BSS_REQ to HAL
2313 * HAL responds with WMA_ADD_BSS_RSP to MLME
2314 * MLME responds with LIM_MLM_START_CNF to LIM
2315 * LIM responds with eWNI_SME_START_BSS_RSP to SME
2316 *
2317 ***ASSUMPTIONS:
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002318 * struct scheduler_msg.body is allocated by MLME during
2319 * lim_process_mlm_start_req
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002320 * struct scheduler_msg.body will now be freed by this routine
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 *
2322 ***NOTE:
2323 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002324 * @param mac Pointer to Global MAC structure
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002325 * @param struct scheduler_msg The MsgQ header, which contains
2326 * the response buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327 *
2328 * @return None
2329 */
2330static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002331lim_process_ibss_mlm_add_bss_rsp(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002332 struct scheduler_msg *limMsgQ,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002333 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334{
2335 tLimMlmStartCnf mlmStartCnf;
2336 tpAddBssParams pAddBssParams = (tpAddBssParams) limMsgQ->bodyptr;
2337
2338 if (NULL == pAddBssParams) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002339 pe_err("Invalid body pointer in message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 goto end;
2341 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302342 if (QDF_STATUS_SUCCESS == pAddBssParams->status) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002343 pe_debug("WMA_ADD_BSS_RSP returned with QDF_STATUS_SUCCESS");
2344
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 if (lim_set_link_state
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002346 (mac, eSIR_LINK_IBSS_STATE, pe_session->bssId,
2347 pe_session->selfMacAddr, NULL,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002348 NULL) != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349 goto end;
2350 /* Set MLME state */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002351 pe_session->limMlmState = eLIM_MLM_BSS_STARTED_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002353 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
2354 pe_session->limMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355 /** IBSS is 'active' when we receive
2356 * Beacon frames from other STAs that are part of same IBSS.
2357 * Mark internal state as inactive until then.
2358 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002359 pe_session->limIbssActive = false;
2360 limResetHBPktCount(pe_session);
2361 pe_session->bssIdx = (uint8_t) pAddBssParams->bssIdx;
2362 pe_session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
2363 pe_session->statypeForBss = STA_ENTRY_SELF;
2364 sch_edca_profile_update(mac, pe_session);
2365 if (0 == pe_session->freePeerIdxHead)
2366 lim_init_peer_idxpool(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367
2368 /* Apply previously set configuration at HW */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002369 lim_apply_configuration(mac, pe_session);
2370 pe_session->staId = pAddBssParams->staContext.staIdx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 mlmStartCnf.resultCode = eSIR_SME_SUCCESS;
2372 /* If ADD BSS was issued as part of IBSS coalescing, don't send the message to SME, as that is internal to LIM */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002373 if (true == mac->lim.gLimIbssCoalescingHappened) {
2374 lim_ibss_add_bss_rsp_when_coalescing(mac, limMsgQ->bodyptr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002375 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 goto end;
2377 }
2378 } else {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002379 pe_err("WMA_ADD_BSS_REQ failed with status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 pAddBssParams->status);
2381 mlmStartCnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
2382 }
2383 /* Send this message to SME, when ADD_BSS is initiated by SME */
2384 /* If ADD_BSS is done as part of coalescing, this won't happen. */
2385 /* Update PE session Id */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002386 mlmStartCnf.sessionId = pe_session->peSessionId;
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08002387 lim_send_start_bss_confirm(mac, &mlmStartCnf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388end:
2389 if (0 != limMsgQ->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302390 qdf_mem_free(pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 limMsgQ->bodyptr = NULL;
2392 }
2393}
2394
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302395#ifdef WLAN_FEATURE_FILS_SK
2396/*
2397 * lim_update_fils_auth_mode: API to update Auth mode in case of fils session
2398 * @session_entry: pe session entry
2399 * @auth_mode: auth mode needs to be updated
2400 *
2401 * Return: None
2402 */
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08002403static void lim_update_fils_auth_mode(struct pe_session *session_entry,
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302404 tAniAuthType *auth_mode)
2405{
2406 if (!session_entry->fils_info)
2407 return;
2408
2409 if (session_entry->fils_info->is_fils_connection)
2410 *auth_mode = session_entry->fils_info->auth;
2411}
2412#else
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08002413static void lim_update_fils_auth_mode(struct pe_session *session_entry,
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302414 tAniAuthType *auth_mode)
2415{ }
2416#endif
2417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418/**
2419 * csr_neighbor_roam_handoff_req_hdlr - Processes handoff request
2420 * @mac_ctx: Pointer to mac context
2421 * @msg: message sent to HDD
2422 * @session_entry: PE session handle
2423 *
2424 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2425 * Upon receipt of this message from HAL if the state is pre assoc.
2426 *
2427 * Return: Null
2428 */
2429static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002430lim_process_sta_add_bss_rsp_pre_assoc(struct mac_context *mac_ctx,
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08002431 struct scheduler_msg *msg, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432{
2433 tpAddBssParams pAddBssParams = (tpAddBssParams) msg->bodyptr;
2434 tAniAuthType cfgAuthType, authMode;
2435 tLimMlmAuthReq *pMlmAuthReq;
2436 tpDphHashNode pStaDs = NULL;
2437
2438 if (NULL == pAddBssParams) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002439 pe_err("Invalid body pointer in message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440 goto joinFailure;
2441 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302442 if (QDF_STATUS_SUCCESS == pAddBssParams->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 pStaDs = dph_add_hash_entry(mac_ctx,
2444 pAddBssParams->staContext.staMac,
2445 DPH_STA_HASH_INDEX_PEER,
2446 &session_entry->dph.dphHashTable);
2447 if (pStaDs == NULL) {
2448 /* Could not add hash table entry */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002449 pe_err("could not add hash entry at DPH for");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 lim_print_mac_addr(mac_ctx,
2451 pAddBssParams->staContext.staMac, LOGE);
2452 goto joinFailure;
2453 }
2454 session_entry->bssIdx = (uint8_t) pAddBssParams->bssIdx;
2455 /* Success, handle below */
2456 pStaDs->bssId = pAddBssParams->bssIdx;
2457 /* STA Index(genr by HAL) for the BSS entry is stored here */
2458 pStaDs->staIndex = pAddBssParams->staContext.staIdx;
2459 /* Trigger Authentication with AP */
Pragaspathi Thilagarajda3b5e22018-09-23 01:55:57 +05302460 cfgAuthType = mac_ctx->mlme_cfg->wep_params.auth_type;
2461
Rajeev Kumar437c9212016-04-14 15:26:59 -07002462 /* Try shared Authentication first */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 if (cfgAuthType == eSIR_AUTO_SWITCH)
Rajeev Kumar437c9212016-04-14 15:26:59 -07002464 authMode = eSIR_SHARED_KEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 else
2466 authMode = cfgAuthType;
2467
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302468 lim_update_fils_auth_mode(session_entry, &authMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 /* Trigger MAC based Authentication */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302470 pMlmAuthReq = qdf_mem_malloc(sizeof(tLimMlmAuthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 if (NULL == pMlmAuthReq) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002472 pe_err("Allocate Memory failed for mlmAuthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 return;
2474 }
2475 sir_copy_mac_addr(pMlmAuthReq->peerMacAddr,
2476 session_entry->bssId);
2477
2478 pMlmAuthReq->authType = authMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 session_entry->limMlmState = eLIM_MLM_JOINED_STATE;
2480 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2481 session_entry->peSessionId, eLIM_MLM_JOINED_STATE));
2482 pMlmAuthReq->sessionId = session_entry->peSessionId;
2483 session_entry->limPrevSmeState = session_entry->limSmeState;
2484 session_entry->limSmeState = eLIM_SME_WT_AUTH_STATE;
2485 /* remember staId in case of assoc timeout/failure handling */
2486 session_entry->staId = pAddBssParams->staContext.staIdx;
2487
2488 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2489 session_entry->peSessionId,
2490 session_entry->limSmeState));
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002491 pe_debug("SessionId:%d lim_post_mlm_message "
2492 "LIM_MLM_AUTH_REQ with limSmeState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 session_entry->peSessionId, session_entry->limSmeState);
2494 lim_post_mlm_message(mac_ctx, LIM_MLM_AUTH_REQ,
2495 (uint32_t *) pMlmAuthReq);
2496 return;
2497 }
2498
2499joinFailure:
2500 {
2501 session_entry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
2502 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2503 session_entry->peSessionId,
2504 session_entry->limSmeState));
2505
2506 /* Send Join response to Host */
2507 lim_handle_sme_join_result(mac_ctx, eSIR_SME_REFUSED,
2508 eSIR_MAC_UNSPEC_FAILURE_STATUS, session_entry);
2509 }
2510
2511}
2512
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513/**
2514 * lim_process_sta_mlm_add_bss_rsp() - Process ADD BSS response
2515 * @mac_ctx: Pointer to Global MAC structure
2516 * @msg: The MsgQ header, which contains the response buffer
2517 *
2518 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2519 * Upon receipt of this message from HAL, MLME -
2520 * > Validates the result of WMA_ADD_BSS_REQ
2521 * > Now, send an ADD_STA to HAL and ADD the "local" STA itself
2522 *
2523 * MLME had sent WMA_ADD_BSS_REQ to HAL
2524 * HAL responded with WMA_ADD_BSS_RSP to MLME
2525 * MLME now sends WMA_ADD_STA_REQ to HAL
2526 * ASSUMPTIONS:
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002527 * struct scheduler_msg.body is allocated by MLME during
2528 * lim_process_mlm_join_req
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002529 * struct scheduler_msg.body will now be freed by this routine
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530 *
2531 * Return: None
2532 */
2533static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002534lim_process_sta_mlm_add_bss_rsp(struct mac_context *mac_ctx,
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08002535 struct scheduler_msg *msg, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536{
2537 tpAddBssParams add_bss_params = (tpAddBssParams) msg->bodyptr;
2538 tLimMlmAssocCnf mlm_assoc_cnf;
2539 uint32_t msg_type = LIM_MLM_ASSOC_CNF;
2540 uint32_t sub_type = LIM_ASSOC;
2541 tpDphHashNode sta_ds = NULL;
2542 uint16_t sta_idx = STA_INVALID_IDX;
2543 uint8_t update_sta = false;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 mlm_assoc_cnf.resultCode = eSIR_SME_SUCCESS;
2546
2547 if (eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE ==
2548 session_entry->limMlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002549 pe_debug("SessionId: %d lim_process_sta_add_bss_rsp_pre_assoc",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 session_entry->peSessionId);
2551 lim_process_sta_add_bss_rsp_pre_assoc(mac_ctx, msg,
2552 session_entry);
2553 goto end;
2554 }
2555 if (eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE == session_entry->limMlmState
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 || (eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE ==
Deepak Dhamdhere9a7110c2015-11-08 19:44:07 -08002557 session_entry->limMlmState)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 msg_type = LIM_MLM_REASSOC_CNF;
2559 sub_type = LIM_REASSOC;
2560 /*
2561 * If Reassoc is happening for the same BSS, then
2562 * use the existing StaId and indicate to HAL to update
2563 * the existing STA entry.
2564 * If Reassoc is happening for the new BSS, then
2565 * old BSS and STA entry would have been already deleted
2566 * before PE tries to add BSS for the new BSS, so set the
2567 * updateSta to false and pass INVALID STA Index.
2568 */
2569 if (sir_compare_mac_addr(session_entry->bssId,
2570 session_entry->limReAssocbssId)) {
2571 sta_idx = session_entry->staId;
2572 update_sta = true;
2573 }
2574 }
2575
2576 if (add_bss_params == 0)
2577 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302579 if (QDF_STATUS_SUCCESS == add_bss_params->status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 if (eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE ==
2581 session_entry->limMlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002582 pe_debug("Mlm=%d %d", session_entry->limMlmState,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583 eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 lim_process_sta_mlm_add_bss_rsp_ft(mac_ctx, msg,
2585 session_entry);
2586 goto end;
2587 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588
2589 /* Set MLME state */
2590 session_entry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2591 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2592 session_entry->peSessionId,
2593 session_entry->limMlmState));
2594 /* to know the session started for self or for peer */
2595 session_entry->statypeForBss = STA_ENTRY_PEER;
2596 /* Now, send WMA_ADD_STA_REQ */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002597 pe_debug("SessionId: %d On STA: ADD_BSS was successful",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 session_entry->peSessionId);
2599 sta_ds =
2600 dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
2601 &session_entry->dph.dphHashTable);
2602 if (sta_ds == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002603 pe_err("Session:%d Fail to add Self Entry for STA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 session_entry->peSessionId);
2605 mlm_assoc_cnf.resultCode =
2606 (tSirResultCodes) eSIR_SME_REFUSED;
2607 } else {
2608 session_entry->bssIdx =
2609 (uint8_t) add_bss_params->bssIdx;
2610 /* Success, handle below */
2611 sta_ds->bssId = add_bss_params->bssIdx;
2612 /*
2613 * STA Index(genr by HAL) for the BSS
2614 * entry is stored here
2615 */
2616 sta_ds->staIndex = add_bss_params->staContext.staIdx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 /* Downgrade the EDCA parameters if needed */
2618 lim_set_active_edca_params(mac_ctx,
2619 session_entry->gLimEdcaParams, session_entry);
2620 lim_send_edca_params(mac_ctx,
2621 session_entry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08002622 sta_ds->bssId, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 rrm_cache_mgmt_tx_power(mac_ctx,
2624 add_bss_params->txMgmtPower, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 if (lim_add_sta_self(mac_ctx, sta_idx, update_sta,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002626 session_entry) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 /* Add STA context at HW */
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002628 pe_err("Session:%d could not Add Self"
2629 "Entry for the station",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 session_entry->peSessionId);
2631 mlm_assoc_cnf.resultCode =
2632 (tSirResultCodes) eSIR_SME_REFUSED;
2633 }
2634 }
2635 } else {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002636 pe_err("SessionId: %d ADD_BSS failed!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 session_entry->peSessionId);
Abhishek Singhac2be142015-12-03 16:16:25 +05302638 mlm_assoc_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 /* Return Assoc confirm to SME with failure */
2640 if (eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE ==
2641 session_entry->limMlmState)
2642 mlm_assoc_cnf.resultCode =
2643 (tSirResultCodes) eSIR_SME_FT_REASSOC_FAILURE;
2644 else
2645 mlm_assoc_cnf.resultCode =
2646 (tSirResultCodes) eSIR_SME_REFUSED;
Abhishek Singh96bda8e2015-12-03 16:45:35 +05302647 session_entry->add_bss_failed = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 }
2649
2650 if (mlm_assoc_cnf.resultCode != eSIR_SME_SUCCESS) {
2651 session_entry->limMlmState = eLIM_MLM_IDLE_STATE;
2652 if (lim_set_link_state(mac_ctx, eSIR_LINK_IDLE_STATE,
2653 session_entry->bssId,
2654 session_entry->selfMacAddr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002655 NULL, NULL) != QDF_STATUS_SUCCESS)
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002656 pe_err("Failed to set the LinkState");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 /* Update PE session Id */
2658 mlm_assoc_cnf.sessionId = session_entry->peSessionId;
2659 lim_post_sme_message(mac_ctx, msg_type,
2660 (uint32_t *) &mlm_assoc_cnf);
2661 }
2662end:
2663 if (0 != msg->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302664 qdf_mem_free(add_bss_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 msg->bodyptr = NULL;
2666 }
2667}
2668
2669/**
2670 * lim_process_mlm_add_bss_rsp() - Processes ADD BSS Response
2671 *
2672 * @mac_ctx - Pointer to Global MAC structure
2673 * @msg - The MsgQ header, which contains the response buffer
2674 *
2675 * This function is called to process a WMA_ADD_BSS_RSP from HAL.
2676 * Upon receipt of this message from HAL, MLME -
2677 * Determines the "state" in which this message was received
2678 * Forwards it to the appropriate callback
2679 *
2680 *LOGIC:
2681 * WMA_ADD_BSS_RSP can be received by MLME while the LIM is
2682 * in the following two states:
2683 * 1) As AP, LIM state = eLIM_SME_WT_START_BSS_STATE
2684 * 2) As STA, LIM state = eLIM_SME_WT_JOIN_STATE
2685 * Based on these two states, this API will determine where to
2686 * route the message to
2687 *
2688 * Return None
2689 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002690void lim_process_mlm_add_bss_rsp(struct mac_context *mac_ctx,
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002691 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692{
2693 tLimMlmStartCnf mlm_start_cnf;
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08002694 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 tpAddBssParams add_bss_param = (tpAddBssParams) (msg->bodyptr);
2696 tSirBssType bss_type;
2697
2698 if (NULL == add_bss_param) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002699 pe_err("Encountered NULL Pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 return;
2701 }
2702
2703 /*
2704 * we need to process the deferred message since the
2705 * initiating req.there might be nested request.
2706 * in the case of nested request the new request initiated
2707 * from the response will take care of resetting the deffered
2708 * flag.
2709 */
2710 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
2711 /* Validate SME/LIM/MLME state */
2712 session_entry = pe_find_session_by_session_id(mac_ctx,
2713 add_bss_param->sessionId);
2714 if (session_entry == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002715 pe_err("SessionId:%d Session Doesn't exist",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 add_bss_param->sessionId);
2717 if (NULL != add_bss_param) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302718 qdf_mem_free(add_bss_param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 msg->bodyptr = NULL;
2720 }
2721 return;
2722 }
2723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 bss_type = session_entry->bssType;
2725 /* update PE session Id */
2726 mlm_start_cnf.sessionId = session_entry->peSessionId;
2727 if (eSIR_IBSS_MODE == bss_type) {
2728 lim_process_ibss_mlm_add_bss_rsp(mac_ctx, msg, session_entry);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07002729 } else if (eSIR_NDI_MODE == session_entry->bssType) {
2730 lim_process_ndi_mlm_add_bss_rsp(mac_ctx, msg, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 } else {
2732 if (eLIM_SME_WT_START_BSS_STATE == session_entry->limSmeState) {
2733 if (eLIM_MLM_WT_ADD_BSS_RSP_STATE !=
2734 session_entry->limMlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002735 pe_err("SessionId:%d Received "
2736 " WMA_ADD_BSS_RSP in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 session_entry->peSessionId,
2738 session_entry->limMlmState);
2739 mlm_start_cnf.resultCode =
2740 eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
2741 if (0 != msg->bodyptr) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302742 qdf_mem_free(add_bss_param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 msg->bodyptr = NULL;
2744 }
Abhishek Singh1df50882018-08-30 18:04:29 +05302745
2746 lim_send_start_bss_confirm(mac_ctx, &mlm_start_cnf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 } else
2748 lim_process_ap_mlm_add_bss_rsp(mac_ctx, msg);
2749 } else {
2750 /* Called while processing assoc response */
2751 lim_process_sta_mlm_add_bss_rsp(mac_ctx, msg,
2752 session_entry);
2753 }
2754 }
2755
2756#ifdef WLAN_FEATURE_11W
2757 if (session_entry->limRmfEnabled) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002758 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 lim_send_exclude_unencrypt_ind(mac_ctx, false,
2760 session_entry)) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002761 pe_err("Failed to send Exclude Unencrypted Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 }
2763 }
2764#endif
2765}
2766
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002767void lim_process_mlm_update_hidden_ssid_rsp(struct mac_context *mac_ctx,
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07002768 struct scheduler_msg *msg)
2769{
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08002770 struct pe_session *session_entry;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07002771 tpHalHiddenSsidVdevRestart hidden_ssid_vdev_restart;
2772
2773 hidden_ssid_vdev_restart = (tpHalHiddenSsidVdevRestart)(msg->bodyptr);
2774
2775 if (NULL == hidden_ssid_vdev_restart) {
2776 pe_err("NULL msg pointer");
2777 return;
2778 }
2779
2780 session_entry = pe_find_session_by_session_id(mac_ctx,
2781 hidden_ssid_vdev_restart->pe_session_id);
2782
2783 if (session_entry == NULL) {
2784 pe_err("SessionId:%d Session Doesn't exist",
2785 hidden_ssid_vdev_restart->pe_session_id);
2786 goto free_req;
2787 }
2788 /* Update beacon */
2789 sch_set_fixed_beacon_fields(mac_ctx, session_entry);
Abhishek Singh6c681f42018-09-12 15:52:36 +05302790 lim_send_beacon(mac_ctx, session_entry);
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07002791
2792free_req:
2793 if (NULL != hidden_ssid_vdev_restart) {
2794 qdf_mem_free(hidden_ssid_vdev_restart);
2795 msg->bodyptr = NULL;
2796 }
2797}
2798
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799/**
2800 * lim_process_mlm_set_sta_key_rsp() - Process STA key response
2801 *
2802 * @mac_ctx: Pointer to Global MAC structure
2803 * @msg: The MsgQ header, which contains the response buffer
2804 *
2805 * This function is called to process the following two
2806 * messages from HAL:
2807 * 1) WMA_SET_BSSKEY_RSP
2808 * 2) WMA_SET_STAKEY_RSP
2809 * 3) WMA_SET_STA_BCASTKEY_RSP
2810 * Upon receipt of this message from HAL,
2811 * MLME -
2812 * > Determines the "state" in which this message was received
2813 * > Forwards it to the appropriate callback
2814 * LOGIC:
2815 * WMA_SET_BSSKEY_RSP/WMA_SET_STAKEY_RSP can be
2816 * received by MLME while in the following state:
2817 * MLME state = eLIM_MLM_WT_SET_BSS_KEY_STATE --OR--
2818 * MLME state = eLIM_MLM_WT_SET_STA_KEY_STATE --OR--
2819 * MLME state = eLIM_MLM_WT_SET_STA_BCASTKEY_STATE
2820 * Based on this state, this API will determine where to
2821 * route the message to
2822 * Assumption:
2823 * ONLY the MLME state is being taken into account for now.
2824 * This is because, it appears that the handling of the
2825 * SETKEYS REQ is handled symmetrically on both the AP & STA
2826 *
2827 * Return: None
2828 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002829void lim_process_mlm_set_sta_key_rsp(struct mac_context *mac_ctx,
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002830 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831{
2832 uint8_t resp_reqd = 1;
Varun Reddy Yeturu371404b2017-11-30 15:31:35 -08002833 struct sLimMlmSetKeysCnf mlm_set_key_cnf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834 uint8_t session_id = 0;
Varun Reddy Yeturu371404b2017-11-30 15:31:35 -08002835 uint8_t sme_session_id;
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08002836 struct pe_session *session_entry;
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002837 uint16_t key_len;
2838 uint16_t result_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839
2840 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302841 qdf_mem_set((void *)&mlm_set_key_cnf, sizeof(tLimMlmSetKeysCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 if (NULL == msg->bodyptr) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002843 pe_err("msg bodyptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 return;
2845 }
2846 session_id = ((tpSetStaKeyParams) msg->bodyptr)->sessionId;
Varun Reddy Yeturu371404b2017-11-30 15:31:35 -08002847 sme_session_id = ((tpSetBssKeyParams) msg->bodyptr)->smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 session_entry = pe_find_session_by_session_id(mac_ctx, session_id);
2849 if (session_entry == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002850 pe_err("session does not exist for given session_id");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302851 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 msg->bodyptr = NULL;
Varun Reddy Yeturu371404b2017-11-30 15:31:35 -08002853 lim_send_sme_set_context_rsp(mac_ctx,
2854 mlm_set_key_cnf.peer_macaddr,
2855 0, eSIR_SME_INVALID_SESSION, NULL,
2856 sme_session_id, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 return;
2858 }
2859 if (eLIM_MLM_WT_SET_STA_KEY_STATE != session_entry->limMlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002860 pe_err("Received unexpected [Mesg Id - %d] in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 msg->type, session_entry->limMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 resp_reqd = 0;
2863 } else {
2864 mlm_set_key_cnf.resultCode =
2865 (uint16_t)(((tpSetStaKeyParams) msg->bodyptr)->status);
2866 }
2867
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002868 result_status = (uint16_t)(((tpSetStaKeyParams) msg->bodyptr)->status);
2869 key_len = ((tpSetStaKeyParams)msg->bodyptr)->key[0].keyLength;
2870
2871 if (result_status == eSIR_SME_SUCCESS && key_len)
2872 mlm_set_key_cnf.key_len_nonzero = true;
2873 else
2874 mlm_set_key_cnf.key_len_nonzero = false;
2875
2876
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302877 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 msg->bodyptr = NULL;
2879 /* Restore MLME state */
2880 session_entry->limMlmState = session_entry->limPrevMlmState;
2881 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2882 session_entry->peSessionId, session_entry->limMlmState));
2883 if (resp_reqd) {
2884 tpLimMlmSetKeysReq lpLimMlmSetKeysReq =
2885 (tpLimMlmSetKeysReq) mac_ctx->lim.gpLimMlmSetKeysReq;
2886 /* Prepare and Send LIM_MLM_SETKEYS_CNF */
2887 if (NULL != lpLimMlmSetKeysReq) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05302888 qdf_copy_macaddr(&mlm_set_key_cnf.peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002889 &lpLimMlmSetKeysReq->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 /*
2891 * Free the buffer cached for the global
2892 * mac_ctx->lim.gpLimMlmSetKeysReq
2893 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302894 qdf_mem_free(mac_ctx->lim.gpLimMlmSetKeysReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 mac_ctx->lim.gpLimMlmSetKeysReq = NULL;
2896 }
2897 mlm_set_key_cnf.sessionId = session_id;
2898 lim_post_sme_message(mac_ctx, LIM_MLM_SETKEYS_CNF,
2899 (uint32_t *) &mlm_set_key_cnf);
2900 }
2901}
2902
2903/**
2904 * lim_process_mlm_set_bss_key_rsp() - handles BSS key
2905 *
2906 * @mac_ctx: A pointer to Global MAC structure
2907 * @msg: Message from SME
2908 *
2909 * This function processes BSS key response and updates
2910 * PE status accordingly.
2911 *
2912 * Return: NULL
2913 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002914void lim_process_mlm_set_bss_key_rsp(struct mac_context *mac_ctx,
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002915 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916{
Varun Reddy Yeturu371404b2017-11-30 15:31:35 -08002917 struct sLimMlmSetKeysCnf set_key_cnf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 uint16_t result_status;
2919 uint8_t session_id = 0;
Varun Reddy Yeturu371404b2017-11-30 15:31:35 -08002920 uint8_t sme_session_id;
Jeff Johnsonf6f4aeb2018-11-18 22:56:39 -08002921 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 tpLimMlmSetKeysReq set_key_req;
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002923 uint16_t key_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924
2925 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302926 qdf_mem_set((void *)&set_key_cnf, sizeof(tLimMlmSetKeysCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 if (NULL == msg->bodyptr) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002928 pe_err("msg bodyptr is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 return;
2930 }
2931 session_id = ((tpSetBssKeyParams) msg->bodyptr)->sessionId;
Varun Reddy Yeturu371404b2017-11-30 15:31:35 -08002932 sme_session_id = ((tpSetBssKeyParams) msg->bodyptr)->smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 session_entry = pe_find_session_by_session_id(mac_ctx, session_id);
2934 if (session_entry == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002935 pe_err("session does not exist for given sessionId [%d]",
2936 session_id);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302937 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 msg->bodyptr = NULL;
Varun Reddy Yeturu371404b2017-11-30 15:31:35 -08002939 lim_send_sme_set_context_rsp(mac_ctx, set_key_cnf.peer_macaddr,
2940 0, eSIR_SME_INVALID_SESSION, NULL,
2941 sme_session_id, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 return;
2943 }
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002944 if (eLIM_MLM_WT_SET_BSS_KEY_STATE == session_entry->limMlmState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 result_status =
2946 (uint16_t)(((tpSetBssKeyParams)msg->bodyptr)->status);
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002947 key_len = ((tpSetBssKeyParams)msg->bodyptr)->key[0].keyLength;
2948 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 /*
2950 * BCAST key also uses tpSetStaKeyParams.
2951 * Done this way for readabilty.
2952 */
2953 result_status =
2954 (uint16_t)(((tpSetStaKeyParams)msg->bodyptr)->status);
Deepak Dhamdhere07168162016-10-19 20:45:20 -07002955 key_len = ((tpSetStaKeyParams)msg->bodyptr)->key[0].keyLength;
2956 }
2957
2958 if (result_status == eSIR_SME_SUCCESS && key_len)
2959 set_key_cnf.key_len_nonzero = true;
2960 else
2961 set_key_cnf.key_len_nonzero = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962
2963 /* Validate MLME state */
2964 if (eLIM_MLM_WT_SET_BSS_KEY_STATE != session_entry->limMlmState &&
2965 eLIM_MLM_WT_SET_STA_BCASTKEY_STATE !=
2966 session_entry->limMlmState) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07002967 pe_err("Received unexpected [Mesg Id - %d] in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 msg->type, session_entry->limMlmState);
2969 } else {
2970 set_key_cnf.resultCode = result_status;
2971 }
2972
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302973 qdf_mem_free(msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 msg->bodyptr = NULL;
2975 /* Restore MLME state */
2976 session_entry->limMlmState = session_entry->limPrevMlmState;
2977
2978 MTRACE(mac_trace
2979 (mac_ctx, TRACE_CODE_MLM_STATE, session_entry->peSessionId,
2980 session_entry->limMlmState));
2981 set_key_req =
2982 (tpLimMlmSetKeysReq) mac_ctx->lim.gpLimMlmSetKeysReq;
2983 set_key_cnf.sessionId = session_id;
2984
2985 /* Prepare and Send LIM_MLM_SETKEYS_CNF */
2986 if (NULL != set_key_req) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05302987 qdf_copy_macaddr(&set_key_cnf.peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002988 &set_key_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 /*
2990 * Free the buffer cached for the
2991 * global mac_ctx->lim.gpLimMlmSetKeysReq
2992 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302993 qdf_mem_free(mac_ctx->lim.gpLimMlmSetKeysReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994 mac_ctx->lim.gpLimMlmSetKeysReq = NULL;
2995 }
2996 lim_post_sme_message(mac_ctx, LIM_MLM_SETKEYS_CNF,
2997 (uint32_t *) &set_key_cnf);
2998}
2999
3000/**
3001 * lim_process_switch_channel_re_assoc_req()
3002 *
3003 ***FUNCTION:
3004 * This function is called to send the reassoc req mgmt frame after the
3005 * switchChannelRsp message is received from HAL.
3006 *
3007 ***LOGIC:
3008 *
3009 ***ASSUMPTIONS:
3010 * NA
3011 *
3012 ***NOTE:
3013 * NA
3014 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003015 * @param mac - Pointer to Global MAC structure.
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003016 * @param pe_session - session related information.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 * @param status - channel switch success/failure.
3018 *
3019 * @return None
3020 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003021static void lim_process_switch_channel_re_assoc_req(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003022 struct pe_session *pe_session,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303023 QDF_STATUS status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024{
3025 tLimMlmReassocCnf mlmReassocCnf;
3026 tLimMlmReassocReq *pMlmReassocReq;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 pMlmReassocReq =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003029 (tLimMlmReassocReq *) (pe_session->pLimMlmReassocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 if (pMlmReassocReq == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003031 pe_err("pLimMlmReassocReq does not exist for given switchChanSession");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3033 goto end;
3034 }
3035
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303036 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003037 pe_err("Change channel failed!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038 mlmReassocCnf.resultCode = eSIR_SME_CHANNEL_SWITCH_FAIL;
3039 goto end;
3040 }
3041 /* / Start reassociation failure timer */
3042 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003043 (mac, TRACE_CODE_TIMER_ACTIVATE, pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 eLIM_REASSOC_FAIL_TIMER));
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003045 if (tx_timer_activate(&mac->lim.limTimers.gLimReassocFailureTimer)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 != TX_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003047 pe_err("could not start Reassociation failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 /* Return Reassoc confirm with */
3049 /* Resources Unavailable */
3050 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3051 goto end;
3052 }
3053 /* / Prepare and send Reassociation request frame */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003054 lim_send_reassoc_req_mgmt_frame(mac, pMlmReassocReq, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 return;
3056end:
3057 /* Free up buffer allocated for reassocReq */
3058 if (pMlmReassocReq != NULL) {
3059 /* Update PE session Id */
3060 mlmReassocCnf.sessionId = pMlmReassocReq->sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303061 qdf_mem_free(pMlmReassocReq);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003062 pe_session->pLimMlmReassocReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 } else {
3064 mlmReassocCnf.sessionId = 0;
3065 }
3066
3067 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3068 /* Update PE sessio Id */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003069 mlmReassocCnf.sessionId = pe_session->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003071 lim_post_sme_message(mac, LIM_MLM_REASSOC_CNF,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 (uint32_t *) &mlmReassocCnf);
3073}
3074
3075
3076/**
3077 * lim_process_switch_channel_join_req() -Initiates probe request
3078 *
3079 * @mac_ctx - A pointer to Global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003080 * @pe_session - session related information.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 * @status - channel switch success/failure
3082 *
3083 * This function is called to send the probe req mgmt frame
3084 * after the switchChannelRsp message is received from HAL.
3085 *
3086 * Return None
3087 */
3088static void lim_process_switch_channel_join_req(
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003089 struct mac_context *mac_ctx, struct pe_session *session_entry,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303090 QDF_STATUS status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091{
3092 tSirMacSSid ssId;
3093 tLimMlmJoinCnf join_cnf;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003094
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303095 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003096 pe_err("Change channel failed!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 goto error;
3098 }
3099
3100 if ((NULL == session_entry) || (NULL == session_entry->pLimMlmJoinReq)
3101 || (NULL == session_entry->pLimJoinReq)) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003102 pe_err("invalid pointer!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 goto error;
3104 }
3105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 session_entry->limPrevMlmState = session_entry->limMlmState;
3107 session_entry->limMlmState = eLIM_MLM_WT_JOIN_BEACON_STATE;
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003108 pe_debug("Sessionid %d prev lim state %d new lim state %d "
3109 "systemrole = %d", session_entry->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 session_entry->limPrevMlmState,
3111 session_entry->limMlmState, GET_LIM_SYSTEM_ROLE(session_entry));
3112
3113 /* Apply previously set configuration at HW */
3114 lim_apply_configuration(mac_ctx, session_entry);
3115
3116 /*
Wu Gao93816212018-08-31 16:49:54 +08003117 * If deauth_before_connection is enabled, Send Deauth first to AP if
3118 * last disconnection was caused by HB failure.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 */
Wu Gao93816212018-08-31 16:49:54 +08003120 if (mac_ctx->mlme_cfg->sta.deauth_before_connection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 int apCount;
3122
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303123 for (apCount = 0; apCount < 2; apCount++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303125 if (!qdf_mem_cmp(session_entry->pLimMlmJoinReq->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 mac_ctx->lim.gLimHeartBeatApMac[apCount], sizeof(tSirMacAddr))) {
3127
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003128 pe_err("Index %d Sessionid: %d Send deauth on "
3129 "channel %d to BSSID: "MAC_ADDRESS_STR, apCount,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 session_entry->peSessionId, session_entry->currentOperChannel,
3131 MAC_ADDR_ARRAY(session_entry->pLimMlmJoinReq->bssDescription.
3132 bssId));
3133
3134 lim_send_deauth_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_REASON,
3135 session_entry->pLimMlmJoinReq->bssDescription.bssId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303136 session_entry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303138 qdf_mem_zero(mac_ctx->lim.gLimHeartBeatApMac[apCount],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003139 sizeof(tSirMacAddr));
3140 break;
3141 }
3142 }
3143 }
3144
3145 /* Wait for Beacon to announce join success */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303146 qdf_mem_copy(ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 session_entry->ssId.ssId, session_entry->ssId.length);
3148 ssId.length = session_entry->ssId.length;
3149
3150 lim_deactivate_and_change_timer(mac_ctx,
3151 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
3152
3153 /* assign appropriate sessionId to the timer object */
3154 mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer.sessionId =
3155 session_entry->peSessionId;
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003156 pe_debug("Sessionid: %d Send Probe req on channel %d ssid:%.*s "
3157 "BSSID: " MAC_ADDRESS_STR, session_entry->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 session_entry->currentOperChannel, ssId.length, ssId.ssId,
3159 MAC_ADDR_ARRAY(
3160 session_entry->pLimMlmJoinReq->bssDescription.bssId));
3161
3162 /*
3163 * We need to wait for probe response, so start join
3164 * timeout timer.This timer will be deactivated once
3165 * we receive probe response.
3166 */
3167 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE,
3168 session_entry->peSessionId, eLIM_JOIN_FAIL_TIMER));
3169 if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimJoinFailureTimer) !=
3170 TX_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003171 pe_err("couldn't activate Join failure timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 session_entry->limMlmState = session_entry->limPrevMlmState;
3173 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
3174 session_entry->peSessionId,
3175 mac_ctx->lim.gLimMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 goto error;
3177 }
3178 /* include additional IE if there is */
3179 lim_send_probe_req_mgmt_frame(mac_ctx, &ssId,
3180 session_entry->pLimMlmJoinReq->bssDescription.bssId,
3181 session_entry->currentOperChannel, session_entry->selfMacAddr,
3182 session_entry->dot11mode,
Sandeep Puligilla06ae8902018-04-16 19:02:47 -07003183 &session_entry->pLimJoinReq->addIEScan.length,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 session_entry->pLimJoinReq->addIEScan.addIEdata);
3185
Anurag Chouhan6d760662016-02-20 16:05:43 +05303186 if (session_entry->pePersona == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 /* Activate Join Periodic Probe Req timer */
3188 if (tx_timer_activate
3189 (&mac_ctx->lim.limTimers.gLimPeriodicJoinProbeReqTimer)
3190 != TX_SUCCESS) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003191 pe_err("Periodic JoinReq timer activate failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 goto error;
3193 }
3194 }
3195 return;
3196error:
3197 if (NULL != session_entry) {
3198 if (session_entry->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303199 qdf_mem_free(session_entry->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 session_entry->pLimMlmJoinReq = NULL;
3201 }
3202 if (session_entry->pLimJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303203 qdf_mem_free(session_entry->pLimJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 session_entry->pLimJoinReq = NULL;
3205 }
3206 join_cnf.sessionId = session_entry->peSessionId;
3207 } else {
3208 join_cnf.sessionId = 0;
3209 }
3210 join_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3211 join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3212 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF, (uint32_t *)&join_cnf);
3213}
3214
3215/**
3216 * lim_process_switch_channel_rsp()
3217 *
3218 ***FUNCTION:
3219 * This function is called to process switchChannelRsp message from HAL.
3220 *
3221 ***LOGIC:
3222 *
3223 ***ASSUMPTIONS:
3224 * NA
3225 *
3226 ***NOTE:
3227 * NA
3228 *
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003229 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 * @param body - message body.
3231 *
3232 * @return None
3233 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003234void lim_process_switch_channel_rsp(struct mac_context *mac, void *body)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235{
3236 tpSwitchChannelParams pChnlParams = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303237 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 uint16_t channelChangeReasonCode;
3239 uint8_t peSessionId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003240 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 /* we need to process the deferred message since the initiating req. there might be nested request. */
3242 /* in the case of nested request the new request initiated from the response will take care of resetting */
3243 /* the deffered flag. */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003244 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 pChnlParams = (tpSwitchChannelParams) body;
3246 status = pChnlParams->status;
3247 peSessionId = pChnlParams->peSessionId;
3248
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003249 pe_session = pe_find_session_by_session_id(mac, peSessionId);
3250 if (pe_session == NULL) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003251 pe_err("session does not exist for given sessionId");
Vignesh Viswanathan03f5f0e2018-05-11 17:44:28 +05303252 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003254 pe_session->ch_switch_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 /* HAL fills in the tx power used for mgmt frames in this field. */
3256 /* Store this value to use in TPC report IE. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003257 rrm_cache_mgmt_tx_power(mac, pChnlParams->txMgmtPower, pe_session);
3258 channelChangeReasonCode = pe_session->channelChangeReasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 /* initialize it back to invalid id */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003260 pe_session->chainMask = pChnlParams->chainMask;
3261 pe_session->smpsMode = pChnlParams->smpsMode;
3262 pe_session->channelChangeReasonCode = 0xBAD;
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003263 pe_debug("channelChangeReasonCode %d", channelChangeReasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 switch (channelChangeReasonCode) {
3265 case LIM_SWITCH_CHANNEL_REASSOC:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003266 lim_process_switch_channel_re_assoc_req(mac, pe_session, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 break;
3268 case LIM_SWITCH_CHANNEL_JOIN:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003269 lim_process_switch_channel_join_req(mac, pe_session, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 break;
3271
3272 case LIM_SWITCH_CHANNEL_OPERATION:
3273 /*
3274 * The above code should also use the callback.
3275 * mechanism below, there is scope for cleanup here.
3276 * THat way all this response handler does is call the call back
3277 * We can get rid of the reason code here.
3278 */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003279 if (mac->lim.gpchangeChannelCallback) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003280 pe_debug("Channel changed hence invoke registered call back");
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003281 mac->lim.gpchangeChannelCallback(mac, status,
3282 mac->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 gpchangeChannelData,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003284 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 }
Chandrasekaran, Manishekarce7ab082016-02-02 10:24:15 +05303286 /* If MCC upgrade/DBS downgrade happended during channel switch,
3287 * the policy manager connection table needs to be updated.
3288 */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003289 policy_mgr_update_connection_info(mac->psoc,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003290 pe_session->smeSessionId);
3291 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003292 pe_debug("Send p2p operating channel change conf action frame once first beacon is received on new channel");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003293 pe_session->send_p2p_conf_frame = true;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303294 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 break;
3296 case LIM_SWITCH_CHANNEL_SAP_DFS:
3297 {
3298 /* Note: This event code specific to SAP mode
3299 * When SAP session issues channel change as performing
3300 * DFS, we will come here. Other sessions, for e.g. P2P
3301 * will have to define their own event code and channel
3302 * switch handler. This is required since the SME may
3303 * require completely different information for P2P unlike
3304 * SAP.
3305 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003306 lim_send_sme_ap_channel_switch_resp(mac, pe_session,
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -08003307 pChnlParams);
Chandrasekaran, Manishekarce7ab082016-02-02 10:24:15 +05303308 /* If MCC upgrade/DBS downgrade happended during channel switch,
3309 * the policy manager connection table needs to be updated.
3310 */
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003311 policy_mgr_update_connection_info(mac->psoc,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003312 pe_session->smeSessionId);
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003313 policy_mgr_set_do_hw_mode_change_flag(mac->psoc, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 }
3315 break;
3316 default:
3317 break;
3318 }
Vignesh Viswanathan03f5f0e2018-05-11 17:44:28 +05303319free:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303320 qdf_mem_free(body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321}
3322
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003323QDF_STATUS lim_send_beacon_ind(struct mac_context *mac, struct pe_session *pe_session,
Abhishek Singhfc740be2018-10-12 11:34:26 +05303324 enum sir_bcn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325{
3326 tBeaconGenParams *pBeaconGenParams = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003327 struct scheduler_msg limMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 /** Allocate the Memory for Beacon Pre Message and for Stations in PoweSave*/
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003329 if (!pe_session) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003330 pe_err("Error:Unable to get the PESessionEntry");
Abhishek Singhfc740be2018-10-12 11:34:26 +05303331 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303333 pBeaconGenParams = qdf_mem_malloc(sizeof(*pBeaconGenParams));
Abhishek Singhfc740be2018-10-12 11:34:26 +05303334 if (!pBeaconGenParams) {
Srinivas Girigowda8a1e9662017-03-26 14:46:06 -07003335 pe_err("Unable to allocate memory during sending beaconPreMessage");
Abhishek Singhfc740be2018-10-12 11:34:26 +05303336 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303338 qdf_mem_copy((void *)pBeaconGenParams->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003339 (void *)pe_session->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 limMsg.bodyptr = pBeaconGenParams;
Jeff Johnsonb97bdce2018-11-22 12:27:32 -08003341 return sch_process_pre_beacon_ind(mac, &limMsg, reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342}
3343
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003344void lim_process_rx_channel_status_event(struct mac_context *mac_ctx, void *buf)
gaoleze5108942017-03-31 16:56:42 +08003345{
3346 struct lim_channel_status *chan_status = buf;
3347
3348 if (NULL == chan_status) {
3349 QDF_TRACE(QDF_MODULE_ID_PE,
3350 QDF_TRACE_LEVEL_ERROR,
3351 "%s: ACS evt report buf NULL", __func__);
3352 return;
3353 }
3354
3355 if (mac_ctx->sap.acs_with_more_param)
3356 lim_add_channel_status_info(mac_ctx, chan_status,
3357 chan_status->channel_id);
3358 else
3359 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_WARN,
3360 "%s: Error evt report", __func__);
3361
3362 qdf_mem_free(buf);
3363
3364 return;
3365}