blob: a153139305ccc04b4bb6d3957f01dbbcb5d54f15 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08002 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_process_sme_req_messages.cc contains the code
30 * for processing SME request messages.
31 * Author: Chandra Modumudi
32 * Date: 02/11/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 *
37 */
38
39#include "cds_api.h"
40#include "wni_api.h"
41#include "wni_cfg.h"
42#include "cfg_api.h"
43#include "sir_api.h"
44#include "sch_api.h"
45#include "utils_api.h"
46#include "lim_types.h"
47#include "lim_utils.h"
48#include "lim_assoc_utils.h"
49#include "lim_security_utils.h"
50#include "lim_ser_des_utils.h"
51#include "lim_sme_req_utils.h"
52#include "lim_ibss_peer_mgmt.h"
53#include "lim_admit_control.h"
54#include "dph_hash_table.h"
55#include "lim_send_messages.h"
56#include "lim_api.h"
57#include "wmm_apsd.h"
58#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080059#include "rrm_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070060#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061
62#include "sap_api.h"
63
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070066#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
68/*
69 * This overhead is time for sending NOA start to host in case of GO/sending
70 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
71 * with init scan req/rsp plus in case of concurrency, taking care of sending
72 * null data and receiving ACK to/from AP/Also SetChannel with calibration
73 * is taking around 7ms .
74 */
75#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
76#define JOIN_NOA_DURATION 2000 /* in msecs */
77#define OEM_DATA_NOA_DURATION 60 /* in msecs */
78#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
79
80#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
81
82/* SME REQ processing function templates */
83static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
84static bool __lim_process_sme_start_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
85static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
91static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
92static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053093static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
94 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
96 uint32_t *pMsg);
97static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
98static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
99static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
100static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
101
102static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
103 uint8_t **pDstData_buff,
104 uint16_t *pDstDataLen,
105 uint8_t *pSrcData_buff,
106 uint16_t srcDataLen);
107
108static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
109 uint8_t **pDstData_buff,
110 uint16_t *pDstDataLen,
111 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800112static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
113 uint8_t **pDstData_buff,
114 uint16_t *pDstDataLen,
115 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
117
118static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
119
Abhishek Singh518323d2015-10-19 17:42:01 +0530120static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
121 uint32_t *msg);
122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123/**
124 * lim_process_set_hw_mode() - Send set HW mode command to WMA
125 * @mac: Globacl MAC pointer
126 * @msg: Message containing the hw mode index
127 *
128 * Send the set HW mode command to WMA
129 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530130 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530132static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530134 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135 cds_msg_t cds_message;
136 struct sir_hw_mode *req_msg;
137 uint32_t len;
138 struct s_sir_set_hw_mode *buf;
139 tSirMsgQ resp_msg;
140 struct sir_set_hw_mode_resp *param;
141
142 buf = (struct s_sir_set_hw_mode *) msg;
143 if (!buf) {
144 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
145 /* To free the active command list */
146 goto fail;
147 }
148
149 len = sizeof(*req_msg);
150
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530151 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530153 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 /* Free the active command list
155 * Probably the malloc is going to fail there as well?!
156 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530157 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 }
159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530161 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162 /* Other parameters are not needed for WMA */
163
164 cds_message.bodyptr = req_msg;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +0530165 cds_message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166
167 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
Krunal Soni66c113f2016-12-21 16:46:47 -0800168 status = cds_mq_post_message(QDF_MODULE_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530169 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700171 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530173 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 goto fail;
175 }
176 return status;
177fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530178 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 if (!param) {
180 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530181 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 }
183 param->status = SET_HW_MODE_STATUS_ECANCELED;
184 param->cfgd_hw_mode_index = 0;
185 param->num_vdev_mac_entries = 0;
186 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
187 resp_msg.bodyptr = param;
188 resp_msg.bodyval = 0;
189 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530190 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191}
192
193/**
194 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
195 * @mac: Global MAC pointer
196 * @msg: Message containing the dual mac config parameter
197 *
198 * Send the set dual mac config command to WMA
199 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530200 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530202static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 uint32_t *msg)
204{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530205 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 cds_msg_t cds_message;
207 struct sir_dual_mac_config *req_msg;
208 uint32_t len;
209 struct sir_set_dual_mac_cfg *buf;
210 tSirMsgQ resp_msg;
211 struct sir_dual_mac_config_resp *param;
212
213 buf = (struct sir_set_dual_mac_cfg *) msg;
214 if (!buf) {
215 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
216 /* To free the active command list */
217 goto fail;
218 }
219
220 len = sizeof(*req_msg);
221
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530222 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 if (!req_msg) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700224 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 /* Free the active command list
226 * Probably the malloc is going to fail there as well?!
227 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530228 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 }
230
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 req_msg->scan_config = buf->set_dual_mac.scan_config;
232 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
233 /* Other parameters are not needed for WMA */
234
235 cds_message.bodyptr = req_msg;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530236 cds_message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237
238 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530239 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 req_msg->scan_config, req_msg->fw_mode_config);
Krunal Soni66c113f2016-12-21 16:46:47 -0800241 status = cds_mq_post_message(QDF_MODULE_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530242 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700244 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530246 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 goto fail;
248 }
249 return status;
250fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530251 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 if (!param) {
253 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530254 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 }
256 param->status = SET_HW_MODE_STATUS_ECANCELED;
257 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
258 resp_msg.bodyptr = param;
259 resp_msg.bodyval = 0;
260 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530261 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262}
263
264/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800265 * lim_process_set_antenna_mode_req() - Set antenna mode command
266 * to WMA
267 * @mac: Global MAC pointer
268 * @msg: Message containing the antenna mode parameter
269 *
270 * Send the set antenna mode command to WMA
271 *
272 * Return: QDF_STATUS_SUCCESS if message posting is successful
273 */
274static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
275 uint32_t *msg)
276{
277 QDF_STATUS status = QDF_STATUS_SUCCESS;
278 cds_msg_t cds_message;
279 struct sir_antenna_mode_param *req_msg;
280 struct sir_set_antenna_mode *buf;
281 tSirMsgQ resp_msg;
282 struct sir_antenna_mode_resp *param;
283
284 buf = (struct sir_set_antenna_mode *) msg;
285 if (!buf) {
286 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
287 /* To free the active command list */
288 goto fail;
289 }
290
291 req_msg = qdf_mem_malloc(sizeof(*req_msg));
292 if (!req_msg) {
293 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
294 return QDF_STATUS_E_NOMEM;
295 }
296
297 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
298 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
299
300 cds_message.bodyptr = req_msg;
301 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
302
303 lim_log(mac, LOG1,
304 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
305 req_msg->num_rx_chains,
306 req_msg->num_tx_chains);
Krunal Soni66c113f2016-12-21 16:46:47 -0800307 status = cds_mq_post_message(QDF_MODULE_ID_WMA, &cds_message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800308 if (!QDF_IS_STATUS_SUCCESS(status)) {
309 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700310 FL("cds_mq_post_message failed!(err=%d)"),
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800311 status);
312 qdf_mem_free(req_msg);
313 goto fail;
314 }
315 return status;
316fail:
317 param = qdf_mem_malloc(sizeof(*param));
318 if (!param) {
319 lim_log(mac, LOGE, FL("antenna mode resp failed"));
320 return QDF_STATUS_E_NOMEM;
321 }
322 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
323 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
324 resp_msg.bodyptr = param;
325 resp_msg.bodyval = 0;
326 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
327 return QDF_STATUS_SUCCESS;
328}
329
330/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
332 * @mac_ctx: Pointer to Global MAC structure
333 * @return_fresh_results: Trigger fresh scan.
334 *
335 * PE will do fresh scan, if all of the active sessions are in
336 * good state (Link Est or BSS Started). If one of the sessions
337 * is not in one of the above states, then PE does not do fresh
338 * scan. If no session exists (scanning very first time),
339 * then PE will always do fresh scan if SME asks it to do that.
340 *
341 * Return: true for fresh scan results, false if in invalid state.
342 */
343static uint8_t
344__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
345{
346 uint8_t valid_state = true;
347 int i;
348
349 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
350 mac_ctx->lim.gLimSmeState, return_fresh_results);
351
352 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
353 lim_log(mac_ctx, LOG1, FL("return FALSE"));
354 return false;
355 }
356
357 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700358
359 if (mac_ctx->lim.gpSession[i].valid == false)
360 continue;
361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 lim_log(mac_ctx, LOG1,
363 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
364 i, mac_ctx->lim.gpSession[i].bssType,
365 mac_ctx->lim.gpSession[i].limSystemRole,
366 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700367
368 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
369 continue;
370
371 if (mac_ctx->lim.gpSession[i].bssType ==
372 eSIR_INFRASTRUCTURE_MODE &&
373 mac_ctx->lim.gpSession[i].limSmeState ==
374 eLIM_SME_LINK_EST_STATE)
375 continue;
376
377 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
378 mac_ctx->lim.gpSession[i].limSmeState ==
379 eLIM_SME_NORMAL_STATE)
380 continue;
381
382 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
383 mac_ctx->lim.gpSession[i].pePersona ==
384 QDF_P2P_GO_MODE &&
385 mac_ctx->lim.gpSession[i].limSmeState ==
386 eLIM_SME_NORMAL_STATE)
387 continue;
388
389 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
390 mac_ctx->lim.gpSession[i].limSmeState ==
391 eLIM_SME_NORMAL_STATE)
392 continue;
393
394 valid_state = false;
395 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 }
397
398 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
399
400 if ((valid_state) &&
401 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
402 return true;
403 else
404 return false;
405}
406
407/**
408 * __lim_is_sme_assoc_cnf_valid()
409 *
410 ***FUNCTION:
411 * This function is called by __lim_process_sme_assoc_cnf_new() upon
412 * receiving SME_ASSOC_CNF.
413 *
414 ***LOGIC:
415 * Message validity checks are performed in this function
416 *
417 ***ASSUMPTIONS:
418 *
419 ***NOTE:
420 *
421 * @param pMeasReq Pointer to Received ASSOC_CNF message
422 * @return true When received SME_ASSOC_CNF is formatted
423 * correctly
424 * false otherwise
425 */
426
427static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
428{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530429 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 return false;
431 else
432 return true;
433} /*** end __lim_is_sme_assoc_cnf_valid() ***/
434
435/**
436 * __lim_get_sme_join_req_size_for_alloc()
437 *
438 ***FUNCTION:
439 * This function is called in various places to get IE length
440 * from tSirBssDescription structure
441 * number being scanned.
442 *
443 ***PARAMS:
444 *
445 ***LOGIC:
446 *
447 ***ASSUMPTIONS:
448 * NA
449 *
450 ***NOTE:
451 * NA
452 *
453 * @param pBssDescr
454 * @return Total IE length
455 */
456
457static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
458{
459 uint16_t len = 0;
460
461 if (!pBuf)
462 return len;
463
464 pBuf += sizeof(uint16_t);
465 len = lim_get_u16(pBuf);
466 return len + sizeof(uint16_t);
467}
468
469/**
470 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
471 * @pMac: Global MAC context
472 * @pMsg: Pointer to message posted from SME to LIM.
473 *
474 * Has role only if 11h is enabled. Not used on STA side.
475 * Defers the message if SME is in learn state and brings
476 * the LIM back to normal mode.
477 *
478 * Return: true - If defered false - Otherwise
479 */
480
481static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
482{
483 if (lim_is_system_in_scan_state(pMac)) {
484 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
485 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
486 pMsg->type);
487 return false;
488 }
489 lim_log(pMac, LOG1,
490 FL("Defer the message, in learn mode type = %d"),
491 pMsg->type);
492 return true;
493 }
494 return false;
495}
496
497/**
498 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
499 * @mac_ctx: Pointer to Global MAC structure
500 * @message: Pointer to message posted from SME to LIM.
501 *
502 * Has role only if 11h is enabled. Not used on STA side.
503 * Defers the message if radar is detected.
504 *
505 * Return: true, if defered otherwise return false.
506 */
507static bool
508__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
509{
510 /*
511 * fRadarDetCurOperChan will be set only if we
512 * detect radar in current operating channel and
513 * System Role == AP ROLE
514 *
515 * TODO: Need to take care radar detection.
516 *
517 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
518 */
519 if (0) {
520 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
521 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
522 message->type);
523 return false;
524 }
525 lim_log(mac_ctx, LOG1,
526 FL("Defer the message, in learn mode type = %d"),
527 message->type);
528 return true;
529 }
530 return false;
531}
532
533/**
534 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
535 * @pMac: Global MAC context
536 * @pMsgBuf: Message from WMA
537 *
538 * handles the notification from HDD. PE just forwards this message to HAL.
539 *
540 * Return: true-Posting to HAL failed, so PE will consume the buffer.
541 * false-Posting to HAL successful, so HAL will consume the buffer.
542 */
543
544static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
545{
546 tSirMsgQ msg;
547 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
548
549 msg.type = WMA_SYS_READY_IND;
550 msg.reserved = 0;
551 msg.bodyptr = pMsgBuf;
552 msg.bodyval = 0;
553
554 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800555 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700556 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800557 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
558 }
559 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
560 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
561
562 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
563 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
564 return true;
565 }
566 return false;
567}
568
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569/**
570 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
571 *@mac_ctx: Pointer to Global MAC structure
572 *@session: A pointer to session entry
573 *@sme_start_bss_req: Start BSS Request from upper layers.
574 *
575 * This function is used to configure the start bss parameters
576 * in to the session.
577 *
578 * Return: None.
579 */
580static void
581lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
582 tpSirSmeStartBssReq sme_start_bss_req)
583{
584 session->limSystemRole = eLIM_AP_ROLE;
585 session->privacy = sme_start_bss_req->privacy;
586 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
587 session->authType = sme_start_bss_req->authType;
588 /* Store the DTIM period */
589 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
590 /* Enable/disable UAPSD */
591 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530592 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 session->proxyProbeRspEn = 0;
594 } else {
595 /*
596 * To detect PBC overlap in SAP WPS mode,
597 * Host handles Probe Requests.
598 */
599 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
600 session->proxyProbeRspEn = 1;
601 else
602 session->proxyProbeRspEn = 0;
603 }
604 session->ssidHidden = sme_start_bss_req->ssidHidden;
605 session->wps_state = sme_start_bss_req->wps_state;
606 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530607 session->vendor_vht_sap =
608 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
610 &session->shortSlotTimeSupported);
611 session->isCoalesingInIBSSAllowed =
612 sme_start_bss_req->isCoalesingInIBSSAllowed;
613
614}
615
616/**
617 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
618 *@mac_ctx: Pointer to Global MAC structure
619 *@msg_buf: A pointer to the SME message buffer
620 *
621 * This function is called to process SME_START_BSS_REQ message
622 * from HDD or upper layer application.
623 *
624 * Return: None
625 */
626static void
627__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
628{
629 uint16_t size;
630 uint32_t val = 0;
631 tSirRetStatus ret_status;
632 tSirMacChanNum channel_number;
633 tLimMlmStartReq *mlm_start_req = NULL;
634 tpSirSmeStartBssReq sme_start_bss_req = NULL;
635 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
636 /* Flag Used in case of IBSS to Auto generate BSSID. */
637 uint32_t auto_gen_bssid = false;
638 uint8_t session_id;
639 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800640 uint8_t sme_session_id = 0xFF;
641 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700643 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
645
646/* FEATURE_WLAN_DIAG_SUPPORT */
647#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
648 /*
649 * Since the session is not created yet, sending NULL.
650 * The response should have the correct state.
651 */
652 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
653 NULL, 0, 0);
654#endif /* FEATURE_WLAN_DIAG_SUPPORT */
655
656 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
Krunal Sonib37bb352016-12-20 14:12:21 -0800657 size = sizeof(tSirSmeStartBssReq);
658 sme_start_bss_req = qdf_mem_malloc(size);
659 if (NULL == sme_start_bss_req) {
660 lim_log(mac_ctx, LOGE,
661 FL("Allocate Memory fail for LimStartBssReq"));
662 /* Send failure response to host */
663 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
664 goto free;
665 }
666 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
667 sme_session_id = sme_start_bss_req->sessionId;
668 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
671 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
673 sme_start_bss_req)) {
674 lim_log(mac_ctx, LOGW,
675 FL("Received invalid eWNI_SME_START_BSS_REQ"));
676 ret_code = eSIR_SME_INVALID_PARAMETERS;
677 goto free;
678 }
679
680 /*
681 * This is the place where PE is going to create a session.
682 * If session is not existed, then create a new session
683 */
684 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800685 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 if (session != NULL) {
687 lim_log(mac_ctx, LOGW,
688 FL("Session Already exists for given BSSID"));
689 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
690 session = NULL;
691 goto free;
692 } else {
693 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800694 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 &session_id, mac_ctx->lim.maxStation,
696 sme_start_bss_req->bssType);
697 if (session == NULL) {
698 lim_log(mac_ctx, LOGW,
699 FL("Session Can not be created "));
700 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
701 goto free;
702 }
703 }
704
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700705 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
706 /* Probe resp add ie */
707 lim_start_bss_update_add_ie_buffer(mac_ctx,
708 &session->addIeParams.probeRespData_buff,
709 &session->addIeParams.probeRespDataLen,
710 sme_start_bss_req->addIeParams.
711 probeRespData_buff,
712 sme_start_bss_req->addIeParams.
713 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700715 /* Probe Beacon add ie */
716 lim_start_bss_update_add_ie_buffer(mac_ctx,
717 &session->addIeParams.probeRespBCNData_buff,
718 &session->addIeParams.probeRespBCNDataLen,
719 sme_start_bss_req->addIeParams.
720 probeRespBCNData_buff,
721 sme_start_bss_req->addIeParams.
722 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700724 /* Assoc resp IE */
725 lim_start_bss_update_add_ie_buffer(mac_ctx,
726 &session->addIeParams.assocRespData_buff,
727 &session->addIeParams.assocRespDataLen,
728 sme_start_bss_req->addIeParams.
729 assocRespData_buff,
730 sme_start_bss_req->addIeParams.
731 assocRespDataLen);
732 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 /* Store the session related params in newly created session */
734 session->pLimStartBssReq = sme_start_bss_req;
735
736 /* Store PE session_id in session Table */
737 session->peSessionId = session_id;
738
739 /* Store SME session Id in sessionTable */
740 session->smeSessionId = sme_start_bss_req->sessionId;
741
742 session->transactionId = sme_start_bss_req->transactionId;
743
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530744 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 &(sme_start_bss_req->htConfig),
746 sizeof(session->htConfig));
747
Sandeep Puligilla98917432016-06-10 13:50:28 -0700748 qdf_mem_copy(&(session->vht_config),
749 &(sme_start_bss_req->vht_config),
750 sizeof(session->vht_config));
751
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800753 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754
755 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530756 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 (uint8_t *) &sme_start_bss_req->ssId,
758 (sme_start_bss_req->ssId.length + 1));
759
760 session->bssType = sme_start_bss_req->bssType;
761
762 session->nwType = sme_start_bss_req->nwType;
763
764 session->beaconParams.beaconInterval =
765 sme_start_bss_req->beaconInterval;
766
767 /* Store the channel number in session Table */
768 session->currentOperChannel =
769 sme_start_bss_req->channelId;
770
771 /* Store Persona */
772 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530773 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 FL("PE PERSONA=%d"), session->pePersona);
775
776 /* Update the phymode */
777 session->gLimPhyMode = sme_start_bss_req->nwType;
778
779 session->maxTxPower =
780 cfg_get_regulatory_max_transmit_power(mac_ctx,
781 session->currentOperChannel);
782 /* Store the dot 11 mode in to the session Table */
783 session->dot11mode = sme_start_bss_req->dot11mode;
784#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
785 session->cc_switch_mode =
786 sme_start_bss_req->cc_switch_mode;
787#endif
788 session->htCapability =
789 IS_DOT11_MODE_HT(session->dot11mode);
790 session->vhtCapability =
791 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530792 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 FL("*****session->vhtCapability = %d"),
794 session->vhtCapability);
795 session->txLdpcIniFeatureEnabled =
796 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797#ifdef WLAN_FEATURE_11W
798 session->limRmfEnabled =
799 sme_start_bss_req->pmfCapable ? 1 : 0;
800 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
801 session->limRmfEnabled);
802#endif
803
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530804 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 (void *)&sme_start_bss_req->operationalRateSet,
806 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 (void *)&sme_start_bss_req->extendedRateSet,
809 sizeof(tSirMacRateSet));
810
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700811 if (IS_5G_CH(session->currentOperChannel))
812 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
813 else
814 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 switch (sme_start_bss_req->bssType) {
817 case eSIR_INFRA_AP_MODE:
818 lim_configure_ap_start_bss_session(mac_ctx, session,
819 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700820 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700821 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700822 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700823 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 break;
825 case eSIR_IBSS_MODE:
826 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
827 lim_get_short_slot_from_phy_mode(mac_ctx, session,
828 session->gLimPhyMode,
829 &session->shortSlotTimeSupported);
830
831 /*
832 * initialize to "OPEN".
833 * will be updated upon key installation
834 */
835 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700836 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837
838 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700839 case eSIR_NDI_MODE:
840 session->limSystemRole = eLIM_NDI_ROLE;
841 break;
842
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 /*
845 * There is one more mode called auto mode.
846 * which is used no where
847 */
848
849 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
850
851 default:
852 /* not used anywhere...used in scan function */
853 break;
854 }
855
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700856 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
857 session->pePersona, session->vdev_nss);
858 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700860 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 * parsed (Re)Assoc request structure
862 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700863 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530865 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700866 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 if (NULL == session->parsedAssocReq) {
868 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700869 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
871 goto free;
872 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 }
874
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700875 if (!sme_start_bss_req->channelId &&
876 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 lim_log(mac_ctx, LOGE,
878 FL("Received invalid eWNI_SME_START_BSS_REQ"));
879 ret_code = eSIR_SME_INVALID_PARAMETERS;
880 goto free;
881 }
882 channel_number = sme_start_bss_req->channelId;
883#ifdef QCA_HT_2040_COEX
884 if (sme_start_bss_req->obssEnabled)
885 session->htSupportedChannelWidthSet =
886 session->htCapability;
887 else
888#endif
889 session->htSupportedChannelWidthSet =
890 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
891 session->htSecondaryChannelOffset =
892 sme_start_bss_req->sec_ch_offset;
893 session->htRecommendedTxWidthSet =
894 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530895 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 FL("cbMode %u"), sme_start_bss_req->cbMode);
897 if (session->vhtCapability || session->htCapability) {
898 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800899 lim_log(mac_ctx, LOG1,
900 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
901 sme_start_bss_req->vht_channel_width,
902 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 session->ch_width = chanwidth;
904 if (session->htSupportedChannelWidthSet) {
905 session->ch_center_freq_seg0 =
906 sme_start_bss_req->center_freq_seg0;
907 session->ch_center_freq_seg1 =
908 sme_start_bss_req->center_freq_seg1;
909 } else {
910 session->ch_center_freq_seg0 = 0;
911 session->ch_center_freq_seg1 = 0;
912 }
913 }
914
915 if (session->vhtCapability &&
Krunal Soni53993f72016-07-08 18:20:03 -0700916 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917 session->nss = 1;
Krunal Soni53993f72016-07-08 18:20:03 -0700918 lim_log(mac_ctx, LOG1, FL("nss set to [%d]"),
919 session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 }
Krunal Soni53993f72016-07-08 18:20:03 -0700921 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"),
922 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923
924 /* Delete pre-auth list if any */
925 lim_delete_pre_auth_list(mac_ctx);
926
Krunal Soni53993f72016-07-08 18:20:03 -0700927 if (session->nss == 1) {
928 session->vht_config.su_beam_former = 0;
929 session->vht_config.tx_stbc = 0;
930 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530931 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700932 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 /*
934 * keep the RSN/WPA IE information in PE Session Entry
935 * later will be using this to check when received (Re)Assoc req
936 */
937 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
938 &sme_start_bss_req->rsnIE, session);
939
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700940 if (LIM_IS_AP_ROLE(session) ||
941 LIM_IS_IBSS_ROLE(session) ||
942 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 session->gLimProtectionControl =
944 sme_start_bss_req->protEnabled;
945 /*
946 * each byte will have the following info
947 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
948 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
949 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530950 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951 (void *)&sme_start_bss_req->ht_capab,
952 sizeof(uint16_t));
953 /* Initialize WPS PBC session link list */
954 session->pAPWPSPBCSession = NULL;
955 }
956 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530957 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 if (NULL == mlm_start_req) {
959 lim_log(mac_ctx, LOGP,
960 FL("Allocate Memory failed for mlmStartReq"));
961 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
962 goto free;
963 }
964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530966 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 (uint8_t *) &sme_start_bss_req->ssId,
968 sme_start_bss_req->ssId.length + 1);
969 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
970 mlm_start_req->obssProtEnabled =
971 sme_start_bss_req->obssProtEnabled;
972
973 mlm_start_req->bssType = session->bssType;
974
975 /* Fill PE session Id from the session Table */
976 mlm_start_req->sessionId = session->peSessionId;
977
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700978 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
979 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 /*
981 * Copy the BSSId from sessionTable to
982 * mlmStartReq struct
983 */
984 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
985 } else {
986 /* ibss mode */
987 mac_ctx->lim.gLimIbssCoalescingHappened = false;
988
989 ret_status = wlan_cfg_get_int(mac_ctx,
990 WNI_CFG_IBSS_AUTO_BSSID,
991 &auto_gen_bssid);
992 if (ret_status != eSIR_SUCCESS) {
993 lim_log(mac_ctx, LOGP,
994 FL("Get Auto Gen BSSID fail,Status=%d"),
995 ret_status);
996 ret_code = eSIR_LOGP_EXCEPTION;
997 goto free;
998 }
999
1000 if (!auto_gen_bssid) {
1001 /*
1002 * We're not auto generating BSSID.
1003 * Instead, get it from session entry
1004 */
1005 sir_copy_mac_addr(mlm_start_req->bssId,
1006 session->bssId);
1007 /*
1008 * Start IBSS group BSSID
1009 * Auto Generating BSSID.
1010 */
1011 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1012 0x01) ? true : false);
1013 }
1014
1015 if (auto_gen_bssid) {
1016 /*
1017 * if BSSID is not any uc id.
1018 * then use locally generated BSSID.
1019 * Autogenerate the BSSID
1020 */
1021 lim_get_random_bssid(mac_ctx,
1022 mlm_start_req->bssId);
1023 mlm_start_req->bssId[0] = 0x02;
1024
1025 /*
1026 * Copy randomly generated BSSID
1027 * to the session Table
1028 */
1029 sir_copy_mac_addr(session->bssId,
1030 mlm_start_req->bssId);
1031 }
1032 }
1033 /* store the channel num in mlmstart req structure */
1034 mlm_start_req->channelNumber = session->currentOperChannel;
1035 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1036 mlm_start_req->beaconPeriod =
1037 session->beaconParams.beaconInterval;
1038
1039 if (LIM_IS_AP_ROLE(session)) {
1040 mlm_start_req->dtimPeriod = session->dtimPeriod;
1041 mlm_start_req->wps_state = session->wps_state;
1042
1043 } else {
1044 if (wlan_cfg_get_int(mac_ctx,
1045 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1046 lim_log(mac_ctx, LOGP,
1047 FL("could not retrieve DTIM Period"));
1048 mlm_start_req->dtimPeriod = (uint8_t) val;
1049 }
1050
1051 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1052 eSIR_SUCCESS)
1053 lim_log(mac_ctx, LOGP,
1054 FL("could not retrieve Beacon interval"));
1055 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1056
1057 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1058 eSIR_SUCCESS)
1059 lim_log(mac_ctx, LOGP,
1060 FL("could not retrieve CFPMaxDuration"));
1061 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1062
1063 /*
1064 * this may not be needed anymore now,
1065 * as rateSet is now included in the
1066 * session entry and MLM has session context.
1067 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301068 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 (void *)&session->rateSet,
1070 sizeof(tSirMacRateSet));
1071
1072 /* Now populate the 11n related parameters */
1073 mlm_start_req->nwType = session->nwType;
1074 mlm_start_req->htCapable = session->htCapability;
1075
1076 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1077 /* Unused */
1078 mlm_start_req->dualCTSProtection =
1079 mac_ctx->lim.gHTDualCTSProtection;
1080 mlm_start_req->txChannelWidthSet =
1081 session->htRecommendedTxWidthSet;
1082
1083 session->limRFBand = lim_get_rf_band(channel_number);
1084
1085 /* Initialize 11h Enable Flag */
1086 session->lim11hEnable = 0;
1087 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1088 (SIR_BAND_5_GHZ == session->limRFBand)) {
1089 if (wlan_cfg_get_int(mac_ctx,
1090 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1091 lim_log(mac_ctx, LOGP,
1092 FL("Fail to get WNI_CFG_11H_ENABLED "));
1093 else
1094 session->lim11hEnable = val;
1095
1096 if (session->lim11hEnable &&
1097 (eSIR_INFRA_AP_MODE ==
1098 mlm_start_req->bssType)) {
1099 cfg_get_wmi_dfs_master_param =
1100 wlan_cfg_get_int(mac_ctx,
1101 WNI_CFG_DFS_MASTER_ENABLED,
1102 &val);
1103 session->lim11hEnable = val;
1104 }
1105 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1106 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1107 lim_log(mac_ctx, LOGE,
1108 FL("Get Fail, CFG DFS ENABLE"));
1109 }
1110
1111 if (!session->lim11hEnable) {
1112 if (cfg_set_int(mac_ctx,
1113 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1114 eSIR_SUCCESS)
1115 /*
1116 * Failed to set the CFG param
1117 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1118 */
1119 lim_log(mac_ctx, LOGE,
1120 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1121 }
1122
1123 session->limPrevSmeState = session->limSmeState;
1124 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1125 MTRACE(mac_trace
1126 (mac_ctx, TRACE_CODE_SME_STATE,
1127 session->peSessionId,
1128 session->limSmeState));
1129
1130 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1131 (uint32_t *) mlm_start_req);
1132 return;
1133 } else {
1134
1135 lim_log(mac_ctx, LOGE,
1136 FL("Received unexpected START_BSS_REQ, in state %X"),
1137 mac_ctx->lim.gLimSmeState);
1138 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001139 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1141
1142free:
1143 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001144 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 session->pLimStartBssReq = NULL;
1146 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001147 if (NULL != sme_start_bss_req)
1148 qdf_mem_free(sme_start_bss_req);
1149 if (NULL != mlm_start_req)
1150 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 if (NULL != session) {
1152 pe_delete_session(mac_ctx, session);
1153 session = NULL;
1154 }
1155 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1156 session, sme_session_id, sme_transaction_id);
1157}
1158
1159/**
1160 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1161 *
1162 * @pMac: Global MAC context
1163 * @pMsg: Message pointer
1164 *
1165 * Wrapper for the function __lim_handle_sme_start_bss_request
1166 * This message will be defered until softmac come out of
1167 * scan mode or if we have detected radar on the current
1168 * operating channel.
1169 *
1170 * return true - If we consumed the buffer
1171 * false - If have defered the message.
1172 */
1173static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1174{
1175 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1176 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1177 /**
1178 * If message defered, buffer is not consumed yet.
1179 * So return false
1180 */
1181 return false;
1182 }
1183
1184 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1185 return true;
1186}
1187
1188/**
1189 * lim_get_random_bssid()
1190 *
1191 * FUNCTION:This function is called to process generate the random number for bssid
1192 * This function is called to process SME_SCAN_REQ message
1193 * from HDD or upper layer application.
1194 *
1195 * LOGIC:
1196 *
1197 * ASSUMPTIONS:
1198 *
1199 * NOTE:
1200 * 1. geneartes the unique random number for bssid in ibss
1201 *
1202 * @param pMac Pointer to Global MAC structure
1203 * @param *data Pointer to bssid buffer
1204 * @return None
1205 */
1206void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1207{
1208 uint32_t random[2];
1209 random[0] = tx_time_get();
1210 random[0] |= (random[0] << 15);
1211 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301212 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213}
1214
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301215static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 tpSirSmeScanReq pScanReq)
1217{
1218 tSirScanOffloadReq *pScanOffloadReq;
1219 uint8_t *p;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220 tSirMsgQ msg;
1221 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001222 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 tSirRetStatus status, rc = eSIR_SUCCESS;
1224 tDot11fIEExtCap extracted_extcap = {0};
1225 bool extcap_present = true;
1226
1227 if (pScanReq->uIEFieldLen) {
1228 status = lim_strip_extcap_update_struct(pMac,
1229 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1230 &pScanReq->uIEFieldLen, &extracted_extcap);
1231
1232 if (eSIR_SUCCESS != status) {
1233 extcap_present = false;
1234 lim_log(pMac, LOG1,
1235 FL("Unable to Strip ExtCap IE from Scan Req"));
1236 }
1237
1238 if (extcap_present) {
1239 lim_log(pMac, LOG1,
1240 FL("Extcap was part of SCAN IE - Updating FW"));
1241 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1242 &extracted_extcap, true);
1243 }
1244 } else {
1245 lim_log(pMac, LOG1,
1246 FL("No IEs in the scan request from supplicant"));
1247 }
1248
1249 /**
1250 * The tSirScanOffloadReq will reserve the space for first channel,
1251 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1252 */
1253 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001254 (pScanReq->channelList.numChannels - 1) +
1255 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001256
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301257 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 if (NULL == pScanOffloadReq) {
1259 lim_log(pMac, LOGE,
1260 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301261 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 }
1263
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1265 msg.bodyptr = pScanOffloadReq;
1266 msg.bodyval = 0;
1267
Anurag Chouhanc5548422016-02-24 18:33:27 +05301268 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269
1270 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1271 lim_log(pMac, LOGE,
1272 FL("Invalid value (%d) for numSsid"),
1273 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301274 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301275 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 }
1277
1278 pScanOffloadReq->numSsid = pScanReq->numSsid;
1279 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1280 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301281 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 (uint8_t *) pScanReq->ssId[i].ssId,
1283 pScanOffloadReq->ssId[i].length);
1284 }
1285
1286 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301287 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 pScanOffloadReq->bssType = pScanReq->bssType;
1289 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1290 pScanOffloadReq->scanType = pScanReq->scanType;
1291 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1292 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1293 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301294 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1295 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301296 pScanOffloadReq->scan_adaptive_dwell_mode =
1297 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001298
1299 /* for normal scan, the value for p2pScanType should be 0
1300 always */
1301 if (pScanReq->p2pSearch)
1302 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1303
1304 pScanOffloadReq->sessionId = pScanReq->sessionId;
1305 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001306 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301307 pScanOffloadReq->scan_adaptive_dwell_mode =
1308 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309
1310 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1311 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1312 pScanOffloadReq->sessionId);
1313
1314 pScanOffloadReq->channelList.numChannels =
1315 pScanReq->channelList.numChannels;
1316 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1317 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1318 p[i] = pScanReq->channelList.channelNumber[i];
1319
1320 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1321 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1322 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301323 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 pScanOffloadReq->uIEFieldOffset,
1325 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1326 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001327
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 rc = wma_post_ctrl_msg(pMac, &msg);
1329 if (rc != eSIR_SUCCESS) {
1330 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301331 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301332 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 }
1334
1335 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1336
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301337 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338}
1339
1340/**
1341 * __lim_process_sme_scan_req() - Process the SME Scan Request
1342 * @mac_ctx: Global MAC Context
1343 * @msg_buf: Buffer which contains the request and pertinent parameters
1344 *
1345 * This function is called to process SME_SCAN_REQ message
1346 * from HDD or upper layer application.
1347 *
1348 * Return: None
1349 */
1350
1351static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1352 uint32_t *msg_buf)
1353{
1354 tpSirSmeScanReq scan_req;
1355 uint8_t valid_req = 0;
1356
1357#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1358 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1359 eSIR_SUCCESS, eSIR_SUCCESS);
1360#endif
1361
1362 scan_req = (tpSirSmeScanReq) msg_buf;
1363 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301364 FL("SME SCAN REQ id %d numChan %d min %d max %d IELen %d first %d fresh %d unique %d type %s (%d) rsp %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 scan_req->scan_id, scan_req->channelList.numChannels,
1366 scan_req->minChannelTime, scan_req->maxChannelTime,
1367 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1368 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301369 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1371 /*
1372 * Since scan req always requires a response, we will overwrite response
1373 * required here. This is added esp to take care of the condition where
1374 * in p2p go case, we hold the scan req and insert single NOA. We send
1375 * the held scan request to FW later on getting start NOA ind from FW so
1376 * we lose state of the gLimRspReqd flag for the scan req if any other
1377 * request comes by then. e.g. While unit testing, we found when insert
1378 * single NOA is done, we see a get stats request which turns the flag
1379 * gLimRspReqd to false; now when we actually start the saved scan req
1380 * for init scan after getting NOA started, the gLimRspReqd being a
1381 * global flag is showing false instead of true value for this saved
1382 * scan req. Since all scan reqs coming to lim require a response,
1383 * there is no harm in setting the global flag gLimRspReqd to true here.
1384 */
1385 mac_ctx->lim.gLimRspReqd = true;
1386
1387 /*
1388 * copy the Self MAC address from SmeReq to the globalplace,
1389 * used for sending probe req
1390 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001391 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1392 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1394
1395 if (!valid_req || mac_ctx->lim.scan_disabled) {
1396 lim_log(mac_ctx, LOGE,
1397 FL("Scan disabled %d, Valid Scan Req %d"),
1398 mac_ctx->lim.scan_disabled, valid_req);
1399
1400 if (mac_ctx->lim.gLimRspReqd) {
1401 mac_ctx->lim.gLimRspReqd = false;
1402
1403 lim_send_sme_scan_rsp(mac_ctx,
1404 eSIR_SME_INVALID_PARAMETERS,
1405 scan_req->sessionId,
1406 scan_req->transactionId,
1407 scan_req->scan_id);
1408 }
1409 return;
1410 }
1411
1412 /*
1413 * If scan request is received in idle, joinFailed
1414 * states or in link established state (in STA role)
1415 * or in normal state (in STA-in-IBSS/AP role) with
1416 * 'return fresh scan results' request from HDD or
1417 * it is periodic background scanning request,
1418 * trigger fresh scan request to MLM
1419 */
1420 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1421
1422 mac_ctx->lim.gLim24Band11dScanDone = 0;
1423 mac_ctx->lim.gLim50Band11dScanDone = 0;
1424 mac_ctx->lim.gLimReturnAfterFirstMatch =
1425 scan_req->returnAfterFirstMatch;
1426 mac_ctx->lim.gLimReturnUniqueResults =
1427 ((scan_req->returnUniqueResults) > 0 ? true : false);
1428
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301429 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 lim_send_hal_start_scan_offload_req(mac_ctx,
1431 scan_req)) {
1432 lim_log(mac_ctx, LOGE, FL(
1433 "Couldn't send Offload scan request"));
1434 lim_send_sme_scan_rsp(mac_ctx,
1435 eSIR_SME_INVALID_PARAMETERS,
1436 scan_req->sessionId,
1437 scan_req->transactionId,
1438 scan_req->scan_id);
1439 return;
1440 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301441 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 /* In all other cases return 'cached' scan results */
1443 if (mac_ctx->lim.gLimRspReqd) {
1444 mac_ctx->lim.gLimRspReqd = false;
1445 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1446 scan_req->sessionId,
1447 scan_req->transactionId, scan_req->scan_id);
1448 }
1449 }
1450}
1451
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452/**
1453 * __lim_process_clear_dfs_channel_list()
1454 *
1455 ***FUNCTION:
1456 ***Clear DFS channel list when country is changed/aquired.
1457 .*This message is sent from SME.
1458 *
1459 ***LOGIC:
1460 *
1461 ***ASSUMPTIONS:
1462 *
1463 ***NOTE:
1464 *
1465 * @param pMac Pointer to Global MAC structure
1466 * @param *pMsgBuf A pointer to the SME message buffer
1467 * @return None
1468 */
1469static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1470{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301471 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472}
1473
1474/**
1475 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1476 * @mac_ctx: Pointer to Global MAC structure
1477 * @msg_buf: A pointer to the SME message buffer
1478 *
1479 * This function is called to process SME_JOIN_REQ message
1480 * from HDD or upper layer application.
1481 *
1482 * Return: None
1483 */
1484static void
1485__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1486{
1487 tpSirSmeJoinReq sme_join_req = NULL;
1488 tLimMlmJoinReq *mlm_join_req;
1489 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1490 uint32_t val = 0;
1491 uint16_t n_size;
1492 uint8_t session_id;
1493 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301494 uint8_t sme_session_id = 0;
1495 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001496 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497 uint16_t ie_len;
1498 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001499 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001500 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501
Arif Hussain995fcaf2016-07-18 11:28:22 -07001502 if (!mac_ctx || !msg_buf) {
1503 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1504 FL("JOIN REQ with invalid data"));
1505 return;
1506 }
1507
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508/* FEATURE_WLAN_DIAG_SUPPORT */
1509#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1510 /*
1511 * Not sending any session, since it is not created yet.
1512 * The response whould have correct state.
1513 */
1514 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1515#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 /*
1518 * Expect Join request in idle state.
1519 * Reassociate request is expected in link established state.
1520 */
1521
1522 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1523 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1524 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1525 msg_buf);
1526
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301527 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 if (NULL == sme_join_req) {
1529 lim_log(mac_ctx, LOGP,
1530 FL("AllocateMemory failed for sme_join_req"));
1531 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301532 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301534 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 n_size);
1536
1537 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1538 /* Received invalid eWNI_SME_JOIN_REQ */
1539 /* Log the event */
1540 lim_log(mac_ctx, LOGW,
1541 FL("SessionId:%d JOIN REQ with invalid data"),
1542 sme_join_req->sessionId);
1543 ret_code = eSIR_SME_INVALID_PARAMETERS;
1544 goto end;
1545 }
1546
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001547 /*
1548 * Update the capability here itself as this is used in
1549 * lim_extract_ap_capability() below. If not updated issues
1550 * like not honoring power constraint on 1st association after
1551 * driver loading might occur.
1552 */
1553 lim_update_rrm_capability(mac_ctx, sme_join_req);
1554
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001555 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001557 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 &session_id);
1559
1560 if (session != NULL) {
1561 lim_log(mac_ctx, LOGE,
1562 FL("Session(%d) Already exists for BSSID: "
1563 MAC_ADDRESS_STR " in limSmeState = %X"),
1564 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001565 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 session->limSmeState);
1567
1568 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1569 session->smeSessionId == sme_join_req->sessionId) {
1570 /*
1571 * Received eWNI_SME_JOIN_REQ for same
1572 * BSS as currently associated.
1573 * Log the event and send success
1574 */
1575 lim_log(mac_ctx, LOGW,
1576 FL("SessionId: %d"), session_id);
1577 lim_log(mac_ctx, LOGW,
1578 FL("JOIN_REQ for current joined BSS"));
1579 /* Send Join success response to host */
1580 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1581 session = NULL;
1582 goto end;
1583 } else {
1584 lim_log(mac_ctx, LOGE,
1585 FL("JOIN_REQ not for current joined BSS"));
1586 ret_code = eSIR_SME_REFUSED;
1587 session = NULL;
1588 goto end;
1589 }
1590 } else {
1591 /*
1592 * Session Entry does not exist for given BSSId
1593 * Try to Create a new session
1594 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001595 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 &session_id, mac_ctx->lim.maxStation,
1597 eSIR_INFRASTRUCTURE_MODE);
1598 if (session == NULL) {
1599 lim_log(mac_ctx, LOGE,
1600 FL("Session Can not be created "));
1601 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1602 goto end;
1603 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301604 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 FL("SessionId:%d New session created"),
1606 session_id);
1607 }
1608 session->isAmsduSupportInAMPDU =
1609 sme_join_req->isAmsduSupportInAMPDU;
1610
1611 /*
1612 * Store Session related parameters
1613 * Store PE session Id in session Table
1614 */
1615 session->peSessionId = session_id;
1616
1617 /* store the smejoin req handle in session table */
1618 session->pLimJoinReq = sme_join_req;
1619
1620 /* Store SME session Id in sessionTable */
1621 session->smeSessionId = sme_join_req->sessionId;
1622
1623 /* Store SME transaction Id in session Table */
1624 session->transactionId = sme_join_req->transactionId;
1625
1626 /* Store beaconInterval */
1627 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001628 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301630 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631 sizeof(session->htConfig));
1632
Sandeep Puligilla98917432016-06-10 13:50:28 -07001633 qdf_mem_copy(&(session->vht_config),
1634 &(sme_join_req->vht_config),
1635 sizeof(session->vht_config));
1636
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 /* Copying of bssId is already done, while creating session */
1638 sir_copy_mac_addr(session->selfMacAddr,
1639 sme_join_req->selfMacAddr);
1640 session->bssType = sme_join_req->bsstype;
1641
1642 session->statypeForBss = STA_ENTRY_PEER;
1643 session->limWmeEnabled = sme_join_req->isWMEenabled;
1644 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301645 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646
1647 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001648 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1650
1651 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1652 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001653 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654
1655 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001656 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 session->isCiscoVendorAP = true;
1658 } else {
1659 session->isCiscoVendorAP = false;
1660 }
1661
1662 /* Copy the dot 11 mode in to the session table */
1663
1664 session->dot11mode = sme_join_req->dot11mode;
1665#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1666 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1667#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001668 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1670 session->enableHtSmps = sme_join_req->enableHtSmps;
1671 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001672 session->send_smps_action =
1673 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001674 /*
1675 * By default supported NSS 1x1 is set to true
1676 * and later on updated while determining session
1677 * supported rates which is the intersection of
1678 * self and peer rates
1679 */
1680 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301681 /*Store Persona */
1682 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001683 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301684 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001685 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001686 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001687 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301688 session->supported_nss_1x1,
1689 session->pePersona,
1690 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001691
1692 /*Store Persona */
1693 session->pePersona = sme_join_req->staPersona;
1694 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1695 FL("PE PERSONA=%d cbMode %u"),
1696 session->pePersona, sme_join_req->cbMode);
1697 /* Copy The channel Id to the session Table */
1698 session->currentOperChannel = bss_desc->channelId;
1699 if (IS_5G_CH(session->currentOperChannel))
1700 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001701 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001702 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1703 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1704 session->vdev_nss = vdev_type_nss->p2p_cli;
1705 else
1706 session->vdev_nss = vdev_type_nss->sta;
1707 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 session->vhtCapability =
1709 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301711 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001712 session->vht_config.su_beam_formee =
1713 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001715 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 session->enableVhtpAid =
1718 sme_join_req->enableVhtpAid;
1719 session->enableVhtGid =
1720 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001721 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1722 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723 }
Krunal Soni53993f72016-07-08 18:20:03 -07001724
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301725 lim_log(mac_ctx, LOG1,
Krunal Soni53993f72016-07-08 18:20:03 -07001726 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301727 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001728 session->vht_config.su_beam_formee,
1729 session->vht_config.csnof_beamformer_antSup,
1730 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001732 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 /* cbMode is already merged value of peer and self -
1735 * done by csr in csr_get_cb_mode_from_ies */
1736 session->htSupportedChannelWidthSet =
1737 (sme_join_req->cbMode) ? 1 : 0;
1738 session->htRecommendedTxWidthSet =
1739 session->htSupportedChannelWidthSet;
1740 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1741
1742 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1743 session->ch_center_freq_seg0 =
1744 session->currentOperChannel - 2;
1745 session->ch_width = CH_WIDTH_40MHZ;
1746 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1747 sme_join_req->cbMode) {
1748 session->ch_center_freq_seg0 =
1749 session->currentOperChannel + 2;
1750 session->ch_width = CH_WIDTH_40MHZ;
1751 } else {
1752 session->ch_center_freq_seg0 = 0;
1753 session->ch_width = CH_WIDTH_20MHZ;
1754 }
1755
1756 /* Record if management frames need to be protected */
1757#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001758 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001760 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762#endif
1763
1764#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001765 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766#endif
1767
1768 /* Copy the SSID from smejoinreq to session entry */
1769 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301770 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 session->ssId.length);
1772
1773 /*
1774 * Determin 11r or ESE connection based on input from SME
1775 * which inturn is dependent on the profile the user wants
1776 * to connect to, So input is coming from supplicant
1777 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779#ifdef FEATURE_WLAN_ESE
1780 session->isESEconnection = sme_join_req->isESEconnection;
1781#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 session->isFastTransitionEnabled =
1783 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 session->isFastRoamIniFeatureEnabled =
1786 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 session->txLdpcIniFeatureEnabled =
1788 sme_join_req->txLdpcIniFeatureEnabled;
1789
1790 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1791 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 } else {
1793 /*
1794 * Throw an error and return and make
1795 * sure to delete the session.
1796 */
1797 lim_log(mac_ctx, LOGE,
1798 FL("recvd JOIN_REQ with invalid bss type %d"),
1799 session->bssType);
1800 ret_code = eSIR_SME_INVALID_PARAMETERS;
1801 goto end;
1802 }
1803
1804 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301805 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 &sme_join_req->addIEScan, sizeof(tSirAddie));
1807
1808 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301809 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1811
1812 val = sizeof(tLimMlmJoinReq) +
1813 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301814 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815 if (NULL == mlm_join_req) {
1816 lim_log(mac_ctx, LOGP,
1817 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301818 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1819 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821
1822 /* PE SessionId is stored as a part of JoinReq */
1823 mlm_join_req->sessionId = session->peSessionId;
1824
1825 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1826 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1827 eSIR_SUCCESS) {
1828 lim_log(mac_ctx, LOGP,
1829 FL("couldn't retrieve JoinFailureTimer value"
1830 " setting to default value"));
1831 mlm_join_req->joinFailureTimeout =
1832 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1833 }
1834
1835 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301836 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 (void *)&sme_join_req->operationalRateSet,
1838 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301839 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 (void *)&sme_join_req->extendedRateSet,
1841 sizeof(tSirMacRateSet));
1842 /*
1843 * this may not be needed anymore now, as rateSet is now
1844 * included in the session entry and MLM has session context.
1845 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301846 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847 (void *)&session->rateSet,
1848 sizeof(tSirMacRateSet));
1849
1850 session->encryptType = sme_join_req->UCEncryptionType;
1851
1852 mlm_join_req->bssDescription.length =
1853 session->pLimJoinReq->bssDescription.length;
1854
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301855 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 (uint8_t *)
1857 &session->pLimJoinReq->bssDescription.bssId,
1858 session->pLimJoinReq->bssDescription.length + 2);
1859
1860 session->limCurrentBssCaps =
1861 session->pLimJoinReq->bssDescription.capabilityInfo;
1862
1863 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1864 session->currentOperChannel);
1865 local_power_constraint = reg_max;
1866
1867 lim_extract_ap_capability(mac_ctx,
1868 (uint8_t *)
1869 session->pLimJoinReq->bssDescription.ieFields,
1870 lim_get_ielen_from_bss_description(
1871 &session->pLimJoinReq->bssDescription),
1872 &session->limCurrentBssQosCaps,
1873 &session->limCurrentBssPropCap,
1874 &session->gLimCurrentBssUapsd,
1875 &local_power_constraint, session);
1876
Krunal Soni53993f72016-07-08 18:20:03 -07001877 /*
1878 * Once the AP capabilities are available then set the
1879 * beam forming capabilities accordingly.
1880 */
1881 if (session->nss == 1) {
1882 session->vht_config.su_beam_former = 0;
1883 session->vht_config.tx_stbc = 0;
1884 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301885 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001886 }
1887
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 session->maxTxPower = lim_get_max_tx_power(reg_max,
1889 local_power_constraint,
1890 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301891
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301892 lim_log(mac_ctx, LOG1,
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301893 FL("Reg max %d local power con %d max tx pwr %d"),
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301894 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895
1896 if (session->gLimCurrentBssUapsd) {
1897 session->gUapsdPerAcBitmask =
1898 session->pLimJoinReq->uapsdPerAcBitmask;
1899 lim_log(mac_ctx, LOG1,
1900 FL("UAPSD flag for all AC - 0x%2x"),
1901 session->gUapsdPerAcBitmask);
1902
1903 /* resetting the dynamic uapsd mask */
1904 session->gUapsdPerAcDeliveryEnableMask = 0;
1905 session->gUapsdPerAcTriggerEnableMask = 0;
1906 }
1907
1908 session->limRFBand =
1909 lim_get_rf_band(session->currentOperChannel);
1910
1911 /* Initialize 11h Enable Flag */
1912 if (SIR_BAND_5_GHZ == session->limRFBand) {
1913 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1914 &val) != eSIR_SUCCESS) {
1915 lim_log(mac_ctx, LOGP,
1916 FL("Fail to get WNI_CFG_11H_ENABLED "));
1917 session->lim11hEnable =
1918 WNI_CFG_11H_ENABLED_STADEF;
1919 } else {
1920 session->lim11hEnable = val;
1921 }
1922 } else {
1923 session->lim11hEnable = 0;
1924 }
1925
1926 /*
1927 * To care of the scenario when STA transitions from
1928 * IBSS to Infrastructure mode.
1929 */
1930 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1931
1932 session->limPrevSmeState = session->limSmeState;
1933 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1934 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1935 session->peSessionId,
1936 session->limSmeState));
1937
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 /* Indicate whether spectrum management is enabled */
1939 session->spectrumMgtEnabled =
1940 sme_join_req->spectrumMgtIndicator;
1941
1942 /* Enable the spectrum management if this is a DFS channel */
1943 if (session->country_info_present &&
1944 lim_isconnected_on_dfs_channel(
1945 session->currentOperChannel))
1946 session->spectrumMgtEnabled = true;
1947
1948 session->isOSENConnection = sme_join_req->isOSENConnection;
1949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 /* Issue LIM_MLM_JOIN_REQ to MLM */
1951 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1952 (uint32_t *) mlm_join_req);
1953 return;
1954
1955 } else {
1956 /* Received eWNI_SME_JOIN_REQ un expected state */
1957 lim_log(mac_ctx, LOGE,
1958 FL("received unexpected SME_JOIN_REQ in state %X"),
1959 mac_ctx->lim.gLimSmeState);
1960 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1961 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1962 session = NULL;
1963 goto end;
1964 }
1965
1966end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301967 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1968 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969
1970 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301971 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 sme_join_req = NULL;
1973 if (NULL != session)
1974 session->pLimJoinReq = NULL;
1975 }
1976 if (ret_code != eSIR_SME_SUCCESS) {
1977 if (NULL != session) {
1978 pe_delete_session(mac_ctx, session);
1979 session = NULL;
1980 }
1981 }
1982 lim_log(mac_ctx, LOG1,
1983 FL("Send failure status on sessionid: %d with ret_code = %d"),
1984 sme_session_id, ret_code);
1985 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1986 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1987 sme_transaction_id);
1988}
1989
Amar Singhala297bfa2015-10-15 15:07:29 -07001990uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 uint8_t iniTxPower)
1992{
1993 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301994 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
1995 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1997 maxTxPower = txPower;
1998 else if (txPower < MIN_TX_PWR_CAP)
1999 maxTxPower = MIN_TX_PWR_CAP;
2000 else
2001 maxTxPower = MAX_TX_PWR_CAP;
2002
2003 return maxTxPower;
2004}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005
2006/**
2007 * __lim_process_sme_reassoc_req() - process reassoc req
2008 *
2009 * @mac_ctx: Pointer to Global MAC structure
2010 * @msg_buf: pointer to the SME message buffer
2011 *
2012 * This function is called to process SME_REASSOC_REQ message
2013 * from HDD or upper layer application.
2014 *
2015 * Return: None
2016 */
2017
2018static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2019 uint32_t *msg_buf)
2020{
2021 uint16_t caps;
2022 uint32_t val;
2023 tpSirSmeJoinReq reassoc_req = NULL;
2024 tLimMlmReassocReq *mlm_reassoc_req;
2025 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2026 tpPESession session_entry = NULL;
2027 uint8_t session_id;
2028 uint8_t sme_session_id;
2029 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002030 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 uint32_t tele_bcn_en = 0;
2032 uint16_t size;
2033
2034 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2035
2036 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302037 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 if (NULL == reassoc_req) {
2039 lim_log(mac_ctx, LOGP,
2040 FL("call to AllocateMemory failed for reassoc_req"));
2041
2042 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2043 goto end;
2044 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302045 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046
2047 if (!lim_is_sme_join_req_valid(mac_ctx,
2048 (tpSirSmeJoinReq)reassoc_req)) {
2049 /*
2050 * Received invalid eWNI_SME_REASSOC_REQ
2051 */
2052 lim_log(mac_ctx, LOGW,
2053 FL("received SME_REASSOC_REQ with invalid data"));
2054
2055 ret_code = eSIR_SME_INVALID_PARAMETERS;
2056 goto end;
2057 }
2058
2059 session_entry = pe_find_session_by_bssid(mac_ctx,
2060 reassoc_req->bssDescription.bssId,
2061 &session_id);
2062 if (session_entry == NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 lim_log(mac_ctx, LOGE,
2064 FL("Session does not exist for given bssId"));
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002065 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2066 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002068 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2069 &sme_session_id, &transaction_id);
2070 session_entry =
2071 pe_find_session_by_sme_session_id(mac_ctx,
2072 sme_session_id);
2073 if (session_entry != NULL)
2074 lim_handle_sme_join_result(mac_ctx,
2075 eSIR_SME_INVALID_PARAMETERS,
2076 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2077 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 goto end;
2079 }
2080#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2081 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2082 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2083#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2084 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2085
2086 /* Store the reassoc handle in the session Table */
2087 session_entry->pLimReAssocReq = reassoc_req;
2088
2089 session_entry->dot11mode = reassoc_req->dot11mode;
2090 session_entry->vhtCapability =
2091 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002092
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302093 if (session_entry->vhtCapability) {
2094 if (session_entry->pePersona == QDF_STA_MODE) {
2095 session_entry->vht_config.su_beam_formee =
2096 reassoc_req->vht_config.su_beam_formee;
2097 } else {
2098 reassoc_req->vht_config.su_beam_formee = 0;
2099 }
2100 session_entry->enableVhtpAid =
2101 reassoc_req->enableVhtpAid;
2102 session_entry->enableVhtGid =
2103 reassoc_req->enableVhtGid;
2104 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2105 session_entry->vht_config.su_beam_former);
2106 }
2107
2108 lim_log(mac_ctx, LOG1,
2109 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2110 session_entry->vhtCapability,
2111 session_entry->vht_config.su_beam_formee,
2112 session_entry->vht_config.su_beam_former);
2113
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002114 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2115 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002116 session_entry->send_smps_action =
2117 reassoc_req->send_smps_action;
2118 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002119 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002120 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002121 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002122 session_entry->send_smps_action,
2123 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 /*
2125 * Reassociate request is expected
2126 * in link established state only.
2127 */
2128
2129 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2131 /*
2132 * May be from 11r FT pre-auth. So lets check it
2133 * before we bail out
2134 */
2135 lim_log(mac_ctx, LOG1, FL(
2136 "Session in reassoc state is %d"),
2137 session_entry->peSessionId);
2138
2139 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302140 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 session_entry->limReAssocbssId,
2142 6)) {
2143 lim_print_mac_addr(mac_ctx,
2144 reassoc_req->bssDescription.
2145 bssId, LOGE);
2146 lim_log(mac_ctx, LOGP,
2147 FL("Unknown bssId in reassoc state"));
2148 ret_code = eSIR_SME_INVALID_PARAMETERS;
2149 goto end;
2150 }
2151
2152 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2153 session_entry);
2154 return;
2155 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156 /*
2157 * Should not have received eWNI_SME_REASSOC_REQ
2158 */
2159 lim_log(mac_ctx, LOGE,
2160 FL("received unexpected SME_REASSOC_REQ in state %X"),
2161 session_entry->limSmeState);
2162 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2163
2164 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2165 goto end;
2166 }
2167
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302168 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 session_entry->pLimReAssocReq->bssDescription.bssId,
2170 sizeof(tSirMacAddr));
2171
2172 session_entry->limReassocChannelId =
2173 session_entry->pLimReAssocReq->bssDescription.channelId;
2174
2175 session_entry->reAssocHtSupportedChannelWidthSet =
2176 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2177 session_entry->reAssocHtRecommendedTxWidthSet =
2178 session_entry->reAssocHtSupportedChannelWidthSet;
2179 session_entry->reAssocHtSecondaryChannelOffset =
2180 session_entry->pLimReAssocReq->cbMode;
2181
2182 session_entry->limReassocBssCaps =
2183 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2184 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2185 session_entry->currentOperChannel);
2186 local_pwr_constraint = reg_max;
2187
2188 lim_extract_ap_capability(mac_ctx,
2189 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2190 lim_get_ielen_from_bss_description(
2191 &session_entry->pLimReAssocReq->bssDescription),
2192 &session_entry->limReassocBssQosCaps,
2193 &session_entry->limReassocBssPropCap,
2194 &session_entry->gLimCurrentBssUapsd,
2195 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302196 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302198 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2199 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 /* Copy the SSID from session entry to local variable */
2201 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302202 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 reassoc_req->ssId.ssId,
2204 session_entry->limReassocSSID.length);
2205 if (session_entry->gLimCurrentBssUapsd) {
2206 session_entry->gUapsdPerAcBitmask =
2207 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2208 lim_log(mac_ctx, LOG1,
2209 FL("UAPSD flag for all AC - 0x%2x"),
2210 session_entry->gUapsdPerAcBitmask);
2211 }
2212
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302213 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 if (NULL == mlm_reassoc_req) {
2215 lim_log(mac_ctx, LOGP,
2216 FL("call to AllocateMemory failed for mlmReassocReq"));
2217
2218 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2219 goto end;
2220 }
2221
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302222 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2224
2225 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2226 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2227 eSIR_SUCCESS) {
2228 /*
2229 * Could not get ReassocFailureTimeout value
2230 * from CFG. Log error.
2231 */
2232 lim_log(mac_ctx, LOGP,
2233 FL("could not retrieve ReassocFailureTimeout value"));
2234 }
2235
2236 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2237 eSIR_SUCCESS) {
2238 /*
2239 * Could not get Capabilities value
2240 * from CFG. Log error.
2241 */
2242 lim_log(mac_ctx, LOGP, FL(
2243 "could not retrieve Capabilities value"));
2244 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302245
2246 lim_update_caps_info_for_bss(mac_ctx, &caps,
2247 reassoc_req->bssDescription.capabilityInfo);
2248 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2249
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 mlm_reassoc_req->capabilityInfo = caps;
2251
2252 /* Update PE session_id */
2253 mlm_reassoc_req->sessionId = session_id;
2254
2255 /*
2256 * If telescopic beaconing is enabled, set listen interval to
2257 * WNI_CFG_TELE_BCN_MAX_LI
2258 */
2259 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2260 &tele_bcn_en) != eSIR_SUCCESS)
2261 lim_log(mac_ctx, LOGP,
2262 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2263
2264 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2265
2266 if (tele_bcn_en) {
2267 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2268 eSIR_SUCCESS)
2269 /*
2270 * Could not get ListenInterval value
2271 * from CFG. Log error.
2272 */
2273 lim_log(mac_ctx, LOGP,
2274 FL("could not retrieve ListenInterval"));
2275 } else {
2276 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2277 eSIR_SUCCESS)
2278 /*
2279 * Could not get ListenInterval value
2280 * from CFG. Log error.
2281 */
2282 lim_log(mac_ctx, LOGP,
2283 FL("could not retrieve ListenInterval"));
2284 }
2285
2286 mlm_reassoc_req->listenInterval = (uint16_t) val;
2287
2288 /* Indicate whether spectrum management is enabled */
2289 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2290
2291 /* Enable the spectrum management if this is a DFS channel */
2292 if (session_entry->country_info_present &&
2293 lim_isconnected_on_dfs_channel(
2294 session_entry->currentOperChannel))
2295 session_entry->spectrumMgtEnabled = true;
2296
2297 session_entry->limPrevSmeState = session_entry->limSmeState;
2298 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2299
2300 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2301 session_entry->peSessionId,
2302 session_entry->limSmeState));
2303
2304 lim_post_mlm_message(mac_ctx,
2305 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2306 return;
2307end:
2308 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302309 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 if (session_entry)
2311 session_entry->pLimReAssocReq = NULL;
2312 }
2313
2314 if (session_entry) {
2315 /*
2316 * error occurred after we determined the session so extract
2317 * session and transaction info from there
2318 */
2319 sme_session_id = session_entry->smeSessionId;
2320 transaction_id = session_entry->transactionId;
2321 } else
2322 /*
2323 * error occurred before or during the time we determined
2324 * the session so extract the session and transaction info
2325 * from the message
2326 */
2327 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2328 &sme_session_id, &transaction_id);
2329
2330 /*
2331 * Send Reassoc failure response to host
2332 * (note session_entry may be NULL, but that's OK)
2333 */
2334 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2335 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2336 session_entry, sme_session_id,
2337 transaction_id);
2338}
2339
2340bool send_disassoc_frame = 1;
2341/**
2342 * __lim_process_sme_disassoc_req()
2343 *
2344 ***FUNCTION:
2345 * This function is called to process SME_DISASSOC_REQ message
2346 * from HDD or upper layer application.
2347 *
2348 ***LOGIC:
2349 *
2350 ***ASSUMPTIONS:
2351 *
2352 ***NOTE:
2353 *
2354 * @param pMac Pointer to Global MAC structure
2355 * @param *pMsgBuf A pointer to the SME message buffer
2356 * @return None
2357 */
2358
2359static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2360{
2361 uint16_t disassocTrigger, reasonCode;
2362 tLimMlmDisassocReq *pMlmDisassocReq;
2363 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2364 tSirSmeDisassocReq smeDisassocReq;
2365 tpPESession psessionEntry = NULL;
2366 uint8_t sessionId;
2367 uint8_t smesessionId;
2368 uint16_t smetransactionId;
2369
2370 if (pMsgBuf == NULL) {
2371 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2372 return;
2373 }
2374
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302375 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 smesessionId = smeDisassocReq.sessionId;
2377 smetransactionId = smeDisassocReq.transactionId;
2378 if (!lim_is_sme_disassoc_req_valid(pMac,
2379 &smeDisassocReq,
2380 psessionEntry)) {
2381 PELOGE(lim_log(pMac, LOGE,
2382 FL("received invalid SME_DISASSOC_REQ message"));)
2383 if (pMac->lim.gLimRspReqd) {
2384 pMac->lim.gLimRspReqd = false;
2385
2386 retCode = eSIR_SME_INVALID_PARAMETERS;
2387 disassocTrigger = eLIM_HOST_DISASSOC;
2388 goto sendDisassoc;
2389 }
2390
2391 return;
2392 }
2393
2394 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002395 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 &sessionId);
2397 if (psessionEntry == NULL) {
2398 lim_log(pMac, LOGE,
2399 FL("session does not exist for given bssId "
2400 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002401 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402 retCode = eSIR_SME_INVALID_PARAMETERS;
2403 disassocTrigger = eLIM_HOST_DISASSOC;
2404 goto sendDisassoc;
2405 }
2406 lim_log(pMac, LOG1,
2407 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2408 MAC_ADDRESS_STR), smesessionId,
2409 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2410 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002411 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412
2413#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2414 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2415 0, smeDisassocReq.reasonCode);
2416#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2417
2418 /* Update SME session Id and SME transaction ID */
2419
2420 psessionEntry->smeSessionId = smesessionId;
2421 psessionEntry->transactionId = smetransactionId;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002422 lim_log(pMac, LOGW, FL("ho_fail: %d "), smeDisassocReq.process_ho_fail);
2423 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424
2425 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2426 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 switch (psessionEntry->limSmeState) {
2428 case eLIM_SME_ASSOCIATED_STATE:
2429 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002430 lim_log(pMac, LOG1,
2431 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2432 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 psessionEntry->limPrevSmeState =
2434 psessionEntry->limSmeState;
2435 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2436#ifdef FEATURE_WLAN_TDLS
2437 /* Delete all TDLS peers connected before leaving BSS */
2438 lim_delete_tdls_peers(pMac, psessionEntry);
2439#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002440 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2441 psessionEntry->peSessionId,
2442 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 break;
2444
2445 case eLIM_SME_WT_DEAUTH_STATE:
2446 /* PE shall still process the DISASSOC_REQ and proceed with
2447 * link tear down even if it had already sent a DEAUTH_IND to
2448 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2449 * its been set when PE entered WT_DEAUTH_STATE.
2450 */
2451 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2452 MTRACE(mac_trace
2453 (pMac, TRACE_CODE_SME_STATE,
2454 psessionEntry->peSessionId,
2455 psessionEntry->limSmeState));
2456 lim_log(pMac, LOG1,
2457 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2458 break;
2459
2460 case eLIM_SME_WT_DISASSOC_STATE:
2461 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2462 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2463 * PE can continue processing DISASSOC_REQ and send the response instead
2464 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2465 * for disassoc frame.
2466 *
2467 * It will send a disassoc, which is ok. However, we can use the global flag
2468 * sendDisassoc to not send disassoc frame.
2469 */
2470 lim_log(pMac, LOG1,
2471 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2472 break;
2473
2474 case eLIM_SME_JOIN_FAILURE_STATE: {
2475 /* Already in Disconnected State, return success */
2476 lim_log(pMac, LOG1,
2477 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2478 if (pMac->lim.gLimRspReqd) {
2479 retCode = eSIR_SME_SUCCESS;
2480 disassocTrigger = eLIM_HOST_DISASSOC;
2481 goto sendDisassoc;
2482 }
2483 }
2484 break;
2485 default:
2486 /**
2487 * STA is not currently associated.
2488 * Log error and send response to host
2489 */
2490 lim_log(pMac, LOGE,
2491 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2492 psessionEntry->limSmeState);
2493 lim_print_sme_state(pMac, LOGE,
2494 psessionEntry->limSmeState);
2495
2496 if (pMac->lim.gLimRspReqd) {
2497 if (psessionEntry->limSmeState !=
2498 eLIM_SME_WT_ASSOC_STATE)
2499 pMac->lim.gLimRspReqd = false;
2500
2501 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2502 disassocTrigger = eLIM_HOST_DISASSOC;
2503 goto sendDisassoc;
2504 }
2505
2506 return;
2507 }
2508
2509 break;
2510
2511 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 /* Fall through */
2513 break;
2514
2515 case eLIM_STA_IN_IBSS_ROLE:
2516 default:
2517 /* eLIM_UNKNOWN_ROLE */
2518 lim_log(pMac, LOGE,
2519 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2520 GET_LIM_SYSTEM_ROLE(psessionEntry));
2521
2522 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2523 disassocTrigger = eLIM_HOST_DISASSOC;
2524 goto sendDisassoc;
2525 } /* end switch (pMac->lim.gLimSystemRole) */
2526
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302527 disassocTrigger = eLIM_HOST_DISASSOC;
2528 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529
2530 if (smeDisassocReq.doNotSendOverTheAir) {
2531 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2532 send_disassoc_frame = 0;
2533 }
2534 /* Trigger Disassociation frame to peer MAC entity */
2535 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2536 " : %d, reasonCode : %d"),
2537 disassocTrigger, reasonCode);
2538
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302539 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 if (NULL == pMlmDisassocReq) {
2541 /* Log error */
2542 lim_log(pMac, LOGP,
2543 FL("call to AllocateMemory failed for mlmDisassocReq"));
2544
2545 return;
2546 }
2547
Anurag Chouhanc5548422016-02-24 18:33:27 +05302548 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002549 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550
2551 pMlmDisassocReq->reasonCode = reasonCode;
2552 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2553
2554 /* Update PE session ID */
2555 pMlmDisassocReq->sessionId = sessionId;
2556
2557 lim_post_mlm_message(pMac,
2558 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2559 return;
2560
2561sendDisassoc:
2562 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002563 lim_send_sme_disassoc_ntf(pMac,
2564 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 retCode,
2566 disassocTrigger,
2567 1, smesessionId, smetransactionId,
2568 psessionEntry);
2569 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002570 lim_send_sme_disassoc_ntf(pMac,
2571 smeDisassocReq.peer_macaddr.bytes,
2572 retCode, disassocTrigger, 1,
2573 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574
2575} /*** end __lim_process_sme_disassoc_req() ***/
2576
2577/** -----------------------------------------------------------------
2578 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2579
2580 This function is called to process SME_DISASSOC_CNF message
2581 from HDD or upper layer application.
2582
2583 \param pMac - global mac structure
2584 \param pStaDs - station dph hash node
2585 \return none
2586 \sa
2587 ----------------------------------------------------------------- */
2588static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2589{
2590 tSirSmeDisassocCnf smeDisassocCnf;
2591 uint16_t aid;
2592 tpDphHashNode pStaDs;
2593 tpPESession psessionEntry;
2594 uint8_t sessionId;
2595
2596 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2597
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302598 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 sizeof(struct sSirSmeDisassocCnf));
2600
2601 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002602 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 &sessionId);
2604 if (psessionEntry == NULL) {
2605 lim_log(pMac, LOGE,
2606 FL("session does not exist for given bssId"));
2607 return;
2608 }
2609
2610 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2611 lim_log(pMac, LOGE,
2612 FL("received invalid SME_DISASSOC_CNF message"));
2613 return;
2614 }
2615#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2616 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2617 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2618 psessionEntry,
2619 (uint16_t) smeDisassocCnf.statusCode, 0);
2620 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2621 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2622 psessionEntry,
2623 (uint16_t) smeDisassocCnf.statusCode, 0);
2624#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2625
2626 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2627 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2629 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2630 && (psessionEntry->limSmeState !=
2631 eLIM_SME_WT_DEAUTH_STATE)) {
2632 lim_log(pMac, LOGE,
2633 FL
2634 ("received unexp SME_DISASSOC_CNF in state %X"),
2635 psessionEntry->limSmeState);
2636 lim_print_sme_state(pMac, LOGE,
2637 psessionEntry->limSmeState);
2638 return;
2639 }
2640 break;
2641
2642 case eLIM_AP_ROLE:
2643 /* Fall through */
2644 break;
2645
2646 case eLIM_STA_IN_IBSS_ROLE:
2647 default: /* eLIM_UNKNOWN_ROLE */
2648 lim_log(pMac, LOGE,
2649 FL("received unexpected SME_DISASSOC_CNF role %d"),
2650 GET_LIM_SYSTEM_ROLE(psessionEntry));
2651
2652 return;
2653 }
2654
2655 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2656 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2657 LIM_IS_AP_ROLE(psessionEntry)) {
2658 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002659 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 &psessionEntry->dph.dphHashTable);
2661 if (pStaDs == NULL) {
2662 lim_log(pMac, LOGE,
2663 FL("DISASSOC_CNF for a STA with no context, addr= "
2664 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002665 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 return;
2667 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302668
2669 if ((pStaDs->mlmStaContext.mlmState ==
2670 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2671 (pStaDs->mlmStaContext.mlmState ==
2672 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2673 lim_log(pMac, LOGE,
2674 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002675 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302676 pStaDs->mlmStaContext.mlmState);
2677 return;
2678 }
2679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 /* Delete FT session if there exists one */
2681 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2683
2684 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002685 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 }
2687
2688 return;
2689}
2690
2691/**
2692 * __lim_process_sme_deauth_req() - process sme deauth req
2693 * @mac_ctx: Pointer to Global MAC structure
2694 * @msg_buf: pointer to the SME message buffer
2695 *
2696 * This function is called to process SME_DEAUTH_REQ message
2697 * from HDD or upper layer application.
2698 *
2699 * Return: None
2700 */
2701
2702static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2703 uint32_t *msg_buf)
2704{
2705 uint16_t deauth_trigger, reason_code;
2706 tLimMlmDeauthReq *mlm_deauth_req;
2707 tSirSmeDeauthReq sme_deauth_req;
2708 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2709 tpPESession session_entry;
2710 uint8_t session_id; /* PE sessionId */
2711 uint8_t sme_session_id;
2712 uint16_t sme_transaction_id;
2713
2714 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2715
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302716 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 sme_session_id = sme_deauth_req.sessionId;
2718 sme_transaction_id = sme_deauth_req.transactionId;
2719
2720 /*
2721 * We need to get a session first but we don't even know
2722 * if the message is correct.
2723 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002724 session_entry = pe_find_session_by_bssid(mac_ctx,
2725 sme_deauth_req.bssid.bytes,
2726 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727 if (session_entry == NULL) {
2728 lim_log(mac_ctx, LOGE,
2729 FL("session does not exist for given bssId"));
2730 ret_code = eSIR_SME_INVALID_PARAMETERS;
2731 deauth_trigger = eLIM_HOST_DEAUTH;
2732 goto send_deauth;
2733 }
2734
2735 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2736 session_entry)) {
2737 lim_log(mac_ctx, LOGE,
2738 FL("received invalid SME_DEAUTH_REQ message"));
2739 mac_ctx->lim.gLimRspReqd = false;
2740
2741 ret_code = eSIR_SME_INVALID_PARAMETERS;
2742 deauth_trigger = eLIM_HOST_DEAUTH;
2743 goto send_deauth;
2744 }
2745 lim_log(mac_ctx, LOG1,
2746 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2747 MAC_ADDRESS_STR), sme_session_id,
2748 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2749 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002750 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2752 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2753 session_entry, 0, sme_deauth_req.reasonCode);
2754#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2755
2756 /* Update SME session ID and Transaction ID */
2757 session_entry->smeSessionId = sme_session_id;
2758 session_entry->transactionId = sme_transaction_id;
2759
2760 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2761 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 switch (session_entry->limSmeState) {
2763 case eLIM_SME_ASSOCIATED_STATE:
2764 case eLIM_SME_LINK_EST_STATE:
2765 case eLIM_SME_WT_ASSOC_STATE:
2766 case eLIM_SME_JOIN_FAILURE_STATE:
2767 case eLIM_SME_IDLE_STATE:
2768 session_entry->limPrevSmeState =
2769 session_entry->limSmeState;
2770 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2771 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2772 session_entry->peSessionId,
2773 session_entry->limSmeState));
2774 /* Send Deauthentication request to MLM below */
2775 break;
2776 case eLIM_SME_WT_DEAUTH_STATE:
2777 case eLIM_SME_WT_DISASSOC_STATE:
2778 /*
2779 * PE Recieved a Deauth/Disassoc frame. Normally it get
2780 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2781 * Which means host is also trying to disconnect.
2782 * PE can continue processing DEAUTH_REQ and send
2783 * the response instead of failing the request.
2784 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2785 * was sent for deauth/disassoc frame.
2786 */
2787 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2788 lim_log(mac_ctx, LOG1, FL(
2789 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2790 break;
2791 default:
2792 /*
2793 * STA is not in a state to deauthenticate with
2794 * peer. Log error and send response to host.
2795 */
2796 lim_log(mac_ctx, LOGE, FL(
2797 "received unexp SME_DEAUTH_REQ in state %X"),
2798 session_entry->limSmeState);
2799 lim_print_sme_state(mac_ctx, LOGE,
2800 session_entry->limSmeState);
2801
2802 if (mac_ctx->lim.gLimRspReqd) {
2803 mac_ctx->lim.gLimRspReqd = false;
2804
2805 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2806 deauth_trigger = eLIM_HOST_DEAUTH;
2807
2808 /*
2809 * here we received deauth request from AP so sme state
2810 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2811 * delSta then mlm state should be
2812 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2813 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2814 * so the below condition captures the state where
2815 * delSta not done and firmware still in
2816 * connected state.
2817 */
2818 if (session_entry->limSmeState ==
2819 eLIM_SME_WT_DEAUTH_STATE &&
2820 session_entry->limMlmState !=
2821 eLIM_MLM_IDLE_STATE &&
2822 session_entry->limMlmState !=
2823 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2824 ret_code = eSIR_SME_DEAUTH_STATUS;
2825 goto send_deauth;
2826 }
2827 return;
2828 }
2829 break;
2830
2831 case eLIM_STA_IN_IBSS_ROLE:
2832 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2833 if (mac_ctx->lim.gLimRspReqd) {
2834 mac_ctx->lim.gLimRspReqd = false;
2835 ret_code = eSIR_SME_INVALID_PARAMETERS;
2836 deauth_trigger = eLIM_HOST_DEAUTH;
2837 goto send_deauth;
2838 }
2839 return;
2840 case eLIM_AP_ROLE:
2841 break;
2842 default:
2843 lim_log(mac_ctx, LOGE,
2844 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2845 GET_LIM_SYSTEM_ROLE(session_entry));
2846 if (mac_ctx->lim.gLimRspReqd) {
2847 mac_ctx->lim.gLimRspReqd = false;
2848 ret_code = eSIR_SME_INVALID_PARAMETERS;
2849 deauth_trigger = eLIM_HOST_DEAUTH;
2850 goto send_deauth;
2851 }
2852 return;
2853 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2854
2855 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2856 /* Deauthentication is triggered by Link Monitoring */
2857 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2858 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2859 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2860 } else {
2861 deauth_trigger = eLIM_HOST_DEAUTH;
2862 reason_code = sme_deauth_req.reasonCode;
2863 }
2864
2865 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302866 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 if (NULL == mlm_deauth_req) {
2868 lim_log(mac_ctx, LOGP,
2869 FL("call to AllocateMemory failed for mlmDeauthReq"));
2870 if (mac_ctx->lim.gLimRspReqd) {
2871 mac_ctx->lim.gLimRspReqd = false;
2872 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2873 deauth_trigger = eLIM_HOST_DEAUTH;
2874 goto send_deauth;
2875 }
2876 return;
2877 }
2878
Anurag Chouhanc5548422016-02-24 18:33:27 +05302879 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002880 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881
2882 mlm_deauth_req->reasonCode = reason_code;
2883 mlm_deauth_req->deauthTrigger = deauth_trigger;
2884
2885 /* Update PE session Id */
2886 mlm_deauth_req->sessionId = session_id;
2887
2888 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2889 (uint32_t *)mlm_deauth_req);
2890 return;
2891
2892send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002893 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2894 ret_code, deauth_trigger, 1,
2895 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896}
2897
2898/**
2899 * __lim_process_sme_set_context_req()
2900 *
2901 * @mac_ctx: Pointer to Global MAC structure
2902 * @msg_buf: pointer to the SME message buffer
2903 *
2904 * This function is called to process SME_SETCONTEXT_REQ message
2905 * from HDD or upper layer application.
2906 *
2907 * Return: None
2908 */
2909
2910static void
2911__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2912{
2913 tpSirSmeSetContextReq set_context_req;
2914 tLimMlmSetKeysReq *mlm_set_key_req;
2915 tpPESession session_entry;
2916 uint8_t session_id; /* PE sessionID */
2917 uint8_t sme_session_id;
2918 uint16_t sme_transaction_id;
2919
2920 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2921
2922 if (msg_buf == NULL) {
2923 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2924 return;
2925 }
2926
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302927 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 if (NULL == set_context_req) {
2929 lim_log(mac_ctx, LOGP, FL(
2930 "call to AllocateMemory failed for set_context_req"));
2931 return;
2932 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302933 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934 sizeof(struct sSirSmeSetContextReq));
2935 sme_session_id = set_context_req->sessionId;
2936 sme_transaction_id = set_context_req->transactionId;
2937
2938 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2939 lim_log(mac_ctx, LOGW,
2940 FL("received invalid SME_SETCONTEXT_REQ message"));
2941 goto end;
2942 }
2943
2944 if (set_context_req->keyMaterial.numKeys >
2945 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2946 lim_log(mac_ctx, LOGE, FL(
2947 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2948 set_context_req->keyMaterial.numKeys);
2949 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002950 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 eSIR_SME_INVALID_PARAMETERS, NULL,
2952 sme_session_id, sme_transaction_id);
2953 goto end;
2954 }
2955
2956 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002957 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 if (session_entry == NULL) {
2959 lim_log(mac_ctx, LOGW,
2960 FL("Session does not exist for given BSSID"));
2961 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002962 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 eSIR_SME_INVALID_PARAMETERS, NULL,
2964 sme_session_id, sme_transaction_id);
2965 goto end;
2966 }
2967#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2968 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2969 session_entry, 0, 0);
2970#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2971
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002972 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2974 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002975 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2977 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302978 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 if (NULL == mlm_set_key_req) {
2980 lim_log(mac_ctx, LOGP, FL(
2981 "mem alloc failed for mlmSetKeysReq"));
2982 goto end;
2983 }
2984 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2985 mlm_set_key_req->numKeys =
2986 set_context_req->keyMaterial.numKeys;
2987 if (mlm_set_key_req->numKeys >
2988 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2989 lim_log(mac_ctx, LOGP, FL(
2990 "no.of keys exceeded max num of default keys limit"));
2991 goto end;
2992 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302993 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002994 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302996 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997 (uint8_t *) &set_context_req->keyMaterial.key,
2998 sizeof(tSirKeys) *
2999 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3000 numKeys : 1));
3001
3002 mlm_set_key_req->sessionId = session_id;
3003 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 lim_log(mac_ctx, LOG1, FL(
3005 "received SETCONTEXT_REQ message sessionId=%d"),
3006 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007
3008 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3009 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3010 LIM_IS_AP_ROLE(session_entry)) {
3011 if (set_context_req->keyMaterial.key[0].keyLength) {
3012 uint8_t key_id;
3013 key_id =
3014 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303015 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 &session_entry->WEPKeyMaterial[key_id],
3017 (uint8_t *) &set_context_req->keyMaterial,
3018 sizeof(tSirKeyMaterial));
3019 } else {
3020 uint32_t i;
3021 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3022 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303023 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 &mlm_set_key_req->key[i],
3025 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3026 sizeof(tSirKeys));
3027 }
3028 }
3029 }
3030 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3031 (uint32_t *) mlm_set_key_req);
3032 } else {
3033 lim_log(mac_ctx, LOGE, FL(
3034 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3035 GET_LIM_SYSTEM_ROLE(session_entry),
3036 session_entry->limSmeState);
3037 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3038
3039 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003040 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3042 session_entry, sme_session_id,
3043 sme_transaction_id);
3044 }
3045end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303046 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 return;
3048}
3049
3050/**
3051 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3052 *
3053 * @mac_ctx: Pointer to Global MAC structure
3054 * @msg_buf: pointer to the SME message buffer
3055 *
3056 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3057 * from HDD or upper layer application.
3058 *
3059 * Return: None
3060 */
3061
Jeff Johnson801f1532016-10-07 07:54:50 -07003062static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3063 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064{
3065 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3066 tpDphHashNode sta_ds = NULL;
3067 tpPESession session_entry = NULL;
3068 tSap_Event sap_event;
3069 tpWLAN_SAPEventCB sap_event_cb = NULL;
3070 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3071 uint8_t session_id = CSR_SESSION_ID_INVALID;
3072 uint8_t assoc_id = 0;
3073 uint8_t sta_cnt = 0;
3074
3075 if (msg_buf == NULL) {
3076 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3077 return;
3078 }
3079
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303080 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 sizeof(struct sSirSmeGetAssocSTAsReq));
3082 /*
3083 * Get Associated stations from PE.
3084 * Find PE session Entry
3085 */
3086 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003087 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 &session_id);
3089 if (session_entry == NULL) {
3090 lim_log(mac_ctx, LOGE,
3091 FL("session does not exist for given bssId"));
3092 goto lim_assoc_sta_end;
3093 }
3094
3095 if (!LIM_IS_AP_ROLE(session_entry)) {
3096 lim_log(mac_ctx, LOGE, FL(
3097 "Received unexpected message in state %X, in role %X"),
3098 session_entry->limSmeState,
3099 GET_LIM_SYSTEM_ROLE(session_entry));
3100 goto lim_assoc_sta_end;
3101 }
3102 /* Retrieve values obtained in the request message */
3103 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3104 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3105
3106 if (NULL == assoc_sta_tmp)
3107 goto lim_assoc_sta_end;
3108 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3109 assoc_id++) {
3110 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3111 &session_entry->dph.dphHashTable);
3112 if (NULL == sta_ds)
3113 continue;
3114 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303115 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303117 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3119 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3120
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303121 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 (uint8_t *)&sta_ds->supportedRates,
3123 sizeof(tSirSupportedRates));
3124 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3125 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3126 assoc_sta_tmp->Support40Mhz =
3127 sta_ds->htDsssCckRate40MHzSupport;
3128
3129 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3130 sta_cnt + 1);
3131 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3132 MAC_ADDR_ARRAY(sta_ds->staAddr));
3133 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3134 sta_ds->assocId);
3135 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3136 sta_ds->staIndex);
3137 assoc_sta_tmp++;
3138 sta_cnt++;
3139 }
3140 }
3141lim_assoc_sta_end:
3142 /*
3143 * Call hdd callback with sap event to send the list of
3144 * associated stations from PE
3145 */
3146 if (sap_event_cb != NULL) {
3147 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3148 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303149 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3151 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3152 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3153 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3154 }
3155}
3156
3157/**
3158 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3159 *
3160 * @mac_ctx: Pointer to Global MAC structure
3161 * @msg_buf: pointer to WPS PBC overlap query message
3162 *
3163 * This function parses get WPS PBC overlap information
3164 * message and call callback to pass WPS PBC overlap
3165 * information back to hdd.
3166 *
3167 * Return: None
3168 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003169static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3170 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171{
3172 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3173 tpPESession session_entry = NULL;
3174 tSap_Event sap_event;
3175 tpWLAN_SAPEventCB sap_event_cb = NULL;
3176 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3178
3179 if (msg_buf == NULL) {
3180 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3181 return;
3182 }
3183
3184 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303185 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303187 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3189 /*
3190 * Get Associated stations from PE
3191 * Find PE session Entry
3192 */
3193 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003194 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 if (session_entry == NULL) {
3196 lim_log(mac_ctx, LOGE,
3197 FL("session does not exist for given bssId"));
3198 goto lim_get_wpspbc_sessions_end;
3199 }
3200
3201 if (!LIM_IS_AP_ROLE(session_entry)) {
3202 lim_log(mac_ctx, LOGE,
3203 FL("Received unexpected message in role %X"),
3204 GET_LIM_SYSTEM_ROLE(session_entry));
3205 goto lim_get_wpspbc_sessions_end;
3206 }
3207 /*
3208 * Call hdd callback with sap event to send the
3209 * WPS PBC overlap information
3210 */
3211 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303212 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213
Anurag Chouhanc5548422016-02-24 18:33:27 +05303214 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003216 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 sap_get_wpspbc_event->UUID_E,
3218 &sap_get_wpspbc_event->wpsPBCOverlap,
3219 session_entry);
3220 } else {
3221 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003222 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 session_entry);
3224 /* don't have to inform the HDD/Host */
3225 return;
3226 }
3227
3228 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3229 sap_get_wpspbc_event->wpsPBCOverlap);
3230 lim_print_mac_addr(mac_ctx,
3231 sap_get_wpspbc_event->addr.bytes, LOG4);
3232
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303233 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234
3235lim_get_wpspbc_sessions_end:
3236 sap_event_cb =
3237 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3238 if (NULL != sap_event_cb)
3239 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3240}
3241
3242/**
3243 * __lim_counter_measures()
3244 *
3245 * FUNCTION:
3246 * This function is called to "implement" MIC counter measure
3247 * and is *temporary* only
3248 *
3249 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3250 * we don't do the proper STA disassoc sequence since the
3251 * BSS will be stoped anyway
3252 *
3253 ***ASSUMPTIONS:
3254 *
3255 ***NOTE:
3256 *
3257 * @param pMac Pointer to Global MAC structure
3258 * @return None
3259 */
3260
3261static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3262{
3263 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003264 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3266 mac, psessionEntry, false);
3267};
3268
Jeff Johnson801f1532016-10-07 07:54:50 -07003269static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3270 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271{
3272 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3273 tpPESession psessionEntry;
3274 uint8_t sessionId; /* PE sessionId */
3275
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303276 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 sizeof(struct sSirSmeTkipCntrMeasReq));
3278
3279 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003280 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 if (NULL == psessionEntry) {
3282 lim_log(pMac, LOGE,
3283 FL("session does not exist for given BSSID "));
3284 return;
3285 }
3286
3287 if (tkipCntrMeasReq.bEnable)
3288 __lim_counter_measures(pMac, psessionEntry);
3289
3290 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3291}
3292
3293static void
3294__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3295{
3296 tSirSmeStopBssReq stopBssReq;
3297 tSirRetStatus status;
3298 tLimSmeStates prevState;
3299 tpPESession psessionEntry;
3300 uint8_t smesessionId;
3301 uint8_t sessionId;
3302 uint16_t smetransactionId;
3303 uint8_t i = 0;
3304 tpDphHashNode pStaDs = NULL;
3305
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303306 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 smesessionId = stopBssReq.sessionId;
3308 smetransactionId = stopBssReq.transactionId;
3309
3310 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3311 PELOGW(lim_log(pMac, LOGW,
3312 FL("received invalid SME_STOP_BSS_REQ message"));)
3313 /* Send Stop BSS response to host */
3314 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3315 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3316 smetransactionId);
3317 return;
3318 }
3319
3320 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003321 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 &sessionId);
3323 if (psessionEntry == NULL) {
3324 lim_log(pMac, LOGW,
3325 FL("session does not exist for given BSSID "));
3326 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3327 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3328 smetransactionId);
3329 return;
3330 }
3331#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3332 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3333 0, 0);
3334#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3335
3336 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3337 LIM_IS_STA_ROLE(psessionEntry)) {
3338 /**
3339 * Should not have received STOP_BSS_REQ in states
3340 * other than 'normal' state or on STA in Infrastructure
3341 * mode. Log error and return response to host.
3342 */
3343 lim_log(pMac, LOGE,
3344 FL
3345 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3346 psessionEntry->limSmeState,
3347 GET_LIM_SYSTEM_ROLE(psessionEntry));
3348 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3349 /* / Send Stop BSS response to host */
3350 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3351 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3352 smetransactionId);
3353 return;
3354 }
3355
3356 if (LIM_IS_AP_ROLE(psessionEntry))
3357 lim_wpspbc_close(pMac, psessionEntry);
3358
3359 lim_log(pMac, LOGW,
3360 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3361 stopBssReq.reasonCode);
3362
3363 prevState = psessionEntry->limSmeState;
3364
3365 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3366 MTRACE(mac_trace
3367 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3368 psessionEntry->limSmeState));
3369
3370 /* Update SME session Id and Transaction Id */
3371 psessionEntry->smeSessionId = smesessionId;
3372 psessionEntry->transactionId = smetransactionId;
3373
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003374 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3375 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3376 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3378 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3379 /* Send disassoc all stations associated thru TKIP */
3380 __lim_counter_measures(pMac, psessionEntry);
3381 else
3382 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003383 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3384 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 }
3386
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003387 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3388 /* Free the buffer allocated in START_BSS_REQ */
3389 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3390 psessionEntry->addIeParams.probeRespDataLen = 0;
3391 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003393 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3394 psessionEntry->addIeParams.assocRespDataLen = 0;
3395 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003397 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3398 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3399 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003401 /*
3402 * lim_del_bss is also called as part of coalescing,
3403 * when we send DEL BSS followed by Add Bss msg.
3404 */
3405 pMac->lim.gLimIbssCoalescingHappened = false;
3406 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3408 pStaDs =
3409 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3410 if (NULL == pStaDs)
3411 continue;
3412 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3413 if (eSIR_SUCCESS == status) {
3414 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3415 pStaDs->assocId, psessionEntry);
3416 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3417 } else {
3418 lim_log(pMac, LOGE,
3419 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303420 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 }
3422 }
3423 /* send a delBss to HAL and wait for a response */
3424 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3425
3426 if (status != eSIR_SUCCESS) {
3427 PELOGE(lim_log
3428 (pMac, LOGE, FL("delBss failed for bss %d"),
3429 psessionEntry->bssIdx);
3430 )
3431 psessionEntry->limSmeState = prevState;
3432
3433 MTRACE(mac_trace
3434 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3435 psessionEntry->limSmeState));
3436
3437 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3438 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3439 smetransactionId);
3440 }
3441}
3442
3443/**
3444 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3445 * @pMac: Global MAC context
3446 * @pMsg: Message from SME
3447 *
3448 * Wrapper for the function __lim_handle_sme_stop_bss_request
3449 * This message will be defered until softmac come out of
3450 * scan mode. Message should be handled even if we have
3451 * detected radar in the current operating channel.
3452 *
3453 * Return: true - If we consumed the buffer
3454 * false - If have defered the message.
3455 */
3456
3457static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3458{
3459 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3460 /**
3461 * If message defered, buffer is not consumed yet.
3462 * So return false
3463 */
3464 return false;
3465 }
3466 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3467 return true;
3468} /*** end __lim_process_sme_stop_bss_req() ***/
3469
3470void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3471 uint32_t body, tpPESession psessionEntry)
3472{
3473
3474 (void)body;
3475 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3476 lim_ibss_delete(pMac, psessionEntry);
3477 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3478 lim_delete_pre_auth_list(pMac);
3479 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3480 psessionEntry->smeSessionId,
3481 psessionEntry->transactionId);
3482 return;
3483}
3484
3485/**
3486 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3487 *
3488 * @mac_ctx: pointer to mac context
3489 * @msg_type: message type
3490 * @msg_buf: pointer to the SME message buffer
3491 *
3492 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3493 * in BTAMP AP.
3494 *
3495 * Return: None
3496 */
3497
3498void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3499 uint32_t *msg_buf)
3500{
3501 tSirSmeAssocCnf assoc_cnf;
3502 tpDphHashNode sta_ds = NULL;
3503 tpPESession session_entry = NULL;
3504 uint8_t session_id;
3505 tpSirAssocReq assoc_req;
3506
3507 if (msg_buf == NULL) {
3508 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3509 goto end;
3510 }
3511
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303512 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3514 lim_log(mac_ctx, LOGE,
3515 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3516 goto end;
3517 }
3518
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003519 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 &session_id);
3521 if (session_entry == NULL) {
3522 lim_log(mac_ctx, LOGE,
3523 FL("session does not exist for given bssId"));
3524 goto end;
3525 }
3526
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003527 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3529 (session_entry->limSmeState !=
3530 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3531 lim_log(mac_ctx, LOGE, FL(
3532 "Rcvd unexpected msg %X in state %X, in role %X"),
3533 msg_type, session_entry->limSmeState,
3534 GET_LIM_SYSTEM_ROLE(session_entry));
3535 goto end;
3536 }
3537 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3538 &session_entry->dph.dphHashTable);
3539 if (sta_ds == NULL) {
3540 lim_log(mac_ctx, LOGE, FL(
3541 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3542 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003543 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544
3545 /*
3546 * send a DISASSOC_IND message to WSM to make sure
3547 * the state in WSM and LIM is the same
3548 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003549 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 eSIR_SME_STA_NOT_ASSOCIATED,
3551 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3552 session_entry->smeSessionId,
3553 session_entry->transactionId,
3554 session_entry);
3555 goto end;
3556 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303557 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003558 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303559 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 lim_log(mac_ctx, LOG1, FL(
3561 "peerMacAddr mismatched for aid %d, peer "),
3562 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003563 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 goto end;
3565 }
3566
3567 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3568 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3569 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3570 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3571 (msg_type != eWNI_SME_ASSOC_CNF))) {
3572 lim_log(mac_ctx, LOG1, FL(
3573 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3574 "StaD mlmState : %d"),
3575 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003576 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577 goto end;
3578 }
3579 /*
3580 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3581 * has been received
3582 */
3583 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3584 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3585 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3586
3587 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3588 /*
3589 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3590 * when it had received Assoc Request frame. Now, PE just needs
3591 * to send association rsp frame to the requesting BTAMP-STA.
3592 */
3593 sta_ds->mlmStaContext.mlmState =
3594 eLIM_MLM_LINK_ESTABLISHED_STATE;
3595 lim_log(mac_ctx, LOG1,
3596 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3597 sta_ds->assocId);
3598 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3599 sta_ds->assocId, sta_ds->staAddr,
3600 sta_ds->mlmStaContext.subType, sta_ds,
3601 session_entry);
3602 goto end;
3603 } else {
3604 /*
3605 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3606 * to be associated since the HAL sta entry is created for
3607 * denied STA we need to remove this HAL entry.
3608 * So to do that set updateContext to 1
3609 */
3610 if (!sta_ds->mlmStaContext.updateContext)
3611 sta_ds->mlmStaContext.updateContext = 1;
3612 lim_log(mac_ctx, LOG1,
3613 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3614 assoc_cnf.statusCode, sta_ds->assocId);
3615 lim_reject_association(mac_ctx, sta_ds->staAddr,
3616 sta_ds->mlmStaContext.subType,
3617 true, sta_ds->mlmStaContext.authType,
3618 sta_ds->assocId, true,
3619 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3620 session_entry);
3621 }
3622end:
3623 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3624 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3625 assoc_req = (tpSirAssocReq)
3626 session_entry->parsedAssocReq[sta_ds->assocId];
3627 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303628 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 assoc_req->assocReqFrame = NULL;
3630 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303631 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3633 }
3634}
3635
3636static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3637{
3638 tpDphHashNode pStaDs;
3639 tSirMacAddr peerMac;
3640 tpSirAddtsReq pSirAddts;
3641 uint32_t timeout;
3642 tpPESession psessionEntry;
3643 uint8_t sessionId; /* PE sessionId */
3644 uint8_t smesessionId;
3645 uint16_t smetransactionId;
3646
3647 if (pMsgBuf == NULL) {
3648 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3649 return;
3650 }
3651
3652 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3653 &smetransactionId);
3654
3655 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3656
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003657 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3658 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659 if (psessionEntry == NULL) {
3660 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3661 return;
3662 }
3663#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3664 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3665 0);
3666#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3667
3668 /* if sta
3669 * - verify assoc state
3670 * - send addts request to ap
3671 * - wait for addts response from ap
3672 * if ap, just ignore with error log
3673 */
3674 PELOG1(lim_log(pMac, LOG1,
3675 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3676 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3677 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3678 )
3679
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003680 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3682 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3683 psessionEntry, pSirAddts->req.tspec,
3684 smesessionId, smetransactionId);
3685 return;
3686 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687
3688 pStaDs =
3689 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3690 &psessionEntry->dph.dphHashTable);
3691
3692 if (pStaDs == NULL) {
3693 PELOGE(lim_log
3694 (pMac, LOGE, "Cannot find AP context for addts req");
3695 )
3696 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3697 psessionEntry, pSirAddts->req.tspec,
3698 smesessionId, smetransactionId);
3699 return;
3700 }
3701
3702 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3703 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3704 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3705 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3706 psessionEntry, pSirAddts->req.tspec,
3707 smesessionId, smetransactionId);
3708 return;
3709 }
3710
3711 pSirAddts->req.wsmTspecPresent = 0;
3712 pSirAddts->req.wmeTspecPresent = 0;
3713 pSirAddts->req.lleTspecPresent = 0;
3714
3715 if ((pStaDs->wsmEnabled) &&
3716 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3717 SIR_MAC_ACCESSPOLICY_EDCA))
3718 pSirAddts->req.wsmTspecPresent = 1;
3719 else if (pStaDs->wmeEnabled)
3720 pSirAddts->req.wmeTspecPresent = 1;
3721 else if (pStaDs->lleEnabled)
3722 pSirAddts->req.lleTspecPresent = 1;
3723 else {
3724 PELOGW(lim_log
3725 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3726 )
3727 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3728 psessionEntry, pSirAddts->req.tspec,
3729 smesessionId, smetransactionId);
3730 return;
3731 }
3732
3733 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3734 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3735 lim_log(pMac, LOGE,
3736 "AddTs received in invalid LIMsme state (%d)",
3737 psessionEntry->limSmeState);
3738 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3739 psessionEntry, pSirAddts->req.tspec,
3740 smesessionId, smetransactionId);
3741 return;
3742 }
3743
3744 if (pMac->lim.gLimAddtsSent) {
3745 lim_log(pMac, LOGE,
3746 "Addts (token %d, tsid %d, up %d) is still pending",
3747 pMac->lim.gLimAddtsReq.req.dialogToken,
3748 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3749 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3750 userPrio);
3751 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3752 psessionEntry, pSirAddts->req.tspec,
3753 smesessionId, smetransactionId);
3754 return;
3755 }
3756
3757 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3758
3759 /* save the addts request */
3760 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303761 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3763
3764 /* ship out the message now */
3765 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3766 psessionEntry);
3767 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3768 /* start a timer to wait for the response */
3769 if (pSirAddts->timeout)
3770 timeout = pSirAddts->timeout;
3771 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3772 eSIR_SUCCESS) {
3773 lim_log(pMac, LOGP,
3774 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3775 WNI_CFG_ADDTS_RSP_TIMEOUT);
3776 return;
3777 }
3778
3779 timeout = SYS_MS_TO_TICKS(timeout);
3780 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3781 != TX_SUCCESS) {
3782 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3783 return;
3784 }
3785 pMac->lim.gLimAddtsRspTimerCount++;
3786 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3787 pMac->lim.gLimAddtsRspTimerCount) !=
3788 TX_SUCCESS) {
3789 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3790 return;
3791 }
3792 MTRACE(mac_trace
3793 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3794 eLIM_ADDTS_RSP_TIMER));
3795
3796 /* add the sessionId to the timer object */
3797 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3798 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3799 TX_SUCCESS) {
3800 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3801 return;
3802 }
3803 return;
3804}
3805
3806static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3807{
3808 tSirMacAddr peerMacAddr;
3809 uint8_t ac;
3810 tSirMacTSInfo *pTsinfo;
3811 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3812 tpDphHashNode pStaDs = NULL;
3813 tpPESession psessionEntry;
3814 uint8_t sessionId;
3815 uint32_t status = eSIR_SUCCESS;
3816 uint8_t smesessionId;
3817 uint16_t smetransactionId;
3818
3819 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3820 &smetransactionId);
3821
3822 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003823 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 &sessionId);
3825 if (psessionEntry == NULL) {
3826 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3827 status = eSIR_FAILURE;
3828 goto end;
3829 }
3830#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3831 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3832 0);
3833#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3834
3835 if (eSIR_SUCCESS !=
3836 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3837 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3838 status = eSIR_FAILURE;
3839 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3840 smesessionId, smetransactionId);
3841 return;
3842 }
3843
3844 lim_log(pMac, LOG1,
3845 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3846 MAC_ADDRESS_STR),
3847 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3848
3849 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3850 pDeltsReq->req.wmeTspecPresent,
3851 &pDeltsReq->req.tsinfo,
3852 &pDeltsReq->req.tspec, psessionEntry);
3853
3854 pTsinfo =
3855 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3856 tsinfo : &pDeltsReq->req.tsinfo;
3857
3858 /* We've successfully send DELTS frame to AP. Update the
3859 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3860 * is no longer trigger enabled or delivery enabled
3861 */
3862 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3863 pTsinfo, CLEAR_UAPSD_MASK);
3864
3865 /* We're deleting the TSPEC, so this particular AC is no longer
3866 * admitted. PE needs to downgrade the EDCA
3867 * parameters(for the AC for which TS is being deleted) to the
3868 * next best AC for which ACM is not enabled, and send the
3869 * updated values to HAL.
3870 */
3871 ac = upToAc(pTsinfo->traffic.userPrio);
3872
3873 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3874 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3875 ~(1 << ac);
3876 } else if (pTsinfo->traffic.direction ==
3877 SIR_MAC_DIRECTION_DNLINK) {
3878 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3879 ~(1 << ac);
3880 } else if (pTsinfo->traffic.direction ==
3881 SIR_MAC_DIRECTION_BIDIR) {
3882 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3883 ~(1 << ac);
3884 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3885 ~(1 << ac);
3886 }
3887
3888 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3889 psessionEntry);
3890
3891 pStaDs =
3892 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3893 &psessionEntry->dph.dphHashTable);
3894 if (pStaDs != NULL) {
3895 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3896 pStaDs->bssId);
3897 status = eSIR_SUCCESS;
3898 } else {
3899 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3900 status = eSIR_FAILURE;
3901 }
3902#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904#endif
3905
3906 /* send an sme response back */
3907end:
3908 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3909 smesessionId, smetransactionId);
3910}
3911
Jeff Johnson801f1532016-10-07 07:54:50 -07003912static void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac,
3913 uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914{
3915 /* fetch the sessionEntry based on the sessionId */
3916 tpPESession psessionEntry;
3917 psessionEntry = pe_find_session_by_session_id(pMac,
3918 pMac->lim.limTimers.gLimAddtsRspTimer.
3919 sessionId);
3920 if (psessionEntry == NULL) {
3921 lim_log(pMac, LOGP,
3922 FL("Session Does not exist for given sessionID"));
3923 return;
3924 }
3925
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003926 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3928 GET_LIM_SYSTEM_ROLE(psessionEntry));
3929 pMac->lim.gLimAddtsSent = false;
3930 return;
3931 }
3932
3933 if (!pMac->lim.gLimAddtsSent) {
3934 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3935 return;
3936 }
3937
3938 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3939 lim_log(pMac, LOGE,
3940 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3941 pMac->lim.gLimAddtsRspTimerCount);
3942 return;
3943 }
3944 /* this a real response timeout */
3945 pMac->lim.gLimAddtsSent = false;
3946 pMac->lim.gLimAddtsRspTimerCount++;
3947
3948 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3949 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3950 psessionEntry->smeSessionId,
3951 psessionEntry->transactionId);
3952}
3953
3954/**
3955 * __lim_process_sme_get_statistics_request()
3956 *
3957 ***FUNCTION:
3958 *
3959 *
3960 ***NOTE:
3961 *
3962 * @param pMac Pointer to Global MAC structure
3963 * @param *pMsgBuf A pointer to the SME message buffer
3964 * @return None
3965 */
3966static void
3967__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3968{
3969 tpAniGetPEStatsReq pPEStatsReq;
3970 tSirMsgQ msgQ;
3971
3972 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3973
3974 msgQ.type = WMA_GET_STATISTICS_REQ;
3975
3976 msgQ.reserved = 0;
3977 msgQ.bodyptr = pMsgBuf;
3978 msgQ.bodyval = 0;
3979 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3980
3981 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303982 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 pMsgBuf = NULL;
3984 lim_log(pMac, LOGP, "Unable to forward request");
3985 return;
3986 }
3987
3988 return;
3989}
3990
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003991#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003993 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003995 * @pMac: Pointer to Global MAC structure
3996 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003998 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 */
4000static void
4001__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4002{
4003 tSirMsgQ msgQ;
4004
4005 msgQ.type = WMA_TSM_STATS_REQ;
4006 msgQ.reserved = 0;
4007 msgQ.bodyptr = pMsgBuf;
4008 msgQ.bodyval = 0;
4009 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4010
4011 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304012 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013 pMsgBuf = NULL;
4014 lim_log(pMac, LOGP, "Unable to forward request");
4015 return;
4016 }
4017}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004018#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019
4020static void
4021__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4022{
4023 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4024 tpPESession psessionEntry;
4025 uint8_t sessionId; /* PE sessionID */
4026
4027 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4028
4029 if (pMsgBuf == NULL) {
4030 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4031 return;
4032 }
4033
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304034 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035 if (NULL == pUpdateAPWPSIEsReq) {
4036 lim_log(pMac, LOGP,
4037 FL
4038 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4039 return;
4040 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304041 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 sizeof(struct sSirUpdateAPWPSIEsReq));
4043
4044 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004045 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046 &sessionId);
4047 if (psessionEntry == NULL) {
4048 lim_log(pMac, LOGW,
4049 FL("Session does not exist for given BSSID"));
4050 goto end;
4051 }
4052
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304053 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054 sizeof(tSirAPWPSIEs));
4055
4056 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4057 lim_send_beacon_ind(pMac, psessionEntry);
4058
4059end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304060 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 return;
4062}
4063
4064void
4065lim_send_vdev_restart(tpAniSirGlobal pMac,
4066 tpPESession psessionEntry, uint8_t sessionId)
4067{
4068 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4069 tSirMsgQ msgQ;
4070 tSirRetStatus retCode = eSIR_SUCCESS;
4071
4072 if (psessionEntry == NULL) {
4073 PELOGE(lim_log
4074 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4075 __LINE__);
4076 )
4077 return;
4078 }
4079
4080 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304081 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 if (NULL == pHalHiddenSsidVdevRestart) {
4083 PELOGE(lim_log
4084 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4085 __func__, __LINE__);
4086 )
4087 return;
4088 }
4089
4090 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4091 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4092
4093 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4094 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4095 msgQ.bodyval = 0;
4096
4097 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4098 if (eSIR_SUCCESS != retCode) {
4099 PELOGE(lim_log
4100 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4101 __LINE__);
4102 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304103 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 }
4105}
4106
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304107/**
4108 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4109 * @mac_ctx: Pointer to Global MAC structure
4110 * @msg_buf: Pointer to SME message buffer
4111 *
4112 * Return: None
4113 */
4114static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4115 uint32_t *msg_buf)
4116{
4117 tpPESession pe_session;
4118 tSirMsgQ wma_msg;
4119 tSirRetStatus status;
4120 tSirRoamOffloadScanReq *req_buffer;
4121 uint16_t local_ie_len;
4122 uint8_t *local_ie_buf;
4123
4124 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4125 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4126 req_buffer->sessionId);
4127
4128 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4129 if (!local_ie_buf) {
Arif Hussain963331b2016-10-27 22:59:01 -07004130 lim_log(mac_ctx, LOGE,
4131 FL("Mem Alloc failed for local_ie_buf"));
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304132 return;
4133 }
4134
4135 local_ie_len = req_buffer->assoc_ie.length;
4136 /* Update ext cap IE if present */
4137 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004138 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4139 local_ie_buf, &local_ie_len)) {
4140 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004141 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4142 req_buffer->assoc_ie.length = local_ie_len;
4143 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4144 local_ie_buf, local_ie_len);
4145 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304146 }
4147 qdf_mem_free(local_ie_buf);
4148
4149 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4150 wma_msg.bodyptr = req_buffer;
4151
4152 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4153 if (eSIR_SUCCESS != status) {
4154 lim_log(mac_ctx, LOGE,
4155 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4156 qdf_mem_free(req_buffer);
4157 }
4158}
4159
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304160/*
4161 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4162 * @mac_ctx: Pointer to global mac context
4163 * @session: Pointer to PE session
4164 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4165 * 1 - Disable broadcast SSID
4166 *
4167 * Return: None
4168 */
4169static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4170 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304172 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4173 if (ssid_hidden != session->ssidHidden)
4174 session->ssidHidden = ssid_hidden;
4175 else {
4176 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304177 return;
4178 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179
4180 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304181 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182
4183 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304184 sch_set_fixed_beacon_fields(mac_ctx, session);
4185 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186
4187 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304188}
4189
4190/**
4191 * __lim_process_sme_session_update - process SME session update msg
4192 *
4193 * @mac_ctx: Pointer to global mac context
4194 * @msg_buf: Pointer to the received message buffer
4195 *
4196 * Return: None
4197 */
4198static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4199 uint32_t *msg_buf)
4200{
4201 struct sir_update_session_param *msg;
4202 tpPESession session;
4203
4204 if (!msg_buf) {
4205 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4206 return;
4207 }
4208
4209 msg = (struct sir_update_session_param *) msg_buf;
4210
4211 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4212 if (!session) {
4213 lim_log(mac_ctx, LOGW,
4214 "Session does not exist for given sessionId %d",
4215 msg->session_id);
4216 return;
4217 }
4218
4219 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4220 msg->param_type, msg->param_val);
4221 switch (msg->param_type) {
4222 case SIR_PARAM_SSID_HIDDEN:
4223 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4224 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304225 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4226 session->ignore_assoc_disallowed = msg->param_val;
4227 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304228 default:
4229 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4230 break;
4231 }
4232}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233
4234static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4235{
4236 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4237 tpPESession psessionEntry;
4238 uint8_t sessionId; /* PE sessionID */
4239
4240 if (pMsgBuf == NULL) {
4241 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4242 return;
4243 }
4244
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304245 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004246 if (NULL == pUpdateAPWPARSNIEsReq) {
4247 lim_log(pMac, LOGP,
4248 FL
4249 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4250 return;
4251 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304252 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4254
4255 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004256 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 &sessionId);
4258 if (psessionEntry == NULL) {
4259 lim_log(pMac, LOGW,
4260 FL("Session does not exist for given BSSID"));
4261 goto end;
4262 }
4263
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304264 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4266
4267 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4268 &psessionEntry->
4269 pLimStartBssReq->rsnIE,
4270 psessionEntry);
4271
4272 psessionEntry->pLimStartBssReq->privacy = 1;
4273 psessionEntry->privacy = 1;
4274
4275 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4276 lim_send_beacon_ind(pMac, psessionEntry);
4277
4278end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304279 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 return;
4281} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4282
4283/*
4284 Update the beacon Interval dynamically if beaconInterval is different in MCC
4285 */
4286static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4287{
4288 tpSirChangeBIParams pChangeBIParams;
4289 tpPESession psessionEntry;
4290 uint8_t sessionId = 0;
4291 tUpdateBeaconParams beaconParams;
4292
4293 PELOG1(lim_log(pMac, LOG1,
4294 FL("received Update Beacon Interval message"));
4295 );
4296
4297 if (pMsgBuf == NULL) {
4298 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4299 return;
4300 }
4301
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304302 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004303 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4304
4305 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004306 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 &sessionId);
4308 if (psessionEntry == NULL) {
4309 lim_log(pMac, LOGE,
4310 FL("Session does not exist for given BSSID"));
4311 return;
4312 }
4313
4314 /*Update sessionEntry Beacon Interval */
4315 if (psessionEntry->beaconParams.beaconInterval !=
4316 pChangeBIParams->beaconInterval) {
4317 psessionEntry->beaconParams.beaconInterval =
4318 pChangeBIParams->beaconInterval;
4319 }
4320
4321 /*Update sch beaconInterval */
4322 if (pMac->sch.schObject.gSchBeaconInterval !=
4323 pChangeBIParams->beaconInterval) {
4324 pMac->sch.schObject.gSchBeaconInterval =
4325 pChangeBIParams->beaconInterval;
4326
4327 PELOG1(lim_log(pMac, LOG1,
4328 FL
4329 ("LIM send update BeaconInterval Indication : %d"),
4330 pChangeBIParams->beaconInterval);
4331 );
4332
4333 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4334 /* Update beacon */
4335 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4336
4337 beaconParams.bssIdx = psessionEntry->bssIdx;
4338 /* Set change in beacon Interval */
4339 beaconParams.beaconInterval =
4340 pChangeBIParams->beaconInterval;
4341 beaconParams.paramChangeBitmap =
4342 PARAM_BCN_INTERVAL_CHANGED;
4343 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4344 }
4345 }
4346
4347 return;
4348} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4349
4350#ifdef QCA_HT_2040_COEX
4351static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4352 uint32_t *pMsgBuf)
4353{
4354 tpSirSetHT2040Mode pSetHT2040Mode;
4355 tpPESession psessionEntry;
4356 uint8_t sessionId = 0;
4357 cds_msg_t msg;
4358 tUpdateVHTOpMode *pHtOpMode = NULL;
4359 uint16_t staId = 0;
4360 tpDphHashNode pStaDs = NULL;
4361
4362 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4363 if (pMsgBuf == NULL) {
4364 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4365 return;
4366 }
4367
4368 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4369
4370 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004371 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004372 &sessionId);
4373 if (psessionEntry == NULL) {
4374 lim_log(pMac, LOG1,
4375 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004376 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377 return;
4378 }
4379
4380 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4381 pSetHT2040Mode->cbMode);
4382 /*Update sessionEntry HT related fields */
4383 switch (pSetHT2040Mode->cbMode) {
4384 case PHY_SINGLE_CHANNEL_CENTERED:
4385 psessionEntry->htSecondaryChannelOffset =
4386 PHY_SINGLE_CHANNEL_CENTERED;
4387 psessionEntry->htRecommendedTxWidthSet = 0;
4388 if (pSetHT2040Mode->obssEnabled)
4389 psessionEntry->htSupportedChannelWidthSet
4390 = eHT_CHANNEL_WIDTH_40MHZ;
4391 else
4392 psessionEntry->htSupportedChannelWidthSet
4393 = eHT_CHANNEL_WIDTH_20MHZ;
4394 break;
4395 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4396 psessionEntry->htSecondaryChannelOffset =
4397 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4398 psessionEntry->htRecommendedTxWidthSet = 1;
4399 break;
4400 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4401 psessionEntry->htSecondaryChannelOffset =
4402 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4403 psessionEntry->htRecommendedTxWidthSet = 1;
4404 break;
4405 default:
4406 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4407 return;
4408 }
4409
4410 /* Update beacon */
4411 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4412 lim_send_beacon_ind(pMac, psessionEntry);
4413
4414 /* update OP Mode for each associated peer */
4415 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4416 pStaDs = dph_get_hash_entry(pMac, staId,
4417 &psessionEntry->dph.dphHashTable);
4418 if (NULL == pStaDs)
4419 continue;
4420
4421 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304422 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 if (NULL == pHtOpMode) {
4424 lim_log(pMac, LOGE,
4425 FL
4426 ("%s: Not able to allocate memory for setting OP mode"),
4427 __func__);
4428 return;
4429 }
4430 pHtOpMode->opMode =
4431 (psessionEntry->htSecondaryChannelOffset ==
4432 PHY_SINGLE_CHANNEL_CENTERED) ?
4433 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4434 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304435 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 sizeof(tSirMacAddr));
4437 pHtOpMode->smesessionId = sessionId;
4438
4439 msg.type = WMA_UPDATE_OP_MODE;
4440 msg.reserved = 0;
4441 msg.bodyptr = pHtOpMode;
Krunal Soni66c113f2016-12-21 16:46:47 -08004442 if (!QDF_IS_STATUS_SUCCESS(
4443 cds_mq_post_message(QDF_MODULE_ID_WMA,
4444 &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 lim_log(pMac, LOGE,
4446 FL
4447 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4448 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304449 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450 return;
4451 }
4452 lim_log(pMac, LOG1,
4453 FL
4454 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4455 __func__, pHtOpMode->opMode, staId);
4456
4457 } else
4458 lim_log(pMac, LOG1,
4459 FL("%s: station %d does not support HT40\n"),
4460 __func__, staId);
4461 }
4462
4463 return;
4464}
4465#endif
4466
4467/* -------------------------------------------------------------------- */
4468/**
4469 * __lim_process_report_message
4470 *
4471 * FUNCTION: Processes the next received Radio Resource Management message
4472 *
4473 * LOGIC:
4474 *
4475 * ASSUMPTIONS:
4476 *
4477 * NOTE:
4478 *
4479 * @param None
4480 * @return None
4481 */
4482
Jeff Johnson801f1532016-10-07 07:54:50 -07004483static void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004484{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 switch (pMsg->type) {
4486 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4487 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4488 break;
4489 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004491 break;
4492 default:
4493 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495}
4496
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497/* -------------------------------------------------------------------- */
4498/**
4499 * lim_send_set_max_tx_power_req
4500 *
4501 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4502 *
4503 * LOGIC:
4504 *
4505 * ASSUMPTIONS:
4506 *
4507 * NOTE:
4508 *
4509 * @param txPower txPower to be set.
4510 * @param pSessionEntry session entry.
4511 * @return None
4512 */
4513tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004514lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 tpPESession pSessionEntry)
4516{
4517 tpMaxTxPowerParams pMaxTxParams = NULL;
4518 tSirRetStatus retCode = eSIR_SUCCESS;
4519 tSirMsgQ msgQ;
4520
4521 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304522 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 return eSIR_FAILURE;
4524 }
4525
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304526 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 if (NULL == pMaxTxParams) {
4528 lim_log(pMac, LOGP,
4529 FL("Unable to allocate memory for pMaxTxParams "));
4530 return eSIR_MEM_ALLOC_FAILED;
4531
4532 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304534 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304535 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304536 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004537 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304538 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539
4540 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4541 msgQ.bodyptr = pMaxTxParams;
4542 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304543 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004544 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4545 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4546 if (eSIR_SUCCESS != retCode) {
4547 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304548 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 }
4550 return retCode;
4551}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004552
4553/**
4554 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4555 *
4556 * @mac_ctx: Pointer to Global MAC structure
4557 * @msg_buf: pointer to the SME message buffer
4558 *
4559 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4560 * from SME. It Register this information within PE.
4561 *
4562 * Return: None
4563 */
4564static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4565 uint32_t *msg_buf)
4566{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304567 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4569 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4570 struct mgmt_frm_reg_info *next = NULL;
4571 bool match = false;
4572
4573 lim_log(mac_ctx, LOG1, FL(
4574 "registerFrame %d, frameType %d, matchLen %d"),
4575 sme_req->registerFrame, sme_req->frameType,
4576 sme_req->matchLen);
4577 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304578 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304579 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4580 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304581 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582
4583 while (lim_mgmt_regn != NULL) {
4584 if (lim_mgmt_regn->frameType != sme_req->frameType)
4585 goto skip_match;
4586 if (sme_req->matchLen) {
4587 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304588 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 sme_req->matchData,
4590 lim_mgmt_regn->matchLen))) {
4591 /* found match! */
4592 match = true;
4593 break;
4594 }
4595 } else {
4596 /* found match! */
4597 match = true;
4598 break;
4599 }
4600skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304601 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304602 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304604 (qdf_list_node_t *)lim_mgmt_regn,
4605 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304606 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 lim_mgmt_regn = next;
4608 next = NULL;
4609 }
4610 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304611 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004612 if (QDF_STATUS_SUCCESS ==
4613 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004615 (qdf_list_node_t *)lim_mgmt_regn))
4616 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304617 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 }
4619
4620 if (sme_req->registerFrame) {
4621 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304622 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623 sme_req->matchLen);
4624 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 lim_mgmt_regn->frameType = sme_req->frameType;
4626 lim_mgmt_regn->matchLen = sme_req->matchLen;
4627 lim_mgmt_regn->sessionId = sme_req->sessionId;
4628 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304629 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 sme_req->matchData,
4631 sme_req->matchLen);
4632 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304633 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304635 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 gLimMgmtFrameRegistratinQueue,
4637 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304638 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 &mac_ctx->lim.lim_frame_register_lock);
4640 }
4641 }
4642 return;
4643}
4644
4645static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4646{
4647 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4648 pMac->lim.gDeferMsgTypeForNOA);
4649 pMac->lim.gDeferMsgTypeForNOA = 0;
4650 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4651 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304652 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4654 }
4655}
4656
4657/**
4658 * lim_process_regd_defd_sme_req_after_noa_start()
4659 *
4660 * mac_ctx: Pointer to Global MAC structure
4661 *
4662 * This function is called to process deferred sme req message
4663 * after noa start.
4664 *
4665 * Return: None
4666 */
4667void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4668{
4669 bool buf_consumed = true;
4670
4671 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4672 mac_ctx->lim.gDeferMsgTypeForNOA);
4673
4674 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4675 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4676 lim_log(mac_ctx, LOGW,
4677 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4678 lim_log(mac_ctx, LOGW,
4679 FL("It may happen when NOA start ind and timeout happen at the same time"));
4680 return;
4681 }
4682 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4683 case eWNI_SME_SCAN_REQ:
4684 __lim_process_sme_scan_req(mac_ctx,
4685 mac_ctx->lim.gpDefdSmeMsgForNOA);
4686 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4688 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4689 mac_ctx->lim.gpDefdSmeMsgForNOA);
4690 /*
4691 * lim_process_remain_on_chnl_req doesnt want us to free
4692 * the buffer since it is freed in lim_remain_on_chn_rsp.
4693 * this change is to avoid "double free"
4694 */
4695 if (false == buf_consumed)
4696 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4697 break;
4698 case eWNI_SME_JOIN_REQ:
4699 __lim_process_sme_join_req(mac_ctx,
4700 mac_ctx->lim.gpDefdSmeMsgForNOA);
4701 break;
4702 default:
4703 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4704 mac_ctx->lim.gDeferMsgTypeForNOA);
4705 break;
4706 }
4707 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4708}
4709
4710static void
4711__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4712{
4713 tpSirResetAPCapsChange pResetCapsChange;
4714 tpPESession psessionEntry;
4715 uint8_t sessionId = 0;
4716 if (pMsgBuf == NULL) {
4717 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4718 return;
4719 }
4720
4721 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4722 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004723 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4724 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725 if (psessionEntry == NULL) {
4726 lim_log(pMac, LOGE,
4727 FL("Session does not exist for given BSSID"));
4728 return;
4729 }
4730
4731 psessionEntry->limSentCapsChangeNtf = false;
4732 return;
4733}
4734
4735/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304736 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4737 * @mac_ctx: Mac pointer
4738 * @msg_buf: Msg pointer containing the callback
4739 *
4740 * This function is used to save the p2p ack indication callback in PE.
4741 *
4742 * Return: None
4743 */
4744static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4745 uint32_t *msg_buf)
4746{
4747 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4748 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4749
4750 if (NULL == msg_buf) {
4751 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4752 return;
4753 }
4754 if (sme_req->callback)
4755 mac_ctx->p2p_ack_ind_cb =
4756 sme_req->callback;
4757 else
4758 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4759}
4760
4761/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304762 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4763 * indication callback in PE.
4764 * @mac_ptr: Mac pointer
4765 * @msg_buf: Msg pointer containing the callback
4766 *
4767 * This function is used save the Management frame
4768 * indication callback in PE.
4769 *
4770 * Return: None
4771 */
4772static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4773 uint32_t *msg_buf)
4774{
4775 struct sir_sme_mgmt_frame_cb_req *sme_req =
4776 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4777
4778 if (NULL == msg_buf) {
4779 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4780 return;
4781 }
4782 if (sme_req->callback)
4783 mac_ctx->mgmt_frame_ind_cb =
4784 (sir_mgmt_frame_ind_callback)sme_req->callback;
4785 else
4786 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4787}
4788
4789/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304790 *__lim_process_send_disassoc_frame: function processes disassoc frame
4791 * @mac_ctx: pointer to mac context
4792 * @msg_buf: message buffer
4793 *
4794 * function processes disassoc request received from SME
4795 *
4796 * return: none
4797 */
4798static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4799 uint32_t *msg_buf)
4800{
4801 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4802 tSirRetStatus status;
4803 tpPESession session_entry = NULL;
4804 uint8_t sme_session_id;
4805 uint16_t sme_trans_id;
4806
4807 if (msg_buf == NULL) {
4808 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4809 return;
4810 }
4811
4812 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4813 &sme_trans_id);
4814
4815 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4816 &sme_send_disassoc_frame_req,
4817 (uint8_t *)msg_buf);
4818
4819 if ((eSIR_FAILURE == status) ||
4820 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4821 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4822 PELOGE(lim_log(mac_ctx, LOGE,
4823 FL("received invalid SME_DISASSOC_REQ message"));)
4824 return;
4825 }
4826
4827 session_entry = pe_find_session_by_sme_session_id(
4828 mac_ctx, sme_session_id);
4829 if (session_entry == NULL) {
4830 lim_log(mac_ctx, LOGE,
4831 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4832 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4833 return;
4834 }
4835
4836 lim_log(mac_ctx, LOG1,
4837 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4838 sme_send_disassoc_frame_req.msg_type,
4839 sme_send_disassoc_frame_req.length,
4840 sme_send_disassoc_frame_req.session_id,
4841 sme_send_disassoc_frame_req.trans_id,
4842 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4843 sme_send_disassoc_frame_req.reason,
4844 sme_send_disassoc_frame_req.wait_for_ack);
4845
4846 lim_send_disassoc_mgmt_frame(mac_ctx,
4847 sme_send_disassoc_frame_req.reason,
4848 sme_send_disassoc_frame_req.peer_mac,
4849 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4850}
4851
4852/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004853 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4854 * @mac_ctx: Pointer to Global MAC structure
4855 * @pdev_id: pdev id to set the IE.
4856 * @nss: Nss values to prepare the HT IE.
4857 *
4858 * Prepares the HT IE with self capabilities for different
4859 * Nss values and sends the set HT IE req to FW.
4860 *
4861 * Return: None
4862 */
4863static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4864 uint8_t nss)
4865{
4866 struct set_ie_param *ie_params;
4867 tSirMsgQ msg;
4868 tSirRetStatus rc = eSIR_SUCCESS;
4869 uint8_t *p_ie = NULL;
4870 tHtCaps *p_ht_cap;
4871 int i;
4872
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004873 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004874 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4875 if (NULL == ie_params) {
4876 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4877 return;
4878 }
4879 ie_params->nss = i;
4880 ie_params->pdev_id = pdev_id;
4881 ie_params->ie_type = DOT11_HT_IE;
4882 /* 2 for IE len and EID */
4883 ie_params->ie_len = 2 + sizeof(tHtCaps);
4884 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4885 if (NULL == ie_params->ie_ptr) {
4886 qdf_mem_free(ie_params);
4887 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4888 return;
4889 }
4890 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4891 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4892 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4893 ie_params->ie_len);
4894
4895 if (NSS_1x1_MODE == i) {
4896 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4897 ie_params->ie_len,
4898 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004899 if (NULL == p_ie) {
4900 qdf_mem_free(ie_params->ie_ptr);
4901 qdf_mem_free(ie_params);
4902 lim_log(mac_ctx, LOGE,
4903 FL("failed to get IE ptr"));
4904 return;
4905 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004906 p_ht_cap = (tHtCaps *)&p_ie[2];
4907 p_ht_cap->supportedMCSSet[1] = 0;
4908 p_ht_cap->txSTBC = 0;
4909 }
4910
4911 msg.type = WMA_SET_PDEV_IE_REQ;
4912 msg.bodyptr = ie_params;
4913 msg.bodyval = 0;
4914
4915 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4916 if (rc != eSIR_SUCCESS) {
4917 lim_log(mac_ctx, LOGE,
4918 FL("wma_post_ctrl_msg() return failure"));
4919 qdf_mem_free(ie_params->ie_ptr);
4920 qdf_mem_free(ie_params);
4921 return;
4922 }
4923 }
4924}
4925
4926/**
4927 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4928 * @mac_ctx: Pointer to Global MAC structure
4929 * @pdev_id: pdev id to set the IE.
4930 * @nss: Nss values to prepare the VHT IE.
4931 *
4932 * Prepares the VHT IE with self capabilities for different
4933 * Nss values and sends the set VHT IE req to FW.
4934 *
4935 * Return: None
4936 */
4937static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4938 uint8_t nss)
4939{
4940 struct set_ie_param *ie_params;
4941 tSirMsgQ msg;
4942 tSirRetStatus rc = eSIR_SUCCESS;
4943 uint8_t *p_ie = NULL;
4944 tSirMacVHTCapabilityInfo *vht_cap;
4945 int i;
4946 tSirVhtMcsInfo *vht_mcs;
4947
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004948 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004949 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4950 if (NULL == ie_params) {
4951 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4952 return;
4953 }
4954 ie_params->nss = i;
4955 ie_params->pdev_id = pdev_id;
4956 ie_params->ie_type = DOT11_VHT_IE;
4957 /* 2 for IE len and EID */
4958 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4959 sizeof(tSirVhtMcsInfo);
4960 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4961 if (NULL == ie_params->ie_ptr) {
4962 qdf_mem_free(ie_params);
4963 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4964 return;
4965 }
4966 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4967 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4968 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4969 ie_params->ie_len);
4970
4971 if (NSS_1x1_MODE == i) {
4972 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4973 ie_params->ie_len,
4974 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004975 if (NULL == p_ie) {
4976 qdf_mem_free(ie_params->ie_ptr);
4977 qdf_mem_free(ie_params);
4978 lim_log(mac_ctx, LOGE,
4979 FL("failed to get IE ptr"));
4980 return;
4981 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004982 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4983 vht_cap->txSTBC = 0;
4984 vht_mcs =
4985 (tSirVhtMcsInfo *)&p_ie[2 +
4986 sizeof(tSirMacVHTCapabilityInfo)];
4987 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4988 vht_mcs->rxHighest =
4989 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4990 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4991 vht_mcs->txHighest =
4992 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4993 }
4994 msg.type = WMA_SET_PDEV_IE_REQ;
4995 msg.bodyptr = ie_params;
4996 msg.bodyval = 0;
4997
4998 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4999 if (rc != eSIR_SUCCESS) {
5000 lim_log(mac_ctx, LOGE,
5001 FL("wma_post_ctrl_msg failure"));
5002 qdf_mem_free(ie_params->ie_ptr);
5003 qdf_mem_free(ie_params);
5004 return;
5005 }
5006 }
5007}
5008
5009/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005010 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5011 * @mac_ctx: Pointer to Global MAC structure
5012 * @msg_buf: Pointer to the SME message buffer
5013 *
5014 * This function is called by limProcessMessageQueue(). This function sets the
5015 * VDEV IEs to the FW.
5016 *
5017 * Return: None
5018 */
5019static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5020 uint32_t *msg_buf)
5021{
5022 struct sir_set_vdev_ies_per_band *p_msg =
5023 (struct sir_set_vdev_ies_per_band *)msg_buf;
5024
5025 if (NULL == p_msg) {
5026 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5027 return;
5028 }
5029
5030 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5031 p_msg->vdev_id);
5032 /* intentionally using NULL here so that self capabilty are sent */
5033 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5034 QDF_STATUS_SUCCESS)
5035 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5036}
5037
5038/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005039 * lim_process_set_pdev_IEs() - process the set pdev IE req
5040 * @mac_ctx: Pointer to Global MAC structure
5041 * @msg_buf: Pointer to the SME message buffer
5042 *
5043 * This function is called by limProcessMessageQueue(). This
5044 * function sets the PDEV IEs to the FW.
5045 *
5046 * Return: None
5047 */
5048static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5049{
5050 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5051
5052 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5053
5054 if (NULL == ht_vht_cfg) {
5055 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5056 return;
5057 }
5058
5059 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5060 ht_vht_cfg->nss);
5061 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5062
5063 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5064 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5065 ht_vht_cfg->nss);
5066}
5067
5068/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305069 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5070 *
5071 * access policy
5072 * @mac_ctx: pointer to mac context
5073 * @msg: message buffer
5074 *
5075 * function processes vendor IE and access policy from SME and updates PE
5076 *
5077 * session entry
5078 *
5079 * return: none
5080*/
5081static void lim_process_sme_update_access_policy_vendor_ie(
5082 tpAniSirGlobal mac_ctx,
5083 uint32_t *msg)
5084{
5085 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5086 struct sPESession *pe_session_entry;
5087 uint8_t num_bytes;
5088
5089 if (!msg) {
5090 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5091 return;
5092 }
5093 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5094 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5095 update_vendor_ie->sme_session_id);
5096
5097 if (!pe_session_entry) {
5098 lim_log(mac_ctx, LOGE,
5099 FL("Session does not exist for given sme session id(%hu)"),
5100 update_vendor_ie->sme_session_id);
5101 return;
5102 }
5103 if (pe_session_entry->access_policy_vendor_ie)
5104 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5105
5106 num_bytes = update_vendor_ie->ie[1] + 2;
5107 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5108
5109 if (!pe_session_entry->access_policy_vendor_ie) {
5110 lim_log(mac_ctx, LOGE,
5111 FL("Failed to allocate memory for vendor ie"));
5112 return;
5113 }
5114 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5115 &update_vendor_ie->ie[0], num_bytes);
5116
5117 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5118}
5119
5120/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 * lim_process_sme_req_messages()
5122 *
5123 ***FUNCTION:
5124 * This function is called by limProcessMessageQueue(). This
5125 * function processes SME request messages from HDD or upper layer
5126 * application.
5127 *
5128 ***LOGIC:
5129 *
5130 ***ASSUMPTIONS:
5131 *
5132 ***NOTE:
5133 *
5134 * @param pMac Pointer to Global MAC structure
5135 * @param msgType Indicates the SME message type
5136 * @param *pMsgBuf A pointer to the SME message buffer
5137 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5138 * false - if pMsgBuf is not to be freed.
5139 */
5140
5141bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5142{
5143 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5144 uint32_t *pMsgBuf = pMsg->bodyptr;
5145 tpSirSmeScanReq pScanReq;
5146 PELOG1(lim_log
5147 (pMac, LOG1,
5148 FL
5149 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5150 lim_msg_str(pMsg->type), pMsg->type,
5151 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5152 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5153 )
5154
5155 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5156 /* If no insert NOA required then execute the code below */
5157
5158 switch (pMsg->type) {
5159 case eWNI_SME_SYS_READY_IND:
5160 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5161 break;
5162
5163 case eWNI_SME_START_BSS_REQ:
5164 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5165 break;
5166
5167 case eWNI_SME_SCAN_REQ:
5168 __lim_process_sme_scan_req(pMac, pMsgBuf);
5169 break;
5170
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5172 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5173 break;
5174
5175 case eWNI_SME_UPDATE_NOA:
5176 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5177 break;
5178 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5179 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5180 break;
5181 case eWNI_SME_JOIN_REQ:
5182 __lim_process_sme_join_req(pMac, pMsgBuf);
5183 break;
5184
5185 case eWNI_SME_REASSOC_REQ:
5186 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5187 break;
5188
5189 case eWNI_SME_DISASSOC_REQ:
5190 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5191 break;
5192
5193 case eWNI_SME_DISASSOC_CNF:
5194 case eWNI_SME_DEAUTH_CNF:
5195 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5196 break;
5197
5198 case eWNI_SME_DEAUTH_REQ:
5199 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5200 break;
5201
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305202 case eWNI_SME_SEND_DISASSOC_FRAME:
5203 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5204 break;
5205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 case eWNI_SME_SETCONTEXT_REQ:
5207 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5208 break;
5209
5210 case eWNI_SME_STOP_BSS_REQ:
5211 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5212 break;
5213
5214 case eWNI_SME_ASSOC_CNF:
5215 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5216 PELOG1(lim_log(pMac,
5217 LOG1, FL("Received ASSOC_CNF message"));)
5218 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5219 pMsgBuf);
5220 break;
5221
5222 case eWNI_SME_ADDTS_REQ:
5223 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5224 __lim_process_sme_addts_req(pMac, pMsgBuf);
5225 break;
5226
5227 case eWNI_SME_DELTS_REQ:
5228 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5229 __lim_process_sme_delts_req(pMac, pMsgBuf);
5230 break;
5231
5232 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5233 PELOG1(lim_log
5234 (pMac, LOG1,
5235 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5236 )
5237 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5238 break;
5239
5240 case eWNI_SME_GET_STATISTICS_REQ:
5241 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5242 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5243 bufConsumed = false;
5244 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005245#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 case eWNI_SME_GET_TSM_STATS_REQ:
5247 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5248 bufConsumed = false;
5249 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005250#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 case eWNI_SME_GET_ASSOC_STAS_REQ:
5252 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5253 break;
5254 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5255 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5256 break;
5257
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305258 case eWNI_SME_SESSION_UPDATE_PARAM:
5259 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305261 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5262 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5263 bufConsumed = false;
5264 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265 case eWNI_SME_UPDATE_APWPSIE_REQ:
5266 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5267 break;
5268 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5269 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5270 break;
5271
5272 case eWNI_SME_SET_APWPARSNIEs_REQ:
5273 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5274 break;
5275
5276 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5277 /* Update the beaconInterval */
5278 __lim_process_sme_change_bi(pMac, pMsgBuf);
5279 break;
5280
5281#ifdef QCA_HT_2040_COEX
5282 case eWNI_SME_SET_HT_2040_MODE:
5283 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5284 break;
5285#endif
5286
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005287 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5288 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5289 __lim_process_report_message(pMac, pMsg);
5290 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292 case eWNI_SME_FT_PRE_AUTH_REQ:
5293 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5294 break;
5295 case eWNI_SME_FT_UPDATE_KEY:
5296 lim_process_ft_update_key(pMac, pMsgBuf);
5297 break;
5298
5299 case eWNI_SME_FT_AGGR_QOS_REQ:
5300 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5301 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302
5303 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5304 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5305 break;
5306#ifdef FEATURE_WLAN_TDLS
5307 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5308 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5309 break;
5310 case eWNI_SME_TDLS_ADD_STA_REQ:
5311 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5312 break;
5313 case eWNI_SME_TDLS_DEL_STA_REQ:
5314 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5315 break;
5316 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5317 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5318 break;
5319#endif
5320 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5321 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5322 break;
5323
5324 case eWNI_SME_CHANNEL_CHANGE_REQ:
5325 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5326 break;
5327
5328 case eWNI_SME_START_BEACON_REQ:
5329 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5330 break;
5331
5332 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5333 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5334 break;
5335
5336 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5337 lim_process_update_add_ies(pMac, pMsgBuf);
5338 break;
5339
5340 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5341 lim_process_modify_add_ies(pMac, pMsgBuf);
5342 break;
5343 case eWNI_SME_SET_HW_MODE_REQ:
5344 lim_process_set_hw_mode(pMac, pMsgBuf);
5345 break;
5346 case eWNI_SME_NSS_UPDATE_REQ:
5347 lim_process_nss_update_request(pMac, pMsgBuf);
5348 break;
5349 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5350 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5351 break;
5352 case eWNI_SME_SET_IE_REQ:
5353 lim_process_set_ie_req(pMac, pMsgBuf);
5354 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305355 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5356 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5357 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305358 case eWNI_SME_EXT_CHANGE_CHANNEL:
5359 lim_process_ext_change_channel(pMac, pMsgBuf);
5360 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005361 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5362 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5363 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005364 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5365 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005366 break;
5367 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5368 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5369 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005370 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005371 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005372 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005373 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005374 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305375 case eWNI_SME_REGISTER_P2P_ACK_CB:
5376 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5377 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305378 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5379 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5380 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305382 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 pMsg->bodyptr = NULL;
5384 break;
5385 } /* switch (msgType) */
5386
5387 return bufConsumed;
5388} /*** end lim_process_sme_req_messages() ***/
5389
5390/**
5391 * lim_process_sme_start_beacon_req()
5392 *
5393 ***FUNCTION:
5394 * This function is called by limProcessMessageQueue(). This
5395 * function processes SME request messages from HDD or upper layer
5396 * application.
5397 *
5398 ***LOGIC:
5399 *
5400 ***ASSUMPTIONS:
5401 *
5402 ***NOTE:
5403 *
5404 * @param pMac Pointer to Global MAC structure
5405 * @param msgType Indicates the SME message type
5406 * @param *pMsgBuf A pointer to the SME message buffer
5407 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5408 * false - if pMsgBuf is not to be freed.
5409 */
5410static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5411{
5412 tpSirStartBeaconIndication pBeaconStartInd;
5413 tpPESession psessionEntry;
5414 uint8_t sessionId; /* PE sessionID */
5415
5416 if (pMsg == NULL) {
5417 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5418 return;
5419 }
5420
5421 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5422 psessionEntry = pe_find_session_by_bssid(pMac,
5423 pBeaconStartInd->bssid,
5424 &sessionId);
5425 if (psessionEntry == NULL) {
5426 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5427 lim_log(pMac, LOGE,
5428 FL("Session does not exist for given bssId"));
5429 return;
5430 }
5431
5432 if (pBeaconStartInd->beaconStartStatus == true) {
5433 /*
5434 * Currently this Indication comes from SAP
5435 * to start Beacon Tx on a DFS channel
5436 * since beaconing has to be done on DFS
5437 * channel only after CAC WAIT is completed.
5438 * On a DFS Channel LIM does not start beacon
5439 * Tx right after the WMA_ADD_BSS_RSP.
5440 */
5441 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305442 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 FL("Start Beacon with ssid %s Ch %d"),
5444 psessionEntry->ssId.ssId,
5445 psessionEntry->currentOperChannel);
5446 lim_send_beacon_ind(pMac, psessionEntry);
5447 } else {
5448 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5449 return;
5450 }
5451}
5452
5453/**
5454 * lim_process_sme_channel_change_request() - process sme ch change req
5455 *
5456 * @mac_ctx: Pointer to Global MAC structure
5457 * @msg_buf: pointer to the SME message buffer
5458 *
5459 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5460 *
5461 * Return: None
5462 */
5463static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5464 uint32_t *msg_buf)
5465{
5466 tpSirChanChangeRequest ch_change_req;
5467 tpPESession session_entry;
5468 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005469 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005470 uint32_t val = 0;
5471
5472 if (msg_buf == NULL) {
5473 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5474 return;
5475 }
5476 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5477
5478 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5479 ch_change_req->targetChannel);
5480
5481 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5482 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5483 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5484 return;
5485 }
5486
5487 session_entry = pe_find_session_by_bssid(mac_ctx,
5488 ch_change_req->bssid, &session_id);
5489 if (session_entry == NULL) {
5490 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5491 lim_log(mac_ctx, LOGE, FL(
5492 "Session does not exist for given bssId"));
5493 return;
5494 }
5495
5496 if (session_entry->currentOperChannel ==
5497 ch_change_req->targetChannel) {
5498 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5499 return;
5500 }
5501
5502 if (LIM_IS_AP_ROLE(session_entry))
5503 session_entry->channelChangeReasonCode =
5504 LIM_SWITCH_CHANNEL_SAP_DFS;
5505 else
5506 session_entry->channelChangeReasonCode =
5507 LIM_SWITCH_CHANNEL_OPERATION;
5508
5509 lim_log(mac_ctx, LOGW, FL(
5510 "switch old chnl %d to new chnl %d, ch_bw %d"),
5511 session_entry->currentOperChannel,
5512 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005513 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514
5515 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005516 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 session_entry->ch_center_freq_seg0 =
5518 ch_change_req->center_freq_seg_0;
5519 session_entry->ch_center_freq_seg1 =
5520 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005521 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005523 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005524 session_entry->htRecommendedTxWidthSet =
5525 session_entry->htSupportedChannelWidthSet;
5526 session_entry->currentOperChannel =
5527 ch_change_req->targetChannel;
5528 session_entry->limRFBand =
5529 lim_get_rf_band(session_entry->currentOperChannel);
5530 /* Initialize 11h Enable Flag */
5531 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5532 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5533 eSIR_SUCCESS)
5534 lim_log(mac_ctx, LOGP,
5535 FL("Fail to get WNI_CFG_11H_ENABLED"));
5536 }
5537
5538 session_entry->lim11hEnable = val;
5539 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305540 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541 &ch_change_req->operational_rateset,
5542 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305543 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 &ch_change_req->extended_rateset,
5545 sizeof(session_entry->extRateSet));
5546 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5547 session_entry->ch_center_freq_seg0,
5548 session_entry->ch_center_freq_seg1,
5549 session_entry->ch_width,
5550 max_tx_pwr, session_entry->peSessionId);
5551}
5552
5553/******************************************************************************
5554* lim_start_bss_update_add_ie_buffer()
5555*
5556***FUNCTION:
5557* This function checks the src buffer and its length and then malloc for
5558* dst buffer update the same
5559*
5560***LOGIC:
5561*
5562***ASSUMPTIONS:
5563*
5564***NOTE:
5565*
5566* @param pMac Pointer to Global MAC structure
5567* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5568* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5569* @param *pSrcData_buff A pointer of uint8_t src buffer
5570* @param srcDataLen src buffer length
5571******************************************************************************/
5572
5573static void
5574lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5575 uint8_t **pDstData_buff,
5576 uint16_t *pDstDataLen,
5577 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5578{
5579
5580 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5581 *pDstDataLen = srcDataLen;
5582
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305583 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584
5585 if (NULL == *pDstData_buff) {
5586 lim_log(pMac, LOGE,
5587 FL("AllocateMemory failed for pDstData_buff"));
5588 return;
5589 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305590 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005591 } else {
5592 *pDstData_buff = NULL;
5593 *pDstDataLen = 0;
5594 }
5595}
5596
5597/******************************************************************************
5598* lim_update_add_ie_buffer()
5599*
5600***FUNCTION:
5601* This function checks the src buffer and length if src buffer length more
5602* than dst buffer length then free the dst buffer and malloc for the new src
5603* length, and update the dst buffer and length. But if dst buffer is bigger
5604* than src buffer length then it just update the dst buffer and length
5605*
5606***LOGIC:
5607*
5608***ASSUMPTIONS:
5609*
5610***NOTE:
5611*
5612* @param pMac Pointer to Global MAC structure
5613* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5614* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5615* @param *pSrcData_buff A pointer of uint8_t src buffer
5616* @param srcDataLen src buffer length
5617******************************************************************************/
5618
5619static void
5620lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5621 uint8_t **pDstData_buff,
5622 uint16_t *pDstDataLen,
5623 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5624{
5625
5626 if (NULL == pSrcData_buff) {
5627 lim_log(pMac, LOGE, FL("src buffer is null."));
5628 return;
5629 }
5630
5631 if (srcDataLen > *pDstDataLen) {
5632 *pDstDataLen = srcDataLen;
5633 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305634 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005635 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305636 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637
5638 if (NULL == *pDstData_buff) {
5639 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5640 *pDstDataLen = 0;
5641 return;
5642 }
5643 }
5644
5645 /* copy the content of buffer into dst buffer
5646 */
5647 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305648 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005649
5650}
5651
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005652/**
5653 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5654 * @pMac : Pointer to Global MAC structure
5655 * @pDstData_buff : A pointer to pointer of dst buffer
5656 * @pDstDataLen : A pointer to pointer of dst buffer length
5657 * @pModifyIE : A pointer to tSirModifyIE
5658 *
5659 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5660 *
5661 * Return:
5662 * True or false depending upon whether IE is updated or not
5663 */
5664static bool
5665lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5666 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5667{
Hong Shi1553d692016-09-28 12:16:19 +08005668 int32_t oui_length;
5669 uint8_t *ibss_ie = NULL;
5670 uint8_t *vendor_ie;
5671#define MAC_VENDOR_OUI "\x00\x16\x32"
5672#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005673
5674 ibss_ie = pModifyIE->pIEBuffer;
5675 oui_length = pModifyIE->oui_length;
5676
5677 if ((0 == oui_length) || (NULL == ibss_ie)) {
5678 PELOGE(lim_log(pMac, LOGE,
5679 FL("Invalid set IBSS vendor IE command length %d "),
5680 oui_length);)
5681 return false;
5682 }
5683
Hong Shi1553d692016-09-28 12:16:19 +08005684 /*
5685 * Why replace only beacon OUI data here:
5686 * 1. other ie (such as wpa) shall not be overwritten here.
5687 * 2. per spec, beacon oui ie might be set twice and original one
5688 * shall be updated.
5689 */
5690 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5691 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5692 if (vendor_ie) {
5693 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5694 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5695 pModifyIE->ieBufferlength);
5696 } else {
5697 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5698 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005699
Hong Shi1553d692016-09-28 12:16:19 +08005700 if (NULL == new_ptr) {
5701 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5702 return false;
5703 }
5704 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5705 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5706 pModifyIE->ieBufferlength);
5707 qdf_mem_free(*pDstData_buff);
5708 *pDstDataLen = new_length;
5709 *pDstData_buff = new_ptr;
5710 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005711 return true;
5712}
5713
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714/*
5715* lim_process_modify_add_ies() - process modify additional IE req.
5716*
5717* @mac_ctx: Pointer to Global MAC structure
5718* @msg_buf: pointer to the SME message buffer
5719*
5720* This function update the PE buffers for additional IEs.
5721*
5722* Return: None
5723*/
5724static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5725 uint32_t *msg_buf)
5726{
5727 tpSirModifyIEsInd modify_add_ies;
5728 tpPESession session_entry;
5729 uint8_t session_id;
5730 bool ret = false;
5731 tSirAddIeParams *add_ie_params;
5732
5733 if (msg_buf == NULL) {
5734 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5735 return;
5736 }
5737
5738 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5739 /* Incoming message has smeSession, use BSSID to find PE session */
5740 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005741 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742
5743 if (NULL == session_entry) {
5744 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5745 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005746 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 goto end;
5748 }
5749 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5750 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5751 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5752 lim_log(mac_ctx, LOGE,
5753 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5754 modify_add_ies->modifyIE.pIEBuffer,
5755 modify_add_ies->modifyIE.ieBufferlength,
5756 modify_add_ies->modifyIE.ieID,
5757 modify_add_ies->modifyIE.ieIDLen,
5758 modify_add_ies->updateType);
5759 goto end;
5760 }
5761 add_ie_params = &session_entry->addIeParams;
5762 switch (modify_add_ies->updateType) {
5763 case eUPDATE_IE_PROBE_RESP:
5764 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005765 if (LIM_IS_IBSS_ROLE(session_entry)) {
5766 lim_update_ibss_prop_add_ies(mac_ctx,
5767 &add_ie_params->probeRespData_buff,
5768 &add_ie_params->probeRespDataLen,
5769 &modify_add_ies->modifyIE);
5770 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 break;
5772 case eUPDATE_IE_ASSOC_RESP:
5773 /* assoc resp IE */
5774 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305775 QDF_TRACE(QDF_MODULE_ID_PE,
5776 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005777 "assoc resp add ie not present %d"),
5778 add_ie_params->assocRespDataLen);
5779 }
5780 /* search through the buffer and modify the IE */
5781 break;
5782 case eUPDATE_IE_PROBE_BCN:
5783 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005784 if (LIM_IS_IBSS_ROLE(session_entry)) {
5785 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5786 &add_ie_params->probeRespBCNData_buff,
5787 &add_ie_params->probeRespBCNDataLen,
5788 &modify_add_ies->modifyIE);
5789 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 if (ret == true && modify_add_ies->modifyIE.notify) {
5791 lim_handle_param_update(mac_ctx,
5792 modify_add_ies->updateType);
5793 }
5794 break;
5795 default:
5796 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5797 modify_add_ies->updateType);
5798 break;
5799 }
5800end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305801 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 modify_add_ies->modifyIE.pIEBuffer = NULL;
5803}
5804
5805/*
5806* lim_process_update_add_ies() - process additional IE update req
5807*
5808* @mac_ctx: Pointer to Global MAC structure
5809* @msg_buf: pointer to the SME message buffer
5810*
5811* This function update the PE buffers for additional IEs.
5812*
5813* Return: None
5814*/
5815static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5816 uint32_t *msg_buf)
5817{
5818 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5819 uint8_t session_id;
5820 tpPESession session_entry;
5821 tSirAddIeParams *addn_ie;
5822 uint16_t new_length = 0;
5823 uint8_t *new_ptr = NULL;
5824 tSirUpdateIE *update_ie;
5825
5826 if (msg_buf == NULL) {
5827 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5828 return;
5829 }
5830 update_ie = &update_add_ies->updateIE;
5831 /* incoming message has smeSession, use BSSID to find PE session */
5832 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005833 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834
5835 if (NULL == session_entry) {
5836 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5837 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005838 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005839 goto end;
5840 }
5841 addn_ie = &session_entry->addIeParams;
5842 /* if len is 0, upper layer requested freeing of buffer */
5843 if (0 == update_ie->ieBufferlength) {
5844 switch (update_add_ies->updateType) {
5845 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305846 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847 addn_ie->probeRespData_buff = NULL;
5848 addn_ie->probeRespDataLen = 0;
5849 break;
5850 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305851 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 addn_ie->assocRespData_buff = NULL;
5853 addn_ie->assocRespDataLen = 0;
5854 break;
5855 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305856 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857 addn_ie->probeRespBCNData_buff = NULL;
5858 addn_ie->probeRespBCNDataLen = 0;
5859
5860 if (update_ie->notify)
5861 lim_handle_param_update(mac_ctx,
5862 update_add_ies->updateType);
5863 break;
5864 default:
5865 break;
5866 }
5867 return;
5868 }
5869 switch (update_add_ies->updateType) {
5870 case eUPDATE_IE_PROBE_RESP:
5871 if (update_ie->append) {
5872 /*
5873 * In case of append, allocate new memory
5874 * with combined length
5875 */
5876 new_length = update_ie->ieBufferlength +
5877 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305878 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879 if (NULL == new_ptr) {
5880 lim_log(mac_ctx, LOGE, FL(
5881 "Memory allocation failed."));
5882 goto end;
5883 }
5884 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305885 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005886 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305887 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888 update_ie->pAdditionIEBuffer,
5889 update_ie->ieBufferlength);
5890 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305891 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005892 /* adjust length accordingly */
5893 addn_ie->probeRespDataLen = new_length;
5894 /* save refernece of local buffer in PE session */
5895 addn_ie->probeRespData_buff = new_ptr;
5896 goto end;
5897 }
5898 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5899 &addn_ie->probeRespDataLen,
5900 update_ie->pAdditionIEBuffer,
5901 update_ie->ieBufferlength);
5902 break;
5903 case eUPDATE_IE_ASSOC_RESP:
5904 /* assoc resp IE */
5905 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5906 &addn_ie->assocRespDataLen,
5907 update_ie->pAdditionIEBuffer,
5908 update_ie->ieBufferlength);
5909 break;
5910 case eUPDATE_IE_PROBE_BCN:
5911 /* probe resp Bcn IE */
5912 lim_update_add_ie_buffer(mac_ctx,
5913 &addn_ie->probeRespBCNData_buff,
5914 &addn_ie->probeRespBCNDataLen,
5915 update_ie->pAdditionIEBuffer,
5916 update_ie->ieBufferlength);
5917 if (update_ie->notify)
5918 lim_handle_param_update(mac_ctx,
5919 update_add_ies->updateType);
5920 break;
5921 default:
5922 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5923 update_add_ies->updateType);
5924 break;
5925 }
5926end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305927 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928 update_ie->pAdditionIEBuffer = NULL;
5929}
5930
5931/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305932 * send_extended_chan_switch_action_frame()- function to send ECSA
5933 * action frame for each sta connected to SAP/GO and AP in case of
5934 * STA .
5935 * @mac_ctx: pointer to global mac structure
5936 * @new_channel: new channel to switch to.
5937 * @ch_bandwidth: BW of channel to calculate op_class
5938 * @session_entry: pe session
5939 *
5940 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5941 *
5942 * Return: void
5943 */
5944
5945static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5946 uint16_t new_channel, uint8_t ch_bandwidth,
5947 tpPESession session_entry)
5948{
5949 uint16_t op_class;
5950 uint8_t switch_mode = 0, i;
5951 tpDphHashNode psta;
5952
5953
Amar Singhal22995112016-01-22 10:42:33 -08005954 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305955 mac_ctx->scan.countryCodeCurrent,
5956 new_channel,
5957 ch_bandwidth);
5958
5959 if (LIM_IS_AP_ROLE(session_entry) &&
5960 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5961 switch_mode = 1;
5962
5963 if (LIM_IS_AP_ROLE(session_entry)) {
5964 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5965 psta =
5966 session_entry->dph.dphHashTable.pDphNodeArray + i;
5967 if (psta && psta->added)
5968 lim_send_extended_chan_switch_action_frame(
5969 mac_ctx,
5970 psta->staAddr,
5971 switch_mode, op_class, new_channel,
5972 LIM_MAX_CSA_IE_UPDATES, session_entry);
5973 }
5974 } else if (LIM_IS_STA_ROLE(session_entry)) {
5975 lim_send_extended_chan_switch_action_frame(mac_ctx,
5976 session_entry->bssId,
5977 switch_mode, op_class, new_channel,
5978 LIM_MAX_CSA_IE_UPDATES, session_entry);
5979 }
5980
5981}
5982
5983/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5985 *
5986 * @mac_ctx: Pointer to Global MAC structure
5987 * @msg_buf: pointer to the SME message buffer
5988 *
5989 * This function processes SME request messages from HDD or upper layer
5990 * application.
5991 *
5992 * Return: None
5993 */
5994static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5995 uint32_t *msg_buf)
5996{
5997 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5998 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 uint8_t session_id;
6000 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006001 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006002
6003 if (msg_buf == NULL) {
6004 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6005 return;
6006 }
6007
6008 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6009 session_entry = pe_find_session_by_bssid(mac_ctx,
6010 dfs_csa_ie_req->bssid, &session_id);
6011 if (session_entry == NULL) {
6012 lim_log(mac_ctx, LOGE, FL(
6013 "Session not found for given BSSID" MAC_ADDRESS_STR),
6014 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6015 return;
6016 }
6017
6018 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6019 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6020 GET_LIM_SYSTEM_ROLE(session_entry));
6021 return;
6022 }
6023
6024 /* target channel */
6025 session_entry->gLimChannelSwitch.primaryChannel =
6026 dfs_csa_ie_req->targetChannel;
6027
6028 /* Channel switch announcement needs to be included in beacon */
6029 session_entry->dfsIncludeChanSwIe = true;
6030 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6031 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006032 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306033 session_entry->gLimChannelSwitch.sec_ch_offset =
6034 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6036 session_entry->gLimChannelSwitch.switchMode = 1;
6037
6038 /*
6039 * Validate if SAP is operating HT or VHT mode and set the Channel
6040 * Switch Wrapper element with the Wide Band Switch subelement.
6041 */
6042 if (true != session_entry->vhtCapability)
6043 goto skip_vht;
6044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 /* Now encode the Wider Ch BW element depending on the ch width */
6046 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006047 switch (dfs_csa_ie_req->ch_params.ch_width) {
6048 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006049 /*
6050 * Wide channel BW sublement in channel wrapper element is not
6051 * required in case of 20 Mhz operation. Currently It is set
6052 * only set in case of 40/80 Mhz Operation.
6053 */
6054 session_entry->dfsIncludeChanWrapperIe = false;
6055 wider_bw_ch_switch->newChanWidth =
6056 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6057 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006058 case CH_WIDTH_40MHZ:
6059 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 wider_bw_ch_switch->newChanWidth =
6061 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6062 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006063 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006064 session_entry->dfsIncludeChanWrapperIe = true;
6065 wider_bw_ch_switch->newChanWidth =
6066 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6067 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006068 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069 session_entry->dfsIncludeChanWrapperIe = true;
6070 wider_bw_ch_switch->newChanWidth =
6071 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6072 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006073 case CH_WIDTH_80P80MHZ:
6074 session_entry->dfsIncludeChanWrapperIe = true;
6075 wider_bw_ch_switch->newChanWidth =
6076 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006077 /*
6078 * This is not applicable for 20/40/80 Mhz.
6079 * Only used when we support 80+80 Mhz operation.
6080 * In case of 80+80 Mhz, this parameter indicates
6081 * center channel frequency index of 80 Mhz channel of
6082 * frequency segment 1.
6083 */
6084 wider_bw_ch_switch->newCenterChanFreq1 =
6085 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006086 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006087 default:
6088 session_entry->dfsIncludeChanWrapperIe = false;
6089 /*
6090 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6091 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6092 */
6093 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6094 break;
6095 }
6096 /* Fetch the center channel based on the channel width */
6097 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006098 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099skip_vht:
6100 /* Send CSA IE request from here */
6101 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6102 eSIR_SUCCESS) {
6103 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6104 return;
6105 }
6106
6107 /*
6108 * First beacon update request is sent here, the remaining updates are
6109 * done when the FW responds back after sending the first beacon after
6110 * the template update
6111 */
6112 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306113
6114 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6115 ch_offset = BW80;
6116 else
6117 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6118
6119 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6120 session_entry->gLimChannelSwitch.switchCount,
6121 session_entry->gLimChannelSwitch.primaryChannel,
6122 session_entry->gLimChannelSwitch.ch_width,
6123 session_entry->dfsIncludeChanWrapperIe,
6124 ch_offset);
6125
Abhishek Singh518323d2015-10-19 17:42:01 +05306126 /* Send ECSA Action frame after updating the beacon */
6127 send_extended_chan_switch_action_frame(mac_ctx,
6128 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306129 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006130 session_entry->gLimChannelSwitch.switchCount--;
6131}
6132
6133/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306134 * lim_process_ext_change_channel()- function to send ECSA
6135 * action frame for STA/CLI .
6136 * @mac_ctx: pointer to global mac structure
6137 * @msg: params from sme for new channel.
6138 *
6139 * This function is called to send ECSA frame for STA/CLI.
6140 *
6141 * Return: void
6142 */
6143
6144static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6145 uint32_t *msg)
6146{
6147 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6148 (struct sir_sme_ext_cng_chan_req *) msg;
6149 tpPESession session_entry = NULL;
6150
6151 if (NULL == msg) {
6152 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6153 return;
6154 }
6155 session_entry =
6156 pe_find_session_by_sme_session_id(mac_ctx,
6157 ext_chng_channel->session_id);
6158 if (NULL == session_entry) {
6159 lim_log(mac_ctx, LOGE,
6160 FL("Session not found for given session %d"),
6161 ext_chng_channel->session_id);
6162 return;
6163 }
6164 if (LIM_IS_AP_ROLE(session_entry)) {
6165 lim_log(mac_ctx, LOGE,
6166 FL("not an STA/CLI session"));
6167 return;
6168 }
6169 send_extended_chan_switch_action_frame(mac_ctx,
6170 ext_chng_channel->new_channel,
6171 0, session_entry);
6172}
6173
6174/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175 * lim_process_nss_update_request() - process sme nss update req
6176 *
6177 * @mac_ctx: Pointer to Global MAC structure
6178 * @msg_buf: pointer to the SME message buffer
6179 *
6180 * This function processes SME request messages from HDD or upper layer
6181 * application.
6182 *
6183 * Return: None
6184 */
6185static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6186 uint32_t *msg_buf)
6187{
6188 struct sir_nss_update_request *nss_update_req_ptr;
6189 tpPESession session_entry = NULL;
6190
6191 if (msg_buf == NULL) {
6192 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6193 return;
6194 }
6195
6196 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306197 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198 nss_update_req_ptr->vdev_id);
6199 if (session_entry == NULL) {
6200 lim_log(mac_ctx, LOGE, FL(
6201 "Session not found for given session_id %d"),
6202 nss_update_req_ptr->vdev_id);
6203 return;
6204 }
6205
6206 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6207 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6208 GET_LIM_SYSTEM_ROLE(session_entry));
6209 return;
6210 }
6211
6212 /* populate nss field in the beacon */
6213 session_entry->gLimOperatingMode.present = 1;
6214 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6215 /* Send nss update request from here */
6216 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6217 eSIR_SUCCESS) {
6218 lim_log(mac_ctx, LOGE,
6219 FL("Unable to set op mode IE in beacon"));
6220 return;
6221 }
6222
6223 lim_send_beacon_ind(mac_ctx, session_entry);
6224}
6225
6226/**
6227 * lim_process_set_ie_req() - process sme set IE request
6228 *
6229 * @mac_ctx: Pointer to Global MAC structure
6230 * @msg_buf: pointer to the SME message buffer
6231 *
6232 * This function processes SME request messages from HDD or upper layer
6233 * application.
6234 *
6235 * Return: None
6236 */
6237static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6238{
6239 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306240 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006241
6242 if (msg_buf == NULL) {
6243 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6244 return;
6245 }
6246
6247 msg = (struct send_extcap_ie *)msg_buf;
6248 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306249 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006250 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6251
6252}