blob: 37a9806dd2934c393611bf90763b3f54116903ce [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08002 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_process_sme_req_messages.cc contains the code
30 * for processing SME request messages.
31 * Author: Chandra Modumudi
32 * Date: 02/11/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 *
37 */
38
39#include "cds_api.h"
40#include "wni_api.h"
41#include "wni_cfg.h"
42#include "cfg_api.h"
43#include "sir_api.h"
44#include "sch_api.h"
45#include "utils_api.h"
46#include "lim_types.h"
47#include "lim_utils.h"
48#include "lim_assoc_utils.h"
49#include "lim_security_utils.h"
50#include "lim_ser_des_utils.h"
51#include "lim_sme_req_utils.h"
52#include "lim_ibss_peer_mgmt.h"
53#include "lim_admit_control.h"
54#include "dph_hash_table.h"
55#include "lim_send_messages.h"
56#include "lim_api.h"
57#include "wmm_apsd.h"
58#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080059#include "rrm_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070060#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061
62#include "sap_api.h"
63
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070066#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
68/*
69 * This overhead is time for sending NOA start to host in case of GO/sending
70 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
71 * with init scan req/rsp plus in case of concurrency, taking care of sending
72 * null data and receiving ACK to/from AP/Also SetChannel with calibration
73 * is taking around 7ms .
74 */
75#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
76#define JOIN_NOA_DURATION 2000 /* in msecs */
77#define OEM_DATA_NOA_DURATION 60 /* in msecs */
78#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
79
80#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
81
82/* SME REQ processing function templates */
83static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
84static bool __lim_process_sme_start_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
85static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
91static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
92static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053093static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
94 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
96 uint32_t *pMsg);
97static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
98static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
99static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
100static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
101
102static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
103 uint8_t **pDstData_buff,
104 uint16_t *pDstDataLen,
105 uint8_t *pSrcData_buff,
106 uint16_t srcDataLen);
107
108static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
109 uint8_t **pDstData_buff,
110 uint16_t *pDstDataLen,
111 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800112static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
113 uint8_t **pDstData_buff,
114 uint16_t *pDstDataLen,
115 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
117
118static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
119
Abhishek Singh518323d2015-10-19 17:42:01 +0530120static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
121 uint32_t *msg);
122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123/**
124 * lim_process_set_hw_mode() - Send set HW mode command to WMA
125 * @mac: Globacl MAC pointer
126 * @msg: Message containing the hw mode index
127 *
128 * Send the set HW mode command to WMA
129 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530130 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530132static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530134 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135 cds_msg_t cds_message;
136 struct sir_hw_mode *req_msg;
137 uint32_t len;
138 struct s_sir_set_hw_mode *buf;
139 tSirMsgQ resp_msg;
140 struct sir_set_hw_mode_resp *param;
141
142 buf = (struct s_sir_set_hw_mode *) msg;
143 if (!buf) {
144 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
145 /* To free the active command list */
146 goto fail;
147 }
148
149 len = sizeof(*req_msg);
150
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530151 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530153 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 /* Free the active command list
155 * Probably the malloc is going to fail there as well?!
156 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530157 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 }
159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530161 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162 /* Other parameters are not needed for WMA */
163
164 cds_message.bodyptr = req_msg;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +0530165 cds_message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166
167 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
168 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530169 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700171 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530173 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 goto fail;
175 }
176 return status;
177fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530178 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 if (!param) {
180 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530181 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 }
183 param->status = SET_HW_MODE_STATUS_ECANCELED;
184 param->cfgd_hw_mode_index = 0;
185 param->num_vdev_mac_entries = 0;
186 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
187 resp_msg.bodyptr = param;
188 resp_msg.bodyval = 0;
189 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530190 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191}
192
193/**
194 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
195 * @mac: Global MAC pointer
196 * @msg: Message containing the dual mac config parameter
197 *
198 * Send the set dual mac config command to WMA
199 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530200 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530202static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 uint32_t *msg)
204{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530205 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 cds_msg_t cds_message;
207 struct sir_dual_mac_config *req_msg;
208 uint32_t len;
209 struct sir_set_dual_mac_cfg *buf;
210 tSirMsgQ resp_msg;
211 struct sir_dual_mac_config_resp *param;
212
213 buf = (struct sir_set_dual_mac_cfg *) msg;
214 if (!buf) {
215 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
216 /* To free the active command list */
217 goto fail;
218 }
219
220 len = sizeof(*req_msg);
221
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530222 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 if (!req_msg) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700224 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 /* Free the active command list
226 * Probably the malloc is going to fail there as well?!
227 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530228 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 }
230
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 req_msg->scan_config = buf->set_dual_mac.scan_config;
232 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
233 /* Other parameters are not needed for WMA */
234
235 cds_message.bodyptr = req_msg;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530236 cds_message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237
238 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530239 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 req_msg->scan_config, req_msg->fw_mode_config);
241 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530242 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700244 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530246 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 goto fail;
248 }
249 return status;
250fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530251 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 if (!param) {
253 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530254 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 }
256 param->status = SET_HW_MODE_STATUS_ECANCELED;
257 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
258 resp_msg.bodyptr = param;
259 resp_msg.bodyval = 0;
260 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530261 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262}
263
264/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800265 * lim_process_set_antenna_mode_req() - Set antenna mode command
266 * to WMA
267 * @mac: Global MAC pointer
268 * @msg: Message containing the antenna mode parameter
269 *
270 * Send the set antenna mode command to WMA
271 *
272 * Return: QDF_STATUS_SUCCESS if message posting is successful
273 */
274static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
275 uint32_t *msg)
276{
277 QDF_STATUS status = QDF_STATUS_SUCCESS;
278 cds_msg_t cds_message;
279 struct sir_antenna_mode_param *req_msg;
280 struct sir_set_antenna_mode *buf;
281 tSirMsgQ resp_msg;
282 struct sir_antenna_mode_resp *param;
283
284 buf = (struct sir_set_antenna_mode *) msg;
285 if (!buf) {
286 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
287 /* To free the active command list */
288 goto fail;
289 }
290
291 req_msg = qdf_mem_malloc(sizeof(*req_msg));
292 if (!req_msg) {
293 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
294 return QDF_STATUS_E_NOMEM;
295 }
296
297 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
298 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
299
300 cds_message.bodyptr = req_msg;
301 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
302
303 lim_log(mac, LOG1,
304 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
305 req_msg->num_rx_chains,
306 req_msg->num_tx_chains);
307 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
308 if (!QDF_IS_STATUS_SUCCESS(status)) {
309 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700310 FL("cds_mq_post_message failed!(err=%d)"),
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800311 status);
312 qdf_mem_free(req_msg);
313 goto fail;
314 }
315 return status;
316fail:
317 param = qdf_mem_malloc(sizeof(*param));
318 if (!param) {
319 lim_log(mac, LOGE, FL("antenna mode resp failed"));
320 return QDF_STATUS_E_NOMEM;
321 }
322 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
323 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
324 resp_msg.bodyptr = param;
325 resp_msg.bodyval = 0;
326 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
327 return QDF_STATUS_SUCCESS;
328}
329
330/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
332 * @mac_ctx: Pointer to Global MAC structure
333 * @return_fresh_results: Trigger fresh scan.
334 *
335 * PE will do fresh scan, if all of the active sessions are in
336 * good state (Link Est or BSS Started). If one of the sessions
337 * is not in one of the above states, then PE does not do fresh
338 * scan. If no session exists (scanning very first time),
339 * then PE will always do fresh scan if SME asks it to do that.
340 *
341 * Return: true for fresh scan results, false if in invalid state.
342 */
343static uint8_t
344__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
345{
346 uint8_t valid_state = true;
347 int i;
348
349 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
350 mac_ctx->lim.gLimSmeState, return_fresh_results);
351
352 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
353 lim_log(mac_ctx, LOG1, FL("return FALSE"));
354 return false;
355 }
356
357 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700358
359 if (mac_ctx->lim.gpSession[i].valid == false)
360 continue;
361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 lim_log(mac_ctx, LOG1,
363 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
364 i, mac_ctx->lim.gpSession[i].bssType,
365 mac_ctx->lim.gpSession[i].limSystemRole,
366 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700367
368 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
369 continue;
370
371 if (mac_ctx->lim.gpSession[i].bssType ==
372 eSIR_INFRASTRUCTURE_MODE &&
373 mac_ctx->lim.gpSession[i].limSmeState ==
374 eLIM_SME_LINK_EST_STATE)
375 continue;
376
377 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
378 mac_ctx->lim.gpSession[i].limSmeState ==
379 eLIM_SME_NORMAL_STATE)
380 continue;
381
382 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
383 mac_ctx->lim.gpSession[i].pePersona ==
384 QDF_P2P_GO_MODE &&
385 mac_ctx->lim.gpSession[i].limSmeState ==
386 eLIM_SME_NORMAL_STATE)
387 continue;
388
389 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
390 mac_ctx->lim.gpSession[i].limSmeState ==
391 eLIM_SME_NORMAL_STATE)
392 continue;
393
394 valid_state = false;
395 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 }
397
398 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
399
400 if ((valid_state) &&
401 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
402 return true;
403 else
404 return false;
405}
406
407/**
408 * __lim_is_sme_assoc_cnf_valid()
409 *
410 ***FUNCTION:
411 * This function is called by __lim_process_sme_assoc_cnf_new() upon
412 * receiving SME_ASSOC_CNF.
413 *
414 ***LOGIC:
415 * Message validity checks are performed in this function
416 *
417 ***ASSUMPTIONS:
418 *
419 ***NOTE:
420 *
421 * @param pMeasReq Pointer to Received ASSOC_CNF message
422 * @return true When received SME_ASSOC_CNF is formatted
423 * correctly
424 * false otherwise
425 */
426
427static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
428{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530429 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 return false;
431 else
432 return true;
433} /*** end __lim_is_sme_assoc_cnf_valid() ***/
434
435/**
436 * __lim_get_sme_join_req_size_for_alloc()
437 *
438 ***FUNCTION:
439 * This function is called in various places to get IE length
440 * from tSirBssDescription structure
441 * number being scanned.
442 *
443 ***PARAMS:
444 *
445 ***LOGIC:
446 *
447 ***ASSUMPTIONS:
448 * NA
449 *
450 ***NOTE:
451 * NA
452 *
453 * @param pBssDescr
454 * @return Total IE length
455 */
456
457static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
458{
459 uint16_t len = 0;
460
461 if (!pBuf)
462 return len;
463
464 pBuf += sizeof(uint16_t);
465 len = lim_get_u16(pBuf);
466 return len + sizeof(uint16_t);
467}
468
469/**
470 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
471 * @pMac: Global MAC context
472 * @pMsg: Pointer to message posted from SME to LIM.
473 *
474 * Has role only if 11h is enabled. Not used on STA side.
475 * Defers the message if SME is in learn state and brings
476 * the LIM back to normal mode.
477 *
478 * Return: true - If defered false - Otherwise
479 */
480
481static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
482{
483 if (lim_is_system_in_scan_state(pMac)) {
484 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
485 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
486 pMsg->type);
487 return false;
488 }
489 lim_log(pMac, LOG1,
490 FL("Defer the message, in learn mode type = %d"),
491 pMsg->type);
492 return true;
493 }
494 return false;
495}
496
497/**
498 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
499 * @mac_ctx: Pointer to Global MAC structure
500 * @message: Pointer to message posted from SME to LIM.
501 *
502 * Has role only if 11h is enabled. Not used on STA side.
503 * Defers the message if radar is detected.
504 *
505 * Return: true, if defered otherwise return false.
506 */
507static bool
508__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
509{
510 /*
511 * fRadarDetCurOperChan will be set only if we
512 * detect radar in current operating channel and
513 * System Role == AP ROLE
514 *
515 * TODO: Need to take care radar detection.
516 *
517 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
518 */
519 if (0) {
520 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
521 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
522 message->type);
523 return false;
524 }
525 lim_log(mac_ctx, LOG1,
526 FL("Defer the message, in learn mode type = %d"),
527 message->type);
528 return true;
529 }
530 return false;
531}
532
533/**
534 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
535 * @pMac: Global MAC context
536 * @pMsgBuf: Message from WMA
537 *
538 * handles the notification from HDD. PE just forwards this message to HAL.
539 *
540 * Return: true-Posting to HAL failed, so PE will consume the buffer.
541 * false-Posting to HAL successful, so HAL will consume the buffer.
542 */
543
544static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
545{
546 tSirMsgQ msg;
547 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
548
549 msg.type = WMA_SYS_READY_IND;
550 msg.reserved = 0;
551 msg.bodyptr = pMsgBuf;
552 msg.bodyval = 0;
553
554 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800555 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700556 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800557 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
558 }
559 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
560 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
561
562 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
563 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
564 return true;
565 }
566 return false;
567}
568
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569/**
570 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
571 *@mac_ctx: Pointer to Global MAC structure
572 *@session: A pointer to session entry
573 *@sme_start_bss_req: Start BSS Request from upper layers.
574 *
575 * This function is used to configure the start bss parameters
576 * in to the session.
577 *
578 * Return: None.
579 */
580static void
581lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
582 tpSirSmeStartBssReq sme_start_bss_req)
583{
584 session->limSystemRole = eLIM_AP_ROLE;
585 session->privacy = sme_start_bss_req->privacy;
586 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
587 session->authType = sme_start_bss_req->authType;
588 /* Store the DTIM period */
589 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
590 /* Enable/disable UAPSD */
591 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530592 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 session->proxyProbeRspEn = 0;
594 } else {
595 /*
596 * To detect PBC overlap in SAP WPS mode,
597 * Host handles Probe Requests.
598 */
599 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
600 session->proxyProbeRspEn = 1;
601 else
602 session->proxyProbeRspEn = 0;
603 }
604 session->ssidHidden = sme_start_bss_req->ssidHidden;
605 session->wps_state = sme_start_bss_req->wps_state;
606 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530607 session->vendor_vht_sap =
608 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
610 &session->shortSlotTimeSupported);
611 session->isCoalesingInIBSSAllowed =
612 sme_start_bss_req->isCoalesingInIBSSAllowed;
613
614}
615
616/**
617 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
618 *@mac_ctx: Pointer to Global MAC structure
619 *@msg_buf: A pointer to the SME message buffer
620 *
621 * This function is called to process SME_START_BSS_REQ message
622 * from HDD or upper layer application.
623 *
624 * Return: None
625 */
626static void
627__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
628{
629 uint16_t size;
630 uint32_t val = 0;
631 tSirRetStatus ret_status;
632 tSirMacChanNum channel_number;
633 tLimMlmStartReq *mlm_start_req = NULL;
634 tpSirSmeStartBssReq sme_start_bss_req = NULL;
635 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
636 /* Flag Used in case of IBSS to Auto generate BSSID. */
637 uint32_t auto_gen_bssid = false;
638 uint8_t session_id;
639 tpPESession session = NULL;
640 uint8_t sme_session_id = 0;
641 uint16_t sme_transaction_id = 0;
642 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700643 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
645
646/* FEATURE_WLAN_DIAG_SUPPORT */
647#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
648 /*
649 * Since the session is not created yet, sending NULL.
650 * The response should have the correct state.
651 */
652 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
653 NULL, 0, 0);
654#endif /* FEATURE_WLAN_DIAG_SUPPORT */
655
656 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
657
658 /*
659 * Global Sme state and mlm states are not defined yet,
660 * for BT-AMP Suppoprt . TO BE DONE
661 */
662 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
663 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
664 size = sizeof(tSirSmeStartBssReq);
665
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530666 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 if (NULL == sme_start_bss_req) {
668 lim_log(mac_ctx, LOGE,
669 FL("Allocate Memory fail for LimStartBssReq"));
670 /* Send failure response to host */
671 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
672 goto end;
673 }
674
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530675 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 sizeof(tSirSmeStartBssReq));
677 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
678 sme_start_bss_req)) {
679 lim_log(mac_ctx, LOGW,
680 FL("Received invalid eWNI_SME_START_BSS_REQ"));
681 ret_code = eSIR_SME_INVALID_PARAMETERS;
682 goto free;
683 }
684
685 /*
686 * This is the place where PE is going to create a session.
687 * If session is not existed, then create a new session
688 */
689 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800690 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 if (session != NULL) {
692 lim_log(mac_ctx, LOGW,
693 FL("Session Already exists for given BSSID"));
694 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
695 session = NULL;
696 goto free;
697 } else {
698 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800699 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 &session_id, mac_ctx->lim.maxStation,
701 sme_start_bss_req->bssType);
702 if (session == NULL) {
703 lim_log(mac_ctx, LOGW,
704 FL("Session Can not be created "));
705 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
706 goto free;
707 }
708 }
709
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700710 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
711 /* Probe resp add ie */
712 lim_start_bss_update_add_ie_buffer(mac_ctx,
713 &session->addIeParams.probeRespData_buff,
714 &session->addIeParams.probeRespDataLen,
715 sme_start_bss_req->addIeParams.
716 probeRespData_buff,
717 sme_start_bss_req->addIeParams.
718 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700720 /* Probe Beacon add ie */
721 lim_start_bss_update_add_ie_buffer(mac_ctx,
722 &session->addIeParams.probeRespBCNData_buff,
723 &session->addIeParams.probeRespBCNDataLen,
724 sme_start_bss_req->addIeParams.
725 probeRespBCNData_buff,
726 sme_start_bss_req->addIeParams.
727 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700729 /* Assoc resp IE */
730 lim_start_bss_update_add_ie_buffer(mac_ctx,
731 &session->addIeParams.assocRespData_buff,
732 &session->addIeParams.assocRespDataLen,
733 sme_start_bss_req->addIeParams.
734 assocRespData_buff,
735 sme_start_bss_req->addIeParams.
736 assocRespDataLen);
737 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 /* Store the session related params in newly created session */
739 session->pLimStartBssReq = sme_start_bss_req;
740
741 /* Store PE session_id in session Table */
742 session->peSessionId = session_id;
743
744 /* Store SME session Id in sessionTable */
745 session->smeSessionId = sme_start_bss_req->sessionId;
746
747 session->transactionId = sme_start_bss_req->transactionId;
748
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530749 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 &(sme_start_bss_req->htConfig),
751 sizeof(session->htConfig));
752
Sandeep Puligilla98917432016-06-10 13:50:28 -0700753 qdf_mem_copy(&(session->vht_config),
754 &(sme_start_bss_req->vht_config),
755 sizeof(session->vht_config));
756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800758 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759
760 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530761 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 (uint8_t *) &sme_start_bss_req->ssId,
763 (sme_start_bss_req->ssId.length + 1));
764
765 session->bssType = sme_start_bss_req->bssType;
766
767 session->nwType = sme_start_bss_req->nwType;
768
769 session->beaconParams.beaconInterval =
770 sme_start_bss_req->beaconInterval;
771
772 /* Store the channel number in session Table */
773 session->currentOperChannel =
774 sme_start_bss_req->channelId;
775
776 /* Store Persona */
777 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530778 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 FL("PE PERSONA=%d"), session->pePersona);
780
781 /* Update the phymode */
782 session->gLimPhyMode = sme_start_bss_req->nwType;
783
784 session->maxTxPower =
785 cfg_get_regulatory_max_transmit_power(mac_ctx,
786 session->currentOperChannel);
787 /* Store the dot 11 mode in to the session Table */
788 session->dot11mode = sme_start_bss_req->dot11mode;
789#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
790 session->cc_switch_mode =
791 sme_start_bss_req->cc_switch_mode;
792#endif
793 session->htCapability =
794 IS_DOT11_MODE_HT(session->dot11mode);
795 session->vhtCapability =
796 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530797 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 FL("*****session->vhtCapability = %d"),
799 session->vhtCapability);
800 session->txLdpcIniFeatureEnabled =
801 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802#ifdef WLAN_FEATURE_11W
803 session->limRmfEnabled =
804 sme_start_bss_req->pmfCapable ? 1 : 0;
805 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
806 session->limRmfEnabled);
807#endif
808
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530809 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 (void *)&sme_start_bss_req->operationalRateSet,
811 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530812 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 (void *)&sme_start_bss_req->extendedRateSet,
814 sizeof(tSirMacRateSet));
815
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700816 if (IS_5G_CH(session->currentOperChannel))
817 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
818 else
819 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
820
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 switch (sme_start_bss_req->bssType) {
822 case eSIR_INFRA_AP_MODE:
823 lim_configure_ap_start_bss_session(mac_ctx, session,
824 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700825 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700826 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700827 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700828 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 break;
830 case eSIR_IBSS_MODE:
831 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
832 lim_get_short_slot_from_phy_mode(mac_ctx, session,
833 session->gLimPhyMode,
834 &session->shortSlotTimeSupported);
835
836 /*
837 * initialize to "OPEN".
838 * will be updated upon key installation
839 */
840 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700841 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842
843 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700844 case eSIR_NDI_MODE:
845 session->limSystemRole = eLIM_NDI_ROLE;
846 break;
847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849 /*
850 * There is one more mode called auto mode.
851 * which is used no where
852 */
853
854 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
855
856 default:
857 /* not used anywhere...used in scan function */
858 break;
859 }
860
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700861 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
862 session->pePersona, session->vdev_nss);
863 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700865 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866 * parsed (Re)Assoc request structure
867 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700868 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530870 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700871 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 if (NULL == session->parsedAssocReq) {
873 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700874 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
876 goto free;
877 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 }
879
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700880 if (!sme_start_bss_req->channelId &&
881 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 lim_log(mac_ctx, LOGE,
883 FL("Received invalid eWNI_SME_START_BSS_REQ"));
884 ret_code = eSIR_SME_INVALID_PARAMETERS;
885 goto free;
886 }
887 channel_number = sme_start_bss_req->channelId;
888#ifdef QCA_HT_2040_COEX
889 if (sme_start_bss_req->obssEnabled)
890 session->htSupportedChannelWidthSet =
891 session->htCapability;
892 else
893#endif
894 session->htSupportedChannelWidthSet =
895 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
896 session->htSecondaryChannelOffset =
897 sme_start_bss_req->sec_ch_offset;
898 session->htRecommendedTxWidthSet =
899 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530900 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 FL("cbMode %u"), sme_start_bss_req->cbMode);
902 if (session->vhtCapability || session->htCapability) {
903 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800904 lim_log(mac_ctx, LOG1,
905 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
906 sme_start_bss_req->vht_channel_width,
907 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 session->ch_width = chanwidth;
909 if (session->htSupportedChannelWidthSet) {
910 session->ch_center_freq_seg0 =
911 sme_start_bss_req->center_freq_seg0;
912 session->ch_center_freq_seg1 =
913 sme_start_bss_req->center_freq_seg1;
914 } else {
915 session->ch_center_freq_seg0 = 0;
916 session->ch_center_freq_seg1 = 0;
917 }
918 }
919
920 if (session->vhtCapability &&
Krunal Soni53993f72016-07-08 18:20:03 -0700921 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922 session->nss = 1;
Krunal Soni53993f72016-07-08 18:20:03 -0700923 lim_log(mac_ctx, LOG1, FL("nss set to [%d]"),
924 session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925 }
Krunal Soni53993f72016-07-08 18:20:03 -0700926 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"),
927 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928
929 /* Delete pre-auth list if any */
930 lim_delete_pre_auth_list(mac_ctx);
931
Krunal Soni53993f72016-07-08 18:20:03 -0700932 if (session->nss == 1) {
933 session->vht_config.su_beam_former = 0;
934 session->vht_config.tx_stbc = 0;
935 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530936 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700937 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 /*
939 * keep the RSN/WPA IE information in PE Session Entry
940 * later will be using this to check when received (Re)Assoc req
941 */
942 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
943 &sme_start_bss_req->rsnIE, session);
944
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700945 if (LIM_IS_AP_ROLE(session) ||
946 LIM_IS_IBSS_ROLE(session) ||
947 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 session->gLimProtectionControl =
949 sme_start_bss_req->protEnabled;
950 /*
951 * each byte will have the following info
952 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
953 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
954 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530955 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 (void *)&sme_start_bss_req->ht_capab,
957 sizeof(uint16_t));
958 /* Initialize WPS PBC session link list */
959 session->pAPWPSPBCSession = NULL;
960 }
961 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530962 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 if (NULL == mlm_start_req) {
964 lim_log(mac_ctx, LOGP,
965 FL("Allocate Memory failed for mlmStartReq"));
966 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
967 goto free;
968 }
969
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530971 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 (uint8_t *) &sme_start_bss_req->ssId,
973 sme_start_bss_req->ssId.length + 1);
974 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
975 mlm_start_req->obssProtEnabled =
976 sme_start_bss_req->obssProtEnabled;
977
978 mlm_start_req->bssType = session->bssType;
979
980 /* Fill PE session Id from the session Table */
981 mlm_start_req->sessionId = session->peSessionId;
982
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700983 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
984 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985 /*
986 * Copy the BSSId from sessionTable to
987 * mlmStartReq struct
988 */
989 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
990 } else {
991 /* ibss mode */
992 mac_ctx->lim.gLimIbssCoalescingHappened = false;
993
994 ret_status = wlan_cfg_get_int(mac_ctx,
995 WNI_CFG_IBSS_AUTO_BSSID,
996 &auto_gen_bssid);
997 if (ret_status != eSIR_SUCCESS) {
998 lim_log(mac_ctx, LOGP,
999 FL("Get Auto Gen BSSID fail,Status=%d"),
1000 ret_status);
1001 ret_code = eSIR_LOGP_EXCEPTION;
1002 goto free;
1003 }
1004
1005 if (!auto_gen_bssid) {
1006 /*
1007 * We're not auto generating BSSID.
1008 * Instead, get it from session entry
1009 */
1010 sir_copy_mac_addr(mlm_start_req->bssId,
1011 session->bssId);
1012 /*
1013 * Start IBSS group BSSID
1014 * Auto Generating BSSID.
1015 */
1016 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1017 0x01) ? true : false);
1018 }
1019
1020 if (auto_gen_bssid) {
1021 /*
1022 * if BSSID is not any uc id.
1023 * then use locally generated BSSID.
1024 * Autogenerate the BSSID
1025 */
1026 lim_get_random_bssid(mac_ctx,
1027 mlm_start_req->bssId);
1028 mlm_start_req->bssId[0] = 0x02;
1029
1030 /*
1031 * Copy randomly generated BSSID
1032 * to the session Table
1033 */
1034 sir_copy_mac_addr(session->bssId,
1035 mlm_start_req->bssId);
1036 }
1037 }
1038 /* store the channel num in mlmstart req structure */
1039 mlm_start_req->channelNumber = session->currentOperChannel;
1040 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1041 mlm_start_req->beaconPeriod =
1042 session->beaconParams.beaconInterval;
1043
1044 if (LIM_IS_AP_ROLE(session)) {
1045 mlm_start_req->dtimPeriod = session->dtimPeriod;
1046 mlm_start_req->wps_state = session->wps_state;
1047
1048 } else {
1049 if (wlan_cfg_get_int(mac_ctx,
1050 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1051 lim_log(mac_ctx, LOGP,
1052 FL("could not retrieve DTIM Period"));
1053 mlm_start_req->dtimPeriod = (uint8_t) val;
1054 }
1055
1056 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1057 eSIR_SUCCESS)
1058 lim_log(mac_ctx, LOGP,
1059 FL("could not retrieve Beacon interval"));
1060 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1061
1062 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1063 eSIR_SUCCESS)
1064 lim_log(mac_ctx, LOGP,
1065 FL("could not retrieve CFPMaxDuration"));
1066 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1067
1068 /*
1069 * this may not be needed anymore now,
1070 * as rateSet is now included in the
1071 * session entry and MLM has session context.
1072 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301073 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 (void *)&session->rateSet,
1075 sizeof(tSirMacRateSet));
1076
1077 /* Now populate the 11n related parameters */
1078 mlm_start_req->nwType = session->nwType;
1079 mlm_start_req->htCapable = session->htCapability;
1080
1081 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1082 /* Unused */
1083 mlm_start_req->dualCTSProtection =
1084 mac_ctx->lim.gHTDualCTSProtection;
1085 mlm_start_req->txChannelWidthSet =
1086 session->htRecommendedTxWidthSet;
1087
1088 session->limRFBand = lim_get_rf_band(channel_number);
1089
1090 /* Initialize 11h Enable Flag */
1091 session->lim11hEnable = 0;
1092 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1093 (SIR_BAND_5_GHZ == session->limRFBand)) {
1094 if (wlan_cfg_get_int(mac_ctx,
1095 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1096 lim_log(mac_ctx, LOGP,
1097 FL("Fail to get WNI_CFG_11H_ENABLED "));
1098 else
1099 session->lim11hEnable = val;
1100
1101 if (session->lim11hEnable &&
1102 (eSIR_INFRA_AP_MODE ==
1103 mlm_start_req->bssType)) {
1104 cfg_get_wmi_dfs_master_param =
1105 wlan_cfg_get_int(mac_ctx,
1106 WNI_CFG_DFS_MASTER_ENABLED,
1107 &val);
1108 session->lim11hEnable = val;
1109 }
1110 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1111 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1112 lim_log(mac_ctx, LOGE,
1113 FL("Get Fail, CFG DFS ENABLE"));
1114 }
1115
1116 if (!session->lim11hEnable) {
1117 if (cfg_set_int(mac_ctx,
1118 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1119 eSIR_SUCCESS)
1120 /*
1121 * Failed to set the CFG param
1122 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1123 */
1124 lim_log(mac_ctx, LOGE,
1125 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1126 }
1127
1128 session->limPrevSmeState = session->limSmeState;
1129 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1130 MTRACE(mac_trace
1131 (mac_ctx, TRACE_CODE_SME_STATE,
1132 session->peSessionId,
1133 session->limSmeState));
1134
1135 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1136 (uint32_t *) mlm_start_req);
1137 return;
1138 } else {
1139
1140 lim_log(mac_ctx, LOGE,
1141 FL("Received unexpected START_BSS_REQ, in state %X"),
1142 mac_ctx->lim.gLimSmeState);
1143 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1144 goto end;
1145 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1146
1147free:
1148 if ((session != NULL) &&
1149 (session->pLimStartBssReq == sme_start_bss_req)) {
1150 session->pLimStartBssReq = NULL;
1151 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301152 qdf_mem_free(sme_start_bss_req);
1153 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154
1155end:
1156 if (sme_start_bss_req != NULL) {
1157 sme_session_id = sme_start_bss_req->sessionId;
1158 sme_transaction_id = sme_start_bss_req->transactionId;
1159 }
1160 if (NULL != session) {
1161 pe_delete_session(mac_ctx, session);
1162 session = NULL;
1163 }
1164 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1165 session, sme_session_id, sme_transaction_id);
1166}
1167
1168/**
1169 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1170 *
1171 * @pMac: Global MAC context
1172 * @pMsg: Message pointer
1173 *
1174 * Wrapper for the function __lim_handle_sme_start_bss_request
1175 * This message will be defered until softmac come out of
1176 * scan mode or if we have detected radar on the current
1177 * operating channel.
1178 *
1179 * return true - If we consumed the buffer
1180 * false - If have defered the message.
1181 */
1182static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1183{
1184 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1185 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1186 /**
1187 * If message defered, buffer is not consumed yet.
1188 * So return false
1189 */
1190 return false;
1191 }
1192
1193 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1194 return true;
1195}
1196
1197/**
1198 * lim_get_random_bssid()
1199 *
1200 * FUNCTION:This function is called to process generate the random number for bssid
1201 * This function is called to process SME_SCAN_REQ message
1202 * from HDD or upper layer application.
1203 *
1204 * LOGIC:
1205 *
1206 * ASSUMPTIONS:
1207 *
1208 * NOTE:
1209 * 1. geneartes the unique random number for bssid in ibss
1210 *
1211 * @param pMac Pointer to Global MAC structure
1212 * @param *data Pointer to bssid buffer
1213 * @return None
1214 */
1215void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1216{
1217 uint32_t random[2];
1218 random[0] = tx_time_get();
1219 random[0] |= (random[0] << 15);
1220 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301221 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222}
1223
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301224static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 tpSirSmeScanReq pScanReq)
1226{
1227 tSirScanOffloadReq *pScanOffloadReq;
1228 uint8_t *p;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 tSirMsgQ msg;
1230 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001231 uint16_t addn_ie_len = 0;
Naveen Rawat02e12662016-08-31 16:49:27 -07001232 uint8_t *vendor_tpc_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 tSirRetStatus status, rc = eSIR_SUCCESS;
1234 tDot11fIEExtCap extracted_extcap = {0};
1235 bool extcap_present = true;
Naveen Rawat02e12662016-08-31 16:49:27 -07001236 uint32_t lim_11h_enable = WNI_CFG_11H_ENABLED_STADEF;
1237
1238 wlan_cfg_get_int(pMac, WNI_CFG_11H_ENABLED, &lim_11h_enable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239
1240 if (pScanReq->uIEFieldLen) {
1241 status = lim_strip_extcap_update_struct(pMac,
1242 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1243 &pScanReq->uIEFieldLen, &extracted_extcap);
1244
1245 if (eSIR_SUCCESS != status) {
1246 extcap_present = false;
1247 lim_log(pMac, LOG1,
1248 FL("Unable to Strip ExtCap IE from Scan Req"));
1249 }
1250
1251 if (extcap_present) {
1252 lim_log(pMac, LOG1,
1253 FL("Extcap was part of SCAN IE - Updating FW"));
1254 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1255 &extracted_extcap, true);
1256 }
1257 } else {
1258 lim_log(pMac, LOG1,
1259 FL("No IEs in the scan request from supplicant"));
1260 }
1261
1262 /**
1263 * The tSirScanOffloadReq will reserve the space for first channel,
1264 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1265 */
1266 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001267 (pScanReq->channelList.numChannels - 1) +
1268 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001269 if (lim_11h_enable) {
1270 addn_ie_len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1271 len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1272 }
1273
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301274 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 if (NULL == pScanOffloadReq) {
1276 lim_log(pMac, LOGE,
1277 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301278 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001279 }
1280
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1282 msg.bodyptr = pScanOffloadReq;
1283 msg.bodyval = 0;
1284
Anurag Chouhanc5548422016-02-24 18:33:27 +05301285 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286
1287 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1288 lim_log(pMac, LOGE,
1289 FL("Invalid value (%d) for numSsid"),
1290 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301291 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301292 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 }
1294
1295 pScanOffloadReq->numSsid = pScanReq->numSsid;
1296 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1297 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301298 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 (uint8_t *) pScanReq->ssId[i].ssId,
1300 pScanOffloadReq->ssId[i].length);
1301 }
1302
1303 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301304 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 pScanOffloadReq->bssType = pScanReq->bssType;
1306 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1307 pScanOffloadReq->scanType = pScanReq->scanType;
1308 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1309 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1310 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301311 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1312 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301313 pScanOffloadReq->scan_adaptive_dwell_mode =
1314 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315
1316 /* for normal scan, the value for p2pScanType should be 0
1317 always */
1318 if (pScanReq->p2pSearch)
1319 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1320
1321 pScanOffloadReq->sessionId = pScanReq->sessionId;
1322 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001323 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301324 pScanOffloadReq->scan_adaptive_dwell_mode =
1325 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326
1327 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1328 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1329 pScanOffloadReq->sessionId);
1330
1331 pScanOffloadReq->channelList.numChannels =
1332 pScanReq->channelList.numChannels;
1333 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1334 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1335 p[i] = pScanReq->channelList.channelNumber[i];
1336
1337 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1338 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1339 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301340 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 pScanOffloadReq->uIEFieldOffset,
1342 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1343 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001344
1345 if (lim_11h_enable) {
1346 tDot11fIEWFATPC wfa_tpc;
1347 vendor_tpc_ie = (uint8_t *) pScanOffloadReq +
1348 pScanOffloadReq->uIEFieldOffset +
1349 pScanOffloadReq->uIEFieldLen;
1350 populate_dot11f_wfatpc(pMac, &wfa_tpc,
1351 rrm_get_mgmt_tx_power(pMac, NULL), 0);
1352 vendor_tpc_ie[0] = DOT11F_EID_WFATPC;
1353 vendor_tpc_ie[1] = DOT11F_IE_WFATPC_MAX_LEN;
1354 qdf_mem_copy(&vendor_tpc_ie[2], SIR_MAC_WFA_TPC_OUI,
1355 SIR_MAC_WFA_TPC_OUI_SIZE);
1356 qdf_mem_copy(&vendor_tpc_ie[SIR_MAC_WFA_TPC_OUI_SIZE + 2],
1357 ((uint8_t *)&wfa_tpc) + 1,
1358 DOT11F_IE_WFATPC_MAX_LEN - SIR_MAC_WFA_TPC_OUI_SIZE);
1359 pScanOffloadReq->uIEFieldLen += DOT11F_IE_WFATPC_MAX_LEN + 2;
Naveen Rawat30b84502016-10-13 17:44:48 -07001360 if (pScanReq->uIEFieldLen)
1361 lim_strip_ie(pMac,
1362 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1363 &pScanReq->uIEFieldLen,
1364 DOT11F_EID_WFATPC, ONE_BYTE,
1365 SIR_MAC_WFA_TPC_OUI, SIR_MAC_WFA_TPC_OUI_SIZE,
1366 NULL);
Naveen Rawat02e12662016-08-31 16:49:27 -07001367 }
1368
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 rc = wma_post_ctrl_msg(pMac, &msg);
1370 if (rc != eSIR_SUCCESS) {
1371 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301372 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301373 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 }
1375
1376 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1377
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301378 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379}
1380
1381/**
1382 * __lim_process_sme_scan_req() - Process the SME Scan Request
1383 * @mac_ctx: Global MAC Context
1384 * @msg_buf: Buffer which contains the request and pertinent parameters
1385 *
1386 * This function is called to process SME_SCAN_REQ message
1387 * from HDD or upper layer application.
1388 *
1389 * Return: None
1390 */
1391
1392static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1393 uint32_t *msg_buf)
1394{
1395 tpSirSmeScanReq scan_req;
1396 uint8_t valid_req = 0;
1397
1398#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1399 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1400 eSIR_SUCCESS, eSIR_SUCCESS);
1401#endif
1402
1403 scan_req = (tpSirSmeScanReq) msg_buf;
1404 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301405 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 -08001406 scan_req->scan_id, scan_req->channelList.numChannels,
1407 scan_req->minChannelTime, scan_req->maxChannelTime,
1408 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1409 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301410 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1412 /*
1413 * Since scan req always requires a response, we will overwrite response
1414 * required here. This is added esp to take care of the condition where
1415 * in p2p go case, we hold the scan req and insert single NOA. We send
1416 * the held scan request to FW later on getting start NOA ind from FW so
1417 * we lose state of the gLimRspReqd flag for the scan req if any other
1418 * request comes by then. e.g. While unit testing, we found when insert
1419 * single NOA is done, we see a get stats request which turns the flag
1420 * gLimRspReqd to false; now when we actually start the saved scan req
1421 * for init scan after getting NOA started, the gLimRspReqd being a
1422 * global flag is showing false instead of true value for this saved
1423 * scan req. Since all scan reqs coming to lim require a response,
1424 * there is no harm in setting the global flag gLimRspReqd to true here.
1425 */
1426 mac_ctx->lim.gLimRspReqd = true;
1427
1428 /*
1429 * copy the Self MAC address from SmeReq to the globalplace,
1430 * used for sending probe req
1431 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001432 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1433 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1435
1436 if (!valid_req || mac_ctx->lim.scan_disabled) {
1437 lim_log(mac_ctx, LOGE,
1438 FL("Scan disabled %d, Valid Scan Req %d"),
1439 mac_ctx->lim.scan_disabled, valid_req);
1440
1441 if (mac_ctx->lim.gLimRspReqd) {
1442 mac_ctx->lim.gLimRspReqd = false;
1443
1444 lim_send_sme_scan_rsp(mac_ctx,
1445 eSIR_SME_INVALID_PARAMETERS,
1446 scan_req->sessionId,
1447 scan_req->transactionId,
1448 scan_req->scan_id);
1449 }
1450 return;
1451 }
1452
1453 /*
1454 * If scan request is received in idle, joinFailed
1455 * states or in link established state (in STA role)
1456 * or in normal state (in STA-in-IBSS/AP role) with
1457 * 'return fresh scan results' request from HDD or
1458 * it is periodic background scanning request,
1459 * trigger fresh scan request to MLM
1460 */
1461 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1462
1463 mac_ctx->lim.gLim24Band11dScanDone = 0;
1464 mac_ctx->lim.gLim50Band11dScanDone = 0;
1465 mac_ctx->lim.gLimReturnAfterFirstMatch =
1466 scan_req->returnAfterFirstMatch;
1467 mac_ctx->lim.gLimReturnUniqueResults =
1468 ((scan_req->returnUniqueResults) > 0 ? true : false);
1469
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301470 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471 lim_send_hal_start_scan_offload_req(mac_ctx,
1472 scan_req)) {
1473 lim_log(mac_ctx, LOGE, FL(
1474 "Couldn't send Offload scan request"));
1475 lim_send_sme_scan_rsp(mac_ctx,
1476 eSIR_SME_INVALID_PARAMETERS,
1477 scan_req->sessionId,
1478 scan_req->transactionId,
1479 scan_req->scan_id);
1480 return;
1481 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301482 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483 /* In all other cases return 'cached' scan results */
1484 if (mac_ctx->lim.gLimRspReqd) {
1485 mac_ctx->lim.gLimRspReqd = false;
1486 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1487 scan_req->sessionId,
1488 scan_req->transactionId, scan_req->scan_id);
1489 }
1490 }
1491}
1492
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493/**
1494 * __lim_process_clear_dfs_channel_list()
1495 *
1496 ***FUNCTION:
1497 ***Clear DFS channel list when country is changed/aquired.
1498 .*This message is sent from SME.
1499 *
1500 ***LOGIC:
1501 *
1502 ***ASSUMPTIONS:
1503 *
1504 ***NOTE:
1505 *
1506 * @param pMac Pointer to Global MAC structure
1507 * @param *pMsgBuf A pointer to the SME message buffer
1508 * @return None
1509 */
1510static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1511{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301512 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513}
1514
1515/**
1516 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1517 * @mac_ctx: Pointer to Global MAC structure
1518 * @msg_buf: A pointer to the SME message buffer
1519 *
1520 * This function is called to process SME_JOIN_REQ message
1521 * from HDD or upper layer application.
1522 *
1523 * Return: None
1524 */
1525static void
1526__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1527{
1528 tpSirSmeJoinReq sme_join_req = NULL;
1529 tLimMlmJoinReq *mlm_join_req;
1530 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1531 uint32_t val = 0;
1532 uint16_t n_size;
1533 uint8_t session_id;
1534 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301535 uint8_t sme_session_id = 0;
1536 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001537 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 uint16_t ie_len;
1539 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001540 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001541 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542
Arif Hussain995fcaf2016-07-18 11:28:22 -07001543 if (!mac_ctx || !msg_buf) {
1544 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1545 FL("JOIN REQ with invalid data"));
1546 return;
1547 }
1548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549/* FEATURE_WLAN_DIAG_SUPPORT */
1550#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1551 /*
1552 * Not sending any session, since it is not created yet.
1553 * The response whould have correct state.
1554 */
1555 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1556#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1557
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 /*
1559 * Expect Join request in idle state.
1560 * Reassociate request is expected in link established state.
1561 */
1562
1563 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1564 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1565 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1566 msg_buf);
1567
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301568 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 if (NULL == sme_join_req) {
1570 lim_log(mac_ctx, LOGP,
1571 FL("AllocateMemory failed for sme_join_req"));
1572 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301573 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301575 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 n_size);
1577
1578 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1579 /* Received invalid eWNI_SME_JOIN_REQ */
1580 /* Log the event */
1581 lim_log(mac_ctx, LOGW,
1582 FL("SessionId:%d JOIN REQ with invalid data"),
1583 sme_join_req->sessionId);
1584 ret_code = eSIR_SME_INVALID_PARAMETERS;
1585 goto end;
1586 }
1587
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001588 /*
1589 * Update the capability here itself as this is used in
1590 * lim_extract_ap_capability() below. If not updated issues
1591 * like not honoring power constraint on 1st association after
1592 * driver loading might occur.
1593 */
1594 lim_update_rrm_capability(mac_ctx, sme_join_req);
1595
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001596 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001598 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 &session_id);
1600
1601 if (session != NULL) {
1602 lim_log(mac_ctx, LOGE,
1603 FL("Session(%d) Already exists for BSSID: "
1604 MAC_ADDRESS_STR " in limSmeState = %X"),
1605 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001606 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 session->limSmeState);
1608
1609 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1610 session->smeSessionId == sme_join_req->sessionId) {
1611 /*
1612 * Received eWNI_SME_JOIN_REQ for same
1613 * BSS as currently associated.
1614 * Log the event and send success
1615 */
1616 lim_log(mac_ctx, LOGW,
1617 FL("SessionId: %d"), session_id);
1618 lim_log(mac_ctx, LOGW,
1619 FL("JOIN_REQ for current joined BSS"));
1620 /* Send Join success response to host */
1621 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1622 session = NULL;
1623 goto end;
1624 } else {
1625 lim_log(mac_ctx, LOGE,
1626 FL("JOIN_REQ not for current joined BSS"));
1627 ret_code = eSIR_SME_REFUSED;
1628 session = NULL;
1629 goto end;
1630 }
1631 } else {
1632 /*
1633 * Session Entry does not exist for given BSSId
1634 * Try to Create a new session
1635 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001636 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 &session_id, mac_ctx->lim.maxStation,
1638 eSIR_INFRASTRUCTURE_MODE);
1639 if (session == NULL) {
1640 lim_log(mac_ctx, LOGE,
1641 FL("Session Can not be created "));
1642 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1643 goto end;
1644 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301645 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 FL("SessionId:%d New session created"),
1647 session_id);
1648 }
1649 session->isAmsduSupportInAMPDU =
1650 sme_join_req->isAmsduSupportInAMPDU;
1651
1652 /*
1653 * Store Session related parameters
1654 * Store PE session Id in session Table
1655 */
1656 session->peSessionId = session_id;
1657
1658 /* store the smejoin req handle in session table */
1659 session->pLimJoinReq = sme_join_req;
1660
1661 /* Store SME session Id in sessionTable */
1662 session->smeSessionId = sme_join_req->sessionId;
1663
1664 /* Store SME transaction Id in session Table */
1665 session->transactionId = sme_join_req->transactionId;
1666
1667 /* Store beaconInterval */
1668 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001669 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301671 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 sizeof(session->htConfig));
1673
Sandeep Puligilla98917432016-06-10 13:50:28 -07001674 qdf_mem_copy(&(session->vht_config),
1675 &(sme_join_req->vht_config),
1676 sizeof(session->vht_config));
1677
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 /* Copying of bssId is already done, while creating session */
1679 sir_copy_mac_addr(session->selfMacAddr,
1680 sme_join_req->selfMacAddr);
1681 session->bssType = sme_join_req->bsstype;
1682
1683 session->statypeForBss = STA_ENTRY_PEER;
1684 session->limWmeEnabled = sme_join_req->isWMEenabled;
1685 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301686 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687
1688 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001689 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1691
1692 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1693 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001694 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695
1696 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001697 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 session->isCiscoVendorAP = true;
1699 } else {
1700 session->isCiscoVendorAP = false;
1701 }
1702
1703 /* Copy the dot 11 mode in to the session table */
1704
1705 session->dot11mode = sme_join_req->dot11mode;
1706#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1707 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1708#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001709 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1711 session->enableHtSmps = sme_join_req->enableHtSmps;
1712 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001713 session->send_smps_action =
1714 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001715 /*
1716 * By default supported NSS 1x1 is set to true
1717 * and later on updated while determining session
1718 * supported rates which is the intersection of
1719 * self and peer rates
1720 */
1721 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301722 /*Store Persona */
1723 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001724 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301725 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001726 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001727 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001728 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301729 session->supported_nss_1x1,
1730 session->pePersona,
1731 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001732
1733 /*Store Persona */
1734 session->pePersona = sme_join_req->staPersona;
1735 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1736 FL("PE PERSONA=%d cbMode %u"),
1737 session->pePersona, sme_join_req->cbMode);
1738 /* Copy The channel Id to the session Table */
1739 session->currentOperChannel = bss_desc->channelId;
1740 if (IS_5G_CH(session->currentOperChannel))
1741 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001743 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1744 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1745 session->vdev_nss = vdev_type_nss->p2p_cli;
1746 else
1747 session->vdev_nss = vdev_type_nss->sta;
1748 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 session->vhtCapability =
1750 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301752 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001753 session->vht_config.su_beam_formee =
1754 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001756 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 session->enableVhtpAid =
1759 sme_join_req->enableVhtpAid;
1760 session->enableVhtGid =
1761 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001762 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1763 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 }
Krunal Soni53993f72016-07-08 18:20:03 -07001765
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301766 lim_log(mac_ctx, LOG1,
Krunal Soni53993f72016-07-08 18:20:03 -07001767 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301768 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001769 session->vht_config.su_beam_formee,
1770 session->vht_config.csnof_beamformer_antSup,
1771 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001773 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 /* cbMode is already merged value of peer and self -
1776 * done by csr in csr_get_cb_mode_from_ies */
1777 session->htSupportedChannelWidthSet =
1778 (sme_join_req->cbMode) ? 1 : 0;
1779 session->htRecommendedTxWidthSet =
1780 session->htSupportedChannelWidthSet;
1781 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1782
1783 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1784 session->ch_center_freq_seg0 =
1785 session->currentOperChannel - 2;
1786 session->ch_width = CH_WIDTH_40MHZ;
1787 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1788 sme_join_req->cbMode) {
1789 session->ch_center_freq_seg0 =
1790 session->currentOperChannel + 2;
1791 session->ch_width = CH_WIDTH_40MHZ;
1792 } else {
1793 session->ch_center_freq_seg0 = 0;
1794 session->ch_width = CH_WIDTH_20MHZ;
1795 }
1796
1797 /* Record if management frames need to be protected */
1798#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001799 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001801 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803#endif
1804
1805#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001806 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807#endif
1808
1809 /* Copy the SSID from smejoinreq to session entry */
1810 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301811 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 session->ssId.length);
1813
1814 /*
1815 * Determin 11r or ESE connection based on input from SME
1816 * which inturn is dependent on the profile the user wants
1817 * to connect to, So input is coming from supplicant
1818 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820#ifdef FEATURE_WLAN_ESE
1821 session->isESEconnection = sme_join_req->isESEconnection;
1822#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 session->isFastTransitionEnabled =
1824 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 session->isFastRoamIniFeatureEnabled =
1827 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 session->txLdpcIniFeatureEnabled =
1829 sme_join_req->txLdpcIniFeatureEnabled;
1830
1831 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1832 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 } else {
1834 /*
1835 * Throw an error and return and make
1836 * sure to delete the session.
1837 */
1838 lim_log(mac_ctx, LOGE,
1839 FL("recvd JOIN_REQ with invalid bss type %d"),
1840 session->bssType);
1841 ret_code = eSIR_SME_INVALID_PARAMETERS;
1842 goto end;
1843 }
1844
1845 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301846 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847 &sme_join_req->addIEScan, sizeof(tSirAddie));
1848
1849 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301850 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1852
1853 val = sizeof(tLimMlmJoinReq) +
1854 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301855 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 if (NULL == mlm_join_req) {
1857 lim_log(mac_ctx, LOGP,
1858 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301859 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1860 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862
1863 /* PE SessionId is stored as a part of JoinReq */
1864 mlm_join_req->sessionId = session->peSessionId;
1865
1866 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1867 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1868 eSIR_SUCCESS) {
1869 lim_log(mac_ctx, LOGP,
1870 FL("couldn't retrieve JoinFailureTimer value"
1871 " setting to default value"));
1872 mlm_join_req->joinFailureTimeout =
1873 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1874 }
1875
1876 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301877 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 (void *)&sme_join_req->operationalRateSet,
1879 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301880 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 (void *)&sme_join_req->extendedRateSet,
1882 sizeof(tSirMacRateSet));
1883 /*
1884 * this may not be needed anymore now, as rateSet is now
1885 * included in the session entry and MLM has session context.
1886 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301887 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 (void *)&session->rateSet,
1889 sizeof(tSirMacRateSet));
1890
1891 session->encryptType = sme_join_req->UCEncryptionType;
1892
1893 mlm_join_req->bssDescription.length =
1894 session->pLimJoinReq->bssDescription.length;
1895
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301896 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 (uint8_t *)
1898 &session->pLimJoinReq->bssDescription.bssId,
1899 session->pLimJoinReq->bssDescription.length + 2);
1900
1901 session->limCurrentBssCaps =
1902 session->pLimJoinReq->bssDescription.capabilityInfo;
1903
1904 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1905 session->currentOperChannel);
1906 local_power_constraint = reg_max;
1907
1908 lim_extract_ap_capability(mac_ctx,
1909 (uint8_t *)
1910 session->pLimJoinReq->bssDescription.ieFields,
1911 lim_get_ielen_from_bss_description(
1912 &session->pLimJoinReq->bssDescription),
1913 &session->limCurrentBssQosCaps,
1914 &session->limCurrentBssPropCap,
1915 &session->gLimCurrentBssUapsd,
1916 &local_power_constraint, session);
1917
Krunal Soni53993f72016-07-08 18:20:03 -07001918 /*
1919 * Once the AP capabilities are available then set the
1920 * beam forming capabilities accordingly.
1921 */
1922 if (session->nss == 1) {
1923 session->vht_config.su_beam_former = 0;
1924 session->vht_config.tx_stbc = 0;
1925 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301926 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001927 }
1928
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 session->maxTxPower = lim_get_max_tx_power(reg_max,
1930 local_power_constraint,
1931 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301932
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301933 lim_log(mac_ctx, LOG1,
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301934 FL("Reg max %d local power con %d max tx pwr %d"),
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301935 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936
1937 if (session->gLimCurrentBssUapsd) {
1938 session->gUapsdPerAcBitmask =
1939 session->pLimJoinReq->uapsdPerAcBitmask;
1940 lim_log(mac_ctx, LOG1,
1941 FL("UAPSD flag for all AC - 0x%2x"),
1942 session->gUapsdPerAcBitmask);
1943
1944 /* resetting the dynamic uapsd mask */
1945 session->gUapsdPerAcDeliveryEnableMask = 0;
1946 session->gUapsdPerAcTriggerEnableMask = 0;
1947 }
1948
1949 session->limRFBand =
1950 lim_get_rf_band(session->currentOperChannel);
1951
1952 /* Initialize 11h Enable Flag */
1953 if (SIR_BAND_5_GHZ == session->limRFBand) {
1954 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1955 &val) != eSIR_SUCCESS) {
1956 lim_log(mac_ctx, LOGP,
1957 FL("Fail to get WNI_CFG_11H_ENABLED "));
1958 session->lim11hEnable =
1959 WNI_CFG_11H_ENABLED_STADEF;
1960 } else {
1961 session->lim11hEnable = val;
1962 }
1963 } else {
1964 session->lim11hEnable = 0;
1965 }
1966
1967 /*
1968 * To care of the scenario when STA transitions from
1969 * IBSS to Infrastructure mode.
1970 */
1971 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1972
1973 session->limPrevSmeState = session->limSmeState;
1974 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1975 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1976 session->peSessionId,
1977 session->limSmeState));
1978
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 /* Indicate whether spectrum management is enabled */
1980 session->spectrumMgtEnabled =
1981 sme_join_req->spectrumMgtIndicator;
1982
1983 /* Enable the spectrum management if this is a DFS channel */
1984 if (session->country_info_present &&
1985 lim_isconnected_on_dfs_channel(
1986 session->currentOperChannel))
1987 session->spectrumMgtEnabled = true;
1988
1989 session->isOSENConnection = sme_join_req->isOSENConnection;
1990
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 /* Issue LIM_MLM_JOIN_REQ to MLM */
1992 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1993 (uint32_t *) mlm_join_req);
1994 return;
1995
1996 } else {
1997 /* Received eWNI_SME_JOIN_REQ un expected state */
1998 lim_log(mac_ctx, LOGE,
1999 FL("received unexpected SME_JOIN_REQ in state %X"),
2000 mac_ctx->lim.gLimSmeState);
2001 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2002 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2003 session = NULL;
2004 goto end;
2005 }
2006
2007end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302008 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2009 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010
2011 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302012 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 sme_join_req = NULL;
2014 if (NULL != session)
2015 session->pLimJoinReq = NULL;
2016 }
2017 if (ret_code != eSIR_SME_SUCCESS) {
2018 if (NULL != session) {
2019 pe_delete_session(mac_ctx, session);
2020 session = NULL;
2021 }
2022 }
2023 lim_log(mac_ctx, LOG1,
2024 FL("Send failure status on sessionid: %d with ret_code = %d"),
2025 sme_session_id, ret_code);
2026 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2027 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2028 sme_transaction_id);
2029}
2030
Amar Singhala297bfa2015-10-15 15:07:29 -07002031uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 uint8_t iniTxPower)
2033{
2034 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302035 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2036 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2038 maxTxPower = txPower;
2039 else if (txPower < MIN_TX_PWR_CAP)
2040 maxTxPower = MIN_TX_PWR_CAP;
2041 else
2042 maxTxPower = MAX_TX_PWR_CAP;
2043
2044 return maxTxPower;
2045}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046
2047/**
2048 * __lim_process_sme_reassoc_req() - process reassoc req
2049 *
2050 * @mac_ctx: Pointer to Global MAC structure
2051 * @msg_buf: pointer to the SME message buffer
2052 *
2053 * This function is called to process SME_REASSOC_REQ message
2054 * from HDD or upper layer application.
2055 *
2056 * Return: None
2057 */
2058
2059static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2060 uint32_t *msg_buf)
2061{
2062 uint16_t caps;
2063 uint32_t val;
2064 tpSirSmeJoinReq reassoc_req = NULL;
2065 tLimMlmReassocReq *mlm_reassoc_req;
2066 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2067 tpPESession session_entry = NULL;
2068 uint8_t session_id;
2069 uint8_t sme_session_id;
2070 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002071 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 uint32_t tele_bcn_en = 0;
2073 uint16_t size;
2074
2075 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2076
2077 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302078 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 if (NULL == reassoc_req) {
2080 lim_log(mac_ctx, LOGP,
2081 FL("call to AllocateMemory failed for reassoc_req"));
2082
2083 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2084 goto end;
2085 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302086 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087
2088 if (!lim_is_sme_join_req_valid(mac_ctx,
2089 (tpSirSmeJoinReq)reassoc_req)) {
2090 /*
2091 * Received invalid eWNI_SME_REASSOC_REQ
2092 */
2093 lim_log(mac_ctx, LOGW,
2094 FL("received SME_REASSOC_REQ with invalid data"));
2095
2096 ret_code = eSIR_SME_INVALID_PARAMETERS;
2097 goto end;
2098 }
2099
2100 session_entry = pe_find_session_by_bssid(mac_ctx,
2101 reassoc_req->bssDescription.bssId,
2102 &session_id);
2103 if (session_entry == NULL) {
2104 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2105 LOGE);
2106 lim_log(mac_ctx, LOGE,
2107 FL("Session does not exist for given bssId"));
2108 ret_code = eSIR_SME_INVALID_PARAMETERS;
2109 goto end;
2110 }
2111#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2112 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2113 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2114#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2115 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2116
2117 /* Store the reassoc handle in the session Table */
2118 session_entry->pLimReAssocReq = reassoc_req;
2119
2120 session_entry->dot11mode = reassoc_req->dot11mode;
2121 session_entry->vhtCapability =
2122 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002123
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302124 if (session_entry->vhtCapability) {
2125 if (session_entry->pePersona == QDF_STA_MODE) {
2126 session_entry->vht_config.su_beam_formee =
2127 reassoc_req->vht_config.su_beam_formee;
2128 } else {
2129 reassoc_req->vht_config.su_beam_formee = 0;
2130 }
2131 session_entry->enableVhtpAid =
2132 reassoc_req->enableVhtpAid;
2133 session_entry->enableVhtGid =
2134 reassoc_req->enableVhtGid;
2135 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2136 session_entry->vht_config.su_beam_former);
2137 }
2138
2139 lim_log(mac_ctx, LOG1,
2140 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2141 session_entry->vhtCapability,
2142 session_entry->vht_config.su_beam_formee,
2143 session_entry->vht_config.su_beam_former);
2144
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002145 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2146 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002147 session_entry->send_smps_action =
2148 reassoc_req->send_smps_action;
2149 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002150 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002151 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002152 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002153 session_entry->send_smps_action,
2154 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 /*
2156 * Reassociate request is expected
2157 * in link established state only.
2158 */
2159
2160 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2162 /*
2163 * May be from 11r FT pre-auth. So lets check it
2164 * before we bail out
2165 */
2166 lim_log(mac_ctx, LOG1, FL(
2167 "Session in reassoc state is %d"),
2168 session_entry->peSessionId);
2169
2170 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302171 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 session_entry->limReAssocbssId,
2173 6)) {
2174 lim_print_mac_addr(mac_ctx,
2175 reassoc_req->bssDescription.
2176 bssId, LOGE);
2177 lim_log(mac_ctx, LOGP,
2178 FL("Unknown bssId in reassoc state"));
2179 ret_code = eSIR_SME_INVALID_PARAMETERS;
2180 goto end;
2181 }
2182
2183 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2184 session_entry);
2185 return;
2186 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187 /*
2188 * Should not have received eWNI_SME_REASSOC_REQ
2189 */
2190 lim_log(mac_ctx, LOGE,
2191 FL("received unexpected SME_REASSOC_REQ in state %X"),
2192 session_entry->limSmeState);
2193 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2194
2195 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2196 goto end;
2197 }
2198
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302199 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 session_entry->pLimReAssocReq->bssDescription.bssId,
2201 sizeof(tSirMacAddr));
2202
2203 session_entry->limReassocChannelId =
2204 session_entry->pLimReAssocReq->bssDescription.channelId;
2205
2206 session_entry->reAssocHtSupportedChannelWidthSet =
2207 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2208 session_entry->reAssocHtRecommendedTxWidthSet =
2209 session_entry->reAssocHtSupportedChannelWidthSet;
2210 session_entry->reAssocHtSecondaryChannelOffset =
2211 session_entry->pLimReAssocReq->cbMode;
2212
2213 session_entry->limReassocBssCaps =
2214 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2215 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2216 session_entry->currentOperChannel);
2217 local_pwr_constraint = reg_max;
2218
2219 lim_extract_ap_capability(mac_ctx,
2220 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2221 lim_get_ielen_from_bss_description(
2222 &session_entry->pLimReAssocReq->bssDescription),
2223 &session_entry->limReassocBssQosCaps,
2224 &session_entry->limReassocBssPropCap,
2225 &session_entry->gLimCurrentBssUapsd,
2226 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302227 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302229 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2230 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 /* Copy the SSID from session entry to local variable */
2232 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302233 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 reassoc_req->ssId.ssId,
2235 session_entry->limReassocSSID.length);
2236 if (session_entry->gLimCurrentBssUapsd) {
2237 session_entry->gUapsdPerAcBitmask =
2238 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2239 lim_log(mac_ctx, LOG1,
2240 FL("UAPSD flag for all AC - 0x%2x"),
2241 session_entry->gUapsdPerAcBitmask);
2242 }
2243
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302244 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 if (NULL == mlm_reassoc_req) {
2246 lim_log(mac_ctx, LOGP,
2247 FL("call to AllocateMemory failed for mlmReassocReq"));
2248
2249 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2250 goto end;
2251 }
2252
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302253 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2255
2256 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2257 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2258 eSIR_SUCCESS) {
2259 /*
2260 * Could not get ReassocFailureTimeout value
2261 * from CFG. Log error.
2262 */
2263 lim_log(mac_ctx, LOGP,
2264 FL("could not retrieve ReassocFailureTimeout value"));
2265 }
2266
2267 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2268 eSIR_SUCCESS) {
2269 /*
2270 * Could not get Capabilities value
2271 * from CFG. Log error.
2272 */
2273 lim_log(mac_ctx, LOGP, FL(
2274 "could not retrieve Capabilities value"));
2275 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302276
2277 lim_update_caps_info_for_bss(mac_ctx, &caps,
2278 reassoc_req->bssDescription.capabilityInfo);
2279 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2280
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 mlm_reassoc_req->capabilityInfo = caps;
2282
2283 /* Update PE session_id */
2284 mlm_reassoc_req->sessionId = session_id;
2285
2286 /*
2287 * If telescopic beaconing is enabled, set listen interval to
2288 * WNI_CFG_TELE_BCN_MAX_LI
2289 */
2290 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2291 &tele_bcn_en) != eSIR_SUCCESS)
2292 lim_log(mac_ctx, LOGP,
2293 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2294
2295 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2296
2297 if (tele_bcn_en) {
2298 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2299 eSIR_SUCCESS)
2300 /*
2301 * Could not get ListenInterval value
2302 * from CFG. Log error.
2303 */
2304 lim_log(mac_ctx, LOGP,
2305 FL("could not retrieve ListenInterval"));
2306 } else {
2307 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &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 }
2316
2317 mlm_reassoc_req->listenInterval = (uint16_t) val;
2318
2319 /* Indicate whether spectrum management is enabled */
2320 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2321
2322 /* Enable the spectrum management if this is a DFS channel */
2323 if (session_entry->country_info_present &&
2324 lim_isconnected_on_dfs_channel(
2325 session_entry->currentOperChannel))
2326 session_entry->spectrumMgtEnabled = true;
2327
2328 session_entry->limPrevSmeState = session_entry->limSmeState;
2329 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2330
2331 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2332 session_entry->peSessionId,
2333 session_entry->limSmeState));
2334
2335 lim_post_mlm_message(mac_ctx,
2336 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2337 return;
2338end:
2339 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302340 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 if (session_entry)
2342 session_entry->pLimReAssocReq = NULL;
2343 }
2344
2345 if (session_entry) {
2346 /*
2347 * error occurred after we determined the session so extract
2348 * session and transaction info from there
2349 */
2350 sme_session_id = session_entry->smeSessionId;
2351 transaction_id = session_entry->transactionId;
2352 } else
2353 /*
2354 * error occurred before or during the time we determined
2355 * the session so extract the session and transaction info
2356 * from the message
2357 */
2358 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2359 &sme_session_id, &transaction_id);
2360
2361 /*
2362 * Send Reassoc failure response to host
2363 * (note session_entry may be NULL, but that's OK)
2364 */
2365 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2366 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2367 session_entry, sme_session_id,
2368 transaction_id);
2369}
2370
2371bool send_disassoc_frame = 1;
2372/**
2373 * __lim_process_sme_disassoc_req()
2374 *
2375 ***FUNCTION:
2376 * This function is called to process SME_DISASSOC_REQ message
2377 * from HDD or upper layer application.
2378 *
2379 ***LOGIC:
2380 *
2381 ***ASSUMPTIONS:
2382 *
2383 ***NOTE:
2384 *
2385 * @param pMac Pointer to Global MAC structure
2386 * @param *pMsgBuf A pointer to the SME message buffer
2387 * @return None
2388 */
2389
2390static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2391{
2392 uint16_t disassocTrigger, reasonCode;
2393 tLimMlmDisassocReq *pMlmDisassocReq;
2394 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2395 tSirSmeDisassocReq smeDisassocReq;
2396 tpPESession psessionEntry = NULL;
2397 uint8_t sessionId;
2398 uint8_t smesessionId;
2399 uint16_t smetransactionId;
2400
2401 if (pMsgBuf == NULL) {
2402 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2403 return;
2404 }
2405
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302406 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 smesessionId = smeDisassocReq.sessionId;
2408 smetransactionId = smeDisassocReq.transactionId;
2409 if (!lim_is_sme_disassoc_req_valid(pMac,
2410 &smeDisassocReq,
2411 psessionEntry)) {
2412 PELOGE(lim_log(pMac, LOGE,
2413 FL("received invalid SME_DISASSOC_REQ message"));)
2414 if (pMac->lim.gLimRspReqd) {
2415 pMac->lim.gLimRspReqd = false;
2416
2417 retCode = eSIR_SME_INVALID_PARAMETERS;
2418 disassocTrigger = eLIM_HOST_DISASSOC;
2419 goto sendDisassoc;
2420 }
2421
2422 return;
2423 }
2424
2425 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002426 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 &sessionId);
2428 if (psessionEntry == NULL) {
2429 lim_log(pMac, LOGE,
2430 FL("session does not exist for given bssId "
2431 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002432 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 retCode = eSIR_SME_INVALID_PARAMETERS;
2434 disassocTrigger = eLIM_HOST_DISASSOC;
2435 goto sendDisassoc;
2436 }
2437 lim_log(pMac, LOG1,
2438 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2439 MAC_ADDRESS_STR), smesessionId,
2440 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2441 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002442 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443
2444#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2445 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2446 0, smeDisassocReq.reasonCode);
2447#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2448
2449 /* Update SME session Id and SME transaction ID */
2450
2451 psessionEntry->smeSessionId = smesessionId;
2452 psessionEntry->transactionId = smetransactionId;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002453 lim_log(pMac, LOGW, FL("ho_fail: %d "), smeDisassocReq.process_ho_fail);
2454 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455
2456 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2457 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458 switch (psessionEntry->limSmeState) {
2459 case eLIM_SME_ASSOCIATED_STATE:
2460 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002461 lim_log(pMac, LOG1,
2462 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2463 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 psessionEntry->limPrevSmeState =
2465 psessionEntry->limSmeState;
2466 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2467#ifdef FEATURE_WLAN_TDLS
2468 /* Delete all TDLS peers connected before leaving BSS */
2469 lim_delete_tdls_peers(pMac, psessionEntry);
2470#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002471 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2472 psessionEntry->peSessionId,
2473 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 break;
2475
2476 case eLIM_SME_WT_DEAUTH_STATE:
2477 /* PE shall still process the DISASSOC_REQ and proceed with
2478 * link tear down even if it had already sent a DEAUTH_IND to
2479 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2480 * its been set when PE entered WT_DEAUTH_STATE.
2481 */
2482 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2483 MTRACE(mac_trace
2484 (pMac, TRACE_CODE_SME_STATE,
2485 psessionEntry->peSessionId,
2486 psessionEntry->limSmeState));
2487 lim_log(pMac, LOG1,
2488 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2489 break;
2490
2491 case eLIM_SME_WT_DISASSOC_STATE:
2492 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2493 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2494 * PE can continue processing DISASSOC_REQ and send the response instead
2495 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2496 * for disassoc frame.
2497 *
2498 * It will send a disassoc, which is ok. However, we can use the global flag
2499 * sendDisassoc to not send disassoc frame.
2500 */
2501 lim_log(pMac, LOG1,
2502 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2503 break;
2504
2505 case eLIM_SME_JOIN_FAILURE_STATE: {
2506 /* Already in Disconnected State, return success */
2507 lim_log(pMac, LOG1,
2508 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2509 if (pMac->lim.gLimRspReqd) {
2510 retCode = eSIR_SME_SUCCESS;
2511 disassocTrigger = eLIM_HOST_DISASSOC;
2512 goto sendDisassoc;
2513 }
2514 }
2515 break;
2516 default:
2517 /**
2518 * STA is not currently associated.
2519 * Log error and send response to host
2520 */
2521 lim_log(pMac, LOGE,
2522 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2523 psessionEntry->limSmeState);
2524 lim_print_sme_state(pMac, LOGE,
2525 psessionEntry->limSmeState);
2526
2527 if (pMac->lim.gLimRspReqd) {
2528 if (psessionEntry->limSmeState !=
2529 eLIM_SME_WT_ASSOC_STATE)
2530 pMac->lim.gLimRspReqd = false;
2531
2532 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2533 disassocTrigger = eLIM_HOST_DISASSOC;
2534 goto sendDisassoc;
2535 }
2536
2537 return;
2538 }
2539
2540 break;
2541
2542 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 /* Fall through */
2544 break;
2545
2546 case eLIM_STA_IN_IBSS_ROLE:
2547 default:
2548 /* eLIM_UNKNOWN_ROLE */
2549 lim_log(pMac, LOGE,
2550 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2551 GET_LIM_SYSTEM_ROLE(psessionEntry));
2552
2553 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2554 disassocTrigger = eLIM_HOST_DISASSOC;
2555 goto sendDisassoc;
2556 } /* end switch (pMac->lim.gLimSystemRole) */
2557
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302558 disassocTrigger = eLIM_HOST_DISASSOC;
2559 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560
2561 if (smeDisassocReq.doNotSendOverTheAir) {
2562 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2563 send_disassoc_frame = 0;
2564 }
2565 /* Trigger Disassociation frame to peer MAC entity */
2566 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2567 " : %d, reasonCode : %d"),
2568 disassocTrigger, reasonCode);
2569
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302570 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571 if (NULL == pMlmDisassocReq) {
2572 /* Log error */
2573 lim_log(pMac, LOGP,
2574 FL("call to AllocateMemory failed for mlmDisassocReq"));
2575
2576 return;
2577 }
2578
Anurag Chouhanc5548422016-02-24 18:33:27 +05302579 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002580 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581
2582 pMlmDisassocReq->reasonCode = reasonCode;
2583 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2584
2585 /* Update PE session ID */
2586 pMlmDisassocReq->sessionId = sessionId;
2587
2588 lim_post_mlm_message(pMac,
2589 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2590 return;
2591
2592sendDisassoc:
2593 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002594 lim_send_sme_disassoc_ntf(pMac,
2595 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 retCode,
2597 disassocTrigger,
2598 1, smesessionId, smetransactionId,
2599 psessionEntry);
2600 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002601 lim_send_sme_disassoc_ntf(pMac,
2602 smeDisassocReq.peer_macaddr.bytes,
2603 retCode, disassocTrigger, 1,
2604 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605
2606} /*** end __lim_process_sme_disassoc_req() ***/
2607
2608/** -----------------------------------------------------------------
2609 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2610
2611 This function is called to process SME_DISASSOC_CNF message
2612 from HDD or upper layer application.
2613
2614 \param pMac - global mac structure
2615 \param pStaDs - station dph hash node
2616 \return none
2617 \sa
2618 ----------------------------------------------------------------- */
2619static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2620{
2621 tSirSmeDisassocCnf smeDisassocCnf;
2622 uint16_t aid;
2623 tpDphHashNode pStaDs;
2624 tpPESession psessionEntry;
2625 uint8_t sessionId;
2626
2627 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2628
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302629 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 sizeof(struct sSirSmeDisassocCnf));
2631
2632 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002633 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634 &sessionId);
2635 if (psessionEntry == NULL) {
2636 lim_log(pMac, LOGE,
2637 FL("session does not exist for given bssId"));
2638 return;
2639 }
2640
2641 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2642 lim_log(pMac, LOGE,
2643 FL("received invalid SME_DISASSOC_CNF message"));
2644 return;
2645 }
2646#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2647 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2648 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2649 psessionEntry,
2650 (uint16_t) smeDisassocCnf.statusCode, 0);
2651 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2652 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2653 psessionEntry,
2654 (uint16_t) smeDisassocCnf.statusCode, 0);
2655#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2656
2657 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2658 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2660 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2661 && (psessionEntry->limSmeState !=
2662 eLIM_SME_WT_DEAUTH_STATE)) {
2663 lim_log(pMac, LOGE,
2664 FL
2665 ("received unexp SME_DISASSOC_CNF in state %X"),
2666 psessionEntry->limSmeState);
2667 lim_print_sme_state(pMac, LOGE,
2668 psessionEntry->limSmeState);
2669 return;
2670 }
2671 break;
2672
2673 case eLIM_AP_ROLE:
2674 /* Fall through */
2675 break;
2676
2677 case eLIM_STA_IN_IBSS_ROLE:
2678 default: /* eLIM_UNKNOWN_ROLE */
2679 lim_log(pMac, LOGE,
2680 FL("received unexpected SME_DISASSOC_CNF role %d"),
2681 GET_LIM_SYSTEM_ROLE(psessionEntry));
2682
2683 return;
2684 }
2685
2686 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2687 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2688 LIM_IS_AP_ROLE(psessionEntry)) {
2689 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002690 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002691 &psessionEntry->dph.dphHashTable);
2692 if (pStaDs == NULL) {
2693 lim_log(pMac, LOGE,
2694 FL("DISASSOC_CNF for a STA with no context, addr= "
2695 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002696 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 return;
2698 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302699
2700 if ((pStaDs->mlmStaContext.mlmState ==
2701 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2702 (pStaDs->mlmStaContext.mlmState ==
2703 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2704 lim_log(pMac, LOGE,
2705 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002706 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302707 pStaDs->mlmStaContext.mlmState);
2708 return;
2709 }
2710
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 /* Delete FT session if there exists one */
2712 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2714
2715 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002716 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 }
2718
2719 return;
2720}
2721
2722/**
2723 * __lim_process_sme_deauth_req() - process sme deauth req
2724 * @mac_ctx: Pointer to Global MAC structure
2725 * @msg_buf: pointer to the SME message buffer
2726 *
2727 * This function is called to process SME_DEAUTH_REQ message
2728 * from HDD or upper layer application.
2729 *
2730 * Return: None
2731 */
2732
2733static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2734 uint32_t *msg_buf)
2735{
2736 uint16_t deauth_trigger, reason_code;
2737 tLimMlmDeauthReq *mlm_deauth_req;
2738 tSirSmeDeauthReq sme_deauth_req;
2739 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2740 tpPESession session_entry;
2741 uint8_t session_id; /* PE sessionId */
2742 uint8_t sme_session_id;
2743 uint16_t sme_transaction_id;
2744
2745 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2746
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302747 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 sme_session_id = sme_deauth_req.sessionId;
2749 sme_transaction_id = sme_deauth_req.transactionId;
2750
2751 /*
2752 * We need to get a session first but we don't even know
2753 * if the message is correct.
2754 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002755 session_entry = pe_find_session_by_bssid(mac_ctx,
2756 sme_deauth_req.bssid.bytes,
2757 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 if (session_entry == NULL) {
2759 lim_log(mac_ctx, LOGE,
2760 FL("session does not exist for given bssId"));
2761 ret_code = eSIR_SME_INVALID_PARAMETERS;
2762 deauth_trigger = eLIM_HOST_DEAUTH;
2763 goto send_deauth;
2764 }
2765
2766 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2767 session_entry)) {
2768 lim_log(mac_ctx, LOGE,
2769 FL("received invalid SME_DEAUTH_REQ message"));
2770 mac_ctx->lim.gLimRspReqd = false;
2771
2772 ret_code = eSIR_SME_INVALID_PARAMETERS;
2773 deauth_trigger = eLIM_HOST_DEAUTH;
2774 goto send_deauth;
2775 }
2776 lim_log(mac_ctx, LOG1,
2777 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2778 MAC_ADDRESS_STR), sme_session_id,
2779 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2780 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002781 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2783 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2784 session_entry, 0, sme_deauth_req.reasonCode);
2785#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2786
2787 /* Update SME session ID and Transaction ID */
2788 session_entry->smeSessionId = sme_session_id;
2789 session_entry->transactionId = sme_transaction_id;
2790
2791 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2792 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 switch (session_entry->limSmeState) {
2794 case eLIM_SME_ASSOCIATED_STATE:
2795 case eLIM_SME_LINK_EST_STATE:
2796 case eLIM_SME_WT_ASSOC_STATE:
2797 case eLIM_SME_JOIN_FAILURE_STATE:
2798 case eLIM_SME_IDLE_STATE:
2799 session_entry->limPrevSmeState =
2800 session_entry->limSmeState;
2801 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2802 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2803 session_entry->peSessionId,
2804 session_entry->limSmeState));
2805 /* Send Deauthentication request to MLM below */
2806 break;
2807 case eLIM_SME_WT_DEAUTH_STATE:
2808 case eLIM_SME_WT_DISASSOC_STATE:
2809 /*
2810 * PE Recieved a Deauth/Disassoc frame. Normally it get
2811 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2812 * Which means host is also trying to disconnect.
2813 * PE can continue processing DEAUTH_REQ and send
2814 * the response instead of failing the request.
2815 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2816 * was sent for deauth/disassoc frame.
2817 */
2818 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2819 lim_log(mac_ctx, LOG1, FL(
2820 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2821 break;
2822 default:
2823 /*
2824 * STA is not in a state to deauthenticate with
2825 * peer. Log error and send response to host.
2826 */
2827 lim_log(mac_ctx, LOGE, FL(
2828 "received unexp SME_DEAUTH_REQ in state %X"),
2829 session_entry->limSmeState);
2830 lim_print_sme_state(mac_ctx, LOGE,
2831 session_entry->limSmeState);
2832
2833 if (mac_ctx->lim.gLimRspReqd) {
2834 mac_ctx->lim.gLimRspReqd = false;
2835
2836 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2837 deauth_trigger = eLIM_HOST_DEAUTH;
2838
2839 /*
2840 * here we received deauth request from AP so sme state
2841 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2842 * delSta then mlm state should be
2843 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2844 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2845 * so the below condition captures the state where
2846 * delSta not done and firmware still in
2847 * connected state.
2848 */
2849 if (session_entry->limSmeState ==
2850 eLIM_SME_WT_DEAUTH_STATE &&
2851 session_entry->limMlmState !=
2852 eLIM_MLM_IDLE_STATE &&
2853 session_entry->limMlmState !=
2854 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2855 ret_code = eSIR_SME_DEAUTH_STATUS;
2856 goto send_deauth;
2857 }
2858 return;
2859 }
2860 break;
2861
2862 case eLIM_STA_IN_IBSS_ROLE:
2863 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2864 if (mac_ctx->lim.gLimRspReqd) {
2865 mac_ctx->lim.gLimRspReqd = false;
2866 ret_code = eSIR_SME_INVALID_PARAMETERS;
2867 deauth_trigger = eLIM_HOST_DEAUTH;
2868 goto send_deauth;
2869 }
2870 return;
2871 case eLIM_AP_ROLE:
2872 break;
2873 default:
2874 lim_log(mac_ctx, LOGE,
2875 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2876 GET_LIM_SYSTEM_ROLE(session_entry));
2877 if (mac_ctx->lim.gLimRspReqd) {
2878 mac_ctx->lim.gLimRspReqd = false;
2879 ret_code = eSIR_SME_INVALID_PARAMETERS;
2880 deauth_trigger = eLIM_HOST_DEAUTH;
2881 goto send_deauth;
2882 }
2883 return;
2884 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2885
2886 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2887 /* Deauthentication is triggered by Link Monitoring */
2888 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2889 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2890 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2891 } else {
2892 deauth_trigger = eLIM_HOST_DEAUTH;
2893 reason_code = sme_deauth_req.reasonCode;
2894 }
2895
2896 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302897 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 if (NULL == mlm_deauth_req) {
2899 lim_log(mac_ctx, LOGP,
2900 FL("call to AllocateMemory failed for mlmDeauthReq"));
2901 if (mac_ctx->lim.gLimRspReqd) {
2902 mac_ctx->lim.gLimRspReqd = false;
2903 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2904 deauth_trigger = eLIM_HOST_DEAUTH;
2905 goto send_deauth;
2906 }
2907 return;
2908 }
2909
Anurag Chouhanc5548422016-02-24 18:33:27 +05302910 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002911 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912
2913 mlm_deauth_req->reasonCode = reason_code;
2914 mlm_deauth_req->deauthTrigger = deauth_trigger;
2915
2916 /* Update PE session Id */
2917 mlm_deauth_req->sessionId = session_id;
2918
2919 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2920 (uint32_t *)mlm_deauth_req);
2921 return;
2922
2923send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002924 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2925 ret_code, deauth_trigger, 1,
2926 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927}
2928
2929/**
2930 * __lim_process_sme_set_context_req()
2931 *
2932 * @mac_ctx: Pointer to Global MAC structure
2933 * @msg_buf: pointer to the SME message buffer
2934 *
2935 * This function is called to process SME_SETCONTEXT_REQ message
2936 * from HDD or upper layer application.
2937 *
2938 * Return: None
2939 */
2940
2941static void
2942__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2943{
2944 tpSirSmeSetContextReq set_context_req;
2945 tLimMlmSetKeysReq *mlm_set_key_req;
2946 tpPESession session_entry;
2947 uint8_t session_id; /* PE sessionID */
2948 uint8_t sme_session_id;
2949 uint16_t sme_transaction_id;
2950
2951 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2952
2953 if (msg_buf == NULL) {
2954 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2955 return;
2956 }
2957
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302958 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 if (NULL == set_context_req) {
2960 lim_log(mac_ctx, LOGP, FL(
2961 "call to AllocateMemory failed for set_context_req"));
2962 return;
2963 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302964 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 sizeof(struct sSirSmeSetContextReq));
2966 sme_session_id = set_context_req->sessionId;
2967 sme_transaction_id = set_context_req->transactionId;
2968
2969 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2970 lim_log(mac_ctx, LOGW,
2971 FL("received invalid SME_SETCONTEXT_REQ message"));
2972 goto end;
2973 }
2974
2975 if (set_context_req->keyMaterial.numKeys >
2976 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2977 lim_log(mac_ctx, LOGE, FL(
2978 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2979 set_context_req->keyMaterial.numKeys);
2980 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002981 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 eSIR_SME_INVALID_PARAMETERS, NULL,
2983 sme_session_id, sme_transaction_id);
2984 goto end;
2985 }
2986
2987 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002988 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 if (session_entry == NULL) {
2990 lim_log(mac_ctx, LOGW,
2991 FL("Session does not exist for given BSSID"));
2992 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002993 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994 eSIR_SME_INVALID_PARAMETERS, NULL,
2995 sme_session_id, sme_transaction_id);
2996 goto end;
2997 }
2998#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2999 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3000 session_entry, 0, 0);
3001#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3002
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003003 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3005 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003006 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3008 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303009 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 if (NULL == mlm_set_key_req) {
3011 lim_log(mac_ctx, LOGP, FL(
3012 "mem alloc failed for mlmSetKeysReq"));
3013 goto end;
3014 }
3015 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3016 mlm_set_key_req->numKeys =
3017 set_context_req->keyMaterial.numKeys;
3018 if (mlm_set_key_req->numKeys >
3019 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3020 lim_log(mac_ctx, LOGP, FL(
3021 "no.of keys exceeded max num of default keys limit"));
3022 goto end;
3023 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303024 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003025 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303027 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 (uint8_t *) &set_context_req->keyMaterial.key,
3029 sizeof(tSirKeys) *
3030 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3031 numKeys : 1));
3032
3033 mlm_set_key_req->sessionId = session_id;
3034 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 lim_log(mac_ctx, LOG1, FL(
3036 "received SETCONTEXT_REQ message sessionId=%d"),
3037 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038
3039 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3040 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3041 LIM_IS_AP_ROLE(session_entry)) {
3042 if (set_context_req->keyMaterial.key[0].keyLength) {
3043 uint8_t key_id;
3044 key_id =
3045 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303046 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 &session_entry->WEPKeyMaterial[key_id],
3048 (uint8_t *) &set_context_req->keyMaterial,
3049 sizeof(tSirKeyMaterial));
3050 } else {
3051 uint32_t i;
3052 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3053 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303054 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 &mlm_set_key_req->key[i],
3056 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3057 sizeof(tSirKeys));
3058 }
3059 }
3060 }
3061 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3062 (uint32_t *) mlm_set_key_req);
3063 } else {
3064 lim_log(mac_ctx, LOGE, FL(
3065 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3066 GET_LIM_SYSTEM_ROLE(session_entry),
3067 session_entry->limSmeState);
3068 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3069
3070 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003071 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3073 session_entry, sme_session_id,
3074 sme_transaction_id);
3075 }
3076end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303077 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 return;
3079}
3080
3081/**
3082 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3083 *
3084 * @mac_ctx: Pointer to Global MAC structure
3085 * @msg_buf: pointer to the SME message buffer
3086 *
3087 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3088 * from HDD or upper layer application.
3089 *
3090 * Return: None
3091 */
3092
Jeff Johnson801f1532016-10-07 07:54:50 -07003093static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3094 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095{
3096 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3097 tpDphHashNode sta_ds = NULL;
3098 tpPESession session_entry = NULL;
3099 tSap_Event sap_event;
3100 tpWLAN_SAPEventCB sap_event_cb = NULL;
3101 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3102 uint8_t session_id = CSR_SESSION_ID_INVALID;
3103 uint8_t assoc_id = 0;
3104 uint8_t sta_cnt = 0;
3105
3106 if (msg_buf == NULL) {
3107 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3108 return;
3109 }
3110
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303111 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112 sizeof(struct sSirSmeGetAssocSTAsReq));
3113 /*
3114 * Get Associated stations from PE.
3115 * Find PE session Entry
3116 */
3117 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003118 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 &session_id);
3120 if (session_entry == NULL) {
3121 lim_log(mac_ctx, LOGE,
3122 FL("session does not exist for given bssId"));
3123 goto lim_assoc_sta_end;
3124 }
3125
3126 if (!LIM_IS_AP_ROLE(session_entry)) {
3127 lim_log(mac_ctx, LOGE, FL(
3128 "Received unexpected message in state %X, in role %X"),
3129 session_entry->limSmeState,
3130 GET_LIM_SYSTEM_ROLE(session_entry));
3131 goto lim_assoc_sta_end;
3132 }
3133 /* Retrieve values obtained in the request message */
3134 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3135 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3136
3137 if (NULL == assoc_sta_tmp)
3138 goto lim_assoc_sta_end;
3139 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3140 assoc_id++) {
3141 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3142 &session_entry->dph.dphHashTable);
3143 if (NULL == sta_ds)
3144 continue;
3145 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303146 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303148 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3150 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3151
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303152 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 (uint8_t *)&sta_ds->supportedRates,
3154 sizeof(tSirSupportedRates));
3155 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3156 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3157 assoc_sta_tmp->Support40Mhz =
3158 sta_ds->htDsssCckRate40MHzSupport;
3159
3160 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3161 sta_cnt + 1);
3162 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3163 MAC_ADDR_ARRAY(sta_ds->staAddr));
3164 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3165 sta_ds->assocId);
3166 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3167 sta_ds->staIndex);
3168 assoc_sta_tmp++;
3169 sta_cnt++;
3170 }
3171 }
3172lim_assoc_sta_end:
3173 /*
3174 * Call hdd callback with sap event to send the list of
3175 * associated stations from PE
3176 */
3177 if (sap_event_cb != NULL) {
3178 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3179 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303180 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3182 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3183 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3184 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3185 }
3186}
3187
3188/**
3189 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3190 *
3191 * @mac_ctx: Pointer to Global MAC structure
3192 * @msg_buf: pointer to WPS PBC overlap query message
3193 *
3194 * This function parses get WPS PBC overlap information
3195 * message and call callback to pass WPS PBC overlap
3196 * information back to hdd.
3197 *
3198 * Return: None
3199 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003200static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3201 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202{
3203 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3204 tpPESession session_entry = NULL;
3205 tSap_Event sap_event;
3206 tpWLAN_SAPEventCB sap_event_cb = NULL;
3207 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3209
3210 if (msg_buf == NULL) {
3211 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3212 return;
3213 }
3214
3215 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303216 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303218 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3220 /*
3221 * Get Associated stations from PE
3222 * Find PE session Entry
3223 */
3224 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003225 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 if (session_entry == NULL) {
3227 lim_log(mac_ctx, LOGE,
3228 FL("session does not exist for given bssId"));
3229 goto lim_get_wpspbc_sessions_end;
3230 }
3231
3232 if (!LIM_IS_AP_ROLE(session_entry)) {
3233 lim_log(mac_ctx, LOGE,
3234 FL("Received unexpected message in role %X"),
3235 GET_LIM_SYSTEM_ROLE(session_entry));
3236 goto lim_get_wpspbc_sessions_end;
3237 }
3238 /*
3239 * Call hdd callback with sap event to send the
3240 * WPS PBC overlap information
3241 */
3242 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303243 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244
Anurag Chouhanc5548422016-02-24 18:33:27 +05303245 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003247 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 sap_get_wpspbc_event->UUID_E,
3249 &sap_get_wpspbc_event->wpsPBCOverlap,
3250 session_entry);
3251 } else {
3252 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003253 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 session_entry);
3255 /* don't have to inform the HDD/Host */
3256 return;
3257 }
3258
3259 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3260 sap_get_wpspbc_event->wpsPBCOverlap);
3261 lim_print_mac_addr(mac_ctx,
3262 sap_get_wpspbc_event->addr.bytes, LOG4);
3263
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303264 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265
3266lim_get_wpspbc_sessions_end:
3267 sap_event_cb =
3268 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3269 if (NULL != sap_event_cb)
3270 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3271}
3272
3273/**
3274 * __lim_counter_measures()
3275 *
3276 * FUNCTION:
3277 * This function is called to "implement" MIC counter measure
3278 * and is *temporary* only
3279 *
3280 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3281 * we don't do the proper STA disassoc sequence since the
3282 * BSS will be stoped anyway
3283 *
3284 ***ASSUMPTIONS:
3285 *
3286 ***NOTE:
3287 *
3288 * @param pMac Pointer to Global MAC structure
3289 * @return None
3290 */
3291
3292static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3293{
3294 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003295 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3297 mac, psessionEntry, false);
3298};
3299
Jeff Johnson801f1532016-10-07 07:54:50 -07003300static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3301 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302{
3303 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3304 tpPESession psessionEntry;
3305 uint8_t sessionId; /* PE sessionId */
3306
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303307 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 sizeof(struct sSirSmeTkipCntrMeasReq));
3309
3310 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003311 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 if (NULL == psessionEntry) {
3313 lim_log(pMac, LOGE,
3314 FL("session does not exist for given BSSID "));
3315 return;
3316 }
3317
3318 if (tkipCntrMeasReq.bEnable)
3319 __lim_counter_measures(pMac, psessionEntry);
3320
3321 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3322}
3323
3324static void
3325__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3326{
3327 tSirSmeStopBssReq stopBssReq;
3328 tSirRetStatus status;
3329 tLimSmeStates prevState;
3330 tpPESession psessionEntry;
3331 uint8_t smesessionId;
3332 uint8_t sessionId;
3333 uint16_t smetransactionId;
3334 uint8_t i = 0;
3335 tpDphHashNode pStaDs = NULL;
3336
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303337 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 smesessionId = stopBssReq.sessionId;
3339 smetransactionId = stopBssReq.transactionId;
3340
3341 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3342 PELOGW(lim_log(pMac, LOGW,
3343 FL("received invalid SME_STOP_BSS_REQ message"));)
3344 /* Send Stop BSS response to host */
3345 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3346 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3347 smetransactionId);
3348 return;
3349 }
3350
3351 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003352 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 &sessionId);
3354 if (psessionEntry == NULL) {
3355 lim_log(pMac, LOGW,
3356 FL("session does not exist for given BSSID "));
3357 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3358 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3359 smetransactionId);
3360 return;
3361 }
3362#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3363 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3364 0, 0);
3365#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3366
3367 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3368 LIM_IS_STA_ROLE(psessionEntry)) {
3369 /**
3370 * Should not have received STOP_BSS_REQ in states
3371 * other than 'normal' state or on STA in Infrastructure
3372 * mode. Log error and return response to host.
3373 */
3374 lim_log(pMac, LOGE,
3375 FL
3376 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3377 psessionEntry->limSmeState,
3378 GET_LIM_SYSTEM_ROLE(psessionEntry));
3379 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3380 /* / Send Stop BSS response to host */
3381 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3382 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3383 smetransactionId);
3384 return;
3385 }
3386
3387 if (LIM_IS_AP_ROLE(psessionEntry))
3388 lim_wpspbc_close(pMac, psessionEntry);
3389
3390 lim_log(pMac, LOGW,
3391 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3392 stopBssReq.reasonCode);
3393
3394 prevState = psessionEntry->limSmeState;
3395
3396 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3397 MTRACE(mac_trace
3398 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3399 psessionEntry->limSmeState));
3400
3401 /* Update SME session Id and Transaction Id */
3402 psessionEntry->smeSessionId = smesessionId;
3403 psessionEntry->transactionId = smetransactionId;
3404
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003405 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3406 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3407 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3409 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3410 /* Send disassoc all stations associated thru TKIP */
3411 __lim_counter_measures(pMac, psessionEntry);
3412 else
3413 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003414 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3415 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 }
3417
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003418 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3419 /* Free the buffer allocated in START_BSS_REQ */
3420 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3421 psessionEntry->addIeParams.probeRespDataLen = 0;
3422 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003424 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3425 psessionEntry->addIeParams.assocRespDataLen = 0;
3426 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003428 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3429 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3430 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003432 /*
3433 * lim_del_bss is also called as part of coalescing,
3434 * when we send DEL BSS followed by Add Bss msg.
3435 */
3436 pMac->lim.gLimIbssCoalescingHappened = false;
3437 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3439 pStaDs =
3440 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3441 if (NULL == pStaDs)
3442 continue;
3443 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3444 if (eSIR_SUCCESS == status) {
3445 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3446 pStaDs->assocId, psessionEntry);
3447 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3448 } else {
3449 lim_log(pMac, LOGE,
3450 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303451 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 }
3453 }
3454 /* send a delBss to HAL and wait for a response */
3455 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3456
3457 if (status != eSIR_SUCCESS) {
3458 PELOGE(lim_log
3459 (pMac, LOGE, FL("delBss failed for bss %d"),
3460 psessionEntry->bssIdx);
3461 )
3462 psessionEntry->limSmeState = prevState;
3463
3464 MTRACE(mac_trace
3465 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3466 psessionEntry->limSmeState));
3467
3468 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3469 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3470 smetransactionId);
3471 }
3472}
3473
3474/**
3475 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3476 * @pMac: Global MAC context
3477 * @pMsg: Message from SME
3478 *
3479 * Wrapper for the function __lim_handle_sme_stop_bss_request
3480 * This message will be defered until softmac come out of
3481 * scan mode. Message should be handled even if we have
3482 * detected radar in the current operating channel.
3483 *
3484 * Return: true - If we consumed the buffer
3485 * false - If have defered the message.
3486 */
3487
3488static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3489{
3490 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3491 /**
3492 * If message defered, buffer is not consumed yet.
3493 * So return false
3494 */
3495 return false;
3496 }
3497 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3498 return true;
3499} /*** end __lim_process_sme_stop_bss_req() ***/
3500
3501void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3502 uint32_t body, tpPESession psessionEntry)
3503{
3504
3505 (void)body;
3506 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3507 lim_ibss_delete(pMac, psessionEntry);
3508 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3509 lim_delete_pre_auth_list(pMac);
3510 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3511 psessionEntry->smeSessionId,
3512 psessionEntry->transactionId);
3513 return;
3514}
3515
3516/**
3517 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3518 *
3519 * @mac_ctx: pointer to mac context
3520 * @msg_type: message type
3521 * @msg_buf: pointer to the SME message buffer
3522 *
3523 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3524 * in BTAMP AP.
3525 *
3526 * Return: None
3527 */
3528
3529void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3530 uint32_t *msg_buf)
3531{
3532 tSirSmeAssocCnf assoc_cnf;
3533 tpDphHashNode sta_ds = NULL;
3534 tpPESession session_entry = NULL;
3535 uint8_t session_id;
3536 tpSirAssocReq assoc_req;
3537
3538 if (msg_buf == NULL) {
3539 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3540 goto end;
3541 }
3542
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303543 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3545 lim_log(mac_ctx, LOGE,
3546 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3547 goto end;
3548 }
3549
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003550 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 &session_id);
3552 if (session_entry == NULL) {
3553 lim_log(mac_ctx, LOGE,
3554 FL("session does not exist for given bssId"));
3555 goto end;
3556 }
3557
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003558 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3560 (session_entry->limSmeState !=
3561 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3562 lim_log(mac_ctx, LOGE, FL(
3563 "Rcvd unexpected msg %X in state %X, in role %X"),
3564 msg_type, session_entry->limSmeState,
3565 GET_LIM_SYSTEM_ROLE(session_entry));
3566 goto end;
3567 }
3568 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3569 &session_entry->dph.dphHashTable);
3570 if (sta_ds == NULL) {
3571 lim_log(mac_ctx, LOGE, FL(
3572 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3573 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003574 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575
3576 /*
3577 * send a DISASSOC_IND message to WSM to make sure
3578 * the state in WSM and LIM is the same
3579 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003580 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581 eSIR_SME_STA_NOT_ASSOCIATED,
3582 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3583 session_entry->smeSessionId,
3584 session_entry->transactionId,
3585 session_entry);
3586 goto end;
3587 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303588 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003589 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303590 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 lim_log(mac_ctx, LOG1, FL(
3592 "peerMacAddr mismatched for aid %d, peer "),
3593 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003594 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 goto end;
3596 }
3597
3598 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3599 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3600 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3601 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3602 (msg_type != eWNI_SME_ASSOC_CNF))) {
3603 lim_log(mac_ctx, LOG1, FL(
3604 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3605 "StaD mlmState : %d"),
3606 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003607 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 goto end;
3609 }
3610 /*
3611 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3612 * has been received
3613 */
3614 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3615 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3616 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3617
3618 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3619 /*
3620 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3621 * when it had received Assoc Request frame. Now, PE just needs
3622 * to send association rsp frame to the requesting BTAMP-STA.
3623 */
3624 sta_ds->mlmStaContext.mlmState =
3625 eLIM_MLM_LINK_ESTABLISHED_STATE;
3626 lim_log(mac_ctx, LOG1,
3627 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3628 sta_ds->assocId);
3629 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3630 sta_ds->assocId, sta_ds->staAddr,
3631 sta_ds->mlmStaContext.subType, sta_ds,
3632 session_entry);
3633 goto end;
3634 } else {
3635 /*
3636 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3637 * to be associated since the HAL sta entry is created for
3638 * denied STA we need to remove this HAL entry.
3639 * So to do that set updateContext to 1
3640 */
3641 if (!sta_ds->mlmStaContext.updateContext)
3642 sta_ds->mlmStaContext.updateContext = 1;
3643 lim_log(mac_ctx, LOG1,
3644 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3645 assoc_cnf.statusCode, sta_ds->assocId);
3646 lim_reject_association(mac_ctx, sta_ds->staAddr,
3647 sta_ds->mlmStaContext.subType,
3648 true, sta_ds->mlmStaContext.authType,
3649 sta_ds->assocId, true,
3650 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3651 session_entry);
3652 }
3653end:
3654 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3655 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3656 assoc_req = (tpSirAssocReq)
3657 session_entry->parsedAssocReq[sta_ds->assocId];
3658 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303659 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 assoc_req->assocReqFrame = NULL;
3661 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303662 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3664 }
3665}
3666
3667static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3668{
3669 tpDphHashNode pStaDs;
3670 tSirMacAddr peerMac;
3671 tpSirAddtsReq pSirAddts;
3672 uint32_t timeout;
3673 tpPESession psessionEntry;
3674 uint8_t sessionId; /* PE sessionId */
3675 uint8_t smesessionId;
3676 uint16_t smetransactionId;
3677
3678 if (pMsgBuf == NULL) {
3679 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3680 return;
3681 }
3682
3683 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3684 &smetransactionId);
3685
3686 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3687
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003688 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3689 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 if (psessionEntry == NULL) {
3691 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3692 return;
3693 }
3694#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3695 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3696 0);
3697#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3698
3699 /* if sta
3700 * - verify assoc state
3701 * - send addts request to ap
3702 * - wait for addts response from ap
3703 * if ap, just ignore with error log
3704 */
3705 PELOG1(lim_log(pMac, LOG1,
3706 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3707 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3708 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3709 )
3710
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003711 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3713 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3714 psessionEntry, pSirAddts->req.tspec,
3715 smesessionId, smetransactionId);
3716 return;
3717 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718
3719 pStaDs =
3720 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3721 &psessionEntry->dph.dphHashTable);
3722
3723 if (pStaDs == NULL) {
3724 PELOGE(lim_log
3725 (pMac, LOGE, "Cannot find AP context for addts req");
3726 )
3727 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3728 psessionEntry, pSirAddts->req.tspec,
3729 smesessionId, smetransactionId);
3730 return;
3731 }
3732
3733 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3734 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3735 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3736 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3737 psessionEntry, pSirAddts->req.tspec,
3738 smesessionId, smetransactionId);
3739 return;
3740 }
3741
3742 pSirAddts->req.wsmTspecPresent = 0;
3743 pSirAddts->req.wmeTspecPresent = 0;
3744 pSirAddts->req.lleTspecPresent = 0;
3745
3746 if ((pStaDs->wsmEnabled) &&
3747 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3748 SIR_MAC_ACCESSPOLICY_EDCA))
3749 pSirAddts->req.wsmTspecPresent = 1;
3750 else if (pStaDs->wmeEnabled)
3751 pSirAddts->req.wmeTspecPresent = 1;
3752 else if (pStaDs->lleEnabled)
3753 pSirAddts->req.lleTspecPresent = 1;
3754 else {
3755 PELOGW(lim_log
3756 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3757 )
3758 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3759 psessionEntry, pSirAddts->req.tspec,
3760 smesessionId, smetransactionId);
3761 return;
3762 }
3763
3764 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3765 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3766 lim_log(pMac, LOGE,
3767 "AddTs received in invalid LIMsme state (%d)",
3768 psessionEntry->limSmeState);
3769 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3770 psessionEntry, pSirAddts->req.tspec,
3771 smesessionId, smetransactionId);
3772 return;
3773 }
3774
3775 if (pMac->lim.gLimAddtsSent) {
3776 lim_log(pMac, LOGE,
3777 "Addts (token %d, tsid %d, up %d) is still pending",
3778 pMac->lim.gLimAddtsReq.req.dialogToken,
3779 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3780 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3781 userPrio);
3782 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3783 psessionEntry, pSirAddts->req.tspec,
3784 smesessionId, smetransactionId);
3785 return;
3786 }
3787
3788 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3789
3790 /* save the addts request */
3791 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303792 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3794
3795 /* ship out the message now */
3796 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3797 psessionEntry);
3798 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3799 /* start a timer to wait for the response */
3800 if (pSirAddts->timeout)
3801 timeout = pSirAddts->timeout;
3802 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3803 eSIR_SUCCESS) {
3804 lim_log(pMac, LOGP,
3805 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3806 WNI_CFG_ADDTS_RSP_TIMEOUT);
3807 return;
3808 }
3809
3810 timeout = SYS_MS_TO_TICKS(timeout);
3811 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3812 != TX_SUCCESS) {
3813 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3814 return;
3815 }
3816 pMac->lim.gLimAddtsRspTimerCount++;
3817 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3818 pMac->lim.gLimAddtsRspTimerCount) !=
3819 TX_SUCCESS) {
3820 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3821 return;
3822 }
3823 MTRACE(mac_trace
3824 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3825 eLIM_ADDTS_RSP_TIMER));
3826
3827 /* add the sessionId to the timer object */
3828 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3829 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3830 TX_SUCCESS) {
3831 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3832 return;
3833 }
3834 return;
3835}
3836
3837static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3838{
3839 tSirMacAddr peerMacAddr;
3840 uint8_t ac;
3841 tSirMacTSInfo *pTsinfo;
3842 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3843 tpDphHashNode pStaDs = NULL;
3844 tpPESession psessionEntry;
3845 uint8_t sessionId;
3846 uint32_t status = eSIR_SUCCESS;
3847 uint8_t smesessionId;
3848 uint16_t smetransactionId;
3849
3850 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3851 &smetransactionId);
3852
3853 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003854 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855 &sessionId);
3856 if (psessionEntry == NULL) {
3857 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3858 status = eSIR_FAILURE;
3859 goto end;
3860 }
3861#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3862 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3863 0);
3864#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3865
3866 if (eSIR_SUCCESS !=
3867 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3868 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3869 status = eSIR_FAILURE;
3870 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3871 smesessionId, smetransactionId);
3872 return;
3873 }
3874
3875 lim_log(pMac, LOG1,
3876 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3877 MAC_ADDRESS_STR),
3878 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3879
3880 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3881 pDeltsReq->req.wmeTspecPresent,
3882 &pDeltsReq->req.tsinfo,
3883 &pDeltsReq->req.tspec, psessionEntry);
3884
3885 pTsinfo =
3886 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3887 tsinfo : &pDeltsReq->req.tsinfo;
3888
3889 /* We've successfully send DELTS frame to AP. Update the
3890 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3891 * is no longer trigger enabled or delivery enabled
3892 */
3893 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3894 pTsinfo, CLEAR_UAPSD_MASK);
3895
3896 /* We're deleting the TSPEC, so this particular AC is no longer
3897 * admitted. PE needs to downgrade the EDCA
3898 * parameters(for the AC for which TS is being deleted) to the
3899 * next best AC for which ACM is not enabled, and send the
3900 * updated values to HAL.
3901 */
3902 ac = upToAc(pTsinfo->traffic.userPrio);
3903
3904 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3905 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3906 ~(1 << ac);
3907 } else if (pTsinfo->traffic.direction ==
3908 SIR_MAC_DIRECTION_DNLINK) {
3909 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3910 ~(1 << ac);
3911 } else if (pTsinfo->traffic.direction ==
3912 SIR_MAC_DIRECTION_BIDIR) {
3913 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3914 ~(1 << ac);
3915 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3916 ~(1 << ac);
3917 }
3918
3919 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3920 psessionEntry);
3921
3922 pStaDs =
3923 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3924 &psessionEntry->dph.dphHashTable);
3925 if (pStaDs != NULL) {
3926 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3927 pStaDs->bssId);
3928 status = eSIR_SUCCESS;
3929 } else {
3930 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3931 status = eSIR_FAILURE;
3932 }
3933#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003934 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003935#endif
3936
3937 /* send an sme response back */
3938end:
3939 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3940 smesessionId, smetransactionId);
3941}
3942
Jeff Johnson801f1532016-10-07 07:54:50 -07003943static void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac,
3944 uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945{
3946 /* fetch the sessionEntry based on the sessionId */
3947 tpPESession psessionEntry;
3948 psessionEntry = pe_find_session_by_session_id(pMac,
3949 pMac->lim.limTimers.gLimAddtsRspTimer.
3950 sessionId);
3951 if (psessionEntry == NULL) {
3952 lim_log(pMac, LOGP,
3953 FL("Session Does not exist for given sessionID"));
3954 return;
3955 }
3956
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003957 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3959 GET_LIM_SYSTEM_ROLE(psessionEntry));
3960 pMac->lim.gLimAddtsSent = false;
3961 return;
3962 }
3963
3964 if (!pMac->lim.gLimAddtsSent) {
3965 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3966 return;
3967 }
3968
3969 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3970 lim_log(pMac, LOGE,
3971 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3972 pMac->lim.gLimAddtsRspTimerCount);
3973 return;
3974 }
3975 /* this a real response timeout */
3976 pMac->lim.gLimAddtsSent = false;
3977 pMac->lim.gLimAddtsRspTimerCount++;
3978
3979 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3980 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3981 psessionEntry->smeSessionId,
3982 psessionEntry->transactionId);
3983}
3984
3985/**
3986 * __lim_process_sme_get_statistics_request()
3987 *
3988 ***FUNCTION:
3989 *
3990 *
3991 ***NOTE:
3992 *
3993 * @param pMac Pointer to Global MAC structure
3994 * @param *pMsgBuf A pointer to the SME message buffer
3995 * @return None
3996 */
3997static void
3998__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3999{
4000 tpAniGetPEStatsReq pPEStatsReq;
4001 tSirMsgQ msgQ;
4002
4003 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4004
4005 msgQ.type = WMA_GET_STATISTICS_REQ;
4006
4007 msgQ.reserved = 0;
4008 msgQ.bodyptr = pMsgBuf;
4009 msgQ.bodyval = 0;
4010 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4011
4012 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304013 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004014 pMsgBuf = NULL;
4015 lim_log(pMac, LOGP, "Unable to forward request");
4016 return;
4017 }
4018
4019 return;
4020}
4021
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004022#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004024 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004026 * @pMac: Pointer to Global MAC structure
4027 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004029 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030 */
4031static void
4032__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4033{
4034 tSirMsgQ msgQ;
4035
4036 msgQ.type = WMA_TSM_STATS_REQ;
4037 msgQ.reserved = 0;
4038 msgQ.bodyptr = pMsgBuf;
4039 msgQ.bodyval = 0;
4040 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4041
4042 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304043 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 pMsgBuf = NULL;
4045 lim_log(pMac, LOGP, "Unable to forward request");
4046 return;
4047 }
4048}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004049#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050
4051static void
4052__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4053{
4054 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4055 tpPESession psessionEntry;
4056 uint8_t sessionId; /* PE sessionID */
4057
4058 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4059
4060 if (pMsgBuf == NULL) {
4061 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4062 return;
4063 }
4064
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304065 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 if (NULL == pUpdateAPWPSIEsReq) {
4067 lim_log(pMac, LOGP,
4068 FL
4069 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4070 return;
4071 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304072 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 sizeof(struct sSirUpdateAPWPSIEsReq));
4074
4075 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004076 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077 &sessionId);
4078 if (psessionEntry == NULL) {
4079 lim_log(pMac, LOGW,
4080 FL("Session does not exist for given BSSID"));
4081 goto end;
4082 }
4083
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304084 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 sizeof(tSirAPWPSIEs));
4086
4087 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4088 lim_send_beacon_ind(pMac, psessionEntry);
4089
4090end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304091 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 return;
4093}
4094
4095void
4096lim_send_vdev_restart(tpAniSirGlobal pMac,
4097 tpPESession psessionEntry, uint8_t sessionId)
4098{
4099 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4100 tSirMsgQ msgQ;
4101 tSirRetStatus retCode = eSIR_SUCCESS;
4102
4103 if (psessionEntry == NULL) {
4104 PELOGE(lim_log
4105 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4106 __LINE__);
4107 )
4108 return;
4109 }
4110
4111 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304112 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 if (NULL == pHalHiddenSsidVdevRestart) {
4114 PELOGE(lim_log
4115 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4116 __func__, __LINE__);
4117 )
4118 return;
4119 }
4120
4121 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4122 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4123
4124 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4125 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4126 msgQ.bodyval = 0;
4127
4128 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4129 if (eSIR_SUCCESS != retCode) {
4130 PELOGE(lim_log
4131 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4132 __LINE__);
4133 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304134 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135 }
4136}
4137
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304138/**
4139 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4140 * @mac_ctx: Pointer to Global MAC structure
4141 * @msg_buf: Pointer to SME message buffer
4142 *
4143 * Return: None
4144 */
4145static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4146 uint32_t *msg_buf)
4147{
4148 tpPESession pe_session;
4149 tSirMsgQ wma_msg;
4150 tSirRetStatus status;
4151 tSirRoamOffloadScanReq *req_buffer;
4152 uint16_t local_ie_len;
4153 uint8_t *local_ie_buf;
4154
4155 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4156 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4157 req_buffer->sessionId);
4158
4159 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4160 if (!local_ie_buf) {
Arif Hussain963331b2016-10-27 22:59:01 -07004161 lim_log(mac_ctx, LOGE,
4162 FL("Mem Alloc failed for local_ie_buf"));
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304163 return;
4164 }
4165
4166 local_ie_len = req_buffer->assoc_ie.length;
4167 /* Update ext cap IE if present */
4168 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004169 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4170 local_ie_buf, &local_ie_len)) {
4171 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004172 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4173 req_buffer->assoc_ie.length = local_ie_len;
4174 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4175 local_ie_buf, local_ie_len);
4176 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304177 }
4178 qdf_mem_free(local_ie_buf);
4179
4180 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4181 wma_msg.bodyptr = req_buffer;
4182
4183 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4184 if (eSIR_SUCCESS != status) {
4185 lim_log(mac_ctx, LOGE,
4186 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4187 qdf_mem_free(req_buffer);
4188 }
4189}
4190
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304191/*
4192 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4193 * @mac_ctx: Pointer to global mac context
4194 * @session: Pointer to PE session
4195 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4196 * 1 - Disable broadcast SSID
4197 *
4198 * Return: None
4199 */
4200static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4201 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304203 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4204 if (ssid_hidden != session->ssidHidden)
4205 session->ssidHidden = ssid_hidden;
4206 else {
4207 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304208 return;
4209 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210
4211 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304212 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213
4214 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304215 sch_set_fixed_beacon_fields(mac_ctx, session);
4216 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217
4218 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304219}
4220
4221/**
4222 * __lim_process_sme_session_update - process SME session update msg
4223 *
4224 * @mac_ctx: Pointer to global mac context
4225 * @msg_buf: Pointer to the received message buffer
4226 *
4227 * Return: None
4228 */
4229static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4230 uint32_t *msg_buf)
4231{
4232 struct sir_update_session_param *msg;
4233 tpPESession session;
4234
4235 if (!msg_buf) {
4236 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4237 return;
4238 }
4239
4240 msg = (struct sir_update_session_param *) msg_buf;
4241
4242 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4243 if (!session) {
4244 lim_log(mac_ctx, LOGW,
4245 "Session does not exist for given sessionId %d",
4246 msg->session_id);
4247 return;
4248 }
4249
4250 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4251 msg->param_type, msg->param_val);
4252 switch (msg->param_type) {
4253 case SIR_PARAM_SSID_HIDDEN:
4254 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4255 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304256 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4257 session->ignore_assoc_disallowed = msg->param_val;
4258 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304259 default:
4260 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4261 break;
4262 }
4263}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264
4265static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4266{
4267 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4268 tpPESession psessionEntry;
4269 uint8_t sessionId; /* PE sessionID */
4270
4271 if (pMsgBuf == NULL) {
4272 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4273 return;
4274 }
4275
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304276 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 if (NULL == pUpdateAPWPARSNIEsReq) {
4278 lim_log(pMac, LOGP,
4279 FL
4280 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4281 return;
4282 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304283 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4285
4286 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004287 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288 &sessionId);
4289 if (psessionEntry == NULL) {
4290 lim_log(pMac, LOGW,
4291 FL("Session does not exist for given BSSID"));
4292 goto end;
4293 }
4294
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304295 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4297
4298 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4299 &psessionEntry->
4300 pLimStartBssReq->rsnIE,
4301 psessionEntry);
4302
4303 psessionEntry->pLimStartBssReq->privacy = 1;
4304 psessionEntry->privacy = 1;
4305
4306 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4307 lim_send_beacon_ind(pMac, psessionEntry);
4308
4309end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304310 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 return;
4312} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4313
4314/*
4315 Update the beacon Interval dynamically if beaconInterval is different in MCC
4316 */
4317static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4318{
4319 tpSirChangeBIParams pChangeBIParams;
4320 tpPESession psessionEntry;
4321 uint8_t sessionId = 0;
4322 tUpdateBeaconParams beaconParams;
4323
4324 PELOG1(lim_log(pMac, LOG1,
4325 FL("received Update Beacon Interval message"));
4326 );
4327
4328 if (pMsgBuf == NULL) {
4329 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4330 return;
4331 }
4332
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304333 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4335
4336 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004337 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338 &sessionId);
4339 if (psessionEntry == NULL) {
4340 lim_log(pMac, LOGE,
4341 FL("Session does not exist for given BSSID"));
4342 return;
4343 }
4344
4345 /*Update sessionEntry Beacon Interval */
4346 if (psessionEntry->beaconParams.beaconInterval !=
4347 pChangeBIParams->beaconInterval) {
4348 psessionEntry->beaconParams.beaconInterval =
4349 pChangeBIParams->beaconInterval;
4350 }
4351
4352 /*Update sch beaconInterval */
4353 if (pMac->sch.schObject.gSchBeaconInterval !=
4354 pChangeBIParams->beaconInterval) {
4355 pMac->sch.schObject.gSchBeaconInterval =
4356 pChangeBIParams->beaconInterval;
4357
4358 PELOG1(lim_log(pMac, LOG1,
4359 FL
4360 ("LIM send update BeaconInterval Indication : %d"),
4361 pChangeBIParams->beaconInterval);
4362 );
4363
4364 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4365 /* Update beacon */
4366 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4367
4368 beaconParams.bssIdx = psessionEntry->bssIdx;
4369 /* Set change in beacon Interval */
4370 beaconParams.beaconInterval =
4371 pChangeBIParams->beaconInterval;
4372 beaconParams.paramChangeBitmap =
4373 PARAM_BCN_INTERVAL_CHANGED;
4374 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4375 }
4376 }
4377
4378 return;
4379} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4380
4381#ifdef QCA_HT_2040_COEX
4382static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4383 uint32_t *pMsgBuf)
4384{
4385 tpSirSetHT2040Mode pSetHT2040Mode;
4386 tpPESession psessionEntry;
4387 uint8_t sessionId = 0;
4388 cds_msg_t msg;
4389 tUpdateVHTOpMode *pHtOpMode = NULL;
4390 uint16_t staId = 0;
4391 tpDphHashNode pStaDs = NULL;
4392
4393 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4394 if (pMsgBuf == NULL) {
4395 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4396 return;
4397 }
4398
4399 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4400
4401 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004402 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 &sessionId);
4404 if (psessionEntry == NULL) {
4405 lim_log(pMac, LOG1,
4406 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004407 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 return;
4409 }
4410
4411 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4412 pSetHT2040Mode->cbMode);
4413 /*Update sessionEntry HT related fields */
4414 switch (pSetHT2040Mode->cbMode) {
4415 case PHY_SINGLE_CHANNEL_CENTERED:
4416 psessionEntry->htSecondaryChannelOffset =
4417 PHY_SINGLE_CHANNEL_CENTERED;
4418 psessionEntry->htRecommendedTxWidthSet = 0;
4419 if (pSetHT2040Mode->obssEnabled)
4420 psessionEntry->htSupportedChannelWidthSet
4421 = eHT_CHANNEL_WIDTH_40MHZ;
4422 else
4423 psessionEntry->htSupportedChannelWidthSet
4424 = eHT_CHANNEL_WIDTH_20MHZ;
4425 break;
4426 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4427 psessionEntry->htSecondaryChannelOffset =
4428 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4429 psessionEntry->htRecommendedTxWidthSet = 1;
4430 break;
4431 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4432 psessionEntry->htSecondaryChannelOffset =
4433 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4434 psessionEntry->htRecommendedTxWidthSet = 1;
4435 break;
4436 default:
4437 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4438 return;
4439 }
4440
4441 /* Update beacon */
4442 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4443 lim_send_beacon_ind(pMac, psessionEntry);
4444
4445 /* update OP Mode for each associated peer */
4446 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4447 pStaDs = dph_get_hash_entry(pMac, staId,
4448 &psessionEntry->dph.dphHashTable);
4449 if (NULL == pStaDs)
4450 continue;
4451
4452 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304453 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454 if (NULL == pHtOpMode) {
4455 lim_log(pMac, LOGE,
4456 FL
4457 ("%s: Not able to allocate memory for setting OP mode"),
4458 __func__);
4459 return;
4460 }
4461 pHtOpMode->opMode =
4462 (psessionEntry->htSecondaryChannelOffset ==
4463 PHY_SINGLE_CHANNEL_CENTERED) ?
4464 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4465 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304466 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 sizeof(tSirMacAddr));
4468 pHtOpMode->smesessionId = sessionId;
4469
4470 msg.type = WMA_UPDATE_OP_MODE;
4471 msg.reserved = 0;
4472 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304473 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304474 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 lim_log(pMac, LOGE,
4476 FL
4477 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4478 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304479 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 return;
4481 }
4482 lim_log(pMac, LOG1,
4483 FL
4484 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4485 __func__, pHtOpMode->opMode, staId);
4486
4487 } else
4488 lim_log(pMac, LOG1,
4489 FL("%s: station %d does not support HT40\n"),
4490 __func__, staId);
4491 }
4492
4493 return;
4494}
4495#endif
4496
4497/* -------------------------------------------------------------------- */
4498/**
4499 * __lim_process_report_message
4500 *
4501 * FUNCTION: Processes the next received Radio Resource Management message
4502 *
4503 * LOGIC:
4504 *
4505 * ASSUMPTIONS:
4506 *
4507 * NOTE:
4508 *
4509 * @param None
4510 * @return None
4511 */
4512
Jeff Johnson801f1532016-10-07 07:54:50 -07004513static void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 switch (pMsg->type) {
4516 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4517 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4518 break;
4519 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004521 break;
4522 default:
4523 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525}
4526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527/* -------------------------------------------------------------------- */
4528/**
4529 * lim_send_set_max_tx_power_req
4530 *
4531 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4532 *
4533 * LOGIC:
4534 *
4535 * ASSUMPTIONS:
4536 *
4537 * NOTE:
4538 *
4539 * @param txPower txPower to be set.
4540 * @param pSessionEntry session entry.
4541 * @return None
4542 */
4543tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004544lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 tpPESession pSessionEntry)
4546{
4547 tpMaxTxPowerParams pMaxTxParams = NULL;
4548 tSirRetStatus retCode = eSIR_SUCCESS;
4549 tSirMsgQ msgQ;
4550
4551 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304552 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 return eSIR_FAILURE;
4554 }
4555
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304556 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 if (NULL == pMaxTxParams) {
4558 lim_log(pMac, LOGP,
4559 FL("Unable to allocate memory for pMaxTxParams "));
4560 return eSIR_MEM_ALLOC_FAILED;
4561
4562 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304564 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304565 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304566 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004567 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304568 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569
4570 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4571 msgQ.bodyptr = pMaxTxParams;
4572 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304573 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4575 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4576 if (eSIR_SUCCESS != retCode) {
4577 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304578 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 }
4580 return retCode;
4581}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582
4583/**
4584 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4585 *
4586 * @mac_ctx: Pointer to Global MAC structure
4587 * @msg_buf: pointer to the SME message buffer
4588 *
4589 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4590 * from SME. It Register this information within PE.
4591 *
4592 * Return: None
4593 */
4594static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4595 uint32_t *msg_buf)
4596{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304597 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4599 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4600 struct mgmt_frm_reg_info *next = NULL;
4601 bool match = false;
4602
4603 lim_log(mac_ctx, LOG1, FL(
4604 "registerFrame %d, frameType %d, matchLen %d"),
4605 sme_req->registerFrame, sme_req->frameType,
4606 sme_req->matchLen);
4607 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304608 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304609 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4610 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304611 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612
4613 while (lim_mgmt_regn != NULL) {
4614 if (lim_mgmt_regn->frameType != sme_req->frameType)
4615 goto skip_match;
4616 if (sme_req->matchLen) {
4617 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304618 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 sme_req->matchData,
4620 lim_mgmt_regn->matchLen))) {
4621 /* found match! */
4622 match = true;
4623 break;
4624 }
4625 } else {
4626 /* found match! */
4627 match = true;
4628 break;
4629 }
4630skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304631 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304632 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304634 (qdf_list_node_t *)lim_mgmt_regn,
4635 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304636 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 lim_mgmt_regn = next;
4638 next = NULL;
4639 }
4640 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304641 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004642 if (QDF_STATUS_SUCCESS ==
4643 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004645 (qdf_list_node_t *)lim_mgmt_regn))
4646 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304647 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 }
4649
4650 if (sme_req->registerFrame) {
4651 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304652 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 sme_req->matchLen);
4654 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 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}