blob: 03936bd0f3601a0b4cad7ba24240932d2a150c25 [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;
2453
2454 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2455 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 switch (psessionEntry->limSmeState) {
2457 case eLIM_SME_ASSOCIATED_STATE:
2458 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002459 lim_log(pMac, LOG1,
2460 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2461 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462 psessionEntry->limPrevSmeState =
2463 psessionEntry->limSmeState;
2464 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2465#ifdef FEATURE_WLAN_TDLS
2466 /* Delete all TDLS peers connected before leaving BSS */
2467 lim_delete_tdls_peers(pMac, psessionEntry);
2468#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002469 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2470 psessionEntry->peSessionId,
2471 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 break;
2473
2474 case eLIM_SME_WT_DEAUTH_STATE:
2475 /* PE shall still process the DISASSOC_REQ and proceed with
2476 * link tear down even if it had already sent a DEAUTH_IND to
2477 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2478 * its been set when PE entered WT_DEAUTH_STATE.
2479 */
2480 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2481 MTRACE(mac_trace
2482 (pMac, TRACE_CODE_SME_STATE,
2483 psessionEntry->peSessionId,
2484 psessionEntry->limSmeState));
2485 lim_log(pMac, LOG1,
2486 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2487 break;
2488
2489 case eLIM_SME_WT_DISASSOC_STATE:
2490 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2491 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2492 * PE can continue processing DISASSOC_REQ and send the response instead
2493 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2494 * for disassoc frame.
2495 *
2496 * It will send a disassoc, which is ok. However, we can use the global flag
2497 * sendDisassoc to not send disassoc frame.
2498 */
2499 lim_log(pMac, LOG1,
2500 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2501 break;
2502
2503 case eLIM_SME_JOIN_FAILURE_STATE: {
2504 /* Already in Disconnected State, return success */
2505 lim_log(pMac, LOG1,
2506 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2507 if (pMac->lim.gLimRspReqd) {
2508 retCode = eSIR_SME_SUCCESS;
2509 disassocTrigger = eLIM_HOST_DISASSOC;
2510 goto sendDisassoc;
2511 }
2512 }
2513 break;
2514 default:
2515 /**
2516 * STA is not currently associated.
2517 * Log error and send response to host
2518 */
2519 lim_log(pMac, LOGE,
2520 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2521 psessionEntry->limSmeState);
2522 lim_print_sme_state(pMac, LOGE,
2523 psessionEntry->limSmeState);
2524
2525 if (pMac->lim.gLimRspReqd) {
2526 if (psessionEntry->limSmeState !=
2527 eLIM_SME_WT_ASSOC_STATE)
2528 pMac->lim.gLimRspReqd = false;
2529
2530 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2531 disassocTrigger = eLIM_HOST_DISASSOC;
2532 goto sendDisassoc;
2533 }
2534
2535 return;
2536 }
2537
2538 break;
2539
2540 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541 /* Fall through */
2542 break;
2543
2544 case eLIM_STA_IN_IBSS_ROLE:
2545 default:
2546 /* eLIM_UNKNOWN_ROLE */
2547 lim_log(pMac, LOGE,
2548 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2549 GET_LIM_SYSTEM_ROLE(psessionEntry));
2550
2551 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2552 disassocTrigger = eLIM_HOST_DISASSOC;
2553 goto sendDisassoc;
2554 } /* end switch (pMac->lim.gLimSystemRole) */
2555
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302556 disassocTrigger = eLIM_HOST_DISASSOC;
2557 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558
2559 if (smeDisassocReq.doNotSendOverTheAir) {
2560 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2561 send_disassoc_frame = 0;
2562 }
2563 /* Trigger Disassociation frame to peer MAC entity */
2564 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2565 " : %d, reasonCode : %d"),
2566 disassocTrigger, reasonCode);
2567
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302568 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 if (NULL == pMlmDisassocReq) {
2570 /* Log error */
2571 lim_log(pMac, LOGP,
2572 FL("call to AllocateMemory failed for mlmDisassocReq"));
2573
2574 return;
2575 }
2576
Anurag Chouhanc5548422016-02-24 18:33:27 +05302577 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002578 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579
2580 pMlmDisassocReq->reasonCode = reasonCode;
2581 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2582
2583 /* Update PE session ID */
2584 pMlmDisassocReq->sessionId = sessionId;
2585
2586 lim_post_mlm_message(pMac,
2587 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2588 return;
2589
2590sendDisassoc:
2591 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002592 lim_send_sme_disassoc_ntf(pMac,
2593 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 retCode,
2595 disassocTrigger,
2596 1, smesessionId, smetransactionId,
2597 psessionEntry);
2598 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002599 lim_send_sme_disassoc_ntf(pMac,
2600 smeDisassocReq.peer_macaddr.bytes,
2601 retCode, disassocTrigger, 1,
2602 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603
2604} /*** end __lim_process_sme_disassoc_req() ***/
2605
2606/** -----------------------------------------------------------------
2607 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2608
2609 This function is called to process SME_DISASSOC_CNF message
2610 from HDD or upper layer application.
2611
2612 \param pMac - global mac structure
2613 \param pStaDs - station dph hash node
2614 \return none
2615 \sa
2616 ----------------------------------------------------------------- */
2617static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2618{
2619 tSirSmeDisassocCnf smeDisassocCnf;
2620 uint16_t aid;
2621 tpDphHashNode pStaDs;
2622 tpPESession psessionEntry;
2623 uint8_t sessionId;
2624
2625 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2626
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302627 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 sizeof(struct sSirSmeDisassocCnf));
2629
2630 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002631 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 &sessionId);
2633 if (psessionEntry == NULL) {
2634 lim_log(pMac, LOGE,
2635 FL("session does not exist for given bssId"));
2636 return;
2637 }
2638
2639 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2640 lim_log(pMac, LOGE,
2641 FL("received invalid SME_DISASSOC_CNF message"));
2642 return;
2643 }
2644#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2645 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2646 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2647 psessionEntry,
2648 (uint16_t) smeDisassocCnf.statusCode, 0);
2649 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2650 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2651 psessionEntry,
2652 (uint16_t) smeDisassocCnf.statusCode, 0);
2653#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2654
2655 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2656 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2658 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2659 && (psessionEntry->limSmeState !=
2660 eLIM_SME_WT_DEAUTH_STATE)) {
2661 lim_log(pMac, LOGE,
2662 FL
2663 ("received unexp SME_DISASSOC_CNF in state %X"),
2664 psessionEntry->limSmeState);
2665 lim_print_sme_state(pMac, LOGE,
2666 psessionEntry->limSmeState);
2667 return;
2668 }
2669 break;
2670
2671 case eLIM_AP_ROLE:
2672 /* Fall through */
2673 break;
2674
2675 case eLIM_STA_IN_IBSS_ROLE:
2676 default: /* eLIM_UNKNOWN_ROLE */
2677 lim_log(pMac, LOGE,
2678 FL("received unexpected SME_DISASSOC_CNF role %d"),
2679 GET_LIM_SYSTEM_ROLE(psessionEntry));
2680
2681 return;
2682 }
2683
2684 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2685 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2686 LIM_IS_AP_ROLE(psessionEntry)) {
2687 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002688 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 &psessionEntry->dph.dphHashTable);
2690 if (pStaDs == NULL) {
2691 lim_log(pMac, LOGE,
2692 FL("DISASSOC_CNF for a STA with no context, addr= "
2693 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002694 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 return;
2696 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302697
2698 if ((pStaDs->mlmStaContext.mlmState ==
2699 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2700 (pStaDs->mlmStaContext.mlmState ==
2701 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2702 lim_log(pMac, LOGE,
2703 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002704 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302705 pStaDs->mlmStaContext.mlmState);
2706 return;
2707 }
2708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 /* Delete FT session if there exists one */
2710 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2712
2713 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002714 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 }
2716
2717 return;
2718}
2719
2720/**
2721 * __lim_process_sme_deauth_req() - process sme deauth req
2722 * @mac_ctx: Pointer to Global MAC structure
2723 * @msg_buf: pointer to the SME message buffer
2724 *
2725 * This function is called to process SME_DEAUTH_REQ message
2726 * from HDD or upper layer application.
2727 *
2728 * Return: None
2729 */
2730
2731static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2732 uint32_t *msg_buf)
2733{
2734 uint16_t deauth_trigger, reason_code;
2735 tLimMlmDeauthReq *mlm_deauth_req;
2736 tSirSmeDeauthReq sme_deauth_req;
2737 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2738 tpPESession session_entry;
2739 uint8_t session_id; /* PE sessionId */
2740 uint8_t sme_session_id;
2741 uint16_t sme_transaction_id;
2742
2743 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2744
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302745 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 sme_session_id = sme_deauth_req.sessionId;
2747 sme_transaction_id = sme_deauth_req.transactionId;
2748
2749 /*
2750 * We need to get a session first but we don't even know
2751 * if the message is correct.
2752 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002753 session_entry = pe_find_session_by_bssid(mac_ctx,
2754 sme_deauth_req.bssid.bytes,
2755 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 if (session_entry == NULL) {
2757 lim_log(mac_ctx, LOGE,
2758 FL("session does not exist for given bssId"));
2759 ret_code = eSIR_SME_INVALID_PARAMETERS;
2760 deauth_trigger = eLIM_HOST_DEAUTH;
2761 goto send_deauth;
2762 }
2763
2764 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2765 session_entry)) {
2766 lim_log(mac_ctx, LOGE,
2767 FL("received invalid SME_DEAUTH_REQ message"));
2768 mac_ctx->lim.gLimRspReqd = false;
2769
2770 ret_code = eSIR_SME_INVALID_PARAMETERS;
2771 deauth_trigger = eLIM_HOST_DEAUTH;
2772 goto send_deauth;
2773 }
2774 lim_log(mac_ctx, LOG1,
2775 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2776 MAC_ADDRESS_STR), sme_session_id,
2777 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2778 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002779 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2781 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2782 session_entry, 0, sme_deauth_req.reasonCode);
2783#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2784
2785 /* Update SME session ID and Transaction ID */
2786 session_entry->smeSessionId = sme_session_id;
2787 session_entry->transactionId = sme_transaction_id;
2788
2789 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2790 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 switch (session_entry->limSmeState) {
2792 case eLIM_SME_ASSOCIATED_STATE:
2793 case eLIM_SME_LINK_EST_STATE:
2794 case eLIM_SME_WT_ASSOC_STATE:
2795 case eLIM_SME_JOIN_FAILURE_STATE:
2796 case eLIM_SME_IDLE_STATE:
2797 session_entry->limPrevSmeState =
2798 session_entry->limSmeState;
2799 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2800 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2801 session_entry->peSessionId,
2802 session_entry->limSmeState));
2803 /* Send Deauthentication request to MLM below */
2804 break;
2805 case eLIM_SME_WT_DEAUTH_STATE:
2806 case eLIM_SME_WT_DISASSOC_STATE:
2807 /*
2808 * PE Recieved a Deauth/Disassoc frame. Normally it get
2809 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2810 * Which means host is also trying to disconnect.
2811 * PE can continue processing DEAUTH_REQ and send
2812 * the response instead of failing the request.
2813 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2814 * was sent for deauth/disassoc frame.
2815 */
2816 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2817 lim_log(mac_ctx, LOG1, FL(
2818 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2819 break;
2820 default:
2821 /*
2822 * STA is not in a state to deauthenticate with
2823 * peer. Log error and send response to host.
2824 */
2825 lim_log(mac_ctx, LOGE, FL(
2826 "received unexp SME_DEAUTH_REQ in state %X"),
2827 session_entry->limSmeState);
2828 lim_print_sme_state(mac_ctx, LOGE,
2829 session_entry->limSmeState);
2830
2831 if (mac_ctx->lim.gLimRspReqd) {
2832 mac_ctx->lim.gLimRspReqd = false;
2833
2834 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2835 deauth_trigger = eLIM_HOST_DEAUTH;
2836
2837 /*
2838 * here we received deauth request from AP so sme state
2839 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2840 * delSta then mlm state should be
2841 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2842 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2843 * so the below condition captures the state where
2844 * delSta not done and firmware still in
2845 * connected state.
2846 */
2847 if (session_entry->limSmeState ==
2848 eLIM_SME_WT_DEAUTH_STATE &&
2849 session_entry->limMlmState !=
2850 eLIM_MLM_IDLE_STATE &&
2851 session_entry->limMlmState !=
2852 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2853 ret_code = eSIR_SME_DEAUTH_STATUS;
2854 goto send_deauth;
2855 }
2856 return;
2857 }
2858 break;
2859
2860 case eLIM_STA_IN_IBSS_ROLE:
2861 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2862 if (mac_ctx->lim.gLimRspReqd) {
2863 mac_ctx->lim.gLimRspReqd = false;
2864 ret_code = eSIR_SME_INVALID_PARAMETERS;
2865 deauth_trigger = eLIM_HOST_DEAUTH;
2866 goto send_deauth;
2867 }
2868 return;
2869 case eLIM_AP_ROLE:
2870 break;
2871 default:
2872 lim_log(mac_ctx, LOGE,
2873 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2874 GET_LIM_SYSTEM_ROLE(session_entry));
2875 if (mac_ctx->lim.gLimRspReqd) {
2876 mac_ctx->lim.gLimRspReqd = false;
2877 ret_code = eSIR_SME_INVALID_PARAMETERS;
2878 deauth_trigger = eLIM_HOST_DEAUTH;
2879 goto send_deauth;
2880 }
2881 return;
2882 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2883
2884 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2885 /* Deauthentication is triggered by Link Monitoring */
2886 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2887 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2888 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2889 } else {
2890 deauth_trigger = eLIM_HOST_DEAUTH;
2891 reason_code = sme_deauth_req.reasonCode;
2892 }
2893
2894 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302895 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 if (NULL == mlm_deauth_req) {
2897 lim_log(mac_ctx, LOGP,
2898 FL("call to AllocateMemory failed for mlmDeauthReq"));
2899 if (mac_ctx->lim.gLimRspReqd) {
2900 mac_ctx->lim.gLimRspReqd = false;
2901 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2902 deauth_trigger = eLIM_HOST_DEAUTH;
2903 goto send_deauth;
2904 }
2905 return;
2906 }
2907
Anurag Chouhanc5548422016-02-24 18:33:27 +05302908 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002909 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910
2911 mlm_deauth_req->reasonCode = reason_code;
2912 mlm_deauth_req->deauthTrigger = deauth_trigger;
2913
2914 /* Update PE session Id */
2915 mlm_deauth_req->sessionId = session_id;
2916
2917 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2918 (uint32_t *)mlm_deauth_req);
2919 return;
2920
2921send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002922 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2923 ret_code, deauth_trigger, 1,
2924 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925}
2926
2927/**
2928 * __lim_process_sme_set_context_req()
2929 *
2930 * @mac_ctx: Pointer to Global MAC structure
2931 * @msg_buf: pointer to the SME message buffer
2932 *
2933 * This function is called to process SME_SETCONTEXT_REQ message
2934 * from HDD or upper layer application.
2935 *
2936 * Return: None
2937 */
2938
2939static void
2940__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2941{
2942 tpSirSmeSetContextReq set_context_req;
2943 tLimMlmSetKeysReq *mlm_set_key_req;
2944 tpPESession session_entry;
2945 uint8_t session_id; /* PE sessionID */
2946 uint8_t sme_session_id;
2947 uint16_t sme_transaction_id;
2948
2949 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2950
2951 if (msg_buf == NULL) {
2952 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2953 return;
2954 }
2955
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302956 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957 if (NULL == set_context_req) {
2958 lim_log(mac_ctx, LOGP, FL(
2959 "call to AllocateMemory failed for set_context_req"));
2960 return;
2961 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302962 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 sizeof(struct sSirSmeSetContextReq));
2964 sme_session_id = set_context_req->sessionId;
2965 sme_transaction_id = set_context_req->transactionId;
2966
2967 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2968 lim_log(mac_ctx, LOGW,
2969 FL("received invalid SME_SETCONTEXT_REQ message"));
2970 goto end;
2971 }
2972
2973 if (set_context_req->keyMaterial.numKeys >
2974 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2975 lim_log(mac_ctx, LOGE, FL(
2976 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2977 set_context_req->keyMaterial.numKeys);
2978 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002979 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002980 eSIR_SME_INVALID_PARAMETERS, NULL,
2981 sme_session_id, sme_transaction_id);
2982 goto end;
2983 }
2984
2985 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002986 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987 if (session_entry == NULL) {
2988 lim_log(mac_ctx, LOGW,
2989 FL("Session does not exist for given BSSID"));
2990 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002991 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992 eSIR_SME_INVALID_PARAMETERS, NULL,
2993 sme_session_id, sme_transaction_id);
2994 goto end;
2995 }
2996#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2997 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2998 session_entry, 0, 0);
2999#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3000
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003001 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3003 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003004 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3006 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303007 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 if (NULL == mlm_set_key_req) {
3009 lim_log(mac_ctx, LOGP, FL(
3010 "mem alloc failed for mlmSetKeysReq"));
3011 goto end;
3012 }
3013 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3014 mlm_set_key_req->numKeys =
3015 set_context_req->keyMaterial.numKeys;
3016 if (mlm_set_key_req->numKeys >
3017 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3018 lim_log(mac_ctx, LOGP, FL(
3019 "no.of keys exceeded max num of default keys limit"));
3020 goto end;
3021 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303022 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003023 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303025 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 (uint8_t *) &set_context_req->keyMaterial.key,
3027 sizeof(tSirKeys) *
3028 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3029 numKeys : 1));
3030
3031 mlm_set_key_req->sessionId = session_id;
3032 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 lim_log(mac_ctx, LOG1, FL(
3034 "received SETCONTEXT_REQ message sessionId=%d"),
3035 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036
3037 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3038 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3039 LIM_IS_AP_ROLE(session_entry)) {
3040 if (set_context_req->keyMaterial.key[0].keyLength) {
3041 uint8_t key_id;
3042 key_id =
3043 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303044 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 &session_entry->WEPKeyMaterial[key_id],
3046 (uint8_t *) &set_context_req->keyMaterial,
3047 sizeof(tSirKeyMaterial));
3048 } else {
3049 uint32_t i;
3050 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3051 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303052 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 &mlm_set_key_req->key[i],
3054 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3055 sizeof(tSirKeys));
3056 }
3057 }
3058 }
3059 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3060 (uint32_t *) mlm_set_key_req);
3061 } else {
3062 lim_log(mac_ctx, LOGE, FL(
3063 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3064 GET_LIM_SYSTEM_ROLE(session_entry),
3065 session_entry->limSmeState);
3066 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3067
3068 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003069 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3071 session_entry, sme_session_id,
3072 sme_transaction_id);
3073 }
3074end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303075 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 return;
3077}
3078
3079/**
3080 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3081 *
3082 * @mac_ctx: Pointer to Global MAC structure
3083 * @msg_buf: pointer to the SME message buffer
3084 *
3085 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3086 * from HDD or upper layer application.
3087 *
3088 * Return: None
3089 */
3090
Jeff Johnson801f1532016-10-07 07:54:50 -07003091static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3092 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093{
3094 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3095 tpDphHashNode sta_ds = NULL;
3096 tpPESession session_entry = NULL;
3097 tSap_Event sap_event;
3098 tpWLAN_SAPEventCB sap_event_cb = NULL;
3099 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3100 uint8_t session_id = CSR_SESSION_ID_INVALID;
3101 uint8_t assoc_id = 0;
3102 uint8_t sta_cnt = 0;
3103
3104 if (msg_buf == NULL) {
3105 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3106 return;
3107 }
3108
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303109 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 sizeof(struct sSirSmeGetAssocSTAsReq));
3111 /*
3112 * Get Associated stations from PE.
3113 * Find PE session Entry
3114 */
3115 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003116 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 &session_id);
3118 if (session_entry == NULL) {
3119 lim_log(mac_ctx, LOGE,
3120 FL("session does not exist for given bssId"));
3121 goto lim_assoc_sta_end;
3122 }
3123
3124 if (!LIM_IS_AP_ROLE(session_entry)) {
3125 lim_log(mac_ctx, LOGE, FL(
3126 "Received unexpected message in state %X, in role %X"),
3127 session_entry->limSmeState,
3128 GET_LIM_SYSTEM_ROLE(session_entry));
3129 goto lim_assoc_sta_end;
3130 }
3131 /* Retrieve values obtained in the request message */
3132 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3133 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3134
3135 if (NULL == assoc_sta_tmp)
3136 goto lim_assoc_sta_end;
3137 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3138 assoc_id++) {
3139 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3140 &session_entry->dph.dphHashTable);
3141 if (NULL == sta_ds)
3142 continue;
3143 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303144 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303146 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3148 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3149
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303150 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151 (uint8_t *)&sta_ds->supportedRates,
3152 sizeof(tSirSupportedRates));
3153 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3154 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3155 assoc_sta_tmp->Support40Mhz =
3156 sta_ds->htDsssCckRate40MHzSupport;
3157
3158 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3159 sta_cnt + 1);
3160 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3161 MAC_ADDR_ARRAY(sta_ds->staAddr));
3162 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3163 sta_ds->assocId);
3164 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3165 sta_ds->staIndex);
3166 assoc_sta_tmp++;
3167 sta_cnt++;
3168 }
3169 }
3170lim_assoc_sta_end:
3171 /*
3172 * Call hdd callback with sap event to send the list of
3173 * associated stations from PE
3174 */
3175 if (sap_event_cb != NULL) {
3176 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3177 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303178 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3180 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3181 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3182 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3183 }
3184}
3185
3186/**
3187 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3188 *
3189 * @mac_ctx: Pointer to Global MAC structure
3190 * @msg_buf: pointer to WPS PBC overlap query message
3191 *
3192 * This function parses get WPS PBC overlap information
3193 * message and call callback to pass WPS PBC overlap
3194 * information back to hdd.
3195 *
3196 * Return: None
3197 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003198static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3199 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200{
3201 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3202 tpPESession session_entry = NULL;
3203 tSap_Event sap_event;
3204 tpWLAN_SAPEventCB sap_event_cb = NULL;
3205 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3207
3208 if (msg_buf == NULL) {
3209 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3210 return;
3211 }
3212
3213 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303214 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303216 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3218 /*
3219 * Get Associated stations from PE
3220 * Find PE session Entry
3221 */
3222 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003223 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 if (session_entry == NULL) {
3225 lim_log(mac_ctx, LOGE,
3226 FL("session does not exist for given bssId"));
3227 goto lim_get_wpspbc_sessions_end;
3228 }
3229
3230 if (!LIM_IS_AP_ROLE(session_entry)) {
3231 lim_log(mac_ctx, LOGE,
3232 FL("Received unexpected message in role %X"),
3233 GET_LIM_SYSTEM_ROLE(session_entry));
3234 goto lim_get_wpspbc_sessions_end;
3235 }
3236 /*
3237 * Call hdd callback with sap event to send the
3238 * WPS PBC overlap information
3239 */
3240 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303241 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242
Anurag Chouhanc5548422016-02-24 18:33:27 +05303243 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003245 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246 sap_get_wpspbc_event->UUID_E,
3247 &sap_get_wpspbc_event->wpsPBCOverlap,
3248 session_entry);
3249 } else {
3250 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003251 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 session_entry);
3253 /* don't have to inform the HDD/Host */
3254 return;
3255 }
3256
3257 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3258 sap_get_wpspbc_event->wpsPBCOverlap);
3259 lim_print_mac_addr(mac_ctx,
3260 sap_get_wpspbc_event->addr.bytes, LOG4);
3261
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303262 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263
3264lim_get_wpspbc_sessions_end:
3265 sap_event_cb =
3266 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3267 if (NULL != sap_event_cb)
3268 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3269}
3270
3271/**
3272 * __lim_counter_measures()
3273 *
3274 * FUNCTION:
3275 * This function is called to "implement" MIC counter measure
3276 * and is *temporary* only
3277 *
3278 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3279 * we don't do the proper STA disassoc sequence since the
3280 * BSS will be stoped anyway
3281 *
3282 ***ASSUMPTIONS:
3283 *
3284 ***NOTE:
3285 *
3286 * @param pMac Pointer to Global MAC structure
3287 * @return None
3288 */
3289
3290static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3291{
3292 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003293 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3295 mac, psessionEntry, false);
3296};
3297
Jeff Johnson801f1532016-10-07 07:54:50 -07003298static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3299 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300{
3301 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3302 tpPESession psessionEntry;
3303 uint8_t sessionId; /* PE sessionId */
3304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303305 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 sizeof(struct sSirSmeTkipCntrMeasReq));
3307
3308 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003309 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310 if (NULL == psessionEntry) {
3311 lim_log(pMac, LOGE,
3312 FL("session does not exist for given BSSID "));
3313 return;
3314 }
3315
3316 if (tkipCntrMeasReq.bEnable)
3317 __lim_counter_measures(pMac, psessionEntry);
3318
3319 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3320}
3321
3322static void
3323__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3324{
3325 tSirSmeStopBssReq stopBssReq;
3326 tSirRetStatus status;
3327 tLimSmeStates prevState;
3328 tpPESession psessionEntry;
3329 uint8_t smesessionId;
3330 uint8_t sessionId;
3331 uint16_t smetransactionId;
3332 uint8_t i = 0;
3333 tpDphHashNode pStaDs = NULL;
3334
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303335 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 smesessionId = stopBssReq.sessionId;
3337 smetransactionId = stopBssReq.transactionId;
3338
3339 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3340 PELOGW(lim_log(pMac, LOGW,
3341 FL("received invalid SME_STOP_BSS_REQ message"));)
3342 /* Send Stop BSS response to host */
3343 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3344 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3345 smetransactionId);
3346 return;
3347 }
3348
3349 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003350 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 &sessionId);
3352 if (psessionEntry == NULL) {
3353 lim_log(pMac, LOGW,
3354 FL("session does not exist for given BSSID "));
3355 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3356 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3357 smetransactionId);
3358 return;
3359 }
3360#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3361 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3362 0, 0);
3363#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3364
3365 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3366 LIM_IS_STA_ROLE(psessionEntry)) {
3367 /**
3368 * Should not have received STOP_BSS_REQ in states
3369 * other than 'normal' state or on STA in Infrastructure
3370 * mode. Log error and return response to host.
3371 */
3372 lim_log(pMac, LOGE,
3373 FL
3374 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3375 psessionEntry->limSmeState,
3376 GET_LIM_SYSTEM_ROLE(psessionEntry));
3377 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3378 /* / Send Stop BSS response to host */
3379 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3380 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3381 smetransactionId);
3382 return;
3383 }
3384
3385 if (LIM_IS_AP_ROLE(psessionEntry))
3386 lim_wpspbc_close(pMac, psessionEntry);
3387
3388 lim_log(pMac, LOGW,
3389 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3390 stopBssReq.reasonCode);
3391
3392 prevState = psessionEntry->limSmeState;
3393
3394 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3395 MTRACE(mac_trace
3396 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3397 psessionEntry->limSmeState));
3398
3399 /* Update SME session Id and Transaction Id */
3400 psessionEntry->smeSessionId = smesessionId;
3401 psessionEntry->transactionId = smetransactionId;
3402
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003403 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3404 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3405 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3407 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3408 /* Send disassoc all stations associated thru TKIP */
3409 __lim_counter_measures(pMac, psessionEntry);
3410 else
3411 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003412 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3413 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 }
3415
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003416 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3417 /* Free the buffer allocated in START_BSS_REQ */
3418 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3419 psessionEntry->addIeParams.probeRespDataLen = 0;
3420 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003422 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3423 psessionEntry->addIeParams.assocRespDataLen = 0;
3424 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003426 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3427 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3428 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003430 /*
3431 * lim_del_bss is also called as part of coalescing,
3432 * when we send DEL BSS followed by Add Bss msg.
3433 */
3434 pMac->lim.gLimIbssCoalescingHappened = false;
3435 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3437 pStaDs =
3438 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3439 if (NULL == pStaDs)
3440 continue;
3441 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3442 if (eSIR_SUCCESS == status) {
3443 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3444 pStaDs->assocId, psessionEntry);
3445 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3446 } else {
3447 lim_log(pMac, LOGE,
3448 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303449 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 }
3451 }
3452 /* send a delBss to HAL and wait for a response */
3453 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3454
3455 if (status != eSIR_SUCCESS) {
3456 PELOGE(lim_log
3457 (pMac, LOGE, FL("delBss failed for bss %d"),
3458 psessionEntry->bssIdx);
3459 )
3460 psessionEntry->limSmeState = prevState;
3461
3462 MTRACE(mac_trace
3463 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3464 psessionEntry->limSmeState));
3465
3466 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3467 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3468 smetransactionId);
3469 }
3470}
3471
3472/**
3473 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3474 * @pMac: Global MAC context
3475 * @pMsg: Message from SME
3476 *
3477 * Wrapper for the function __lim_handle_sme_stop_bss_request
3478 * This message will be defered until softmac come out of
3479 * scan mode. Message should be handled even if we have
3480 * detected radar in the current operating channel.
3481 *
3482 * Return: true - If we consumed the buffer
3483 * false - If have defered the message.
3484 */
3485
3486static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3487{
3488 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3489 /**
3490 * If message defered, buffer is not consumed yet.
3491 * So return false
3492 */
3493 return false;
3494 }
3495 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3496 return true;
3497} /*** end __lim_process_sme_stop_bss_req() ***/
3498
3499void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3500 uint32_t body, tpPESession psessionEntry)
3501{
3502
3503 (void)body;
3504 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3505 lim_ibss_delete(pMac, psessionEntry);
3506 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3507 lim_delete_pre_auth_list(pMac);
3508 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3509 psessionEntry->smeSessionId,
3510 psessionEntry->transactionId);
3511 return;
3512}
3513
3514/**
3515 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3516 *
3517 * @mac_ctx: pointer to mac context
3518 * @msg_type: message type
3519 * @msg_buf: pointer to the SME message buffer
3520 *
3521 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3522 * in BTAMP AP.
3523 *
3524 * Return: None
3525 */
3526
3527void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3528 uint32_t *msg_buf)
3529{
3530 tSirSmeAssocCnf assoc_cnf;
3531 tpDphHashNode sta_ds = NULL;
3532 tpPESession session_entry = NULL;
3533 uint8_t session_id;
3534 tpSirAssocReq assoc_req;
3535
3536 if (msg_buf == NULL) {
3537 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3538 goto end;
3539 }
3540
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303541 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003542 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3543 lim_log(mac_ctx, LOGE,
3544 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3545 goto end;
3546 }
3547
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003548 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 &session_id);
3550 if (session_entry == NULL) {
3551 lim_log(mac_ctx, LOGE,
3552 FL("session does not exist for given bssId"));
3553 goto end;
3554 }
3555
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003556 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3558 (session_entry->limSmeState !=
3559 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3560 lim_log(mac_ctx, LOGE, FL(
3561 "Rcvd unexpected msg %X in state %X, in role %X"),
3562 msg_type, session_entry->limSmeState,
3563 GET_LIM_SYSTEM_ROLE(session_entry));
3564 goto end;
3565 }
3566 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3567 &session_entry->dph.dphHashTable);
3568 if (sta_ds == NULL) {
3569 lim_log(mac_ctx, LOGE, FL(
3570 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3571 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003572 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573
3574 /*
3575 * send a DISASSOC_IND message to WSM to make sure
3576 * the state in WSM and LIM is the same
3577 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003578 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 eSIR_SME_STA_NOT_ASSOCIATED,
3580 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3581 session_entry->smeSessionId,
3582 session_entry->transactionId,
3583 session_entry);
3584 goto end;
3585 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303586 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003587 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303588 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 lim_log(mac_ctx, LOG1, FL(
3590 "peerMacAddr mismatched for aid %d, peer "),
3591 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003592 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 goto end;
3594 }
3595
3596 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3597 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3598 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3599 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3600 (msg_type != eWNI_SME_ASSOC_CNF))) {
3601 lim_log(mac_ctx, LOG1, FL(
3602 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3603 "StaD mlmState : %d"),
3604 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003605 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 goto end;
3607 }
3608 /*
3609 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3610 * has been received
3611 */
3612 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3613 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3614 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3615
3616 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3617 /*
3618 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3619 * when it had received Assoc Request frame. Now, PE just needs
3620 * to send association rsp frame to the requesting BTAMP-STA.
3621 */
3622 sta_ds->mlmStaContext.mlmState =
3623 eLIM_MLM_LINK_ESTABLISHED_STATE;
3624 lim_log(mac_ctx, LOG1,
3625 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3626 sta_ds->assocId);
3627 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3628 sta_ds->assocId, sta_ds->staAddr,
3629 sta_ds->mlmStaContext.subType, sta_ds,
3630 session_entry);
3631 goto end;
3632 } else {
3633 /*
3634 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3635 * to be associated since the HAL sta entry is created for
3636 * denied STA we need to remove this HAL entry.
3637 * So to do that set updateContext to 1
3638 */
3639 if (!sta_ds->mlmStaContext.updateContext)
3640 sta_ds->mlmStaContext.updateContext = 1;
3641 lim_log(mac_ctx, LOG1,
3642 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3643 assoc_cnf.statusCode, sta_ds->assocId);
3644 lim_reject_association(mac_ctx, sta_ds->staAddr,
3645 sta_ds->mlmStaContext.subType,
3646 true, sta_ds->mlmStaContext.authType,
3647 sta_ds->assocId, true,
3648 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3649 session_entry);
3650 }
3651end:
3652 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3653 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3654 assoc_req = (tpSirAssocReq)
3655 session_entry->parsedAssocReq[sta_ds->assocId];
3656 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303657 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 assoc_req->assocReqFrame = NULL;
3659 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303660 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3662 }
3663}
3664
3665static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3666{
3667 tpDphHashNode pStaDs;
3668 tSirMacAddr peerMac;
3669 tpSirAddtsReq pSirAddts;
3670 uint32_t timeout;
3671 tpPESession psessionEntry;
3672 uint8_t sessionId; /* PE sessionId */
3673 uint8_t smesessionId;
3674 uint16_t smetransactionId;
3675
3676 if (pMsgBuf == NULL) {
3677 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3678 return;
3679 }
3680
3681 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3682 &smetransactionId);
3683
3684 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3685
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003686 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3687 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688 if (psessionEntry == NULL) {
3689 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3690 return;
3691 }
3692#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3693 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3694 0);
3695#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3696
3697 /* if sta
3698 * - verify assoc state
3699 * - send addts request to ap
3700 * - wait for addts response from ap
3701 * if ap, just ignore with error log
3702 */
3703 PELOG1(lim_log(pMac, LOG1,
3704 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3705 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3706 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3707 )
3708
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003709 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3711 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3712 psessionEntry, pSirAddts->req.tspec,
3713 smesessionId, smetransactionId);
3714 return;
3715 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716
3717 pStaDs =
3718 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3719 &psessionEntry->dph.dphHashTable);
3720
3721 if (pStaDs == NULL) {
3722 PELOGE(lim_log
3723 (pMac, LOGE, "Cannot find AP context for addts req");
3724 )
3725 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3726 psessionEntry, pSirAddts->req.tspec,
3727 smesessionId, smetransactionId);
3728 return;
3729 }
3730
3731 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3732 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3733 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3734 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3735 psessionEntry, pSirAddts->req.tspec,
3736 smesessionId, smetransactionId);
3737 return;
3738 }
3739
3740 pSirAddts->req.wsmTspecPresent = 0;
3741 pSirAddts->req.wmeTspecPresent = 0;
3742 pSirAddts->req.lleTspecPresent = 0;
3743
3744 if ((pStaDs->wsmEnabled) &&
3745 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3746 SIR_MAC_ACCESSPOLICY_EDCA))
3747 pSirAddts->req.wsmTspecPresent = 1;
3748 else if (pStaDs->wmeEnabled)
3749 pSirAddts->req.wmeTspecPresent = 1;
3750 else if (pStaDs->lleEnabled)
3751 pSirAddts->req.lleTspecPresent = 1;
3752 else {
3753 PELOGW(lim_log
3754 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3755 )
3756 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3757 psessionEntry, pSirAddts->req.tspec,
3758 smesessionId, smetransactionId);
3759 return;
3760 }
3761
3762 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3763 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3764 lim_log(pMac, LOGE,
3765 "AddTs received in invalid LIMsme state (%d)",
3766 psessionEntry->limSmeState);
3767 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3768 psessionEntry, pSirAddts->req.tspec,
3769 smesessionId, smetransactionId);
3770 return;
3771 }
3772
3773 if (pMac->lim.gLimAddtsSent) {
3774 lim_log(pMac, LOGE,
3775 "Addts (token %d, tsid %d, up %d) is still pending",
3776 pMac->lim.gLimAddtsReq.req.dialogToken,
3777 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3778 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3779 userPrio);
3780 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3781 psessionEntry, pSirAddts->req.tspec,
3782 smesessionId, smetransactionId);
3783 return;
3784 }
3785
3786 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3787
3788 /* save the addts request */
3789 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303790 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3792
3793 /* ship out the message now */
3794 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3795 psessionEntry);
3796 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3797 /* start a timer to wait for the response */
3798 if (pSirAddts->timeout)
3799 timeout = pSirAddts->timeout;
3800 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3801 eSIR_SUCCESS) {
3802 lim_log(pMac, LOGP,
3803 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3804 WNI_CFG_ADDTS_RSP_TIMEOUT);
3805 return;
3806 }
3807
3808 timeout = SYS_MS_TO_TICKS(timeout);
3809 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3810 != TX_SUCCESS) {
3811 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3812 return;
3813 }
3814 pMac->lim.gLimAddtsRspTimerCount++;
3815 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3816 pMac->lim.gLimAddtsRspTimerCount) !=
3817 TX_SUCCESS) {
3818 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3819 return;
3820 }
3821 MTRACE(mac_trace
3822 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3823 eLIM_ADDTS_RSP_TIMER));
3824
3825 /* add the sessionId to the timer object */
3826 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3827 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3828 TX_SUCCESS) {
3829 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3830 return;
3831 }
3832 return;
3833}
3834
3835static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3836{
3837 tSirMacAddr peerMacAddr;
3838 uint8_t ac;
3839 tSirMacTSInfo *pTsinfo;
3840 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3841 tpDphHashNode pStaDs = NULL;
3842 tpPESession psessionEntry;
3843 uint8_t sessionId;
3844 uint32_t status = eSIR_SUCCESS;
3845 uint8_t smesessionId;
3846 uint16_t smetransactionId;
3847
3848 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3849 &smetransactionId);
3850
3851 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003852 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 &sessionId);
3854 if (psessionEntry == NULL) {
3855 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3856 status = eSIR_FAILURE;
3857 goto end;
3858 }
3859#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3860 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3861 0);
3862#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3863
3864 if (eSIR_SUCCESS !=
3865 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3866 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3867 status = eSIR_FAILURE;
3868 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3869 smesessionId, smetransactionId);
3870 return;
3871 }
3872
3873 lim_log(pMac, LOG1,
3874 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3875 MAC_ADDRESS_STR),
3876 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3877
3878 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3879 pDeltsReq->req.wmeTspecPresent,
3880 &pDeltsReq->req.tsinfo,
3881 &pDeltsReq->req.tspec, psessionEntry);
3882
3883 pTsinfo =
3884 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3885 tsinfo : &pDeltsReq->req.tsinfo;
3886
3887 /* We've successfully send DELTS frame to AP. Update the
3888 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3889 * is no longer trigger enabled or delivery enabled
3890 */
3891 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3892 pTsinfo, CLEAR_UAPSD_MASK);
3893
3894 /* We're deleting the TSPEC, so this particular AC is no longer
3895 * admitted. PE needs to downgrade the EDCA
3896 * parameters(for the AC for which TS is being deleted) to the
3897 * next best AC for which ACM is not enabled, and send the
3898 * updated values to HAL.
3899 */
3900 ac = upToAc(pTsinfo->traffic.userPrio);
3901
3902 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3903 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3904 ~(1 << ac);
3905 } else if (pTsinfo->traffic.direction ==
3906 SIR_MAC_DIRECTION_DNLINK) {
3907 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3908 ~(1 << ac);
3909 } else if (pTsinfo->traffic.direction ==
3910 SIR_MAC_DIRECTION_BIDIR) {
3911 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3912 ~(1 << ac);
3913 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3914 ~(1 << ac);
3915 }
3916
3917 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3918 psessionEntry);
3919
3920 pStaDs =
3921 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3922 &psessionEntry->dph.dphHashTable);
3923 if (pStaDs != NULL) {
3924 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3925 pStaDs->bssId);
3926 status = eSIR_SUCCESS;
3927 } else {
3928 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3929 status = eSIR_FAILURE;
3930 }
3931#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003932 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933#endif
3934
3935 /* send an sme response back */
3936end:
3937 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3938 smesessionId, smetransactionId);
3939}
3940
Jeff Johnson801f1532016-10-07 07:54:50 -07003941static void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac,
3942 uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943{
3944 /* fetch the sessionEntry based on the sessionId */
3945 tpPESession psessionEntry;
3946 psessionEntry = pe_find_session_by_session_id(pMac,
3947 pMac->lim.limTimers.gLimAddtsRspTimer.
3948 sessionId);
3949 if (psessionEntry == NULL) {
3950 lim_log(pMac, LOGP,
3951 FL("Session Does not exist for given sessionID"));
3952 return;
3953 }
3954
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003955 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003956 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3957 GET_LIM_SYSTEM_ROLE(psessionEntry));
3958 pMac->lim.gLimAddtsSent = false;
3959 return;
3960 }
3961
3962 if (!pMac->lim.gLimAddtsSent) {
3963 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3964 return;
3965 }
3966
3967 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3968 lim_log(pMac, LOGE,
3969 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3970 pMac->lim.gLimAddtsRspTimerCount);
3971 return;
3972 }
3973 /* this a real response timeout */
3974 pMac->lim.gLimAddtsSent = false;
3975 pMac->lim.gLimAddtsRspTimerCount++;
3976
3977 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3978 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3979 psessionEntry->smeSessionId,
3980 psessionEntry->transactionId);
3981}
3982
3983/**
3984 * __lim_process_sme_get_statistics_request()
3985 *
3986 ***FUNCTION:
3987 *
3988 *
3989 ***NOTE:
3990 *
3991 * @param pMac Pointer to Global MAC structure
3992 * @param *pMsgBuf A pointer to the SME message buffer
3993 * @return None
3994 */
3995static void
3996__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3997{
3998 tpAniGetPEStatsReq pPEStatsReq;
3999 tSirMsgQ msgQ;
4000
4001 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4002
4003 msgQ.type = WMA_GET_STATISTICS_REQ;
4004
4005 msgQ.reserved = 0;
4006 msgQ.bodyptr = pMsgBuf;
4007 msgQ.bodyval = 0;
4008 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4009
4010 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304011 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004012 pMsgBuf = NULL;
4013 lim_log(pMac, LOGP, "Unable to forward request");
4014 return;
4015 }
4016
4017 return;
4018}
4019
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004020#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004022 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004024 * @pMac: Pointer to Global MAC structure
4025 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004027 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028 */
4029static void
4030__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4031{
4032 tSirMsgQ msgQ;
4033
4034 msgQ.type = WMA_TSM_STATS_REQ;
4035 msgQ.reserved = 0;
4036 msgQ.bodyptr = pMsgBuf;
4037 msgQ.bodyval = 0;
4038 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4039
4040 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304041 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 pMsgBuf = NULL;
4043 lim_log(pMac, LOGP, "Unable to forward request");
4044 return;
4045 }
4046}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004047#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048
4049static void
4050__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4051{
4052 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4053 tpPESession psessionEntry;
4054 uint8_t sessionId; /* PE sessionID */
4055
4056 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4057
4058 if (pMsgBuf == NULL) {
4059 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4060 return;
4061 }
4062
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304063 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 if (NULL == pUpdateAPWPSIEsReq) {
4065 lim_log(pMac, LOGP,
4066 FL
4067 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4068 return;
4069 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304070 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 sizeof(struct sSirUpdateAPWPSIEsReq));
4072
4073 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004074 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 &sessionId);
4076 if (psessionEntry == NULL) {
4077 lim_log(pMac, LOGW,
4078 FL("Session does not exist for given BSSID"));
4079 goto end;
4080 }
4081
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304082 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083 sizeof(tSirAPWPSIEs));
4084
4085 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4086 lim_send_beacon_ind(pMac, psessionEntry);
4087
4088end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304089 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 return;
4091}
4092
4093void
4094lim_send_vdev_restart(tpAniSirGlobal pMac,
4095 tpPESession psessionEntry, uint8_t sessionId)
4096{
4097 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4098 tSirMsgQ msgQ;
4099 tSirRetStatus retCode = eSIR_SUCCESS;
4100
4101 if (psessionEntry == NULL) {
4102 PELOGE(lim_log
4103 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4104 __LINE__);
4105 )
4106 return;
4107 }
4108
4109 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304110 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 if (NULL == pHalHiddenSsidVdevRestart) {
4112 PELOGE(lim_log
4113 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4114 __func__, __LINE__);
4115 )
4116 return;
4117 }
4118
4119 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4120 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4121
4122 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4123 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4124 msgQ.bodyval = 0;
4125
4126 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4127 if (eSIR_SUCCESS != retCode) {
4128 PELOGE(lim_log
4129 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4130 __LINE__);
4131 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304132 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 }
4134}
4135
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304136/**
4137 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4138 * @mac_ctx: Pointer to Global MAC structure
4139 * @msg_buf: Pointer to SME message buffer
4140 *
4141 * Return: None
4142 */
4143static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4144 uint32_t *msg_buf)
4145{
4146 tpPESession pe_session;
4147 tSirMsgQ wma_msg;
4148 tSirRetStatus status;
4149 tSirRoamOffloadScanReq *req_buffer;
4150 uint16_t local_ie_len;
4151 uint8_t *local_ie_buf;
4152
4153 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4154 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4155 req_buffer->sessionId);
4156
4157 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4158 if (!local_ie_buf) {
4159 lim_log(mac_ctx, LOGE, FL("Mem Alloc failed for local_ie_buf"));
4160 return;
4161 }
4162
4163 local_ie_len = req_buffer->assoc_ie.length;
4164 /* Update ext cap IE if present */
4165 if (local_ie_len &&
4166 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4167 local_ie_buf, &local_ie_len)) {
4168 req_buffer->assoc_ie.length = local_ie_len;
4169 qdf_mem_copy(req_buffer->assoc_ie.addIEdata, local_ie_buf,
4170 local_ie_len);
4171 }
4172 qdf_mem_free(local_ie_buf);
4173
4174 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4175 wma_msg.bodyptr = req_buffer;
4176
4177 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4178 if (eSIR_SUCCESS != status) {
4179 lim_log(mac_ctx, LOGE,
4180 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4181 qdf_mem_free(req_buffer);
4182 }
4183}
4184
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304185/*
4186 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4187 * @mac_ctx: Pointer to global mac context
4188 * @session: Pointer to PE session
4189 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4190 * 1 - Disable broadcast SSID
4191 *
4192 * Return: None
4193 */
4194static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4195 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304197 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4198 if (ssid_hidden != session->ssidHidden)
4199 session->ssidHidden = ssid_hidden;
4200 else {
4201 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304202 return;
4203 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204
4205 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304206 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207
4208 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304209 sch_set_fixed_beacon_fields(mac_ctx, session);
4210 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211
4212 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304213}
4214
4215/**
4216 * __lim_process_sme_session_update - process SME session update msg
4217 *
4218 * @mac_ctx: Pointer to global mac context
4219 * @msg_buf: Pointer to the received message buffer
4220 *
4221 * Return: None
4222 */
4223static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4224 uint32_t *msg_buf)
4225{
4226 struct sir_update_session_param *msg;
4227 tpPESession session;
4228
4229 if (!msg_buf) {
4230 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4231 return;
4232 }
4233
4234 msg = (struct sir_update_session_param *) msg_buf;
4235
4236 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4237 if (!session) {
4238 lim_log(mac_ctx, LOGW,
4239 "Session does not exist for given sessionId %d",
4240 msg->session_id);
4241 return;
4242 }
4243
4244 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4245 msg->param_type, msg->param_val);
4246 switch (msg->param_type) {
4247 case SIR_PARAM_SSID_HIDDEN:
4248 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4249 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304250 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4251 session->ignore_assoc_disallowed = msg->param_val;
4252 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304253 default:
4254 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4255 break;
4256 }
4257}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258
4259static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4260{
4261 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4262 tpPESession psessionEntry;
4263 uint8_t sessionId; /* PE sessionID */
4264
4265 if (pMsgBuf == NULL) {
4266 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4267 return;
4268 }
4269
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304270 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 if (NULL == pUpdateAPWPARSNIEsReq) {
4272 lim_log(pMac, LOGP,
4273 FL
4274 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4275 return;
4276 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304277 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4279
4280 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004281 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 &sessionId);
4283 if (psessionEntry == NULL) {
4284 lim_log(pMac, LOGW,
4285 FL("Session does not exist for given BSSID"));
4286 goto end;
4287 }
4288
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304289 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4291
4292 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4293 &psessionEntry->
4294 pLimStartBssReq->rsnIE,
4295 psessionEntry);
4296
4297 psessionEntry->pLimStartBssReq->privacy = 1;
4298 psessionEntry->privacy = 1;
4299
4300 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4301 lim_send_beacon_ind(pMac, psessionEntry);
4302
4303end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304304 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 return;
4306} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4307
4308/*
4309 Update the beacon Interval dynamically if beaconInterval is different in MCC
4310 */
4311static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4312{
4313 tpSirChangeBIParams pChangeBIParams;
4314 tpPESession psessionEntry;
4315 uint8_t sessionId = 0;
4316 tUpdateBeaconParams beaconParams;
4317
4318 PELOG1(lim_log(pMac, LOG1,
4319 FL("received Update Beacon Interval message"));
4320 );
4321
4322 if (pMsgBuf == NULL) {
4323 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4324 return;
4325 }
4326
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304327 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4329
4330 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004331 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332 &sessionId);
4333 if (psessionEntry == NULL) {
4334 lim_log(pMac, LOGE,
4335 FL("Session does not exist for given BSSID"));
4336 return;
4337 }
4338
4339 /*Update sessionEntry Beacon Interval */
4340 if (psessionEntry->beaconParams.beaconInterval !=
4341 pChangeBIParams->beaconInterval) {
4342 psessionEntry->beaconParams.beaconInterval =
4343 pChangeBIParams->beaconInterval;
4344 }
4345
4346 /*Update sch beaconInterval */
4347 if (pMac->sch.schObject.gSchBeaconInterval !=
4348 pChangeBIParams->beaconInterval) {
4349 pMac->sch.schObject.gSchBeaconInterval =
4350 pChangeBIParams->beaconInterval;
4351
4352 PELOG1(lim_log(pMac, LOG1,
4353 FL
4354 ("LIM send update BeaconInterval Indication : %d"),
4355 pChangeBIParams->beaconInterval);
4356 );
4357
4358 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4359 /* Update beacon */
4360 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4361
4362 beaconParams.bssIdx = psessionEntry->bssIdx;
4363 /* Set change in beacon Interval */
4364 beaconParams.beaconInterval =
4365 pChangeBIParams->beaconInterval;
4366 beaconParams.paramChangeBitmap =
4367 PARAM_BCN_INTERVAL_CHANGED;
4368 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4369 }
4370 }
4371
4372 return;
4373} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4374
4375#ifdef QCA_HT_2040_COEX
4376static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4377 uint32_t *pMsgBuf)
4378{
4379 tpSirSetHT2040Mode pSetHT2040Mode;
4380 tpPESession psessionEntry;
4381 uint8_t sessionId = 0;
4382 cds_msg_t msg;
4383 tUpdateVHTOpMode *pHtOpMode = NULL;
4384 uint16_t staId = 0;
4385 tpDphHashNode pStaDs = NULL;
4386
4387 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4388 if (pMsgBuf == NULL) {
4389 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4390 return;
4391 }
4392
4393 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4394
4395 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004396 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 &sessionId);
4398 if (psessionEntry == NULL) {
4399 lim_log(pMac, LOG1,
4400 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004401 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402 return;
4403 }
4404
4405 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4406 pSetHT2040Mode->cbMode);
4407 /*Update sessionEntry HT related fields */
4408 switch (pSetHT2040Mode->cbMode) {
4409 case PHY_SINGLE_CHANNEL_CENTERED:
4410 psessionEntry->htSecondaryChannelOffset =
4411 PHY_SINGLE_CHANNEL_CENTERED;
4412 psessionEntry->htRecommendedTxWidthSet = 0;
4413 if (pSetHT2040Mode->obssEnabled)
4414 psessionEntry->htSupportedChannelWidthSet
4415 = eHT_CHANNEL_WIDTH_40MHZ;
4416 else
4417 psessionEntry->htSupportedChannelWidthSet
4418 = eHT_CHANNEL_WIDTH_20MHZ;
4419 break;
4420 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4421 psessionEntry->htSecondaryChannelOffset =
4422 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4423 psessionEntry->htRecommendedTxWidthSet = 1;
4424 break;
4425 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4426 psessionEntry->htSecondaryChannelOffset =
4427 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4428 psessionEntry->htRecommendedTxWidthSet = 1;
4429 break;
4430 default:
4431 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4432 return;
4433 }
4434
4435 /* Update beacon */
4436 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4437 lim_send_beacon_ind(pMac, psessionEntry);
4438
4439 /* update OP Mode for each associated peer */
4440 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4441 pStaDs = dph_get_hash_entry(pMac, staId,
4442 &psessionEntry->dph.dphHashTable);
4443 if (NULL == pStaDs)
4444 continue;
4445
4446 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304447 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004448 if (NULL == pHtOpMode) {
4449 lim_log(pMac, LOGE,
4450 FL
4451 ("%s: Not able to allocate memory for setting OP mode"),
4452 __func__);
4453 return;
4454 }
4455 pHtOpMode->opMode =
4456 (psessionEntry->htSecondaryChannelOffset ==
4457 PHY_SINGLE_CHANNEL_CENTERED) ?
4458 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4459 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304460 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 sizeof(tSirMacAddr));
4462 pHtOpMode->smesessionId = sessionId;
4463
4464 msg.type = WMA_UPDATE_OP_MODE;
4465 msg.reserved = 0;
4466 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304467 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304468 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 lim_log(pMac, LOGE,
4470 FL
4471 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4472 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304473 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004474 return;
4475 }
4476 lim_log(pMac, LOG1,
4477 FL
4478 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4479 __func__, pHtOpMode->opMode, staId);
4480
4481 } else
4482 lim_log(pMac, LOG1,
4483 FL("%s: station %d does not support HT40\n"),
4484 __func__, staId);
4485 }
4486
4487 return;
4488}
4489#endif
4490
4491/* -------------------------------------------------------------------- */
4492/**
4493 * __lim_process_report_message
4494 *
4495 * FUNCTION: Processes the next received Radio Resource Management message
4496 *
4497 * LOGIC:
4498 *
4499 * ASSUMPTIONS:
4500 *
4501 * NOTE:
4502 *
4503 * @param None
4504 * @return None
4505 */
4506
Jeff Johnson801f1532016-10-07 07:54:50 -07004507static void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 switch (pMsg->type) {
4510 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4511 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4512 break;
4513 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004515 break;
4516 default:
4517 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519}
4520
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521/* -------------------------------------------------------------------- */
4522/**
4523 * lim_send_set_max_tx_power_req
4524 *
4525 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4526 *
4527 * LOGIC:
4528 *
4529 * ASSUMPTIONS:
4530 *
4531 * NOTE:
4532 *
4533 * @param txPower txPower to be set.
4534 * @param pSessionEntry session entry.
4535 * @return None
4536 */
4537tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004538lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539 tpPESession pSessionEntry)
4540{
4541 tpMaxTxPowerParams pMaxTxParams = NULL;
4542 tSirRetStatus retCode = eSIR_SUCCESS;
4543 tSirMsgQ msgQ;
4544
4545 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304546 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547 return eSIR_FAILURE;
4548 }
4549
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304550 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 if (NULL == pMaxTxParams) {
4552 lim_log(pMac, LOGP,
4553 FL("Unable to allocate memory for pMaxTxParams "));
4554 return eSIR_MEM_ALLOC_FAILED;
4555
4556 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304558 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304559 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304560 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004561 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304562 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563
4564 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4565 msgQ.bodyptr = pMaxTxParams;
4566 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304567 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4569 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4570 if (eSIR_SUCCESS != retCode) {
4571 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304572 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 }
4574 return retCode;
4575}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576
4577/**
4578 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4579 *
4580 * @mac_ctx: Pointer to Global MAC structure
4581 * @msg_buf: pointer to the SME message buffer
4582 *
4583 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4584 * from SME. It Register this information within PE.
4585 *
4586 * Return: None
4587 */
4588static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4589 uint32_t *msg_buf)
4590{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304591 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4593 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4594 struct mgmt_frm_reg_info *next = NULL;
4595 bool match = false;
4596
4597 lim_log(mac_ctx, LOG1, FL(
4598 "registerFrame %d, frameType %d, matchLen %d"),
4599 sme_req->registerFrame, sme_req->frameType,
4600 sme_req->matchLen);
4601 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304602 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304603 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4604 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304605 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606
4607 while (lim_mgmt_regn != NULL) {
4608 if (lim_mgmt_regn->frameType != sme_req->frameType)
4609 goto skip_match;
4610 if (sme_req->matchLen) {
4611 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304612 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 sme_req->matchData,
4614 lim_mgmt_regn->matchLen))) {
4615 /* found match! */
4616 match = true;
4617 break;
4618 }
4619 } else {
4620 /* found match! */
4621 match = true;
4622 break;
4623 }
4624skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304625 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304626 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304628 (qdf_list_node_t *)lim_mgmt_regn,
4629 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304630 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 lim_mgmt_regn = next;
4632 next = NULL;
4633 }
4634 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304635 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004636 if (QDF_STATUS_SUCCESS ==
4637 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004639 (qdf_list_node_t *)lim_mgmt_regn))
4640 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304641 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 }
4643
4644 if (sme_req->registerFrame) {
4645 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304646 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 sme_req->matchLen);
4648 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 lim_mgmt_regn->frameType = sme_req->frameType;
4650 lim_mgmt_regn->matchLen = sme_req->matchLen;
4651 lim_mgmt_regn->sessionId = sme_req->sessionId;
4652 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304653 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 sme_req->matchData,
4655 sme_req->matchLen);
4656 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304657 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304659 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 gLimMgmtFrameRegistratinQueue,
4661 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304662 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 &mac_ctx->lim.lim_frame_register_lock);
4664 }
4665 }
4666 return;
4667}
4668
4669static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4670{
4671 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4672 pMac->lim.gDeferMsgTypeForNOA);
4673 pMac->lim.gDeferMsgTypeForNOA = 0;
4674 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4675 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304676 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4678 }
4679}
4680
4681/**
4682 * lim_process_regd_defd_sme_req_after_noa_start()
4683 *
4684 * mac_ctx: Pointer to Global MAC structure
4685 *
4686 * This function is called to process deferred sme req message
4687 * after noa start.
4688 *
4689 * Return: None
4690 */
4691void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4692{
4693 bool buf_consumed = true;
4694
4695 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4696 mac_ctx->lim.gDeferMsgTypeForNOA);
4697
4698 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4699 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4700 lim_log(mac_ctx, LOGW,
4701 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4702 lim_log(mac_ctx, LOGW,
4703 FL("It may happen when NOA start ind and timeout happen at the same time"));
4704 return;
4705 }
4706 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4707 case eWNI_SME_SCAN_REQ:
4708 __lim_process_sme_scan_req(mac_ctx,
4709 mac_ctx->lim.gpDefdSmeMsgForNOA);
4710 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4712 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4713 mac_ctx->lim.gpDefdSmeMsgForNOA);
4714 /*
4715 * lim_process_remain_on_chnl_req doesnt want us to free
4716 * the buffer since it is freed in lim_remain_on_chn_rsp.
4717 * this change is to avoid "double free"
4718 */
4719 if (false == buf_consumed)
4720 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4721 break;
4722 case eWNI_SME_JOIN_REQ:
4723 __lim_process_sme_join_req(mac_ctx,
4724 mac_ctx->lim.gpDefdSmeMsgForNOA);
4725 break;
4726 default:
4727 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4728 mac_ctx->lim.gDeferMsgTypeForNOA);
4729 break;
4730 }
4731 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4732}
4733
4734static void
4735__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4736{
4737 tpSirResetAPCapsChange pResetCapsChange;
4738 tpPESession psessionEntry;
4739 uint8_t sessionId = 0;
4740 if (pMsgBuf == NULL) {
4741 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4742 return;
4743 }
4744
4745 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4746 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004747 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4748 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 if (psessionEntry == NULL) {
4750 lim_log(pMac, LOGE,
4751 FL("Session does not exist for given BSSID"));
4752 return;
4753 }
4754
4755 psessionEntry->limSentCapsChangeNtf = false;
4756 return;
4757}
4758
4759/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304760 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4761 * @mac_ctx: Mac pointer
4762 * @msg_buf: Msg pointer containing the callback
4763 *
4764 * This function is used to save the p2p ack indication callback in PE.
4765 *
4766 * Return: None
4767 */
4768static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4769 uint32_t *msg_buf)
4770{
4771 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4772 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4773
4774 if (NULL == msg_buf) {
4775 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4776 return;
4777 }
4778 if (sme_req->callback)
4779 mac_ctx->p2p_ack_ind_cb =
4780 sme_req->callback;
4781 else
4782 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4783}
4784
4785/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304786 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4787 * indication callback in PE.
4788 * @mac_ptr: Mac pointer
4789 * @msg_buf: Msg pointer containing the callback
4790 *
4791 * This function is used save the Management frame
4792 * indication callback in PE.
4793 *
4794 * Return: None
4795 */
4796static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4797 uint32_t *msg_buf)
4798{
4799 struct sir_sme_mgmt_frame_cb_req *sme_req =
4800 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4801
4802 if (NULL == msg_buf) {
4803 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4804 return;
4805 }
4806 if (sme_req->callback)
4807 mac_ctx->mgmt_frame_ind_cb =
4808 (sir_mgmt_frame_ind_callback)sme_req->callback;
4809 else
4810 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4811}
4812
4813/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304814 *__lim_process_send_disassoc_frame: function processes disassoc frame
4815 * @mac_ctx: pointer to mac context
4816 * @msg_buf: message buffer
4817 *
4818 * function processes disassoc request received from SME
4819 *
4820 * return: none
4821 */
4822static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4823 uint32_t *msg_buf)
4824{
4825 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4826 tSirRetStatus status;
4827 tpPESession session_entry = NULL;
4828 uint8_t sme_session_id;
4829 uint16_t sme_trans_id;
4830
4831 if (msg_buf == NULL) {
4832 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4833 return;
4834 }
4835
4836 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4837 &sme_trans_id);
4838
4839 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4840 &sme_send_disassoc_frame_req,
4841 (uint8_t *)msg_buf);
4842
4843 if ((eSIR_FAILURE == status) ||
4844 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4845 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4846 PELOGE(lim_log(mac_ctx, LOGE,
4847 FL("received invalid SME_DISASSOC_REQ message"));)
4848 return;
4849 }
4850
4851 session_entry = pe_find_session_by_sme_session_id(
4852 mac_ctx, sme_session_id);
4853 if (session_entry == NULL) {
4854 lim_log(mac_ctx, LOGE,
4855 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4856 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4857 return;
4858 }
4859
4860 lim_log(mac_ctx, LOG1,
4861 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4862 sme_send_disassoc_frame_req.msg_type,
4863 sme_send_disassoc_frame_req.length,
4864 sme_send_disassoc_frame_req.session_id,
4865 sme_send_disassoc_frame_req.trans_id,
4866 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4867 sme_send_disassoc_frame_req.reason,
4868 sme_send_disassoc_frame_req.wait_for_ack);
4869
4870 lim_send_disassoc_mgmt_frame(mac_ctx,
4871 sme_send_disassoc_frame_req.reason,
4872 sme_send_disassoc_frame_req.peer_mac,
4873 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4874}
4875
4876/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004877 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4878 * @mac_ctx: Pointer to Global MAC structure
4879 * @pdev_id: pdev id to set the IE.
4880 * @nss: Nss values to prepare the HT IE.
4881 *
4882 * Prepares the HT IE with self capabilities for different
4883 * Nss values and sends the set HT IE req to FW.
4884 *
4885 * Return: None
4886 */
4887static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4888 uint8_t nss)
4889{
4890 struct set_ie_param *ie_params;
4891 tSirMsgQ msg;
4892 tSirRetStatus rc = eSIR_SUCCESS;
4893 uint8_t *p_ie = NULL;
4894 tHtCaps *p_ht_cap;
4895 int i;
4896
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004897 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004898 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4899 if (NULL == ie_params) {
4900 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4901 return;
4902 }
4903 ie_params->nss = i;
4904 ie_params->pdev_id = pdev_id;
4905 ie_params->ie_type = DOT11_HT_IE;
4906 /* 2 for IE len and EID */
4907 ie_params->ie_len = 2 + sizeof(tHtCaps);
4908 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4909 if (NULL == ie_params->ie_ptr) {
4910 qdf_mem_free(ie_params);
4911 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4912 return;
4913 }
4914 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4915 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4916 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4917 ie_params->ie_len);
4918
4919 if (NSS_1x1_MODE == i) {
4920 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4921 ie_params->ie_len,
4922 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004923 if (NULL == p_ie) {
4924 qdf_mem_free(ie_params->ie_ptr);
4925 qdf_mem_free(ie_params);
4926 lim_log(mac_ctx, LOGE,
4927 FL("failed to get IE ptr"));
4928 return;
4929 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004930 p_ht_cap = (tHtCaps *)&p_ie[2];
4931 p_ht_cap->supportedMCSSet[1] = 0;
4932 p_ht_cap->txSTBC = 0;
4933 }
4934
4935 msg.type = WMA_SET_PDEV_IE_REQ;
4936 msg.bodyptr = ie_params;
4937 msg.bodyval = 0;
4938
4939 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4940 if (rc != eSIR_SUCCESS) {
4941 lim_log(mac_ctx, LOGE,
4942 FL("wma_post_ctrl_msg() return failure"));
4943 qdf_mem_free(ie_params->ie_ptr);
4944 qdf_mem_free(ie_params);
4945 return;
4946 }
4947 }
4948}
4949
4950/**
4951 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4952 * @mac_ctx: Pointer to Global MAC structure
4953 * @pdev_id: pdev id to set the IE.
4954 * @nss: Nss values to prepare the VHT IE.
4955 *
4956 * Prepares the VHT IE with self capabilities for different
4957 * Nss values and sends the set VHT IE req to FW.
4958 *
4959 * Return: None
4960 */
4961static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4962 uint8_t nss)
4963{
4964 struct set_ie_param *ie_params;
4965 tSirMsgQ msg;
4966 tSirRetStatus rc = eSIR_SUCCESS;
4967 uint8_t *p_ie = NULL;
4968 tSirMacVHTCapabilityInfo *vht_cap;
4969 int i;
4970 tSirVhtMcsInfo *vht_mcs;
4971
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004972 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004973 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4974 if (NULL == ie_params) {
4975 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4976 return;
4977 }
4978 ie_params->nss = i;
4979 ie_params->pdev_id = pdev_id;
4980 ie_params->ie_type = DOT11_VHT_IE;
4981 /* 2 for IE len and EID */
4982 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4983 sizeof(tSirVhtMcsInfo);
4984 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4985 if (NULL == ie_params->ie_ptr) {
4986 qdf_mem_free(ie_params);
4987 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4988 return;
4989 }
4990 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4991 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4992 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4993 ie_params->ie_len);
4994
4995 if (NSS_1x1_MODE == i) {
4996 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4997 ie_params->ie_len,
4998 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004999 if (NULL == p_ie) {
5000 qdf_mem_free(ie_params->ie_ptr);
5001 qdf_mem_free(ie_params);
5002 lim_log(mac_ctx, LOGE,
5003 FL("failed to get IE ptr"));
5004 return;
5005 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005006 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
5007 vht_cap->txSTBC = 0;
5008 vht_mcs =
5009 (tSirVhtMcsInfo *)&p_ie[2 +
5010 sizeof(tSirMacVHTCapabilityInfo)];
5011 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5012 vht_mcs->rxHighest =
5013 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5014 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5015 vht_mcs->txHighest =
5016 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5017 }
5018 msg.type = WMA_SET_PDEV_IE_REQ;
5019 msg.bodyptr = ie_params;
5020 msg.bodyval = 0;
5021
5022 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5023 if (rc != eSIR_SUCCESS) {
5024 lim_log(mac_ctx, LOGE,
5025 FL("wma_post_ctrl_msg failure"));
5026 qdf_mem_free(ie_params->ie_ptr);
5027 qdf_mem_free(ie_params);
5028 return;
5029 }
5030 }
5031}
5032
5033/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005034 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5035 * @mac_ctx: Pointer to Global MAC structure
5036 * @msg_buf: Pointer to the SME message buffer
5037 *
5038 * This function is called by limProcessMessageQueue(). This function sets the
5039 * VDEV IEs to the FW.
5040 *
5041 * Return: None
5042 */
5043static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5044 uint32_t *msg_buf)
5045{
5046 struct sir_set_vdev_ies_per_band *p_msg =
5047 (struct sir_set_vdev_ies_per_band *)msg_buf;
5048
5049 if (NULL == p_msg) {
5050 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5051 return;
5052 }
5053
5054 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5055 p_msg->vdev_id);
5056 /* intentionally using NULL here so that self capabilty are sent */
5057 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5058 QDF_STATUS_SUCCESS)
5059 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5060}
5061
5062/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005063 * lim_process_set_pdev_IEs() - process the set pdev IE req
5064 * @mac_ctx: Pointer to Global MAC structure
5065 * @msg_buf: Pointer to the SME message buffer
5066 *
5067 * This function is called by limProcessMessageQueue(). This
5068 * function sets the PDEV IEs to the FW.
5069 *
5070 * Return: None
5071 */
5072static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5073{
5074 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5075
5076 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5077
5078 if (NULL == ht_vht_cfg) {
5079 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5080 return;
5081 }
5082
5083 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5084 ht_vht_cfg->nss);
5085 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5086
5087 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5088 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5089 ht_vht_cfg->nss);
5090}
5091
5092/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305093 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5094 *
5095 * access policy
5096 * @mac_ctx: pointer to mac context
5097 * @msg: message buffer
5098 *
5099 * function processes vendor IE and access policy from SME and updates PE
5100 *
5101 * session entry
5102 *
5103 * return: none
5104*/
5105static void lim_process_sme_update_access_policy_vendor_ie(
5106 tpAniSirGlobal mac_ctx,
5107 uint32_t *msg)
5108{
5109 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5110 struct sPESession *pe_session_entry;
5111 uint8_t num_bytes;
5112
5113 if (!msg) {
5114 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5115 return;
5116 }
5117 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5118 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5119 update_vendor_ie->sme_session_id);
5120
5121 if (!pe_session_entry) {
5122 lim_log(mac_ctx, LOGE,
5123 FL("Session does not exist for given sme session id(%hu)"),
5124 update_vendor_ie->sme_session_id);
5125 return;
5126 }
5127 if (pe_session_entry->access_policy_vendor_ie)
5128 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5129
5130 num_bytes = update_vendor_ie->ie[1] + 2;
5131 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5132
5133 if (!pe_session_entry->access_policy_vendor_ie) {
5134 lim_log(mac_ctx, LOGE,
5135 FL("Failed to allocate memory for vendor ie"));
5136 return;
5137 }
5138 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5139 &update_vendor_ie->ie[0], num_bytes);
5140
5141 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5142}
5143
5144/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005145 * lim_process_sme_req_messages()
5146 *
5147 ***FUNCTION:
5148 * This function is called by limProcessMessageQueue(). This
5149 * function processes SME request messages from HDD or upper layer
5150 * application.
5151 *
5152 ***LOGIC:
5153 *
5154 ***ASSUMPTIONS:
5155 *
5156 ***NOTE:
5157 *
5158 * @param pMac Pointer to Global MAC structure
5159 * @param msgType Indicates the SME message type
5160 * @param *pMsgBuf A pointer to the SME message buffer
5161 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5162 * false - if pMsgBuf is not to be freed.
5163 */
5164
5165bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5166{
5167 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5168 uint32_t *pMsgBuf = pMsg->bodyptr;
5169 tpSirSmeScanReq pScanReq;
5170 PELOG1(lim_log
5171 (pMac, LOG1,
5172 FL
5173 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5174 lim_msg_str(pMsg->type), pMsg->type,
5175 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5176 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5177 )
5178
5179 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5180 /* If no insert NOA required then execute the code below */
5181
5182 switch (pMsg->type) {
5183 case eWNI_SME_SYS_READY_IND:
5184 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5185 break;
5186
5187 case eWNI_SME_START_BSS_REQ:
5188 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5189 break;
5190
5191 case eWNI_SME_SCAN_REQ:
5192 __lim_process_sme_scan_req(pMac, pMsgBuf);
5193 break;
5194
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5196 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5197 break;
5198
5199 case eWNI_SME_UPDATE_NOA:
5200 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5201 break;
5202 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5203 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5204 break;
5205 case eWNI_SME_JOIN_REQ:
5206 __lim_process_sme_join_req(pMac, pMsgBuf);
5207 break;
5208
5209 case eWNI_SME_REASSOC_REQ:
5210 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5211 break;
5212
5213 case eWNI_SME_DISASSOC_REQ:
5214 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5215 break;
5216
5217 case eWNI_SME_DISASSOC_CNF:
5218 case eWNI_SME_DEAUTH_CNF:
5219 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5220 break;
5221
5222 case eWNI_SME_DEAUTH_REQ:
5223 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5224 break;
5225
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305226 case eWNI_SME_SEND_DISASSOC_FRAME:
5227 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5228 break;
5229
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005230 case eWNI_SME_SETCONTEXT_REQ:
5231 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5232 break;
5233
5234 case eWNI_SME_STOP_BSS_REQ:
5235 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5236 break;
5237
5238 case eWNI_SME_ASSOC_CNF:
5239 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5240 PELOG1(lim_log(pMac,
5241 LOG1, FL("Received ASSOC_CNF message"));)
5242 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5243 pMsgBuf);
5244 break;
5245
5246 case eWNI_SME_ADDTS_REQ:
5247 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5248 __lim_process_sme_addts_req(pMac, pMsgBuf);
5249 break;
5250
5251 case eWNI_SME_DELTS_REQ:
5252 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5253 __lim_process_sme_delts_req(pMac, pMsgBuf);
5254 break;
5255
5256 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5257 PELOG1(lim_log
5258 (pMac, LOG1,
5259 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5260 )
5261 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5262 break;
5263
5264 case eWNI_SME_GET_STATISTICS_REQ:
5265 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5266 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5267 bufConsumed = false;
5268 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005269#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270 case eWNI_SME_GET_TSM_STATS_REQ:
5271 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5272 bufConsumed = false;
5273 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005274#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 case eWNI_SME_GET_ASSOC_STAS_REQ:
5276 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5277 break;
5278 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5279 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5280 break;
5281
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305282 case eWNI_SME_SESSION_UPDATE_PARAM:
5283 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305285 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5286 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5287 bufConsumed = false;
5288 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289 case eWNI_SME_UPDATE_APWPSIE_REQ:
5290 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5291 break;
5292 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5293 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5294 break;
5295
5296 case eWNI_SME_SET_APWPARSNIEs_REQ:
5297 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5298 break;
5299
5300 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5301 /* Update the beaconInterval */
5302 __lim_process_sme_change_bi(pMac, pMsgBuf);
5303 break;
5304
5305#ifdef QCA_HT_2040_COEX
5306 case eWNI_SME_SET_HT_2040_MODE:
5307 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5308 break;
5309#endif
5310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005311 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5312 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5313 __lim_process_report_message(pMac, pMsg);
5314 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005316 case eWNI_SME_FT_PRE_AUTH_REQ:
5317 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5318 break;
5319 case eWNI_SME_FT_UPDATE_KEY:
5320 lim_process_ft_update_key(pMac, pMsgBuf);
5321 break;
5322
5323 case eWNI_SME_FT_AGGR_QOS_REQ:
5324 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5325 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326
5327 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5328 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5329 break;
5330#ifdef FEATURE_WLAN_TDLS
5331 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5332 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5333 break;
5334 case eWNI_SME_TDLS_ADD_STA_REQ:
5335 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5336 break;
5337 case eWNI_SME_TDLS_DEL_STA_REQ:
5338 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5339 break;
5340 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5341 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5342 break;
5343#endif
5344 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5345 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5346 break;
5347
5348 case eWNI_SME_CHANNEL_CHANGE_REQ:
5349 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5350 break;
5351
5352 case eWNI_SME_START_BEACON_REQ:
5353 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5354 break;
5355
5356 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5357 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5358 break;
5359
5360 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5361 lim_process_update_add_ies(pMac, pMsgBuf);
5362 break;
5363
5364 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5365 lim_process_modify_add_ies(pMac, pMsgBuf);
5366 break;
5367 case eWNI_SME_SET_HW_MODE_REQ:
5368 lim_process_set_hw_mode(pMac, pMsgBuf);
5369 break;
5370 case eWNI_SME_NSS_UPDATE_REQ:
5371 lim_process_nss_update_request(pMac, pMsgBuf);
5372 break;
5373 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5374 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5375 break;
5376 case eWNI_SME_SET_IE_REQ:
5377 lim_process_set_ie_req(pMac, pMsgBuf);
5378 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305379 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5380 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5381 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305382 case eWNI_SME_EXT_CHANGE_CHANNEL:
5383 lim_process_ext_change_channel(pMac, pMsgBuf);
5384 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005385 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5386 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5387 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005388 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5389 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005390 break;
5391 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5392 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5393 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005394 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005395 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005396 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005397 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005398 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305399 case eWNI_SME_REGISTER_P2P_ACK_CB:
5400 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5401 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305402 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5403 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5404 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005405 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305406 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 pMsg->bodyptr = NULL;
5408 break;
5409 } /* switch (msgType) */
5410
5411 return bufConsumed;
5412} /*** end lim_process_sme_req_messages() ***/
5413
5414/**
5415 * lim_process_sme_start_beacon_req()
5416 *
5417 ***FUNCTION:
5418 * This function is called by limProcessMessageQueue(). This
5419 * function processes SME request messages from HDD or upper layer
5420 * application.
5421 *
5422 ***LOGIC:
5423 *
5424 ***ASSUMPTIONS:
5425 *
5426 ***NOTE:
5427 *
5428 * @param pMac Pointer to Global MAC structure
5429 * @param msgType Indicates the SME message type
5430 * @param *pMsgBuf A pointer to the SME message buffer
5431 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5432 * false - if pMsgBuf is not to be freed.
5433 */
5434static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5435{
5436 tpSirStartBeaconIndication pBeaconStartInd;
5437 tpPESession psessionEntry;
5438 uint8_t sessionId; /* PE sessionID */
5439
5440 if (pMsg == NULL) {
5441 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5442 return;
5443 }
5444
5445 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5446 psessionEntry = pe_find_session_by_bssid(pMac,
5447 pBeaconStartInd->bssid,
5448 &sessionId);
5449 if (psessionEntry == NULL) {
5450 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5451 lim_log(pMac, LOGE,
5452 FL("Session does not exist for given bssId"));
5453 return;
5454 }
5455
5456 if (pBeaconStartInd->beaconStartStatus == true) {
5457 /*
5458 * Currently this Indication comes from SAP
5459 * to start Beacon Tx on a DFS channel
5460 * since beaconing has to be done on DFS
5461 * channel only after CAC WAIT is completed.
5462 * On a DFS Channel LIM does not start beacon
5463 * Tx right after the WMA_ADD_BSS_RSP.
5464 */
5465 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305466 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005467 FL("Start Beacon with ssid %s Ch %d"),
5468 psessionEntry->ssId.ssId,
5469 psessionEntry->currentOperChannel);
5470 lim_send_beacon_ind(pMac, psessionEntry);
5471 } else {
5472 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5473 return;
5474 }
5475}
5476
5477/**
5478 * lim_process_sme_channel_change_request() - process sme ch change req
5479 *
5480 * @mac_ctx: Pointer to Global MAC structure
5481 * @msg_buf: pointer to the SME message buffer
5482 *
5483 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5484 *
5485 * Return: None
5486 */
5487static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5488 uint32_t *msg_buf)
5489{
5490 tpSirChanChangeRequest ch_change_req;
5491 tpPESession session_entry;
5492 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005493 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 uint32_t val = 0;
5495
5496 if (msg_buf == NULL) {
5497 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5498 return;
5499 }
5500 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5501
5502 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5503 ch_change_req->targetChannel);
5504
5505 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5506 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5507 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5508 return;
5509 }
5510
5511 session_entry = pe_find_session_by_bssid(mac_ctx,
5512 ch_change_req->bssid, &session_id);
5513 if (session_entry == NULL) {
5514 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5515 lim_log(mac_ctx, LOGE, FL(
5516 "Session does not exist for given bssId"));
5517 return;
5518 }
5519
5520 if (session_entry->currentOperChannel ==
5521 ch_change_req->targetChannel) {
5522 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5523 return;
5524 }
5525
5526 if (LIM_IS_AP_ROLE(session_entry))
5527 session_entry->channelChangeReasonCode =
5528 LIM_SWITCH_CHANNEL_SAP_DFS;
5529 else
5530 session_entry->channelChangeReasonCode =
5531 LIM_SWITCH_CHANNEL_OPERATION;
5532
5533 lim_log(mac_ctx, LOGW, FL(
5534 "switch old chnl %d to new chnl %d, ch_bw %d"),
5535 session_entry->currentOperChannel,
5536 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005537 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538
5539 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005540 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541 session_entry->ch_center_freq_seg0 =
5542 ch_change_req->center_freq_seg_0;
5543 session_entry->ch_center_freq_seg1 =
5544 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005545 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005547 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548 session_entry->htRecommendedTxWidthSet =
5549 session_entry->htSupportedChannelWidthSet;
5550 session_entry->currentOperChannel =
5551 ch_change_req->targetChannel;
5552 session_entry->limRFBand =
5553 lim_get_rf_band(session_entry->currentOperChannel);
5554 /* Initialize 11h Enable Flag */
5555 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5556 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5557 eSIR_SUCCESS)
5558 lim_log(mac_ctx, LOGP,
5559 FL("Fail to get WNI_CFG_11H_ENABLED"));
5560 }
5561
5562 session_entry->lim11hEnable = val;
5563 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305564 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 &ch_change_req->operational_rateset,
5566 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305567 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 &ch_change_req->extended_rateset,
5569 sizeof(session_entry->extRateSet));
5570 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5571 session_entry->ch_center_freq_seg0,
5572 session_entry->ch_center_freq_seg1,
5573 session_entry->ch_width,
5574 max_tx_pwr, session_entry->peSessionId);
5575}
5576
5577/******************************************************************************
5578* lim_start_bss_update_add_ie_buffer()
5579*
5580***FUNCTION:
5581* This function checks the src buffer and its length and then malloc for
5582* dst buffer update the same
5583*
5584***LOGIC:
5585*
5586***ASSUMPTIONS:
5587*
5588***NOTE:
5589*
5590* @param pMac Pointer to Global MAC structure
5591* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5592* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5593* @param *pSrcData_buff A pointer of uint8_t src buffer
5594* @param srcDataLen src buffer length
5595******************************************************************************/
5596
5597static void
5598lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5599 uint8_t **pDstData_buff,
5600 uint16_t *pDstDataLen,
5601 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5602{
5603
5604 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5605 *pDstDataLen = srcDataLen;
5606
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305607 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608
5609 if (NULL == *pDstData_buff) {
5610 lim_log(pMac, LOGE,
5611 FL("AllocateMemory failed for pDstData_buff"));
5612 return;
5613 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305614 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 } else {
5616 *pDstData_buff = NULL;
5617 *pDstDataLen = 0;
5618 }
5619}
5620
5621/******************************************************************************
5622* lim_update_add_ie_buffer()
5623*
5624***FUNCTION:
5625* This function checks the src buffer and length if src buffer length more
5626* than dst buffer length then free the dst buffer and malloc for the new src
5627* length, and update the dst buffer and length. But if dst buffer is bigger
5628* than src buffer length then it just update the dst buffer and length
5629*
5630***LOGIC:
5631*
5632***ASSUMPTIONS:
5633*
5634***NOTE:
5635*
5636* @param pMac Pointer to Global MAC structure
5637* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5638* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5639* @param *pSrcData_buff A pointer of uint8_t src buffer
5640* @param srcDataLen src buffer length
5641******************************************************************************/
5642
5643static void
5644lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5645 uint8_t **pDstData_buff,
5646 uint16_t *pDstDataLen,
5647 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5648{
5649
5650 if (NULL == pSrcData_buff) {
5651 lim_log(pMac, LOGE, FL("src buffer is null."));
5652 return;
5653 }
5654
5655 if (srcDataLen > *pDstDataLen) {
5656 *pDstDataLen = srcDataLen;
5657 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305658 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305660 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661
5662 if (NULL == *pDstData_buff) {
5663 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5664 *pDstDataLen = 0;
5665 return;
5666 }
5667 }
5668
5669 /* copy the content of buffer into dst buffer
5670 */
5671 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305672 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005673
5674}
5675
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005676/**
5677 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5678 * @pMac : Pointer to Global MAC structure
5679 * @pDstData_buff : A pointer to pointer of dst buffer
5680 * @pDstDataLen : A pointer to pointer of dst buffer length
5681 * @pModifyIE : A pointer to tSirModifyIE
5682 *
5683 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5684 *
5685 * Return:
5686 * True or false depending upon whether IE is updated or not
5687 */
5688static bool
5689lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5690 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5691{
5692 int32_t oui_length;
5693 uint8_t *ibss_ie = NULL;
5694
5695 ibss_ie = pModifyIE->pIEBuffer;
5696 oui_length = pModifyIE->oui_length;
5697
5698 if ((0 == oui_length) || (NULL == ibss_ie)) {
5699 PELOGE(lim_log(pMac, LOGE,
5700 FL("Invalid set IBSS vendor IE command length %d "),
5701 oui_length);)
5702 return false;
5703 }
5704
5705 lim_update_add_ie_buffer(pMac,
5706 pDstData_buff,
5707 pDstDataLen,
5708 pModifyIE->pIEBuffer,
5709 pModifyIE->ieBufferlength);
5710
5711 return true;
5712}
5713
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714/*
5715* lim_process_modify_add_ies() - process modify additional IE req.
5716*
5717* @mac_ctx: Pointer to Global MAC structure
5718* @msg_buf: pointer to the SME message buffer
5719*
5720* This function update the PE buffers for additional IEs.
5721*
5722* Return: None
5723*/
5724static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5725 uint32_t *msg_buf)
5726{
5727 tpSirModifyIEsInd modify_add_ies;
5728 tpPESession session_entry;
5729 uint8_t session_id;
5730 bool ret = false;
5731 tSirAddIeParams *add_ie_params;
5732
5733 if (msg_buf == NULL) {
5734 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5735 return;
5736 }
5737
5738 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5739 /* Incoming message has smeSession, use BSSID to find PE session */
5740 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005741 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742
5743 if (NULL == session_entry) {
5744 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5745 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005746 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 goto end;
5748 }
5749 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5750 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5751 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5752 lim_log(mac_ctx, LOGE,
5753 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5754 modify_add_ies->modifyIE.pIEBuffer,
5755 modify_add_ies->modifyIE.ieBufferlength,
5756 modify_add_ies->modifyIE.ieID,
5757 modify_add_ies->modifyIE.ieIDLen,
5758 modify_add_ies->updateType);
5759 goto end;
5760 }
5761 add_ie_params = &session_entry->addIeParams;
5762 switch (modify_add_ies->updateType) {
5763 case eUPDATE_IE_PROBE_RESP:
5764 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005765 if (LIM_IS_IBSS_ROLE(session_entry)) {
5766 lim_update_ibss_prop_add_ies(mac_ctx,
5767 &add_ie_params->probeRespData_buff,
5768 &add_ie_params->probeRespDataLen,
5769 &modify_add_ies->modifyIE);
5770 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 break;
5772 case eUPDATE_IE_ASSOC_RESP:
5773 /* assoc resp IE */
5774 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305775 QDF_TRACE(QDF_MODULE_ID_PE,
5776 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005777 "assoc resp add ie not present %d"),
5778 add_ie_params->assocRespDataLen);
5779 }
5780 /* search through the buffer and modify the IE */
5781 break;
5782 case eUPDATE_IE_PROBE_BCN:
5783 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005784 if (LIM_IS_IBSS_ROLE(session_entry)) {
5785 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5786 &add_ie_params->probeRespBCNData_buff,
5787 &add_ie_params->probeRespBCNDataLen,
5788 &modify_add_ies->modifyIE);
5789 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 if (ret == true && modify_add_ies->modifyIE.notify) {
5791 lim_handle_param_update(mac_ctx,
5792 modify_add_ies->updateType);
5793 }
5794 break;
5795 default:
5796 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5797 modify_add_ies->updateType);
5798 break;
5799 }
5800end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305801 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 modify_add_ies->modifyIE.pIEBuffer = NULL;
5803}
5804
5805/*
5806* lim_process_update_add_ies() - process additional IE update req
5807*
5808* @mac_ctx: Pointer to Global MAC structure
5809* @msg_buf: pointer to the SME message buffer
5810*
5811* This function update the PE buffers for additional IEs.
5812*
5813* Return: None
5814*/
5815static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5816 uint32_t *msg_buf)
5817{
5818 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5819 uint8_t session_id;
5820 tpPESession session_entry;
5821 tSirAddIeParams *addn_ie;
5822 uint16_t new_length = 0;
5823 uint8_t *new_ptr = NULL;
5824 tSirUpdateIE *update_ie;
5825
5826 if (msg_buf == NULL) {
5827 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5828 return;
5829 }
5830 update_ie = &update_add_ies->updateIE;
5831 /* incoming message has smeSession, use BSSID to find PE session */
5832 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005833 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005834
5835 if (NULL == session_entry) {
5836 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5837 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005838 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005839 goto end;
5840 }
5841 addn_ie = &session_entry->addIeParams;
5842 /* if len is 0, upper layer requested freeing of buffer */
5843 if (0 == update_ie->ieBufferlength) {
5844 switch (update_add_ies->updateType) {
5845 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305846 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847 addn_ie->probeRespData_buff = NULL;
5848 addn_ie->probeRespDataLen = 0;
5849 break;
5850 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305851 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 addn_ie->assocRespData_buff = NULL;
5853 addn_ie->assocRespDataLen = 0;
5854 break;
5855 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305856 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857 addn_ie->probeRespBCNData_buff = NULL;
5858 addn_ie->probeRespBCNDataLen = 0;
5859
5860 if (update_ie->notify)
5861 lim_handle_param_update(mac_ctx,
5862 update_add_ies->updateType);
5863 break;
5864 default:
5865 break;
5866 }
5867 return;
5868 }
5869 switch (update_add_ies->updateType) {
5870 case eUPDATE_IE_PROBE_RESP:
5871 if (update_ie->append) {
5872 /*
5873 * In case of append, allocate new memory
5874 * with combined length
5875 */
5876 new_length = update_ie->ieBufferlength +
5877 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305878 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879 if (NULL == new_ptr) {
5880 lim_log(mac_ctx, LOGE, FL(
5881 "Memory allocation failed."));
5882 goto end;
5883 }
5884 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305885 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005886 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305887 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888 update_ie->pAdditionIEBuffer,
5889 update_ie->ieBufferlength);
5890 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305891 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005892 /* adjust length accordingly */
5893 addn_ie->probeRespDataLen = new_length;
5894 /* save refernece of local buffer in PE session */
5895 addn_ie->probeRespData_buff = new_ptr;
5896 goto end;
5897 }
5898 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5899 &addn_ie->probeRespDataLen,
5900 update_ie->pAdditionIEBuffer,
5901 update_ie->ieBufferlength);
5902 break;
5903 case eUPDATE_IE_ASSOC_RESP:
5904 /* assoc resp IE */
5905 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5906 &addn_ie->assocRespDataLen,
5907 update_ie->pAdditionIEBuffer,
5908 update_ie->ieBufferlength);
5909 break;
5910 case eUPDATE_IE_PROBE_BCN:
5911 /* probe resp Bcn IE */
5912 lim_update_add_ie_buffer(mac_ctx,
5913 &addn_ie->probeRespBCNData_buff,
5914 &addn_ie->probeRespBCNDataLen,
5915 update_ie->pAdditionIEBuffer,
5916 update_ie->ieBufferlength);
5917 if (update_ie->notify)
5918 lim_handle_param_update(mac_ctx,
5919 update_add_ies->updateType);
5920 break;
5921 default:
5922 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5923 update_add_ies->updateType);
5924 break;
5925 }
5926end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305927 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928 update_ie->pAdditionIEBuffer = NULL;
5929}
5930
5931/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305932 * send_extended_chan_switch_action_frame()- function to send ECSA
5933 * action frame for each sta connected to SAP/GO and AP in case of
5934 * STA .
5935 * @mac_ctx: pointer to global mac structure
5936 * @new_channel: new channel to switch to.
5937 * @ch_bandwidth: BW of channel to calculate op_class
5938 * @session_entry: pe session
5939 *
5940 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5941 *
5942 * Return: void
5943 */
5944
5945static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5946 uint16_t new_channel, uint8_t ch_bandwidth,
5947 tpPESession session_entry)
5948{
5949 uint16_t op_class;
5950 uint8_t switch_mode = 0, i;
5951 tpDphHashNode psta;
5952
5953
Amar Singhal22995112016-01-22 10:42:33 -08005954 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305955 mac_ctx->scan.countryCodeCurrent,
5956 new_channel,
5957 ch_bandwidth);
5958
5959 if (LIM_IS_AP_ROLE(session_entry) &&
5960 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5961 switch_mode = 1;
5962
5963 if (LIM_IS_AP_ROLE(session_entry)) {
5964 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5965 psta =
5966 session_entry->dph.dphHashTable.pDphNodeArray + i;
5967 if (psta && psta->added)
5968 lim_send_extended_chan_switch_action_frame(
5969 mac_ctx,
5970 psta->staAddr,
5971 switch_mode, op_class, new_channel,
5972 LIM_MAX_CSA_IE_UPDATES, session_entry);
5973 }
5974 } else if (LIM_IS_STA_ROLE(session_entry)) {
5975 lim_send_extended_chan_switch_action_frame(mac_ctx,
5976 session_entry->bssId,
5977 switch_mode, op_class, new_channel,
5978 LIM_MAX_CSA_IE_UPDATES, session_entry);
5979 }
5980
5981}
5982
5983/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5985 *
5986 * @mac_ctx: Pointer to Global MAC structure
5987 * @msg_buf: pointer to the SME message buffer
5988 *
5989 * This function processes SME request messages from HDD or upper layer
5990 * application.
5991 *
5992 * Return: None
5993 */
5994static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5995 uint32_t *msg_buf)
5996{
5997 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5998 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 uint8_t session_id;
6000 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006001 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006002
6003 if (msg_buf == NULL) {
6004 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6005 return;
6006 }
6007
6008 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6009 session_entry = pe_find_session_by_bssid(mac_ctx,
6010 dfs_csa_ie_req->bssid, &session_id);
6011 if (session_entry == NULL) {
6012 lim_log(mac_ctx, LOGE, FL(
6013 "Session not found for given BSSID" MAC_ADDRESS_STR),
6014 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6015 return;
6016 }
6017
6018 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6019 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6020 GET_LIM_SYSTEM_ROLE(session_entry));
6021 return;
6022 }
6023
6024 /* target channel */
6025 session_entry->gLimChannelSwitch.primaryChannel =
6026 dfs_csa_ie_req->targetChannel;
6027
6028 /* Channel switch announcement needs to be included in beacon */
6029 session_entry->dfsIncludeChanSwIe = true;
6030 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6031 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006032 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306033 session_entry->gLimChannelSwitch.sec_ch_offset =
6034 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6036 session_entry->gLimChannelSwitch.switchMode = 1;
6037
6038 /*
6039 * Validate if SAP is operating HT or VHT mode and set the Channel
6040 * Switch Wrapper element with the Wide Band Switch subelement.
6041 */
6042 if (true != session_entry->vhtCapability)
6043 goto skip_vht;
6044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 /* Now encode the Wider Ch BW element depending on the ch width */
6046 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006047 switch (dfs_csa_ie_req->ch_params.ch_width) {
6048 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006049 /*
6050 * Wide channel BW sublement in channel wrapper element is not
6051 * required in case of 20 Mhz operation. Currently It is set
6052 * only set in case of 40/80 Mhz Operation.
6053 */
6054 session_entry->dfsIncludeChanWrapperIe = false;
6055 wider_bw_ch_switch->newChanWidth =
6056 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6057 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006058 case CH_WIDTH_40MHZ:
6059 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 wider_bw_ch_switch->newChanWidth =
6061 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6062 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006063 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006064 session_entry->dfsIncludeChanWrapperIe = true;
6065 wider_bw_ch_switch->newChanWidth =
6066 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6067 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006068 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069 session_entry->dfsIncludeChanWrapperIe = true;
6070 wider_bw_ch_switch->newChanWidth =
6071 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6072 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006073 case CH_WIDTH_80P80MHZ:
6074 session_entry->dfsIncludeChanWrapperIe = true;
6075 wider_bw_ch_switch->newChanWidth =
6076 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006077 /*
6078 * This is not applicable for 20/40/80 Mhz.
6079 * Only used when we support 80+80 Mhz operation.
6080 * In case of 80+80 Mhz, this parameter indicates
6081 * center channel frequency index of 80 Mhz channel of
6082 * frequency segment 1.
6083 */
6084 wider_bw_ch_switch->newCenterChanFreq1 =
6085 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006086 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006087 default:
6088 session_entry->dfsIncludeChanWrapperIe = false;
6089 /*
6090 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6091 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6092 */
6093 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6094 break;
6095 }
6096 /* Fetch the center channel based on the channel width */
6097 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006098 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099skip_vht:
6100 /* Send CSA IE request from here */
6101 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6102 eSIR_SUCCESS) {
6103 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6104 return;
6105 }
6106
6107 /*
6108 * First beacon update request is sent here, the remaining updates are
6109 * done when the FW responds back after sending the first beacon after
6110 * the template update
6111 */
6112 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306113
6114 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6115 ch_offset = BW80;
6116 else
6117 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6118
6119 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6120 session_entry->gLimChannelSwitch.switchCount,
6121 session_entry->gLimChannelSwitch.primaryChannel,
6122 session_entry->gLimChannelSwitch.ch_width,
6123 session_entry->dfsIncludeChanWrapperIe,
6124 ch_offset);
6125
Abhishek Singh518323d2015-10-19 17:42:01 +05306126 /* Send ECSA Action frame after updating the beacon */
6127 send_extended_chan_switch_action_frame(mac_ctx,
6128 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306129 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006130 session_entry->gLimChannelSwitch.switchCount--;
6131}
6132
6133/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306134 * lim_process_ext_change_channel()- function to send ECSA
6135 * action frame for STA/CLI .
6136 * @mac_ctx: pointer to global mac structure
6137 * @msg: params from sme for new channel.
6138 *
6139 * This function is called to send ECSA frame for STA/CLI.
6140 *
6141 * Return: void
6142 */
6143
6144static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6145 uint32_t *msg)
6146{
6147 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6148 (struct sir_sme_ext_cng_chan_req *) msg;
6149 tpPESession session_entry = NULL;
6150
6151 if (NULL == msg) {
6152 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6153 return;
6154 }
6155 session_entry =
6156 pe_find_session_by_sme_session_id(mac_ctx,
6157 ext_chng_channel->session_id);
6158 if (NULL == session_entry) {
6159 lim_log(mac_ctx, LOGE,
6160 FL("Session not found for given session %d"),
6161 ext_chng_channel->session_id);
6162 return;
6163 }
6164 if (LIM_IS_AP_ROLE(session_entry)) {
6165 lim_log(mac_ctx, LOGE,
6166 FL("not an STA/CLI session"));
6167 return;
6168 }
6169 send_extended_chan_switch_action_frame(mac_ctx,
6170 ext_chng_channel->new_channel,
6171 0, session_entry);
6172}
6173
6174/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175 * lim_process_nss_update_request() - process sme nss update req
6176 *
6177 * @mac_ctx: Pointer to Global MAC structure
6178 * @msg_buf: pointer to the SME message buffer
6179 *
6180 * This function processes SME request messages from HDD or upper layer
6181 * application.
6182 *
6183 * Return: None
6184 */
6185static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6186 uint32_t *msg_buf)
6187{
6188 struct sir_nss_update_request *nss_update_req_ptr;
6189 tpPESession session_entry = NULL;
6190
6191 if (msg_buf == NULL) {
6192 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6193 return;
6194 }
6195
6196 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306197 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198 nss_update_req_ptr->vdev_id);
6199 if (session_entry == NULL) {
6200 lim_log(mac_ctx, LOGE, FL(
6201 "Session not found for given session_id %d"),
6202 nss_update_req_ptr->vdev_id);
6203 return;
6204 }
6205
6206 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6207 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6208 GET_LIM_SYSTEM_ROLE(session_entry));
6209 return;
6210 }
6211
6212 /* populate nss field in the beacon */
6213 session_entry->gLimOperatingMode.present = 1;
6214 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6215 /* Send nss update request from here */
6216 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6217 eSIR_SUCCESS) {
6218 lim_log(mac_ctx, LOGE,
6219 FL("Unable to set op mode IE in beacon"));
6220 return;
6221 }
6222
6223 lim_send_beacon_ind(mac_ctx, session_entry);
6224}
6225
6226/**
6227 * lim_process_set_ie_req() - process sme set IE request
6228 *
6229 * @mac_ctx: Pointer to Global MAC structure
6230 * @msg_buf: pointer to the SME message buffer
6231 *
6232 * This function processes SME request messages from HDD or upper layer
6233 * application.
6234 *
6235 * Return: None
6236 */
6237static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6238{
6239 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306240 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006241
6242 if (msg_buf == NULL) {
6243 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6244 return;
6245 }
6246
6247 msg = (struct send_extcap_ie *)msg_buf;
6248 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306249 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006250 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6251
6252}