blob: 24475f6117290b7179ec5761dba9c0bd1f96a085 [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
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530160 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161
162 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530163 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 /* Other parameters are not needed for WMA */
165
166 cds_message.bodyptr = req_msg;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +0530167 cds_message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168
169 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
170 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530171 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700173 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530175 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 goto fail;
177 }
178 return status;
179fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530180 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800181 if (!param) {
182 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530183 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 }
185 param->status = SET_HW_MODE_STATUS_ECANCELED;
186 param->cfgd_hw_mode_index = 0;
187 param->num_vdev_mac_entries = 0;
188 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
189 resp_msg.bodyptr = param;
190 resp_msg.bodyval = 0;
191 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530192 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193}
194
195/**
196 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
197 * @mac: Global MAC pointer
198 * @msg: Message containing the dual mac config parameter
199 *
200 * Send the set dual mac config command to WMA
201 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530202 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530204static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 uint32_t *msg)
206{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530207 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 cds_msg_t cds_message;
209 struct sir_dual_mac_config *req_msg;
210 uint32_t len;
211 struct sir_set_dual_mac_cfg *buf;
212 tSirMsgQ resp_msg;
213 struct sir_dual_mac_config_resp *param;
214
215 buf = (struct sir_set_dual_mac_cfg *) msg;
216 if (!buf) {
217 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
218 /* To free the active command list */
219 goto fail;
220 }
221
222 len = sizeof(*req_msg);
223
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530224 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 if (!req_msg) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700226 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 /* Free the active command list
228 * Probably the malloc is going to fail there as well?!
229 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530230 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 }
232
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530233 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234
235 req_msg->scan_config = buf->set_dual_mac.scan_config;
236 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
237 /* Other parameters are not needed for WMA */
238
239 cds_message.bodyptr = req_msg;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530240 cds_message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241
242 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530243 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 req_msg->scan_config, req_msg->fw_mode_config);
245 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530246 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700248 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530250 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251 goto fail;
252 }
253 return status;
254fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530255 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 if (!param) {
257 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530258 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 }
260 param->status = SET_HW_MODE_STATUS_ECANCELED;
261 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
262 resp_msg.bodyptr = param;
263 resp_msg.bodyval = 0;
264 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530265 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266}
267
268/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800269 * lim_process_set_antenna_mode_req() - Set antenna mode command
270 * to WMA
271 * @mac: Global MAC pointer
272 * @msg: Message containing the antenna mode parameter
273 *
274 * Send the set antenna mode command to WMA
275 *
276 * Return: QDF_STATUS_SUCCESS if message posting is successful
277 */
278static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
279 uint32_t *msg)
280{
281 QDF_STATUS status = QDF_STATUS_SUCCESS;
282 cds_msg_t cds_message;
283 struct sir_antenna_mode_param *req_msg;
284 struct sir_set_antenna_mode *buf;
285 tSirMsgQ resp_msg;
286 struct sir_antenna_mode_resp *param;
287
288 buf = (struct sir_set_antenna_mode *) msg;
289 if (!buf) {
290 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
291 /* To free the active command list */
292 goto fail;
293 }
294
295 req_msg = qdf_mem_malloc(sizeof(*req_msg));
296 if (!req_msg) {
297 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
298 return QDF_STATUS_E_NOMEM;
299 }
300
301 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
302 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
303
304 cds_message.bodyptr = req_msg;
305 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
306
307 lim_log(mac, LOG1,
308 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
309 req_msg->num_rx_chains,
310 req_msg->num_tx_chains);
311 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
312 if (!QDF_IS_STATUS_SUCCESS(status)) {
313 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700314 FL("cds_mq_post_message failed!(err=%d)"),
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800315 status);
316 qdf_mem_free(req_msg);
317 goto fail;
318 }
319 return status;
320fail:
321 param = qdf_mem_malloc(sizeof(*param));
322 if (!param) {
323 lim_log(mac, LOGE, FL("antenna mode resp failed"));
324 return QDF_STATUS_E_NOMEM;
325 }
326 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
327 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
328 resp_msg.bodyptr = param;
329 resp_msg.bodyval = 0;
330 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
331 return QDF_STATUS_SUCCESS;
332}
333
334/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
336 * @mac_ctx: Pointer to Global MAC structure
337 * @return_fresh_results: Trigger fresh scan.
338 *
339 * PE will do fresh scan, if all of the active sessions are in
340 * good state (Link Est or BSS Started). If one of the sessions
341 * is not in one of the above states, then PE does not do fresh
342 * scan. If no session exists (scanning very first time),
343 * then PE will always do fresh scan if SME asks it to do that.
344 *
345 * Return: true for fresh scan results, false if in invalid state.
346 */
347static uint8_t
348__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
349{
350 uint8_t valid_state = true;
351 int i;
352
353 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
354 mac_ctx->lim.gLimSmeState, return_fresh_results);
355
356 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
357 lim_log(mac_ctx, LOG1, FL("return FALSE"));
358 return false;
359 }
360
361 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700362
363 if (mac_ctx->lim.gpSession[i].valid == false)
364 continue;
365
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 lim_log(mac_ctx, LOG1,
367 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
368 i, mac_ctx->lim.gpSession[i].bssType,
369 mac_ctx->lim.gpSession[i].limSystemRole,
370 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700371
372 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
373 continue;
374
375 if (mac_ctx->lim.gpSession[i].bssType ==
376 eSIR_INFRASTRUCTURE_MODE &&
377 mac_ctx->lim.gpSession[i].limSmeState ==
378 eLIM_SME_LINK_EST_STATE)
379 continue;
380
381 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
382 mac_ctx->lim.gpSession[i].limSmeState ==
383 eLIM_SME_NORMAL_STATE)
384 continue;
385
386 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
387 mac_ctx->lim.gpSession[i].pePersona ==
388 QDF_P2P_GO_MODE &&
389 mac_ctx->lim.gpSession[i].limSmeState ==
390 eLIM_SME_NORMAL_STATE)
391 continue;
392
393 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
394 mac_ctx->lim.gpSession[i].limSmeState ==
395 eLIM_SME_NORMAL_STATE)
396 continue;
397
398 valid_state = false;
399 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400 }
401
402 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
403
404 if ((valid_state) &&
405 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
406 return true;
407 else
408 return false;
409}
410
411/**
412 * __lim_is_sme_assoc_cnf_valid()
413 *
414 ***FUNCTION:
415 * This function is called by __lim_process_sme_assoc_cnf_new() upon
416 * receiving SME_ASSOC_CNF.
417 *
418 ***LOGIC:
419 * Message validity checks are performed in this function
420 *
421 ***ASSUMPTIONS:
422 *
423 ***NOTE:
424 *
425 * @param pMeasReq Pointer to Received ASSOC_CNF message
426 * @return true When received SME_ASSOC_CNF is formatted
427 * correctly
428 * false otherwise
429 */
430
431static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
432{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530433 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 return false;
435 else
436 return true;
437} /*** end __lim_is_sme_assoc_cnf_valid() ***/
438
439/**
440 * __lim_get_sme_join_req_size_for_alloc()
441 *
442 ***FUNCTION:
443 * This function is called in various places to get IE length
444 * from tSirBssDescription structure
445 * number being scanned.
446 *
447 ***PARAMS:
448 *
449 ***LOGIC:
450 *
451 ***ASSUMPTIONS:
452 * NA
453 *
454 ***NOTE:
455 * NA
456 *
457 * @param pBssDescr
458 * @return Total IE length
459 */
460
461static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
462{
463 uint16_t len = 0;
464
465 if (!pBuf)
466 return len;
467
468 pBuf += sizeof(uint16_t);
469 len = lim_get_u16(pBuf);
470 return len + sizeof(uint16_t);
471}
472
473/**
474 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
475 * @pMac: Global MAC context
476 * @pMsg: Pointer to message posted from SME to LIM.
477 *
478 * Has role only if 11h is enabled. Not used on STA side.
479 * Defers the message if SME is in learn state and brings
480 * the LIM back to normal mode.
481 *
482 * Return: true - If defered false - Otherwise
483 */
484
485static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
486{
487 if (lim_is_system_in_scan_state(pMac)) {
488 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
489 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
490 pMsg->type);
491 return false;
492 }
493 lim_log(pMac, LOG1,
494 FL("Defer the message, in learn mode type = %d"),
495 pMsg->type);
496 return true;
497 }
498 return false;
499}
500
501/**
502 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
503 * @mac_ctx: Pointer to Global MAC structure
504 * @message: Pointer to message posted from SME to LIM.
505 *
506 * Has role only if 11h is enabled. Not used on STA side.
507 * Defers the message if radar is detected.
508 *
509 * Return: true, if defered otherwise return false.
510 */
511static bool
512__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
513{
514 /*
515 * fRadarDetCurOperChan will be set only if we
516 * detect radar in current operating channel and
517 * System Role == AP ROLE
518 *
519 * TODO: Need to take care radar detection.
520 *
521 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
522 */
523 if (0) {
524 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
525 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
526 message->type);
527 return false;
528 }
529 lim_log(mac_ctx, LOG1,
530 FL("Defer the message, in learn mode type = %d"),
531 message->type);
532 return true;
533 }
534 return false;
535}
536
537/**
538 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
539 * @pMac: Global MAC context
540 * @pMsgBuf: Message from WMA
541 *
542 * handles the notification from HDD. PE just forwards this message to HAL.
543 *
544 * Return: true-Posting to HAL failed, so PE will consume the buffer.
545 * false-Posting to HAL successful, so HAL will consume the buffer.
546 */
547
548static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
549{
550 tSirMsgQ msg;
551 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
552
553 msg.type = WMA_SYS_READY_IND;
554 msg.reserved = 0;
555 msg.bodyptr = pMsgBuf;
556 msg.bodyval = 0;
557
558 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800559 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700560 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
562 }
563 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
564 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
565
566 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
567 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
568 return true;
569 }
570 return false;
571}
572
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573/**
574 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
575 *@mac_ctx: Pointer to Global MAC structure
576 *@session: A pointer to session entry
577 *@sme_start_bss_req: Start BSS Request from upper layers.
578 *
579 * This function is used to configure the start bss parameters
580 * in to the session.
581 *
582 * Return: None.
583 */
584static void
585lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
586 tpSirSmeStartBssReq sme_start_bss_req)
587{
588 session->limSystemRole = eLIM_AP_ROLE;
589 session->privacy = sme_start_bss_req->privacy;
590 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
591 session->authType = sme_start_bss_req->authType;
592 /* Store the DTIM period */
593 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
594 /* Enable/disable UAPSD */
595 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530596 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 session->proxyProbeRspEn = 0;
598 } else {
599 /*
600 * To detect PBC overlap in SAP WPS mode,
601 * Host handles Probe Requests.
602 */
603 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
604 session->proxyProbeRspEn = 1;
605 else
606 session->proxyProbeRspEn = 0;
607 }
608 session->ssidHidden = sme_start_bss_req->ssidHidden;
609 session->wps_state = sme_start_bss_req->wps_state;
610 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530611 session->vendor_vht_sap =
612 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
614 &session->shortSlotTimeSupported);
615 session->isCoalesingInIBSSAllowed =
616 sme_start_bss_req->isCoalesingInIBSSAllowed;
617
618}
619
620/**
621 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
622 *@mac_ctx: Pointer to Global MAC structure
623 *@msg_buf: A pointer to the SME message buffer
624 *
625 * This function is called to process SME_START_BSS_REQ message
626 * from HDD or upper layer application.
627 *
628 * Return: None
629 */
630static void
631__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
632{
633 uint16_t size;
634 uint32_t val = 0;
635 tSirRetStatus ret_status;
636 tSirMacChanNum channel_number;
637 tLimMlmStartReq *mlm_start_req = NULL;
638 tpSirSmeStartBssReq sme_start_bss_req = NULL;
639 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
640 /* Flag Used in case of IBSS to Auto generate BSSID. */
641 uint32_t auto_gen_bssid = false;
642 uint8_t session_id;
643 tpPESession session = NULL;
644 uint8_t sme_session_id = 0;
645 uint16_t sme_transaction_id = 0;
646 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700647 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
649
650/* FEATURE_WLAN_DIAG_SUPPORT */
651#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
652 /*
653 * Since the session is not created yet, sending NULL.
654 * The response should have the correct state.
655 */
656 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
657 NULL, 0, 0);
658#endif /* FEATURE_WLAN_DIAG_SUPPORT */
659
660 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
661
662 /*
663 * Global Sme state and mlm states are not defined yet,
664 * for BT-AMP Suppoprt . TO BE DONE
665 */
666 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
667 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
668 size = sizeof(tSirSmeStartBssReq);
669
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530670 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 if (NULL == sme_start_bss_req) {
672 lim_log(mac_ctx, LOGE,
673 FL("Allocate Memory fail for LimStartBssReq"));
674 /* Send failure response to host */
675 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
676 goto end;
677 }
678
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530679 qdf_mem_set((void *)sme_start_bss_req, size, 0);
680 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 sizeof(tSirSmeStartBssReq));
682 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
683 sme_start_bss_req)) {
684 lim_log(mac_ctx, LOGW,
685 FL("Received invalid eWNI_SME_START_BSS_REQ"));
686 ret_code = eSIR_SME_INVALID_PARAMETERS;
687 goto free;
688 }
689
690 /*
691 * This is the place where PE is going to create a session.
692 * If session is not existed, then create a new session
693 */
694 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800695 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 if (session != NULL) {
697 lim_log(mac_ctx, LOGW,
698 FL("Session Already exists for given BSSID"));
699 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
700 session = NULL;
701 goto free;
702 } else {
703 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800704 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705 &session_id, mac_ctx->lim.maxStation,
706 sme_start_bss_req->bssType);
707 if (session == NULL) {
708 lim_log(mac_ctx, LOGW,
709 FL("Session Can not be created "));
710 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
711 goto free;
712 }
713 }
714
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700715 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
716 /* Probe resp add ie */
717 lim_start_bss_update_add_ie_buffer(mac_ctx,
718 &session->addIeParams.probeRespData_buff,
719 &session->addIeParams.probeRespDataLen,
720 sme_start_bss_req->addIeParams.
721 probeRespData_buff,
722 sme_start_bss_req->addIeParams.
723 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700725 /* Probe Beacon add ie */
726 lim_start_bss_update_add_ie_buffer(mac_ctx,
727 &session->addIeParams.probeRespBCNData_buff,
728 &session->addIeParams.probeRespBCNDataLen,
729 sme_start_bss_req->addIeParams.
730 probeRespBCNData_buff,
731 sme_start_bss_req->addIeParams.
732 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700734 /* Assoc resp IE */
735 lim_start_bss_update_add_ie_buffer(mac_ctx,
736 &session->addIeParams.assocRespData_buff,
737 &session->addIeParams.assocRespDataLen,
738 sme_start_bss_req->addIeParams.
739 assocRespData_buff,
740 sme_start_bss_req->addIeParams.
741 assocRespDataLen);
742 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 /* Store the session related params in newly created session */
744 session->pLimStartBssReq = sme_start_bss_req;
745
746 /* Store PE session_id in session Table */
747 session->peSessionId = session_id;
748
749 /* Store SME session Id in sessionTable */
750 session->smeSessionId = sme_start_bss_req->sessionId;
751
752 session->transactionId = sme_start_bss_req->transactionId;
753
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530754 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 &(sme_start_bss_req->htConfig),
756 sizeof(session->htConfig));
757
Sandeep Puligilla98917432016-06-10 13:50:28 -0700758 qdf_mem_copy(&(session->vht_config),
759 &(sme_start_bss_req->vht_config),
760 sizeof(session->vht_config));
761
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800763 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764
765 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530766 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767 (uint8_t *) &sme_start_bss_req->ssId,
768 (sme_start_bss_req->ssId.length + 1));
769
770 session->bssType = sme_start_bss_req->bssType;
771
772 session->nwType = sme_start_bss_req->nwType;
773
774 session->beaconParams.beaconInterval =
775 sme_start_bss_req->beaconInterval;
776
777 /* Store the channel number in session Table */
778 session->currentOperChannel =
779 sme_start_bss_req->channelId;
780
781 /* Store Persona */
782 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530783 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 FL("PE PERSONA=%d"), session->pePersona);
785
786 /* Update the phymode */
787 session->gLimPhyMode = sme_start_bss_req->nwType;
788
789 session->maxTxPower =
790 cfg_get_regulatory_max_transmit_power(mac_ctx,
791 session->currentOperChannel);
792 /* Store the dot 11 mode in to the session Table */
793 session->dot11mode = sme_start_bss_req->dot11mode;
794#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
795 session->cc_switch_mode =
796 sme_start_bss_req->cc_switch_mode;
797#endif
798 session->htCapability =
799 IS_DOT11_MODE_HT(session->dot11mode);
800 session->vhtCapability =
801 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530802 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 FL("*****session->vhtCapability = %d"),
804 session->vhtCapability);
805 session->txLdpcIniFeatureEnabled =
806 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807#ifdef WLAN_FEATURE_11W
808 session->limRmfEnabled =
809 sme_start_bss_req->pmfCapable ? 1 : 0;
810 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
811 session->limRmfEnabled);
812#endif
813
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530814 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 (void *)&sme_start_bss_req->operationalRateSet,
816 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530817 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 (void *)&sme_start_bss_req->extendedRateSet,
819 sizeof(tSirMacRateSet));
820
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700821 if (IS_5G_CH(session->currentOperChannel))
822 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
823 else
824 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
825
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 switch (sme_start_bss_req->bssType) {
827 case eSIR_INFRA_AP_MODE:
828 lim_configure_ap_start_bss_session(mac_ctx, session,
829 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700830 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700831 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700832 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700833 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 break;
835 case eSIR_IBSS_MODE:
836 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
837 lim_get_short_slot_from_phy_mode(mac_ctx, session,
838 session->gLimPhyMode,
839 &session->shortSlotTimeSupported);
840
841 /*
842 * initialize to "OPEN".
843 * will be updated upon key installation
844 */
845 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700846 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
848 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700849 case eSIR_NDI_MODE:
850 session->limSystemRole = eLIM_NDI_ROLE;
851 break;
852
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 /*
855 * There is one more mode called auto mode.
856 * which is used no where
857 */
858
859 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
860
861 default:
862 /* not used anywhere...used in scan function */
863 break;
864 }
865
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700866 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
867 session->pePersona, session->vdev_nss);
868 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700870 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 * parsed (Re)Assoc request structure
872 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700873 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530875 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700876 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 if (NULL == session->parsedAssocReq) {
878 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700879 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
881 goto free;
882 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530883 qdf_mem_set(session->parsedAssocReq,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700884 (session->dph.dphHashTable.size *
885 sizeof(tpSirAssocReq)), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 }
887
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700888 if (!sme_start_bss_req->channelId &&
889 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 lim_log(mac_ctx, LOGE,
891 FL("Received invalid eWNI_SME_START_BSS_REQ"));
892 ret_code = eSIR_SME_INVALID_PARAMETERS;
893 goto free;
894 }
895 channel_number = sme_start_bss_req->channelId;
896#ifdef QCA_HT_2040_COEX
897 if (sme_start_bss_req->obssEnabled)
898 session->htSupportedChannelWidthSet =
899 session->htCapability;
900 else
901#endif
902 session->htSupportedChannelWidthSet =
903 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
904 session->htSecondaryChannelOffset =
905 sme_start_bss_req->sec_ch_offset;
906 session->htRecommendedTxWidthSet =
907 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530908 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 FL("cbMode %u"), sme_start_bss_req->cbMode);
910 if (session->vhtCapability || session->htCapability) {
911 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800912 lim_log(mac_ctx, LOG1,
913 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
914 sme_start_bss_req->vht_channel_width,
915 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 session->ch_width = chanwidth;
917 if (session->htSupportedChannelWidthSet) {
918 session->ch_center_freq_seg0 =
919 sme_start_bss_req->center_freq_seg0;
920 session->ch_center_freq_seg1 =
921 sme_start_bss_req->center_freq_seg1;
922 } else {
923 session->ch_center_freq_seg0 = 0;
924 session->ch_center_freq_seg1 = 0;
925 }
926 }
927
928 if (session->vhtCapability &&
Krunal Soni53993f72016-07-08 18:20:03 -0700929 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 session->nss = 1;
Krunal Soni53993f72016-07-08 18:20:03 -0700931 lim_log(mac_ctx, LOG1, FL("nss set to [%d]"),
932 session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 }
Krunal Soni53993f72016-07-08 18:20:03 -0700934 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"),
935 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936
937 /* Delete pre-auth list if any */
938 lim_delete_pre_auth_list(mac_ctx);
939
Krunal Soni53993f72016-07-08 18:20:03 -0700940 if (session->nss == 1) {
941 session->vht_config.su_beam_former = 0;
942 session->vht_config.tx_stbc = 0;
943 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530944 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700945 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 /*
947 * keep the RSN/WPA IE information in PE Session Entry
948 * later will be using this to check when received (Re)Assoc req
949 */
950 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
951 &sme_start_bss_req->rsnIE, session);
952
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700953 if (LIM_IS_AP_ROLE(session) ||
954 LIM_IS_IBSS_ROLE(session) ||
955 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 session->gLimProtectionControl =
957 sme_start_bss_req->protEnabled;
958 /*
959 * each byte will have the following info
960 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
961 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
962 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530963 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 (void *)&sme_start_bss_req->ht_capab,
965 sizeof(uint16_t));
966 /* Initialize WPS PBC session link list */
967 session->pAPWPSPBCSession = NULL;
968 }
969 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530970 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 if (NULL == mlm_start_req) {
972 lim_log(mac_ctx, LOGP,
973 FL("Allocate Memory failed for mlmStartReq"));
974 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
975 goto free;
976 }
977
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530978 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979
980 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530981 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 (uint8_t *) &sme_start_bss_req->ssId,
983 sme_start_bss_req->ssId.length + 1);
984 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
985 mlm_start_req->obssProtEnabled =
986 sme_start_bss_req->obssProtEnabled;
987
988 mlm_start_req->bssType = session->bssType;
989
990 /* Fill PE session Id from the session Table */
991 mlm_start_req->sessionId = session->peSessionId;
992
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700993 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
994 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 /*
996 * Copy the BSSId from sessionTable to
997 * mlmStartReq struct
998 */
999 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
1000 } else {
1001 /* ibss mode */
1002 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1003
1004 ret_status = wlan_cfg_get_int(mac_ctx,
1005 WNI_CFG_IBSS_AUTO_BSSID,
1006 &auto_gen_bssid);
1007 if (ret_status != eSIR_SUCCESS) {
1008 lim_log(mac_ctx, LOGP,
1009 FL("Get Auto Gen BSSID fail,Status=%d"),
1010 ret_status);
1011 ret_code = eSIR_LOGP_EXCEPTION;
1012 goto free;
1013 }
1014
1015 if (!auto_gen_bssid) {
1016 /*
1017 * We're not auto generating BSSID.
1018 * Instead, get it from session entry
1019 */
1020 sir_copy_mac_addr(mlm_start_req->bssId,
1021 session->bssId);
1022 /*
1023 * Start IBSS group BSSID
1024 * Auto Generating BSSID.
1025 */
1026 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1027 0x01) ? true : false);
1028 }
1029
1030 if (auto_gen_bssid) {
1031 /*
1032 * if BSSID is not any uc id.
1033 * then use locally generated BSSID.
1034 * Autogenerate the BSSID
1035 */
1036 lim_get_random_bssid(mac_ctx,
1037 mlm_start_req->bssId);
1038 mlm_start_req->bssId[0] = 0x02;
1039
1040 /*
1041 * Copy randomly generated BSSID
1042 * to the session Table
1043 */
1044 sir_copy_mac_addr(session->bssId,
1045 mlm_start_req->bssId);
1046 }
1047 }
1048 /* store the channel num in mlmstart req structure */
1049 mlm_start_req->channelNumber = session->currentOperChannel;
1050 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1051 mlm_start_req->beaconPeriod =
1052 session->beaconParams.beaconInterval;
1053
1054 if (LIM_IS_AP_ROLE(session)) {
1055 mlm_start_req->dtimPeriod = session->dtimPeriod;
1056 mlm_start_req->wps_state = session->wps_state;
1057
1058 } else {
1059 if (wlan_cfg_get_int(mac_ctx,
1060 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1061 lim_log(mac_ctx, LOGP,
1062 FL("could not retrieve DTIM Period"));
1063 mlm_start_req->dtimPeriod = (uint8_t) val;
1064 }
1065
1066 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1067 eSIR_SUCCESS)
1068 lim_log(mac_ctx, LOGP,
1069 FL("could not retrieve Beacon interval"));
1070 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1071
1072 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1073 eSIR_SUCCESS)
1074 lim_log(mac_ctx, LOGP,
1075 FL("could not retrieve CFPMaxDuration"));
1076 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1077
1078 /*
1079 * this may not be needed anymore now,
1080 * as rateSet is now included in the
1081 * session entry and MLM has session context.
1082 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301083 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 (void *)&session->rateSet,
1085 sizeof(tSirMacRateSet));
1086
1087 /* Now populate the 11n related parameters */
1088 mlm_start_req->nwType = session->nwType;
1089 mlm_start_req->htCapable = session->htCapability;
1090
1091 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1092 /* Unused */
1093 mlm_start_req->dualCTSProtection =
1094 mac_ctx->lim.gHTDualCTSProtection;
1095 mlm_start_req->txChannelWidthSet =
1096 session->htRecommendedTxWidthSet;
1097
1098 session->limRFBand = lim_get_rf_band(channel_number);
1099
1100 /* Initialize 11h Enable Flag */
1101 session->lim11hEnable = 0;
1102 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1103 (SIR_BAND_5_GHZ == session->limRFBand)) {
1104 if (wlan_cfg_get_int(mac_ctx,
1105 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1106 lim_log(mac_ctx, LOGP,
1107 FL("Fail to get WNI_CFG_11H_ENABLED "));
1108 else
1109 session->lim11hEnable = val;
1110
1111 if (session->lim11hEnable &&
1112 (eSIR_INFRA_AP_MODE ==
1113 mlm_start_req->bssType)) {
1114 cfg_get_wmi_dfs_master_param =
1115 wlan_cfg_get_int(mac_ctx,
1116 WNI_CFG_DFS_MASTER_ENABLED,
1117 &val);
1118 session->lim11hEnable = val;
1119 }
1120 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1121 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1122 lim_log(mac_ctx, LOGE,
1123 FL("Get Fail, CFG DFS ENABLE"));
1124 }
1125
1126 if (!session->lim11hEnable) {
1127 if (cfg_set_int(mac_ctx,
1128 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1129 eSIR_SUCCESS)
1130 /*
1131 * Failed to set the CFG param
1132 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1133 */
1134 lim_log(mac_ctx, LOGE,
1135 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1136 }
1137
1138 session->limPrevSmeState = session->limSmeState;
1139 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1140 MTRACE(mac_trace
1141 (mac_ctx, TRACE_CODE_SME_STATE,
1142 session->peSessionId,
1143 session->limSmeState));
1144
1145 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1146 (uint32_t *) mlm_start_req);
1147 return;
1148 } else {
1149
1150 lim_log(mac_ctx, LOGE,
1151 FL("Received unexpected START_BSS_REQ, in state %X"),
1152 mac_ctx->lim.gLimSmeState);
1153 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1154 goto end;
1155 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1156
1157free:
1158 if ((session != NULL) &&
1159 (session->pLimStartBssReq == sme_start_bss_req)) {
1160 session->pLimStartBssReq = NULL;
1161 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301162 qdf_mem_free(sme_start_bss_req);
1163 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164
1165end:
1166 if (sme_start_bss_req != NULL) {
1167 sme_session_id = sme_start_bss_req->sessionId;
1168 sme_transaction_id = sme_start_bss_req->transactionId;
1169 }
1170 if (NULL != session) {
1171 pe_delete_session(mac_ctx, session);
1172 session = NULL;
1173 }
1174 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1175 session, sme_session_id, sme_transaction_id);
1176}
1177
1178/**
1179 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1180 *
1181 * @pMac: Global MAC context
1182 * @pMsg: Message pointer
1183 *
1184 * Wrapper for the function __lim_handle_sme_start_bss_request
1185 * This message will be defered until softmac come out of
1186 * scan mode or if we have detected radar on the current
1187 * operating channel.
1188 *
1189 * return true - If we consumed the buffer
1190 * false - If have defered the message.
1191 */
1192static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1193{
1194 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1195 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1196 /**
1197 * If message defered, buffer is not consumed yet.
1198 * So return false
1199 */
1200 return false;
1201 }
1202
1203 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1204 return true;
1205}
1206
1207/**
1208 * lim_get_random_bssid()
1209 *
1210 * FUNCTION:This function is called to process generate the random number for bssid
1211 * This function is called to process SME_SCAN_REQ message
1212 * from HDD or upper layer application.
1213 *
1214 * LOGIC:
1215 *
1216 * ASSUMPTIONS:
1217 *
1218 * NOTE:
1219 * 1. geneartes the unique random number for bssid in ibss
1220 *
1221 * @param pMac Pointer to Global MAC structure
1222 * @param *data Pointer to bssid buffer
1223 * @return None
1224 */
1225void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1226{
1227 uint32_t random[2];
1228 random[0] = tx_time_get();
1229 random[0] |= (random[0] << 15);
1230 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301231 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232}
1233
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301234static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 tpSirSmeScanReq pScanReq)
1236{
1237 tSirScanOffloadReq *pScanOffloadReq;
1238 uint8_t *p;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 tSirMsgQ msg;
1240 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001241 uint16_t addn_ie_len = 0;
Naveen Rawat02e12662016-08-31 16:49:27 -07001242 uint8_t *vendor_tpc_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 tSirRetStatus status, rc = eSIR_SUCCESS;
1244 tDot11fIEExtCap extracted_extcap = {0};
1245 bool extcap_present = true;
Naveen Rawat02e12662016-08-31 16:49:27 -07001246 uint32_t lim_11h_enable = WNI_CFG_11H_ENABLED_STADEF;
1247
1248 wlan_cfg_get_int(pMac, WNI_CFG_11H_ENABLED, &lim_11h_enable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249
1250 if (pScanReq->uIEFieldLen) {
1251 status = lim_strip_extcap_update_struct(pMac,
1252 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1253 &pScanReq->uIEFieldLen, &extracted_extcap);
1254
1255 if (eSIR_SUCCESS != status) {
1256 extcap_present = false;
1257 lim_log(pMac, LOG1,
1258 FL("Unable to Strip ExtCap IE from Scan Req"));
1259 }
1260
1261 if (extcap_present) {
1262 lim_log(pMac, LOG1,
1263 FL("Extcap was part of SCAN IE - Updating FW"));
1264 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1265 &extracted_extcap, true);
1266 }
1267 } else {
1268 lim_log(pMac, LOG1,
1269 FL("No IEs in the scan request from supplicant"));
1270 }
1271
1272 /**
1273 * The tSirScanOffloadReq will reserve the space for first channel,
1274 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1275 */
1276 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001277 (pScanReq->channelList.numChannels - 1) +
1278 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001279
1280 if (lim_11h_enable) {
1281 addn_ie_len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1282 len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1283 }
1284
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301285 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 if (NULL == pScanOffloadReq) {
1287 lim_log(pMac, LOGE,
1288 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301289 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 }
1291
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301292 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293
1294 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1295 msg.bodyptr = pScanOffloadReq;
1296 msg.bodyval = 0;
1297
Anurag Chouhanc5548422016-02-24 18:33:27 +05301298 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299
1300 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1301 lim_log(pMac, LOGE,
1302 FL("Invalid value (%d) for numSsid"),
1303 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301304 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301305 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 }
1307
1308 pScanOffloadReq->numSsid = pScanReq->numSsid;
1309 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1310 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301311 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 (uint8_t *) pScanReq->ssId[i].ssId,
1313 pScanOffloadReq->ssId[i].length);
1314 }
1315
1316 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301317 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 pScanOffloadReq->bssType = pScanReq->bssType;
1319 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1320 pScanOffloadReq->scanType = pScanReq->scanType;
1321 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1322 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1323 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301324 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1325 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301326 pScanOffloadReq->scan_adaptive_dwell_mode =
1327 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328
1329 /* for normal scan, the value for p2pScanType should be 0
1330 always */
1331 if (pScanReq->p2pSearch)
1332 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1333
1334 pScanOffloadReq->sessionId = pScanReq->sessionId;
1335 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001336 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301337 pScanOffloadReq->scan_adaptive_dwell_mode =
1338 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
1340 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1341 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1342 pScanOffloadReq->sessionId);
1343
1344 pScanOffloadReq->channelList.numChannels =
1345 pScanReq->channelList.numChannels;
1346 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1347 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1348 p[i] = pScanReq->channelList.channelNumber[i];
1349
1350 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1351 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1352 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301353 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 pScanOffloadReq->uIEFieldOffset,
1355 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1356 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001357
1358 if (lim_11h_enable) {
1359 tDot11fIEWFATPC wfa_tpc;
1360 vendor_tpc_ie = (uint8_t *) pScanOffloadReq +
1361 pScanOffloadReq->uIEFieldOffset +
1362 pScanOffloadReq->uIEFieldLen;
1363 populate_dot11f_wfatpc(pMac, &wfa_tpc,
1364 rrm_get_mgmt_tx_power(pMac, NULL), 0);
1365 vendor_tpc_ie[0] = DOT11F_EID_WFATPC;
1366 vendor_tpc_ie[1] = DOT11F_IE_WFATPC_MAX_LEN;
1367 qdf_mem_copy(&vendor_tpc_ie[2], SIR_MAC_WFA_TPC_OUI,
1368 SIR_MAC_WFA_TPC_OUI_SIZE);
1369 qdf_mem_copy(&vendor_tpc_ie[SIR_MAC_WFA_TPC_OUI_SIZE + 2],
1370 ((uint8_t *)&wfa_tpc) + 1,
1371 DOT11F_IE_WFATPC_MAX_LEN - SIR_MAC_WFA_TPC_OUI_SIZE);
1372 pScanOffloadReq->uIEFieldLen += DOT11F_IE_WFATPC_MAX_LEN + 2;
1373 }
1374
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 rc = wma_post_ctrl_msg(pMac, &msg);
1376 if (rc != eSIR_SUCCESS) {
1377 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301378 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301379 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 }
1381
1382 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1383
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301384 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385}
1386
1387/**
1388 * __lim_process_sme_scan_req() - Process the SME Scan Request
1389 * @mac_ctx: Global MAC Context
1390 * @msg_buf: Buffer which contains the request and pertinent parameters
1391 *
1392 * This function is called to process SME_SCAN_REQ message
1393 * from HDD or upper layer application.
1394 *
1395 * Return: None
1396 */
1397
1398static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1399 uint32_t *msg_buf)
1400{
1401 tpSirSmeScanReq scan_req;
1402 uint8_t valid_req = 0;
1403
1404#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1405 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1406 eSIR_SUCCESS, eSIR_SUCCESS);
1407#endif
1408
1409 scan_req = (tpSirSmeScanReq) msg_buf;
1410 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301411 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 -08001412 scan_req->scan_id, scan_req->channelList.numChannels,
1413 scan_req->minChannelTime, scan_req->maxChannelTime,
1414 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1415 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301416 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1418 /*
1419 * Since scan req always requires a response, we will overwrite response
1420 * required here. This is added esp to take care of the condition where
1421 * in p2p go case, we hold the scan req and insert single NOA. We send
1422 * the held scan request to FW later on getting start NOA ind from FW so
1423 * we lose state of the gLimRspReqd flag for the scan req if any other
1424 * request comes by then. e.g. While unit testing, we found when insert
1425 * single NOA is done, we see a get stats request which turns the flag
1426 * gLimRspReqd to false; now when we actually start the saved scan req
1427 * for init scan after getting NOA started, the gLimRspReqd being a
1428 * global flag is showing false instead of true value for this saved
1429 * scan req. Since all scan reqs coming to lim require a response,
1430 * there is no harm in setting the global flag gLimRspReqd to true here.
1431 */
1432 mac_ctx->lim.gLimRspReqd = true;
1433
1434 /*
1435 * copy the Self MAC address from SmeReq to the globalplace,
1436 * used for sending probe req
1437 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001438 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1439 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1441
1442 if (!valid_req || mac_ctx->lim.scan_disabled) {
1443 lim_log(mac_ctx, LOGE,
1444 FL("Scan disabled %d, Valid Scan Req %d"),
1445 mac_ctx->lim.scan_disabled, valid_req);
1446
1447 if (mac_ctx->lim.gLimRspReqd) {
1448 mac_ctx->lim.gLimRspReqd = false;
1449
1450 lim_send_sme_scan_rsp(mac_ctx,
1451 eSIR_SME_INVALID_PARAMETERS,
1452 scan_req->sessionId,
1453 scan_req->transactionId,
1454 scan_req->scan_id);
1455 }
1456 return;
1457 }
1458
1459 /*
1460 * If scan request is received in idle, joinFailed
1461 * states or in link established state (in STA role)
1462 * or in normal state (in STA-in-IBSS/AP role) with
1463 * 'return fresh scan results' request from HDD or
1464 * it is periodic background scanning request,
1465 * trigger fresh scan request to MLM
1466 */
1467 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1468
1469 mac_ctx->lim.gLim24Band11dScanDone = 0;
1470 mac_ctx->lim.gLim50Band11dScanDone = 0;
1471 mac_ctx->lim.gLimReturnAfterFirstMatch =
1472 scan_req->returnAfterFirstMatch;
1473 mac_ctx->lim.gLimReturnUniqueResults =
1474 ((scan_req->returnUniqueResults) > 0 ? true : false);
1475
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301476 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001477 lim_send_hal_start_scan_offload_req(mac_ctx,
1478 scan_req)) {
1479 lim_log(mac_ctx, LOGE, FL(
1480 "Couldn't send Offload scan request"));
1481 lim_send_sme_scan_rsp(mac_ctx,
1482 eSIR_SME_INVALID_PARAMETERS,
1483 scan_req->sessionId,
1484 scan_req->transactionId,
1485 scan_req->scan_id);
1486 return;
1487 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301488 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 /* In all other cases return 'cached' scan results */
1490 if (mac_ctx->lim.gLimRspReqd) {
1491 mac_ctx->lim.gLimRspReqd = false;
1492 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1493 scan_req->sessionId,
1494 scan_req->transactionId, scan_req->scan_id);
1495 }
1496 }
1497}
1498
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499/**
1500 * __lim_process_clear_dfs_channel_list()
1501 *
1502 ***FUNCTION:
1503 ***Clear DFS channel list when country is changed/aquired.
1504 .*This message is sent from SME.
1505 *
1506 ***LOGIC:
1507 *
1508 ***ASSUMPTIONS:
1509 *
1510 ***NOTE:
1511 *
1512 * @param pMac Pointer to Global MAC structure
1513 * @param *pMsgBuf A pointer to the SME message buffer
1514 * @return None
1515 */
1516static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1517{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301518 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519}
1520
1521/**
1522 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1523 * @mac_ctx: Pointer to Global MAC structure
1524 * @msg_buf: A pointer to the SME message buffer
1525 *
1526 * This function is called to process SME_JOIN_REQ message
1527 * from HDD or upper layer application.
1528 *
1529 * Return: None
1530 */
1531static void
1532__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1533{
1534 tpSirSmeJoinReq sme_join_req = NULL;
1535 tLimMlmJoinReq *mlm_join_req;
1536 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1537 uint32_t val = 0;
1538 uint16_t n_size;
1539 uint8_t session_id;
1540 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301541 uint8_t sme_session_id = 0;
1542 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001543 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 uint16_t ie_len;
1545 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001546 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001547 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548
Arif Hussain995fcaf2016-07-18 11:28:22 -07001549 if (!mac_ctx || !msg_buf) {
1550 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1551 FL("JOIN REQ with invalid data"));
1552 return;
1553 }
1554
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555/* FEATURE_WLAN_DIAG_SUPPORT */
1556#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1557 /*
1558 * Not sending any session, since it is not created yet.
1559 * The response whould have correct state.
1560 */
1561 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1562#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1563
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 /*
1565 * Expect Join request in idle state.
1566 * Reassociate request is expected in link established state.
1567 */
1568
1569 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1570 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1571 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1572 msg_buf);
1573
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301574 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 if (NULL == sme_join_req) {
1576 lim_log(mac_ctx, LOGP,
1577 FL("AllocateMemory failed for sme_join_req"));
1578 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301579 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1582 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 n_size);
1584
1585 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1586 /* Received invalid eWNI_SME_JOIN_REQ */
1587 /* Log the event */
1588 lim_log(mac_ctx, LOGW,
1589 FL("SessionId:%d JOIN REQ with invalid data"),
1590 sme_join_req->sessionId);
1591 ret_code = eSIR_SME_INVALID_PARAMETERS;
1592 goto end;
1593 }
1594
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001595 /*
1596 * Update the capability here itself as this is used in
1597 * lim_extract_ap_capability() below. If not updated issues
1598 * like not honoring power constraint on 1st association after
1599 * driver loading might occur.
1600 */
1601 lim_update_rrm_capability(mac_ctx, sme_join_req);
1602
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001603 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001605 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 &session_id);
1607
1608 if (session != NULL) {
1609 lim_log(mac_ctx, LOGE,
1610 FL("Session(%d) Already exists for BSSID: "
1611 MAC_ADDRESS_STR " in limSmeState = %X"),
1612 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001613 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 session->limSmeState);
1615
1616 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1617 session->smeSessionId == sme_join_req->sessionId) {
1618 /*
1619 * Received eWNI_SME_JOIN_REQ for same
1620 * BSS as currently associated.
1621 * Log the event and send success
1622 */
1623 lim_log(mac_ctx, LOGW,
1624 FL("SessionId: %d"), session_id);
1625 lim_log(mac_ctx, LOGW,
1626 FL("JOIN_REQ for current joined BSS"));
1627 /* Send Join success response to host */
1628 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1629 session = NULL;
1630 goto end;
1631 } else {
1632 lim_log(mac_ctx, LOGE,
1633 FL("JOIN_REQ not for current joined BSS"));
1634 ret_code = eSIR_SME_REFUSED;
1635 session = NULL;
1636 goto end;
1637 }
1638 } else {
1639 /*
1640 * Session Entry does not exist for given BSSId
1641 * Try to Create a new session
1642 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001643 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 &session_id, mac_ctx->lim.maxStation,
1645 eSIR_INFRASTRUCTURE_MODE);
1646 if (session == NULL) {
1647 lim_log(mac_ctx, LOGE,
1648 FL("Session Can not be created "));
1649 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1650 goto end;
1651 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301652 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 FL("SessionId:%d New session created"),
1654 session_id);
1655 }
1656 session->isAmsduSupportInAMPDU =
1657 sme_join_req->isAmsduSupportInAMPDU;
1658
1659 /*
1660 * Store Session related parameters
1661 * Store PE session Id in session Table
1662 */
1663 session->peSessionId = session_id;
1664
1665 /* store the smejoin req handle in session table */
1666 session->pLimJoinReq = sme_join_req;
1667
1668 /* Store SME session Id in sessionTable */
1669 session->smeSessionId = sme_join_req->sessionId;
1670
1671 /* Store SME transaction Id in session Table */
1672 session->transactionId = sme_join_req->transactionId;
1673
1674 /* Store beaconInterval */
1675 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001676 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301678 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 sizeof(session->htConfig));
1680
Sandeep Puligilla98917432016-06-10 13:50:28 -07001681 qdf_mem_copy(&(session->vht_config),
1682 &(sme_join_req->vht_config),
1683 sizeof(session->vht_config));
1684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 /* Copying of bssId is already done, while creating session */
1686 sir_copy_mac_addr(session->selfMacAddr,
1687 sme_join_req->selfMacAddr);
1688 session->bssType = sme_join_req->bsstype;
1689
1690 session->statypeForBss = STA_ENTRY_PEER;
1691 session->limWmeEnabled = sme_join_req->isWMEenabled;
1692 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301693 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694
1695 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001696 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1698
1699 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1700 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001701 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702
1703 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001704 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 session->isCiscoVendorAP = true;
1706 } else {
1707 session->isCiscoVendorAP = false;
1708 }
1709
1710 /* Copy the dot 11 mode in to the session table */
1711
1712 session->dot11mode = sme_join_req->dot11mode;
1713#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1714 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1715#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001716 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1718 session->enableHtSmps = sme_join_req->enableHtSmps;
1719 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001720 session->send_smps_action =
1721 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001722 /*
1723 * By default supported NSS 1x1 is set to true
1724 * and later on updated while determining session
1725 * supported rates which is the intersection of
1726 * self and peer rates
1727 */
1728 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301729 /*Store Persona */
1730 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001731 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301732 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001733 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001734 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001735 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301736 session->supported_nss_1x1,
1737 session->pePersona,
1738 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001739
1740 /*Store Persona */
1741 session->pePersona = sme_join_req->staPersona;
1742 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1743 FL("PE PERSONA=%d cbMode %u"),
1744 session->pePersona, sme_join_req->cbMode);
1745 /* Copy The channel Id to the session Table */
1746 session->currentOperChannel = bss_desc->channelId;
1747 if (IS_5G_CH(session->currentOperChannel))
1748 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001750 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1751 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1752 session->vdev_nss = vdev_type_nss->p2p_cli;
1753 else
1754 session->vdev_nss = vdev_type_nss->sta;
1755 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 session->vhtCapability =
1757 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301759 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001760 session->vht_config.su_beam_formee =
1761 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001763 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 session->enableVhtpAid =
1766 sme_join_req->enableVhtpAid;
1767 session->enableVhtGid =
1768 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001769 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1770 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 }
Krunal Soni53993f72016-07-08 18:20:03 -07001772
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301773 lim_log(mac_ctx, LOG1,
Krunal Soni53993f72016-07-08 18:20:03 -07001774 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301775 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001776 session->vht_config.su_beam_formee,
1777 session->vht_config.csnof_beamformer_antSup,
1778 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001780 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 /* cbMode is already merged value of peer and self -
1783 * done by csr in csr_get_cb_mode_from_ies */
1784 session->htSupportedChannelWidthSet =
1785 (sme_join_req->cbMode) ? 1 : 0;
1786 session->htRecommendedTxWidthSet =
1787 session->htSupportedChannelWidthSet;
1788 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1789
1790 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1791 session->ch_center_freq_seg0 =
1792 session->currentOperChannel - 2;
1793 session->ch_width = CH_WIDTH_40MHZ;
1794 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1795 sme_join_req->cbMode) {
1796 session->ch_center_freq_seg0 =
1797 session->currentOperChannel + 2;
1798 session->ch_width = CH_WIDTH_40MHZ;
1799 } else {
1800 session->ch_center_freq_seg0 = 0;
1801 session->ch_width = CH_WIDTH_20MHZ;
1802 }
1803
1804 /* Record if management frames need to be protected */
1805#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001806 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001808 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810#endif
1811
1812#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001813 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814#endif
1815
1816 /* Copy the SSID from smejoinreq to session entry */
1817 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301818 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 session->ssId.length);
1820
1821 /*
1822 * Determin 11r or ESE connection based on input from SME
1823 * which inturn is dependent on the profile the user wants
1824 * to connect to, So input is coming from supplicant
1825 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827#ifdef FEATURE_WLAN_ESE
1828 session->isESEconnection = sme_join_req->isESEconnection;
1829#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 session->isFastTransitionEnabled =
1831 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 session->isFastRoamIniFeatureEnabled =
1834 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 session->txLdpcIniFeatureEnabled =
1836 sme_join_req->txLdpcIniFeatureEnabled;
1837
1838 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1839 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 } else {
1841 /*
1842 * Throw an error and return and make
1843 * sure to delete the session.
1844 */
1845 lim_log(mac_ctx, LOGE,
1846 FL("recvd JOIN_REQ with invalid bss type %d"),
1847 session->bssType);
1848 ret_code = eSIR_SME_INVALID_PARAMETERS;
1849 goto end;
1850 }
1851
1852 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301853 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 &sme_join_req->addIEScan, sizeof(tSirAddie));
1855
1856 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301857 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1859
1860 val = sizeof(tLimMlmJoinReq) +
1861 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301862 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863 if (NULL == mlm_join_req) {
1864 lim_log(mac_ctx, LOGP,
1865 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301866 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1867 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301869 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870
1871 /* PE SessionId is stored as a part of JoinReq */
1872 mlm_join_req->sessionId = session->peSessionId;
1873
1874 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1875 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1876 eSIR_SUCCESS) {
1877 lim_log(mac_ctx, LOGP,
1878 FL("couldn't retrieve JoinFailureTimer value"
1879 " setting to default value"));
1880 mlm_join_req->joinFailureTimeout =
1881 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1882 }
1883
1884 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301885 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 (void *)&sme_join_req->operationalRateSet,
1887 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301888 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 (void *)&sme_join_req->extendedRateSet,
1890 sizeof(tSirMacRateSet));
1891 /*
1892 * this may not be needed anymore now, as rateSet is now
1893 * included in the session entry and MLM has session context.
1894 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301895 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 (void *)&session->rateSet,
1897 sizeof(tSirMacRateSet));
1898
1899 session->encryptType = sme_join_req->UCEncryptionType;
1900
1901 mlm_join_req->bssDescription.length =
1902 session->pLimJoinReq->bssDescription.length;
1903
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301904 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905 (uint8_t *)
1906 &session->pLimJoinReq->bssDescription.bssId,
1907 session->pLimJoinReq->bssDescription.length + 2);
1908
1909 session->limCurrentBssCaps =
1910 session->pLimJoinReq->bssDescription.capabilityInfo;
1911
1912 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1913 session->currentOperChannel);
1914 local_power_constraint = reg_max;
1915
1916 lim_extract_ap_capability(mac_ctx,
1917 (uint8_t *)
1918 session->pLimJoinReq->bssDescription.ieFields,
1919 lim_get_ielen_from_bss_description(
1920 &session->pLimJoinReq->bssDescription),
1921 &session->limCurrentBssQosCaps,
1922 &session->limCurrentBssPropCap,
1923 &session->gLimCurrentBssUapsd,
1924 &local_power_constraint, session);
1925
Krunal Soni53993f72016-07-08 18:20:03 -07001926 /*
1927 * Once the AP capabilities are available then set the
1928 * beam forming capabilities accordingly.
1929 */
1930 if (session->nss == 1) {
1931 session->vht_config.su_beam_former = 0;
1932 session->vht_config.tx_stbc = 0;
1933 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301934 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001935 }
1936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 session->maxTxPower = lim_get_max_tx_power(reg_max,
1938 local_power_constraint,
1939 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301940
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301941 lim_log(mac_ctx, LOG1,
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301942 FL("Reg max %d local power con %d max tx pwr %d"),
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301943 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944
1945 if (session->gLimCurrentBssUapsd) {
1946 session->gUapsdPerAcBitmask =
1947 session->pLimJoinReq->uapsdPerAcBitmask;
1948 lim_log(mac_ctx, LOG1,
1949 FL("UAPSD flag for all AC - 0x%2x"),
1950 session->gUapsdPerAcBitmask);
1951
1952 /* resetting the dynamic uapsd mask */
1953 session->gUapsdPerAcDeliveryEnableMask = 0;
1954 session->gUapsdPerAcTriggerEnableMask = 0;
1955 }
1956
1957 session->limRFBand =
1958 lim_get_rf_band(session->currentOperChannel);
1959
1960 /* Initialize 11h Enable Flag */
1961 if (SIR_BAND_5_GHZ == session->limRFBand) {
1962 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1963 &val) != eSIR_SUCCESS) {
1964 lim_log(mac_ctx, LOGP,
1965 FL("Fail to get WNI_CFG_11H_ENABLED "));
1966 session->lim11hEnable =
1967 WNI_CFG_11H_ENABLED_STADEF;
1968 } else {
1969 session->lim11hEnable = val;
1970 }
1971 } else {
1972 session->lim11hEnable = 0;
1973 }
1974
1975 /*
1976 * To care of the scenario when STA transitions from
1977 * IBSS to Infrastructure mode.
1978 */
1979 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1980
1981 session->limPrevSmeState = session->limSmeState;
1982 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1983 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1984 session->peSessionId,
1985 session->limSmeState));
1986
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 /* Indicate whether spectrum management is enabled */
1988 session->spectrumMgtEnabled =
1989 sme_join_req->spectrumMgtIndicator;
1990
1991 /* Enable the spectrum management if this is a DFS channel */
1992 if (session->country_info_present &&
1993 lim_isconnected_on_dfs_channel(
1994 session->currentOperChannel))
1995 session->spectrumMgtEnabled = true;
1996
1997 session->isOSENConnection = sme_join_req->isOSENConnection;
1998
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 /* Issue LIM_MLM_JOIN_REQ to MLM */
2000 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2001 (uint32_t *) mlm_join_req);
2002 return;
2003
2004 } else {
2005 /* Received eWNI_SME_JOIN_REQ un expected state */
2006 lim_log(mac_ctx, LOGE,
2007 FL("received unexpected SME_JOIN_REQ in state %X"),
2008 mac_ctx->lim.gLimSmeState);
2009 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2010 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2011 session = NULL;
2012 goto end;
2013 }
2014
2015end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302016 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2017 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018
2019 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302020 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 sme_join_req = NULL;
2022 if (NULL != session)
2023 session->pLimJoinReq = NULL;
2024 }
2025 if (ret_code != eSIR_SME_SUCCESS) {
2026 if (NULL != session) {
2027 pe_delete_session(mac_ctx, session);
2028 session = NULL;
2029 }
2030 }
2031 lim_log(mac_ctx, LOG1,
2032 FL("Send failure status on sessionid: %d with ret_code = %d"),
2033 sme_session_id, ret_code);
2034 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2035 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2036 sme_transaction_id);
2037}
2038
Amar Singhala297bfa2015-10-15 15:07:29 -07002039uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 uint8_t iniTxPower)
2041{
2042 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302043 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2044 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2046 maxTxPower = txPower;
2047 else if (txPower < MIN_TX_PWR_CAP)
2048 maxTxPower = MIN_TX_PWR_CAP;
2049 else
2050 maxTxPower = MAX_TX_PWR_CAP;
2051
2052 return maxTxPower;
2053}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054
2055/**
2056 * __lim_process_sme_reassoc_req() - process reassoc req
2057 *
2058 * @mac_ctx: Pointer to Global MAC structure
2059 * @msg_buf: pointer to the SME message buffer
2060 *
2061 * This function is called to process SME_REASSOC_REQ message
2062 * from HDD or upper layer application.
2063 *
2064 * Return: None
2065 */
2066
2067static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2068 uint32_t *msg_buf)
2069{
2070 uint16_t caps;
2071 uint32_t val;
2072 tpSirSmeJoinReq reassoc_req = NULL;
2073 tLimMlmReassocReq *mlm_reassoc_req;
2074 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2075 tpPESession session_entry = NULL;
2076 uint8_t session_id;
2077 uint8_t sme_session_id;
2078 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002079 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 uint32_t tele_bcn_en = 0;
2081 uint16_t size;
2082
2083 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2084
2085 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302086 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 if (NULL == reassoc_req) {
2088 lim_log(mac_ctx, LOGP,
2089 FL("call to AllocateMemory failed for reassoc_req"));
2090
2091 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2092 goto end;
2093 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302094 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2095 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096
2097 if (!lim_is_sme_join_req_valid(mac_ctx,
2098 (tpSirSmeJoinReq)reassoc_req)) {
2099 /*
2100 * Received invalid eWNI_SME_REASSOC_REQ
2101 */
2102 lim_log(mac_ctx, LOGW,
2103 FL("received SME_REASSOC_REQ with invalid data"));
2104
2105 ret_code = eSIR_SME_INVALID_PARAMETERS;
2106 goto end;
2107 }
2108
2109 session_entry = pe_find_session_by_bssid(mac_ctx,
2110 reassoc_req->bssDescription.bssId,
2111 &session_id);
2112 if (session_entry == NULL) {
2113 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2114 LOGE);
2115 lim_log(mac_ctx, LOGE,
2116 FL("Session does not exist for given bssId"));
2117 ret_code = eSIR_SME_INVALID_PARAMETERS;
2118 goto end;
2119 }
2120#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2121 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2122 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2123#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2124 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2125
2126 /* Store the reassoc handle in the session Table */
2127 session_entry->pLimReAssocReq = reassoc_req;
2128
2129 session_entry->dot11mode = reassoc_req->dot11mode;
2130 session_entry->vhtCapability =
2131 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002132
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302133 if (session_entry->vhtCapability) {
2134 if (session_entry->pePersona == QDF_STA_MODE) {
2135 session_entry->vht_config.su_beam_formee =
2136 reassoc_req->vht_config.su_beam_formee;
2137 } else {
2138 reassoc_req->vht_config.su_beam_formee = 0;
2139 }
2140 session_entry->enableVhtpAid =
2141 reassoc_req->enableVhtpAid;
2142 session_entry->enableVhtGid =
2143 reassoc_req->enableVhtGid;
2144 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2145 session_entry->vht_config.su_beam_former);
2146 }
2147
2148 lim_log(mac_ctx, LOG1,
2149 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2150 session_entry->vhtCapability,
2151 session_entry->vht_config.su_beam_formee,
2152 session_entry->vht_config.su_beam_former);
2153
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002154 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2155 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002156 session_entry->send_smps_action =
2157 reassoc_req->send_smps_action;
2158 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002159 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002160 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002161 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002162 session_entry->send_smps_action,
2163 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 /*
2165 * Reassociate request is expected
2166 * in link established state only.
2167 */
2168
2169 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2171 /*
2172 * May be from 11r FT pre-auth. So lets check it
2173 * before we bail out
2174 */
2175 lim_log(mac_ctx, LOG1, FL(
2176 "Session in reassoc state is %d"),
2177 session_entry->peSessionId);
2178
2179 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302180 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 session_entry->limReAssocbssId,
2182 6)) {
2183 lim_print_mac_addr(mac_ctx,
2184 reassoc_req->bssDescription.
2185 bssId, LOGE);
2186 lim_log(mac_ctx, LOGP,
2187 FL("Unknown bssId in reassoc state"));
2188 ret_code = eSIR_SME_INVALID_PARAMETERS;
2189 goto end;
2190 }
2191
2192 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2193 session_entry);
2194 return;
2195 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 /*
2197 * Should not have received eWNI_SME_REASSOC_REQ
2198 */
2199 lim_log(mac_ctx, LOGE,
2200 FL("received unexpected SME_REASSOC_REQ in state %X"),
2201 session_entry->limSmeState);
2202 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2203
2204 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2205 goto end;
2206 }
2207
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302208 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 session_entry->pLimReAssocReq->bssDescription.bssId,
2210 sizeof(tSirMacAddr));
2211
2212 session_entry->limReassocChannelId =
2213 session_entry->pLimReAssocReq->bssDescription.channelId;
2214
2215 session_entry->reAssocHtSupportedChannelWidthSet =
2216 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2217 session_entry->reAssocHtRecommendedTxWidthSet =
2218 session_entry->reAssocHtSupportedChannelWidthSet;
2219 session_entry->reAssocHtSecondaryChannelOffset =
2220 session_entry->pLimReAssocReq->cbMode;
2221
2222 session_entry->limReassocBssCaps =
2223 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2224 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2225 session_entry->currentOperChannel);
2226 local_pwr_constraint = reg_max;
2227
2228 lim_extract_ap_capability(mac_ctx,
2229 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2230 lim_get_ielen_from_bss_description(
2231 &session_entry->pLimReAssocReq->bssDescription),
2232 &session_entry->limReassocBssQosCaps,
2233 &session_entry->limReassocBssPropCap,
2234 &session_entry->gLimCurrentBssUapsd,
2235 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302236 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302238 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2239 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 /* Copy the SSID from session entry to local variable */
2241 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302242 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 reassoc_req->ssId.ssId,
2244 session_entry->limReassocSSID.length);
2245 if (session_entry->gLimCurrentBssUapsd) {
2246 session_entry->gUapsdPerAcBitmask =
2247 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2248 lim_log(mac_ctx, LOG1,
2249 FL("UAPSD flag for all AC - 0x%2x"),
2250 session_entry->gUapsdPerAcBitmask);
2251 }
2252
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302253 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 if (NULL == mlm_reassoc_req) {
2255 lim_log(mac_ctx, LOGP,
2256 FL("call to AllocateMemory failed for mlmReassocReq"));
2257
2258 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2259 goto end;
2260 }
2261
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302262 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2264
2265 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2266 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2267 eSIR_SUCCESS) {
2268 /*
2269 * Could not get ReassocFailureTimeout value
2270 * from CFG. Log error.
2271 */
2272 lim_log(mac_ctx, LOGP,
2273 FL("could not retrieve ReassocFailureTimeout value"));
2274 }
2275
2276 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2277 eSIR_SUCCESS) {
2278 /*
2279 * Could not get Capabilities value
2280 * from CFG. Log error.
2281 */
2282 lim_log(mac_ctx, LOGP, FL(
2283 "could not retrieve Capabilities value"));
2284 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302285
2286 lim_update_caps_info_for_bss(mac_ctx, &caps,
2287 reassoc_req->bssDescription.capabilityInfo);
2288 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2289
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 mlm_reassoc_req->capabilityInfo = caps;
2291
2292 /* Update PE session_id */
2293 mlm_reassoc_req->sessionId = session_id;
2294
2295 /*
2296 * If telescopic beaconing is enabled, set listen interval to
2297 * WNI_CFG_TELE_BCN_MAX_LI
2298 */
2299 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2300 &tele_bcn_en) != eSIR_SUCCESS)
2301 lim_log(mac_ctx, LOGP,
2302 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2303
2304 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2305
2306 if (tele_bcn_en) {
2307 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2308 eSIR_SUCCESS)
2309 /*
2310 * Could not get ListenInterval value
2311 * from CFG. Log error.
2312 */
2313 lim_log(mac_ctx, LOGP,
2314 FL("could not retrieve ListenInterval"));
2315 } else {
2316 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2317 eSIR_SUCCESS)
2318 /*
2319 * Could not get ListenInterval value
2320 * from CFG. Log error.
2321 */
2322 lim_log(mac_ctx, LOGP,
2323 FL("could not retrieve ListenInterval"));
2324 }
2325
2326 mlm_reassoc_req->listenInterval = (uint16_t) val;
2327
2328 /* Indicate whether spectrum management is enabled */
2329 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2330
2331 /* Enable the spectrum management if this is a DFS channel */
2332 if (session_entry->country_info_present &&
2333 lim_isconnected_on_dfs_channel(
2334 session_entry->currentOperChannel))
2335 session_entry->spectrumMgtEnabled = true;
2336
2337 session_entry->limPrevSmeState = session_entry->limSmeState;
2338 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2339
2340 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2341 session_entry->peSessionId,
2342 session_entry->limSmeState));
2343
2344 lim_post_mlm_message(mac_ctx,
2345 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2346 return;
2347end:
2348 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302349 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 if (session_entry)
2351 session_entry->pLimReAssocReq = NULL;
2352 }
2353
2354 if (session_entry) {
2355 /*
2356 * error occurred after we determined the session so extract
2357 * session and transaction info from there
2358 */
2359 sme_session_id = session_entry->smeSessionId;
2360 transaction_id = session_entry->transactionId;
2361 } else
2362 /*
2363 * error occurred before or during the time we determined
2364 * the session so extract the session and transaction info
2365 * from the message
2366 */
2367 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2368 &sme_session_id, &transaction_id);
2369
2370 /*
2371 * Send Reassoc failure response to host
2372 * (note session_entry may be NULL, but that's OK)
2373 */
2374 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2375 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2376 session_entry, sme_session_id,
2377 transaction_id);
2378}
2379
2380bool send_disassoc_frame = 1;
2381/**
2382 * __lim_process_sme_disassoc_req()
2383 *
2384 ***FUNCTION:
2385 * This function is called to process SME_DISASSOC_REQ message
2386 * from HDD or upper layer application.
2387 *
2388 ***LOGIC:
2389 *
2390 ***ASSUMPTIONS:
2391 *
2392 ***NOTE:
2393 *
2394 * @param pMac Pointer to Global MAC structure
2395 * @param *pMsgBuf A pointer to the SME message buffer
2396 * @return None
2397 */
2398
2399static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2400{
2401 uint16_t disassocTrigger, reasonCode;
2402 tLimMlmDisassocReq *pMlmDisassocReq;
2403 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2404 tSirSmeDisassocReq smeDisassocReq;
2405 tpPESession psessionEntry = NULL;
2406 uint8_t sessionId;
2407 uint8_t smesessionId;
2408 uint16_t smetransactionId;
2409
2410 if (pMsgBuf == NULL) {
2411 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2412 return;
2413 }
2414
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302415 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 smesessionId = smeDisassocReq.sessionId;
2417 smetransactionId = smeDisassocReq.transactionId;
2418 if (!lim_is_sme_disassoc_req_valid(pMac,
2419 &smeDisassocReq,
2420 psessionEntry)) {
2421 PELOGE(lim_log(pMac, LOGE,
2422 FL("received invalid SME_DISASSOC_REQ message"));)
2423 if (pMac->lim.gLimRspReqd) {
2424 pMac->lim.gLimRspReqd = false;
2425
2426 retCode = eSIR_SME_INVALID_PARAMETERS;
2427 disassocTrigger = eLIM_HOST_DISASSOC;
2428 goto sendDisassoc;
2429 }
2430
2431 return;
2432 }
2433
2434 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002435 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436 &sessionId);
2437 if (psessionEntry == NULL) {
2438 lim_log(pMac, LOGE,
2439 FL("session does not exist for given bssId "
2440 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002441 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 retCode = eSIR_SME_INVALID_PARAMETERS;
2443 disassocTrigger = eLIM_HOST_DISASSOC;
2444 goto sendDisassoc;
2445 }
2446 lim_log(pMac, LOG1,
2447 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2448 MAC_ADDRESS_STR), smesessionId,
2449 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2450 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002451 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452
2453#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2454 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2455 0, smeDisassocReq.reasonCode);
2456#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2457
2458 /* Update SME session Id and SME transaction ID */
2459
2460 psessionEntry->smeSessionId = smesessionId;
2461 psessionEntry->transactionId = smetransactionId;
2462
2463 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2464 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 switch (psessionEntry->limSmeState) {
2466 case eLIM_SME_ASSOCIATED_STATE:
2467 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002468 lim_log(pMac, LOG1,
2469 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2470 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 psessionEntry->limPrevSmeState =
2472 psessionEntry->limSmeState;
2473 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2474#ifdef FEATURE_WLAN_TDLS
2475 /* Delete all TDLS peers connected before leaving BSS */
2476 lim_delete_tdls_peers(pMac, psessionEntry);
2477#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002478 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2479 psessionEntry->peSessionId,
2480 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 break;
2482
2483 case eLIM_SME_WT_DEAUTH_STATE:
2484 /* PE shall still process the DISASSOC_REQ and proceed with
2485 * link tear down even if it had already sent a DEAUTH_IND to
2486 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2487 * its been set when PE entered WT_DEAUTH_STATE.
2488 */
2489 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2490 MTRACE(mac_trace
2491 (pMac, TRACE_CODE_SME_STATE,
2492 psessionEntry->peSessionId,
2493 psessionEntry->limSmeState));
2494 lim_log(pMac, LOG1,
2495 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2496 break;
2497
2498 case eLIM_SME_WT_DISASSOC_STATE:
2499 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2500 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2501 * PE can continue processing DISASSOC_REQ and send the response instead
2502 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2503 * for disassoc frame.
2504 *
2505 * It will send a disassoc, which is ok. However, we can use the global flag
2506 * sendDisassoc to not send disassoc frame.
2507 */
2508 lim_log(pMac, LOG1,
2509 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2510 break;
2511
2512 case eLIM_SME_JOIN_FAILURE_STATE: {
2513 /* Already in Disconnected State, return success */
2514 lim_log(pMac, LOG1,
2515 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2516 if (pMac->lim.gLimRspReqd) {
2517 retCode = eSIR_SME_SUCCESS;
2518 disassocTrigger = eLIM_HOST_DISASSOC;
2519 goto sendDisassoc;
2520 }
2521 }
2522 break;
2523 default:
2524 /**
2525 * STA is not currently associated.
2526 * Log error and send response to host
2527 */
2528 lim_log(pMac, LOGE,
2529 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2530 psessionEntry->limSmeState);
2531 lim_print_sme_state(pMac, LOGE,
2532 psessionEntry->limSmeState);
2533
2534 if (pMac->lim.gLimRspReqd) {
2535 if (psessionEntry->limSmeState !=
2536 eLIM_SME_WT_ASSOC_STATE)
2537 pMac->lim.gLimRspReqd = false;
2538
2539 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2540 disassocTrigger = eLIM_HOST_DISASSOC;
2541 goto sendDisassoc;
2542 }
2543
2544 return;
2545 }
2546
2547 break;
2548
2549 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 /* Fall through */
2551 break;
2552
2553 case eLIM_STA_IN_IBSS_ROLE:
2554 default:
2555 /* eLIM_UNKNOWN_ROLE */
2556 lim_log(pMac, LOGE,
2557 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2558 GET_LIM_SYSTEM_ROLE(psessionEntry));
2559
2560 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2561 disassocTrigger = eLIM_HOST_DISASSOC;
2562 goto sendDisassoc;
2563 } /* end switch (pMac->lim.gLimSystemRole) */
2564
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302565 disassocTrigger = eLIM_HOST_DISASSOC;
2566 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567
2568 if (smeDisassocReq.doNotSendOverTheAir) {
2569 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2570 send_disassoc_frame = 0;
2571 }
2572 /* Trigger Disassociation frame to peer MAC entity */
2573 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2574 " : %d, reasonCode : %d"),
2575 disassocTrigger, reasonCode);
2576
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302577 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 if (NULL == pMlmDisassocReq) {
2579 /* Log error */
2580 lim_log(pMac, LOGP,
2581 FL("call to AllocateMemory failed for mlmDisassocReq"));
2582
2583 return;
2584 }
2585
Anurag Chouhanc5548422016-02-24 18:33:27 +05302586 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002587 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588
2589 pMlmDisassocReq->reasonCode = reasonCode;
2590 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2591
2592 /* Update PE session ID */
2593 pMlmDisassocReq->sessionId = sessionId;
2594
2595 lim_post_mlm_message(pMac,
2596 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2597 return;
2598
2599sendDisassoc:
2600 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002601 lim_send_sme_disassoc_ntf(pMac,
2602 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 retCode,
2604 disassocTrigger,
2605 1, smesessionId, smetransactionId,
2606 psessionEntry);
2607 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002608 lim_send_sme_disassoc_ntf(pMac,
2609 smeDisassocReq.peer_macaddr.bytes,
2610 retCode, disassocTrigger, 1,
2611 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612
2613} /*** end __lim_process_sme_disassoc_req() ***/
2614
2615/** -----------------------------------------------------------------
2616 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2617
2618 This function is called to process SME_DISASSOC_CNF message
2619 from HDD or upper layer application.
2620
2621 \param pMac - global mac structure
2622 \param pStaDs - station dph hash node
2623 \return none
2624 \sa
2625 ----------------------------------------------------------------- */
2626static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2627{
2628 tSirSmeDisassocCnf smeDisassocCnf;
2629 uint16_t aid;
2630 tpDphHashNode pStaDs;
2631 tpPESession psessionEntry;
2632 uint8_t sessionId;
2633
2634 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2635
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302636 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 sizeof(struct sSirSmeDisassocCnf));
2638
2639 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002640 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 &sessionId);
2642 if (psessionEntry == NULL) {
2643 lim_log(pMac, LOGE,
2644 FL("session does not exist for given bssId"));
2645 return;
2646 }
2647
2648 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2649 lim_log(pMac, LOGE,
2650 FL("received invalid SME_DISASSOC_CNF message"));
2651 return;
2652 }
2653#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2654 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2655 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2656 psessionEntry,
2657 (uint16_t) smeDisassocCnf.statusCode, 0);
2658 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2659 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2660 psessionEntry,
2661 (uint16_t) smeDisassocCnf.statusCode, 0);
2662#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2663
2664 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2665 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2667 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2668 && (psessionEntry->limSmeState !=
2669 eLIM_SME_WT_DEAUTH_STATE)) {
2670 lim_log(pMac, LOGE,
2671 FL
2672 ("received unexp SME_DISASSOC_CNF in state %X"),
2673 psessionEntry->limSmeState);
2674 lim_print_sme_state(pMac, LOGE,
2675 psessionEntry->limSmeState);
2676 return;
2677 }
2678 break;
2679
2680 case eLIM_AP_ROLE:
2681 /* Fall through */
2682 break;
2683
2684 case eLIM_STA_IN_IBSS_ROLE:
2685 default: /* eLIM_UNKNOWN_ROLE */
2686 lim_log(pMac, LOGE,
2687 FL("received unexpected SME_DISASSOC_CNF role %d"),
2688 GET_LIM_SYSTEM_ROLE(psessionEntry));
2689
2690 return;
2691 }
2692
2693 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2694 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2695 LIM_IS_AP_ROLE(psessionEntry)) {
2696 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002697 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 &psessionEntry->dph.dphHashTable);
2699 if (pStaDs == NULL) {
2700 lim_log(pMac, LOGE,
2701 FL("DISASSOC_CNF for a STA with no context, addr= "
2702 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002703 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 return;
2705 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302706
2707 if ((pStaDs->mlmStaContext.mlmState ==
2708 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2709 (pStaDs->mlmStaContext.mlmState ==
2710 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2711 lim_log(pMac, LOGE,
2712 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002713 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302714 pStaDs->mlmStaContext.mlmState);
2715 return;
2716 }
2717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 /* Delete FT session if there exists one */
2719 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2721
2722 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002723 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 }
2725
2726 return;
2727}
2728
2729/**
2730 * __lim_process_sme_deauth_req() - process sme deauth req
2731 * @mac_ctx: Pointer to Global MAC structure
2732 * @msg_buf: pointer to the SME message buffer
2733 *
2734 * This function is called to process SME_DEAUTH_REQ message
2735 * from HDD or upper layer application.
2736 *
2737 * Return: None
2738 */
2739
2740static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2741 uint32_t *msg_buf)
2742{
2743 uint16_t deauth_trigger, reason_code;
2744 tLimMlmDeauthReq *mlm_deauth_req;
2745 tSirSmeDeauthReq sme_deauth_req;
2746 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2747 tpPESession session_entry;
2748 uint8_t session_id; /* PE sessionId */
2749 uint8_t sme_session_id;
2750 uint16_t sme_transaction_id;
2751
2752 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2753
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302754 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 sme_session_id = sme_deauth_req.sessionId;
2756 sme_transaction_id = sme_deauth_req.transactionId;
2757
2758 /*
2759 * We need to get a session first but we don't even know
2760 * if the message is correct.
2761 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002762 session_entry = pe_find_session_by_bssid(mac_ctx,
2763 sme_deauth_req.bssid.bytes,
2764 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 if (session_entry == NULL) {
2766 lim_log(mac_ctx, LOGE,
2767 FL("session does not exist for given bssId"));
2768 ret_code = eSIR_SME_INVALID_PARAMETERS;
2769 deauth_trigger = eLIM_HOST_DEAUTH;
2770 goto send_deauth;
2771 }
2772
2773 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2774 session_entry)) {
2775 lim_log(mac_ctx, LOGE,
2776 FL("received invalid SME_DEAUTH_REQ message"));
2777 mac_ctx->lim.gLimRspReqd = false;
2778
2779 ret_code = eSIR_SME_INVALID_PARAMETERS;
2780 deauth_trigger = eLIM_HOST_DEAUTH;
2781 goto send_deauth;
2782 }
2783 lim_log(mac_ctx, LOG1,
2784 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2785 MAC_ADDRESS_STR), sme_session_id,
2786 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2787 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002788 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2790 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2791 session_entry, 0, sme_deauth_req.reasonCode);
2792#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2793
2794 /* Update SME session ID and Transaction ID */
2795 session_entry->smeSessionId = sme_session_id;
2796 session_entry->transactionId = sme_transaction_id;
2797
2798 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2799 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 switch (session_entry->limSmeState) {
2801 case eLIM_SME_ASSOCIATED_STATE:
2802 case eLIM_SME_LINK_EST_STATE:
2803 case eLIM_SME_WT_ASSOC_STATE:
2804 case eLIM_SME_JOIN_FAILURE_STATE:
2805 case eLIM_SME_IDLE_STATE:
2806 session_entry->limPrevSmeState =
2807 session_entry->limSmeState;
2808 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2809 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2810 session_entry->peSessionId,
2811 session_entry->limSmeState));
2812 /* Send Deauthentication request to MLM below */
2813 break;
2814 case eLIM_SME_WT_DEAUTH_STATE:
2815 case eLIM_SME_WT_DISASSOC_STATE:
2816 /*
2817 * PE Recieved a Deauth/Disassoc frame. Normally it get
2818 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2819 * Which means host is also trying to disconnect.
2820 * PE can continue processing DEAUTH_REQ and send
2821 * the response instead of failing the request.
2822 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2823 * was sent for deauth/disassoc frame.
2824 */
2825 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2826 lim_log(mac_ctx, LOG1, FL(
2827 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2828 break;
2829 default:
2830 /*
2831 * STA is not in a state to deauthenticate with
2832 * peer. Log error and send response to host.
2833 */
2834 lim_log(mac_ctx, LOGE, FL(
2835 "received unexp SME_DEAUTH_REQ in state %X"),
2836 session_entry->limSmeState);
2837 lim_print_sme_state(mac_ctx, LOGE,
2838 session_entry->limSmeState);
2839
2840 if (mac_ctx->lim.gLimRspReqd) {
2841 mac_ctx->lim.gLimRspReqd = false;
2842
2843 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2844 deauth_trigger = eLIM_HOST_DEAUTH;
2845
2846 /*
2847 * here we received deauth request from AP so sme state
2848 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2849 * delSta then mlm state should be
2850 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2851 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2852 * so the below condition captures the state where
2853 * delSta not done and firmware still in
2854 * connected state.
2855 */
2856 if (session_entry->limSmeState ==
2857 eLIM_SME_WT_DEAUTH_STATE &&
2858 session_entry->limMlmState !=
2859 eLIM_MLM_IDLE_STATE &&
2860 session_entry->limMlmState !=
2861 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2862 ret_code = eSIR_SME_DEAUTH_STATUS;
2863 goto send_deauth;
2864 }
2865 return;
2866 }
2867 break;
2868
2869 case eLIM_STA_IN_IBSS_ROLE:
2870 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2871 if (mac_ctx->lim.gLimRspReqd) {
2872 mac_ctx->lim.gLimRspReqd = false;
2873 ret_code = eSIR_SME_INVALID_PARAMETERS;
2874 deauth_trigger = eLIM_HOST_DEAUTH;
2875 goto send_deauth;
2876 }
2877 return;
2878 case eLIM_AP_ROLE:
2879 break;
2880 default:
2881 lim_log(mac_ctx, LOGE,
2882 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2883 GET_LIM_SYSTEM_ROLE(session_entry));
2884 if (mac_ctx->lim.gLimRspReqd) {
2885 mac_ctx->lim.gLimRspReqd = false;
2886 ret_code = eSIR_SME_INVALID_PARAMETERS;
2887 deauth_trigger = eLIM_HOST_DEAUTH;
2888 goto send_deauth;
2889 }
2890 return;
2891 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2892
2893 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2894 /* Deauthentication is triggered by Link Monitoring */
2895 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2896 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2897 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2898 } else {
2899 deauth_trigger = eLIM_HOST_DEAUTH;
2900 reason_code = sme_deauth_req.reasonCode;
2901 }
2902
2903 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302904 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 if (NULL == mlm_deauth_req) {
2906 lim_log(mac_ctx, LOGP,
2907 FL("call to AllocateMemory failed for mlmDeauthReq"));
2908 if (mac_ctx->lim.gLimRspReqd) {
2909 mac_ctx->lim.gLimRspReqd = false;
2910 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2911 deauth_trigger = eLIM_HOST_DEAUTH;
2912 goto send_deauth;
2913 }
2914 return;
2915 }
2916
Anurag Chouhanc5548422016-02-24 18:33:27 +05302917 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002918 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919
2920 mlm_deauth_req->reasonCode = reason_code;
2921 mlm_deauth_req->deauthTrigger = deauth_trigger;
2922
2923 /* Update PE session Id */
2924 mlm_deauth_req->sessionId = session_id;
2925
2926 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2927 (uint32_t *)mlm_deauth_req);
2928 return;
2929
2930send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002931 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2932 ret_code, deauth_trigger, 1,
2933 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934}
2935
2936/**
2937 * __lim_process_sme_set_context_req()
2938 *
2939 * @mac_ctx: Pointer to Global MAC structure
2940 * @msg_buf: pointer to the SME message buffer
2941 *
2942 * This function is called to process SME_SETCONTEXT_REQ message
2943 * from HDD or upper layer application.
2944 *
2945 * Return: None
2946 */
2947
2948static void
2949__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2950{
2951 tpSirSmeSetContextReq set_context_req;
2952 tLimMlmSetKeysReq *mlm_set_key_req;
2953 tpPESession session_entry;
2954 uint8_t session_id; /* PE sessionID */
2955 uint8_t sme_session_id;
2956 uint16_t sme_transaction_id;
2957
2958 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2959
2960 if (msg_buf == NULL) {
2961 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2962 return;
2963 }
2964
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302965 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 if (NULL == set_context_req) {
2967 lim_log(mac_ctx, LOGP, FL(
2968 "call to AllocateMemory failed for set_context_req"));
2969 return;
2970 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302971 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 sizeof(struct sSirSmeSetContextReq));
2973 sme_session_id = set_context_req->sessionId;
2974 sme_transaction_id = set_context_req->transactionId;
2975
2976 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2977 lim_log(mac_ctx, LOGW,
2978 FL("received invalid SME_SETCONTEXT_REQ message"));
2979 goto end;
2980 }
2981
2982 if (set_context_req->keyMaterial.numKeys >
2983 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2984 lim_log(mac_ctx, LOGE, FL(
2985 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2986 set_context_req->keyMaterial.numKeys);
2987 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002988 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 eSIR_SME_INVALID_PARAMETERS, NULL,
2990 sme_session_id, sme_transaction_id);
2991 goto end;
2992 }
2993
2994 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002995 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996 if (session_entry == NULL) {
2997 lim_log(mac_ctx, LOGW,
2998 FL("Session does not exist for given BSSID"));
2999 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003000 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 eSIR_SME_INVALID_PARAMETERS, NULL,
3002 sme_session_id, sme_transaction_id);
3003 goto end;
3004 }
3005#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3006 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3007 session_entry, 0, 0);
3008#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3009
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003010 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3012 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003013 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3015 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303016 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 if (NULL == mlm_set_key_req) {
3018 lim_log(mac_ctx, LOGP, FL(
3019 "mem alloc failed for mlmSetKeysReq"));
3020 goto end;
3021 }
3022 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3023 mlm_set_key_req->numKeys =
3024 set_context_req->keyMaterial.numKeys;
3025 if (mlm_set_key_req->numKeys >
3026 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3027 lim_log(mac_ctx, LOGP, FL(
3028 "no.of keys exceeded max num of default keys limit"));
3029 goto end;
3030 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303031 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003032 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303034 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 (uint8_t *) &set_context_req->keyMaterial.key,
3036 sizeof(tSirKeys) *
3037 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3038 numKeys : 1));
3039
3040 mlm_set_key_req->sessionId = session_id;
3041 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 lim_log(mac_ctx, LOG1, FL(
3043 "received SETCONTEXT_REQ message sessionId=%d"),
3044 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045
3046 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3047 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3048 LIM_IS_AP_ROLE(session_entry)) {
3049 if (set_context_req->keyMaterial.key[0].keyLength) {
3050 uint8_t key_id;
3051 key_id =
3052 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303053 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 &session_entry->WEPKeyMaterial[key_id],
3055 (uint8_t *) &set_context_req->keyMaterial,
3056 sizeof(tSirKeyMaterial));
3057 } else {
3058 uint32_t i;
3059 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3060 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303061 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 &mlm_set_key_req->key[i],
3063 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3064 sizeof(tSirKeys));
3065 }
3066 }
3067 }
3068 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3069 (uint32_t *) mlm_set_key_req);
3070 } else {
3071 lim_log(mac_ctx, LOGE, FL(
3072 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3073 GET_LIM_SYSTEM_ROLE(session_entry),
3074 session_entry->limSmeState);
3075 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3076
3077 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003078 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3080 session_entry, sme_session_id,
3081 sme_transaction_id);
3082 }
3083end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303084 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 return;
3086}
3087
3088/**
3089 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3090 *
3091 * @mac_ctx: Pointer to Global MAC structure
3092 * @msg_buf: pointer to the SME message buffer
3093 *
3094 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3095 * from HDD or upper layer application.
3096 *
3097 * Return: None
3098 */
3099
Jeff Johnson801f1532016-10-07 07:54:50 -07003100static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3101 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102{
3103 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3104 tpDphHashNode sta_ds = NULL;
3105 tpPESession session_entry = NULL;
3106 tSap_Event sap_event;
3107 tpWLAN_SAPEventCB sap_event_cb = NULL;
3108 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3109 uint8_t session_id = CSR_SESSION_ID_INVALID;
3110 uint8_t assoc_id = 0;
3111 uint8_t sta_cnt = 0;
3112
3113 if (msg_buf == NULL) {
3114 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3115 return;
3116 }
3117
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303118 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 sizeof(struct sSirSmeGetAssocSTAsReq));
3120 /*
3121 * Get Associated stations from PE.
3122 * Find PE session Entry
3123 */
3124 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003125 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 &session_id);
3127 if (session_entry == NULL) {
3128 lim_log(mac_ctx, LOGE,
3129 FL("session does not exist for given bssId"));
3130 goto lim_assoc_sta_end;
3131 }
3132
3133 if (!LIM_IS_AP_ROLE(session_entry)) {
3134 lim_log(mac_ctx, LOGE, FL(
3135 "Received unexpected message in state %X, in role %X"),
3136 session_entry->limSmeState,
3137 GET_LIM_SYSTEM_ROLE(session_entry));
3138 goto lim_assoc_sta_end;
3139 }
3140 /* Retrieve values obtained in the request message */
3141 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3142 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3143
3144 if (NULL == assoc_sta_tmp)
3145 goto lim_assoc_sta_end;
3146 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3147 assoc_id++) {
3148 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3149 &session_entry->dph.dphHashTable);
3150 if (NULL == sta_ds)
3151 continue;
3152 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303153 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303155 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3157 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3158
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303159 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 (uint8_t *)&sta_ds->supportedRates,
3161 sizeof(tSirSupportedRates));
3162 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3163 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3164 assoc_sta_tmp->Support40Mhz =
3165 sta_ds->htDsssCckRate40MHzSupport;
3166
3167 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3168 sta_cnt + 1);
3169 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3170 MAC_ADDR_ARRAY(sta_ds->staAddr));
3171 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3172 sta_ds->assocId);
3173 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3174 sta_ds->staIndex);
3175 assoc_sta_tmp++;
3176 sta_cnt++;
3177 }
3178 }
3179lim_assoc_sta_end:
3180 /*
3181 * Call hdd callback with sap event to send the list of
3182 * associated stations from PE
3183 */
3184 if (sap_event_cb != NULL) {
3185 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3186 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303187 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3189 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3190 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3191 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3192 }
3193}
3194
3195/**
3196 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3197 *
3198 * @mac_ctx: Pointer to Global MAC structure
3199 * @msg_buf: pointer to WPS PBC overlap query message
3200 *
3201 * This function parses get WPS PBC overlap information
3202 * message and call callback to pass WPS PBC overlap
3203 * information back to hdd.
3204 *
3205 * Return: None
3206 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003207static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3208 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209{
3210 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3211 tpPESession session_entry = NULL;
3212 tSap_Event sap_event;
3213 tpWLAN_SAPEventCB sap_event_cb = NULL;
3214 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3216
3217 if (msg_buf == NULL) {
3218 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3219 return;
3220 }
3221
3222 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303223 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303225 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3227 /*
3228 * Get Associated stations from PE
3229 * Find PE session Entry
3230 */
3231 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003232 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 if (session_entry == NULL) {
3234 lim_log(mac_ctx, LOGE,
3235 FL("session does not exist for given bssId"));
3236 goto lim_get_wpspbc_sessions_end;
3237 }
3238
3239 if (!LIM_IS_AP_ROLE(session_entry)) {
3240 lim_log(mac_ctx, LOGE,
3241 FL("Received unexpected message in role %X"),
3242 GET_LIM_SYSTEM_ROLE(session_entry));
3243 goto lim_get_wpspbc_sessions_end;
3244 }
3245 /*
3246 * Call hdd callback with sap event to send the
3247 * WPS PBC overlap information
3248 */
3249 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303250 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251
Anurag Chouhanc5548422016-02-24 18:33:27 +05303252 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003254 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 sap_get_wpspbc_event->UUID_E,
3256 &sap_get_wpspbc_event->wpsPBCOverlap,
3257 session_entry);
3258 } else {
3259 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003260 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 session_entry);
3262 /* don't have to inform the HDD/Host */
3263 return;
3264 }
3265
3266 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3267 sap_get_wpspbc_event->wpsPBCOverlap);
3268 lim_print_mac_addr(mac_ctx,
3269 sap_get_wpspbc_event->addr.bytes, LOG4);
3270
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303271 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272
3273lim_get_wpspbc_sessions_end:
3274 sap_event_cb =
3275 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3276 if (NULL != sap_event_cb)
3277 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3278}
3279
3280/**
3281 * __lim_counter_measures()
3282 *
3283 * FUNCTION:
3284 * This function is called to "implement" MIC counter measure
3285 * and is *temporary* only
3286 *
3287 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3288 * we don't do the proper STA disassoc sequence since the
3289 * BSS will be stoped anyway
3290 *
3291 ***ASSUMPTIONS:
3292 *
3293 ***NOTE:
3294 *
3295 * @param pMac Pointer to Global MAC structure
3296 * @return None
3297 */
3298
3299static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3300{
3301 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003302 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3304 mac, psessionEntry, false);
3305};
3306
Jeff Johnson801f1532016-10-07 07:54:50 -07003307static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3308 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309{
3310 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3311 tpPESession psessionEntry;
3312 uint8_t sessionId; /* PE sessionId */
3313
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303314 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 sizeof(struct sSirSmeTkipCntrMeasReq));
3316
3317 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003318 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 if (NULL == psessionEntry) {
3320 lim_log(pMac, LOGE,
3321 FL("session does not exist for given BSSID "));
3322 return;
3323 }
3324
3325 if (tkipCntrMeasReq.bEnable)
3326 __lim_counter_measures(pMac, psessionEntry);
3327
3328 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3329}
3330
3331static void
3332__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3333{
3334 tSirSmeStopBssReq stopBssReq;
3335 tSirRetStatus status;
3336 tLimSmeStates prevState;
3337 tpPESession psessionEntry;
3338 uint8_t smesessionId;
3339 uint8_t sessionId;
3340 uint16_t smetransactionId;
3341 uint8_t i = 0;
3342 tpDphHashNode pStaDs = NULL;
3343
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303344 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 smesessionId = stopBssReq.sessionId;
3346 smetransactionId = stopBssReq.transactionId;
3347
3348 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3349 PELOGW(lim_log(pMac, LOGW,
3350 FL("received invalid SME_STOP_BSS_REQ message"));)
3351 /* Send Stop BSS response to host */
3352 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3353 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3354 smetransactionId);
3355 return;
3356 }
3357
3358 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003359 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 &sessionId);
3361 if (psessionEntry == NULL) {
3362 lim_log(pMac, LOGW,
3363 FL("session does not exist for given BSSID "));
3364 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3365 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3366 smetransactionId);
3367 return;
3368 }
3369#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3370 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3371 0, 0);
3372#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3373
3374 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3375 LIM_IS_STA_ROLE(psessionEntry)) {
3376 /**
3377 * Should not have received STOP_BSS_REQ in states
3378 * other than 'normal' state or on STA in Infrastructure
3379 * mode. Log error and return response to host.
3380 */
3381 lim_log(pMac, LOGE,
3382 FL
3383 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3384 psessionEntry->limSmeState,
3385 GET_LIM_SYSTEM_ROLE(psessionEntry));
3386 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3387 /* / Send Stop BSS response to host */
3388 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3389 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3390 smetransactionId);
3391 return;
3392 }
3393
3394 if (LIM_IS_AP_ROLE(psessionEntry))
3395 lim_wpspbc_close(pMac, psessionEntry);
3396
3397 lim_log(pMac, LOGW,
3398 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3399 stopBssReq.reasonCode);
3400
3401 prevState = psessionEntry->limSmeState;
3402
3403 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3404 MTRACE(mac_trace
3405 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3406 psessionEntry->limSmeState));
3407
3408 /* Update SME session Id and Transaction Id */
3409 psessionEntry->smeSessionId = smesessionId;
3410 psessionEntry->transactionId = smetransactionId;
3411
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003412 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3413 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3414 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3416 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3417 /* Send disassoc all stations associated thru TKIP */
3418 __lim_counter_measures(pMac, psessionEntry);
3419 else
3420 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003421 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3422 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 }
3424
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003425 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3426 /* Free the buffer allocated in START_BSS_REQ */
3427 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3428 psessionEntry->addIeParams.probeRespDataLen = 0;
3429 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003431 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3432 psessionEntry->addIeParams.assocRespDataLen = 0;
3433 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003435 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3436 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3437 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003439 /*
3440 * lim_del_bss is also called as part of coalescing,
3441 * when we send DEL BSS followed by Add Bss msg.
3442 */
3443 pMac->lim.gLimIbssCoalescingHappened = false;
3444 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3446 pStaDs =
3447 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3448 if (NULL == pStaDs)
3449 continue;
3450 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3451 if (eSIR_SUCCESS == status) {
3452 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3453 pStaDs->assocId, psessionEntry);
3454 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3455 } else {
3456 lim_log(pMac, LOGE,
3457 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303458 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 }
3460 }
3461 /* send a delBss to HAL and wait for a response */
3462 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3463
3464 if (status != eSIR_SUCCESS) {
3465 PELOGE(lim_log
3466 (pMac, LOGE, FL("delBss failed for bss %d"),
3467 psessionEntry->bssIdx);
3468 )
3469 psessionEntry->limSmeState = prevState;
3470
3471 MTRACE(mac_trace
3472 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3473 psessionEntry->limSmeState));
3474
3475 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3476 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3477 smetransactionId);
3478 }
3479}
3480
3481/**
3482 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3483 * @pMac: Global MAC context
3484 * @pMsg: Message from SME
3485 *
3486 * Wrapper for the function __lim_handle_sme_stop_bss_request
3487 * This message will be defered until softmac come out of
3488 * scan mode. Message should be handled even if we have
3489 * detected radar in the current operating channel.
3490 *
3491 * Return: true - If we consumed the buffer
3492 * false - If have defered the message.
3493 */
3494
3495static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3496{
3497 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3498 /**
3499 * If message defered, buffer is not consumed yet.
3500 * So return false
3501 */
3502 return false;
3503 }
3504 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3505 return true;
3506} /*** end __lim_process_sme_stop_bss_req() ***/
3507
3508void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3509 uint32_t body, tpPESession psessionEntry)
3510{
3511
3512 (void)body;
3513 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3514 lim_ibss_delete(pMac, psessionEntry);
3515 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3516 lim_delete_pre_auth_list(pMac);
3517 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3518 psessionEntry->smeSessionId,
3519 psessionEntry->transactionId);
3520 return;
3521}
3522
3523/**
3524 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3525 *
3526 * @mac_ctx: pointer to mac context
3527 * @msg_type: message type
3528 * @msg_buf: pointer to the SME message buffer
3529 *
3530 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3531 * in BTAMP AP.
3532 *
3533 * Return: None
3534 */
3535
3536void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3537 uint32_t *msg_buf)
3538{
3539 tSirSmeAssocCnf assoc_cnf;
3540 tpDphHashNode sta_ds = NULL;
3541 tpPESession session_entry = NULL;
3542 uint8_t session_id;
3543 tpSirAssocReq assoc_req;
3544
3545 if (msg_buf == NULL) {
3546 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3547 goto end;
3548 }
3549
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303550 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3552 lim_log(mac_ctx, LOGE,
3553 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3554 goto end;
3555 }
3556
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003557 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 &session_id);
3559 if (session_entry == NULL) {
3560 lim_log(mac_ctx, LOGE,
3561 FL("session does not exist for given bssId"));
3562 goto end;
3563 }
3564
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003565 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3567 (session_entry->limSmeState !=
3568 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3569 lim_log(mac_ctx, LOGE, FL(
3570 "Rcvd unexpected msg %X in state %X, in role %X"),
3571 msg_type, session_entry->limSmeState,
3572 GET_LIM_SYSTEM_ROLE(session_entry));
3573 goto end;
3574 }
3575 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3576 &session_entry->dph.dphHashTable);
3577 if (sta_ds == NULL) {
3578 lim_log(mac_ctx, LOGE, FL(
3579 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3580 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003581 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582
3583 /*
3584 * send a DISASSOC_IND message to WSM to make sure
3585 * the state in WSM and LIM is the same
3586 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003587 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 eSIR_SME_STA_NOT_ASSOCIATED,
3589 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3590 session_entry->smeSessionId,
3591 session_entry->transactionId,
3592 session_entry);
3593 goto end;
3594 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303595 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003596 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303597 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 lim_log(mac_ctx, LOG1, FL(
3599 "peerMacAddr mismatched for aid %d, peer "),
3600 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003601 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602 goto end;
3603 }
3604
3605 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3606 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3607 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3608 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3609 (msg_type != eWNI_SME_ASSOC_CNF))) {
3610 lim_log(mac_ctx, LOG1, FL(
3611 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3612 "StaD mlmState : %d"),
3613 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003614 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 goto end;
3616 }
3617 /*
3618 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3619 * has been received
3620 */
3621 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3622 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3623 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3624
3625 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3626 /*
3627 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3628 * when it had received Assoc Request frame. Now, PE just needs
3629 * to send association rsp frame to the requesting BTAMP-STA.
3630 */
3631 sta_ds->mlmStaContext.mlmState =
3632 eLIM_MLM_LINK_ESTABLISHED_STATE;
3633 lim_log(mac_ctx, LOG1,
3634 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3635 sta_ds->assocId);
3636 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3637 sta_ds->assocId, sta_ds->staAddr,
3638 sta_ds->mlmStaContext.subType, sta_ds,
3639 session_entry);
3640 goto end;
3641 } else {
3642 /*
3643 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3644 * to be associated since the HAL sta entry is created for
3645 * denied STA we need to remove this HAL entry.
3646 * So to do that set updateContext to 1
3647 */
3648 if (!sta_ds->mlmStaContext.updateContext)
3649 sta_ds->mlmStaContext.updateContext = 1;
3650 lim_log(mac_ctx, LOG1,
3651 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3652 assoc_cnf.statusCode, sta_ds->assocId);
3653 lim_reject_association(mac_ctx, sta_ds->staAddr,
3654 sta_ds->mlmStaContext.subType,
3655 true, sta_ds->mlmStaContext.authType,
3656 sta_ds->assocId, true,
3657 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3658 session_entry);
3659 }
3660end:
3661 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3662 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3663 assoc_req = (tpSirAssocReq)
3664 session_entry->parsedAssocReq[sta_ds->assocId];
3665 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303666 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667 assoc_req->assocReqFrame = NULL;
3668 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303669 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3671 }
3672}
3673
3674static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3675{
3676 tpDphHashNode pStaDs;
3677 tSirMacAddr peerMac;
3678 tpSirAddtsReq pSirAddts;
3679 uint32_t timeout;
3680 tpPESession psessionEntry;
3681 uint8_t sessionId; /* PE sessionId */
3682 uint8_t smesessionId;
3683 uint16_t smetransactionId;
3684
3685 if (pMsgBuf == NULL) {
3686 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3687 return;
3688 }
3689
3690 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3691 &smetransactionId);
3692
3693 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3694
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003695 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3696 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697 if (psessionEntry == NULL) {
3698 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3699 return;
3700 }
3701#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3702 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3703 0);
3704#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3705
3706 /* if sta
3707 * - verify assoc state
3708 * - send addts request to ap
3709 * - wait for addts response from ap
3710 * if ap, just ignore with error log
3711 */
3712 PELOG1(lim_log(pMac, LOG1,
3713 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3714 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3715 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3716 )
3717
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003718 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3720 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3721 psessionEntry, pSirAddts->req.tspec,
3722 smesessionId, smetransactionId);
3723 return;
3724 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725
3726 pStaDs =
3727 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3728 &psessionEntry->dph.dphHashTable);
3729
3730 if (pStaDs == NULL) {
3731 PELOGE(lim_log
3732 (pMac, LOGE, "Cannot find AP context for addts req");
3733 )
3734 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3735 psessionEntry, pSirAddts->req.tspec,
3736 smesessionId, smetransactionId);
3737 return;
3738 }
3739
3740 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3741 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3742 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3743 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3744 psessionEntry, pSirAddts->req.tspec,
3745 smesessionId, smetransactionId);
3746 return;
3747 }
3748
3749 pSirAddts->req.wsmTspecPresent = 0;
3750 pSirAddts->req.wmeTspecPresent = 0;
3751 pSirAddts->req.lleTspecPresent = 0;
3752
3753 if ((pStaDs->wsmEnabled) &&
3754 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3755 SIR_MAC_ACCESSPOLICY_EDCA))
3756 pSirAddts->req.wsmTspecPresent = 1;
3757 else if (pStaDs->wmeEnabled)
3758 pSirAddts->req.wmeTspecPresent = 1;
3759 else if (pStaDs->lleEnabled)
3760 pSirAddts->req.lleTspecPresent = 1;
3761 else {
3762 PELOGW(lim_log
3763 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3764 )
3765 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3766 psessionEntry, pSirAddts->req.tspec,
3767 smesessionId, smetransactionId);
3768 return;
3769 }
3770
3771 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3772 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3773 lim_log(pMac, LOGE,
3774 "AddTs received in invalid LIMsme state (%d)",
3775 psessionEntry->limSmeState);
3776 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3777 psessionEntry, pSirAddts->req.tspec,
3778 smesessionId, smetransactionId);
3779 return;
3780 }
3781
3782 if (pMac->lim.gLimAddtsSent) {
3783 lim_log(pMac, LOGE,
3784 "Addts (token %d, tsid %d, up %d) is still pending",
3785 pMac->lim.gLimAddtsReq.req.dialogToken,
3786 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3787 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3788 userPrio);
3789 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3790 psessionEntry, pSirAddts->req.tspec,
3791 smesessionId, smetransactionId);
3792 return;
3793 }
3794
3795 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3796
3797 /* save the addts request */
3798 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303799 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3801
3802 /* ship out the message now */
3803 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3804 psessionEntry);
3805 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3806 /* start a timer to wait for the response */
3807 if (pSirAddts->timeout)
3808 timeout = pSirAddts->timeout;
3809 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3810 eSIR_SUCCESS) {
3811 lim_log(pMac, LOGP,
3812 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3813 WNI_CFG_ADDTS_RSP_TIMEOUT);
3814 return;
3815 }
3816
3817 timeout = SYS_MS_TO_TICKS(timeout);
3818 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3819 != TX_SUCCESS) {
3820 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3821 return;
3822 }
3823 pMac->lim.gLimAddtsRspTimerCount++;
3824 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3825 pMac->lim.gLimAddtsRspTimerCount) !=
3826 TX_SUCCESS) {
3827 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3828 return;
3829 }
3830 MTRACE(mac_trace
3831 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3832 eLIM_ADDTS_RSP_TIMER));
3833
3834 /* add the sessionId to the timer object */
3835 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3836 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3837 TX_SUCCESS) {
3838 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3839 return;
3840 }
3841 return;
3842}
3843
3844static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3845{
3846 tSirMacAddr peerMacAddr;
3847 uint8_t ac;
3848 tSirMacTSInfo *pTsinfo;
3849 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3850 tpDphHashNode pStaDs = NULL;
3851 tpPESession psessionEntry;
3852 uint8_t sessionId;
3853 uint32_t status = eSIR_SUCCESS;
3854 uint8_t smesessionId;
3855 uint16_t smetransactionId;
3856
3857 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3858 &smetransactionId);
3859
3860 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003861 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 &sessionId);
3863 if (psessionEntry == NULL) {
3864 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3865 status = eSIR_FAILURE;
3866 goto end;
3867 }
3868#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3869 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3870 0);
3871#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3872
3873 if (eSIR_SUCCESS !=
3874 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3875 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3876 status = eSIR_FAILURE;
3877 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3878 smesessionId, smetransactionId);
3879 return;
3880 }
3881
3882 lim_log(pMac, LOG1,
3883 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3884 MAC_ADDRESS_STR),
3885 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3886
3887 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3888 pDeltsReq->req.wmeTspecPresent,
3889 &pDeltsReq->req.tsinfo,
3890 &pDeltsReq->req.tspec, psessionEntry);
3891
3892 pTsinfo =
3893 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3894 tsinfo : &pDeltsReq->req.tsinfo;
3895
3896 /* We've successfully send DELTS frame to AP. Update the
3897 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3898 * is no longer trigger enabled or delivery enabled
3899 */
3900 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3901 pTsinfo, CLEAR_UAPSD_MASK);
3902
3903 /* We're deleting the TSPEC, so this particular AC is no longer
3904 * admitted. PE needs to downgrade the EDCA
3905 * parameters(for the AC for which TS is being deleted) to the
3906 * next best AC for which ACM is not enabled, and send the
3907 * updated values to HAL.
3908 */
3909 ac = upToAc(pTsinfo->traffic.userPrio);
3910
3911 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3912 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3913 ~(1 << ac);
3914 } else if (pTsinfo->traffic.direction ==
3915 SIR_MAC_DIRECTION_DNLINK) {
3916 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3917 ~(1 << ac);
3918 } else if (pTsinfo->traffic.direction ==
3919 SIR_MAC_DIRECTION_BIDIR) {
3920 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3921 ~(1 << ac);
3922 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3923 ~(1 << ac);
3924 }
3925
3926 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3927 psessionEntry);
3928
3929 pStaDs =
3930 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3931 &psessionEntry->dph.dphHashTable);
3932 if (pStaDs != NULL) {
3933 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3934 pStaDs->bssId);
3935 status = eSIR_SUCCESS;
3936 } else {
3937 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3938 status = eSIR_FAILURE;
3939 }
3940#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003942#endif
3943
3944 /* send an sme response back */
3945end:
3946 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3947 smesessionId, smetransactionId);
3948}
3949
Jeff Johnson801f1532016-10-07 07:54:50 -07003950static void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac,
3951 uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952{
3953 /* fetch the sessionEntry based on the sessionId */
3954 tpPESession psessionEntry;
3955 psessionEntry = pe_find_session_by_session_id(pMac,
3956 pMac->lim.limTimers.gLimAddtsRspTimer.
3957 sessionId);
3958 if (psessionEntry == NULL) {
3959 lim_log(pMac, LOGP,
3960 FL("Session Does not exist for given sessionID"));
3961 return;
3962 }
3963
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003964 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3966 GET_LIM_SYSTEM_ROLE(psessionEntry));
3967 pMac->lim.gLimAddtsSent = false;
3968 return;
3969 }
3970
3971 if (!pMac->lim.gLimAddtsSent) {
3972 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3973 return;
3974 }
3975
3976 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3977 lim_log(pMac, LOGE,
3978 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3979 pMac->lim.gLimAddtsRspTimerCount);
3980 return;
3981 }
3982 /* this a real response timeout */
3983 pMac->lim.gLimAddtsSent = false;
3984 pMac->lim.gLimAddtsRspTimerCount++;
3985
3986 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3987 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3988 psessionEntry->smeSessionId,
3989 psessionEntry->transactionId);
3990}
3991
3992/**
3993 * __lim_process_sme_get_statistics_request()
3994 *
3995 ***FUNCTION:
3996 *
3997 *
3998 ***NOTE:
3999 *
4000 * @param pMac Pointer to Global MAC structure
4001 * @param *pMsgBuf A pointer to the SME message buffer
4002 * @return None
4003 */
4004static void
4005__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4006{
4007 tpAniGetPEStatsReq pPEStatsReq;
4008 tSirMsgQ msgQ;
4009
4010 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4011
4012 msgQ.type = WMA_GET_STATISTICS_REQ;
4013
4014 msgQ.reserved = 0;
4015 msgQ.bodyptr = pMsgBuf;
4016 msgQ.bodyval = 0;
4017 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4018
4019 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304020 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021 pMsgBuf = NULL;
4022 lim_log(pMac, LOGP, "Unable to forward request");
4023 return;
4024 }
4025
4026 return;
4027}
4028
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004029#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004031 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004033 * @pMac: Pointer to Global MAC structure
4034 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004036 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 */
4038static void
4039__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4040{
4041 tSirMsgQ msgQ;
4042
4043 msgQ.type = WMA_TSM_STATS_REQ;
4044 msgQ.reserved = 0;
4045 msgQ.bodyptr = pMsgBuf;
4046 msgQ.bodyval = 0;
4047 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4048
4049 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304050 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 pMsgBuf = NULL;
4052 lim_log(pMac, LOGP, "Unable to forward request");
4053 return;
4054 }
4055}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004056#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057
4058static void
4059__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4060{
4061 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4062 tpPESession psessionEntry;
4063 uint8_t sessionId; /* PE sessionID */
4064
4065 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4066
4067 if (pMsgBuf == NULL) {
4068 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4069 return;
4070 }
4071
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304072 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 if (NULL == pUpdateAPWPSIEsReq) {
4074 lim_log(pMac, LOGP,
4075 FL
4076 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4077 return;
4078 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304079 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 sizeof(struct sSirUpdateAPWPSIEsReq));
4081
4082 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004083 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 &sessionId);
4085 if (psessionEntry == NULL) {
4086 lim_log(pMac, LOGW,
4087 FL("Session does not exist for given BSSID"));
4088 goto end;
4089 }
4090
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304091 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 sizeof(tSirAPWPSIEs));
4093
4094 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4095 lim_send_beacon_ind(pMac, psessionEntry);
4096
4097end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304098 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 return;
4100}
4101
4102void
4103lim_send_vdev_restart(tpAniSirGlobal pMac,
4104 tpPESession psessionEntry, uint8_t sessionId)
4105{
4106 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4107 tSirMsgQ msgQ;
4108 tSirRetStatus retCode = eSIR_SUCCESS;
4109
4110 if (psessionEntry == NULL) {
4111 PELOGE(lim_log
4112 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4113 __LINE__);
4114 )
4115 return;
4116 }
4117
4118 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304119 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 if (NULL == pHalHiddenSsidVdevRestart) {
4121 PELOGE(lim_log
4122 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4123 __func__, __LINE__);
4124 )
4125 return;
4126 }
4127
4128 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4129 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4130
4131 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4132 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4133 msgQ.bodyval = 0;
4134
4135 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4136 if (eSIR_SUCCESS != retCode) {
4137 PELOGE(lim_log
4138 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4139 __LINE__);
4140 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304141 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 }
4143}
4144
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304145/**
4146 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4147 * @mac_ctx: Pointer to Global MAC structure
4148 * @msg_buf: Pointer to SME message buffer
4149 *
4150 * Return: None
4151 */
4152static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4153 uint32_t *msg_buf)
4154{
4155 tpPESession pe_session;
4156 tSirMsgQ wma_msg;
4157 tSirRetStatus status;
4158 tSirRoamOffloadScanReq *req_buffer;
4159 uint16_t local_ie_len;
4160 uint8_t *local_ie_buf;
4161
4162 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4163 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4164 req_buffer->sessionId);
4165
4166 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4167 if (!local_ie_buf) {
4168 lim_log(mac_ctx, LOGE, FL("Mem Alloc failed for local_ie_buf"));
4169 return;
4170 }
4171
4172 local_ie_len = req_buffer->assoc_ie.length;
4173 /* Update ext cap IE if present */
4174 if (local_ie_len &&
4175 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4176 local_ie_buf, &local_ie_len)) {
4177 req_buffer->assoc_ie.length = local_ie_len;
4178 qdf_mem_copy(req_buffer->assoc_ie.addIEdata, local_ie_buf,
4179 local_ie_len);
4180 }
4181 qdf_mem_free(local_ie_buf);
4182
4183 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4184 wma_msg.bodyptr = req_buffer;
4185
4186 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4187 if (eSIR_SUCCESS != status) {
4188 lim_log(mac_ctx, LOGE,
4189 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4190 qdf_mem_free(req_buffer);
4191 }
4192}
4193
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304194/*
4195 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4196 * @mac_ctx: Pointer to global mac context
4197 * @session: Pointer to PE session
4198 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4199 * 1 - Disable broadcast SSID
4200 *
4201 * Return: None
4202 */
4203static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4204 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304206 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4207 if (ssid_hidden != session->ssidHidden)
4208 session->ssidHidden = ssid_hidden;
4209 else {
4210 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304211 return;
4212 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213
4214 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304215 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216
4217 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304218 sch_set_fixed_beacon_fields(mac_ctx, session);
4219 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220
4221 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304222}
4223
4224/**
4225 * __lim_process_sme_session_update - process SME session update msg
4226 *
4227 * @mac_ctx: Pointer to global mac context
4228 * @msg_buf: Pointer to the received message buffer
4229 *
4230 * Return: None
4231 */
4232static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4233 uint32_t *msg_buf)
4234{
4235 struct sir_update_session_param *msg;
4236 tpPESession session;
4237
4238 if (!msg_buf) {
4239 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4240 return;
4241 }
4242
4243 msg = (struct sir_update_session_param *) msg_buf;
4244
4245 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4246 if (!session) {
4247 lim_log(mac_ctx, LOGW,
4248 "Session does not exist for given sessionId %d",
4249 msg->session_id);
4250 return;
4251 }
4252
4253 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4254 msg->param_type, msg->param_val);
4255 switch (msg->param_type) {
4256 case SIR_PARAM_SSID_HIDDEN:
4257 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4258 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304259 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4260 session->ignore_assoc_disallowed = msg->param_val;
4261 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304262 default:
4263 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4264 break;
4265 }
4266}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267
4268static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4269{
4270 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4271 tpPESession psessionEntry;
4272 uint8_t sessionId; /* PE sessionID */
4273
4274 if (pMsgBuf == NULL) {
4275 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4276 return;
4277 }
4278
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304279 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 if (NULL == pUpdateAPWPARSNIEsReq) {
4281 lim_log(pMac, LOGP,
4282 FL
4283 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4284 return;
4285 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304286 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4288
4289 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004290 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291 &sessionId);
4292 if (psessionEntry == NULL) {
4293 lim_log(pMac, LOGW,
4294 FL("Session does not exist for given BSSID"));
4295 goto end;
4296 }
4297
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304298 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4300
4301 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4302 &psessionEntry->
4303 pLimStartBssReq->rsnIE,
4304 psessionEntry);
4305
4306 psessionEntry->pLimStartBssReq->privacy = 1;
4307 psessionEntry->privacy = 1;
4308
4309 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4310 lim_send_beacon_ind(pMac, psessionEntry);
4311
4312end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304313 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 return;
4315} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4316
4317/*
4318 Update the beacon Interval dynamically if beaconInterval is different in MCC
4319 */
4320static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4321{
4322 tpSirChangeBIParams pChangeBIParams;
4323 tpPESession psessionEntry;
4324 uint8_t sessionId = 0;
4325 tUpdateBeaconParams beaconParams;
4326
4327 PELOG1(lim_log(pMac, LOG1,
4328 FL("received Update Beacon Interval message"));
4329 );
4330
4331 if (pMsgBuf == NULL) {
4332 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4333 return;
4334 }
4335
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304336 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4338
4339 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004340 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004341 &sessionId);
4342 if (psessionEntry == NULL) {
4343 lim_log(pMac, LOGE,
4344 FL("Session does not exist for given BSSID"));
4345 return;
4346 }
4347
4348 /*Update sessionEntry Beacon Interval */
4349 if (psessionEntry->beaconParams.beaconInterval !=
4350 pChangeBIParams->beaconInterval) {
4351 psessionEntry->beaconParams.beaconInterval =
4352 pChangeBIParams->beaconInterval;
4353 }
4354
4355 /*Update sch beaconInterval */
4356 if (pMac->sch.schObject.gSchBeaconInterval !=
4357 pChangeBIParams->beaconInterval) {
4358 pMac->sch.schObject.gSchBeaconInterval =
4359 pChangeBIParams->beaconInterval;
4360
4361 PELOG1(lim_log(pMac, LOG1,
4362 FL
4363 ("LIM send update BeaconInterval Indication : %d"),
4364 pChangeBIParams->beaconInterval);
4365 );
4366
4367 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4368 /* Update beacon */
4369 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4370
4371 beaconParams.bssIdx = psessionEntry->bssIdx;
4372 /* Set change in beacon Interval */
4373 beaconParams.beaconInterval =
4374 pChangeBIParams->beaconInterval;
4375 beaconParams.paramChangeBitmap =
4376 PARAM_BCN_INTERVAL_CHANGED;
4377 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4378 }
4379 }
4380
4381 return;
4382} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4383
4384#ifdef QCA_HT_2040_COEX
4385static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4386 uint32_t *pMsgBuf)
4387{
4388 tpSirSetHT2040Mode pSetHT2040Mode;
4389 tpPESession psessionEntry;
4390 uint8_t sessionId = 0;
4391 cds_msg_t msg;
4392 tUpdateVHTOpMode *pHtOpMode = NULL;
4393 uint16_t staId = 0;
4394 tpDphHashNode pStaDs = NULL;
4395
4396 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4397 if (pMsgBuf == NULL) {
4398 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4399 return;
4400 }
4401
4402 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4403
4404 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004405 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 &sessionId);
4407 if (psessionEntry == NULL) {
4408 lim_log(pMac, LOG1,
4409 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004410 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 return;
4412 }
4413
4414 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4415 pSetHT2040Mode->cbMode);
4416 /*Update sessionEntry HT related fields */
4417 switch (pSetHT2040Mode->cbMode) {
4418 case PHY_SINGLE_CHANNEL_CENTERED:
4419 psessionEntry->htSecondaryChannelOffset =
4420 PHY_SINGLE_CHANNEL_CENTERED;
4421 psessionEntry->htRecommendedTxWidthSet = 0;
4422 if (pSetHT2040Mode->obssEnabled)
4423 psessionEntry->htSupportedChannelWidthSet
4424 = eHT_CHANNEL_WIDTH_40MHZ;
4425 else
4426 psessionEntry->htSupportedChannelWidthSet
4427 = eHT_CHANNEL_WIDTH_20MHZ;
4428 break;
4429 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4430 psessionEntry->htSecondaryChannelOffset =
4431 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4432 psessionEntry->htRecommendedTxWidthSet = 1;
4433 break;
4434 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4435 psessionEntry->htSecondaryChannelOffset =
4436 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4437 psessionEntry->htRecommendedTxWidthSet = 1;
4438 break;
4439 default:
4440 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4441 return;
4442 }
4443
4444 /* Update beacon */
4445 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4446 lim_send_beacon_ind(pMac, psessionEntry);
4447
4448 /* update OP Mode for each associated peer */
4449 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4450 pStaDs = dph_get_hash_entry(pMac, staId,
4451 &psessionEntry->dph.dphHashTable);
4452 if (NULL == pStaDs)
4453 continue;
4454
4455 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304456 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 if (NULL == pHtOpMode) {
4458 lim_log(pMac, LOGE,
4459 FL
4460 ("%s: Not able to allocate memory for setting OP mode"),
4461 __func__);
4462 return;
4463 }
4464 pHtOpMode->opMode =
4465 (psessionEntry->htSecondaryChannelOffset ==
4466 PHY_SINGLE_CHANNEL_CENTERED) ?
4467 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4468 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304469 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 sizeof(tSirMacAddr));
4471 pHtOpMode->smesessionId = sessionId;
4472
4473 msg.type = WMA_UPDATE_OP_MODE;
4474 msg.reserved = 0;
4475 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304476 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304477 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 lim_log(pMac, LOGE,
4479 FL
4480 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4481 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304482 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 return;
4484 }
4485 lim_log(pMac, LOG1,
4486 FL
4487 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4488 __func__, pHtOpMode->opMode, staId);
4489
4490 } else
4491 lim_log(pMac, LOG1,
4492 FL("%s: station %d does not support HT40\n"),
4493 __func__, staId);
4494 }
4495
4496 return;
4497}
4498#endif
4499
4500/* -------------------------------------------------------------------- */
4501/**
4502 * __lim_process_report_message
4503 *
4504 * FUNCTION: Processes the next received Radio Resource Management message
4505 *
4506 * LOGIC:
4507 *
4508 * ASSUMPTIONS:
4509 *
4510 * NOTE:
4511 *
4512 * @param None
4513 * @return None
4514 */
4515
Jeff Johnson801f1532016-10-07 07:54:50 -07004516static void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 switch (pMsg->type) {
4519 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4520 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4521 break;
4522 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004524 break;
4525 default:
4526 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528}
4529
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530/* -------------------------------------------------------------------- */
4531/**
4532 * lim_send_set_max_tx_power_req
4533 *
4534 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4535 *
4536 * LOGIC:
4537 *
4538 * ASSUMPTIONS:
4539 *
4540 * NOTE:
4541 *
4542 * @param txPower txPower to be set.
4543 * @param pSessionEntry session entry.
4544 * @return None
4545 */
4546tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004547lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 tpPESession pSessionEntry)
4549{
4550 tpMaxTxPowerParams pMaxTxParams = NULL;
4551 tSirRetStatus retCode = eSIR_SUCCESS;
4552 tSirMsgQ msgQ;
4553
4554 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304555 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 return eSIR_FAILURE;
4557 }
4558
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304559 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 if (NULL == pMaxTxParams) {
4561 lim_log(pMac, LOGP,
4562 FL("Unable to allocate memory for pMaxTxParams "));
4563 return eSIR_MEM_ALLOC_FAILED;
4564
4565 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304567 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304568 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304569 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004570 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304571 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572
4573 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4574 msgQ.bodyptr = pMaxTxParams;
4575 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304576 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4578 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4579 if (eSIR_SUCCESS != retCode) {
4580 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304581 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582 }
4583 return retCode;
4584}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585
4586/**
4587 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4588 *
4589 * @mac_ctx: Pointer to Global MAC structure
4590 * @msg_buf: pointer to the SME message buffer
4591 *
4592 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4593 * from SME. It Register this information within PE.
4594 *
4595 * Return: None
4596 */
4597static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4598 uint32_t *msg_buf)
4599{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304600 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4602 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4603 struct mgmt_frm_reg_info *next = NULL;
4604 bool match = false;
4605
4606 lim_log(mac_ctx, LOG1, FL(
4607 "registerFrame %d, frameType %d, matchLen %d"),
4608 sme_req->registerFrame, sme_req->frameType,
4609 sme_req->matchLen);
4610 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304611 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304612 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4613 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304614 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615
4616 while (lim_mgmt_regn != NULL) {
4617 if (lim_mgmt_regn->frameType != sme_req->frameType)
4618 goto skip_match;
4619 if (sme_req->matchLen) {
4620 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304621 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 sme_req->matchData,
4623 lim_mgmt_regn->matchLen))) {
4624 /* found match! */
4625 match = true;
4626 break;
4627 }
4628 } else {
4629 /* found match! */
4630 match = true;
4631 break;
4632 }
4633skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304634 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304635 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304637 (qdf_list_node_t *)lim_mgmt_regn,
4638 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304639 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 lim_mgmt_regn = next;
4641 next = NULL;
4642 }
4643 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304644 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304645 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304647 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304648 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304649 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 }
4651
4652 if (sme_req->registerFrame) {
4653 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304654 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 sme_req->matchLen);
4656 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304657 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 sizeof(struct mgmt_frm_reg_info) +
4659 sme_req->matchLen, 0);
4660 lim_mgmt_regn->frameType = sme_req->frameType;
4661 lim_mgmt_regn->matchLen = sme_req->matchLen;
4662 lim_mgmt_regn->sessionId = sme_req->sessionId;
4663 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304664 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 sme_req->matchData,
4666 sme_req->matchLen);
4667 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304668 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304670 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 gLimMgmtFrameRegistratinQueue,
4672 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304673 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 &mac_ctx->lim.lim_frame_register_lock);
4675 }
4676 }
4677 return;
4678}
4679
4680static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4681{
4682 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4683 pMac->lim.gDeferMsgTypeForNOA);
4684 pMac->lim.gDeferMsgTypeForNOA = 0;
4685 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4686 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304687 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4689 }
4690}
4691
4692/**
4693 * lim_process_regd_defd_sme_req_after_noa_start()
4694 *
4695 * mac_ctx: Pointer to Global MAC structure
4696 *
4697 * This function is called to process deferred sme req message
4698 * after noa start.
4699 *
4700 * Return: None
4701 */
4702void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4703{
4704 bool buf_consumed = true;
4705
4706 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4707 mac_ctx->lim.gDeferMsgTypeForNOA);
4708
4709 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4710 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4711 lim_log(mac_ctx, LOGW,
4712 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4713 lim_log(mac_ctx, LOGW,
4714 FL("It may happen when NOA start ind and timeout happen at the same time"));
4715 return;
4716 }
4717 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4718 case eWNI_SME_SCAN_REQ:
4719 __lim_process_sme_scan_req(mac_ctx,
4720 mac_ctx->lim.gpDefdSmeMsgForNOA);
4721 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4723 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4724 mac_ctx->lim.gpDefdSmeMsgForNOA);
4725 /*
4726 * lim_process_remain_on_chnl_req doesnt want us to free
4727 * the buffer since it is freed in lim_remain_on_chn_rsp.
4728 * this change is to avoid "double free"
4729 */
4730 if (false == buf_consumed)
4731 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4732 break;
4733 case eWNI_SME_JOIN_REQ:
4734 __lim_process_sme_join_req(mac_ctx,
4735 mac_ctx->lim.gpDefdSmeMsgForNOA);
4736 break;
4737 default:
4738 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4739 mac_ctx->lim.gDeferMsgTypeForNOA);
4740 break;
4741 }
4742 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4743}
4744
4745static void
4746__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4747{
4748 tpSirResetAPCapsChange pResetCapsChange;
4749 tpPESession psessionEntry;
4750 uint8_t sessionId = 0;
4751 if (pMsgBuf == NULL) {
4752 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4753 return;
4754 }
4755
4756 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4757 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004758 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4759 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 if (psessionEntry == NULL) {
4761 lim_log(pMac, LOGE,
4762 FL("Session does not exist for given BSSID"));
4763 return;
4764 }
4765
4766 psessionEntry->limSentCapsChangeNtf = false;
4767 return;
4768}
4769
4770/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304771 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4772 * @mac_ctx: Mac pointer
4773 * @msg_buf: Msg pointer containing the callback
4774 *
4775 * This function is used to save the p2p ack indication callback in PE.
4776 *
4777 * Return: None
4778 */
4779static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4780 uint32_t *msg_buf)
4781{
4782 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4783 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4784
4785 if (NULL == msg_buf) {
4786 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4787 return;
4788 }
4789 if (sme_req->callback)
4790 mac_ctx->p2p_ack_ind_cb =
4791 sme_req->callback;
4792 else
4793 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4794}
4795
4796/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304797 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4798 * indication callback in PE.
4799 * @mac_ptr: Mac pointer
4800 * @msg_buf: Msg pointer containing the callback
4801 *
4802 * This function is used save the Management frame
4803 * indication callback in PE.
4804 *
4805 * Return: None
4806 */
4807static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4808 uint32_t *msg_buf)
4809{
4810 struct sir_sme_mgmt_frame_cb_req *sme_req =
4811 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4812
4813 if (NULL == msg_buf) {
4814 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4815 return;
4816 }
4817 if (sme_req->callback)
4818 mac_ctx->mgmt_frame_ind_cb =
4819 (sir_mgmt_frame_ind_callback)sme_req->callback;
4820 else
4821 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4822}
4823
4824/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304825 *__lim_process_send_disassoc_frame: function processes disassoc frame
4826 * @mac_ctx: pointer to mac context
4827 * @msg_buf: message buffer
4828 *
4829 * function processes disassoc request received from SME
4830 *
4831 * return: none
4832 */
4833static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4834 uint32_t *msg_buf)
4835{
4836 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4837 tSirRetStatus status;
4838 tpPESession session_entry = NULL;
4839 uint8_t sme_session_id;
4840 uint16_t sme_trans_id;
4841
4842 if (msg_buf == NULL) {
4843 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4844 return;
4845 }
4846
4847 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4848 &sme_trans_id);
4849
4850 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4851 &sme_send_disassoc_frame_req,
4852 (uint8_t *)msg_buf);
4853
4854 if ((eSIR_FAILURE == status) ||
4855 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4856 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4857 PELOGE(lim_log(mac_ctx, LOGE,
4858 FL("received invalid SME_DISASSOC_REQ message"));)
4859 return;
4860 }
4861
4862 session_entry = pe_find_session_by_sme_session_id(
4863 mac_ctx, sme_session_id);
4864 if (session_entry == NULL) {
4865 lim_log(mac_ctx, LOGE,
4866 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4867 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4868 return;
4869 }
4870
4871 lim_log(mac_ctx, LOG1,
4872 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4873 sme_send_disassoc_frame_req.msg_type,
4874 sme_send_disassoc_frame_req.length,
4875 sme_send_disassoc_frame_req.session_id,
4876 sme_send_disassoc_frame_req.trans_id,
4877 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4878 sme_send_disassoc_frame_req.reason,
4879 sme_send_disassoc_frame_req.wait_for_ack);
4880
4881 lim_send_disassoc_mgmt_frame(mac_ctx,
4882 sme_send_disassoc_frame_req.reason,
4883 sme_send_disassoc_frame_req.peer_mac,
4884 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4885}
4886
4887/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004888 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4889 * @mac_ctx: Pointer to Global MAC structure
4890 * @pdev_id: pdev id to set the IE.
4891 * @nss: Nss values to prepare the HT IE.
4892 *
4893 * Prepares the HT IE with self capabilities for different
4894 * Nss values and sends the set HT IE req to FW.
4895 *
4896 * Return: None
4897 */
4898static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4899 uint8_t nss)
4900{
4901 struct set_ie_param *ie_params;
4902 tSirMsgQ msg;
4903 tSirRetStatus rc = eSIR_SUCCESS;
4904 uint8_t *p_ie = NULL;
4905 tHtCaps *p_ht_cap;
4906 int i;
4907
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004908 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004909 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4910 if (NULL == ie_params) {
4911 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4912 return;
4913 }
4914 ie_params->nss = i;
4915 ie_params->pdev_id = pdev_id;
4916 ie_params->ie_type = DOT11_HT_IE;
4917 /* 2 for IE len and EID */
4918 ie_params->ie_len = 2 + sizeof(tHtCaps);
4919 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4920 if (NULL == ie_params->ie_ptr) {
4921 qdf_mem_free(ie_params);
4922 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4923 return;
4924 }
4925 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4926 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4927 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4928 ie_params->ie_len);
4929
4930 if (NSS_1x1_MODE == i) {
4931 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4932 ie_params->ie_len,
4933 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004934 if (NULL == p_ie) {
4935 qdf_mem_free(ie_params->ie_ptr);
4936 qdf_mem_free(ie_params);
4937 lim_log(mac_ctx, LOGE,
4938 FL("failed to get IE ptr"));
4939 return;
4940 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004941 p_ht_cap = (tHtCaps *)&p_ie[2];
4942 p_ht_cap->supportedMCSSet[1] = 0;
4943 p_ht_cap->txSTBC = 0;
4944 }
4945
4946 msg.type = WMA_SET_PDEV_IE_REQ;
4947 msg.bodyptr = ie_params;
4948 msg.bodyval = 0;
4949
4950 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4951 if (rc != eSIR_SUCCESS) {
4952 lim_log(mac_ctx, LOGE,
4953 FL("wma_post_ctrl_msg() return failure"));
4954 qdf_mem_free(ie_params->ie_ptr);
4955 qdf_mem_free(ie_params);
4956 return;
4957 }
4958 }
4959}
4960
4961/**
4962 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4963 * @mac_ctx: Pointer to Global MAC structure
4964 * @pdev_id: pdev id to set the IE.
4965 * @nss: Nss values to prepare the VHT IE.
4966 *
4967 * Prepares the VHT IE with self capabilities for different
4968 * Nss values and sends the set VHT IE req to FW.
4969 *
4970 * Return: None
4971 */
4972static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4973 uint8_t nss)
4974{
4975 struct set_ie_param *ie_params;
4976 tSirMsgQ msg;
4977 tSirRetStatus rc = eSIR_SUCCESS;
4978 uint8_t *p_ie = NULL;
4979 tSirMacVHTCapabilityInfo *vht_cap;
4980 int i;
4981 tSirVhtMcsInfo *vht_mcs;
4982
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004983 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004984 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4985 if (NULL == ie_params) {
4986 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4987 return;
4988 }
4989 ie_params->nss = i;
4990 ie_params->pdev_id = pdev_id;
4991 ie_params->ie_type = DOT11_VHT_IE;
4992 /* 2 for IE len and EID */
4993 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4994 sizeof(tSirVhtMcsInfo);
4995 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4996 if (NULL == ie_params->ie_ptr) {
4997 qdf_mem_free(ie_params);
4998 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4999 return;
5000 }
5001 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
5002 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
5003 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
5004 ie_params->ie_len);
5005
5006 if (NSS_1x1_MODE == i) {
5007 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
5008 ie_params->ie_len,
5009 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07005010 if (NULL == p_ie) {
5011 qdf_mem_free(ie_params->ie_ptr);
5012 qdf_mem_free(ie_params);
5013 lim_log(mac_ctx, LOGE,
5014 FL("failed to get IE ptr"));
5015 return;
5016 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005017 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
5018 vht_cap->txSTBC = 0;
5019 vht_mcs =
5020 (tSirVhtMcsInfo *)&p_ie[2 +
5021 sizeof(tSirMacVHTCapabilityInfo)];
5022 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5023 vht_mcs->rxHighest =
5024 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5025 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5026 vht_mcs->txHighest =
5027 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5028 }
5029 msg.type = WMA_SET_PDEV_IE_REQ;
5030 msg.bodyptr = ie_params;
5031 msg.bodyval = 0;
5032
5033 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5034 if (rc != eSIR_SUCCESS) {
5035 lim_log(mac_ctx, LOGE,
5036 FL("wma_post_ctrl_msg failure"));
5037 qdf_mem_free(ie_params->ie_ptr);
5038 qdf_mem_free(ie_params);
5039 return;
5040 }
5041 }
5042}
5043
5044/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005045 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5046 * @mac_ctx: Pointer to Global MAC structure
5047 * @msg_buf: Pointer to the SME message buffer
5048 *
5049 * This function is called by limProcessMessageQueue(). This function sets the
5050 * VDEV IEs to the FW.
5051 *
5052 * Return: None
5053 */
5054static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5055 uint32_t *msg_buf)
5056{
5057 struct sir_set_vdev_ies_per_band *p_msg =
5058 (struct sir_set_vdev_ies_per_band *)msg_buf;
5059
5060 if (NULL == p_msg) {
5061 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5062 return;
5063 }
5064
5065 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5066 p_msg->vdev_id);
5067 /* intentionally using NULL here so that self capabilty are sent */
5068 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5069 QDF_STATUS_SUCCESS)
5070 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5071}
5072
5073/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005074 * lim_process_set_pdev_IEs() - process the set pdev IE req
5075 * @mac_ctx: Pointer to Global MAC structure
5076 * @msg_buf: Pointer to the SME message buffer
5077 *
5078 * This function is called by limProcessMessageQueue(). This
5079 * function sets the PDEV IEs to the FW.
5080 *
5081 * Return: None
5082 */
5083static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5084{
5085 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5086
5087 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5088
5089 if (NULL == ht_vht_cfg) {
5090 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5091 return;
5092 }
5093
5094 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5095 ht_vht_cfg->nss);
5096 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5097
5098 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5099 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5100 ht_vht_cfg->nss);
5101}
5102
5103/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305104 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5105 *
5106 * access policy
5107 * @mac_ctx: pointer to mac context
5108 * @msg: message buffer
5109 *
5110 * function processes vendor IE and access policy from SME and updates PE
5111 *
5112 * session entry
5113 *
5114 * return: none
5115*/
5116static void lim_process_sme_update_access_policy_vendor_ie(
5117 tpAniSirGlobal mac_ctx,
5118 uint32_t *msg)
5119{
5120 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5121 struct sPESession *pe_session_entry;
5122 uint8_t num_bytes;
5123
5124 if (!msg) {
5125 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5126 return;
5127 }
5128 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5129 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5130 update_vendor_ie->sme_session_id);
5131
5132 if (!pe_session_entry) {
5133 lim_log(mac_ctx, LOGE,
5134 FL("Session does not exist for given sme session id(%hu)"),
5135 update_vendor_ie->sme_session_id);
5136 return;
5137 }
5138 if (pe_session_entry->access_policy_vendor_ie)
5139 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5140
5141 num_bytes = update_vendor_ie->ie[1] + 2;
5142 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5143
5144 if (!pe_session_entry->access_policy_vendor_ie) {
5145 lim_log(mac_ctx, LOGE,
5146 FL("Failed to allocate memory for vendor ie"));
5147 return;
5148 }
5149 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5150 &update_vendor_ie->ie[0], num_bytes);
5151
5152 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5153}
5154
5155/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 * lim_process_sme_req_messages()
5157 *
5158 ***FUNCTION:
5159 * This function is called by limProcessMessageQueue(). This
5160 * function processes SME request messages from HDD or upper layer
5161 * application.
5162 *
5163 ***LOGIC:
5164 *
5165 ***ASSUMPTIONS:
5166 *
5167 ***NOTE:
5168 *
5169 * @param pMac Pointer to Global MAC structure
5170 * @param msgType Indicates the SME message type
5171 * @param *pMsgBuf A pointer to the SME message buffer
5172 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5173 * false - if pMsgBuf is not to be freed.
5174 */
5175
5176bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5177{
5178 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5179 uint32_t *pMsgBuf = pMsg->bodyptr;
5180 tpSirSmeScanReq pScanReq;
5181 PELOG1(lim_log
5182 (pMac, LOG1,
5183 FL
5184 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5185 lim_msg_str(pMsg->type), pMsg->type,
5186 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5187 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5188 )
5189
5190 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5191 /* If no insert NOA required then execute the code below */
5192
5193 switch (pMsg->type) {
5194 case eWNI_SME_SYS_READY_IND:
5195 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5196 break;
5197
5198 case eWNI_SME_START_BSS_REQ:
5199 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5200 break;
5201
5202 case eWNI_SME_SCAN_REQ:
5203 __lim_process_sme_scan_req(pMac, pMsgBuf);
5204 break;
5205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5207 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5208 break;
5209
5210 case eWNI_SME_UPDATE_NOA:
5211 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5212 break;
5213 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5214 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5215 break;
5216 case eWNI_SME_JOIN_REQ:
5217 __lim_process_sme_join_req(pMac, pMsgBuf);
5218 break;
5219
5220 case eWNI_SME_REASSOC_REQ:
5221 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5222 break;
5223
5224 case eWNI_SME_DISASSOC_REQ:
5225 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5226 break;
5227
5228 case eWNI_SME_DISASSOC_CNF:
5229 case eWNI_SME_DEAUTH_CNF:
5230 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5231 break;
5232
5233 case eWNI_SME_DEAUTH_REQ:
5234 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5235 break;
5236
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305237 case eWNI_SME_SEND_DISASSOC_FRAME:
5238 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5239 break;
5240
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005241 case eWNI_SME_SETCONTEXT_REQ:
5242 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5243 break;
5244
5245 case eWNI_SME_STOP_BSS_REQ:
5246 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5247 break;
5248
5249 case eWNI_SME_ASSOC_CNF:
5250 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5251 PELOG1(lim_log(pMac,
5252 LOG1, FL("Received ASSOC_CNF message"));)
5253 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5254 pMsgBuf);
5255 break;
5256
5257 case eWNI_SME_ADDTS_REQ:
5258 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5259 __lim_process_sme_addts_req(pMac, pMsgBuf);
5260 break;
5261
5262 case eWNI_SME_DELTS_REQ:
5263 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5264 __lim_process_sme_delts_req(pMac, pMsgBuf);
5265 break;
5266
5267 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5268 PELOG1(lim_log
5269 (pMac, LOG1,
5270 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5271 )
5272 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5273 break;
5274
5275 case eWNI_SME_GET_STATISTICS_REQ:
5276 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5277 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5278 bufConsumed = false;
5279 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005280#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281 case eWNI_SME_GET_TSM_STATS_REQ:
5282 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5283 bufConsumed = false;
5284 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005285#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 case eWNI_SME_GET_ASSOC_STAS_REQ:
5287 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5288 break;
5289 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5290 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5291 break;
5292
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305293 case eWNI_SME_SESSION_UPDATE_PARAM:
5294 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305296 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5297 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5298 bufConsumed = false;
5299 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005300 case eWNI_SME_UPDATE_APWPSIE_REQ:
5301 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5302 break;
5303 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5304 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5305 break;
5306
5307 case eWNI_SME_SET_APWPARSNIEs_REQ:
5308 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5309 break;
5310
5311 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5312 /* Update the beaconInterval */
5313 __lim_process_sme_change_bi(pMac, pMsgBuf);
5314 break;
5315
5316#ifdef QCA_HT_2040_COEX
5317 case eWNI_SME_SET_HT_2040_MODE:
5318 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5319 break;
5320#endif
5321
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5323 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5324 __lim_process_report_message(pMac, pMsg);
5325 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 case eWNI_SME_FT_PRE_AUTH_REQ:
5328 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5329 break;
5330 case eWNI_SME_FT_UPDATE_KEY:
5331 lim_process_ft_update_key(pMac, pMsgBuf);
5332 break;
5333
5334 case eWNI_SME_FT_AGGR_QOS_REQ:
5335 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5336 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337
5338 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5339 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5340 break;
5341#ifdef FEATURE_WLAN_TDLS
5342 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5343 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5344 break;
5345 case eWNI_SME_TDLS_ADD_STA_REQ:
5346 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5347 break;
5348 case eWNI_SME_TDLS_DEL_STA_REQ:
5349 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5350 break;
5351 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5352 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5353 break;
5354#endif
5355 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5356 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5357 break;
5358
5359 case eWNI_SME_CHANNEL_CHANGE_REQ:
5360 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5361 break;
5362
5363 case eWNI_SME_START_BEACON_REQ:
5364 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5365 break;
5366
5367 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5368 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5369 break;
5370
5371 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5372 lim_process_update_add_ies(pMac, pMsgBuf);
5373 break;
5374
5375 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5376 lim_process_modify_add_ies(pMac, pMsgBuf);
5377 break;
5378 case eWNI_SME_SET_HW_MODE_REQ:
5379 lim_process_set_hw_mode(pMac, pMsgBuf);
5380 break;
5381 case eWNI_SME_NSS_UPDATE_REQ:
5382 lim_process_nss_update_request(pMac, pMsgBuf);
5383 break;
5384 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5385 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5386 break;
5387 case eWNI_SME_SET_IE_REQ:
5388 lim_process_set_ie_req(pMac, pMsgBuf);
5389 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305390 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5391 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5392 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305393 case eWNI_SME_EXT_CHANGE_CHANNEL:
5394 lim_process_ext_change_channel(pMac, pMsgBuf);
5395 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005396 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5397 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5398 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005399 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5400 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005401 break;
5402 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5403 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5404 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005405 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005406 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005407 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005408 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005409 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305410 case eWNI_SME_REGISTER_P2P_ACK_CB:
5411 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5412 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305413 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5414 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5415 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305417 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418 pMsg->bodyptr = NULL;
5419 break;
5420 } /* switch (msgType) */
5421
5422 return bufConsumed;
5423} /*** end lim_process_sme_req_messages() ***/
5424
5425/**
5426 * lim_process_sme_start_beacon_req()
5427 *
5428 ***FUNCTION:
5429 * This function is called by limProcessMessageQueue(). This
5430 * function processes SME request messages from HDD or upper layer
5431 * application.
5432 *
5433 ***LOGIC:
5434 *
5435 ***ASSUMPTIONS:
5436 *
5437 ***NOTE:
5438 *
5439 * @param pMac Pointer to Global MAC structure
5440 * @param msgType Indicates the SME message type
5441 * @param *pMsgBuf A pointer to the SME message buffer
5442 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5443 * false - if pMsgBuf is not to be freed.
5444 */
5445static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5446{
5447 tpSirStartBeaconIndication pBeaconStartInd;
5448 tpPESession psessionEntry;
5449 uint8_t sessionId; /* PE sessionID */
5450
5451 if (pMsg == NULL) {
5452 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5453 return;
5454 }
5455
5456 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5457 psessionEntry = pe_find_session_by_bssid(pMac,
5458 pBeaconStartInd->bssid,
5459 &sessionId);
5460 if (psessionEntry == NULL) {
5461 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5462 lim_log(pMac, LOGE,
5463 FL("Session does not exist for given bssId"));
5464 return;
5465 }
5466
5467 if (pBeaconStartInd->beaconStartStatus == true) {
5468 /*
5469 * Currently this Indication comes from SAP
5470 * to start Beacon Tx on a DFS channel
5471 * since beaconing has to be done on DFS
5472 * channel only after CAC WAIT is completed.
5473 * On a DFS Channel LIM does not start beacon
5474 * Tx right after the WMA_ADD_BSS_RSP.
5475 */
5476 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305477 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478 FL("Start Beacon with ssid %s Ch %d"),
5479 psessionEntry->ssId.ssId,
5480 psessionEntry->currentOperChannel);
5481 lim_send_beacon_ind(pMac, psessionEntry);
5482 } else {
5483 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5484 return;
5485 }
5486}
5487
5488/**
5489 * lim_process_sme_channel_change_request() - process sme ch change req
5490 *
5491 * @mac_ctx: Pointer to Global MAC structure
5492 * @msg_buf: pointer to the SME message buffer
5493 *
5494 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5495 *
5496 * Return: None
5497 */
5498static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5499 uint32_t *msg_buf)
5500{
5501 tpSirChanChangeRequest ch_change_req;
5502 tpPESession session_entry;
5503 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005504 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505 uint32_t val = 0;
5506
5507 if (msg_buf == NULL) {
5508 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5509 return;
5510 }
5511 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5512
5513 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5514 ch_change_req->targetChannel);
5515
5516 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5517 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5518 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5519 return;
5520 }
5521
5522 session_entry = pe_find_session_by_bssid(mac_ctx,
5523 ch_change_req->bssid, &session_id);
5524 if (session_entry == NULL) {
5525 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5526 lim_log(mac_ctx, LOGE, FL(
5527 "Session does not exist for given bssId"));
5528 return;
5529 }
5530
5531 if (session_entry->currentOperChannel ==
5532 ch_change_req->targetChannel) {
5533 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5534 return;
5535 }
5536
5537 if (LIM_IS_AP_ROLE(session_entry))
5538 session_entry->channelChangeReasonCode =
5539 LIM_SWITCH_CHANNEL_SAP_DFS;
5540 else
5541 session_entry->channelChangeReasonCode =
5542 LIM_SWITCH_CHANNEL_OPERATION;
5543
5544 lim_log(mac_ctx, LOGW, FL(
5545 "switch old chnl %d to new chnl %d, ch_bw %d"),
5546 session_entry->currentOperChannel,
5547 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005548 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549
5550 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005551 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 session_entry->ch_center_freq_seg0 =
5553 ch_change_req->center_freq_seg_0;
5554 session_entry->ch_center_freq_seg1 =
5555 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005556 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005558 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 session_entry->htRecommendedTxWidthSet =
5560 session_entry->htSupportedChannelWidthSet;
5561 session_entry->currentOperChannel =
5562 ch_change_req->targetChannel;
5563 session_entry->limRFBand =
5564 lim_get_rf_band(session_entry->currentOperChannel);
5565 /* Initialize 11h Enable Flag */
5566 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5567 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5568 eSIR_SUCCESS)
5569 lim_log(mac_ctx, LOGP,
5570 FL("Fail to get WNI_CFG_11H_ENABLED"));
5571 }
5572
5573 session_entry->lim11hEnable = val;
5574 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305575 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 &ch_change_req->operational_rateset,
5577 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305578 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005579 &ch_change_req->extended_rateset,
5580 sizeof(session_entry->extRateSet));
5581 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5582 session_entry->ch_center_freq_seg0,
5583 session_entry->ch_center_freq_seg1,
5584 session_entry->ch_width,
5585 max_tx_pwr, session_entry->peSessionId);
5586}
5587
5588/******************************************************************************
5589* lim_start_bss_update_add_ie_buffer()
5590*
5591***FUNCTION:
5592* This function checks the src buffer and its length and then malloc for
5593* dst buffer update the same
5594*
5595***LOGIC:
5596*
5597***ASSUMPTIONS:
5598*
5599***NOTE:
5600*
5601* @param pMac Pointer to Global MAC structure
5602* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5603* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5604* @param *pSrcData_buff A pointer of uint8_t src buffer
5605* @param srcDataLen src buffer length
5606******************************************************************************/
5607
5608static void
5609lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5610 uint8_t **pDstData_buff,
5611 uint16_t *pDstDataLen,
5612 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5613{
5614
5615 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5616 *pDstDataLen = srcDataLen;
5617
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305618 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619
5620 if (NULL == *pDstData_buff) {
5621 lim_log(pMac, LOGE,
5622 FL("AllocateMemory failed for pDstData_buff"));
5623 return;
5624 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305625 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626 } else {
5627 *pDstData_buff = NULL;
5628 *pDstDataLen = 0;
5629 }
5630}
5631
5632/******************************************************************************
5633* lim_update_add_ie_buffer()
5634*
5635***FUNCTION:
5636* This function checks the src buffer and length if src buffer length more
5637* than dst buffer length then free the dst buffer and malloc for the new src
5638* length, and update the dst buffer and length. But if dst buffer is bigger
5639* than src buffer length then it just update the dst buffer and length
5640*
5641***LOGIC:
5642*
5643***ASSUMPTIONS:
5644*
5645***NOTE:
5646*
5647* @param pMac Pointer to Global MAC structure
5648* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5649* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5650* @param *pSrcData_buff A pointer of uint8_t src buffer
5651* @param srcDataLen src buffer length
5652******************************************************************************/
5653
5654static void
5655lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5656 uint8_t **pDstData_buff,
5657 uint16_t *pDstDataLen,
5658 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5659{
5660
5661 if (NULL == pSrcData_buff) {
5662 lim_log(pMac, LOGE, FL("src buffer is null."));
5663 return;
5664 }
5665
5666 if (srcDataLen > *pDstDataLen) {
5667 *pDstDataLen = srcDataLen;
5668 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305669 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305671 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672
5673 if (NULL == *pDstData_buff) {
5674 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5675 *pDstDataLen = 0;
5676 return;
5677 }
5678 }
5679
5680 /* copy the content of buffer into dst buffer
5681 */
5682 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305683 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684
5685}
5686
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005687/**
5688 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5689 * @pMac : Pointer to Global MAC structure
5690 * @pDstData_buff : A pointer to pointer of dst buffer
5691 * @pDstDataLen : A pointer to pointer of dst buffer length
5692 * @pModifyIE : A pointer to tSirModifyIE
5693 *
5694 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5695 *
5696 * Return:
5697 * True or false depending upon whether IE is updated or not
5698 */
5699static bool
5700lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5701 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5702{
5703 int32_t oui_length;
5704 uint8_t *ibss_ie = NULL;
5705
5706 ibss_ie = pModifyIE->pIEBuffer;
5707 oui_length = pModifyIE->oui_length;
5708
5709 if ((0 == oui_length) || (NULL == ibss_ie)) {
5710 PELOGE(lim_log(pMac, LOGE,
5711 FL("Invalid set IBSS vendor IE command length %d "),
5712 oui_length);)
5713 return false;
5714 }
5715
5716 lim_update_add_ie_buffer(pMac,
5717 pDstData_buff,
5718 pDstDataLen,
5719 pModifyIE->pIEBuffer,
5720 pModifyIE->ieBufferlength);
5721
5722 return true;
5723}
5724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725/*
5726* lim_process_modify_add_ies() - process modify additional IE req.
5727*
5728* @mac_ctx: Pointer to Global MAC structure
5729* @msg_buf: pointer to the SME message buffer
5730*
5731* This function update the PE buffers for additional IEs.
5732*
5733* Return: None
5734*/
5735static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5736 uint32_t *msg_buf)
5737{
5738 tpSirModifyIEsInd modify_add_ies;
5739 tpPESession session_entry;
5740 uint8_t session_id;
5741 bool ret = false;
5742 tSirAddIeParams *add_ie_params;
5743
5744 if (msg_buf == NULL) {
5745 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5746 return;
5747 }
5748
5749 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5750 /* Incoming message has smeSession, use BSSID to find PE session */
5751 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005752 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753
5754 if (NULL == session_entry) {
5755 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5756 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005757 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 goto end;
5759 }
5760 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5761 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5762 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5763 lim_log(mac_ctx, LOGE,
5764 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5765 modify_add_ies->modifyIE.pIEBuffer,
5766 modify_add_ies->modifyIE.ieBufferlength,
5767 modify_add_ies->modifyIE.ieID,
5768 modify_add_ies->modifyIE.ieIDLen,
5769 modify_add_ies->updateType);
5770 goto end;
5771 }
5772 add_ie_params = &session_entry->addIeParams;
5773 switch (modify_add_ies->updateType) {
5774 case eUPDATE_IE_PROBE_RESP:
5775 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005776 if (LIM_IS_IBSS_ROLE(session_entry)) {
5777 lim_update_ibss_prop_add_ies(mac_ctx,
5778 &add_ie_params->probeRespData_buff,
5779 &add_ie_params->probeRespDataLen,
5780 &modify_add_ies->modifyIE);
5781 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 break;
5783 case eUPDATE_IE_ASSOC_RESP:
5784 /* assoc resp IE */
5785 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305786 QDF_TRACE(QDF_MODULE_ID_PE,
5787 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788 "assoc resp add ie not present %d"),
5789 add_ie_params->assocRespDataLen);
5790 }
5791 /* search through the buffer and modify the IE */
5792 break;
5793 case eUPDATE_IE_PROBE_BCN:
5794 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005795 if (LIM_IS_IBSS_ROLE(session_entry)) {
5796 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5797 &add_ie_params->probeRespBCNData_buff,
5798 &add_ie_params->probeRespBCNDataLen,
5799 &modify_add_ies->modifyIE);
5800 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005801 if (ret == true && modify_add_ies->modifyIE.notify) {
5802 lim_handle_param_update(mac_ctx,
5803 modify_add_ies->updateType);
5804 }
5805 break;
5806 default:
5807 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5808 modify_add_ies->updateType);
5809 break;
5810 }
5811end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305812 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 modify_add_ies->modifyIE.pIEBuffer = NULL;
5814}
5815
5816/*
5817* lim_process_update_add_ies() - process additional IE update req
5818*
5819* @mac_ctx: Pointer to Global MAC structure
5820* @msg_buf: pointer to the SME message buffer
5821*
5822* This function update the PE buffers for additional IEs.
5823*
5824* Return: None
5825*/
5826static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5827 uint32_t *msg_buf)
5828{
5829 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5830 uint8_t session_id;
5831 tpPESession session_entry;
5832 tSirAddIeParams *addn_ie;
5833 uint16_t new_length = 0;
5834 uint8_t *new_ptr = NULL;
5835 tSirUpdateIE *update_ie;
5836
5837 if (msg_buf == NULL) {
5838 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5839 return;
5840 }
5841 update_ie = &update_add_ies->updateIE;
5842 /* incoming message has smeSession, use BSSID to find PE session */
5843 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005844 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845
5846 if (NULL == session_entry) {
5847 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5848 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005849 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 goto end;
5851 }
5852 addn_ie = &session_entry->addIeParams;
5853 /* if len is 0, upper layer requested freeing of buffer */
5854 if (0 == update_ie->ieBufferlength) {
5855 switch (update_add_ies->updateType) {
5856 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305857 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 addn_ie->probeRespData_buff = NULL;
5859 addn_ie->probeRespDataLen = 0;
5860 break;
5861 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305862 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863 addn_ie->assocRespData_buff = NULL;
5864 addn_ie->assocRespDataLen = 0;
5865 break;
5866 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305867 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868 addn_ie->probeRespBCNData_buff = NULL;
5869 addn_ie->probeRespBCNDataLen = 0;
5870
5871 if (update_ie->notify)
5872 lim_handle_param_update(mac_ctx,
5873 update_add_ies->updateType);
5874 break;
5875 default:
5876 break;
5877 }
5878 return;
5879 }
5880 switch (update_add_ies->updateType) {
5881 case eUPDATE_IE_PROBE_RESP:
5882 if (update_ie->append) {
5883 /*
5884 * In case of append, allocate new memory
5885 * with combined length
5886 */
5887 new_length = update_ie->ieBufferlength +
5888 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305889 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005890 if (NULL == new_ptr) {
5891 lim_log(mac_ctx, LOGE, FL(
5892 "Memory allocation failed."));
5893 goto end;
5894 }
5895 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305896 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005897 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305898 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899 update_ie->pAdditionIEBuffer,
5900 update_ie->ieBufferlength);
5901 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305902 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903 /* adjust length accordingly */
5904 addn_ie->probeRespDataLen = new_length;
5905 /* save refernece of local buffer in PE session */
5906 addn_ie->probeRespData_buff = new_ptr;
5907 goto end;
5908 }
5909 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5910 &addn_ie->probeRespDataLen,
5911 update_ie->pAdditionIEBuffer,
5912 update_ie->ieBufferlength);
5913 break;
5914 case eUPDATE_IE_ASSOC_RESP:
5915 /* assoc resp IE */
5916 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5917 &addn_ie->assocRespDataLen,
5918 update_ie->pAdditionIEBuffer,
5919 update_ie->ieBufferlength);
5920 break;
5921 case eUPDATE_IE_PROBE_BCN:
5922 /* probe resp Bcn IE */
5923 lim_update_add_ie_buffer(mac_ctx,
5924 &addn_ie->probeRespBCNData_buff,
5925 &addn_ie->probeRespBCNDataLen,
5926 update_ie->pAdditionIEBuffer,
5927 update_ie->ieBufferlength);
5928 if (update_ie->notify)
5929 lim_handle_param_update(mac_ctx,
5930 update_add_ies->updateType);
5931 break;
5932 default:
5933 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5934 update_add_ies->updateType);
5935 break;
5936 }
5937end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305938 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939 update_ie->pAdditionIEBuffer = NULL;
5940}
5941
5942/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305943 * send_extended_chan_switch_action_frame()- function to send ECSA
5944 * action frame for each sta connected to SAP/GO and AP in case of
5945 * STA .
5946 * @mac_ctx: pointer to global mac structure
5947 * @new_channel: new channel to switch to.
5948 * @ch_bandwidth: BW of channel to calculate op_class
5949 * @session_entry: pe session
5950 *
5951 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5952 *
5953 * Return: void
5954 */
5955
5956static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5957 uint16_t new_channel, uint8_t ch_bandwidth,
5958 tpPESession session_entry)
5959{
5960 uint16_t op_class;
5961 uint8_t switch_mode = 0, i;
5962 tpDphHashNode psta;
5963
5964
Amar Singhal22995112016-01-22 10:42:33 -08005965 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305966 mac_ctx->scan.countryCodeCurrent,
5967 new_channel,
5968 ch_bandwidth);
5969
5970 if (LIM_IS_AP_ROLE(session_entry) &&
5971 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5972 switch_mode = 1;
5973
5974 if (LIM_IS_AP_ROLE(session_entry)) {
5975 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5976 psta =
5977 session_entry->dph.dphHashTable.pDphNodeArray + i;
5978 if (psta && psta->added)
5979 lim_send_extended_chan_switch_action_frame(
5980 mac_ctx,
5981 psta->staAddr,
5982 switch_mode, op_class, new_channel,
5983 LIM_MAX_CSA_IE_UPDATES, session_entry);
5984 }
5985 } else if (LIM_IS_STA_ROLE(session_entry)) {
5986 lim_send_extended_chan_switch_action_frame(mac_ctx,
5987 session_entry->bssId,
5988 switch_mode, op_class, new_channel,
5989 LIM_MAX_CSA_IE_UPDATES, session_entry);
5990 }
5991
5992}
5993
5994/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5996 *
5997 * @mac_ctx: Pointer to Global MAC structure
5998 * @msg_buf: pointer to the SME message buffer
5999 *
6000 * This function processes SME request messages from HDD or upper layer
6001 * application.
6002 *
6003 * Return: None
6004 */
6005static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
6006 uint32_t *msg_buf)
6007{
6008 tpSirDfsCsaIeRequest dfs_csa_ie_req;
6009 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010 uint8_t session_id;
6011 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006012 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013
6014 if (msg_buf == NULL) {
6015 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6016 return;
6017 }
6018
6019 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6020 session_entry = pe_find_session_by_bssid(mac_ctx,
6021 dfs_csa_ie_req->bssid, &session_id);
6022 if (session_entry == NULL) {
6023 lim_log(mac_ctx, LOGE, FL(
6024 "Session not found for given BSSID" MAC_ADDRESS_STR),
6025 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6026 return;
6027 }
6028
6029 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6030 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6031 GET_LIM_SYSTEM_ROLE(session_entry));
6032 return;
6033 }
6034
6035 /* target channel */
6036 session_entry->gLimChannelSwitch.primaryChannel =
6037 dfs_csa_ie_req->targetChannel;
6038
6039 /* Channel switch announcement needs to be included in beacon */
6040 session_entry->dfsIncludeChanSwIe = true;
6041 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6042 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006043 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306044 session_entry->gLimChannelSwitch.sec_ch_offset =
6045 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6047 session_entry->gLimChannelSwitch.switchMode = 1;
6048
6049 /*
6050 * Validate if SAP is operating HT or VHT mode and set the Channel
6051 * Switch Wrapper element with the Wide Band Switch subelement.
6052 */
6053 if (true != session_entry->vhtCapability)
6054 goto skip_vht;
6055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 /* Now encode the Wider Ch BW element depending on the ch width */
6057 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006058 switch (dfs_csa_ie_req->ch_params.ch_width) {
6059 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 /*
6061 * Wide channel BW sublement in channel wrapper element is not
6062 * required in case of 20 Mhz operation. Currently It is set
6063 * only set in case of 40/80 Mhz Operation.
6064 */
6065 session_entry->dfsIncludeChanWrapperIe = false;
6066 wider_bw_ch_switch->newChanWidth =
6067 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6068 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006069 case CH_WIDTH_40MHZ:
6070 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 wider_bw_ch_switch->newChanWidth =
6072 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6073 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006074 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006075 session_entry->dfsIncludeChanWrapperIe = true;
6076 wider_bw_ch_switch->newChanWidth =
6077 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6078 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006079 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006080 session_entry->dfsIncludeChanWrapperIe = true;
6081 wider_bw_ch_switch->newChanWidth =
6082 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6083 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006084 case CH_WIDTH_80P80MHZ:
6085 session_entry->dfsIncludeChanWrapperIe = true;
6086 wider_bw_ch_switch->newChanWidth =
6087 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006088 /*
6089 * This is not applicable for 20/40/80 Mhz.
6090 * Only used when we support 80+80 Mhz operation.
6091 * In case of 80+80 Mhz, this parameter indicates
6092 * center channel frequency index of 80 Mhz channel of
6093 * frequency segment 1.
6094 */
6095 wider_bw_ch_switch->newCenterChanFreq1 =
6096 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006097 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098 default:
6099 session_entry->dfsIncludeChanWrapperIe = false;
6100 /*
6101 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6102 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6103 */
6104 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6105 break;
6106 }
6107 /* Fetch the center channel based on the channel width */
6108 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006109 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110skip_vht:
6111 /* Send CSA IE request from here */
6112 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6113 eSIR_SUCCESS) {
6114 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6115 return;
6116 }
6117
6118 /*
6119 * First beacon update request is sent here, the remaining updates are
6120 * done when the FW responds back after sending the first beacon after
6121 * the template update
6122 */
6123 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306124
6125 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6126 ch_offset = BW80;
6127 else
6128 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6129
6130 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6131 session_entry->gLimChannelSwitch.switchCount,
6132 session_entry->gLimChannelSwitch.primaryChannel,
6133 session_entry->gLimChannelSwitch.ch_width,
6134 session_entry->dfsIncludeChanWrapperIe,
6135 ch_offset);
6136
Abhishek Singh518323d2015-10-19 17:42:01 +05306137 /* Send ECSA Action frame after updating the beacon */
6138 send_extended_chan_switch_action_frame(mac_ctx,
6139 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306140 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006141 session_entry->gLimChannelSwitch.switchCount--;
6142}
6143
6144/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306145 * lim_process_ext_change_channel()- function to send ECSA
6146 * action frame for STA/CLI .
6147 * @mac_ctx: pointer to global mac structure
6148 * @msg: params from sme for new channel.
6149 *
6150 * This function is called to send ECSA frame for STA/CLI.
6151 *
6152 * Return: void
6153 */
6154
6155static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6156 uint32_t *msg)
6157{
6158 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6159 (struct sir_sme_ext_cng_chan_req *) msg;
6160 tpPESession session_entry = NULL;
6161
6162 if (NULL == msg) {
6163 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6164 return;
6165 }
6166 session_entry =
6167 pe_find_session_by_sme_session_id(mac_ctx,
6168 ext_chng_channel->session_id);
6169 if (NULL == session_entry) {
6170 lim_log(mac_ctx, LOGE,
6171 FL("Session not found for given session %d"),
6172 ext_chng_channel->session_id);
6173 return;
6174 }
6175 if (LIM_IS_AP_ROLE(session_entry)) {
6176 lim_log(mac_ctx, LOGE,
6177 FL("not an STA/CLI session"));
6178 return;
6179 }
6180 send_extended_chan_switch_action_frame(mac_ctx,
6181 ext_chng_channel->new_channel,
6182 0, session_entry);
6183}
6184
6185/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 * lim_process_nss_update_request() - process sme nss update req
6187 *
6188 * @mac_ctx: Pointer to Global MAC structure
6189 * @msg_buf: pointer to the SME message buffer
6190 *
6191 * This function processes SME request messages from HDD or upper layer
6192 * application.
6193 *
6194 * Return: None
6195 */
6196static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6197 uint32_t *msg_buf)
6198{
6199 struct sir_nss_update_request *nss_update_req_ptr;
6200 tpPESession session_entry = NULL;
6201
6202 if (msg_buf == NULL) {
6203 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6204 return;
6205 }
6206
6207 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306208 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006209 nss_update_req_ptr->vdev_id);
6210 if (session_entry == NULL) {
6211 lim_log(mac_ctx, LOGE, FL(
6212 "Session not found for given session_id %d"),
6213 nss_update_req_ptr->vdev_id);
6214 return;
6215 }
6216
6217 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6218 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6219 GET_LIM_SYSTEM_ROLE(session_entry));
6220 return;
6221 }
6222
6223 /* populate nss field in the beacon */
6224 session_entry->gLimOperatingMode.present = 1;
6225 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6226 /* Send nss update request from here */
6227 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6228 eSIR_SUCCESS) {
6229 lim_log(mac_ctx, LOGE,
6230 FL("Unable to set op mode IE in beacon"));
6231 return;
6232 }
6233
6234 lim_send_beacon_ind(mac_ctx, session_entry);
6235}
6236
6237/**
6238 * lim_process_set_ie_req() - process sme set IE request
6239 *
6240 * @mac_ctx: Pointer to Global MAC structure
6241 * @msg_buf: pointer to the SME message buffer
6242 *
6243 * This function processes SME request messages from HDD or upper layer
6244 * application.
6245 *
6246 * Return: None
6247 */
6248static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6249{
6250 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306251 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006252
6253 if (msg_buf == NULL) {
6254 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6255 return;
6256 }
6257
6258 msg = (struct send_extcap_ie *)msg_buf;
6259 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306260 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006261 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6262
6263}