blob: 131ce4237ff8a921bcdfb6adf8791012cb5641ac [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
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700120extern void pe_register_callbacks_with_wma(tpAniSirGlobal pMac,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800121 tSirSmeReadyReq *ready_req);
Abhishek Singh518323d2015-10-19 17:42:01 +0530122static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
123 uint32_t *msg);
124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125/**
126 * lim_process_set_hw_mode() - Send set HW mode command to WMA
127 * @mac: Globacl MAC pointer
128 * @msg: Message containing the hw mode index
129 *
130 * Send the set HW mode command to WMA
131 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530132 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530134static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530136 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137 cds_msg_t cds_message;
138 struct sir_hw_mode *req_msg;
139 uint32_t len;
140 struct s_sir_set_hw_mode *buf;
141 tSirMsgQ resp_msg;
142 struct sir_set_hw_mode_resp *param;
143
144 buf = (struct s_sir_set_hw_mode *) msg;
145 if (!buf) {
146 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
147 /* To free the active command list */
148 goto fail;
149 }
150
151 len = sizeof(*req_msg);
152
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530153 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530155 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 /* Free the active command list
157 * Probably the malloc is going to fail there as well?!
158 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530159 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 }
161
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530162 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163
164 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530165 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 /* Other parameters are not needed for WMA */
167
168 cds_message.bodyptr = req_msg;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +0530169 cds_message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170
171 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
172 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530173 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700175 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530177 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 goto fail;
179 }
180 return status;
181fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530182 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 if (!param) {
184 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530185 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 }
187 param->status = SET_HW_MODE_STATUS_ECANCELED;
188 param->cfgd_hw_mode_index = 0;
189 param->num_vdev_mac_entries = 0;
190 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
191 resp_msg.bodyptr = param;
192 resp_msg.bodyval = 0;
193 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530194 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195}
196
197/**
198 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
199 * @mac: Global MAC pointer
200 * @msg: Message containing the dual mac config parameter
201 *
202 * Send the set dual mac config command to WMA
203 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530204 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530206static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 uint32_t *msg)
208{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530209 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210 cds_msg_t cds_message;
211 struct sir_dual_mac_config *req_msg;
212 uint32_t len;
213 struct sir_set_dual_mac_cfg *buf;
214 tSirMsgQ resp_msg;
215 struct sir_dual_mac_config_resp *param;
216
217 buf = (struct sir_set_dual_mac_cfg *) msg;
218 if (!buf) {
219 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
220 /* To free the active command list */
221 goto fail;
222 }
223
224 len = sizeof(*req_msg);
225
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530226 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 if (!req_msg) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700228 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 /* Free the active command list
230 * Probably the malloc is going to fail there as well?!
231 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530232 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 }
234
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530235 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236
237 req_msg->scan_config = buf->set_dual_mac.scan_config;
238 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
239 /* Other parameters are not needed for WMA */
240
241 cds_message.bodyptr = req_msg;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530242 cds_message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243
244 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530245 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 req_msg->scan_config, req_msg->fw_mode_config);
247 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530248 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700250 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530252 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 goto fail;
254 }
255 return status;
256fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530257 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 if (!param) {
259 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530260 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261 }
262 param->status = SET_HW_MODE_STATUS_ECANCELED;
263 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
264 resp_msg.bodyptr = param;
265 resp_msg.bodyval = 0;
266 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530267 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268}
269
270/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800271 * lim_process_set_antenna_mode_req() - Set antenna mode command
272 * to WMA
273 * @mac: Global MAC pointer
274 * @msg: Message containing the antenna mode parameter
275 *
276 * Send the set antenna mode command to WMA
277 *
278 * Return: QDF_STATUS_SUCCESS if message posting is successful
279 */
280static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
281 uint32_t *msg)
282{
283 QDF_STATUS status = QDF_STATUS_SUCCESS;
284 cds_msg_t cds_message;
285 struct sir_antenna_mode_param *req_msg;
286 struct sir_set_antenna_mode *buf;
287 tSirMsgQ resp_msg;
288 struct sir_antenna_mode_resp *param;
289
290 buf = (struct sir_set_antenna_mode *) msg;
291 if (!buf) {
292 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
293 /* To free the active command list */
294 goto fail;
295 }
296
297 req_msg = qdf_mem_malloc(sizeof(*req_msg));
298 if (!req_msg) {
299 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
300 return QDF_STATUS_E_NOMEM;
301 }
302
303 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
304 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
305
306 cds_message.bodyptr = req_msg;
307 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
308
309 lim_log(mac, LOG1,
310 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
311 req_msg->num_rx_chains,
312 req_msg->num_tx_chains);
313 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
314 if (!QDF_IS_STATUS_SUCCESS(status)) {
315 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700316 FL("cds_mq_post_message failed!(err=%d)"),
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800317 status);
318 qdf_mem_free(req_msg);
319 goto fail;
320 }
321 return status;
322fail:
323 param = qdf_mem_malloc(sizeof(*param));
324 if (!param) {
325 lim_log(mac, LOGE, FL("antenna mode resp failed"));
326 return QDF_STATUS_E_NOMEM;
327 }
328 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
329 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
330 resp_msg.bodyptr = param;
331 resp_msg.bodyval = 0;
332 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
333 return QDF_STATUS_SUCCESS;
334}
335
336/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
338 * @mac_ctx: Pointer to Global MAC structure
339 * @return_fresh_results: Trigger fresh scan.
340 *
341 * PE will do fresh scan, if all of the active sessions are in
342 * good state (Link Est or BSS Started). If one of the sessions
343 * is not in one of the above states, then PE does not do fresh
344 * scan. If no session exists (scanning very first time),
345 * then PE will always do fresh scan if SME asks it to do that.
346 *
347 * Return: true for fresh scan results, false if in invalid state.
348 */
349static uint8_t
350__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
351{
352 uint8_t valid_state = true;
353 int i;
354
355 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
356 mac_ctx->lim.gLimSmeState, return_fresh_results);
357
358 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
359 lim_log(mac_ctx, LOG1, FL("return FALSE"));
360 return false;
361 }
362
363 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700364
365 if (mac_ctx->lim.gpSession[i].valid == false)
366 continue;
367
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800368 lim_log(mac_ctx, LOG1,
369 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
370 i, mac_ctx->lim.gpSession[i].bssType,
371 mac_ctx->lim.gpSession[i].limSystemRole,
372 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700373
374 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
375 continue;
376
377 if (mac_ctx->lim.gpSession[i].bssType ==
378 eSIR_INFRASTRUCTURE_MODE &&
379 mac_ctx->lim.gpSession[i].limSmeState ==
380 eLIM_SME_LINK_EST_STATE)
381 continue;
382
383 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
384 mac_ctx->lim.gpSession[i].limSmeState ==
385 eLIM_SME_NORMAL_STATE)
386 continue;
387
388 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
389 mac_ctx->lim.gpSession[i].pePersona ==
390 QDF_P2P_GO_MODE &&
391 mac_ctx->lim.gpSession[i].limSmeState ==
392 eLIM_SME_NORMAL_STATE)
393 continue;
394
395 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
396 mac_ctx->lim.gpSession[i].limSmeState ==
397 eLIM_SME_NORMAL_STATE)
398 continue;
399
400 valid_state = false;
401 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 }
403
404 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
405
406 if ((valid_state) &&
407 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
408 return true;
409 else
410 return false;
411}
412
413/**
414 * __lim_is_sme_assoc_cnf_valid()
415 *
416 ***FUNCTION:
417 * This function is called by __lim_process_sme_assoc_cnf_new() upon
418 * receiving SME_ASSOC_CNF.
419 *
420 ***LOGIC:
421 * Message validity checks are performed in this function
422 *
423 ***ASSUMPTIONS:
424 *
425 ***NOTE:
426 *
427 * @param pMeasReq Pointer to Received ASSOC_CNF message
428 * @return true When received SME_ASSOC_CNF is formatted
429 * correctly
430 * false otherwise
431 */
432
433static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
434{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530435 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800436 return false;
437 else
438 return true;
439} /*** end __lim_is_sme_assoc_cnf_valid() ***/
440
441/**
442 * __lim_get_sme_join_req_size_for_alloc()
443 *
444 ***FUNCTION:
445 * This function is called in various places to get IE length
446 * from tSirBssDescription structure
447 * number being scanned.
448 *
449 ***PARAMS:
450 *
451 ***LOGIC:
452 *
453 ***ASSUMPTIONS:
454 * NA
455 *
456 ***NOTE:
457 * NA
458 *
459 * @param pBssDescr
460 * @return Total IE length
461 */
462
463static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
464{
465 uint16_t len = 0;
466
467 if (!pBuf)
468 return len;
469
470 pBuf += sizeof(uint16_t);
471 len = lim_get_u16(pBuf);
472 return len + sizeof(uint16_t);
473}
474
475/**
476 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
477 * @pMac: Global MAC context
478 * @pMsg: Pointer to message posted from SME to LIM.
479 *
480 * Has role only if 11h is enabled. Not used on STA side.
481 * Defers the message if SME is in learn state and brings
482 * the LIM back to normal mode.
483 *
484 * Return: true - If defered false - Otherwise
485 */
486
487static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
488{
489 if (lim_is_system_in_scan_state(pMac)) {
490 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
491 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
492 pMsg->type);
493 return false;
494 }
495 lim_log(pMac, LOG1,
496 FL("Defer the message, in learn mode type = %d"),
497 pMsg->type);
498 return true;
499 }
500 return false;
501}
502
503/**
504 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
505 * @mac_ctx: Pointer to Global MAC structure
506 * @message: Pointer to message posted from SME to LIM.
507 *
508 * Has role only if 11h is enabled. Not used on STA side.
509 * Defers the message if radar is detected.
510 *
511 * Return: true, if defered otherwise return false.
512 */
513static bool
514__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
515{
516 /*
517 * fRadarDetCurOperChan will be set only if we
518 * detect radar in current operating channel and
519 * System Role == AP ROLE
520 *
521 * TODO: Need to take care radar detection.
522 *
523 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
524 */
525 if (0) {
526 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
527 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
528 message->type);
529 return false;
530 }
531 lim_log(mac_ctx, LOG1,
532 FL("Defer the message, in learn mode type = %d"),
533 message->type);
534 return true;
535 }
536 return false;
537}
538
539/**
540 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
541 * @pMac: Global MAC context
542 * @pMsgBuf: Message from WMA
543 *
544 * handles the notification from HDD. PE just forwards this message to HAL.
545 *
546 * Return: true-Posting to HAL failed, so PE will consume the buffer.
547 * false-Posting to HAL successful, so HAL will consume the buffer.
548 */
549
550static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
551{
552 tSirMsgQ msg;
553 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
554
555 msg.type = WMA_SYS_READY_IND;
556 msg.reserved = 0;
557 msg.bodyptr = pMsgBuf;
558 msg.bodyval = 0;
559
560 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800561 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700562 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
564 }
565 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
566 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
567
568 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
569 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
570 return true;
571 }
572 return false;
573}
574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575/**
576 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
577 *@mac_ctx: Pointer to Global MAC structure
578 *@session: A pointer to session entry
579 *@sme_start_bss_req: Start BSS Request from upper layers.
580 *
581 * This function is used to configure the start bss parameters
582 * in to the session.
583 *
584 * Return: None.
585 */
586static void
587lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
588 tpSirSmeStartBssReq sme_start_bss_req)
589{
590 session->limSystemRole = eLIM_AP_ROLE;
591 session->privacy = sme_start_bss_req->privacy;
592 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
593 session->authType = sme_start_bss_req->authType;
594 /* Store the DTIM period */
595 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
596 /* Enable/disable UAPSD */
597 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530598 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 session->proxyProbeRspEn = 0;
600 } else {
601 /*
602 * To detect PBC overlap in SAP WPS mode,
603 * Host handles Probe Requests.
604 */
605 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
606 session->proxyProbeRspEn = 1;
607 else
608 session->proxyProbeRspEn = 0;
609 }
610 session->ssidHidden = sme_start_bss_req->ssidHidden;
611 session->wps_state = sme_start_bss_req->wps_state;
612 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
613 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#ifdef FEATURE_WLAN_ESE
1938 session->maxTxPower = lim_get_max_tx_power(reg_max,
1939 local_power_constraint,
1940 mac_ctx->roam.configParam.nTxPowerCap);
1941#else
1942 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301943 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301945 lim_log(mac_ctx, LOG1,
1946 FL("Reg max = %d, local power con = %d, max tx = %d"),
1947 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948
1949 if (session->gLimCurrentBssUapsd) {
1950 session->gUapsdPerAcBitmask =
1951 session->pLimJoinReq->uapsdPerAcBitmask;
1952 lim_log(mac_ctx, LOG1,
1953 FL("UAPSD flag for all AC - 0x%2x"),
1954 session->gUapsdPerAcBitmask);
1955
1956 /* resetting the dynamic uapsd mask */
1957 session->gUapsdPerAcDeliveryEnableMask = 0;
1958 session->gUapsdPerAcTriggerEnableMask = 0;
1959 }
1960
1961 session->limRFBand =
1962 lim_get_rf_band(session->currentOperChannel);
1963
1964 /* Initialize 11h Enable Flag */
1965 if (SIR_BAND_5_GHZ == session->limRFBand) {
1966 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1967 &val) != eSIR_SUCCESS) {
1968 lim_log(mac_ctx, LOGP,
1969 FL("Fail to get WNI_CFG_11H_ENABLED "));
1970 session->lim11hEnable =
1971 WNI_CFG_11H_ENABLED_STADEF;
1972 } else {
1973 session->lim11hEnable = val;
1974 }
1975 } else {
1976 session->lim11hEnable = 0;
1977 }
1978
1979 /*
1980 * To care of the scenario when STA transitions from
1981 * IBSS to Infrastructure mode.
1982 */
1983 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1984
1985 session->limPrevSmeState = session->limSmeState;
1986 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1987 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1988 session->peSessionId,
1989 session->limSmeState));
1990
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 /* Indicate whether spectrum management is enabled */
1992 session->spectrumMgtEnabled =
1993 sme_join_req->spectrumMgtIndicator;
1994
1995 /* Enable the spectrum management if this is a DFS channel */
1996 if (session->country_info_present &&
1997 lim_isconnected_on_dfs_channel(
1998 session->currentOperChannel))
1999 session->spectrumMgtEnabled = true;
2000
2001 session->isOSENConnection = sme_join_req->isOSENConnection;
2002
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 /* Issue LIM_MLM_JOIN_REQ to MLM */
2004 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2005 (uint32_t *) mlm_join_req);
2006 return;
2007
2008 } else {
2009 /* Received eWNI_SME_JOIN_REQ un expected state */
2010 lim_log(mac_ctx, LOGE,
2011 FL("received unexpected SME_JOIN_REQ in state %X"),
2012 mac_ctx->lim.gLimSmeState);
2013 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2014 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2015 session = NULL;
2016 goto end;
2017 }
2018
2019end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302020 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2021 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022
2023 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302024 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 sme_join_req = NULL;
2026 if (NULL != session)
2027 session->pLimJoinReq = NULL;
2028 }
2029 if (ret_code != eSIR_SME_SUCCESS) {
2030 if (NULL != session) {
2031 pe_delete_session(mac_ctx, session);
2032 session = NULL;
2033 }
2034 }
2035 lim_log(mac_ctx, LOG1,
2036 FL("Send failure status on sessionid: %d with ret_code = %d"),
2037 sme_session_id, ret_code);
2038 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2039 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2040 sme_transaction_id);
2041}
2042
Amar Singhala297bfa2015-10-15 15:07:29 -07002043uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 uint8_t iniTxPower)
2045{
2046 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302047 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2048 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2050 maxTxPower = txPower;
2051 else if (txPower < MIN_TX_PWR_CAP)
2052 maxTxPower = MIN_TX_PWR_CAP;
2053 else
2054 maxTxPower = MAX_TX_PWR_CAP;
2055
2056 return maxTxPower;
2057}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058
2059/**
2060 * __lim_process_sme_reassoc_req() - process reassoc req
2061 *
2062 * @mac_ctx: Pointer to Global MAC structure
2063 * @msg_buf: pointer to the SME message buffer
2064 *
2065 * This function is called to process SME_REASSOC_REQ message
2066 * from HDD or upper layer application.
2067 *
2068 * Return: None
2069 */
2070
2071static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2072 uint32_t *msg_buf)
2073{
2074 uint16_t caps;
2075 uint32_t val;
2076 tpSirSmeJoinReq reassoc_req = NULL;
2077 tLimMlmReassocReq *mlm_reassoc_req;
2078 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2079 tpPESession session_entry = NULL;
2080 uint8_t session_id;
2081 uint8_t sme_session_id;
2082 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002083 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 uint32_t tele_bcn_en = 0;
2085 uint16_t size;
2086
2087 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2088
2089 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302090 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 if (NULL == reassoc_req) {
2092 lim_log(mac_ctx, LOGP,
2093 FL("call to AllocateMemory failed for reassoc_req"));
2094
2095 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2096 goto end;
2097 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302098 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2099 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100
2101 if (!lim_is_sme_join_req_valid(mac_ctx,
2102 (tpSirSmeJoinReq)reassoc_req)) {
2103 /*
2104 * Received invalid eWNI_SME_REASSOC_REQ
2105 */
2106 lim_log(mac_ctx, LOGW,
2107 FL("received SME_REASSOC_REQ with invalid data"));
2108
2109 ret_code = eSIR_SME_INVALID_PARAMETERS;
2110 goto end;
2111 }
2112
2113 session_entry = pe_find_session_by_bssid(mac_ctx,
2114 reassoc_req->bssDescription.bssId,
2115 &session_id);
2116 if (session_entry == NULL) {
2117 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2118 LOGE);
2119 lim_log(mac_ctx, LOGE,
2120 FL("Session does not exist for given bssId"));
2121 ret_code = eSIR_SME_INVALID_PARAMETERS;
2122 goto end;
2123 }
2124#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2125 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2126 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2127#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2128 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2129
2130 /* Store the reassoc handle in the session Table */
2131 session_entry->pLimReAssocReq = reassoc_req;
2132
2133 session_entry->dot11mode = reassoc_req->dot11mode;
2134 session_entry->vhtCapability =
2135 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002136
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302137 if (session_entry->vhtCapability) {
2138 if (session_entry->pePersona == QDF_STA_MODE) {
2139 session_entry->vht_config.su_beam_formee =
2140 reassoc_req->vht_config.su_beam_formee;
2141 } else {
2142 reassoc_req->vht_config.su_beam_formee = 0;
2143 }
2144 session_entry->enableVhtpAid =
2145 reassoc_req->enableVhtpAid;
2146 session_entry->enableVhtGid =
2147 reassoc_req->enableVhtGid;
2148 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2149 session_entry->vht_config.su_beam_former);
2150 }
2151
2152 lim_log(mac_ctx, LOG1,
2153 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2154 session_entry->vhtCapability,
2155 session_entry->vht_config.su_beam_formee,
2156 session_entry->vht_config.su_beam_former);
2157
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002158 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2159 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002160 session_entry->send_smps_action =
2161 reassoc_req->send_smps_action;
2162 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002163 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002164 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002165 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002166 session_entry->send_smps_action,
2167 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 /*
2169 * Reassociate request is expected
2170 * in link established state only.
2171 */
2172
2173 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2175 /*
2176 * May be from 11r FT pre-auth. So lets check it
2177 * before we bail out
2178 */
2179 lim_log(mac_ctx, LOG1, FL(
2180 "Session in reassoc state is %d"),
2181 session_entry->peSessionId);
2182
2183 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302184 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185 session_entry->limReAssocbssId,
2186 6)) {
2187 lim_print_mac_addr(mac_ctx,
2188 reassoc_req->bssDescription.
2189 bssId, LOGE);
2190 lim_log(mac_ctx, LOGP,
2191 FL("Unknown bssId in reassoc state"));
2192 ret_code = eSIR_SME_INVALID_PARAMETERS;
2193 goto end;
2194 }
2195
2196 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2197 session_entry);
2198 return;
2199 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 /*
2201 * Should not have received eWNI_SME_REASSOC_REQ
2202 */
2203 lim_log(mac_ctx, LOGE,
2204 FL("received unexpected SME_REASSOC_REQ in state %X"),
2205 session_entry->limSmeState);
2206 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2207
2208 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2209 goto end;
2210 }
2211
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302212 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 session_entry->pLimReAssocReq->bssDescription.bssId,
2214 sizeof(tSirMacAddr));
2215
2216 session_entry->limReassocChannelId =
2217 session_entry->pLimReAssocReq->bssDescription.channelId;
2218
2219 session_entry->reAssocHtSupportedChannelWidthSet =
2220 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2221 session_entry->reAssocHtRecommendedTxWidthSet =
2222 session_entry->reAssocHtSupportedChannelWidthSet;
2223 session_entry->reAssocHtSecondaryChannelOffset =
2224 session_entry->pLimReAssocReq->cbMode;
2225
2226 session_entry->limReassocBssCaps =
2227 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2228 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2229 session_entry->currentOperChannel);
2230 local_pwr_constraint = reg_max;
2231
2232 lim_extract_ap_capability(mac_ctx,
2233 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2234 lim_get_ielen_from_bss_description(
2235 &session_entry->pLimReAssocReq->bssDescription),
2236 &session_entry->limReassocBssQosCaps,
2237 &session_entry->limReassocBssPropCap,
2238 &session_entry->gLimCurrentBssUapsd,
2239 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302240 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302242 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2243 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 /* Copy the SSID from session entry to local variable */
2245 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302246 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 reassoc_req->ssId.ssId,
2248 session_entry->limReassocSSID.length);
2249 if (session_entry->gLimCurrentBssUapsd) {
2250 session_entry->gUapsdPerAcBitmask =
2251 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2252 lim_log(mac_ctx, LOG1,
2253 FL("UAPSD flag for all AC - 0x%2x"),
2254 session_entry->gUapsdPerAcBitmask);
2255 }
2256
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302257 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 if (NULL == mlm_reassoc_req) {
2259 lim_log(mac_ctx, LOGP,
2260 FL("call to AllocateMemory failed for mlmReassocReq"));
2261
2262 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2263 goto end;
2264 }
2265
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302266 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2268
2269 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2270 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2271 eSIR_SUCCESS) {
2272 /*
2273 * Could not get ReassocFailureTimeout value
2274 * from CFG. Log error.
2275 */
2276 lim_log(mac_ctx, LOGP,
2277 FL("could not retrieve ReassocFailureTimeout value"));
2278 }
2279
2280 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2281 eSIR_SUCCESS) {
2282 /*
2283 * Could not get Capabilities value
2284 * from CFG. Log error.
2285 */
2286 lim_log(mac_ctx, LOGP, FL(
2287 "could not retrieve Capabilities value"));
2288 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302289
2290 lim_update_caps_info_for_bss(mac_ctx, &caps,
2291 reassoc_req->bssDescription.capabilityInfo);
2292 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 mlm_reassoc_req->capabilityInfo = caps;
2295
2296 /* Update PE session_id */
2297 mlm_reassoc_req->sessionId = session_id;
2298
2299 /*
2300 * If telescopic beaconing is enabled, set listen interval to
2301 * WNI_CFG_TELE_BCN_MAX_LI
2302 */
2303 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2304 &tele_bcn_en) != eSIR_SUCCESS)
2305 lim_log(mac_ctx, LOGP,
2306 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2307
2308 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2309
2310 if (tele_bcn_en) {
2311 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2312 eSIR_SUCCESS)
2313 /*
2314 * Could not get ListenInterval value
2315 * from CFG. Log error.
2316 */
2317 lim_log(mac_ctx, LOGP,
2318 FL("could not retrieve ListenInterval"));
2319 } else {
2320 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2321 eSIR_SUCCESS)
2322 /*
2323 * Could not get ListenInterval value
2324 * from CFG. Log error.
2325 */
2326 lim_log(mac_ctx, LOGP,
2327 FL("could not retrieve ListenInterval"));
2328 }
2329
2330 mlm_reassoc_req->listenInterval = (uint16_t) val;
2331
2332 /* Indicate whether spectrum management is enabled */
2333 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2334
2335 /* Enable the spectrum management if this is a DFS channel */
2336 if (session_entry->country_info_present &&
2337 lim_isconnected_on_dfs_channel(
2338 session_entry->currentOperChannel))
2339 session_entry->spectrumMgtEnabled = true;
2340
2341 session_entry->limPrevSmeState = session_entry->limSmeState;
2342 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2343
2344 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2345 session_entry->peSessionId,
2346 session_entry->limSmeState));
2347
2348 lim_post_mlm_message(mac_ctx,
2349 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2350 return;
2351end:
2352 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302353 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 if (session_entry)
2355 session_entry->pLimReAssocReq = NULL;
2356 }
2357
2358 if (session_entry) {
2359 /*
2360 * error occurred after we determined the session so extract
2361 * session and transaction info from there
2362 */
2363 sme_session_id = session_entry->smeSessionId;
2364 transaction_id = session_entry->transactionId;
2365 } else
2366 /*
2367 * error occurred before or during the time we determined
2368 * the session so extract the session and transaction info
2369 * from the message
2370 */
2371 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2372 &sme_session_id, &transaction_id);
2373
2374 /*
2375 * Send Reassoc failure response to host
2376 * (note session_entry may be NULL, but that's OK)
2377 */
2378 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2379 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2380 session_entry, sme_session_id,
2381 transaction_id);
2382}
2383
2384bool send_disassoc_frame = 1;
2385/**
2386 * __lim_process_sme_disassoc_req()
2387 *
2388 ***FUNCTION:
2389 * This function is called to process SME_DISASSOC_REQ message
2390 * from HDD or upper layer application.
2391 *
2392 ***LOGIC:
2393 *
2394 ***ASSUMPTIONS:
2395 *
2396 ***NOTE:
2397 *
2398 * @param pMac Pointer to Global MAC structure
2399 * @param *pMsgBuf A pointer to the SME message buffer
2400 * @return None
2401 */
2402
2403static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2404{
2405 uint16_t disassocTrigger, reasonCode;
2406 tLimMlmDisassocReq *pMlmDisassocReq;
2407 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2408 tSirSmeDisassocReq smeDisassocReq;
2409 tpPESession psessionEntry = NULL;
2410 uint8_t sessionId;
2411 uint8_t smesessionId;
2412 uint16_t smetransactionId;
2413
2414 if (pMsgBuf == NULL) {
2415 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2416 return;
2417 }
2418
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302419 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 smesessionId = smeDisassocReq.sessionId;
2421 smetransactionId = smeDisassocReq.transactionId;
2422 if (!lim_is_sme_disassoc_req_valid(pMac,
2423 &smeDisassocReq,
2424 psessionEntry)) {
2425 PELOGE(lim_log(pMac, LOGE,
2426 FL("received invalid SME_DISASSOC_REQ message"));)
2427 if (pMac->lim.gLimRspReqd) {
2428 pMac->lim.gLimRspReqd = false;
2429
2430 retCode = eSIR_SME_INVALID_PARAMETERS;
2431 disassocTrigger = eLIM_HOST_DISASSOC;
2432 goto sendDisassoc;
2433 }
2434
2435 return;
2436 }
2437
2438 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002439 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440 &sessionId);
2441 if (psessionEntry == NULL) {
2442 lim_log(pMac, LOGE,
2443 FL("session does not exist for given bssId "
2444 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002445 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 retCode = eSIR_SME_INVALID_PARAMETERS;
2447 disassocTrigger = eLIM_HOST_DISASSOC;
2448 goto sendDisassoc;
2449 }
2450 lim_log(pMac, LOG1,
2451 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2452 MAC_ADDRESS_STR), smesessionId,
2453 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2454 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002455 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456
2457#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2458 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2459 0, smeDisassocReq.reasonCode);
2460#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2461
2462 /* Update SME session Id and SME transaction ID */
2463
2464 psessionEntry->smeSessionId = smesessionId;
2465 psessionEntry->transactionId = smetransactionId;
2466
2467 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2468 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 switch (psessionEntry->limSmeState) {
2470 case eLIM_SME_ASSOCIATED_STATE:
2471 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002472 lim_log(pMac, LOG1,
2473 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2474 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 psessionEntry->limPrevSmeState =
2476 psessionEntry->limSmeState;
2477 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2478#ifdef FEATURE_WLAN_TDLS
2479 /* Delete all TDLS peers connected before leaving BSS */
2480 lim_delete_tdls_peers(pMac, psessionEntry);
2481#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002482 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2483 psessionEntry->peSessionId,
2484 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 break;
2486
2487 case eLIM_SME_WT_DEAUTH_STATE:
2488 /* PE shall still process the DISASSOC_REQ and proceed with
2489 * link tear down even if it had already sent a DEAUTH_IND to
2490 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2491 * its been set when PE entered WT_DEAUTH_STATE.
2492 */
2493 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2494 MTRACE(mac_trace
2495 (pMac, TRACE_CODE_SME_STATE,
2496 psessionEntry->peSessionId,
2497 psessionEntry->limSmeState));
2498 lim_log(pMac, LOG1,
2499 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2500 break;
2501
2502 case eLIM_SME_WT_DISASSOC_STATE:
2503 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2504 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2505 * PE can continue processing DISASSOC_REQ and send the response instead
2506 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2507 * for disassoc frame.
2508 *
2509 * It will send a disassoc, which is ok. However, we can use the global flag
2510 * sendDisassoc to not send disassoc frame.
2511 */
2512 lim_log(pMac, LOG1,
2513 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2514 break;
2515
2516 case eLIM_SME_JOIN_FAILURE_STATE: {
2517 /* Already in Disconnected State, return success */
2518 lim_log(pMac, LOG1,
2519 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2520 if (pMac->lim.gLimRspReqd) {
2521 retCode = eSIR_SME_SUCCESS;
2522 disassocTrigger = eLIM_HOST_DISASSOC;
2523 goto sendDisassoc;
2524 }
2525 }
2526 break;
2527 default:
2528 /**
2529 * STA is not currently associated.
2530 * Log error and send response to host
2531 */
2532 lim_log(pMac, LOGE,
2533 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2534 psessionEntry->limSmeState);
2535 lim_print_sme_state(pMac, LOGE,
2536 psessionEntry->limSmeState);
2537
2538 if (pMac->lim.gLimRspReqd) {
2539 if (psessionEntry->limSmeState !=
2540 eLIM_SME_WT_ASSOC_STATE)
2541 pMac->lim.gLimRspReqd = false;
2542
2543 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2544 disassocTrigger = eLIM_HOST_DISASSOC;
2545 goto sendDisassoc;
2546 }
2547
2548 return;
2549 }
2550
2551 break;
2552
2553 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 /* Fall through */
2555 break;
2556
2557 case eLIM_STA_IN_IBSS_ROLE:
2558 default:
2559 /* eLIM_UNKNOWN_ROLE */
2560 lim_log(pMac, LOGE,
2561 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2562 GET_LIM_SYSTEM_ROLE(psessionEntry));
2563
2564 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2565 disassocTrigger = eLIM_HOST_DISASSOC;
2566 goto sendDisassoc;
2567 } /* end switch (pMac->lim.gLimSystemRole) */
2568
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302569 disassocTrigger = eLIM_HOST_DISASSOC;
2570 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571
2572 if (smeDisassocReq.doNotSendOverTheAir) {
2573 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2574 send_disassoc_frame = 0;
2575 }
2576 /* Trigger Disassociation frame to peer MAC entity */
2577 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2578 " : %d, reasonCode : %d"),
2579 disassocTrigger, reasonCode);
2580
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302581 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 if (NULL == pMlmDisassocReq) {
2583 /* Log error */
2584 lim_log(pMac, LOGP,
2585 FL("call to AllocateMemory failed for mlmDisassocReq"));
2586
2587 return;
2588 }
2589
Anurag Chouhanc5548422016-02-24 18:33:27 +05302590 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002591 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592
2593 pMlmDisassocReq->reasonCode = reasonCode;
2594 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2595
2596 /* Update PE session ID */
2597 pMlmDisassocReq->sessionId = sessionId;
2598
2599 lim_post_mlm_message(pMac,
2600 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2601 return;
2602
2603sendDisassoc:
2604 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002605 lim_send_sme_disassoc_ntf(pMac,
2606 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 retCode,
2608 disassocTrigger,
2609 1, smesessionId, smetransactionId,
2610 psessionEntry);
2611 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002612 lim_send_sme_disassoc_ntf(pMac,
2613 smeDisassocReq.peer_macaddr.bytes,
2614 retCode, disassocTrigger, 1,
2615 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616
2617} /*** end __lim_process_sme_disassoc_req() ***/
2618
2619/** -----------------------------------------------------------------
2620 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2621
2622 This function is called to process SME_DISASSOC_CNF message
2623 from HDD or upper layer application.
2624
2625 \param pMac - global mac structure
2626 \param pStaDs - station dph hash node
2627 \return none
2628 \sa
2629 ----------------------------------------------------------------- */
2630static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2631{
2632 tSirSmeDisassocCnf smeDisassocCnf;
2633 uint16_t aid;
2634 tpDphHashNode pStaDs;
2635 tpPESession psessionEntry;
2636 uint8_t sessionId;
2637
2638 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2639
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302640 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 sizeof(struct sSirSmeDisassocCnf));
2642
2643 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002644 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 &sessionId);
2646 if (psessionEntry == NULL) {
2647 lim_log(pMac, LOGE,
2648 FL("session does not exist for given bssId"));
2649 return;
2650 }
2651
2652 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2653 lim_log(pMac, LOGE,
2654 FL("received invalid SME_DISASSOC_CNF message"));
2655 return;
2656 }
2657#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2658 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2659 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2660 psessionEntry,
2661 (uint16_t) smeDisassocCnf.statusCode, 0);
2662 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2663 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2664 psessionEntry,
2665 (uint16_t) smeDisassocCnf.statusCode, 0);
2666#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2667
2668 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2669 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2671 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2672 && (psessionEntry->limSmeState !=
2673 eLIM_SME_WT_DEAUTH_STATE)) {
2674 lim_log(pMac, LOGE,
2675 FL
2676 ("received unexp SME_DISASSOC_CNF in state %X"),
2677 psessionEntry->limSmeState);
2678 lim_print_sme_state(pMac, LOGE,
2679 psessionEntry->limSmeState);
2680 return;
2681 }
2682 break;
2683
2684 case eLIM_AP_ROLE:
2685 /* Fall through */
2686 break;
2687
2688 case eLIM_STA_IN_IBSS_ROLE:
2689 default: /* eLIM_UNKNOWN_ROLE */
2690 lim_log(pMac, LOGE,
2691 FL("received unexpected SME_DISASSOC_CNF role %d"),
2692 GET_LIM_SYSTEM_ROLE(psessionEntry));
2693
2694 return;
2695 }
2696
2697 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2698 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2699 LIM_IS_AP_ROLE(psessionEntry)) {
2700 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002701 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 &psessionEntry->dph.dphHashTable);
2703 if (pStaDs == NULL) {
2704 lim_log(pMac, LOGE,
2705 FL("DISASSOC_CNF for a STA with no context, addr= "
2706 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002707 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 return;
2709 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302710
2711 if ((pStaDs->mlmStaContext.mlmState ==
2712 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2713 (pStaDs->mlmStaContext.mlmState ==
2714 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2715 lim_log(pMac, LOGE,
2716 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002717 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302718 pStaDs->mlmStaContext.mlmState);
2719 return;
2720 }
2721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 /* Delete FT session if there exists one */
2723 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2725
2726 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002727 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 }
2729
2730 return;
2731}
2732
2733/**
2734 * __lim_process_sme_deauth_req() - process sme deauth req
2735 * @mac_ctx: Pointer to Global MAC structure
2736 * @msg_buf: pointer to the SME message buffer
2737 *
2738 * This function is called to process SME_DEAUTH_REQ message
2739 * from HDD or upper layer application.
2740 *
2741 * Return: None
2742 */
2743
2744static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2745 uint32_t *msg_buf)
2746{
2747 uint16_t deauth_trigger, reason_code;
2748 tLimMlmDeauthReq *mlm_deauth_req;
2749 tSirSmeDeauthReq sme_deauth_req;
2750 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2751 tpPESession session_entry;
2752 uint8_t session_id; /* PE sessionId */
2753 uint8_t sme_session_id;
2754 uint16_t sme_transaction_id;
2755
2756 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2757
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302758 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 sme_session_id = sme_deauth_req.sessionId;
2760 sme_transaction_id = sme_deauth_req.transactionId;
2761
2762 /*
2763 * We need to get a session first but we don't even know
2764 * if the message is correct.
2765 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002766 session_entry = pe_find_session_by_bssid(mac_ctx,
2767 sme_deauth_req.bssid.bytes,
2768 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002769 if (session_entry == NULL) {
2770 lim_log(mac_ctx, LOGE,
2771 FL("session does not exist for given bssId"));
2772 ret_code = eSIR_SME_INVALID_PARAMETERS;
2773 deauth_trigger = eLIM_HOST_DEAUTH;
2774 goto send_deauth;
2775 }
2776
2777 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2778 session_entry)) {
2779 lim_log(mac_ctx, LOGE,
2780 FL("received invalid SME_DEAUTH_REQ message"));
2781 mac_ctx->lim.gLimRspReqd = false;
2782
2783 ret_code = eSIR_SME_INVALID_PARAMETERS;
2784 deauth_trigger = eLIM_HOST_DEAUTH;
2785 goto send_deauth;
2786 }
2787 lim_log(mac_ctx, LOG1,
2788 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2789 MAC_ADDRESS_STR), sme_session_id,
2790 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2791 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002792 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2794 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2795 session_entry, 0, sme_deauth_req.reasonCode);
2796#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2797
2798 /* Update SME session ID and Transaction ID */
2799 session_entry->smeSessionId = sme_session_id;
2800 session_entry->transactionId = sme_transaction_id;
2801
2802 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2803 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 switch (session_entry->limSmeState) {
2805 case eLIM_SME_ASSOCIATED_STATE:
2806 case eLIM_SME_LINK_EST_STATE:
2807 case eLIM_SME_WT_ASSOC_STATE:
2808 case eLIM_SME_JOIN_FAILURE_STATE:
2809 case eLIM_SME_IDLE_STATE:
2810 session_entry->limPrevSmeState =
2811 session_entry->limSmeState;
2812 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2813 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2814 session_entry->peSessionId,
2815 session_entry->limSmeState));
2816 /* Send Deauthentication request to MLM below */
2817 break;
2818 case eLIM_SME_WT_DEAUTH_STATE:
2819 case eLIM_SME_WT_DISASSOC_STATE:
2820 /*
2821 * PE Recieved a Deauth/Disassoc frame. Normally it get
2822 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2823 * Which means host is also trying to disconnect.
2824 * PE can continue processing DEAUTH_REQ and send
2825 * the response instead of failing the request.
2826 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2827 * was sent for deauth/disassoc frame.
2828 */
2829 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2830 lim_log(mac_ctx, LOG1, FL(
2831 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2832 break;
2833 default:
2834 /*
2835 * STA is not in a state to deauthenticate with
2836 * peer. Log error and send response to host.
2837 */
2838 lim_log(mac_ctx, LOGE, FL(
2839 "received unexp SME_DEAUTH_REQ in state %X"),
2840 session_entry->limSmeState);
2841 lim_print_sme_state(mac_ctx, LOGE,
2842 session_entry->limSmeState);
2843
2844 if (mac_ctx->lim.gLimRspReqd) {
2845 mac_ctx->lim.gLimRspReqd = false;
2846
2847 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2848 deauth_trigger = eLIM_HOST_DEAUTH;
2849
2850 /*
2851 * here we received deauth request from AP so sme state
2852 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2853 * delSta then mlm state should be
2854 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2855 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2856 * so the below condition captures the state where
2857 * delSta not done and firmware still in
2858 * connected state.
2859 */
2860 if (session_entry->limSmeState ==
2861 eLIM_SME_WT_DEAUTH_STATE &&
2862 session_entry->limMlmState !=
2863 eLIM_MLM_IDLE_STATE &&
2864 session_entry->limMlmState !=
2865 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2866 ret_code = eSIR_SME_DEAUTH_STATUS;
2867 goto send_deauth;
2868 }
2869 return;
2870 }
2871 break;
2872
2873 case eLIM_STA_IN_IBSS_ROLE:
2874 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2875 if (mac_ctx->lim.gLimRspReqd) {
2876 mac_ctx->lim.gLimRspReqd = false;
2877 ret_code = eSIR_SME_INVALID_PARAMETERS;
2878 deauth_trigger = eLIM_HOST_DEAUTH;
2879 goto send_deauth;
2880 }
2881 return;
2882 case eLIM_AP_ROLE:
2883 break;
2884 default:
2885 lim_log(mac_ctx, LOGE,
2886 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2887 GET_LIM_SYSTEM_ROLE(session_entry));
2888 if (mac_ctx->lim.gLimRspReqd) {
2889 mac_ctx->lim.gLimRspReqd = false;
2890 ret_code = eSIR_SME_INVALID_PARAMETERS;
2891 deauth_trigger = eLIM_HOST_DEAUTH;
2892 goto send_deauth;
2893 }
2894 return;
2895 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2896
2897 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2898 /* Deauthentication is triggered by Link Monitoring */
2899 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2900 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2901 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2902 } else {
2903 deauth_trigger = eLIM_HOST_DEAUTH;
2904 reason_code = sme_deauth_req.reasonCode;
2905 }
2906
2907 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302908 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 if (NULL == mlm_deauth_req) {
2910 lim_log(mac_ctx, LOGP,
2911 FL("call to AllocateMemory failed for mlmDeauthReq"));
2912 if (mac_ctx->lim.gLimRspReqd) {
2913 mac_ctx->lim.gLimRspReqd = false;
2914 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2915 deauth_trigger = eLIM_HOST_DEAUTH;
2916 goto send_deauth;
2917 }
2918 return;
2919 }
2920
Anurag Chouhanc5548422016-02-24 18:33:27 +05302921 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002922 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923
2924 mlm_deauth_req->reasonCode = reason_code;
2925 mlm_deauth_req->deauthTrigger = deauth_trigger;
2926
2927 /* Update PE session Id */
2928 mlm_deauth_req->sessionId = session_id;
2929
2930 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2931 (uint32_t *)mlm_deauth_req);
2932 return;
2933
2934send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002935 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2936 ret_code, deauth_trigger, 1,
2937 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938}
2939
2940/**
2941 * __lim_process_sme_set_context_req()
2942 *
2943 * @mac_ctx: Pointer to Global MAC structure
2944 * @msg_buf: pointer to the SME message buffer
2945 *
2946 * This function is called to process SME_SETCONTEXT_REQ message
2947 * from HDD or upper layer application.
2948 *
2949 * Return: None
2950 */
2951
2952static void
2953__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2954{
2955 tpSirSmeSetContextReq set_context_req;
2956 tLimMlmSetKeysReq *mlm_set_key_req;
2957 tpPESession session_entry;
2958 uint8_t session_id; /* PE sessionID */
2959 uint8_t sme_session_id;
2960 uint16_t sme_transaction_id;
2961
2962 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2963
2964 if (msg_buf == NULL) {
2965 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2966 return;
2967 }
2968
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302969 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 if (NULL == set_context_req) {
2971 lim_log(mac_ctx, LOGP, FL(
2972 "call to AllocateMemory failed for set_context_req"));
2973 return;
2974 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302975 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 sizeof(struct sSirSmeSetContextReq));
2977 sme_session_id = set_context_req->sessionId;
2978 sme_transaction_id = set_context_req->transactionId;
2979
2980 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2981 lim_log(mac_ctx, LOGW,
2982 FL("received invalid SME_SETCONTEXT_REQ message"));
2983 goto end;
2984 }
2985
2986 if (set_context_req->keyMaterial.numKeys >
2987 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2988 lim_log(mac_ctx, LOGE, FL(
2989 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2990 set_context_req->keyMaterial.numKeys);
2991 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002992 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993 eSIR_SME_INVALID_PARAMETERS, NULL,
2994 sme_session_id, sme_transaction_id);
2995 goto end;
2996 }
2997
2998 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002999 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000 if (session_entry == NULL) {
3001 lim_log(mac_ctx, LOGW,
3002 FL("Session does not exist for given BSSID"));
3003 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003004 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 eSIR_SME_INVALID_PARAMETERS, NULL,
3006 sme_session_id, sme_transaction_id);
3007 goto end;
3008 }
3009#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3010 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3011 session_entry, 0, 0);
3012#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3013
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003014 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3016 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003017 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3019 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303020 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 if (NULL == mlm_set_key_req) {
3022 lim_log(mac_ctx, LOGP, FL(
3023 "mem alloc failed for mlmSetKeysReq"));
3024 goto end;
3025 }
3026 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3027 mlm_set_key_req->numKeys =
3028 set_context_req->keyMaterial.numKeys;
3029 if (mlm_set_key_req->numKeys >
3030 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3031 lim_log(mac_ctx, LOGP, FL(
3032 "no.of keys exceeded max num of default keys limit"));
3033 goto end;
3034 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303035 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003036 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303038 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 (uint8_t *) &set_context_req->keyMaterial.key,
3040 sizeof(tSirKeys) *
3041 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3042 numKeys : 1));
3043
3044 mlm_set_key_req->sessionId = session_id;
3045 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 lim_log(mac_ctx, LOG1, FL(
3047 "received SETCONTEXT_REQ message sessionId=%d"),
3048 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049
3050 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3051 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3052 LIM_IS_AP_ROLE(session_entry)) {
3053 if (set_context_req->keyMaterial.key[0].keyLength) {
3054 uint8_t key_id;
3055 key_id =
3056 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303057 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 &session_entry->WEPKeyMaterial[key_id],
3059 (uint8_t *) &set_context_req->keyMaterial,
3060 sizeof(tSirKeyMaterial));
3061 } else {
3062 uint32_t i;
3063 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3064 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303065 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 &mlm_set_key_req->key[i],
3067 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3068 sizeof(tSirKeys));
3069 }
3070 }
3071 }
3072 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3073 (uint32_t *) mlm_set_key_req);
3074 } else {
3075 lim_log(mac_ctx, LOGE, FL(
3076 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3077 GET_LIM_SYSTEM_ROLE(session_entry),
3078 session_entry->limSmeState);
3079 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3080
3081 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003082 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3084 session_entry, sme_session_id,
3085 sme_transaction_id);
3086 }
3087end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303088 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 return;
3090}
3091
3092/**
3093 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3094 *
3095 * @mac_ctx: Pointer to Global MAC structure
3096 * @msg_buf: pointer to the SME message buffer
3097 *
3098 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3099 * from HDD or upper layer application.
3100 *
3101 * Return: None
3102 */
3103
3104void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3105 uint32_t *msg_buf)
3106{
3107 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3108 tpDphHashNode sta_ds = NULL;
3109 tpPESession session_entry = NULL;
3110 tSap_Event sap_event;
3111 tpWLAN_SAPEventCB sap_event_cb = NULL;
3112 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3113 uint8_t session_id = CSR_SESSION_ID_INVALID;
3114 uint8_t assoc_id = 0;
3115 uint8_t sta_cnt = 0;
3116
3117 if (msg_buf == NULL) {
3118 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3119 return;
3120 }
3121
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303122 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 sizeof(struct sSirSmeGetAssocSTAsReq));
3124 /*
3125 * Get Associated stations from PE.
3126 * Find PE session Entry
3127 */
3128 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003129 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 &session_id);
3131 if (session_entry == NULL) {
3132 lim_log(mac_ctx, LOGE,
3133 FL("session does not exist for given bssId"));
3134 goto lim_assoc_sta_end;
3135 }
3136
3137 if (!LIM_IS_AP_ROLE(session_entry)) {
3138 lim_log(mac_ctx, LOGE, FL(
3139 "Received unexpected message in state %X, in role %X"),
3140 session_entry->limSmeState,
3141 GET_LIM_SYSTEM_ROLE(session_entry));
3142 goto lim_assoc_sta_end;
3143 }
3144 /* Retrieve values obtained in the request message */
3145 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3146 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3147
3148 if (NULL == assoc_sta_tmp)
3149 goto lim_assoc_sta_end;
3150 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3151 assoc_id++) {
3152 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3153 &session_entry->dph.dphHashTable);
3154 if (NULL == sta_ds)
3155 continue;
3156 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303157 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303159 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3161 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3162
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303163 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 (uint8_t *)&sta_ds->supportedRates,
3165 sizeof(tSirSupportedRates));
3166 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3167 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3168 assoc_sta_tmp->Support40Mhz =
3169 sta_ds->htDsssCckRate40MHzSupport;
3170
3171 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3172 sta_cnt + 1);
3173 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3174 MAC_ADDR_ARRAY(sta_ds->staAddr));
3175 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3176 sta_ds->assocId);
3177 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3178 sta_ds->staIndex);
3179 assoc_sta_tmp++;
3180 sta_cnt++;
3181 }
3182 }
3183lim_assoc_sta_end:
3184 /*
3185 * Call hdd callback with sap event to send the list of
3186 * associated stations from PE
3187 */
3188 if (sap_event_cb != NULL) {
3189 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3190 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303191 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3193 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3194 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3195 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3196 }
3197}
3198
3199/**
3200 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3201 *
3202 * @mac_ctx: Pointer to Global MAC structure
3203 * @msg_buf: pointer to WPS PBC overlap query message
3204 *
3205 * This function parses get WPS PBC overlap information
3206 * message and call callback to pass WPS PBC overlap
3207 * information back to hdd.
3208 *
3209 * Return: None
3210 */
3211void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3212 uint32_t *msg_buf)
3213{
3214 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3215 tpPESession session_entry = NULL;
3216 tSap_Event sap_event;
3217 tpWLAN_SAPEventCB sap_event_cb = NULL;
3218 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3220
3221 if (msg_buf == NULL) {
3222 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3223 return;
3224 }
3225
3226 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303227 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303229 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3231 /*
3232 * Get Associated stations from PE
3233 * Find PE session Entry
3234 */
3235 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003236 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 if (session_entry == NULL) {
3238 lim_log(mac_ctx, LOGE,
3239 FL("session does not exist for given bssId"));
3240 goto lim_get_wpspbc_sessions_end;
3241 }
3242
3243 if (!LIM_IS_AP_ROLE(session_entry)) {
3244 lim_log(mac_ctx, LOGE,
3245 FL("Received unexpected message in role %X"),
3246 GET_LIM_SYSTEM_ROLE(session_entry));
3247 goto lim_get_wpspbc_sessions_end;
3248 }
3249 /*
3250 * Call hdd callback with sap event to send the
3251 * WPS PBC overlap information
3252 */
3253 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303254 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255
Anurag Chouhanc5548422016-02-24 18:33:27 +05303256 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003258 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 sap_get_wpspbc_event->UUID_E,
3260 &sap_get_wpspbc_event->wpsPBCOverlap,
3261 session_entry);
3262 } else {
3263 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003264 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 session_entry);
3266 /* don't have to inform the HDD/Host */
3267 return;
3268 }
3269
3270 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3271 sap_get_wpspbc_event->wpsPBCOverlap);
3272 lim_print_mac_addr(mac_ctx,
3273 sap_get_wpspbc_event->addr.bytes, LOG4);
3274
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303275 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276
3277lim_get_wpspbc_sessions_end:
3278 sap_event_cb =
3279 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3280 if (NULL != sap_event_cb)
3281 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3282}
3283
3284/**
3285 * __lim_counter_measures()
3286 *
3287 * FUNCTION:
3288 * This function is called to "implement" MIC counter measure
3289 * and is *temporary* only
3290 *
3291 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3292 * we don't do the proper STA disassoc sequence since the
3293 * BSS will be stoped anyway
3294 *
3295 ***ASSUMPTIONS:
3296 *
3297 ***NOTE:
3298 *
3299 * @param pMac Pointer to Global MAC structure
3300 * @return None
3301 */
3302
3303static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3304{
3305 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003306 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3308 mac, psessionEntry, false);
3309};
3310
3311void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3312{
3313 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3314 tpPESession psessionEntry;
3315 uint8_t sessionId; /* PE sessionId */
3316
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303317 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 sizeof(struct sSirSmeTkipCntrMeasReq));
3319
3320 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003321 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 if (NULL == psessionEntry) {
3323 lim_log(pMac, LOGE,
3324 FL("session does not exist for given BSSID "));
3325 return;
3326 }
3327
3328 if (tkipCntrMeasReq.bEnable)
3329 __lim_counter_measures(pMac, psessionEntry);
3330
3331 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3332}
3333
3334static void
3335__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3336{
3337 tSirSmeStopBssReq stopBssReq;
3338 tSirRetStatus status;
3339 tLimSmeStates prevState;
3340 tpPESession psessionEntry;
3341 uint8_t smesessionId;
3342 uint8_t sessionId;
3343 uint16_t smetransactionId;
3344 uint8_t i = 0;
3345 tpDphHashNode pStaDs = NULL;
3346
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303347 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348 smesessionId = stopBssReq.sessionId;
3349 smetransactionId = stopBssReq.transactionId;
3350
3351 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3352 PELOGW(lim_log(pMac, LOGW,
3353 FL("received invalid SME_STOP_BSS_REQ message"));)
3354 /* Send Stop BSS response to host */
3355 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3356 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3357 smetransactionId);
3358 return;
3359 }
3360
3361 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003362 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363 &sessionId);
3364 if (psessionEntry == NULL) {
3365 lim_log(pMac, LOGW,
3366 FL("session does not exist for given BSSID "));
3367 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3368 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3369 smetransactionId);
3370 return;
3371 }
3372#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3373 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3374 0, 0);
3375#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3376
3377 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3378 LIM_IS_STA_ROLE(psessionEntry)) {
3379 /**
3380 * Should not have received STOP_BSS_REQ in states
3381 * other than 'normal' state or on STA in Infrastructure
3382 * mode. Log error and return response to host.
3383 */
3384 lim_log(pMac, LOGE,
3385 FL
3386 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3387 psessionEntry->limSmeState,
3388 GET_LIM_SYSTEM_ROLE(psessionEntry));
3389 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3390 /* / Send Stop BSS response to host */
3391 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3392 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3393 smetransactionId);
3394 return;
3395 }
3396
3397 if (LIM_IS_AP_ROLE(psessionEntry))
3398 lim_wpspbc_close(pMac, psessionEntry);
3399
3400 lim_log(pMac, LOGW,
3401 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3402 stopBssReq.reasonCode);
3403
3404 prevState = psessionEntry->limSmeState;
3405
3406 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3407 MTRACE(mac_trace
3408 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3409 psessionEntry->limSmeState));
3410
3411 /* Update SME session Id and Transaction Id */
3412 psessionEntry->smeSessionId = smesessionId;
3413 psessionEntry->transactionId = smetransactionId;
3414
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003415 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3416 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3417 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3419 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3420 /* Send disassoc all stations associated thru TKIP */
3421 __lim_counter_measures(pMac, psessionEntry);
3422 else
3423 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003424 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3425 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 }
3427
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003428 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3429 /* Free the buffer allocated in START_BSS_REQ */
3430 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3431 psessionEntry->addIeParams.probeRespDataLen = 0;
3432 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003434 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3435 psessionEntry->addIeParams.assocRespDataLen = 0;
3436 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003438 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3439 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3440 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003442 /*
3443 * lim_del_bss is also called as part of coalescing,
3444 * when we send DEL BSS followed by Add Bss msg.
3445 */
3446 pMac->lim.gLimIbssCoalescingHappened = false;
3447 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3449 pStaDs =
3450 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3451 if (NULL == pStaDs)
3452 continue;
3453 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3454 if (eSIR_SUCCESS == status) {
3455 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3456 pStaDs->assocId, psessionEntry);
3457 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3458 } else {
3459 lim_log(pMac, LOGE,
3460 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303461 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 }
3463 }
3464 /* send a delBss to HAL and wait for a response */
3465 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3466
3467 if (status != eSIR_SUCCESS) {
3468 PELOGE(lim_log
3469 (pMac, LOGE, FL("delBss failed for bss %d"),
3470 psessionEntry->bssIdx);
3471 )
3472 psessionEntry->limSmeState = prevState;
3473
3474 MTRACE(mac_trace
3475 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3476 psessionEntry->limSmeState));
3477
3478 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3479 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3480 smetransactionId);
3481 }
3482}
3483
3484/**
3485 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3486 * @pMac: Global MAC context
3487 * @pMsg: Message from SME
3488 *
3489 * Wrapper for the function __lim_handle_sme_stop_bss_request
3490 * This message will be defered until softmac come out of
3491 * scan mode. Message should be handled even if we have
3492 * detected radar in the current operating channel.
3493 *
3494 * Return: true - If we consumed the buffer
3495 * false - If have defered the message.
3496 */
3497
3498static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3499{
3500 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3501 /**
3502 * If message defered, buffer is not consumed yet.
3503 * So return false
3504 */
3505 return false;
3506 }
3507 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3508 return true;
3509} /*** end __lim_process_sme_stop_bss_req() ***/
3510
3511void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3512 uint32_t body, tpPESession psessionEntry)
3513{
3514
3515 (void)body;
3516 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3517 lim_ibss_delete(pMac, psessionEntry);
3518 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3519 lim_delete_pre_auth_list(pMac);
3520 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3521 psessionEntry->smeSessionId,
3522 psessionEntry->transactionId);
3523 return;
3524}
3525
3526/**
3527 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3528 *
3529 * @mac_ctx: pointer to mac context
3530 * @msg_type: message type
3531 * @msg_buf: pointer to the SME message buffer
3532 *
3533 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3534 * in BTAMP AP.
3535 *
3536 * Return: None
3537 */
3538
3539void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3540 uint32_t *msg_buf)
3541{
3542 tSirSmeAssocCnf assoc_cnf;
3543 tpDphHashNode sta_ds = NULL;
3544 tpPESession session_entry = NULL;
3545 uint8_t session_id;
3546 tpSirAssocReq assoc_req;
3547
3548 if (msg_buf == NULL) {
3549 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3550 goto end;
3551 }
3552
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303553 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3555 lim_log(mac_ctx, LOGE,
3556 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3557 goto end;
3558 }
3559
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003560 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 &session_id);
3562 if (session_entry == NULL) {
3563 lim_log(mac_ctx, LOGE,
3564 FL("session does not exist for given bssId"));
3565 goto end;
3566 }
3567
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003568 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3570 (session_entry->limSmeState !=
3571 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3572 lim_log(mac_ctx, LOGE, FL(
3573 "Rcvd unexpected msg %X in state %X, in role %X"),
3574 msg_type, session_entry->limSmeState,
3575 GET_LIM_SYSTEM_ROLE(session_entry));
3576 goto end;
3577 }
3578 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3579 &session_entry->dph.dphHashTable);
3580 if (sta_ds == NULL) {
3581 lim_log(mac_ctx, LOGE, FL(
3582 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3583 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003584 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585
3586 /*
3587 * send a DISASSOC_IND message to WSM to make sure
3588 * the state in WSM and LIM is the same
3589 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003590 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 eSIR_SME_STA_NOT_ASSOCIATED,
3592 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3593 session_entry->smeSessionId,
3594 session_entry->transactionId,
3595 session_entry);
3596 goto end;
3597 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303598 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003599 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303600 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 lim_log(mac_ctx, LOG1, FL(
3602 "peerMacAddr mismatched for aid %d, peer "),
3603 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003604 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 goto end;
3606 }
3607
3608 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3609 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3610 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3611 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3612 (msg_type != eWNI_SME_ASSOC_CNF))) {
3613 lim_log(mac_ctx, LOG1, FL(
3614 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3615 "StaD mlmState : %d"),
3616 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003617 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 goto end;
3619 }
3620 /*
3621 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3622 * has been received
3623 */
3624 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3625 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3626 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3627
3628 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3629 /*
3630 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3631 * when it had received Assoc Request frame. Now, PE just needs
3632 * to send association rsp frame to the requesting BTAMP-STA.
3633 */
3634 sta_ds->mlmStaContext.mlmState =
3635 eLIM_MLM_LINK_ESTABLISHED_STATE;
3636 lim_log(mac_ctx, LOG1,
3637 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3638 sta_ds->assocId);
3639 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3640 sta_ds->assocId, sta_ds->staAddr,
3641 sta_ds->mlmStaContext.subType, sta_ds,
3642 session_entry);
3643 goto end;
3644 } else {
3645 /*
3646 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3647 * to be associated since the HAL sta entry is created for
3648 * denied STA we need to remove this HAL entry.
3649 * So to do that set updateContext to 1
3650 */
3651 if (!sta_ds->mlmStaContext.updateContext)
3652 sta_ds->mlmStaContext.updateContext = 1;
3653 lim_log(mac_ctx, LOG1,
3654 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3655 assoc_cnf.statusCode, sta_ds->assocId);
3656 lim_reject_association(mac_ctx, sta_ds->staAddr,
3657 sta_ds->mlmStaContext.subType,
3658 true, sta_ds->mlmStaContext.authType,
3659 sta_ds->assocId, true,
3660 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3661 session_entry);
3662 }
3663end:
3664 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3665 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3666 assoc_req = (tpSirAssocReq)
3667 session_entry->parsedAssocReq[sta_ds->assocId];
3668 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303669 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 assoc_req->assocReqFrame = NULL;
3671 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303672 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3674 }
3675}
3676
3677static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3678{
3679 tpDphHashNode pStaDs;
3680 tSirMacAddr peerMac;
3681 tpSirAddtsReq pSirAddts;
3682 uint32_t timeout;
3683 tpPESession psessionEntry;
3684 uint8_t sessionId; /* PE sessionId */
3685 uint8_t smesessionId;
3686 uint16_t smetransactionId;
3687
3688 if (pMsgBuf == NULL) {
3689 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3690 return;
3691 }
3692
3693 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3694 &smetransactionId);
3695
3696 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3697
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003698 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3699 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700 if (psessionEntry == NULL) {
3701 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3702 return;
3703 }
3704#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3705 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3706 0);
3707#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3708
3709 /* if sta
3710 * - verify assoc state
3711 * - send addts request to ap
3712 * - wait for addts response from ap
3713 * if ap, just ignore with error log
3714 */
3715 PELOG1(lim_log(pMac, LOG1,
3716 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3717 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3718 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3719 )
3720
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003721 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3723 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3724 psessionEntry, pSirAddts->req.tspec,
3725 smesessionId, smetransactionId);
3726 return;
3727 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728
3729 pStaDs =
3730 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3731 &psessionEntry->dph.dphHashTable);
3732
3733 if (pStaDs == NULL) {
3734 PELOGE(lim_log
3735 (pMac, LOGE, "Cannot find AP context for addts req");
3736 )
3737 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3738 psessionEntry, pSirAddts->req.tspec,
3739 smesessionId, smetransactionId);
3740 return;
3741 }
3742
3743 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3744 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3745 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3746 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3747 psessionEntry, pSirAddts->req.tspec,
3748 smesessionId, smetransactionId);
3749 return;
3750 }
3751
3752 pSirAddts->req.wsmTspecPresent = 0;
3753 pSirAddts->req.wmeTspecPresent = 0;
3754 pSirAddts->req.lleTspecPresent = 0;
3755
3756 if ((pStaDs->wsmEnabled) &&
3757 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3758 SIR_MAC_ACCESSPOLICY_EDCA))
3759 pSirAddts->req.wsmTspecPresent = 1;
3760 else if (pStaDs->wmeEnabled)
3761 pSirAddts->req.wmeTspecPresent = 1;
3762 else if (pStaDs->lleEnabled)
3763 pSirAddts->req.lleTspecPresent = 1;
3764 else {
3765 PELOGW(lim_log
3766 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3767 )
3768 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3769 psessionEntry, pSirAddts->req.tspec,
3770 smesessionId, smetransactionId);
3771 return;
3772 }
3773
3774 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3775 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3776 lim_log(pMac, LOGE,
3777 "AddTs received in invalid LIMsme state (%d)",
3778 psessionEntry->limSmeState);
3779 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3780 psessionEntry, pSirAddts->req.tspec,
3781 smesessionId, smetransactionId);
3782 return;
3783 }
3784
3785 if (pMac->lim.gLimAddtsSent) {
3786 lim_log(pMac, LOGE,
3787 "Addts (token %d, tsid %d, up %d) is still pending",
3788 pMac->lim.gLimAddtsReq.req.dialogToken,
3789 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3790 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3791 userPrio);
3792 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3793 psessionEntry, pSirAddts->req.tspec,
3794 smesessionId, smetransactionId);
3795 return;
3796 }
3797
3798 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3799
3800 /* save the addts request */
3801 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303802 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3804
3805 /* ship out the message now */
3806 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3807 psessionEntry);
3808 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3809 /* start a timer to wait for the response */
3810 if (pSirAddts->timeout)
3811 timeout = pSirAddts->timeout;
3812 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3813 eSIR_SUCCESS) {
3814 lim_log(pMac, LOGP,
3815 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3816 WNI_CFG_ADDTS_RSP_TIMEOUT);
3817 return;
3818 }
3819
3820 timeout = SYS_MS_TO_TICKS(timeout);
3821 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3822 != TX_SUCCESS) {
3823 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3824 return;
3825 }
3826 pMac->lim.gLimAddtsRspTimerCount++;
3827 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3828 pMac->lim.gLimAddtsRspTimerCount) !=
3829 TX_SUCCESS) {
3830 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3831 return;
3832 }
3833 MTRACE(mac_trace
3834 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3835 eLIM_ADDTS_RSP_TIMER));
3836
3837 /* add the sessionId to the timer object */
3838 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3839 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3840 TX_SUCCESS) {
3841 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3842 return;
3843 }
3844 return;
3845}
3846
3847static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3848{
3849 tSirMacAddr peerMacAddr;
3850 uint8_t ac;
3851 tSirMacTSInfo *pTsinfo;
3852 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3853 tpDphHashNode pStaDs = NULL;
3854 tpPESession psessionEntry;
3855 uint8_t sessionId;
3856 uint32_t status = eSIR_SUCCESS;
3857 uint8_t smesessionId;
3858 uint16_t smetransactionId;
3859
3860 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3861 &smetransactionId);
3862
3863 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003864 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865 &sessionId);
3866 if (psessionEntry == NULL) {
3867 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3868 status = eSIR_FAILURE;
3869 goto end;
3870 }
3871#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3872 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3873 0);
3874#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3875
3876 if (eSIR_SUCCESS !=
3877 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3878 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3879 status = eSIR_FAILURE;
3880 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3881 smesessionId, smetransactionId);
3882 return;
3883 }
3884
3885 lim_log(pMac, LOG1,
3886 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3887 MAC_ADDRESS_STR),
3888 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3889
3890 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3891 pDeltsReq->req.wmeTspecPresent,
3892 &pDeltsReq->req.tsinfo,
3893 &pDeltsReq->req.tspec, psessionEntry);
3894
3895 pTsinfo =
3896 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3897 tsinfo : &pDeltsReq->req.tsinfo;
3898
3899 /* We've successfully send DELTS frame to AP. Update the
3900 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3901 * is no longer trigger enabled or delivery enabled
3902 */
3903 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3904 pTsinfo, CLEAR_UAPSD_MASK);
3905
3906 /* We're deleting the TSPEC, so this particular AC is no longer
3907 * admitted. PE needs to downgrade the EDCA
3908 * parameters(for the AC for which TS is being deleted) to the
3909 * next best AC for which ACM is not enabled, and send the
3910 * updated values to HAL.
3911 */
3912 ac = upToAc(pTsinfo->traffic.userPrio);
3913
3914 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3915 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3916 ~(1 << ac);
3917 } else if (pTsinfo->traffic.direction ==
3918 SIR_MAC_DIRECTION_DNLINK) {
3919 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3920 ~(1 << ac);
3921 } else if (pTsinfo->traffic.direction ==
3922 SIR_MAC_DIRECTION_BIDIR) {
3923 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3924 ~(1 << ac);
3925 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3926 ~(1 << ac);
3927 }
3928
3929 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3930 psessionEntry);
3931
3932 pStaDs =
3933 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3934 &psessionEntry->dph.dphHashTable);
3935 if (pStaDs != NULL) {
3936 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3937 pStaDs->bssId);
3938 status = eSIR_SUCCESS;
3939 } else {
3940 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3941 status = eSIR_FAILURE;
3942 }
3943#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945#endif
3946
3947 /* send an sme response back */
3948end:
3949 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3950 smesessionId, smetransactionId);
3951}
3952
3953void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3954{
3955 /* fetch the sessionEntry based on the sessionId */
3956 tpPESession psessionEntry;
3957 psessionEntry = pe_find_session_by_session_id(pMac,
3958 pMac->lim.limTimers.gLimAddtsRspTimer.
3959 sessionId);
3960 if (psessionEntry == NULL) {
3961 lim_log(pMac, LOGP,
3962 FL("Session Does not exist for given sessionID"));
3963 return;
3964 }
3965
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003966 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3968 GET_LIM_SYSTEM_ROLE(psessionEntry));
3969 pMac->lim.gLimAddtsSent = false;
3970 return;
3971 }
3972
3973 if (!pMac->lim.gLimAddtsSent) {
3974 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3975 return;
3976 }
3977
3978 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3979 lim_log(pMac, LOGE,
3980 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3981 pMac->lim.gLimAddtsRspTimerCount);
3982 return;
3983 }
3984 /* this a real response timeout */
3985 pMac->lim.gLimAddtsSent = false;
3986 pMac->lim.gLimAddtsRspTimerCount++;
3987
3988 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3989 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3990 psessionEntry->smeSessionId,
3991 psessionEntry->transactionId);
3992}
3993
3994/**
3995 * __lim_process_sme_get_statistics_request()
3996 *
3997 ***FUNCTION:
3998 *
3999 *
4000 ***NOTE:
4001 *
4002 * @param pMac Pointer to Global MAC structure
4003 * @param *pMsgBuf A pointer to the SME message buffer
4004 * @return None
4005 */
4006static void
4007__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4008{
4009 tpAniGetPEStatsReq pPEStatsReq;
4010 tSirMsgQ msgQ;
4011
4012 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4013
4014 msgQ.type = WMA_GET_STATISTICS_REQ;
4015
4016 msgQ.reserved = 0;
4017 msgQ.bodyptr = pMsgBuf;
4018 msgQ.bodyval = 0;
4019 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4020
4021 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304022 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 pMsgBuf = NULL;
4024 lim_log(pMac, LOGP, "Unable to forward request");
4025 return;
4026 }
4027
4028 return;
4029}
4030
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004031#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004033 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004035 * @pMac: Pointer to Global MAC structure
4036 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004038 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 */
4040static void
4041__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4042{
4043 tSirMsgQ msgQ;
4044
4045 msgQ.type = WMA_TSM_STATS_REQ;
4046 msgQ.reserved = 0;
4047 msgQ.bodyptr = pMsgBuf;
4048 msgQ.bodyval = 0;
4049 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4050
4051 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304052 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053 pMsgBuf = NULL;
4054 lim_log(pMac, LOGP, "Unable to forward request");
4055 return;
4056 }
4057}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004058#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059
4060static void
4061__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4062{
4063 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4064 tpPESession psessionEntry;
4065 uint8_t sessionId; /* PE sessionID */
4066
4067 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4068
4069 if (pMsgBuf == NULL) {
4070 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4071 return;
4072 }
4073
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304074 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 if (NULL == pUpdateAPWPSIEsReq) {
4076 lim_log(pMac, LOGP,
4077 FL
4078 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4079 return;
4080 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304081 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 sizeof(struct sSirUpdateAPWPSIEsReq));
4083
4084 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004085 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 &sessionId);
4087 if (psessionEntry == NULL) {
4088 lim_log(pMac, LOGW,
4089 FL("Session does not exist for given BSSID"));
4090 goto end;
4091 }
4092
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304093 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 sizeof(tSirAPWPSIEs));
4095
4096 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4097 lim_send_beacon_ind(pMac, psessionEntry);
4098
4099end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304100 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 return;
4102}
4103
4104void
4105lim_send_vdev_restart(tpAniSirGlobal pMac,
4106 tpPESession psessionEntry, uint8_t sessionId)
4107{
4108 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4109 tSirMsgQ msgQ;
4110 tSirRetStatus retCode = eSIR_SUCCESS;
4111
4112 if (psessionEntry == NULL) {
4113 PELOGE(lim_log
4114 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4115 __LINE__);
4116 )
4117 return;
4118 }
4119
4120 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304121 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 if (NULL == pHalHiddenSsidVdevRestart) {
4123 PELOGE(lim_log
4124 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4125 __func__, __LINE__);
4126 )
4127 return;
4128 }
4129
4130 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4131 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4132
4133 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4134 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4135 msgQ.bodyval = 0;
4136
4137 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4138 if (eSIR_SUCCESS != retCode) {
4139 PELOGE(lim_log
4140 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4141 __LINE__);
4142 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304143 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 }
4145}
4146
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304147/**
4148 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4149 * @mac_ctx: Pointer to Global MAC structure
4150 * @msg_buf: Pointer to SME message buffer
4151 *
4152 * Return: None
4153 */
4154static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4155 uint32_t *msg_buf)
4156{
4157 tpPESession pe_session;
4158 tSirMsgQ wma_msg;
4159 tSirRetStatus status;
4160 tSirRoamOffloadScanReq *req_buffer;
4161 uint16_t local_ie_len;
4162 uint8_t *local_ie_buf;
4163
4164 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4165 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4166 req_buffer->sessionId);
4167
4168 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4169 if (!local_ie_buf) {
4170 lim_log(mac_ctx, LOGE, FL("Mem Alloc failed for local_ie_buf"));
4171 return;
4172 }
4173
4174 local_ie_len = req_buffer->assoc_ie.length;
4175 /* Update ext cap IE if present */
4176 if (local_ie_len &&
4177 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4178 local_ie_buf, &local_ie_len)) {
4179 req_buffer->assoc_ie.length = local_ie_len;
4180 qdf_mem_copy(req_buffer->assoc_ie.addIEdata, local_ie_buf,
4181 local_ie_len);
4182 }
4183 qdf_mem_free(local_ie_buf);
4184
4185 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4186 wma_msg.bodyptr = req_buffer;
4187
4188 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4189 if (eSIR_SUCCESS != status) {
4190 lim_log(mac_ctx, LOGE,
4191 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4192 qdf_mem_free(req_buffer);
4193 }
4194}
4195
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304196/*
4197 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4198 * @mac_ctx: Pointer to global mac context
4199 * @session: Pointer to PE session
4200 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4201 * 1 - Disable broadcast SSID
4202 *
4203 * Return: None
4204 */
4205static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4206 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304208 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4209 if (ssid_hidden != session->ssidHidden)
4210 session->ssidHidden = ssid_hidden;
4211 else {
4212 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304213 return;
4214 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215
4216 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304217 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218
4219 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304220 sch_set_fixed_beacon_fields(mac_ctx, session);
4221 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222
4223 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304224}
4225
4226/**
4227 * __lim_process_sme_session_update - process SME session update msg
4228 *
4229 * @mac_ctx: Pointer to global mac context
4230 * @msg_buf: Pointer to the received message buffer
4231 *
4232 * Return: None
4233 */
4234static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4235 uint32_t *msg_buf)
4236{
4237 struct sir_update_session_param *msg;
4238 tpPESession session;
4239
4240 if (!msg_buf) {
4241 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4242 return;
4243 }
4244
4245 msg = (struct sir_update_session_param *) msg_buf;
4246
4247 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4248 if (!session) {
4249 lim_log(mac_ctx, LOGW,
4250 "Session does not exist for given sessionId %d",
4251 msg->session_id);
4252 return;
4253 }
4254
4255 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4256 msg->param_type, msg->param_val);
4257 switch (msg->param_type) {
4258 case SIR_PARAM_SSID_HIDDEN:
4259 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4260 break;
4261 default:
4262 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4263 break;
4264 }
4265}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266
4267static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4268{
4269 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4270 tpPESession psessionEntry;
4271 uint8_t sessionId; /* PE sessionID */
4272
4273 if (pMsgBuf == NULL) {
4274 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4275 return;
4276 }
4277
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304278 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 if (NULL == pUpdateAPWPARSNIEsReq) {
4280 lim_log(pMac, LOGP,
4281 FL
4282 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4283 return;
4284 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304285 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4287
4288 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004289 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290 &sessionId);
4291 if (psessionEntry == NULL) {
4292 lim_log(pMac, LOGW,
4293 FL("Session does not exist for given BSSID"));
4294 goto end;
4295 }
4296
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304297 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4299
4300 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4301 &psessionEntry->
4302 pLimStartBssReq->rsnIE,
4303 psessionEntry);
4304
4305 psessionEntry->pLimStartBssReq->privacy = 1;
4306 psessionEntry->privacy = 1;
4307
4308 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4309 lim_send_beacon_ind(pMac, psessionEntry);
4310
4311end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304312 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 return;
4314} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4315
4316/*
4317 Update the beacon Interval dynamically if beaconInterval is different in MCC
4318 */
4319static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4320{
4321 tpSirChangeBIParams pChangeBIParams;
4322 tpPESession psessionEntry;
4323 uint8_t sessionId = 0;
4324 tUpdateBeaconParams beaconParams;
4325
4326 PELOG1(lim_log(pMac, LOG1,
4327 FL("received Update Beacon Interval message"));
4328 );
4329
4330 if (pMsgBuf == NULL) {
4331 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4332 return;
4333 }
4334
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304335 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4337
4338 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004339 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004340 &sessionId);
4341 if (psessionEntry == NULL) {
4342 lim_log(pMac, LOGE,
4343 FL("Session does not exist for given BSSID"));
4344 return;
4345 }
4346
4347 /*Update sessionEntry Beacon Interval */
4348 if (psessionEntry->beaconParams.beaconInterval !=
4349 pChangeBIParams->beaconInterval) {
4350 psessionEntry->beaconParams.beaconInterval =
4351 pChangeBIParams->beaconInterval;
4352 }
4353
4354 /*Update sch beaconInterval */
4355 if (pMac->sch.schObject.gSchBeaconInterval !=
4356 pChangeBIParams->beaconInterval) {
4357 pMac->sch.schObject.gSchBeaconInterval =
4358 pChangeBIParams->beaconInterval;
4359
4360 PELOG1(lim_log(pMac, LOG1,
4361 FL
4362 ("LIM send update BeaconInterval Indication : %d"),
4363 pChangeBIParams->beaconInterval);
4364 );
4365
4366 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4367 /* Update beacon */
4368 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4369
4370 beaconParams.bssIdx = psessionEntry->bssIdx;
4371 /* Set change in beacon Interval */
4372 beaconParams.beaconInterval =
4373 pChangeBIParams->beaconInterval;
4374 beaconParams.paramChangeBitmap =
4375 PARAM_BCN_INTERVAL_CHANGED;
4376 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4377 }
4378 }
4379
4380 return;
4381} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4382
4383#ifdef QCA_HT_2040_COEX
4384static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4385 uint32_t *pMsgBuf)
4386{
4387 tpSirSetHT2040Mode pSetHT2040Mode;
4388 tpPESession psessionEntry;
4389 uint8_t sessionId = 0;
4390 cds_msg_t msg;
4391 tUpdateVHTOpMode *pHtOpMode = NULL;
4392 uint16_t staId = 0;
4393 tpDphHashNode pStaDs = NULL;
4394
4395 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4396 if (pMsgBuf == NULL) {
4397 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4398 return;
4399 }
4400
4401 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4402
4403 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004404 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405 &sessionId);
4406 if (psessionEntry == NULL) {
4407 lim_log(pMac, LOG1,
4408 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004409 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 return;
4411 }
4412
4413 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4414 pSetHT2040Mode->cbMode);
4415 /*Update sessionEntry HT related fields */
4416 switch (pSetHT2040Mode->cbMode) {
4417 case PHY_SINGLE_CHANNEL_CENTERED:
4418 psessionEntry->htSecondaryChannelOffset =
4419 PHY_SINGLE_CHANNEL_CENTERED;
4420 psessionEntry->htRecommendedTxWidthSet = 0;
4421 if (pSetHT2040Mode->obssEnabled)
4422 psessionEntry->htSupportedChannelWidthSet
4423 = eHT_CHANNEL_WIDTH_40MHZ;
4424 else
4425 psessionEntry->htSupportedChannelWidthSet
4426 = eHT_CHANNEL_WIDTH_20MHZ;
4427 break;
4428 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4429 psessionEntry->htSecondaryChannelOffset =
4430 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4431 psessionEntry->htRecommendedTxWidthSet = 1;
4432 break;
4433 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4434 psessionEntry->htSecondaryChannelOffset =
4435 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4436 psessionEntry->htRecommendedTxWidthSet = 1;
4437 break;
4438 default:
4439 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4440 return;
4441 }
4442
4443 /* Update beacon */
4444 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4445 lim_send_beacon_ind(pMac, psessionEntry);
4446
4447 /* update OP Mode for each associated peer */
4448 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4449 pStaDs = dph_get_hash_entry(pMac, staId,
4450 &psessionEntry->dph.dphHashTable);
4451 if (NULL == pStaDs)
4452 continue;
4453
4454 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304455 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456 if (NULL == pHtOpMode) {
4457 lim_log(pMac, LOGE,
4458 FL
4459 ("%s: Not able to allocate memory for setting OP mode"),
4460 __func__);
4461 return;
4462 }
4463 pHtOpMode->opMode =
4464 (psessionEntry->htSecondaryChannelOffset ==
4465 PHY_SINGLE_CHANNEL_CENTERED) ?
4466 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4467 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304468 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 sizeof(tSirMacAddr));
4470 pHtOpMode->smesessionId = sessionId;
4471
4472 msg.type = WMA_UPDATE_OP_MODE;
4473 msg.reserved = 0;
4474 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304475 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304476 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 lim_log(pMac, LOGE,
4478 FL
4479 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4480 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304481 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 return;
4483 }
4484 lim_log(pMac, LOG1,
4485 FL
4486 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4487 __func__, pHtOpMode->opMode, staId);
4488
4489 } else
4490 lim_log(pMac, LOG1,
4491 FL("%s: station %d does not support HT40\n"),
4492 __func__, staId);
4493 }
4494
4495 return;
4496}
4497#endif
4498
4499/* -------------------------------------------------------------------- */
4500/**
4501 * __lim_process_report_message
4502 *
4503 * FUNCTION: Processes the next received Radio Resource Management message
4504 *
4505 * LOGIC:
4506 *
4507 * ASSUMPTIONS:
4508 *
4509 * NOTE:
4510 *
4511 * @param None
4512 * @return None
4513 */
4514
4515void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4516{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517 switch (pMsg->type) {
4518 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4519 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4520 break;
4521 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004523 break;
4524 default:
4525 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004526 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527}
4528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529/* -------------------------------------------------------------------- */
4530/**
4531 * lim_send_set_max_tx_power_req
4532 *
4533 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4534 *
4535 * LOGIC:
4536 *
4537 * ASSUMPTIONS:
4538 *
4539 * NOTE:
4540 *
4541 * @param txPower txPower to be set.
4542 * @param pSessionEntry session entry.
4543 * @return None
4544 */
4545tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004546lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547 tpPESession pSessionEntry)
4548{
4549 tpMaxTxPowerParams pMaxTxParams = NULL;
4550 tSirRetStatus retCode = eSIR_SUCCESS;
4551 tSirMsgQ msgQ;
4552
4553 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304554 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 return eSIR_FAILURE;
4556 }
4557
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304558 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559 if (NULL == pMaxTxParams) {
4560 lim_log(pMac, LOGP,
4561 FL("Unable to allocate memory for pMaxTxParams "));
4562 return eSIR_MEM_ALLOC_FAILED;
4563
4564 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304566 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304567 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304568 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004569 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304570 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571
4572 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4573 msgQ.bodyptr = pMaxTxParams;
4574 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304575 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4577 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4578 if (eSIR_SUCCESS != retCode) {
4579 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304580 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 }
4582 return retCode;
4583}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584
4585/**
4586 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4587 *
4588 * @mac_ctx: Pointer to Global MAC structure
4589 * @msg_buf: pointer to the SME message buffer
4590 *
4591 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4592 * from SME. It Register this information within PE.
4593 *
4594 * Return: None
4595 */
4596static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4597 uint32_t *msg_buf)
4598{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304599 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4601 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4602 struct mgmt_frm_reg_info *next = NULL;
4603 bool match = false;
4604
4605 lim_log(mac_ctx, LOG1, FL(
4606 "registerFrame %d, frameType %d, matchLen %d"),
4607 sme_req->registerFrame, sme_req->frameType,
4608 sme_req->matchLen);
4609 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304610 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304611 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4612 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304613 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614
4615 while (lim_mgmt_regn != NULL) {
4616 if (lim_mgmt_regn->frameType != sme_req->frameType)
4617 goto skip_match;
4618 if (sme_req->matchLen) {
4619 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304620 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 sme_req->matchData,
4622 lim_mgmt_regn->matchLen))) {
4623 /* found match! */
4624 match = true;
4625 break;
4626 }
4627 } else {
4628 /* found match! */
4629 match = true;
4630 break;
4631 }
4632skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304633 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304634 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304636 (qdf_list_node_t *)lim_mgmt_regn,
4637 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304638 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 lim_mgmt_regn = next;
4640 next = NULL;
4641 }
4642 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304643 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304644 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304646 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304647 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304648 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 }
4650
4651 if (sme_req->registerFrame) {
4652 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304653 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 sme_req->matchLen);
4655 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304656 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 sizeof(struct mgmt_frm_reg_info) +
4658 sme_req->matchLen, 0);
4659 lim_mgmt_regn->frameType = sme_req->frameType;
4660 lim_mgmt_regn->matchLen = sme_req->matchLen;
4661 lim_mgmt_regn->sessionId = sme_req->sessionId;
4662 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304663 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 sme_req->matchData,
4665 sme_req->matchLen);
4666 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304667 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304669 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 gLimMgmtFrameRegistratinQueue,
4671 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304672 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673 &mac_ctx->lim.lim_frame_register_lock);
4674 }
4675 }
4676 return;
4677}
4678
4679static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4680{
4681 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4682 pMac->lim.gDeferMsgTypeForNOA);
4683 pMac->lim.gDeferMsgTypeForNOA = 0;
4684 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4685 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304686 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4688 }
4689}
4690
4691/**
4692 * lim_process_regd_defd_sme_req_after_noa_start()
4693 *
4694 * mac_ctx: Pointer to Global MAC structure
4695 *
4696 * This function is called to process deferred sme req message
4697 * after noa start.
4698 *
4699 * Return: None
4700 */
4701void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4702{
4703 bool buf_consumed = true;
4704
4705 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4706 mac_ctx->lim.gDeferMsgTypeForNOA);
4707
4708 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4709 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4710 lim_log(mac_ctx, LOGW,
4711 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4712 lim_log(mac_ctx, LOGW,
4713 FL("It may happen when NOA start ind and timeout happen at the same time"));
4714 return;
4715 }
4716 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4717 case eWNI_SME_SCAN_REQ:
4718 __lim_process_sme_scan_req(mac_ctx,
4719 mac_ctx->lim.gpDefdSmeMsgForNOA);
4720 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4722 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4723 mac_ctx->lim.gpDefdSmeMsgForNOA);
4724 /*
4725 * lim_process_remain_on_chnl_req doesnt want us to free
4726 * the buffer since it is freed in lim_remain_on_chn_rsp.
4727 * this change is to avoid "double free"
4728 */
4729 if (false == buf_consumed)
4730 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4731 break;
4732 case eWNI_SME_JOIN_REQ:
4733 __lim_process_sme_join_req(mac_ctx,
4734 mac_ctx->lim.gpDefdSmeMsgForNOA);
4735 break;
4736 default:
4737 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4738 mac_ctx->lim.gDeferMsgTypeForNOA);
4739 break;
4740 }
4741 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4742}
4743
4744static void
4745__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4746{
4747 tpSirResetAPCapsChange pResetCapsChange;
4748 tpPESession psessionEntry;
4749 uint8_t sessionId = 0;
4750 if (pMsgBuf == NULL) {
4751 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4752 return;
4753 }
4754
4755 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4756 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004757 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4758 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 if (psessionEntry == NULL) {
4760 lim_log(pMac, LOGE,
4761 FL("Session does not exist for given BSSID"));
4762 return;
4763 }
4764
4765 psessionEntry->limSentCapsChangeNtf = false;
4766 return;
4767}
4768
4769/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304770 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4771 * @mac_ctx: Mac pointer
4772 * @msg_buf: Msg pointer containing the callback
4773 *
4774 * This function is used to save the p2p ack indication callback in PE.
4775 *
4776 * Return: None
4777 */
4778static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4779 uint32_t *msg_buf)
4780{
4781 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4782 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4783
4784 if (NULL == msg_buf) {
4785 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4786 return;
4787 }
4788 if (sme_req->callback)
4789 mac_ctx->p2p_ack_ind_cb =
4790 sme_req->callback;
4791 else
4792 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4793}
4794
4795/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304796 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4797 * indication callback in PE.
4798 * @mac_ptr: Mac pointer
4799 * @msg_buf: Msg pointer containing the callback
4800 *
4801 * This function is used save the Management frame
4802 * indication callback in PE.
4803 *
4804 * Return: None
4805 */
4806static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4807 uint32_t *msg_buf)
4808{
4809 struct sir_sme_mgmt_frame_cb_req *sme_req =
4810 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4811
4812 if (NULL == msg_buf) {
4813 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4814 return;
4815 }
4816 if (sme_req->callback)
4817 mac_ctx->mgmt_frame_ind_cb =
4818 (sir_mgmt_frame_ind_callback)sme_req->callback;
4819 else
4820 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4821}
4822
4823/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304824 *__lim_process_send_disassoc_frame: function processes disassoc frame
4825 * @mac_ctx: pointer to mac context
4826 * @msg_buf: message buffer
4827 *
4828 * function processes disassoc request received from SME
4829 *
4830 * return: none
4831 */
4832static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4833 uint32_t *msg_buf)
4834{
4835 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4836 tSirRetStatus status;
4837 tpPESession session_entry = NULL;
4838 uint8_t sme_session_id;
4839 uint16_t sme_trans_id;
4840
4841 if (msg_buf == NULL) {
4842 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4843 return;
4844 }
4845
4846 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4847 &sme_trans_id);
4848
4849 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4850 &sme_send_disassoc_frame_req,
4851 (uint8_t *)msg_buf);
4852
4853 if ((eSIR_FAILURE == status) ||
4854 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4855 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4856 PELOGE(lim_log(mac_ctx, LOGE,
4857 FL("received invalid SME_DISASSOC_REQ message"));)
4858 return;
4859 }
4860
4861 session_entry = pe_find_session_by_sme_session_id(
4862 mac_ctx, sme_session_id);
4863 if (session_entry == NULL) {
4864 lim_log(mac_ctx, LOGE,
4865 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4866 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4867 return;
4868 }
4869
4870 lim_log(mac_ctx, LOG1,
4871 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4872 sme_send_disassoc_frame_req.msg_type,
4873 sme_send_disassoc_frame_req.length,
4874 sme_send_disassoc_frame_req.session_id,
4875 sme_send_disassoc_frame_req.trans_id,
4876 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4877 sme_send_disassoc_frame_req.reason,
4878 sme_send_disassoc_frame_req.wait_for_ack);
4879
4880 lim_send_disassoc_mgmt_frame(mac_ctx,
4881 sme_send_disassoc_frame_req.reason,
4882 sme_send_disassoc_frame_req.peer_mac,
4883 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4884}
4885
4886/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004887 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4888 * @mac_ctx: Pointer to Global MAC structure
4889 * @pdev_id: pdev id to set the IE.
4890 * @nss: Nss values to prepare the HT IE.
4891 *
4892 * Prepares the HT IE with self capabilities for different
4893 * Nss values and sends the set HT IE req to FW.
4894 *
4895 * Return: None
4896 */
4897static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4898 uint8_t nss)
4899{
4900 struct set_ie_param *ie_params;
4901 tSirMsgQ msg;
4902 tSirRetStatus rc = eSIR_SUCCESS;
4903 uint8_t *p_ie = NULL;
4904 tHtCaps *p_ht_cap;
4905 int i;
4906
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004907 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004908 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4909 if (NULL == ie_params) {
4910 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4911 return;
4912 }
4913 ie_params->nss = i;
4914 ie_params->pdev_id = pdev_id;
4915 ie_params->ie_type = DOT11_HT_IE;
4916 /* 2 for IE len and EID */
4917 ie_params->ie_len = 2 + sizeof(tHtCaps);
4918 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4919 if (NULL == ie_params->ie_ptr) {
4920 qdf_mem_free(ie_params);
4921 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4922 return;
4923 }
4924 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4925 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4926 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4927 ie_params->ie_len);
4928
4929 if (NSS_1x1_MODE == i) {
4930 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4931 ie_params->ie_len,
4932 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004933 if (NULL == p_ie) {
4934 qdf_mem_free(ie_params->ie_ptr);
4935 qdf_mem_free(ie_params);
4936 lim_log(mac_ctx, LOGE,
4937 FL("failed to get IE ptr"));
4938 return;
4939 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004940 p_ht_cap = (tHtCaps *)&p_ie[2];
4941 p_ht_cap->supportedMCSSet[1] = 0;
4942 p_ht_cap->txSTBC = 0;
4943 }
4944
4945 msg.type = WMA_SET_PDEV_IE_REQ;
4946 msg.bodyptr = ie_params;
4947 msg.bodyval = 0;
4948
4949 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4950 if (rc != eSIR_SUCCESS) {
4951 lim_log(mac_ctx, LOGE,
4952 FL("wma_post_ctrl_msg() return failure"));
4953 qdf_mem_free(ie_params->ie_ptr);
4954 qdf_mem_free(ie_params);
4955 return;
4956 }
4957 }
4958}
4959
4960/**
4961 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4962 * @mac_ctx: Pointer to Global MAC structure
4963 * @pdev_id: pdev id to set the IE.
4964 * @nss: Nss values to prepare the VHT IE.
4965 *
4966 * Prepares the VHT IE with self capabilities for different
4967 * Nss values and sends the set VHT IE req to FW.
4968 *
4969 * Return: None
4970 */
4971static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4972 uint8_t nss)
4973{
4974 struct set_ie_param *ie_params;
4975 tSirMsgQ msg;
4976 tSirRetStatus rc = eSIR_SUCCESS;
4977 uint8_t *p_ie = NULL;
4978 tSirMacVHTCapabilityInfo *vht_cap;
4979 int i;
4980 tSirVhtMcsInfo *vht_mcs;
4981
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004982 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004983 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4984 if (NULL == ie_params) {
4985 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4986 return;
4987 }
4988 ie_params->nss = i;
4989 ie_params->pdev_id = pdev_id;
4990 ie_params->ie_type = DOT11_VHT_IE;
4991 /* 2 for IE len and EID */
4992 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4993 sizeof(tSirVhtMcsInfo);
4994 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4995 if (NULL == ie_params->ie_ptr) {
4996 qdf_mem_free(ie_params);
4997 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4998 return;
4999 }
5000 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
5001 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
5002 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
5003 ie_params->ie_len);
5004
5005 if (NSS_1x1_MODE == i) {
5006 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
5007 ie_params->ie_len,
5008 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07005009 if (NULL == p_ie) {
5010 qdf_mem_free(ie_params->ie_ptr);
5011 qdf_mem_free(ie_params);
5012 lim_log(mac_ctx, LOGE,
5013 FL("failed to get IE ptr"));
5014 return;
5015 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005016 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
5017 vht_cap->txSTBC = 0;
5018 vht_mcs =
5019 (tSirVhtMcsInfo *)&p_ie[2 +
5020 sizeof(tSirMacVHTCapabilityInfo)];
5021 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5022 vht_mcs->rxHighest =
5023 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5024 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5025 vht_mcs->txHighest =
5026 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5027 }
5028 msg.type = WMA_SET_PDEV_IE_REQ;
5029 msg.bodyptr = ie_params;
5030 msg.bodyval = 0;
5031
5032 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5033 if (rc != eSIR_SUCCESS) {
5034 lim_log(mac_ctx, LOGE,
5035 FL("wma_post_ctrl_msg failure"));
5036 qdf_mem_free(ie_params->ie_ptr);
5037 qdf_mem_free(ie_params);
5038 return;
5039 }
5040 }
5041}
5042
5043/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005044 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5045 * @mac_ctx: Pointer to Global MAC structure
5046 * @msg_buf: Pointer to the SME message buffer
5047 *
5048 * This function is called by limProcessMessageQueue(). This function sets the
5049 * VDEV IEs to the FW.
5050 *
5051 * Return: None
5052 */
5053static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5054 uint32_t *msg_buf)
5055{
5056 struct sir_set_vdev_ies_per_band *p_msg =
5057 (struct sir_set_vdev_ies_per_band *)msg_buf;
5058
5059 if (NULL == p_msg) {
5060 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5061 return;
5062 }
5063
5064 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5065 p_msg->vdev_id);
5066 /* intentionally using NULL here so that self capabilty are sent */
5067 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5068 QDF_STATUS_SUCCESS)
5069 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5070}
5071
5072/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005073 * lim_process_set_pdev_IEs() - process the set pdev IE req
5074 * @mac_ctx: Pointer to Global MAC structure
5075 * @msg_buf: Pointer to the SME message buffer
5076 *
5077 * This function is called by limProcessMessageQueue(). This
5078 * function sets the PDEV IEs to the FW.
5079 *
5080 * Return: None
5081 */
5082static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5083{
5084 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5085
5086 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5087
5088 if (NULL == ht_vht_cfg) {
5089 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5090 return;
5091 }
5092
5093 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5094 ht_vht_cfg->nss);
5095 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5096
5097 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5098 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5099 ht_vht_cfg->nss);
5100}
5101
5102/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305103 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5104 *
5105 * access policy
5106 * @mac_ctx: pointer to mac context
5107 * @msg: message buffer
5108 *
5109 * function processes vendor IE and access policy from SME and updates PE
5110 *
5111 * session entry
5112 *
5113 * return: none
5114*/
5115static void lim_process_sme_update_access_policy_vendor_ie(
5116 tpAniSirGlobal mac_ctx,
5117 uint32_t *msg)
5118{
5119 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5120 struct sPESession *pe_session_entry;
5121 uint8_t num_bytes;
5122
5123 if (!msg) {
5124 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5125 return;
5126 }
5127 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5128 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5129 update_vendor_ie->sme_session_id);
5130
5131 if (!pe_session_entry) {
5132 lim_log(mac_ctx, LOGE,
5133 FL("Session does not exist for given sme session id(%hu)"),
5134 update_vendor_ie->sme_session_id);
5135 return;
5136 }
5137 if (pe_session_entry->access_policy_vendor_ie)
5138 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5139
5140 num_bytes = update_vendor_ie->ie[1] + 2;
5141 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5142
5143 if (!pe_session_entry->access_policy_vendor_ie) {
5144 lim_log(mac_ctx, LOGE,
5145 FL("Failed to allocate memory for vendor ie"));
5146 return;
5147 }
5148 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5149 &update_vendor_ie->ie[0], num_bytes);
5150
5151 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5152}
5153
5154/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155 * lim_process_sme_req_messages()
5156 *
5157 ***FUNCTION:
5158 * This function is called by limProcessMessageQueue(). This
5159 * function processes SME request messages from HDD or upper layer
5160 * application.
5161 *
5162 ***LOGIC:
5163 *
5164 ***ASSUMPTIONS:
5165 *
5166 ***NOTE:
5167 *
5168 * @param pMac Pointer to Global MAC structure
5169 * @param msgType Indicates the SME message type
5170 * @param *pMsgBuf A pointer to the SME message buffer
5171 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5172 * false - if pMsgBuf is not to be freed.
5173 */
5174
5175bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5176{
5177 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5178 uint32_t *pMsgBuf = pMsg->bodyptr;
5179 tpSirSmeScanReq pScanReq;
5180 PELOG1(lim_log
5181 (pMac, LOG1,
5182 FL
5183 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5184 lim_msg_str(pMsg->type), pMsg->type,
5185 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5186 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5187 )
5188
5189 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5190 /* If no insert NOA required then execute the code below */
5191
5192 switch (pMsg->type) {
5193 case eWNI_SME_SYS_READY_IND:
5194 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5195 break;
5196
5197 case eWNI_SME_START_BSS_REQ:
5198 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5199 break;
5200
5201 case eWNI_SME_SCAN_REQ:
5202 __lim_process_sme_scan_req(pMac, pMsgBuf);
5203 break;
5204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5206 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5207 break;
5208
5209 case eWNI_SME_UPDATE_NOA:
5210 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5211 break;
5212 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5213 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5214 break;
5215 case eWNI_SME_JOIN_REQ:
5216 __lim_process_sme_join_req(pMac, pMsgBuf);
5217 break;
5218
5219 case eWNI_SME_REASSOC_REQ:
5220 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5221 break;
5222
5223 case eWNI_SME_DISASSOC_REQ:
5224 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5225 break;
5226
5227 case eWNI_SME_DISASSOC_CNF:
5228 case eWNI_SME_DEAUTH_CNF:
5229 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5230 break;
5231
5232 case eWNI_SME_DEAUTH_REQ:
5233 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5234 break;
5235
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305236 case eWNI_SME_SEND_DISASSOC_FRAME:
5237 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5238 break;
5239
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005240 case eWNI_SME_SETCONTEXT_REQ:
5241 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5242 break;
5243
5244 case eWNI_SME_STOP_BSS_REQ:
5245 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5246 break;
5247
5248 case eWNI_SME_ASSOC_CNF:
5249 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5250 PELOG1(lim_log(pMac,
5251 LOG1, FL("Received ASSOC_CNF message"));)
5252 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5253 pMsgBuf);
5254 break;
5255
5256 case eWNI_SME_ADDTS_REQ:
5257 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5258 __lim_process_sme_addts_req(pMac, pMsgBuf);
5259 break;
5260
5261 case eWNI_SME_DELTS_REQ:
5262 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5263 __lim_process_sme_delts_req(pMac, pMsgBuf);
5264 break;
5265
5266 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5267 PELOG1(lim_log
5268 (pMac, LOG1,
5269 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5270 )
5271 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5272 break;
5273
5274 case eWNI_SME_GET_STATISTICS_REQ:
5275 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5276 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5277 bufConsumed = false;
5278 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005279#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 case eWNI_SME_GET_TSM_STATS_REQ:
5281 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5282 bufConsumed = false;
5283 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005284#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005285 case eWNI_SME_GET_ASSOC_STAS_REQ:
5286 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5287 break;
5288 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5289 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5290 break;
5291
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305292 case eWNI_SME_SESSION_UPDATE_PARAM:
5293 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305295 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5296 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5297 bufConsumed = false;
5298 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 case eWNI_SME_UPDATE_APWPSIE_REQ:
5300 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5301 break;
5302 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5303 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5304 break;
5305
5306 case eWNI_SME_SET_APWPARSNIEs_REQ:
5307 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5308 break;
5309
5310 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5311 /* Update the beaconInterval */
5312 __lim_process_sme_change_bi(pMac, pMsgBuf);
5313 break;
5314
5315#ifdef QCA_HT_2040_COEX
5316 case eWNI_SME_SET_HT_2040_MODE:
5317 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5318 break;
5319#endif
5320
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5322 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5323 __lim_process_report_message(pMac, pMsg);
5324 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005325
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 case eWNI_SME_FT_PRE_AUTH_REQ:
5327 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5328 break;
5329 case eWNI_SME_FT_UPDATE_KEY:
5330 lim_process_ft_update_key(pMac, pMsgBuf);
5331 break;
5332
5333 case eWNI_SME_FT_AGGR_QOS_REQ:
5334 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5335 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336
5337 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5338 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5339 break;
5340#ifdef FEATURE_WLAN_TDLS
5341 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5342 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5343 break;
5344 case eWNI_SME_TDLS_ADD_STA_REQ:
5345 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5346 break;
5347 case eWNI_SME_TDLS_DEL_STA_REQ:
5348 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5349 break;
5350 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5351 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5352 break;
5353#endif
5354 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5355 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5356 break;
5357
5358 case eWNI_SME_CHANNEL_CHANGE_REQ:
5359 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5360 break;
5361
5362 case eWNI_SME_START_BEACON_REQ:
5363 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5364 break;
5365
5366 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5367 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5368 break;
5369
5370 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5371 lim_process_update_add_ies(pMac, pMsgBuf);
5372 break;
5373
5374 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5375 lim_process_modify_add_ies(pMac, pMsgBuf);
5376 break;
5377 case eWNI_SME_SET_HW_MODE_REQ:
5378 lim_process_set_hw_mode(pMac, pMsgBuf);
5379 break;
5380 case eWNI_SME_NSS_UPDATE_REQ:
5381 lim_process_nss_update_request(pMac, pMsgBuf);
5382 break;
5383 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5384 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5385 break;
5386 case eWNI_SME_SET_IE_REQ:
5387 lim_process_set_ie_req(pMac, pMsgBuf);
5388 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305389 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5390 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5391 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305392 case eWNI_SME_EXT_CHANGE_CHANNEL:
5393 lim_process_ext_change_channel(pMac, pMsgBuf);
5394 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005395 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5396 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5397 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005398 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5399 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005400 break;
5401 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5402 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5403 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005404 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005405 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005406 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005407 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005408 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305409 case eWNI_SME_REGISTER_P2P_ACK_CB:
5410 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5411 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305412 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5413 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5414 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005415 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305416 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417 pMsg->bodyptr = NULL;
5418 break;
5419 } /* switch (msgType) */
5420
5421 return bufConsumed;
5422} /*** end lim_process_sme_req_messages() ***/
5423
5424/**
5425 * lim_process_sme_start_beacon_req()
5426 *
5427 ***FUNCTION:
5428 * This function is called by limProcessMessageQueue(). This
5429 * function processes SME request messages from HDD or upper layer
5430 * application.
5431 *
5432 ***LOGIC:
5433 *
5434 ***ASSUMPTIONS:
5435 *
5436 ***NOTE:
5437 *
5438 * @param pMac Pointer to Global MAC structure
5439 * @param msgType Indicates the SME message type
5440 * @param *pMsgBuf A pointer to the SME message buffer
5441 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5442 * false - if pMsgBuf is not to be freed.
5443 */
5444static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5445{
5446 tpSirStartBeaconIndication pBeaconStartInd;
5447 tpPESession psessionEntry;
5448 uint8_t sessionId; /* PE sessionID */
5449
5450 if (pMsg == NULL) {
5451 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5452 return;
5453 }
5454
5455 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5456 psessionEntry = pe_find_session_by_bssid(pMac,
5457 pBeaconStartInd->bssid,
5458 &sessionId);
5459 if (psessionEntry == NULL) {
5460 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5461 lim_log(pMac, LOGE,
5462 FL("Session does not exist for given bssId"));
5463 return;
5464 }
5465
5466 if (pBeaconStartInd->beaconStartStatus == true) {
5467 /*
5468 * Currently this Indication comes from SAP
5469 * to start Beacon Tx on a DFS channel
5470 * since beaconing has to be done on DFS
5471 * channel only after CAC WAIT is completed.
5472 * On a DFS Channel LIM does not start beacon
5473 * Tx right after the WMA_ADD_BSS_RSP.
5474 */
5475 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305476 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477 FL("Start Beacon with ssid %s Ch %d"),
5478 psessionEntry->ssId.ssId,
5479 psessionEntry->currentOperChannel);
5480 lim_send_beacon_ind(pMac, psessionEntry);
5481 } else {
5482 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5483 return;
5484 }
5485}
5486
5487/**
5488 * lim_process_sme_channel_change_request() - process sme ch change req
5489 *
5490 * @mac_ctx: Pointer to Global MAC structure
5491 * @msg_buf: pointer to the SME message buffer
5492 *
5493 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5494 *
5495 * Return: None
5496 */
5497static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5498 uint32_t *msg_buf)
5499{
5500 tpSirChanChangeRequest ch_change_req;
5501 tpPESession session_entry;
5502 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005503 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504 uint32_t val = 0;
5505
5506 if (msg_buf == NULL) {
5507 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5508 return;
5509 }
5510 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5511
5512 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5513 ch_change_req->targetChannel);
5514
5515 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5516 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5517 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5518 return;
5519 }
5520
5521 session_entry = pe_find_session_by_bssid(mac_ctx,
5522 ch_change_req->bssid, &session_id);
5523 if (session_entry == NULL) {
5524 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5525 lim_log(mac_ctx, LOGE, FL(
5526 "Session does not exist for given bssId"));
5527 return;
5528 }
5529
5530 if (session_entry->currentOperChannel ==
5531 ch_change_req->targetChannel) {
5532 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5533 return;
5534 }
5535
5536 if (LIM_IS_AP_ROLE(session_entry))
5537 session_entry->channelChangeReasonCode =
5538 LIM_SWITCH_CHANNEL_SAP_DFS;
5539 else
5540 session_entry->channelChangeReasonCode =
5541 LIM_SWITCH_CHANNEL_OPERATION;
5542
5543 lim_log(mac_ctx, LOGW, FL(
5544 "switch old chnl %d to new chnl %d, ch_bw %d"),
5545 session_entry->currentOperChannel,
5546 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005547 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548
5549 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005550 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551 session_entry->ch_center_freq_seg0 =
5552 ch_change_req->center_freq_seg_0;
5553 session_entry->ch_center_freq_seg1 =
5554 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005555 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005557 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 session_entry->htRecommendedTxWidthSet =
5559 session_entry->htSupportedChannelWidthSet;
5560 session_entry->currentOperChannel =
5561 ch_change_req->targetChannel;
5562 session_entry->limRFBand =
5563 lim_get_rf_band(session_entry->currentOperChannel);
5564 /* Initialize 11h Enable Flag */
5565 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5566 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5567 eSIR_SUCCESS)
5568 lim_log(mac_ctx, LOGP,
5569 FL("Fail to get WNI_CFG_11H_ENABLED"));
5570 }
5571
5572 session_entry->lim11hEnable = val;
5573 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305574 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 &ch_change_req->operational_rateset,
5576 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305577 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 &ch_change_req->extended_rateset,
5579 sizeof(session_entry->extRateSet));
5580 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5581 session_entry->ch_center_freq_seg0,
5582 session_entry->ch_center_freq_seg1,
5583 session_entry->ch_width,
5584 max_tx_pwr, session_entry->peSessionId);
5585}
5586
5587/******************************************************************************
5588* lim_start_bss_update_add_ie_buffer()
5589*
5590***FUNCTION:
5591* This function checks the src buffer and its length and then malloc for
5592* dst buffer update the same
5593*
5594***LOGIC:
5595*
5596***ASSUMPTIONS:
5597*
5598***NOTE:
5599*
5600* @param pMac Pointer to Global MAC structure
5601* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5602* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5603* @param *pSrcData_buff A pointer of uint8_t src buffer
5604* @param srcDataLen src buffer length
5605******************************************************************************/
5606
5607static void
5608lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5609 uint8_t **pDstData_buff,
5610 uint16_t *pDstDataLen,
5611 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5612{
5613
5614 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5615 *pDstDataLen = srcDataLen;
5616
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305617 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005618
5619 if (NULL == *pDstData_buff) {
5620 lim_log(pMac, LOGE,
5621 FL("AllocateMemory failed for pDstData_buff"));
5622 return;
5623 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305624 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005625 } else {
5626 *pDstData_buff = NULL;
5627 *pDstDataLen = 0;
5628 }
5629}
5630
5631/******************************************************************************
5632* lim_update_add_ie_buffer()
5633*
5634***FUNCTION:
5635* This function checks the src buffer and length if src buffer length more
5636* than dst buffer length then free the dst buffer and malloc for the new src
5637* length, and update the dst buffer and length. But if dst buffer is bigger
5638* than src buffer length then it just update the dst buffer and length
5639*
5640***LOGIC:
5641*
5642***ASSUMPTIONS:
5643*
5644***NOTE:
5645*
5646* @param pMac Pointer to Global MAC structure
5647* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5648* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5649* @param *pSrcData_buff A pointer of uint8_t src buffer
5650* @param srcDataLen src buffer length
5651******************************************************************************/
5652
5653static void
5654lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5655 uint8_t **pDstData_buff,
5656 uint16_t *pDstDataLen,
5657 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5658{
5659
5660 if (NULL == pSrcData_buff) {
5661 lim_log(pMac, LOGE, FL("src buffer is null."));
5662 return;
5663 }
5664
5665 if (srcDataLen > *pDstDataLen) {
5666 *pDstDataLen = srcDataLen;
5667 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305668 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305670 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671
5672 if (NULL == *pDstData_buff) {
5673 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5674 *pDstDataLen = 0;
5675 return;
5676 }
5677 }
5678
5679 /* copy the content of buffer into dst buffer
5680 */
5681 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305682 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683
5684}
5685
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005686/**
5687 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5688 * @pMac : Pointer to Global MAC structure
5689 * @pDstData_buff : A pointer to pointer of dst buffer
5690 * @pDstDataLen : A pointer to pointer of dst buffer length
5691 * @pModifyIE : A pointer to tSirModifyIE
5692 *
5693 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5694 *
5695 * Return:
5696 * True or false depending upon whether IE is updated or not
5697 */
5698static bool
5699lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5700 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5701{
5702 int32_t oui_length;
5703 uint8_t *ibss_ie = NULL;
5704
5705 ibss_ie = pModifyIE->pIEBuffer;
5706 oui_length = pModifyIE->oui_length;
5707
5708 if ((0 == oui_length) || (NULL == ibss_ie)) {
5709 PELOGE(lim_log(pMac, LOGE,
5710 FL("Invalid set IBSS vendor IE command length %d "),
5711 oui_length);)
5712 return false;
5713 }
5714
5715 lim_update_add_ie_buffer(pMac,
5716 pDstData_buff,
5717 pDstDataLen,
5718 pModifyIE->pIEBuffer,
5719 pModifyIE->ieBufferlength);
5720
5721 return true;
5722}
5723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724/*
5725* lim_process_modify_add_ies() - process modify additional IE req.
5726*
5727* @mac_ctx: Pointer to Global MAC structure
5728* @msg_buf: pointer to the SME message buffer
5729*
5730* This function update the PE buffers for additional IEs.
5731*
5732* Return: None
5733*/
5734static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5735 uint32_t *msg_buf)
5736{
5737 tpSirModifyIEsInd modify_add_ies;
5738 tpPESession session_entry;
5739 uint8_t session_id;
5740 bool ret = false;
5741 tSirAddIeParams *add_ie_params;
5742
5743 if (msg_buf == NULL) {
5744 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5745 return;
5746 }
5747
5748 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5749 /* Incoming message has smeSession, use BSSID to find PE session */
5750 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005751 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752
5753 if (NULL == session_entry) {
5754 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5755 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005756 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005757 goto end;
5758 }
5759 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5760 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5761 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5762 lim_log(mac_ctx, LOGE,
5763 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5764 modify_add_ies->modifyIE.pIEBuffer,
5765 modify_add_ies->modifyIE.ieBufferlength,
5766 modify_add_ies->modifyIE.ieID,
5767 modify_add_ies->modifyIE.ieIDLen,
5768 modify_add_ies->updateType);
5769 goto end;
5770 }
5771 add_ie_params = &session_entry->addIeParams;
5772 switch (modify_add_ies->updateType) {
5773 case eUPDATE_IE_PROBE_RESP:
5774 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005775 if (LIM_IS_IBSS_ROLE(session_entry)) {
5776 lim_update_ibss_prop_add_ies(mac_ctx,
5777 &add_ie_params->probeRespData_buff,
5778 &add_ie_params->probeRespDataLen,
5779 &modify_add_ies->modifyIE);
5780 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781 break;
5782 case eUPDATE_IE_ASSOC_RESP:
5783 /* assoc resp IE */
5784 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305785 QDF_TRACE(QDF_MODULE_ID_PE,
5786 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787 "assoc resp add ie not present %d"),
5788 add_ie_params->assocRespDataLen);
5789 }
5790 /* search through the buffer and modify the IE */
5791 break;
5792 case eUPDATE_IE_PROBE_BCN:
5793 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005794 if (LIM_IS_IBSS_ROLE(session_entry)) {
5795 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5796 &add_ie_params->probeRespBCNData_buff,
5797 &add_ie_params->probeRespBCNDataLen,
5798 &modify_add_ies->modifyIE);
5799 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800 if (ret == true && modify_add_ies->modifyIE.notify) {
5801 lim_handle_param_update(mac_ctx,
5802 modify_add_ies->updateType);
5803 }
5804 break;
5805 default:
5806 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5807 modify_add_ies->updateType);
5808 break;
5809 }
5810end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305811 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812 modify_add_ies->modifyIE.pIEBuffer = NULL;
5813}
5814
5815/*
5816* lim_process_update_add_ies() - process additional IE update req
5817*
5818* @mac_ctx: Pointer to Global MAC structure
5819* @msg_buf: pointer to the SME message buffer
5820*
5821* This function update the PE buffers for additional IEs.
5822*
5823* Return: None
5824*/
5825static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5826 uint32_t *msg_buf)
5827{
5828 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5829 uint8_t session_id;
5830 tpPESession session_entry;
5831 tSirAddIeParams *addn_ie;
5832 uint16_t new_length = 0;
5833 uint8_t *new_ptr = NULL;
5834 tSirUpdateIE *update_ie;
5835
5836 if (msg_buf == NULL) {
5837 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5838 return;
5839 }
5840 update_ie = &update_add_ies->updateIE;
5841 /* incoming message has smeSession, use BSSID to find PE session */
5842 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005843 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005844
5845 if (NULL == session_entry) {
5846 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5847 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005848 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 goto end;
5850 }
5851 addn_ie = &session_entry->addIeParams;
5852 /* if len is 0, upper layer requested freeing of buffer */
5853 if (0 == update_ie->ieBufferlength) {
5854 switch (update_add_ies->updateType) {
5855 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305856 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857 addn_ie->probeRespData_buff = NULL;
5858 addn_ie->probeRespDataLen = 0;
5859 break;
5860 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305861 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862 addn_ie->assocRespData_buff = NULL;
5863 addn_ie->assocRespDataLen = 0;
5864 break;
5865 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305866 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 addn_ie->probeRespBCNData_buff = NULL;
5868 addn_ie->probeRespBCNDataLen = 0;
5869
5870 if (update_ie->notify)
5871 lim_handle_param_update(mac_ctx,
5872 update_add_ies->updateType);
5873 break;
5874 default:
5875 break;
5876 }
5877 return;
5878 }
5879 switch (update_add_ies->updateType) {
5880 case eUPDATE_IE_PROBE_RESP:
5881 if (update_ie->append) {
5882 /*
5883 * In case of append, allocate new memory
5884 * with combined length
5885 */
5886 new_length = update_ie->ieBufferlength +
5887 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305888 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 if (NULL == new_ptr) {
5890 lim_log(mac_ctx, LOGE, FL(
5891 "Memory allocation failed."));
5892 goto end;
5893 }
5894 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305895 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005896 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305897 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898 update_ie->pAdditionIEBuffer,
5899 update_ie->ieBufferlength);
5900 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305901 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 /* adjust length accordingly */
5903 addn_ie->probeRespDataLen = new_length;
5904 /* save refernece of local buffer in PE session */
5905 addn_ie->probeRespData_buff = new_ptr;
5906 goto end;
5907 }
5908 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5909 &addn_ie->probeRespDataLen,
5910 update_ie->pAdditionIEBuffer,
5911 update_ie->ieBufferlength);
5912 break;
5913 case eUPDATE_IE_ASSOC_RESP:
5914 /* assoc resp IE */
5915 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5916 &addn_ie->assocRespDataLen,
5917 update_ie->pAdditionIEBuffer,
5918 update_ie->ieBufferlength);
5919 break;
5920 case eUPDATE_IE_PROBE_BCN:
5921 /* probe resp Bcn IE */
5922 lim_update_add_ie_buffer(mac_ctx,
5923 &addn_ie->probeRespBCNData_buff,
5924 &addn_ie->probeRespBCNDataLen,
5925 update_ie->pAdditionIEBuffer,
5926 update_ie->ieBufferlength);
5927 if (update_ie->notify)
5928 lim_handle_param_update(mac_ctx,
5929 update_add_ies->updateType);
5930 break;
5931 default:
5932 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5933 update_add_ies->updateType);
5934 break;
5935 }
5936end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305937 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 update_ie->pAdditionIEBuffer = NULL;
5939}
5940
5941/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305942 * send_extended_chan_switch_action_frame()- function to send ECSA
5943 * action frame for each sta connected to SAP/GO and AP in case of
5944 * STA .
5945 * @mac_ctx: pointer to global mac structure
5946 * @new_channel: new channel to switch to.
5947 * @ch_bandwidth: BW of channel to calculate op_class
5948 * @session_entry: pe session
5949 *
5950 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5951 *
5952 * Return: void
5953 */
5954
5955static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5956 uint16_t new_channel, uint8_t ch_bandwidth,
5957 tpPESession session_entry)
5958{
5959 uint16_t op_class;
5960 uint8_t switch_mode = 0, i;
5961 tpDphHashNode psta;
5962
5963
Amar Singhal22995112016-01-22 10:42:33 -08005964 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305965 mac_ctx->scan.countryCodeCurrent,
5966 new_channel,
5967 ch_bandwidth);
5968
5969 if (LIM_IS_AP_ROLE(session_entry) &&
5970 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5971 switch_mode = 1;
5972
5973 if (LIM_IS_AP_ROLE(session_entry)) {
5974 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5975 psta =
5976 session_entry->dph.dphHashTable.pDphNodeArray + i;
5977 if (psta && psta->added)
5978 lim_send_extended_chan_switch_action_frame(
5979 mac_ctx,
5980 psta->staAddr,
5981 switch_mode, op_class, new_channel,
5982 LIM_MAX_CSA_IE_UPDATES, session_entry);
5983 }
5984 } else if (LIM_IS_STA_ROLE(session_entry)) {
5985 lim_send_extended_chan_switch_action_frame(mac_ctx,
5986 session_entry->bssId,
5987 switch_mode, op_class, new_channel,
5988 LIM_MAX_CSA_IE_UPDATES, session_entry);
5989 }
5990
5991}
5992
5993/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5995 *
5996 * @mac_ctx: Pointer to Global MAC structure
5997 * @msg_buf: pointer to the SME message buffer
5998 *
5999 * This function processes SME request messages from HDD or upper layer
6000 * application.
6001 *
6002 * Return: None
6003 */
6004static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
6005 uint32_t *msg_buf)
6006{
6007 tpSirDfsCsaIeRequest dfs_csa_ie_req;
6008 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 uint8_t session_id;
6010 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006011 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012
6013 if (msg_buf == NULL) {
6014 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6015 return;
6016 }
6017
6018 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6019 session_entry = pe_find_session_by_bssid(mac_ctx,
6020 dfs_csa_ie_req->bssid, &session_id);
6021 if (session_entry == NULL) {
6022 lim_log(mac_ctx, LOGE, FL(
6023 "Session not found for given BSSID" MAC_ADDRESS_STR),
6024 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6025 return;
6026 }
6027
6028 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6029 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6030 GET_LIM_SYSTEM_ROLE(session_entry));
6031 return;
6032 }
6033
6034 /* target channel */
6035 session_entry->gLimChannelSwitch.primaryChannel =
6036 dfs_csa_ie_req->targetChannel;
6037
6038 /* Channel switch announcement needs to be included in beacon */
6039 session_entry->dfsIncludeChanSwIe = true;
6040 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6041 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006042 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306043 session_entry->gLimChannelSwitch.sec_ch_offset =
6044 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6046 session_entry->gLimChannelSwitch.switchMode = 1;
6047
6048 /*
6049 * Validate if SAP is operating HT or VHT mode and set the Channel
6050 * Switch Wrapper element with the Wide Band Switch subelement.
6051 */
6052 if (true != session_entry->vhtCapability)
6053 goto skip_vht;
6054
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 /* Now encode the Wider Ch BW element depending on the ch width */
6056 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006057 switch (dfs_csa_ie_req->ch_params.ch_width) {
6058 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 /*
6060 * Wide channel BW sublement in channel wrapper element is not
6061 * required in case of 20 Mhz operation. Currently It is set
6062 * only set in case of 40/80 Mhz Operation.
6063 */
6064 session_entry->dfsIncludeChanWrapperIe = false;
6065 wider_bw_ch_switch->newChanWidth =
6066 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6067 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006068 case CH_WIDTH_40MHZ:
6069 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070 wider_bw_ch_switch->newChanWidth =
6071 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6072 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006073 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074 session_entry->dfsIncludeChanWrapperIe = true;
6075 wider_bw_ch_switch->newChanWidth =
6076 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6077 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006078 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006079 session_entry->dfsIncludeChanWrapperIe = true;
6080 wider_bw_ch_switch->newChanWidth =
6081 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6082 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006083 case CH_WIDTH_80P80MHZ:
6084 session_entry->dfsIncludeChanWrapperIe = true;
6085 wider_bw_ch_switch->newChanWidth =
6086 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006087 /*
6088 * This is not applicable for 20/40/80 Mhz.
6089 * Only used when we support 80+80 Mhz operation.
6090 * In case of 80+80 Mhz, this parameter indicates
6091 * center channel frequency index of 80 Mhz channel of
6092 * frequency segment 1.
6093 */
6094 wider_bw_ch_switch->newCenterChanFreq1 =
6095 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006096 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 default:
6098 session_entry->dfsIncludeChanWrapperIe = false;
6099 /*
6100 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6101 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6102 */
6103 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6104 break;
6105 }
6106 /* Fetch the center channel based on the channel width */
6107 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006108 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006109skip_vht:
6110 /* Send CSA IE request from here */
6111 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6112 eSIR_SUCCESS) {
6113 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6114 return;
6115 }
6116
6117 /*
6118 * First beacon update request is sent here, the remaining updates are
6119 * done when the FW responds back after sending the first beacon after
6120 * the template update
6121 */
6122 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306123
6124 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6125 ch_offset = BW80;
6126 else
6127 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6128
6129 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6130 session_entry->gLimChannelSwitch.switchCount,
6131 session_entry->gLimChannelSwitch.primaryChannel,
6132 session_entry->gLimChannelSwitch.ch_width,
6133 session_entry->dfsIncludeChanWrapperIe,
6134 ch_offset);
6135
Abhishek Singh518323d2015-10-19 17:42:01 +05306136 /* Send ECSA Action frame after updating the beacon */
6137 send_extended_chan_switch_action_frame(mac_ctx,
6138 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306139 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006140 session_entry->gLimChannelSwitch.switchCount--;
6141}
6142
6143/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306144 * lim_process_ext_change_channel()- function to send ECSA
6145 * action frame for STA/CLI .
6146 * @mac_ctx: pointer to global mac structure
6147 * @msg: params from sme for new channel.
6148 *
6149 * This function is called to send ECSA frame for STA/CLI.
6150 *
6151 * Return: void
6152 */
6153
6154static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6155 uint32_t *msg)
6156{
6157 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6158 (struct sir_sme_ext_cng_chan_req *) msg;
6159 tpPESession session_entry = NULL;
6160
6161 if (NULL == msg) {
6162 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6163 return;
6164 }
6165 session_entry =
6166 pe_find_session_by_sme_session_id(mac_ctx,
6167 ext_chng_channel->session_id);
6168 if (NULL == session_entry) {
6169 lim_log(mac_ctx, LOGE,
6170 FL("Session not found for given session %d"),
6171 ext_chng_channel->session_id);
6172 return;
6173 }
6174 if (LIM_IS_AP_ROLE(session_entry)) {
6175 lim_log(mac_ctx, LOGE,
6176 FL("not an STA/CLI session"));
6177 return;
6178 }
6179 send_extended_chan_switch_action_frame(mac_ctx,
6180 ext_chng_channel->new_channel,
6181 0, session_entry);
6182}
6183
6184/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006185 * lim_process_nss_update_request() - process sme nss update req
6186 *
6187 * @mac_ctx: Pointer to Global MAC structure
6188 * @msg_buf: pointer to the SME message buffer
6189 *
6190 * This function processes SME request messages from HDD or upper layer
6191 * application.
6192 *
6193 * Return: None
6194 */
6195static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6196 uint32_t *msg_buf)
6197{
6198 struct sir_nss_update_request *nss_update_req_ptr;
6199 tpPESession session_entry = NULL;
6200
6201 if (msg_buf == NULL) {
6202 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6203 return;
6204 }
6205
6206 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306207 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006208 nss_update_req_ptr->vdev_id);
6209 if (session_entry == NULL) {
6210 lim_log(mac_ctx, LOGE, FL(
6211 "Session not found for given session_id %d"),
6212 nss_update_req_ptr->vdev_id);
6213 return;
6214 }
6215
6216 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6217 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6218 GET_LIM_SYSTEM_ROLE(session_entry));
6219 return;
6220 }
6221
6222 /* populate nss field in the beacon */
6223 session_entry->gLimOperatingMode.present = 1;
6224 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6225 /* Send nss update request from here */
6226 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6227 eSIR_SUCCESS) {
6228 lim_log(mac_ctx, LOGE,
6229 FL("Unable to set op mode IE in beacon"));
6230 return;
6231 }
6232
6233 lim_send_beacon_ind(mac_ctx, session_entry);
6234}
6235
6236/**
6237 * lim_process_set_ie_req() - process sme set IE request
6238 *
6239 * @mac_ctx: Pointer to Global MAC structure
6240 * @msg_buf: pointer to the SME message buffer
6241 *
6242 * This function processes SME request messages from HDD or upper layer
6243 * application.
6244 *
6245 * Return: None
6246 */
6247static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6248{
6249 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306250 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251
6252 if (msg_buf == NULL) {
6253 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6254 return;
6255 }
6256
6257 msg = (struct send_extcap_ie *)msg_buf;
6258 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306259 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006260 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6261
6262}