blob: 347198956135f49a2f796215bf6544336d2acd81 [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 session->maxTxPower = lim_get_max_tx_power(reg_max,
1938 local_power_constraint,
1939 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301940
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301941 lim_log(mac_ctx, LOG1,
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301942 FL("Reg max %d local power con %d max tx pwr %d"),
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301943 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944
1945 if (session->gLimCurrentBssUapsd) {
1946 session->gUapsdPerAcBitmask =
1947 session->pLimJoinReq->uapsdPerAcBitmask;
1948 lim_log(mac_ctx, LOG1,
1949 FL("UAPSD flag for all AC - 0x%2x"),
1950 session->gUapsdPerAcBitmask);
1951
1952 /* resetting the dynamic uapsd mask */
1953 session->gUapsdPerAcDeliveryEnableMask = 0;
1954 session->gUapsdPerAcTriggerEnableMask = 0;
1955 }
1956
1957 session->limRFBand =
1958 lim_get_rf_band(session->currentOperChannel);
1959
1960 /* Initialize 11h Enable Flag */
1961 if (SIR_BAND_5_GHZ == session->limRFBand) {
1962 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1963 &val) != eSIR_SUCCESS) {
1964 lim_log(mac_ctx, LOGP,
1965 FL("Fail to get WNI_CFG_11H_ENABLED "));
1966 session->lim11hEnable =
1967 WNI_CFG_11H_ENABLED_STADEF;
1968 } else {
1969 session->lim11hEnable = val;
1970 }
1971 } else {
1972 session->lim11hEnable = 0;
1973 }
1974
1975 /*
1976 * To care of the scenario when STA transitions from
1977 * IBSS to Infrastructure mode.
1978 */
1979 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1980
1981 session->limPrevSmeState = session->limSmeState;
1982 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1983 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1984 session->peSessionId,
1985 session->limSmeState));
1986
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 /* Indicate whether spectrum management is enabled */
1988 session->spectrumMgtEnabled =
1989 sme_join_req->spectrumMgtIndicator;
1990
1991 /* Enable the spectrum management if this is a DFS channel */
1992 if (session->country_info_present &&
1993 lim_isconnected_on_dfs_channel(
1994 session->currentOperChannel))
1995 session->spectrumMgtEnabled = true;
1996
1997 session->isOSENConnection = sme_join_req->isOSENConnection;
1998
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 /* Issue LIM_MLM_JOIN_REQ to MLM */
2000 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2001 (uint32_t *) mlm_join_req);
2002 return;
2003
2004 } else {
2005 /* Received eWNI_SME_JOIN_REQ un expected state */
2006 lim_log(mac_ctx, LOGE,
2007 FL("received unexpected SME_JOIN_REQ in state %X"),
2008 mac_ctx->lim.gLimSmeState);
2009 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2010 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2011 session = NULL;
2012 goto end;
2013 }
2014
2015end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302016 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2017 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018
2019 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302020 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 sme_join_req = NULL;
2022 if (NULL != session)
2023 session->pLimJoinReq = NULL;
2024 }
2025 if (ret_code != eSIR_SME_SUCCESS) {
2026 if (NULL != session) {
2027 pe_delete_session(mac_ctx, session);
2028 session = NULL;
2029 }
2030 }
2031 lim_log(mac_ctx, LOG1,
2032 FL("Send failure status on sessionid: %d with ret_code = %d"),
2033 sme_session_id, ret_code);
2034 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2035 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2036 sme_transaction_id);
2037}
2038
Amar Singhala297bfa2015-10-15 15:07:29 -07002039uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 uint8_t iniTxPower)
2041{
2042 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302043 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2044 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2046 maxTxPower = txPower;
2047 else if (txPower < MIN_TX_PWR_CAP)
2048 maxTxPower = MIN_TX_PWR_CAP;
2049 else
2050 maxTxPower = MAX_TX_PWR_CAP;
2051
2052 return maxTxPower;
2053}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054
2055/**
2056 * __lim_process_sme_reassoc_req() - process reassoc req
2057 *
2058 * @mac_ctx: Pointer to Global MAC structure
2059 * @msg_buf: pointer to the SME message buffer
2060 *
2061 * This function is called to process SME_REASSOC_REQ message
2062 * from HDD or upper layer application.
2063 *
2064 * Return: None
2065 */
2066
2067static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2068 uint32_t *msg_buf)
2069{
2070 uint16_t caps;
2071 uint32_t val;
2072 tpSirSmeJoinReq reassoc_req = NULL;
2073 tLimMlmReassocReq *mlm_reassoc_req;
2074 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2075 tpPESession session_entry = NULL;
2076 uint8_t session_id;
2077 uint8_t sme_session_id;
2078 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002079 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 uint32_t tele_bcn_en = 0;
2081 uint16_t size;
2082
2083 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2084
2085 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302086 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 if (NULL == reassoc_req) {
2088 lim_log(mac_ctx, LOGP,
2089 FL("call to AllocateMemory failed for reassoc_req"));
2090
2091 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2092 goto end;
2093 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302094 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2095 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096
2097 if (!lim_is_sme_join_req_valid(mac_ctx,
2098 (tpSirSmeJoinReq)reassoc_req)) {
2099 /*
2100 * Received invalid eWNI_SME_REASSOC_REQ
2101 */
2102 lim_log(mac_ctx, LOGW,
2103 FL("received SME_REASSOC_REQ with invalid data"));
2104
2105 ret_code = eSIR_SME_INVALID_PARAMETERS;
2106 goto end;
2107 }
2108
2109 session_entry = pe_find_session_by_bssid(mac_ctx,
2110 reassoc_req->bssDescription.bssId,
2111 &session_id);
2112 if (session_entry == NULL) {
2113 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2114 LOGE);
2115 lim_log(mac_ctx, LOGE,
2116 FL("Session does not exist for given bssId"));
2117 ret_code = eSIR_SME_INVALID_PARAMETERS;
2118 goto end;
2119 }
2120#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2121 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2122 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2123#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2124 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2125
2126 /* Store the reassoc handle in the session Table */
2127 session_entry->pLimReAssocReq = reassoc_req;
2128
2129 session_entry->dot11mode = reassoc_req->dot11mode;
2130 session_entry->vhtCapability =
2131 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002132
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302133 if (session_entry->vhtCapability) {
2134 if (session_entry->pePersona == QDF_STA_MODE) {
2135 session_entry->vht_config.su_beam_formee =
2136 reassoc_req->vht_config.su_beam_formee;
2137 } else {
2138 reassoc_req->vht_config.su_beam_formee = 0;
2139 }
2140 session_entry->enableVhtpAid =
2141 reassoc_req->enableVhtpAid;
2142 session_entry->enableVhtGid =
2143 reassoc_req->enableVhtGid;
2144 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2145 session_entry->vht_config.su_beam_former);
2146 }
2147
2148 lim_log(mac_ctx, LOG1,
2149 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2150 session_entry->vhtCapability,
2151 session_entry->vht_config.su_beam_formee,
2152 session_entry->vht_config.su_beam_former);
2153
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002154 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2155 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002156 session_entry->send_smps_action =
2157 reassoc_req->send_smps_action;
2158 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002159 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002160 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002161 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002162 session_entry->send_smps_action,
2163 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 /*
2165 * Reassociate request is expected
2166 * in link established state only.
2167 */
2168
2169 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2171 /*
2172 * May be from 11r FT pre-auth. So lets check it
2173 * before we bail out
2174 */
2175 lim_log(mac_ctx, LOG1, FL(
2176 "Session in reassoc state is %d"),
2177 session_entry->peSessionId);
2178
2179 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302180 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 session_entry->limReAssocbssId,
2182 6)) {
2183 lim_print_mac_addr(mac_ctx,
2184 reassoc_req->bssDescription.
2185 bssId, LOGE);
2186 lim_log(mac_ctx, LOGP,
2187 FL("Unknown bssId in reassoc state"));
2188 ret_code = eSIR_SME_INVALID_PARAMETERS;
2189 goto end;
2190 }
2191
2192 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2193 session_entry);
2194 return;
2195 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 /*
2197 * Should not have received eWNI_SME_REASSOC_REQ
2198 */
2199 lim_log(mac_ctx, LOGE,
2200 FL("received unexpected SME_REASSOC_REQ in state %X"),
2201 session_entry->limSmeState);
2202 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2203
2204 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2205 goto end;
2206 }
2207
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302208 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 session_entry->pLimReAssocReq->bssDescription.bssId,
2210 sizeof(tSirMacAddr));
2211
2212 session_entry->limReassocChannelId =
2213 session_entry->pLimReAssocReq->bssDescription.channelId;
2214
2215 session_entry->reAssocHtSupportedChannelWidthSet =
2216 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2217 session_entry->reAssocHtRecommendedTxWidthSet =
2218 session_entry->reAssocHtSupportedChannelWidthSet;
2219 session_entry->reAssocHtSecondaryChannelOffset =
2220 session_entry->pLimReAssocReq->cbMode;
2221
2222 session_entry->limReassocBssCaps =
2223 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2224 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2225 session_entry->currentOperChannel);
2226 local_pwr_constraint = reg_max;
2227
2228 lim_extract_ap_capability(mac_ctx,
2229 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2230 lim_get_ielen_from_bss_description(
2231 &session_entry->pLimReAssocReq->bssDescription),
2232 &session_entry->limReassocBssQosCaps,
2233 &session_entry->limReassocBssPropCap,
2234 &session_entry->gLimCurrentBssUapsd,
2235 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302236 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302238 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2239 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 /* Copy the SSID from session entry to local variable */
2241 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302242 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 reassoc_req->ssId.ssId,
2244 session_entry->limReassocSSID.length);
2245 if (session_entry->gLimCurrentBssUapsd) {
2246 session_entry->gUapsdPerAcBitmask =
2247 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2248 lim_log(mac_ctx, LOG1,
2249 FL("UAPSD flag for all AC - 0x%2x"),
2250 session_entry->gUapsdPerAcBitmask);
2251 }
2252
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302253 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 if (NULL == mlm_reassoc_req) {
2255 lim_log(mac_ctx, LOGP,
2256 FL("call to AllocateMemory failed for mlmReassocReq"));
2257
2258 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2259 goto end;
2260 }
2261
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302262 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2264
2265 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2266 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2267 eSIR_SUCCESS) {
2268 /*
2269 * Could not get ReassocFailureTimeout value
2270 * from CFG. Log error.
2271 */
2272 lim_log(mac_ctx, LOGP,
2273 FL("could not retrieve ReassocFailureTimeout value"));
2274 }
2275
2276 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2277 eSIR_SUCCESS) {
2278 /*
2279 * Could not get Capabilities value
2280 * from CFG. Log error.
2281 */
2282 lim_log(mac_ctx, LOGP, FL(
2283 "could not retrieve Capabilities value"));
2284 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302285
2286 lim_update_caps_info_for_bss(mac_ctx, &caps,
2287 reassoc_req->bssDescription.capabilityInfo);
2288 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2289
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 mlm_reassoc_req->capabilityInfo = caps;
2291
2292 /* Update PE session_id */
2293 mlm_reassoc_req->sessionId = session_id;
2294
2295 /*
2296 * If telescopic beaconing is enabled, set listen interval to
2297 * WNI_CFG_TELE_BCN_MAX_LI
2298 */
2299 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2300 &tele_bcn_en) != eSIR_SUCCESS)
2301 lim_log(mac_ctx, LOGP,
2302 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2303
2304 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2305
2306 if (tele_bcn_en) {
2307 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2308 eSIR_SUCCESS)
2309 /*
2310 * Could not get ListenInterval value
2311 * from CFG. Log error.
2312 */
2313 lim_log(mac_ctx, LOGP,
2314 FL("could not retrieve ListenInterval"));
2315 } else {
2316 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2317 eSIR_SUCCESS)
2318 /*
2319 * Could not get ListenInterval value
2320 * from CFG. Log error.
2321 */
2322 lim_log(mac_ctx, LOGP,
2323 FL("could not retrieve ListenInterval"));
2324 }
2325
2326 mlm_reassoc_req->listenInterval = (uint16_t) val;
2327
2328 /* Indicate whether spectrum management is enabled */
2329 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2330
2331 /* Enable the spectrum management if this is a DFS channel */
2332 if (session_entry->country_info_present &&
2333 lim_isconnected_on_dfs_channel(
2334 session_entry->currentOperChannel))
2335 session_entry->spectrumMgtEnabled = true;
2336
2337 session_entry->limPrevSmeState = session_entry->limSmeState;
2338 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2339
2340 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2341 session_entry->peSessionId,
2342 session_entry->limSmeState));
2343
2344 lim_post_mlm_message(mac_ctx,
2345 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2346 return;
2347end:
2348 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302349 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 if (session_entry)
2351 session_entry->pLimReAssocReq = NULL;
2352 }
2353
2354 if (session_entry) {
2355 /*
2356 * error occurred after we determined the session so extract
2357 * session and transaction info from there
2358 */
2359 sme_session_id = session_entry->smeSessionId;
2360 transaction_id = session_entry->transactionId;
2361 } else
2362 /*
2363 * error occurred before or during the time we determined
2364 * the session so extract the session and transaction info
2365 * from the message
2366 */
2367 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2368 &sme_session_id, &transaction_id);
2369
2370 /*
2371 * Send Reassoc failure response to host
2372 * (note session_entry may be NULL, but that's OK)
2373 */
2374 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2375 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2376 session_entry, sme_session_id,
2377 transaction_id);
2378}
2379
2380bool send_disassoc_frame = 1;
2381/**
2382 * __lim_process_sme_disassoc_req()
2383 *
2384 ***FUNCTION:
2385 * This function is called to process SME_DISASSOC_REQ message
2386 * from HDD or upper layer application.
2387 *
2388 ***LOGIC:
2389 *
2390 ***ASSUMPTIONS:
2391 *
2392 ***NOTE:
2393 *
2394 * @param pMac Pointer to Global MAC structure
2395 * @param *pMsgBuf A pointer to the SME message buffer
2396 * @return None
2397 */
2398
2399static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2400{
2401 uint16_t disassocTrigger, reasonCode;
2402 tLimMlmDisassocReq *pMlmDisassocReq;
2403 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2404 tSirSmeDisassocReq smeDisassocReq;
2405 tpPESession psessionEntry = NULL;
2406 uint8_t sessionId;
2407 uint8_t smesessionId;
2408 uint16_t smetransactionId;
2409
2410 if (pMsgBuf == NULL) {
2411 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2412 return;
2413 }
2414
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302415 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 smesessionId = smeDisassocReq.sessionId;
2417 smetransactionId = smeDisassocReq.transactionId;
2418 if (!lim_is_sme_disassoc_req_valid(pMac,
2419 &smeDisassocReq,
2420 psessionEntry)) {
2421 PELOGE(lim_log(pMac, LOGE,
2422 FL("received invalid SME_DISASSOC_REQ message"));)
2423 if (pMac->lim.gLimRspReqd) {
2424 pMac->lim.gLimRspReqd = false;
2425
2426 retCode = eSIR_SME_INVALID_PARAMETERS;
2427 disassocTrigger = eLIM_HOST_DISASSOC;
2428 goto sendDisassoc;
2429 }
2430
2431 return;
2432 }
2433
2434 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002435 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436 &sessionId);
2437 if (psessionEntry == NULL) {
2438 lim_log(pMac, LOGE,
2439 FL("session does not exist for given bssId "
2440 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002441 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 retCode = eSIR_SME_INVALID_PARAMETERS;
2443 disassocTrigger = eLIM_HOST_DISASSOC;
2444 goto sendDisassoc;
2445 }
2446 lim_log(pMac, LOG1,
2447 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2448 MAC_ADDRESS_STR), smesessionId,
2449 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2450 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002451 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452
2453#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2454 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2455 0, smeDisassocReq.reasonCode);
2456#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2457
2458 /* Update SME session Id and SME transaction ID */
2459
2460 psessionEntry->smeSessionId = smesessionId;
2461 psessionEntry->transactionId = smetransactionId;
2462
2463 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2464 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 switch (psessionEntry->limSmeState) {
2466 case eLIM_SME_ASSOCIATED_STATE:
2467 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002468 lim_log(pMac, LOG1,
2469 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2470 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 psessionEntry->limPrevSmeState =
2472 psessionEntry->limSmeState;
2473 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2474#ifdef FEATURE_WLAN_TDLS
2475 /* Delete all TDLS peers connected before leaving BSS */
2476 lim_delete_tdls_peers(pMac, psessionEntry);
2477#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002478 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2479 psessionEntry->peSessionId,
2480 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 break;
2482
2483 case eLIM_SME_WT_DEAUTH_STATE:
2484 /* PE shall still process the DISASSOC_REQ and proceed with
2485 * link tear down even if it had already sent a DEAUTH_IND to
2486 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2487 * its been set when PE entered WT_DEAUTH_STATE.
2488 */
2489 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2490 MTRACE(mac_trace
2491 (pMac, TRACE_CODE_SME_STATE,
2492 psessionEntry->peSessionId,
2493 psessionEntry->limSmeState));
2494 lim_log(pMac, LOG1,
2495 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2496 break;
2497
2498 case eLIM_SME_WT_DISASSOC_STATE:
2499 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2500 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2501 * PE can continue processing DISASSOC_REQ and send the response instead
2502 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2503 * for disassoc frame.
2504 *
2505 * It will send a disassoc, which is ok. However, we can use the global flag
2506 * sendDisassoc to not send disassoc frame.
2507 */
2508 lim_log(pMac, LOG1,
2509 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2510 break;
2511
2512 case eLIM_SME_JOIN_FAILURE_STATE: {
2513 /* Already in Disconnected State, return success */
2514 lim_log(pMac, LOG1,
2515 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2516 if (pMac->lim.gLimRspReqd) {
2517 retCode = eSIR_SME_SUCCESS;
2518 disassocTrigger = eLIM_HOST_DISASSOC;
2519 goto sendDisassoc;
2520 }
2521 }
2522 break;
2523 default:
2524 /**
2525 * STA is not currently associated.
2526 * Log error and send response to host
2527 */
2528 lim_log(pMac, LOGE,
2529 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2530 psessionEntry->limSmeState);
2531 lim_print_sme_state(pMac, LOGE,
2532 psessionEntry->limSmeState);
2533
2534 if (pMac->lim.gLimRspReqd) {
2535 if (psessionEntry->limSmeState !=
2536 eLIM_SME_WT_ASSOC_STATE)
2537 pMac->lim.gLimRspReqd = false;
2538
2539 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2540 disassocTrigger = eLIM_HOST_DISASSOC;
2541 goto sendDisassoc;
2542 }
2543
2544 return;
2545 }
2546
2547 break;
2548
2549 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 /* Fall through */
2551 break;
2552
2553 case eLIM_STA_IN_IBSS_ROLE:
2554 default:
2555 /* eLIM_UNKNOWN_ROLE */
2556 lim_log(pMac, LOGE,
2557 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2558 GET_LIM_SYSTEM_ROLE(psessionEntry));
2559
2560 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2561 disassocTrigger = eLIM_HOST_DISASSOC;
2562 goto sendDisassoc;
2563 } /* end switch (pMac->lim.gLimSystemRole) */
2564
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302565 disassocTrigger = eLIM_HOST_DISASSOC;
2566 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567
2568 if (smeDisassocReq.doNotSendOverTheAir) {
2569 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2570 send_disassoc_frame = 0;
2571 }
2572 /* Trigger Disassociation frame to peer MAC entity */
2573 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2574 " : %d, reasonCode : %d"),
2575 disassocTrigger, reasonCode);
2576
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302577 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 if (NULL == pMlmDisassocReq) {
2579 /* Log error */
2580 lim_log(pMac, LOGP,
2581 FL("call to AllocateMemory failed for mlmDisassocReq"));
2582
2583 return;
2584 }
2585
Anurag Chouhanc5548422016-02-24 18:33:27 +05302586 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002587 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588
2589 pMlmDisassocReq->reasonCode = reasonCode;
2590 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2591
2592 /* Update PE session ID */
2593 pMlmDisassocReq->sessionId = sessionId;
2594
2595 lim_post_mlm_message(pMac,
2596 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2597 return;
2598
2599sendDisassoc:
2600 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002601 lim_send_sme_disassoc_ntf(pMac,
2602 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 retCode,
2604 disassocTrigger,
2605 1, smesessionId, smetransactionId,
2606 psessionEntry);
2607 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002608 lim_send_sme_disassoc_ntf(pMac,
2609 smeDisassocReq.peer_macaddr.bytes,
2610 retCode, disassocTrigger, 1,
2611 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612
2613} /*** end __lim_process_sme_disassoc_req() ***/
2614
2615/** -----------------------------------------------------------------
2616 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2617
2618 This function is called to process SME_DISASSOC_CNF message
2619 from HDD or upper layer application.
2620
2621 \param pMac - global mac structure
2622 \param pStaDs - station dph hash node
2623 \return none
2624 \sa
2625 ----------------------------------------------------------------- */
2626static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2627{
2628 tSirSmeDisassocCnf smeDisassocCnf;
2629 uint16_t aid;
2630 tpDphHashNode pStaDs;
2631 tpPESession psessionEntry;
2632 uint8_t sessionId;
2633
2634 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2635
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302636 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 sizeof(struct sSirSmeDisassocCnf));
2638
2639 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002640 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 &sessionId);
2642 if (psessionEntry == NULL) {
2643 lim_log(pMac, LOGE,
2644 FL("session does not exist for given bssId"));
2645 return;
2646 }
2647
2648 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2649 lim_log(pMac, LOGE,
2650 FL("received invalid SME_DISASSOC_CNF message"));
2651 return;
2652 }
2653#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2654 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2655 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2656 psessionEntry,
2657 (uint16_t) smeDisassocCnf.statusCode, 0);
2658 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2659 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2660 psessionEntry,
2661 (uint16_t) smeDisassocCnf.statusCode, 0);
2662#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2663
2664 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2665 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2667 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2668 && (psessionEntry->limSmeState !=
2669 eLIM_SME_WT_DEAUTH_STATE)) {
2670 lim_log(pMac, LOGE,
2671 FL
2672 ("received unexp SME_DISASSOC_CNF in state %X"),
2673 psessionEntry->limSmeState);
2674 lim_print_sme_state(pMac, LOGE,
2675 psessionEntry->limSmeState);
2676 return;
2677 }
2678 break;
2679
2680 case eLIM_AP_ROLE:
2681 /* Fall through */
2682 break;
2683
2684 case eLIM_STA_IN_IBSS_ROLE:
2685 default: /* eLIM_UNKNOWN_ROLE */
2686 lim_log(pMac, LOGE,
2687 FL("received unexpected SME_DISASSOC_CNF role %d"),
2688 GET_LIM_SYSTEM_ROLE(psessionEntry));
2689
2690 return;
2691 }
2692
2693 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2694 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2695 LIM_IS_AP_ROLE(psessionEntry)) {
2696 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002697 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 &psessionEntry->dph.dphHashTable);
2699 if (pStaDs == NULL) {
2700 lim_log(pMac, LOGE,
2701 FL("DISASSOC_CNF for a STA with no context, addr= "
2702 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002703 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 return;
2705 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302706
2707 if ((pStaDs->mlmStaContext.mlmState ==
2708 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2709 (pStaDs->mlmStaContext.mlmState ==
2710 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2711 lim_log(pMac, LOGE,
2712 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002713 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302714 pStaDs->mlmStaContext.mlmState);
2715 return;
2716 }
2717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 /* Delete FT session if there exists one */
2719 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2721
2722 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002723 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 }
2725
2726 return;
2727}
2728
2729/**
2730 * __lim_process_sme_deauth_req() - process sme deauth req
2731 * @mac_ctx: Pointer to Global MAC structure
2732 * @msg_buf: pointer to the SME message buffer
2733 *
2734 * This function is called to process SME_DEAUTH_REQ message
2735 * from HDD or upper layer application.
2736 *
2737 * Return: None
2738 */
2739
2740static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2741 uint32_t *msg_buf)
2742{
2743 uint16_t deauth_trigger, reason_code;
2744 tLimMlmDeauthReq *mlm_deauth_req;
2745 tSirSmeDeauthReq sme_deauth_req;
2746 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2747 tpPESession session_entry;
2748 uint8_t session_id; /* PE sessionId */
2749 uint8_t sme_session_id;
2750 uint16_t sme_transaction_id;
2751
2752 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2753
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302754 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 sme_session_id = sme_deauth_req.sessionId;
2756 sme_transaction_id = sme_deauth_req.transactionId;
2757
2758 /*
2759 * We need to get a session first but we don't even know
2760 * if the message is correct.
2761 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002762 session_entry = pe_find_session_by_bssid(mac_ctx,
2763 sme_deauth_req.bssid.bytes,
2764 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 if (session_entry == NULL) {
2766 lim_log(mac_ctx, LOGE,
2767 FL("session does not exist for given bssId"));
2768 ret_code = eSIR_SME_INVALID_PARAMETERS;
2769 deauth_trigger = eLIM_HOST_DEAUTH;
2770 goto send_deauth;
2771 }
2772
2773 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2774 session_entry)) {
2775 lim_log(mac_ctx, LOGE,
2776 FL("received invalid SME_DEAUTH_REQ message"));
2777 mac_ctx->lim.gLimRspReqd = false;
2778
2779 ret_code = eSIR_SME_INVALID_PARAMETERS;
2780 deauth_trigger = eLIM_HOST_DEAUTH;
2781 goto send_deauth;
2782 }
2783 lim_log(mac_ctx, LOG1,
2784 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2785 MAC_ADDRESS_STR), sme_session_id,
2786 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2787 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002788 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2790 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2791 session_entry, 0, sme_deauth_req.reasonCode);
2792#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2793
2794 /* Update SME session ID and Transaction ID */
2795 session_entry->smeSessionId = sme_session_id;
2796 session_entry->transactionId = sme_transaction_id;
2797
2798 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2799 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 switch (session_entry->limSmeState) {
2801 case eLIM_SME_ASSOCIATED_STATE:
2802 case eLIM_SME_LINK_EST_STATE:
2803 case eLIM_SME_WT_ASSOC_STATE:
2804 case eLIM_SME_JOIN_FAILURE_STATE:
2805 case eLIM_SME_IDLE_STATE:
2806 session_entry->limPrevSmeState =
2807 session_entry->limSmeState;
2808 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2809 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2810 session_entry->peSessionId,
2811 session_entry->limSmeState));
2812 /* Send Deauthentication request to MLM below */
2813 break;
2814 case eLIM_SME_WT_DEAUTH_STATE:
2815 case eLIM_SME_WT_DISASSOC_STATE:
2816 /*
2817 * PE Recieved a Deauth/Disassoc frame. Normally it get
2818 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2819 * Which means host is also trying to disconnect.
2820 * PE can continue processing DEAUTH_REQ and send
2821 * the response instead of failing the request.
2822 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2823 * was sent for deauth/disassoc frame.
2824 */
2825 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2826 lim_log(mac_ctx, LOG1, FL(
2827 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2828 break;
2829 default:
2830 /*
2831 * STA is not in a state to deauthenticate with
2832 * peer. Log error and send response to host.
2833 */
2834 lim_log(mac_ctx, LOGE, FL(
2835 "received unexp SME_DEAUTH_REQ in state %X"),
2836 session_entry->limSmeState);
2837 lim_print_sme_state(mac_ctx, LOGE,
2838 session_entry->limSmeState);
2839
2840 if (mac_ctx->lim.gLimRspReqd) {
2841 mac_ctx->lim.gLimRspReqd = false;
2842
2843 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2844 deauth_trigger = eLIM_HOST_DEAUTH;
2845
2846 /*
2847 * here we received deauth request from AP so sme state
2848 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2849 * delSta then mlm state should be
2850 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2851 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2852 * so the below condition captures the state where
2853 * delSta not done and firmware still in
2854 * connected state.
2855 */
2856 if (session_entry->limSmeState ==
2857 eLIM_SME_WT_DEAUTH_STATE &&
2858 session_entry->limMlmState !=
2859 eLIM_MLM_IDLE_STATE &&
2860 session_entry->limMlmState !=
2861 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2862 ret_code = eSIR_SME_DEAUTH_STATUS;
2863 goto send_deauth;
2864 }
2865 return;
2866 }
2867 break;
2868
2869 case eLIM_STA_IN_IBSS_ROLE:
2870 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2871 if (mac_ctx->lim.gLimRspReqd) {
2872 mac_ctx->lim.gLimRspReqd = false;
2873 ret_code = eSIR_SME_INVALID_PARAMETERS;
2874 deauth_trigger = eLIM_HOST_DEAUTH;
2875 goto send_deauth;
2876 }
2877 return;
2878 case eLIM_AP_ROLE:
2879 break;
2880 default:
2881 lim_log(mac_ctx, LOGE,
2882 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2883 GET_LIM_SYSTEM_ROLE(session_entry));
2884 if (mac_ctx->lim.gLimRspReqd) {
2885 mac_ctx->lim.gLimRspReqd = false;
2886 ret_code = eSIR_SME_INVALID_PARAMETERS;
2887 deauth_trigger = eLIM_HOST_DEAUTH;
2888 goto send_deauth;
2889 }
2890 return;
2891 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2892
2893 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2894 /* Deauthentication is triggered by Link Monitoring */
2895 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2896 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2897 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2898 } else {
2899 deauth_trigger = eLIM_HOST_DEAUTH;
2900 reason_code = sme_deauth_req.reasonCode;
2901 }
2902
2903 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302904 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 if (NULL == mlm_deauth_req) {
2906 lim_log(mac_ctx, LOGP,
2907 FL("call to AllocateMemory failed for mlmDeauthReq"));
2908 if (mac_ctx->lim.gLimRspReqd) {
2909 mac_ctx->lim.gLimRspReqd = false;
2910 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2911 deauth_trigger = eLIM_HOST_DEAUTH;
2912 goto send_deauth;
2913 }
2914 return;
2915 }
2916
Anurag Chouhanc5548422016-02-24 18:33:27 +05302917 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002918 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919
2920 mlm_deauth_req->reasonCode = reason_code;
2921 mlm_deauth_req->deauthTrigger = deauth_trigger;
2922
2923 /* Update PE session Id */
2924 mlm_deauth_req->sessionId = session_id;
2925
2926 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2927 (uint32_t *)mlm_deauth_req);
2928 return;
2929
2930send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002931 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2932 ret_code, deauth_trigger, 1,
2933 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934}
2935
2936/**
2937 * __lim_process_sme_set_context_req()
2938 *
2939 * @mac_ctx: Pointer to Global MAC structure
2940 * @msg_buf: pointer to the SME message buffer
2941 *
2942 * This function is called to process SME_SETCONTEXT_REQ message
2943 * from HDD or upper layer application.
2944 *
2945 * Return: None
2946 */
2947
2948static void
2949__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2950{
2951 tpSirSmeSetContextReq set_context_req;
2952 tLimMlmSetKeysReq *mlm_set_key_req;
2953 tpPESession session_entry;
2954 uint8_t session_id; /* PE sessionID */
2955 uint8_t sme_session_id;
2956 uint16_t sme_transaction_id;
2957
2958 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2959
2960 if (msg_buf == NULL) {
2961 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2962 return;
2963 }
2964
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302965 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 if (NULL == set_context_req) {
2967 lim_log(mac_ctx, LOGP, FL(
2968 "call to AllocateMemory failed for set_context_req"));
2969 return;
2970 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302971 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 sizeof(struct sSirSmeSetContextReq));
2973 sme_session_id = set_context_req->sessionId;
2974 sme_transaction_id = set_context_req->transactionId;
2975
2976 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2977 lim_log(mac_ctx, LOGW,
2978 FL("received invalid SME_SETCONTEXT_REQ message"));
2979 goto end;
2980 }
2981
2982 if (set_context_req->keyMaterial.numKeys >
2983 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2984 lim_log(mac_ctx, LOGE, FL(
2985 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2986 set_context_req->keyMaterial.numKeys);
2987 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002988 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 eSIR_SME_INVALID_PARAMETERS, NULL,
2990 sme_session_id, sme_transaction_id);
2991 goto end;
2992 }
2993
2994 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002995 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996 if (session_entry == NULL) {
2997 lim_log(mac_ctx, LOGW,
2998 FL("Session does not exist for given BSSID"));
2999 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003000 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 eSIR_SME_INVALID_PARAMETERS, NULL,
3002 sme_session_id, sme_transaction_id);
3003 goto end;
3004 }
3005#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3006 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3007 session_entry, 0, 0);
3008#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3009
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003010 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3012 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003013 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3015 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303016 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 if (NULL == mlm_set_key_req) {
3018 lim_log(mac_ctx, LOGP, FL(
3019 "mem alloc failed for mlmSetKeysReq"));
3020 goto end;
3021 }
3022 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3023 mlm_set_key_req->numKeys =
3024 set_context_req->keyMaterial.numKeys;
3025 if (mlm_set_key_req->numKeys >
3026 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3027 lim_log(mac_ctx, LOGP, FL(
3028 "no.of keys exceeded max num of default keys limit"));
3029 goto end;
3030 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303031 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003032 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303034 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 (uint8_t *) &set_context_req->keyMaterial.key,
3036 sizeof(tSirKeys) *
3037 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3038 numKeys : 1));
3039
3040 mlm_set_key_req->sessionId = session_id;
3041 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 lim_log(mac_ctx, LOG1, FL(
3043 "received SETCONTEXT_REQ message sessionId=%d"),
3044 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045
3046 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3047 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3048 LIM_IS_AP_ROLE(session_entry)) {
3049 if (set_context_req->keyMaterial.key[0].keyLength) {
3050 uint8_t key_id;
3051 key_id =
3052 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303053 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 &session_entry->WEPKeyMaterial[key_id],
3055 (uint8_t *) &set_context_req->keyMaterial,
3056 sizeof(tSirKeyMaterial));
3057 } else {
3058 uint32_t i;
3059 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3060 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303061 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 &mlm_set_key_req->key[i],
3063 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3064 sizeof(tSirKeys));
3065 }
3066 }
3067 }
3068 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3069 (uint32_t *) mlm_set_key_req);
3070 } else {
3071 lim_log(mac_ctx, LOGE, FL(
3072 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3073 GET_LIM_SYSTEM_ROLE(session_entry),
3074 session_entry->limSmeState);
3075 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3076
3077 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003078 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3080 session_entry, sme_session_id,
3081 sme_transaction_id);
3082 }
3083end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303084 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 return;
3086}
3087
3088/**
3089 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3090 *
3091 * @mac_ctx: Pointer to Global MAC structure
3092 * @msg_buf: pointer to the SME message buffer
3093 *
3094 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3095 * from HDD or upper layer application.
3096 *
3097 * Return: None
3098 */
3099
3100void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3101 uint32_t *msg_buf)
3102{
3103 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3104 tpDphHashNode sta_ds = NULL;
3105 tpPESession session_entry = NULL;
3106 tSap_Event sap_event;
3107 tpWLAN_SAPEventCB sap_event_cb = NULL;
3108 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3109 uint8_t session_id = CSR_SESSION_ID_INVALID;
3110 uint8_t assoc_id = 0;
3111 uint8_t sta_cnt = 0;
3112
3113 if (msg_buf == NULL) {
3114 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3115 return;
3116 }
3117
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303118 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 sizeof(struct sSirSmeGetAssocSTAsReq));
3120 /*
3121 * Get Associated stations from PE.
3122 * Find PE session Entry
3123 */
3124 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003125 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 &session_id);
3127 if (session_entry == NULL) {
3128 lim_log(mac_ctx, LOGE,
3129 FL("session does not exist for given bssId"));
3130 goto lim_assoc_sta_end;
3131 }
3132
3133 if (!LIM_IS_AP_ROLE(session_entry)) {
3134 lim_log(mac_ctx, LOGE, FL(
3135 "Received unexpected message in state %X, in role %X"),
3136 session_entry->limSmeState,
3137 GET_LIM_SYSTEM_ROLE(session_entry));
3138 goto lim_assoc_sta_end;
3139 }
3140 /* Retrieve values obtained in the request message */
3141 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3142 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3143
3144 if (NULL == assoc_sta_tmp)
3145 goto lim_assoc_sta_end;
3146 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3147 assoc_id++) {
3148 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3149 &session_entry->dph.dphHashTable);
3150 if (NULL == sta_ds)
3151 continue;
3152 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303153 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303155 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3157 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3158
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303159 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 (uint8_t *)&sta_ds->supportedRates,
3161 sizeof(tSirSupportedRates));
3162 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3163 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3164 assoc_sta_tmp->Support40Mhz =
3165 sta_ds->htDsssCckRate40MHzSupport;
3166
3167 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3168 sta_cnt + 1);
3169 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3170 MAC_ADDR_ARRAY(sta_ds->staAddr));
3171 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3172 sta_ds->assocId);
3173 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3174 sta_ds->staIndex);
3175 assoc_sta_tmp++;
3176 sta_cnt++;
3177 }
3178 }
3179lim_assoc_sta_end:
3180 /*
3181 * Call hdd callback with sap event to send the list of
3182 * associated stations from PE
3183 */
3184 if (sap_event_cb != NULL) {
3185 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3186 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303187 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3189 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3190 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3191 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3192 }
3193}
3194
3195/**
3196 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3197 *
3198 * @mac_ctx: Pointer to Global MAC structure
3199 * @msg_buf: pointer to WPS PBC overlap query message
3200 *
3201 * This function parses get WPS PBC overlap information
3202 * message and call callback to pass WPS PBC overlap
3203 * information back to hdd.
3204 *
3205 * Return: None
3206 */
3207void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3208 uint32_t *msg_buf)
3209{
3210 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3211 tpPESession session_entry = NULL;
3212 tSap_Event sap_event;
3213 tpWLAN_SAPEventCB sap_event_cb = NULL;
3214 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3216
3217 if (msg_buf == NULL) {
3218 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3219 return;
3220 }
3221
3222 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303223 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303225 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3227 /*
3228 * Get Associated stations from PE
3229 * Find PE session Entry
3230 */
3231 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003232 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 if (session_entry == NULL) {
3234 lim_log(mac_ctx, LOGE,
3235 FL("session does not exist for given bssId"));
3236 goto lim_get_wpspbc_sessions_end;
3237 }
3238
3239 if (!LIM_IS_AP_ROLE(session_entry)) {
3240 lim_log(mac_ctx, LOGE,
3241 FL("Received unexpected message in role %X"),
3242 GET_LIM_SYSTEM_ROLE(session_entry));
3243 goto lim_get_wpspbc_sessions_end;
3244 }
3245 /*
3246 * Call hdd callback with sap event to send the
3247 * WPS PBC overlap information
3248 */
3249 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303250 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251
Anurag Chouhanc5548422016-02-24 18:33:27 +05303252 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003254 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 sap_get_wpspbc_event->UUID_E,
3256 &sap_get_wpspbc_event->wpsPBCOverlap,
3257 session_entry);
3258 } else {
3259 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003260 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 session_entry);
3262 /* don't have to inform the HDD/Host */
3263 return;
3264 }
3265
3266 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3267 sap_get_wpspbc_event->wpsPBCOverlap);
3268 lim_print_mac_addr(mac_ctx,
3269 sap_get_wpspbc_event->addr.bytes, LOG4);
3270
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303271 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272
3273lim_get_wpspbc_sessions_end:
3274 sap_event_cb =
3275 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3276 if (NULL != sap_event_cb)
3277 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3278}
3279
3280/**
3281 * __lim_counter_measures()
3282 *
3283 * FUNCTION:
3284 * This function is called to "implement" MIC counter measure
3285 * and is *temporary* only
3286 *
3287 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3288 * we don't do the proper STA disassoc sequence since the
3289 * BSS will be stoped anyway
3290 *
3291 ***ASSUMPTIONS:
3292 *
3293 ***NOTE:
3294 *
3295 * @param pMac Pointer to Global MAC structure
3296 * @return None
3297 */
3298
3299static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3300{
3301 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003302 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3304 mac, psessionEntry, false);
3305};
3306
3307void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3308{
3309 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3310 tpPESession psessionEntry;
3311 uint8_t sessionId; /* PE sessionId */
3312
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303313 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 sizeof(struct sSirSmeTkipCntrMeasReq));
3315
3316 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003317 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 if (NULL == psessionEntry) {
3319 lim_log(pMac, LOGE,
3320 FL("session does not exist for given BSSID "));
3321 return;
3322 }
3323
3324 if (tkipCntrMeasReq.bEnable)
3325 __lim_counter_measures(pMac, psessionEntry);
3326
3327 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3328}
3329
3330static void
3331__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3332{
3333 tSirSmeStopBssReq stopBssReq;
3334 tSirRetStatus status;
3335 tLimSmeStates prevState;
3336 tpPESession psessionEntry;
3337 uint8_t smesessionId;
3338 uint8_t sessionId;
3339 uint16_t smetransactionId;
3340 uint8_t i = 0;
3341 tpDphHashNode pStaDs = NULL;
3342
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303343 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 smesessionId = stopBssReq.sessionId;
3345 smetransactionId = stopBssReq.transactionId;
3346
3347 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3348 PELOGW(lim_log(pMac, LOGW,
3349 FL("received invalid SME_STOP_BSS_REQ message"));)
3350 /* Send Stop BSS response to host */
3351 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3352 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3353 smetransactionId);
3354 return;
3355 }
3356
3357 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003358 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 &sessionId);
3360 if (psessionEntry == NULL) {
3361 lim_log(pMac, LOGW,
3362 FL("session does not exist for given BSSID "));
3363 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3364 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3365 smetransactionId);
3366 return;
3367 }
3368#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3369 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3370 0, 0);
3371#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3372
3373 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3374 LIM_IS_STA_ROLE(psessionEntry)) {
3375 /**
3376 * Should not have received STOP_BSS_REQ in states
3377 * other than 'normal' state or on STA in Infrastructure
3378 * mode. Log error and return response to host.
3379 */
3380 lim_log(pMac, LOGE,
3381 FL
3382 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3383 psessionEntry->limSmeState,
3384 GET_LIM_SYSTEM_ROLE(psessionEntry));
3385 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3386 /* / Send Stop BSS response to host */
3387 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3388 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3389 smetransactionId);
3390 return;
3391 }
3392
3393 if (LIM_IS_AP_ROLE(psessionEntry))
3394 lim_wpspbc_close(pMac, psessionEntry);
3395
3396 lim_log(pMac, LOGW,
3397 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3398 stopBssReq.reasonCode);
3399
3400 prevState = psessionEntry->limSmeState;
3401
3402 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3403 MTRACE(mac_trace
3404 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3405 psessionEntry->limSmeState));
3406
3407 /* Update SME session Id and Transaction Id */
3408 psessionEntry->smeSessionId = smesessionId;
3409 psessionEntry->transactionId = smetransactionId;
3410
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003411 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3412 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3413 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3415 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3416 /* Send disassoc all stations associated thru TKIP */
3417 __lim_counter_measures(pMac, psessionEntry);
3418 else
3419 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003420 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3421 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 }
3423
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003424 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3425 /* Free the buffer allocated in START_BSS_REQ */
3426 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3427 psessionEntry->addIeParams.probeRespDataLen = 0;
3428 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003430 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3431 psessionEntry->addIeParams.assocRespDataLen = 0;
3432 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003434 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3435 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3436 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003438 /*
3439 * lim_del_bss is also called as part of coalescing,
3440 * when we send DEL BSS followed by Add Bss msg.
3441 */
3442 pMac->lim.gLimIbssCoalescingHappened = false;
3443 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3445 pStaDs =
3446 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3447 if (NULL == pStaDs)
3448 continue;
3449 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3450 if (eSIR_SUCCESS == status) {
3451 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3452 pStaDs->assocId, psessionEntry);
3453 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3454 } else {
3455 lim_log(pMac, LOGE,
3456 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303457 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 }
3459 }
3460 /* send a delBss to HAL and wait for a response */
3461 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3462
3463 if (status != eSIR_SUCCESS) {
3464 PELOGE(lim_log
3465 (pMac, LOGE, FL("delBss failed for bss %d"),
3466 psessionEntry->bssIdx);
3467 )
3468 psessionEntry->limSmeState = prevState;
3469
3470 MTRACE(mac_trace
3471 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3472 psessionEntry->limSmeState));
3473
3474 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3475 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3476 smetransactionId);
3477 }
3478}
3479
3480/**
3481 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3482 * @pMac: Global MAC context
3483 * @pMsg: Message from SME
3484 *
3485 * Wrapper for the function __lim_handle_sme_stop_bss_request
3486 * This message will be defered until softmac come out of
3487 * scan mode. Message should be handled even if we have
3488 * detected radar in the current operating channel.
3489 *
3490 * Return: true - If we consumed the buffer
3491 * false - If have defered the message.
3492 */
3493
3494static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3495{
3496 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3497 /**
3498 * If message defered, buffer is not consumed yet.
3499 * So return false
3500 */
3501 return false;
3502 }
3503 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3504 return true;
3505} /*** end __lim_process_sme_stop_bss_req() ***/
3506
3507void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3508 uint32_t body, tpPESession psessionEntry)
3509{
3510
3511 (void)body;
3512 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3513 lim_ibss_delete(pMac, psessionEntry);
3514 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3515 lim_delete_pre_auth_list(pMac);
3516 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3517 psessionEntry->smeSessionId,
3518 psessionEntry->transactionId);
3519 return;
3520}
3521
3522/**
3523 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3524 *
3525 * @mac_ctx: pointer to mac context
3526 * @msg_type: message type
3527 * @msg_buf: pointer to the SME message buffer
3528 *
3529 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3530 * in BTAMP AP.
3531 *
3532 * Return: None
3533 */
3534
3535void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3536 uint32_t *msg_buf)
3537{
3538 tSirSmeAssocCnf assoc_cnf;
3539 tpDphHashNode sta_ds = NULL;
3540 tpPESession session_entry = NULL;
3541 uint8_t session_id;
3542 tpSirAssocReq assoc_req;
3543
3544 if (msg_buf == NULL) {
3545 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3546 goto end;
3547 }
3548
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303549 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3551 lim_log(mac_ctx, LOGE,
3552 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3553 goto end;
3554 }
3555
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003556 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557 &session_id);
3558 if (session_entry == NULL) {
3559 lim_log(mac_ctx, LOGE,
3560 FL("session does not exist for given bssId"));
3561 goto end;
3562 }
3563
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003564 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3566 (session_entry->limSmeState !=
3567 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3568 lim_log(mac_ctx, LOGE, FL(
3569 "Rcvd unexpected msg %X in state %X, in role %X"),
3570 msg_type, session_entry->limSmeState,
3571 GET_LIM_SYSTEM_ROLE(session_entry));
3572 goto end;
3573 }
3574 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3575 &session_entry->dph.dphHashTable);
3576 if (sta_ds == NULL) {
3577 lim_log(mac_ctx, LOGE, FL(
3578 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3579 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003580 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581
3582 /*
3583 * send a DISASSOC_IND message to WSM to make sure
3584 * the state in WSM and LIM is the same
3585 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003586 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587 eSIR_SME_STA_NOT_ASSOCIATED,
3588 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3589 session_entry->smeSessionId,
3590 session_entry->transactionId,
3591 session_entry);
3592 goto end;
3593 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303594 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003595 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303596 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 lim_log(mac_ctx, LOG1, FL(
3598 "peerMacAddr mismatched for aid %d, peer "),
3599 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003600 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 goto end;
3602 }
3603
3604 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3605 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3606 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3607 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3608 (msg_type != eWNI_SME_ASSOC_CNF))) {
3609 lim_log(mac_ctx, LOG1, FL(
3610 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3611 "StaD mlmState : %d"),
3612 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003613 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 goto end;
3615 }
3616 /*
3617 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3618 * has been received
3619 */
3620 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3621 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3622 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3623
3624 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3625 /*
3626 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3627 * when it had received Assoc Request frame. Now, PE just needs
3628 * to send association rsp frame to the requesting BTAMP-STA.
3629 */
3630 sta_ds->mlmStaContext.mlmState =
3631 eLIM_MLM_LINK_ESTABLISHED_STATE;
3632 lim_log(mac_ctx, LOG1,
3633 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3634 sta_ds->assocId);
3635 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3636 sta_ds->assocId, sta_ds->staAddr,
3637 sta_ds->mlmStaContext.subType, sta_ds,
3638 session_entry);
3639 goto end;
3640 } else {
3641 /*
3642 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3643 * to be associated since the HAL sta entry is created for
3644 * denied STA we need to remove this HAL entry.
3645 * So to do that set updateContext to 1
3646 */
3647 if (!sta_ds->mlmStaContext.updateContext)
3648 sta_ds->mlmStaContext.updateContext = 1;
3649 lim_log(mac_ctx, LOG1,
3650 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3651 assoc_cnf.statusCode, sta_ds->assocId);
3652 lim_reject_association(mac_ctx, sta_ds->staAddr,
3653 sta_ds->mlmStaContext.subType,
3654 true, sta_ds->mlmStaContext.authType,
3655 sta_ds->assocId, true,
3656 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3657 session_entry);
3658 }
3659end:
3660 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3661 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3662 assoc_req = (tpSirAssocReq)
3663 session_entry->parsedAssocReq[sta_ds->assocId];
3664 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303665 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 assoc_req->assocReqFrame = NULL;
3667 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303668 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3670 }
3671}
3672
3673static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3674{
3675 tpDphHashNode pStaDs;
3676 tSirMacAddr peerMac;
3677 tpSirAddtsReq pSirAddts;
3678 uint32_t timeout;
3679 tpPESession psessionEntry;
3680 uint8_t sessionId; /* PE sessionId */
3681 uint8_t smesessionId;
3682 uint16_t smetransactionId;
3683
3684 if (pMsgBuf == NULL) {
3685 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3686 return;
3687 }
3688
3689 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3690 &smetransactionId);
3691
3692 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3693
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003694 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3695 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696 if (psessionEntry == NULL) {
3697 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3698 return;
3699 }
3700#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3701 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3702 0);
3703#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3704
3705 /* if sta
3706 * - verify assoc state
3707 * - send addts request to ap
3708 * - wait for addts response from ap
3709 * if ap, just ignore with error log
3710 */
3711 PELOG1(lim_log(pMac, LOG1,
3712 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3713 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3714 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3715 )
3716
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003717 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3719 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3720 psessionEntry, pSirAddts->req.tspec,
3721 smesessionId, smetransactionId);
3722 return;
3723 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724
3725 pStaDs =
3726 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3727 &psessionEntry->dph.dphHashTable);
3728
3729 if (pStaDs == NULL) {
3730 PELOGE(lim_log
3731 (pMac, LOGE, "Cannot find AP context for addts req");
3732 )
3733 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3734 psessionEntry, pSirAddts->req.tspec,
3735 smesessionId, smetransactionId);
3736 return;
3737 }
3738
3739 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3740 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3741 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3742 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3743 psessionEntry, pSirAddts->req.tspec,
3744 smesessionId, smetransactionId);
3745 return;
3746 }
3747
3748 pSirAddts->req.wsmTspecPresent = 0;
3749 pSirAddts->req.wmeTspecPresent = 0;
3750 pSirAddts->req.lleTspecPresent = 0;
3751
3752 if ((pStaDs->wsmEnabled) &&
3753 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3754 SIR_MAC_ACCESSPOLICY_EDCA))
3755 pSirAddts->req.wsmTspecPresent = 1;
3756 else if (pStaDs->wmeEnabled)
3757 pSirAddts->req.wmeTspecPresent = 1;
3758 else if (pStaDs->lleEnabled)
3759 pSirAddts->req.lleTspecPresent = 1;
3760 else {
3761 PELOGW(lim_log
3762 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3763 )
3764 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3765 psessionEntry, pSirAddts->req.tspec,
3766 smesessionId, smetransactionId);
3767 return;
3768 }
3769
3770 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3771 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3772 lim_log(pMac, LOGE,
3773 "AddTs received in invalid LIMsme state (%d)",
3774 psessionEntry->limSmeState);
3775 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3776 psessionEntry, pSirAddts->req.tspec,
3777 smesessionId, smetransactionId);
3778 return;
3779 }
3780
3781 if (pMac->lim.gLimAddtsSent) {
3782 lim_log(pMac, LOGE,
3783 "Addts (token %d, tsid %d, up %d) is still pending",
3784 pMac->lim.gLimAddtsReq.req.dialogToken,
3785 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3786 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3787 userPrio);
3788 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3789 psessionEntry, pSirAddts->req.tspec,
3790 smesessionId, smetransactionId);
3791 return;
3792 }
3793
3794 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3795
3796 /* save the addts request */
3797 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303798 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3800
3801 /* ship out the message now */
3802 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3803 psessionEntry);
3804 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3805 /* start a timer to wait for the response */
3806 if (pSirAddts->timeout)
3807 timeout = pSirAddts->timeout;
3808 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3809 eSIR_SUCCESS) {
3810 lim_log(pMac, LOGP,
3811 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3812 WNI_CFG_ADDTS_RSP_TIMEOUT);
3813 return;
3814 }
3815
3816 timeout = SYS_MS_TO_TICKS(timeout);
3817 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3818 != TX_SUCCESS) {
3819 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3820 return;
3821 }
3822 pMac->lim.gLimAddtsRspTimerCount++;
3823 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3824 pMac->lim.gLimAddtsRspTimerCount) !=
3825 TX_SUCCESS) {
3826 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3827 return;
3828 }
3829 MTRACE(mac_trace
3830 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3831 eLIM_ADDTS_RSP_TIMER));
3832
3833 /* add the sessionId to the timer object */
3834 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3835 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3836 TX_SUCCESS) {
3837 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3838 return;
3839 }
3840 return;
3841}
3842
3843static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3844{
3845 tSirMacAddr peerMacAddr;
3846 uint8_t ac;
3847 tSirMacTSInfo *pTsinfo;
3848 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3849 tpDphHashNode pStaDs = NULL;
3850 tpPESession psessionEntry;
3851 uint8_t sessionId;
3852 uint32_t status = eSIR_SUCCESS;
3853 uint8_t smesessionId;
3854 uint16_t smetransactionId;
3855
3856 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3857 &smetransactionId);
3858
3859 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003860 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861 &sessionId);
3862 if (psessionEntry == NULL) {
3863 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3864 status = eSIR_FAILURE;
3865 goto end;
3866 }
3867#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3868 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3869 0);
3870#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3871
3872 if (eSIR_SUCCESS !=
3873 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3874 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3875 status = eSIR_FAILURE;
3876 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3877 smesessionId, smetransactionId);
3878 return;
3879 }
3880
3881 lim_log(pMac, LOG1,
3882 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3883 MAC_ADDRESS_STR),
3884 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3885
3886 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3887 pDeltsReq->req.wmeTspecPresent,
3888 &pDeltsReq->req.tsinfo,
3889 &pDeltsReq->req.tspec, psessionEntry);
3890
3891 pTsinfo =
3892 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3893 tsinfo : &pDeltsReq->req.tsinfo;
3894
3895 /* We've successfully send DELTS frame to AP. Update the
3896 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3897 * is no longer trigger enabled or delivery enabled
3898 */
3899 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3900 pTsinfo, CLEAR_UAPSD_MASK);
3901
3902 /* We're deleting the TSPEC, so this particular AC is no longer
3903 * admitted. PE needs to downgrade the EDCA
3904 * parameters(for the AC for which TS is being deleted) to the
3905 * next best AC for which ACM is not enabled, and send the
3906 * updated values to HAL.
3907 */
3908 ac = upToAc(pTsinfo->traffic.userPrio);
3909
3910 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3911 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3912 ~(1 << ac);
3913 } else if (pTsinfo->traffic.direction ==
3914 SIR_MAC_DIRECTION_DNLINK) {
3915 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3916 ~(1 << ac);
3917 } else if (pTsinfo->traffic.direction ==
3918 SIR_MAC_DIRECTION_BIDIR) {
3919 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3920 ~(1 << ac);
3921 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3922 ~(1 << ac);
3923 }
3924
3925 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3926 psessionEntry);
3927
3928 pStaDs =
3929 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3930 &psessionEntry->dph.dphHashTable);
3931 if (pStaDs != NULL) {
3932 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3933 pStaDs->bssId);
3934 status = eSIR_SUCCESS;
3935 } else {
3936 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3937 status = eSIR_FAILURE;
3938 }
3939#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941#endif
3942
3943 /* send an sme response back */
3944end:
3945 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3946 smesessionId, smetransactionId);
3947}
3948
3949void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3950{
3951 /* fetch the sessionEntry based on the sessionId */
3952 tpPESession psessionEntry;
3953 psessionEntry = pe_find_session_by_session_id(pMac,
3954 pMac->lim.limTimers.gLimAddtsRspTimer.
3955 sessionId);
3956 if (psessionEntry == NULL) {
3957 lim_log(pMac, LOGP,
3958 FL("Session Does not exist for given sessionID"));
3959 return;
3960 }
3961
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003962 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3964 GET_LIM_SYSTEM_ROLE(psessionEntry));
3965 pMac->lim.gLimAddtsSent = false;
3966 return;
3967 }
3968
3969 if (!pMac->lim.gLimAddtsSent) {
3970 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3971 return;
3972 }
3973
3974 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3975 lim_log(pMac, LOGE,
3976 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3977 pMac->lim.gLimAddtsRspTimerCount);
3978 return;
3979 }
3980 /* this a real response timeout */
3981 pMac->lim.gLimAddtsSent = false;
3982 pMac->lim.gLimAddtsRspTimerCount++;
3983
3984 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3985 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3986 psessionEntry->smeSessionId,
3987 psessionEntry->transactionId);
3988}
3989
3990/**
3991 * __lim_process_sme_get_statistics_request()
3992 *
3993 ***FUNCTION:
3994 *
3995 *
3996 ***NOTE:
3997 *
3998 * @param pMac Pointer to Global MAC structure
3999 * @param *pMsgBuf A pointer to the SME message buffer
4000 * @return None
4001 */
4002static void
4003__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4004{
4005 tpAniGetPEStatsReq pPEStatsReq;
4006 tSirMsgQ msgQ;
4007
4008 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4009
4010 msgQ.type = WMA_GET_STATISTICS_REQ;
4011
4012 msgQ.reserved = 0;
4013 msgQ.bodyptr = pMsgBuf;
4014 msgQ.bodyval = 0;
4015 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4016
4017 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304018 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019 pMsgBuf = NULL;
4020 lim_log(pMac, LOGP, "Unable to forward request");
4021 return;
4022 }
4023
4024 return;
4025}
4026
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004027#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004029 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004031 * @pMac: Pointer to Global MAC structure
4032 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004034 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035 */
4036static void
4037__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4038{
4039 tSirMsgQ msgQ;
4040
4041 msgQ.type = WMA_TSM_STATS_REQ;
4042 msgQ.reserved = 0;
4043 msgQ.bodyptr = pMsgBuf;
4044 msgQ.bodyval = 0;
4045 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4046
4047 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304048 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 pMsgBuf = NULL;
4050 lim_log(pMac, LOGP, "Unable to forward request");
4051 return;
4052 }
4053}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004054#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055
4056static void
4057__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4058{
4059 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4060 tpPESession psessionEntry;
4061 uint8_t sessionId; /* PE sessionID */
4062
4063 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4064
4065 if (pMsgBuf == NULL) {
4066 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4067 return;
4068 }
4069
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304070 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 if (NULL == pUpdateAPWPSIEsReq) {
4072 lim_log(pMac, LOGP,
4073 FL
4074 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4075 return;
4076 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304077 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 sizeof(struct sSirUpdateAPWPSIEsReq));
4079
4080 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004081 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 &sessionId);
4083 if (psessionEntry == NULL) {
4084 lim_log(pMac, LOGW,
4085 FL("Session does not exist for given BSSID"));
4086 goto end;
4087 }
4088
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304089 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 sizeof(tSirAPWPSIEs));
4091
4092 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4093 lim_send_beacon_ind(pMac, psessionEntry);
4094
4095end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304096 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 return;
4098}
4099
4100void
4101lim_send_vdev_restart(tpAniSirGlobal pMac,
4102 tpPESession psessionEntry, uint8_t sessionId)
4103{
4104 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4105 tSirMsgQ msgQ;
4106 tSirRetStatus retCode = eSIR_SUCCESS;
4107
4108 if (psessionEntry == NULL) {
4109 PELOGE(lim_log
4110 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4111 __LINE__);
4112 )
4113 return;
4114 }
4115
4116 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304117 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 if (NULL == pHalHiddenSsidVdevRestart) {
4119 PELOGE(lim_log
4120 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4121 __func__, __LINE__);
4122 )
4123 return;
4124 }
4125
4126 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4127 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4128
4129 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4130 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4131 msgQ.bodyval = 0;
4132
4133 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4134 if (eSIR_SUCCESS != retCode) {
4135 PELOGE(lim_log
4136 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4137 __LINE__);
4138 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304139 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 }
4141}
4142
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304143/**
4144 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4145 * @mac_ctx: Pointer to Global MAC structure
4146 * @msg_buf: Pointer to SME message buffer
4147 *
4148 * Return: None
4149 */
4150static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4151 uint32_t *msg_buf)
4152{
4153 tpPESession pe_session;
4154 tSirMsgQ wma_msg;
4155 tSirRetStatus status;
4156 tSirRoamOffloadScanReq *req_buffer;
4157 uint16_t local_ie_len;
4158 uint8_t *local_ie_buf;
4159
4160 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4161 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4162 req_buffer->sessionId);
4163
4164 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4165 if (!local_ie_buf) {
4166 lim_log(mac_ctx, LOGE, FL("Mem Alloc failed for local_ie_buf"));
4167 return;
4168 }
4169
4170 local_ie_len = req_buffer->assoc_ie.length;
4171 /* Update ext cap IE if present */
4172 if (local_ie_len &&
4173 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4174 local_ie_buf, &local_ie_len)) {
4175 req_buffer->assoc_ie.length = local_ie_len;
4176 qdf_mem_copy(req_buffer->assoc_ie.addIEdata, local_ie_buf,
4177 local_ie_len);
4178 }
4179 qdf_mem_free(local_ie_buf);
4180
4181 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4182 wma_msg.bodyptr = req_buffer;
4183
4184 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4185 if (eSIR_SUCCESS != status) {
4186 lim_log(mac_ctx, LOGE,
4187 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4188 qdf_mem_free(req_buffer);
4189 }
4190}
4191
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304192/*
4193 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4194 * @mac_ctx: Pointer to global mac context
4195 * @session: Pointer to PE session
4196 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4197 * 1 - Disable broadcast SSID
4198 *
4199 * Return: None
4200 */
4201static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4202 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304204 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4205 if (ssid_hidden != session->ssidHidden)
4206 session->ssidHidden = ssid_hidden;
4207 else {
4208 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304209 return;
4210 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211
4212 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304213 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214
4215 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304216 sch_set_fixed_beacon_fields(mac_ctx, session);
4217 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218
4219 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304220}
4221
4222/**
4223 * __lim_process_sme_session_update - process SME session update msg
4224 *
4225 * @mac_ctx: Pointer to global mac context
4226 * @msg_buf: Pointer to the received message buffer
4227 *
4228 * Return: None
4229 */
4230static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4231 uint32_t *msg_buf)
4232{
4233 struct sir_update_session_param *msg;
4234 tpPESession session;
4235
4236 if (!msg_buf) {
4237 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4238 return;
4239 }
4240
4241 msg = (struct sir_update_session_param *) msg_buf;
4242
4243 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4244 if (!session) {
4245 lim_log(mac_ctx, LOGW,
4246 "Session does not exist for given sessionId %d",
4247 msg->session_id);
4248 return;
4249 }
4250
4251 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4252 msg->param_type, msg->param_val);
4253 switch (msg->param_type) {
4254 case SIR_PARAM_SSID_HIDDEN:
4255 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4256 break;
4257 default:
4258 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4259 break;
4260 }
4261}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262
4263static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4264{
4265 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4266 tpPESession psessionEntry;
4267 uint8_t sessionId; /* PE sessionID */
4268
4269 if (pMsgBuf == NULL) {
4270 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4271 return;
4272 }
4273
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304274 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 if (NULL == pUpdateAPWPARSNIEsReq) {
4276 lim_log(pMac, LOGP,
4277 FL
4278 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4279 return;
4280 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304281 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4283
4284 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004285 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 &sessionId);
4287 if (psessionEntry == NULL) {
4288 lim_log(pMac, LOGW,
4289 FL("Session does not exist for given BSSID"));
4290 goto end;
4291 }
4292
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304293 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4295
4296 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4297 &psessionEntry->
4298 pLimStartBssReq->rsnIE,
4299 psessionEntry);
4300
4301 psessionEntry->pLimStartBssReq->privacy = 1;
4302 psessionEntry->privacy = 1;
4303
4304 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4305 lim_send_beacon_ind(pMac, psessionEntry);
4306
4307end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304308 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 return;
4310} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4311
4312/*
4313 Update the beacon Interval dynamically if beaconInterval is different in MCC
4314 */
4315static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4316{
4317 tpSirChangeBIParams pChangeBIParams;
4318 tpPESession psessionEntry;
4319 uint8_t sessionId = 0;
4320 tUpdateBeaconParams beaconParams;
4321
4322 PELOG1(lim_log(pMac, LOG1,
4323 FL("received Update Beacon Interval message"));
4324 );
4325
4326 if (pMsgBuf == NULL) {
4327 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4328 return;
4329 }
4330
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304331 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4333
4334 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004335 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 &sessionId);
4337 if (psessionEntry == NULL) {
4338 lim_log(pMac, LOGE,
4339 FL("Session does not exist for given BSSID"));
4340 return;
4341 }
4342
4343 /*Update sessionEntry Beacon Interval */
4344 if (psessionEntry->beaconParams.beaconInterval !=
4345 pChangeBIParams->beaconInterval) {
4346 psessionEntry->beaconParams.beaconInterval =
4347 pChangeBIParams->beaconInterval;
4348 }
4349
4350 /*Update sch beaconInterval */
4351 if (pMac->sch.schObject.gSchBeaconInterval !=
4352 pChangeBIParams->beaconInterval) {
4353 pMac->sch.schObject.gSchBeaconInterval =
4354 pChangeBIParams->beaconInterval;
4355
4356 PELOG1(lim_log(pMac, LOG1,
4357 FL
4358 ("LIM send update BeaconInterval Indication : %d"),
4359 pChangeBIParams->beaconInterval);
4360 );
4361
4362 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4363 /* Update beacon */
4364 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4365
4366 beaconParams.bssIdx = psessionEntry->bssIdx;
4367 /* Set change in beacon Interval */
4368 beaconParams.beaconInterval =
4369 pChangeBIParams->beaconInterval;
4370 beaconParams.paramChangeBitmap =
4371 PARAM_BCN_INTERVAL_CHANGED;
4372 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4373 }
4374 }
4375
4376 return;
4377} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4378
4379#ifdef QCA_HT_2040_COEX
4380static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4381 uint32_t *pMsgBuf)
4382{
4383 tpSirSetHT2040Mode pSetHT2040Mode;
4384 tpPESession psessionEntry;
4385 uint8_t sessionId = 0;
4386 cds_msg_t msg;
4387 tUpdateVHTOpMode *pHtOpMode = NULL;
4388 uint16_t staId = 0;
4389 tpDphHashNode pStaDs = NULL;
4390
4391 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4392 if (pMsgBuf == NULL) {
4393 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4394 return;
4395 }
4396
4397 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4398
4399 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004400 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 &sessionId);
4402 if (psessionEntry == NULL) {
4403 lim_log(pMac, LOG1,
4404 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004405 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 return;
4407 }
4408
4409 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4410 pSetHT2040Mode->cbMode);
4411 /*Update sessionEntry HT related fields */
4412 switch (pSetHT2040Mode->cbMode) {
4413 case PHY_SINGLE_CHANNEL_CENTERED:
4414 psessionEntry->htSecondaryChannelOffset =
4415 PHY_SINGLE_CHANNEL_CENTERED;
4416 psessionEntry->htRecommendedTxWidthSet = 0;
4417 if (pSetHT2040Mode->obssEnabled)
4418 psessionEntry->htSupportedChannelWidthSet
4419 = eHT_CHANNEL_WIDTH_40MHZ;
4420 else
4421 psessionEntry->htSupportedChannelWidthSet
4422 = eHT_CHANNEL_WIDTH_20MHZ;
4423 break;
4424 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4425 psessionEntry->htSecondaryChannelOffset =
4426 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4427 psessionEntry->htRecommendedTxWidthSet = 1;
4428 break;
4429 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4430 psessionEntry->htSecondaryChannelOffset =
4431 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4432 psessionEntry->htRecommendedTxWidthSet = 1;
4433 break;
4434 default:
4435 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4436 return;
4437 }
4438
4439 /* Update beacon */
4440 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4441 lim_send_beacon_ind(pMac, psessionEntry);
4442
4443 /* update OP Mode for each associated peer */
4444 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4445 pStaDs = dph_get_hash_entry(pMac, staId,
4446 &psessionEntry->dph.dphHashTable);
4447 if (NULL == pStaDs)
4448 continue;
4449
4450 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304451 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 if (NULL == pHtOpMode) {
4453 lim_log(pMac, LOGE,
4454 FL
4455 ("%s: Not able to allocate memory for setting OP mode"),
4456 __func__);
4457 return;
4458 }
4459 pHtOpMode->opMode =
4460 (psessionEntry->htSecondaryChannelOffset ==
4461 PHY_SINGLE_CHANNEL_CENTERED) ?
4462 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4463 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304464 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 sizeof(tSirMacAddr));
4466 pHtOpMode->smesessionId = sessionId;
4467
4468 msg.type = WMA_UPDATE_OP_MODE;
4469 msg.reserved = 0;
4470 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304471 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304472 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 lim_log(pMac, LOGE,
4474 FL
4475 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4476 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304477 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 return;
4479 }
4480 lim_log(pMac, LOG1,
4481 FL
4482 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4483 __func__, pHtOpMode->opMode, staId);
4484
4485 } else
4486 lim_log(pMac, LOG1,
4487 FL("%s: station %d does not support HT40\n"),
4488 __func__, staId);
4489 }
4490
4491 return;
4492}
4493#endif
4494
4495/* -------------------------------------------------------------------- */
4496/**
4497 * __lim_process_report_message
4498 *
4499 * FUNCTION: Processes the next received Radio Resource Management message
4500 *
4501 * LOGIC:
4502 *
4503 * ASSUMPTIONS:
4504 *
4505 * NOTE:
4506 *
4507 * @param None
4508 * @return None
4509 */
4510
4511void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4512{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 switch (pMsg->type) {
4514 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4515 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4516 break;
4517 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004519 break;
4520 default:
4521 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523}
4524
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525/* -------------------------------------------------------------------- */
4526/**
4527 * lim_send_set_max_tx_power_req
4528 *
4529 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4530 *
4531 * LOGIC:
4532 *
4533 * ASSUMPTIONS:
4534 *
4535 * NOTE:
4536 *
4537 * @param txPower txPower to be set.
4538 * @param pSessionEntry session entry.
4539 * @return None
4540 */
4541tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004542lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 tpPESession pSessionEntry)
4544{
4545 tpMaxTxPowerParams pMaxTxParams = NULL;
4546 tSirRetStatus retCode = eSIR_SUCCESS;
4547 tSirMsgQ msgQ;
4548
4549 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304550 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 return eSIR_FAILURE;
4552 }
4553
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304554 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 if (NULL == pMaxTxParams) {
4556 lim_log(pMac, LOGP,
4557 FL("Unable to allocate memory for pMaxTxParams "));
4558 return eSIR_MEM_ALLOC_FAILED;
4559
4560 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304562 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304563 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304564 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004565 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304566 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567
4568 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4569 msgQ.bodyptr = pMaxTxParams;
4570 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304571 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4573 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4574 if (eSIR_SUCCESS != retCode) {
4575 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304576 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 }
4578 return retCode;
4579}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580
4581/**
4582 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4583 *
4584 * @mac_ctx: Pointer to Global MAC structure
4585 * @msg_buf: pointer to the SME message buffer
4586 *
4587 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4588 * from SME. It Register this information within PE.
4589 *
4590 * Return: None
4591 */
4592static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4593 uint32_t *msg_buf)
4594{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304595 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4597 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4598 struct mgmt_frm_reg_info *next = NULL;
4599 bool match = false;
4600
4601 lim_log(mac_ctx, LOG1, FL(
4602 "registerFrame %d, frameType %d, matchLen %d"),
4603 sme_req->registerFrame, sme_req->frameType,
4604 sme_req->matchLen);
4605 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304606 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304607 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4608 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304609 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610
4611 while (lim_mgmt_regn != NULL) {
4612 if (lim_mgmt_regn->frameType != sme_req->frameType)
4613 goto skip_match;
4614 if (sme_req->matchLen) {
4615 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304616 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 sme_req->matchData,
4618 lim_mgmt_regn->matchLen))) {
4619 /* found match! */
4620 match = true;
4621 break;
4622 }
4623 } else {
4624 /* found match! */
4625 match = true;
4626 break;
4627 }
4628skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304629 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304630 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304632 (qdf_list_node_t *)lim_mgmt_regn,
4633 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304634 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 lim_mgmt_regn = next;
4636 next = NULL;
4637 }
4638 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304639 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304640 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304642 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304643 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304644 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 }
4646
4647 if (sme_req->registerFrame) {
4648 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304649 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 sme_req->matchLen);
4651 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304652 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 sizeof(struct mgmt_frm_reg_info) +
4654 sme_req->matchLen, 0);
4655 lim_mgmt_regn->frameType = sme_req->frameType;
4656 lim_mgmt_regn->matchLen = sme_req->matchLen;
4657 lim_mgmt_regn->sessionId = sme_req->sessionId;
4658 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304659 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 sme_req->matchData,
4661 sme_req->matchLen);
4662 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304663 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304665 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 gLimMgmtFrameRegistratinQueue,
4667 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304668 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 &mac_ctx->lim.lim_frame_register_lock);
4670 }
4671 }
4672 return;
4673}
4674
4675static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4676{
4677 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4678 pMac->lim.gDeferMsgTypeForNOA);
4679 pMac->lim.gDeferMsgTypeForNOA = 0;
4680 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4681 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304682 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004683 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4684 }
4685}
4686
4687/**
4688 * lim_process_regd_defd_sme_req_after_noa_start()
4689 *
4690 * mac_ctx: Pointer to Global MAC structure
4691 *
4692 * This function is called to process deferred sme req message
4693 * after noa start.
4694 *
4695 * Return: None
4696 */
4697void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4698{
4699 bool buf_consumed = true;
4700
4701 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4702 mac_ctx->lim.gDeferMsgTypeForNOA);
4703
4704 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4705 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4706 lim_log(mac_ctx, LOGW,
4707 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4708 lim_log(mac_ctx, LOGW,
4709 FL("It may happen when NOA start ind and timeout happen at the same time"));
4710 return;
4711 }
4712 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4713 case eWNI_SME_SCAN_REQ:
4714 __lim_process_sme_scan_req(mac_ctx,
4715 mac_ctx->lim.gpDefdSmeMsgForNOA);
4716 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4718 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4719 mac_ctx->lim.gpDefdSmeMsgForNOA);
4720 /*
4721 * lim_process_remain_on_chnl_req doesnt want us to free
4722 * the buffer since it is freed in lim_remain_on_chn_rsp.
4723 * this change is to avoid "double free"
4724 */
4725 if (false == buf_consumed)
4726 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4727 break;
4728 case eWNI_SME_JOIN_REQ:
4729 __lim_process_sme_join_req(mac_ctx,
4730 mac_ctx->lim.gpDefdSmeMsgForNOA);
4731 break;
4732 default:
4733 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4734 mac_ctx->lim.gDeferMsgTypeForNOA);
4735 break;
4736 }
4737 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4738}
4739
4740static void
4741__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4742{
4743 tpSirResetAPCapsChange pResetCapsChange;
4744 tpPESession psessionEntry;
4745 uint8_t sessionId = 0;
4746 if (pMsgBuf == NULL) {
4747 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4748 return;
4749 }
4750
4751 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4752 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004753 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4754 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755 if (psessionEntry == NULL) {
4756 lim_log(pMac, LOGE,
4757 FL("Session does not exist for given BSSID"));
4758 return;
4759 }
4760
4761 psessionEntry->limSentCapsChangeNtf = false;
4762 return;
4763}
4764
4765/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304766 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4767 * @mac_ctx: Mac pointer
4768 * @msg_buf: Msg pointer containing the callback
4769 *
4770 * This function is used to save the p2p ack indication callback in PE.
4771 *
4772 * Return: None
4773 */
4774static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4775 uint32_t *msg_buf)
4776{
4777 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4778 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4779
4780 if (NULL == msg_buf) {
4781 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4782 return;
4783 }
4784 if (sme_req->callback)
4785 mac_ctx->p2p_ack_ind_cb =
4786 sme_req->callback;
4787 else
4788 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4789}
4790
4791/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304792 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4793 * indication callback in PE.
4794 * @mac_ptr: Mac pointer
4795 * @msg_buf: Msg pointer containing the callback
4796 *
4797 * This function is used save the Management frame
4798 * indication callback in PE.
4799 *
4800 * Return: None
4801 */
4802static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4803 uint32_t *msg_buf)
4804{
4805 struct sir_sme_mgmt_frame_cb_req *sme_req =
4806 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4807
4808 if (NULL == msg_buf) {
4809 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4810 return;
4811 }
4812 if (sme_req->callback)
4813 mac_ctx->mgmt_frame_ind_cb =
4814 (sir_mgmt_frame_ind_callback)sme_req->callback;
4815 else
4816 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4817}
4818
4819/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304820 *__lim_process_send_disassoc_frame: function processes disassoc frame
4821 * @mac_ctx: pointer to mac context
4822 * @msg_buf: message buffer
4823 *
4824 * function processes disassoc request received from SME
4825 *
4826 * return: none
4827 */
4828static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4829 uint32_t *msg_buf)
4830{
4831 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4832 tSirRetStatus status;
4833 tpPESession session_entry = NULL;
4834 uint8_t sme_session_id;
4835 uint16_t sme_trans_id;
4836
4837 if (msg_buf == NULL) {
4838 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4839 return;
4840 }
4841
4842 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4843 &sme_trans_id);
4844
4845 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4846 &sme_send_disassoc_frame_req,
4847 (uint8_t *)msg_buf);
4848
4849 if ((eSIR_FAILURE == status) ||
4850 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4851 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4852 PELOGE(lim_log(mac_ctx, LOGE,
4853 FL("received invalid SME_DISASSOC_REQ message"));)
4854 return;
4855 }
4856
4857 session_entry = pe_find_session_by_sme_session_id(
4858 mac_ctx, sme_session_id);
4859 if (session_entry == NULL) {
4860 lim_log(mac_ctx, LOGE,
4861 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4862 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4863 return;
4864 }
4865
4866 lim_log(mac_ctx, LOG1,
4867 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4868 sme_send_disassoc_frame_req.msg_type,
4869 sme_send_disassoc_frame_req.length,
4870 sme_send_disassoc_frame_req.session_id,
4871 sme_send_disassoc_frame_req.trans_id,
4872 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4873 sme_send_disassoc_frame_req.reason,
4874 sme_send_disassoc_frame_req.wait_for_ack);
4875
4876 lim_send_disassoc_mgmt_frame(mac_ctx,
4877 sme_send_disassoc_frame_req.reason,
4878 sme_send_disassoc_frame_req.peer_mac,
4879 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4880}
4881
4882/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004883 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4884 * @mac_ctx: Pointer to Global MAC structure
4885 * @pdev_id: pdev id to set the IE.
4886 * @nss: Nss values to prepare the HT IE.
4887 *
4888 * Prepares the HT IE with self capabilities for different
4889 * Nss values and sends the set HT IE req to FW.
4890 *
4891 * Return: None
4892 */
4893static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4894 uint8_t nss)
4895{
4896 struct set_ie_param *ie_params;
4897 tSirMsgQ msg;
4898 tSirRetStatus rc = eSIR_SUCCESS;
4899 uint8_t *p_ie = NULL;
4900 tHtCaps *p_ht_cap;
4901 int i;
4902
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004903 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004904 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4905 if (NULL == ie_params) {
4906 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4907 return;
4908 }
4909 ie_params->nss = i;
4910 ie_params->pdev_id = pdev_id;
4911 ie_params->ie_type = DOT11_HT_IE;
4912 /* 2 for IE len and EID */
4913 ie_params->ie_len = 2 + sizeof(tHtCaps);
4914 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4915 if (NULL == ie_params->ie_ptr) {
4916 qdf_mem_free(ie_params);
4917 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4918 return;
4919 }
4920 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4921 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4922 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4923 ie_params->ie_len);
4924
4925 if (NSS_1x1_MODE == i) {
4926 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4927 ie_params->ie_len,
4928 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004929 if (NULL == p_ie) {
4930 qdf_mem_free(ie_params->ie_ptr);
4931 qdf_mem_free(ie_params);
4932 lim_log(mac_ctx, LOGE,
4933 FL("failed to get IE ptr"));
4934 return;
4935 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004936 p_ht_cap = (tHtCaps *)&p_ie[2];
4937 p_ht_cap->supportedMCSSet[1] = 0;
4938 p_ht_cap->txSTBC = 0;
4939 }
4940
4941 msg.type = WMA_SET_PDEV_IE_REQ;
4942 msg.bodyptr = ie_params;
4943 msg.bodyval = 0;
4944
4945 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4946 if (rc != eSIR_SUCCESS) {
4947 lim_log(mac_ctx, LOGE,
4948 FL("wma_post_ctrl_msg() return failure"));
4949 qdf_mem_free(ie_params->ie_ptr);
4950 qdf_mem_free(ie_params);
4951 return;
4952 }
4953 }
4954}
4955
4956/**
4957 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4958 * @mac_ctx: Pointer to Global MAC structure
4959 * @pdev_id: pdev id to set the IE.
4960 * @nss: Nss values to prepare the VHT IE.
4961 *
4962 * Prepares the VHT IE with self capabilities for different
4963 * Nss values and sends the set VHT IE req to FW.
4964 *
4965 * Return: None
4966 */
4967static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4968 uint8_t nss)
4969{
4970 struct set_ie_param *ie_params;
4971 tSirMsgQ msg;
4972 tSirRetStatus rc = eSIR_SUCCESS;
4973 uint8_t *p_ie = NULL;
4974 tSirMacVHTCapabilityInfo *vht_cap;
4975 int i;
4976 tSirVhtMcsInfo *vht_mcs;
4977
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004978 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004979 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4980 if (NULL == ie_params) {
4981 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4982 return;
4983 }
4984 ie_params->nss = i;
4985 ie_params->pdev_id = pdev_id;
4986 ie_params->ie_type = DOT11_VHT_IE;
4987 /* 2 for IE len and EID */
4988 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4989 sizeof(tSirVhtMcsInfo);
4990 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4991 if (NULL == ie_params->ie_ptr) {
4992 qdf_mem_free(ie_params);
4993 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4994 return;
4995 }
4996 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4997 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4998 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4999 ie_params->ie_len);
5000
5001 if (NSS_1x1_MODE == i) {
5002 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
5003 ie_params->ie_len,
5004 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07005005 if (NULL == p_ie) {
5006 qdf_mem_free(ie_params->ie_ptr);
5007 qdf_mem_free(ie_params);
5008 lim_log(mac_ctx, LOGE,
5009 FL("failed to get IE ptr"));
5010 return;
5011 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005012 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
5013 vht_cap->txSTBC = 0;
5014 vht_mcs =
5015 (tSirVhtMcsInfo *)&p_ie[2 +
5016 sizeof(tSirMacVHTCapabilityInfo)];
5017 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5018 vht_mcs->rxHighest =
5019 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5020 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5021 vht_mcs->txHighest =
5022 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5023 }
5024 msg.type = WMA_SET_PDEV_IE_REQ;
5025 msg.bodyptr = ie_params;
5026 msg.bodyval = 0;
5027
5028 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5029 if (rc != eSIR_SUCCESS) {
5030 lim_log(mac_ctx, LOGE,
5031 FL("wma_post_ctrl_msg failure"));
5032 qdf_mem_free(ie_params->ie_ptr);
5033 qdf_mem_free(ie_params);
5034 return;
5035 }
5036 }
5037}
5038
5039/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005040 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5041 * @mac_ctx: Pointer to Global MAC structure
5042 * @msg_buf: Pointer to the SME message buffer
5043 *
5044 * This function is called by limProcessMessageQueue(). This function sets the
5045 * VDEV IEs to the FW.
5046 *
5047 * Return: None
5048 */
5049static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5050 uint32_t *msg_buf)
5051{
5052 struct sir_set_vdev_ies_per_band *p_msg =
5053 (struct sir_set_vdev_ies_per_band *)msg_buf;
5054
5055 if (NULL == p_msg) {
5056 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5057 return;
5058 }
5059
5060 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5061 p_msg->vdev_id);
5062 /* intentionally using NULL here so that self capabilty are sent */
5063 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5064 QDF_STATUS_SUCCESS)
5065 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5066}
5067
5068/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005069 * lim_process_set_pdev_IEs() - process the set pdev IE req
5070 * @mac_ctx: Pointer to Global MAC structure
5071 * @msg_buf: Pointer to the SME message buffer
5072 *
5073 * This function is called by limProcessMessageQueue(). This
5074 * function sets the PDEV IEs to the FW.
5075 *
5076 * Return: None
5077 */
5078static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5079{
5080 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5081
5082 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5083
5084 if (NULL == ht_vht_cfg) {
5085 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5086 return;
5087 }
5088
5089 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5090 ht_vht_cfg->nss);
5091 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5092
5093 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5094 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5095 ht_vht_cfg->nss);
5096}
5097
5098/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305099 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5100 *
5101 * access policy
5102 * @mac_ctx: pointer to mac context
5103 * @msg: message buffer
5104 *
5105 * function processes vendor IE and access policy from SME and updates PE
5106 *
5107 * session entry
5108 *
5109 * return: none
5110*/
5111static void lim_process_sme_update_access_policy_vendor_ie(
5112 tpAniSirGlobal mac_ctx,
5113 uint32_t *msg)
5114{
5115 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5116 struct sPESession *pe_session_entry;
5117 uint8_t num_bytes;
5118
5119 if (!msg) {
5120 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5121 return;
5122 }
5123 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5124 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5125 update_vendor_ie->sme_session_id);
5126
5127 if (!pe_session_entry) {
5128 lim_log(mac_ctx, LOGE,
5129 FL("Session does not exist for given sme session id(%hu)"),
5130 update_vendor_ie->sme_session_id);
5131 return;
5132 }
5133 if (pe_session_entry->access_policy_vendor_ie)
5134 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5135
5136 num_bytes = update_vendor_ie->ie[1] + 2;
5137 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5138
5139 if (!pe_session_entry->access_policy_vendor_ie) {
5140 lim_log(mac_ctx, LOGE,
5141 FL("Failed to allocate memory for vendor ie"));
5142 return;
5143 }
5144 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5145 &update_vendor_ie->ie[0], num_bytes);
5146
5147 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5148}
5149
5150/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 * lim_process_sme_req_messages()
5152 *
5153 ***FUNCTION:
5154 * This function is called by limProcessMessageQueue(). This
5155 * function processes SME request messages from HDD or upper layer
5156 * application.
5157 *
5158 ***LOGIC:
5159 *
5160 ***ASSUMPTIONS:
5161 *
5162 ***NOTE:
5163 *
5164 * @param pMac Pointer to Global MAC structure
5165 * @param msgType Indicates the SME message type
5166 * @param *pMsgBuf A pointer to the SME message buffer
5167 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5168 * false - if pMsgBuf is not to be freed.
5169 */
5170
5171bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5172{
5173 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5174 uint32_t *pMsgBuf = pMsg->bodyptr;
5175 tpSirSmeScanReq pScanReq;
5176 PELOG1(lim_log
5177 (pMac, LOG1,
5178 FL
5179 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5180 lim_msg_str(pMsg->type), pMsg->type,
5181 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5182 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5183 )
5184
5185 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5186 /* If no insert NOA required then execute the code below */
5187
5188 switch (pMsg->type) {
5189 case eWNI_SME_SYS_READY_IND:
5190 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5191 break;
5192
5193 case eWNI_SME_START_BSS_REQ:
5194 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5195 break;
5196
5197 case eWNI_SME_SCAN_REQ:
5198 __lim_process_sme_scan_req(pMac, pMsgBuf);
5199 break;
5200
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5202 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5203 break;
5204
5205 case eWNI_SME_UPDATE_NOA:
5206 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5207 break;
5208 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5209 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5210 break;
5211 case eWNI_SME_JOIN_REQ:
5212 __lim_process_sme_join_req(pMac, pMsgBuf);
5213 break;
5214
5215 case eWNI_SME_REASSOC_REQ:
5216 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5217 break;
5218
5219 case eWNI_SME_DISASSOC_REQ:
5220 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5221 break;
5222
5223 case eWNI_SME_DISASSOC_CNF:
5224 case eWNI_SME_DEAUTH_CNF:
5225 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5226 break;
5227
5228 case eWNI_SME_DEAUTH_REQ:
5229 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5230 break;
5231
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305232 case eWNI_SME_SEND_DISASSOC_FRAME:
5233 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5234 break;
5235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005236 case eWNI_SME_SETCONTEXT_REQ:
5237 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5238 break;
5239
5240 case eWNI_SME_STOP_BSS_REQ:
5241 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5242 break;
5243
5244 case eWNI_SME_ASSOC_CNF:
5245 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5246 PELOG1(lim_log(pMac,
5247 LOG1, FL("Received ASSOC_CNF message"));)
5248 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5249 pMsgBuf);
5250 break;
5251
5252 case eWNI_SME_ADDTS_REQ:
5253 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5254 __lim_process_sme_addts_req(pMac, pMsgBuf);
5255 break;
5256
5257 case eWNI_SME_DELTS_REQ:
5258 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5259 __lim_process_sme_delts_req(pMac, pMsgBuf);
5260 break;
5261
5262 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5263 PELOG1(lim_log
5264 (pMac, LOG1,
5265 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5266 )
5267 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5268 break;
5269
5270 case eWNI_SME_GET_STATISTICS_REQ:
5271 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5272 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5273 bufConsumed = false;
5274 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005275#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276 case eWNI_SME_GET_TSM_STATS_REQ:
5277 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5278 bufConsumed = false;
5279 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005280#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281 case eWNI_SME_GET_ASSOC_STAS_REQ:
5282 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5283 break;
5284 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5285 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5286 break;
5287
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305288 case eWNI_SME_SESSION_UPDATE_PARAM:
5289 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305291 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5292 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5293 bufConsumed = false;
5294 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 case eWNI_SME_UPDATE_APWPSIE_REQ:
5296 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5297 break;
5298 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5299 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5300 break;
5301
5302 case eWNI_SME_SET_APWPARSNIEs_REQ:
5303 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5304 break;
5305
5306 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5307 /* Update the beaconInterval */
5308 __lim_process_sme_change_bi(pMac, pMsgBuf);
5309 break;
5310
5311#ifdef QCA_HT_2040_COEX
5312 case eWNI_SME_SET_HT_2040_MODE:
5313 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5314 break;
5315#endif
5316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5318 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5319 __lim_process_report_message(pMac, pMsg);
5320 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 case eWNI_SME_FT_PRE_AUTH_REQ:
5323 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5324 break;
5325 case eWNI_SME_FT_UPDATE_KEY:
5326 lim_process_ft_update_key(pMac, pMsgBuf);
5327 break;
5328
5329 case eWNI_SME_FT_AGGR_QOS_REQ:
5330 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5331 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332
5333 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5334 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5335 break;
5336#ifdef FEATURE_WLAN_TDLS
5337 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5338 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5339 break;
5340 case eWNI_SME_TDLS_ADD_STA_REQ:
5341 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5342 break;
5343 case eWNI_SME_TDLS_DEL_STA_REQ:
5344 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5345 break;
5346 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5347 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5348 break;
5349#endif
5350 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5351 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5352 break;
5353
5354 case eWNI_SME_CHANNEL_CHANGE_REQ:
5355 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5356 break;
5357
5358 case eWNI_SME_START_BEACON_REQ:
5359 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5360 break;
5361
5362 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5363 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5364 break;
5365
5366 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5367 lim_process_update_add_ies(pMac, pMsgBuf);
5368 break;
5369
5370 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5371 lim_process_modify_add_ies(pMac, pMsgBuf);
5372 break;
5373 case eWNI_SME_SET_HW_MODE_REQ:
5374 lim_process_set_hw_mode(pMac, pMsgBuf);
5375 break;
5376 case eWNI_SME_NSS_UPDATE_REQ:
5377 lim_process_nss_update_request(pMac, pMsgBuf);
5378 break;
5379 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5380 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5381 break;
5382 case eWNI_SME_SET_IE_REQ:
5383 lim_process_set_ie_req(pMac, pMsgBuf);
5384 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305385 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5386 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5387 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305388 case eWNI_SME_EXT_CHANGE_CHANNEL:
5389 lim_process_ext_change_channel(pMac, pMsgBuf);
5390 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005391 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5392 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5393 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005394 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5395 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005396 break;
5397 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5398 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5399 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005400 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005401 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005402 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005403 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005404 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305405 case eWNI_SME_REGISTER_P2P_ACK_CB:
5406 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5407 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305408 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5409 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5410 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005411 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305412 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 pMsg->bodyptr = NULL;
5414 break;
5415 } /* switch (msgType) */
5416
5417 return bufConsumed;
5418} /*** end lim_process_sme_req_messages() ***/
5419
5420/**
5421 * lim_process_sme_start_beacon_req()
5422 *
5423 ***FUNCTION:
5424 * This function is called by limProcessMessageQueue(). This
5425 * function processes SME request messages from HDD or upper layer
5426 * application.
5427 *
5428 ***LOGIC:
5429 *
5430 ***ASSUMPTIONS:
5431 *
5432 ***NOTE:
5433 *
5434 * @param pMac Pointer to Global MAC structure
5435 * @param msgType Indicates the SME message type
5436 * @param *pMsgBuf A pointer to the SME message buffer
5437 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5438 * false - if pMsgBuf is not to be freed.
5439 */
5440static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5441{
5442 tpSirStartBeaconIndication pBeaconStartInd;
5443 tpPESession psessionEntry;
5444 uint8_t sessionId; /* PE sessionID */
5445
5446 if (pMsg == NULL) {
5447 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5448 return;
5449 }
5450
5451 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5452 psessionEntry = pe_find_session_by_bssid(pMac,
5453 pBeaconStartInd->bssid,
5454 &sessionId);
5455 if (psessionEntry == NULL) {
5456 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5457 lim_log(pMac, LOGE,
5458 FL("Session does not exist for given bssId"));
5459 return;
5460 }
5461
5462 if (pBeaconStartInd->beaconStartStatus == true) {
5463 /*
5464 * Currently this Indication comes from SAP
5465 * to start Beacon Tx on a DFS channel
5466 * since beaconing has to be done on DFS
5467 * channel only after CAC WAIT is completed.
5468 * On a DFS Channel LIM does not start beacon
5469 * Tx right after the WMA_ADD_BSS_RSP.
5470 */
5471 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305472 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005473 FL("Start Beacon with ssid %s Ch %d"),
5474 psessionEntry->ssId.ssId,
5475 psessionEntry->currentOperChannel);
5476 lim_send_beacon_ind(pMac, psessionEntry);
5477 } else {
5478 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5479 return;
5480 }
5481}
5482
5483/**
5484 * lim_process_sme_channel_change_request() - process sme ch change req
5485 *
5486 * @mac_ctx: Pointer to Global MAC structure
5487 * @msg_buf: pointer to the SME message buffer
5488 *
5489 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5490 *
5491 * Return: None
5492 */
5493static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5494 uint32_t *msg_buf)
5495{
5496 tpSirChanChangeRequest ch_change_req;
5497 tpPESession session_entry;
5498 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005499 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500 uint32_t val = 0;
5501
5502 if (msg_buf == NULL) {
5503 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5504 return;
5505 }
5506 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5507
5508 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5509 ch_change_req->targetChannel);
5510
5511 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5512 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5513 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5514 return;
5515 }
5516
5517 session_entry = pe_find_session_by_bssid(mac_ctx,
5518 ch_change_req->bssid, &session_id);
5519 if (session_entry == NULL) {
5520 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5521 lim_log(mac_ctx, LOGE, FL(
5522 "Session does not exist for given bssId"));
5523 return;
5524 }
5525
5526 if (session_entry->currentOperChannel ==
5527 ch_change_req->targetChannel) {
5528 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5529 return;
5530 }
5531
5532 if (LIM_IS_AP_ROLE(session_entry))
5533 session_entry->channelChangeReasonCode =
5534 LIM_SWITCH_CHANNEL_SAP_DFS;
5535 else
5536 session_entry->channelChangeReasonCode =
5537 LIM_SWITCH_CHANNEL_OPERATION;
5538
5539 lim_log(mac_ctx, LOGW, FL(
5540 "switch old chnl %d to new chnl %d, ch_bw %d"),
5541 session_entry->currentOperChannel,
5542 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005543 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544
5545 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005546 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005547 session_entry->ch_center_freq_seg0 =
5548 ch_change_req->center_freq_seg_0;
5549 session_entry->ch_center_freq_seg1 =
5550 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005551 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005553 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 session_entry->htRecommendedTxWidthSet =
5555 session_entry->htSupportedChannelWidthSet;
5556 session_entry->currentOperChannel =
5557 ch_change_req->targetChannel;
5558 session_entry->limRFBand =
5559 lim_get_rf_band(session_entry->currentOperChannel);
5560 /* Initialize 11h Enable Flag */
5561 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5562 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5563 eSIR_SUCCESS)
5564 lim_log(mac_ctx, LOGP,
5565 FL("Fail to get WNI_CFG_11H_ENABLED"));
5566 }
5567
5568 session_entry->lim11hEnable = val;
5569 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305570 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571 &ch_change_req->operational_rateset,
5572 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305573 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 &ch_change_req->extended_rateset,
5575 sizeof(session_entry->extRateSet));
5576 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5577 session_entry->ch_center_freq_seg0,
5578 session_entry->ch_center_freq_seg1,
5579 session_entry->ch_width,
5580 max_tx_pwr, session_entry->peSessionId);
5581}
5582
5583/******************************************************************************
5584* lim_start_bss_update_add_ie_buffer()
5585*
5586***FUNCTION:
5587* This function checks the src buffer and its length and then malloc for
5588* dst buffer update the same
5589*
5590***LOGIC:
5591*
5592***ASSUMPTIONS:
5593*
5594***NOTE:
5595*
5596* @param pMac Pointer to Global MAC structure
5597* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5598* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5599* @param *pSrcData_buff A pointer of uint8_t src buffer
5600* @param srcDataLen src buffer length
5601******************************************************************************/
5602
5603static void
5604lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5605 uint8_t **pDstData_buff,
5606 uint16_t *pDstDataLen,
5607 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5608{
5609
5610 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5611 *pDstDataLen = srcDataLen;
5612
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305613 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005614
5615 if (NULL == *pDstData_buff) {
5616 lim_log(pMac, LOGE,
5617 FL("AllocateMemory failed for pDstData_buff"));
5618 return;
5619 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305620 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 } else {
5622 *pDstData_buff = NULL;
5623 *pDstDataLen = 0;
5624 }
5625}
5626
5627/******************************************************************************
5628* lim_update_add_ie_buffer()
5629*
5630***FUNCTION:
5631* This function checks the src buffer and length if src buffer length more
5632* than dst buffer length then free the dst buffer and malloc for the new src
5633* length, and update the dst buffer and length. But if dst buffer is bigger
5634* than src buffer length then it just update the dst buffer and length
5635*
5636***LOGIC:
5637*
5638***ASSUMPTIONS:
5639*
5640***NOTE:
5641*
5642* @param pMac Pointer to Global MAC structure
5643* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5644* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5645* @param *pSrcData_buff A pointer of uint8_t src buffer
5646* @param srcDataLen src buffer length
5647******************************************************************************/
5648
5649static void
5650lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5651 uint8_t **pDstData_buff,
5652 uint16_t *pDstDataLen,
5653 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5654{
5655
5656 if (NULL == pSrcData_buff) {
5657 lim_log(pMac, LOGE, FL("src buffer is null."));
5658 return;
5659 }
5660
5661 if (srcDataLen > *pDstDataLen) {
5662 *pDstDataLen = srcDataLen;
5663 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305664 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305666 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667
5668 if (NULL == *pDstData_buff) {
5669 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5670 *pDstDataLen = 0;
5671 return;
5672 }
5673 }
5674
5675 /* copy the content of buffer into dst buffer
5676 */
5677 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305678 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679
5680}
5681
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005682/**
5683 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5684 * @pMac : Pointer to Global MAC structure
5685 * @pDstData_buff : A pointer to pointer of dst buffer
5686 * @pDstDataLen : A pointer to pointer of dst buffer length
5687 * @pModifyIE : A pointer to tSirModifyIE
5688 *
5689 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5690 *
5691 * Return:
5692 * True or false depending upon whether IE is updated or not
5693 */
5694static bool
5695lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5696 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5697{
5698 int32_t oui_length;
5699 uint8_t *ibss_ie = NULL;
5700
5701 ibss_ie = pModifyIE->pIEBuffer;
5702 oui_length = pModifyIE->oui_length;
5703
5704 if ((0 == oui_length) || (NULL == ibss_ie)) {
5705 PELOGE(lim_log(pMac, LOGE,
5706 FL("Invalid set IBSS vendor IE command length %d "),
5707 oui_length);)
5708 return false;
5709 }
5710
5711 lim_update_add_ie_buffer(pMac,
5712 pDstData_buff,
5713 pDstDataLen,
5714 pModifyIE->pIEBuffer,
5715 pModifyIE->ieBufferlength);
5716
5717 return true;
5718}
5719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720/*
5721* lim_process_modify_add_ies() - process modify additional IE req.
5722*
5723* @mac_ctx: Pointer to Global MAC structure
5724* @msg_buf: pointer to the SME message buffer
5725*
5726* This function update the PE buffers for additional IEs.
5727*
5728* Return: None
5729*/
5730static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5731 uint32_t *msg_buf)
5732{
5733 tpSirModifyIEsInd modify_add_ies;
5734 tpPESession session_entry;
5735 uint8_t session_id;
5736 bool ret = false;
5737 tSirAddIeParams *add_ie_params;
5738
5739 if (msg_buf == NULL) {
5740 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5741 return;
5742 }
5743
5744 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5745 /* Incoming message has smeSession, use BSSID to find PE session */
5746 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005747 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748
5749 if (NULL == session_entry) {
5750 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5751 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005752 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753 goto end;
5754 }
5755 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5756 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5757 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5758 lim_log(mac_ctx, LOGE,
5759 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5760 modify_add_ies->modifyIE.pIEBuffer,
5761 modify_add_ies->modifyIE.ieBufferlength,
5762 modify_add_ies->modifyIE.ieID,
5763 modify_add_ies->modifyIE.ieIDLen,
5764 modify_add_ies->updateType);
5765 goto end;
5766 }
5767 add_ie_params = &session_entry->addIeParams;
5768 switch (modify_add_ies->updateType) {
5769 case eUPDATE_IE_PROBE_RESP:
5770 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005771 if (LIM_IS_IBSS_ROLE(session_entry)) {
5772 lim_update_ibss_prop_add_ies(mac_ctx,
5773 &add_ie_params->probeRespData_buff,
5774 &add_ie_params->probeRespDataLen,
5775 &modify_add_ies->modifyIE);
5776 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005777 break;
5778 case eUPDATE_IE_ASSOC_RESP:
5779 /* assoc resp IE */
5780 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305781 QDF_TRACE(QDF_MODULE_ID_PE,
5782 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 "assoc resp add ie not present %d"),
5784 add_ie_params->assocRespDataLen);
5785 }
5786 /* search through the buffer and modify the IE */
5787 break;
5788 case eUPDATE_IE_PROBE_BCN:
5789 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005790 if (LIM_IS_IBSS_ROLE(session_entry)) {
5791 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5792 &add_ie_params->probeRespBCNData_buff,
5793 &add_ie_params->probeRespBCNDataLen,
5794 &modify_add_ies->modifyIE);
5795 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005796 if (ret == true && modify_add_ies->modifyIE.notify) {
5797 lim_handle_param_update(mac_ctx,
5798 modify_add_ies->updateType);
5799 }
5800 break;
5801 default:
5802 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5803 modify_add_ies->updateType);
5804 break;
5805 }
5806end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305807 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 modify_add_ies->modifyIE.pIEBuffer = NULL;
5809}
5810
5811/*
5812* lim_process_update_add_ies() - process additional IE update req
5813*
5814* @mac_ctx: Pointer to Global MAC structure
5815* @msg_buf: pointer to the SME message buffer
5816*
5817* This function update the PE buffers for additional IEs.
5818*
5819* Return: None
5820*/
5821static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5822 uint32_t *msg_buf)
5823{
5824 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5825 uint8_t session_id;
5826 tpPESession session_entry;
5827 tSirAddIeParams *addn_ie;
5828 uint16_t new_length = 0;
5829 uint8_t *new_ptr = NULL;
5830 tSirUpdateIE *update_ie;
5831
5832 if (msg_buf == NULL) {
5833 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5834 return;
5835 }
5836 update_ie = &update_add_ies->updateIE;
5837 /* incoming message has smeSession, use BSSID to find PE session */
5838 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005839 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005840
5841 if (NULL == session_entry) {
5842 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5843 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005844 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845 goto end;
5846 }
5847 addn_ie = &session_entry->addIeParams;
5848 /* if len is 0, upper layer requested freeing of buffer */
5849 if (0 == update_ie->ieBufferlength) {
5850 switch (update_add_ies->updateType) {
5851 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305852 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853 addn_ie->probeRespData_buff = NULL;
5854 addn_ie->probeRespDataLen = 0;
5855 break;
5856 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305857 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 addn_ie->assocRespData_buff = NULL;
5859 addn_ie->assocRespDataLen = 0;
5860 break;
5861 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305862 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863 addn_ie->probeRespBCNData_buff = NULL;
5864 addn_ie->probeRespBCNDataLen = 0;
5865
5866 if (update_ie->notify)
5867 lim_handle_param_update(mac_ctx,
5868 update_add_ies->updateType);
5869 break;
5870 default:
5871 break;
5872 }
5873 return;
5874 }
5875 switch (update_add_ies->updateType) {
5876 case eUPDATE_IE_PROBE_RESP:
5877 if (update_ie->append) {
5878 /*
5879 * In case of append, allocate new memory
5880 * with combined length
5881 */
5882 new_length = update_ie->ieBufferlength +
5883 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305884 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885 if (NULL == new_ptr) {
5886 lim_log(mac_ctx, LOGE, FL(
5887 "Memory allocation failed."));
5888 goto end;
5889 }
5890 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305891 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005892 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305893 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005894 update_ie->pAdditionIEBuffer,
5895 update_ie->ieBufferlength);
5896 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305897 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898 /* adjust length accordingly */
5899 addn_ie->probeRespDataLen = new_length;
5900 /* save refernece of local buffer in PE session */
5901 addn_ie->probeRespData_buff = new_ptr;
5902 goto end;
5903 }
5904 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5905 &addn_ie->probeRespDataLen,
5906 update_ie->pAdditionIEBuffer,
5907 update_ie->ieBufferlength);
5908 break;
5909 case eUPDATE_IE_ASSOC_RESP:
5910 /* assoc resp IE */
5911 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5912 &addn_ie->assocRespDataLen,
5913 update_ie->pAdditionIEBuffer,
5914 update_ie->ieBufferlength);
5915 break;
5916 case eUPDATE_IE_PROBE_BCN:
5917 /* probe resp Bcn IE */
5918 lim_update_add_ie_buffer(mac_ctx,
5919 &addn_ie->probeRespBCNData_buff,
5920 &addn_ie->probeRespBCNDataLen,
5921 update_ie->pAdditionIEBuffer,
5922 update_ie->ieBufferlength);
5923 if (update_ie->notify)
5924 lim_handle_param_update(mac_ctx,
5925 update_add_ies->updateType);
5926 break;
5927 default:
5928 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5929 update_add_ies->updateType);
5930 break;
5931 }
5932end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305933 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005934 update_ie->pAdditionIEBuffer = NULL;
5935}
5936
5937/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305938 * send_extended_chan_switch_action_frame()- function to send ECSA
5939 * action frame for each sta connected to SAP/GO and AP in case of
5940 * STA .
5941 * @mac_ctx: pointer to global mac structure
5942 * @new_channel: new channel to switch to.
5943 * @ch_bandwidth: BW of channel to calculate op_class
5944 * @session_entry: pe session
5945 *
5946 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5947 *
5948 * Return: void
5949 */
5950
5951static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5952 uint16_t new_channel, uint8_t ch_bandwidth,
5953 tpPESession session_entry)
5954{
5955 uint16_t op_class;
5956 uint8_t switch_mode = 0, i;
5957 tpDphHashNode psta;
5958
5959
Amar Singhal22995112016-01-22 10:42:33 -08005960 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305961 mac_ctx->scan.countryCodeCurrent,
5962 new_channel,
5963 ch_bandwidth);
5964
5965 if (LIM_IS_AP_ROLE(session_entry) &&
5966 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5967 switch_mode = 1;
5968
5969 if (LIM_IS_AP_ROLE(session_entry)) {
5970 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5971 psta =
5972 session_entry->dph.dphHashTable.pDphNodeArray + i;
5973 if (psta && psta->added)
5974 lim_send_extended_chan_switch_action_frame(
5975 mac_ctx,
5976 psta->staAddr,
5977 switch_mode, op_class, new_channel,
5978 LIM_MAX_CSA_IE_UPDATES, session_entry);
5979 }
5980 } else if (LIM_IS_STA_ROLE(session_entry)) {
5981 lim_send_extended_chan_switch_action_frame(mac_ctx,
5982 session_entry->bssId,
5983 switch_mode, op_class, new_channel,
5984 LIM_MAX_CSA_IE_UPDATES, session_entry);
5985 }
5986
5987}
5988
5989/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5991 *
5992 * @mac_ctx: Pointer to Global MAC structure
5993 * @msg_buf: pointer to the SME message buffer
5994 *
5995 * This function processes SME request messages from HDD or upper layer
5996 * application.
5997 *
5998 * Return: None
5999 */
6000static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
6001 uint32_t *msg_buf)
6002{
6003 tpSirDfsCsaIeRequest dfs_csa_ie_req;
6004 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005 uint8_t session_id;
6006 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006007 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008
6009 if (msg_buf == NULL) {
6010 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6011 return;
6012 }
6013
6014 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6015 session_entry = pe_find_session_by_bssid(mac_ctx,
6016 dfs_csa_ie_req->bssid, &session_id);
6017 if (session_entry == NULL) {
6018 lim_log(mac_ctx, LOGE, FL(
6019 "Session not found for given BSSID" MAC_ADDRESS_STR),
6020 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6021 return;
6022 }
6023
6024 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6025 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6026 GET_LIM_SYSTEM_ROLE(session_entry));
6027 return;
6028 }
6029
6030 /* target channel */
6031 session_entry->gLimChannelSwitch.primaryChannel =
6032 dfs_csa_ie_req->targetChannel;
6033
6034 /* Channel switch announcement needs to be included in beacon */
6035 session_entry->dfsIncludeChanSwIe = true;
6036 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6037 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006038 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306039 session_entry->gLimChannelSwitch.sec_ch_offset =
6040 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6042 session_entry->gLimChannelSwitch.switchMode = 1;
6043
6044 /*
6045 * Validate if SAP is operating HT or VHT mode and set the Channel
6046 * Switch Wrapper element with the Wide Band Switch subelement.
6047 */
6048 if (true != session_entry->vhtCapability)
6049 goto skip_vht;
6050
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051 /* Now encode the Wider Ch BW element depending on the ch width */
6052 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006053 switch (dfs_csa_ie_req->ch_params.ch_width) {
6054 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 /*
6056 * Wide channel BW sublement in channel wrapper element is not
6057 * required in case of 20 Mhz operation. Currently It is set
6058 * only set in case of 40/80 Mhz Operation.
6059 */
6060 session_entry->dfsIncludeChanWrapperIe = false;
6061 wider_bw_ch_switch->newChanWidth =
6062 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6063 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006064 case CH_WIDTH_40MHZ:
6065 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066 wider_bw_ch_switch->newChanWidth =
6067 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6068 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006069 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070 session_entry->dfsIncludeChanWrapperIe = true;
6071 wider_bw_ch_switch->newChanWidth =
6072 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6073 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006074 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006075 session_entry->dfsIncludeChanWrapperIe = true;
6076 wider_bw_ch_switch->newChanWidth =
6077 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6078 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006079 case CH_WIDTH_80P80MHZ:
6080 session_entry->dfsIncludeChanWrapperIe = true;
6081 wider_bw_ch_switch->newChanWidth =
6082 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006083 /*
6084 * This is not applicable for 20/40/80 Mhz.
6085 * Only used when we support 80+80 Mhz operation.
6086 * In case of 80+80 Mhz, this parameter indicates
6087 * center channel frequency index of 80 Mhz channel of
6088 * frequency segment 1.
6089 */
6090 wider_bw_ch_switch->newCenterChanFreq1 =
6091 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006092 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093 default:
6094 session_entry->dfsIncludeChanWrapperIe = false;
6095 /*
6096 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6097 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6098 */
6099 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6100 break;
6101 }
6102 /* Fetch the center channel based on the channel width */
6103 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006104 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006105skip_vht:
6106 /* Send CSA IE request from here */
6107 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6108 eSIR_SUCCESS) {
6109 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6110 return;
6111 }
6112
6113 /*
6114 * First beacon update request is sent here, the remaining updates are
6115 * done when the FW responds back after sending the first beacon after
6116 * the template update
6117 */
6118 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306119
6120 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6121 ch_offset = BW80;
6122 else
6123 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6124
6125 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6126 session_entry->gLimChannelSwitch.switchCount,
6127 session_entry->gLimChannelSwitch.primaryChannel,
6128 session_entry->gLimChannelSwitch.ch_width,
6129 session_entry->dfsIncludeChanWrapperIe,
6130 ch_offset);
6131
Abhishek Singh518323d2015-10-19 17:42:01 +05306132 /* Send ECSA Action frame after updating the beacon */
6133 send_extended_chan_switch_action_frame(mac_ctx,
6134 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306135 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006136 session_entry->gLimChannelSwitch.switchCount--;
6137}
6138
6139/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306140 * lim_process_ext_change_channel()- function to send ECSA
6141 * action frame for STA/CLI .
6142 * @mac_ctx: pointer to global mac structure
6143 * @msg: params from sme for new channel.
6144 *
6145 * This function is called to send ECSA frame for STA/CLI.
6146 *
6147 * Return: void
6148 */
6149
6150static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6151 uint32_t *msg)
6152{
6153 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6154 (struct sir_sme_ext_cng_chan_req *) msg;
6155 tpPESession session_entry = NULL;
6156
6157 if (NULL == msg) {
6158 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6159 return;
6160 }
6161 session_entry =
6162 pe_find_session_by_sme_session_id(mac_ctx,
6163 ext_chng_channel->session_id);
6164 if (NULL == session_entry) {
6165 lim_log(mac_ctx, LOGE,
6166 FL("Session not found for given session %d"),
6167 ext_chng_channel->session_id);
6168 return;
6169 }
6170 if (LIM_IS_AP_ROLE(session_entry)) {
6171 lim_log(mac_ctx, LOGE,
6172 FL("not an STA/CLI session"));
6173 return;
6174 }
6175 send_extended_chan_switch_action_frame(mac_ctx,
6176 ext_chng_channel->new_channel,
6177 0, session_entry);
6178}
6179
6180/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006181 * lim_process_nss_update_request() - process sme nss update req
6182 *
6183 * @mac_ctx: Pointer to Global MAC structure
6184 * @msg_buf: pointer to the SME message buffer
6185 *
6186 * This function processes SME request messages from HDD or upper layer
6187 * application.
6188 *
6189 * Return: None
6190 */
6191static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6192 uint32_t *msg_buf)
6193{
6194 struct sir_nss_update_request *nss_update_req_ptr;
6195 tpPESession session_entry = NULL;
6196
6197 if (msg_buf == NULL) {
6198 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6199 return;
6200 }
6201
6202 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306203 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006204 nss_update_req_ptr->vdev_id);
6205 if (session_entry == NULL) {
6206 lim_log(mac_ctx, LOGE, FL(
6207 "Session not found for given session_id %d"),
6208 nss_update_req_ptr->vdev_id);
6209 return;
6210 }
6211
6212 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6213 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6214 GET_LIM_SYSTEM_ROLE(session_entry));
6215 return;
6216 }
6217
6218 /* populate nss field in the beacon */
6219 session_entry->gLimOperatingMode.present = 1;
6220 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6221 /* Send nss update request from here */
6222 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6223 eSIR_SUCCESS) {
6224 lim_log(mac_ctx, LOGE,
6225 FL("Unable to set op mode IE in beacon"));
6226 return;
6227 }
6228
6229 lim_send_beacon_ind(mac_ctx, session_entry);
6230}
6231
6232/**
6233 * lim_process_set_ie_req() - process sme set IE request
6234 *
6235 * @mac_ctx: Pointer to Global MAC structure
6236 * @msg_buf: pointer to the SME message buffer
6237 *
6238 * This function processes SME request messages from HDD or upper layer
6239 * application.
6240 *
6241 * Return: None
6242 */
6243static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6244{
6245 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306246 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006247
6248 if (msg_buf == NULL) {
6249 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6250 return;
6251 }
6252
6253 msg = (struct send_extcap_ie *)msg_buf;
6254 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306255 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006256 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6257
6258}