blob: 9de78d54f1de64ba222ccb802fe588d7cd2e933d [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002 * Copyright (c) 2012-2018 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_send_sme_rspMessages.cc contains the functions
30 * for sending SME response/notification messages to applications
31 * above MAC software.
32 * Author: Chandra Modumudi
33 * Date: 02/13/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38
Anurag Chouhan6d760662016-02-20 16:05:43 +053039#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include "wni_api.h"
41#include "sir_common.h"
42#include "ani_global.h"
43
44#include "wni_cfg.h"
45#include "sys_def.h"
46#include "cfg_api.h"
47
48#include "sch_api.h"
49#include "utils_api.h"
50#include "lim_utils.h"
51#include "lim_security_utils.h"
52#include "lim_ser_des_utils.h"
53#include "lim_send_sme_rsp_messages.h"
54#include "lim_ibss_peer_mgmt.h"
55#include "lim_session_utils.h"
56#include "lim_types.h"
57#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070058#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053059#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070060#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070061#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070062#include "wlan_reg_services_api.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070063#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070065#include "wlan_tdls_tgt_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053066#include "lim_process_fils.h"
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -080067#include "wma.h"
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
70 tpPESession session_entry, tSirResultCodes result_code,
71 tpSirSmeJoinRsp sme_join_rsp);
72
73/**
74 * lim_send_sme_rsp() - Send Response to upper layers
75 * @mac_ctx: Pointer to Global MAC structure
76 * @msg_type: Indicates message type
77 * @result_code: Indicates the result of previously issued
78 * eWNI_SME_msg_type_REQ message
79 *
80 * This function is called by lim_process_sme_req_messages() to send
81 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
82 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
83 * Software.
84 *
85 * Return: None
86 */
87
88void
89lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
90 tSirResultCodes result_code, uint8_t sme_session_id,
91 uint16_t sme_transaction_id)
92{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070093 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094 tSirSmeRsp *sme_rsp;
95
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053096 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097 lim_msg_str(msg_type), lim_result_code_str(result_code));
98
Anurag Chouhan600c3a02016-03-01 10:33:54 +053099 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100 if (NULL == sme_rsp) {
101 /* Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530102 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 return;
104 }
105
106 sme_rsp->messageType = msg_type;
107 sme_rsp->length = sizeof(tSirSmeRsp);
108 sme_rsp->statusCode = result_code;
109
110 sme_rsp->sessionId = sme_session_id;
111 sme_rsp->transactionId = sme_transaction_id;
112
113 msg.type = msg_type;
114 msg.bodyptr = sme_rsp;
115 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530116 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
117 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118
119#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
120 switch (msg_type) {
121 case eWNI_SME_STOP_BSS_RSP:
122 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
123 NULL, (uint16_t) result_code, 0);
124 break;
125 }
126#endif /* FEATURE_WLAN_DIAG_SUPPORT */
127 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
128}
129
130
131
132/**
133 * lim_send_sme_roc_rsp() - Send Response to SME
134 * @mac_ctx: Pointer to Global MAC structure
135 * @status: Resume link status
136 * @result_code: Result of the ROC request
137 * @sme_session_id: SME sesson Id
138 * @scan_id: Scan Identifier
139 *
140 * This function is called to send ROC rsp
141 * message to SME.
142 *
143 * Return: None
144 */
145void
146lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
147 tSirResultCodes result_code, uint8_t sme_session_id,
148 uint32_t scan_id)
149{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700150 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 struct sir_roc_rsp *sme_rsp;
152
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530153 pe_debug("Sending message: %s with reasonCode: %s scanId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 lim_msg_str(msg_type), lim_result_code_str(result_code),
155 scan_id);
156
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530157 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 if (NULL == sme_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530159 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 return;
161 }
162
163 sme_rsp->message_type = msg_type;
164 sme_rsp->length = sizeof(struct sir_roc_rsp);
165 sme_rsp->status = result_code;
166
167 sme_rsp->session_id = sme_session_id;
168 sme_rsp->scan_id = scan_id;
169
170 msg.type = msg_type;
171 msg.bodyptr = sme_rsp;
172 msg.bodyval = 0;
173 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
174 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
175}
176
177
178/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530179 * lim_get_max_rate_flags() - Get rate flags
180 * @mac_ctx: Pointer to global MAC structure
181 * @sta_ds: Pointer to station ds structure
182 *
183 * This function is called to get the rate flags for a connection
184 * from the station ds structure depending on the ht and the vht
185 * channel width supported.
186 *
187 * Return: Returns the populated rate_flags
188 */
189uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
190{
191 uint32_t rate_flags = 0;
192
193 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530194 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530195 return rate_flags;
196 }
197
198 if (!sta_ds->mlmStaContext.htCapability &&
199 !sta_ds->mlmStaContext.vhtCapability) {
200 rate_flags |= eHAL_TX_RATE_LEGACY;
201 } else {
202 if (sta_ds->mlmStaContext.vhtCapability) {
203 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
204 sta_ds->vhtSupportedChannelWidthSet) {
205 rate_flags |= eHAL_TX_RATE_VHT80;
206 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
207 sta_ds->vhtSupportedChannelWidthSet) {
208 if (sta_ds->htSupportedChannelWidthSet)
209 rate_flags |= eHAL_TX_RATE_VHT40;
210 else
211 rate_flags |= eHAL_TX_RATE_VHT20;
212 }
213 } else if (sta_ds->mlmStaContext.htCapability) {
214 if (sta_ds->htSupportedChannelWidthSet)
215 rate_flags |= eHAL_TX_RATE_HT40;
216 else
217 rate_flags |= eHAL_TX_RATE_HT20;
218 }
219 }
220
221 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
222 rate_flags |= eHAL_TX_RATE_SGI;
223
224 return rate_flags;
225}
226
227/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
229 * @mac_ctx Pointer to Global MAC structure
230 * @status Resume link status
231 * @ctx context passed while calling resmune link.
232 * (join response to be sent)
233 *
234 * This function is called to send Join/Reassoc rsp
235 * message to SME after the resume link.
236 *
237 * Return: None
238 */
239static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530240 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700242 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
244
245 msg.type = sme_join_rsp->messageType;
246 msg.bodyptr = sme_join_rsp;
247 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530248 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
250}
251
252/**
253 * lim_handle_join_rsp_status() - Handle the response.
254 * @mac_ctx: Pointer to Global MAC structure
255 * @session_entry: PE Session Info
256 * @result_code: Indicates the result of previously issued
257 * eWNI_SME_msgType_REQ message
258 * @sme_join_rsp The received response.
259 *
260 * This function will handle both the success and failure status
261 * of the received response.
262 *
263 * Return: None
264 */
265static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
266 tpPESession session_entry, tSirResultCodes result_code,
267 tpSirSmeJoinRsp sme_join_rsp)
268{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700269 uint16_t bss_ie_len;
270 void *bss_ies;
271 bool is_vendor_ap_1_present;
Wu Gao2968fc92017-06-19 19:18:34 +0800272 tpSirSmeJoinReq join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700273
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
275 tSirSmeHTProfile *ht_profile;
276#endif
277 if (result_code == eSIR_SME_SUCCESS) {
278 if (session_entry->beacon != NULL) {
279 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530280 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 session_entry->beacon,
282 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530283 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530285 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530286 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530287 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 }
289 if (session_entry->assocReq != NULL) {
290 sme_join_rsp->assocReqLength =
291 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530292 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530293 sme_join_rsp->beaconLength,
294 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530296 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530298 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530299 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530300 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301 }
302 if (session_entry->assocRsp != NULL) {
303 sme_join_rsp->assocRspLength =
304 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530305 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530306 sme_join_rsp->beaconLength +
307 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 session_entry->assocRsp,
309 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530310 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530312 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314 if (session_entry->ricData != NULL) {
315 sme_join_rsp->parsedRicRspLen =
316 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530317 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530318 sme_join_rsp->beaconLength +
319 sme_join_rsp->assocReqLength +
320 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321 session_entry->ricData,
322 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530323 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800324 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530325 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530326 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327 sme_join_rsp->parsedRicRspLen);
328 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329#ifdef FEATURE_WLAN_ESE
330 if (session_entry->tspecIes != NULL) {
331 sme_join_rsp->tspecIeLen =
332 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530333 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530334 sme_join_rsp->beaconLength +
335 sme_join_rsp->assocReqLength +
336 sme_join_rsp->assocRspLength +
337 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 session_entry->tspecIes,
339 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530340 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530342 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530343 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530344 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 }
346#endif
347 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530348 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530349 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350 sme_join_rsp->vht_channel_width =
351 session_entry->ch_width;
352#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
353 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530354 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 ht_profile = &sme_join_rsp->HTProfile;
356 ht_profile->htSupportedChannelWidthSet =
357 session_entry->htSupportedChannelWidthSet;
358 ht_profile->htRecommendedTxWidthSet =
359 session_entry->htRecommendedTxWidthSet;
360 ht_profile->htSecondaryChannelOffset =
361 session_entry->htSecondaryChannelOffset;
362 ht_profile->dot11mode = session_entry->dot11mode;
363 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 ht_profile->vhtCapability =
365 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
367 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800368 }
369#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700370 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800371 session_entry->pLimJoinReq,
372 session_entry->pLimReAssocReq);
373
374 if (session_entry->pLimJoinReq)
375 join_reassoc_req = session_entry->pLimJoinReq;
376
377 if (session_entry->pLimReAssocReq)
378 join_reassoc_req = session_entry->pLimReAssocReq;
379
380 if (!join_reassoc_req) {
381 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
382 return;
383 }
384
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700385 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800386 &join_reassoc_req->bssDescription);
387 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700388 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700389 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
390 bss_ies, bss_ie_len) != NULL);
391
392 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700393 is_vendor_ap_1_present && (session_entry->nss == 2) &&
394 (mac_ctx->lteCoexAntShare == 0 ||
395 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700396 /* SET vdev param */
397 pe_debug("sending SMPS intolrent vdev_param");
398 wma_cli_set_command(session_entry->smeSessionId,
399 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
400 1, VDEV_CMD);
401
402 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403 } else {
404 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530405 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530407 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 }
409 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530410 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530412 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800413 }
414 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530415 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530417 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800419 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530420 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530422 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424#ifdef FEATURE_WLAN_ESE
425 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530426 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530428 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 }
430#endif
431 }
432}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530433
434/**
435 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530436 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530437 * @sme_join_rsp: Join response buffer to be filled up
438 *
439 * Return: None
440 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700441static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530442{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530443 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
444
445 if (parsed_ies->hs20vendor_ie.present)
446 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
447 if (parsed_ies->vht_caps.present)
448 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
449 if (parsed_ies->ht_caps.present)
450 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
451 if (parsed_ies->ht_operation.present)
452 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
453 if (parsed_ies->vht_operation.present)
454 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530455}
456
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530457#ifdef WLAN_FEATURE_FILS_SK
458static void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
459 tpPESession session_entry)
460{
461 sme_join_rsp->fils_seq_num =
462 session_entry->fils_info->sequence_number;
463}
464#else
465static inline void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
466 tpPESession session_entry)
467{}
468#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469/**
470 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
471 * @mac_ctx: Pointer to Global MAC structure
472 * @msg_type: Indicates message type
473 * @result_code: Indicates the result of previously issued
474 * eWNI_SME_msgType_REQ message
475 * @prot_status_code: Protocol Status Code
476 * @session_entry: PE Session Info
477 * @sme_session_id: SME Session ID
478 * @sme_transaction_id: SME Transaction ID
479 *
480 * This function is called by lim_process_sme_req_messages() to send
481 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
482 * above MAC Software.
483 *
484 * Return: None
485 */
486
487void
488lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
489 tSirResultCodes result_code, uint16_t prot_status_code,
490 tpPESession session_entry, uint8_t sme_session_id,
491 uint16_t sme_transaction_id)
492{
493 tpSirSmeJoinRsp sme_join_rsp;
494 uint32_t rsp_len;
495 tpDphHashNode sta_ds = NULL;
496#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
497 if (msg_type == eWNI_SME_REASSOC_RSP)
498 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
499 session_entry, (uint16_t) result_code, 0);
500 else
501 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
502 session_entry, (uint16_t) result_code, 0);
503#endif /* FEATURE_WLAN_DIAG_SUPPORT */
504
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530505 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 lim_msg_str(msg_type), lim_result_code_str(result_code));
507
508 if (session_entry == NULL) {
509 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530510 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530512 pe_err("Mem Alloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513 return;
514 }
515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 sme_join_rsp->beaconLength = 0;
517 sme_join_rsp->assocReqLength = 0;
518 sme_join_rsp->assocRspLength = 0;
519 } else {
520 rsp_len = session_entry->assocReqLen +
521 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523#ifdef FEATURE_WLAN_ESE
524 session_entry->tspecLen +
525#endif
526 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530527 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530529 pe_err("MemAlloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 return;
531 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530532
533 if (lim_is_fils_connection(session_entry)) {
534 sme_join_rsp->is_fils_connection = true;
535 lim_update_fils_seq_num(sme_join_rsp,
536 session_entry);
537 }
538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539 if (result_code == eSIR_SME_SUCCESS) {
540 sta_ds = dph_get_hash_entry(mac_ctx,
541 DPH_STA_HASH_INDEX_PEER,
542 &session_entry->dph.dphHashTable);
543 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530544 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 } else {
546 /* Pass the peer's staId */
547 sme_join_rsp->staId = sta_ds->staIndex;
548 sme_join_rsp->ucastSig =
549 sta_ds->ucUcastSig;
550 sme_join_rsp->bcastSig =
551 sta_ds->ucBcastSig;
552 sme_join_rsp->timingMeasCap =
553 sta_ds->timingMeasCap;
554#ifdef FEATURE_WLAN_TDLS
555 sme_join_rsp->tdls_prohibited =
556 session_entry->tdls_prohibited;
557 sme_join_rsp->tdls_chan_swit_prohibited =
558 session_entry->tdls_chan_swit_prohibited;
559#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530560 sme_join_rsp->nss = sta_ds->nss;
561 sme_join_rsp->max_rate_flags =
562 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530563 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530564
565 /* Copy FILS params only for Successful join */
566 populate_fils_connect_params(mac_ctx,
567 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 }
569 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530570
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 sme_join_rsp->beaconLength = 0;
572 sme_join_rsp->assocReqLength = 0;
573 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575#ifdef FEATURE_WLAN_ESE
576 sme_join_rsp->tspecIeLen = 0;
577#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
579 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800580
581 /* Send supported NSS 1x1 to SME */
582 sme_join_rsp->supported_nss_1x1 =
583 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530584 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800585 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 }
587
588 sme_join_rsp->messageType = msg_type;
589 sme_join_rsp->length = (uint16_t) rsp_len;
590 sme_join_rsp->statusCode = result_code;
591 sme_join_rsp->protStatusCode = prot_status_code;
592
593 sme_join_rsp->sessionId = sme_session_id;
594 sme_join_rsp->transactionId = sme_transaction_id;
595
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530596 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 (uint32_t *)sme_join_rsp);
598}
599
600/**
601 * lim_send_sme_start_bss_rsp()
602 *
603 ***FUNCTION:
604 * This function is called to send eWNI_SME_START_BSS_RSP
605 * message to applications above MAC Software.
606 *
607 ***PARAMS:
608 *
609 ***LOGIC:
610 *
611 ***ASSUMPTIONS:
612 * NA
613 *
614 ***NOTE:
615 * NA
616 *
617 * @param pMac Pointer to Global MAC structure
618 * @param msgType Indicates message type
619 * @param resultCode Indicates the result of previously issued
620 * eWNI_SME_msgType_REQ message
621 *
622 * @return None
623 */
624
625void
626lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
627 uint16_t msgType, tSirResultCodes resultCode,
628 tpPESession psessionEntry, uint8_t smesessionId,
629 uint16_t smetransactionId)
630{
631
632 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700633 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 tSirSmeStartBssRsp *pSirSmeRsp;
635 uint16_t ieLen;
636 uint16_t ieOffset, curLen;
637
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530638 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640
641 size = sizeof(tSirSmeStartBssRsp);
642
643 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530644 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 if (NULL == pSirSmeRsp) {
646 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530647 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 return;
649 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 } else {
651 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
652 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
653 ieLen = psessionEntry->schBeaconOffsetBegin
654 + psessionEntry->schBeaconOffsetEnd - ieOffset;
655 /* calculate the memory size to allocate */
656 size += ieLen;
657
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530658 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659 if (NULL == pSirSmeRsp) {
660 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530661 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662 return;
663 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664 size = sizeof(tSirSmeStartBssRsp);
665 if (resultCode == eSIR_SME_SUCCESS) {
666
667 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
668 psessionEntry->bssId);
669
670 /* Read beacon interval from session */
671 pSirSmeRsp->bssDescription.beaconInterval =
672 (uint16_t) psessionEntry->beaconParams.
673 beaconInterval;
674 pSirSmeRsp->bssType = psessionEntry->bssType;
675
676 if (cfg_get_capability_info
677 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
678 psessionEntry)
679 != eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530680 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681
682 lim_get_phy_mode(pMac,
683 (uint32_t *) &pSirSmeRsp->bssDescription.
684 nwType, psessionEntry);
685
686 pSirSmeRsp->bssDescription.channelId =
687 psessionEntry->currentOperChannel;
688
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700689 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530691 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 ieFields,
693 psessionEntry->pSchBeaconFrameBegin +
694 ieOffset, (uint32_t) curLen);
695
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530696 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 ieFields) + curLen,
698 psessionEntry->pSchBeaconFrameEnd,
699 (uint32_t) psessionEntry->
700 schBeaconOffsetEnd);
701
Abhishek Singh34a4d862016-10-26 16:01:51 +0530702 pSirSmeRsp->bssDescription.length = (uint16_t)
703 (offsetof(tSirBssDescription, ieFields[0])
704 - sizeof(pSirSmeRsp->bssDescription.length)
705 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706 /* This is the size of the message, subtracting the size of the pointer to ieFields */
707 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700708 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
710 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530711 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 pSirSmeRsp->HTProfile.
713 htSupportedChannelWidthSet =
714 psessionEntry->htSupportedChannelWidthSet;
715 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
716 psessionEntry->htRecommendedTxWidthSet;
717 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
718 psessionEntry->htSecondaryChannelOffset;
719 pSirSmeRsp->HTProfile.dot11mode =
720 psessionEntry->dot11mode;
721 pSirSmeRsp->HTProfile.htCapability =
722 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 pSirSmeRsp->HTProfile.vhtCapability =
724 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725 pSirSmeRsp->HTProfile.apCenterChan =
726 psessionEntry->ch_center_freq_seg0;
727 pSirSmeRsp->HTProfile.apChanWidth =
728 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 }
730#endif
731 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 pSirSmeRsp->messageType = msgType;
734 pSirSmeRsp->length = size;
735
736 /* Update SME session Id and transaction Id */
737 pSirSmeRsp->sessionId = smesessionId;
738 pSirSmeRsp->transactionId = smetransactionId;
739 pSirSmeRsp->statusCode = resultCode;
740 if (psessionEntry != NULL)
741 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
742
743 mmhMsg.type = msgType;
744 mmhMsg.bodyptr = pSirSmeRsp;
745 mmhMsg.bodyval = 0;
746 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530747 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
748 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530750 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
751 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 }
753#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
754 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
755 psessionEntry, (uint16_t) resultCode, 0);
756#endif /* FEATURE_WLAN_DIAG_SUPPORT */
757
758 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
759} /*** end lim_send_sme_start_bss_rsp() ***/
760
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761/**
762 * lim_send_sme_scan_rsp() - Send scan response to SME
763 * @pMac: Pointer to Global MAC structure
764 * @length: Indicates length of message
765 * @resultCode: Indicates the result of previously issued
766 * eWNI_SME_SCAN_REQ message
767 * @scan_id: scan identifier
768 *
769 * This function is called by lim_process_sme_req_messages() to send
770 * eWNI_SME_SCAN_RSP message to applications above MAC
771 *
772 * return: None
773 */
774
775void
776lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
777 uint8_t smesessionId, uint16_t smetranscationId,
778 uint32_t scan_id)
779{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
781 smetranscationId, scan_id);
782}
783
784/**
785 * lim_post_sme_scan_rsp_message()
786 *
787 ***FUNCTION:
788 * This function is called by lim_send_sme_scan_rsp() to send
789 * eWNI_SME_SCAN_RSP message with failed result code
790 *
791 ***NOTE:
792 * NA
793 *
794 * @param pMac Pointer to Global MAC structure
795 * @param length Indicates length of message
796 * @param resultCode failed result code
797 *
798 * @return None
799 */
800
801void
802lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
803 tSirResultCodes resultCode, uint8_t smesessionId,
804 uint16_t smetransactionId,
805 uint32_t scan_id)
806{
807 tpSirSmeScanRsp pSirSmeScanRsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700808 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530810 pe_debug("send SME_SCAN_RSP reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811 lim_result_code_str(resultCode));
812
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530813 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 if (NULL == pSirSmeScanRsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530815 pe_err("AllocateMemory failed for eWNI_SME_SCAN_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 return;
817 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818
819 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
820 pSirSmeScanRsp->statusCode = resultCode;
821
822 /*Update SME session Id and transaction Id */
823 pSirSmeScanRsp->sessionId = smesessionId;
824 pSirSmeScanRsp->transcationId = smetransactionId;
825 pSirSmeScanRsp->scan_id = scan_id;
826
827 mmhMsg.type = eWNI_SME_SCAN_RSP;
828 mmhMsg.bodyptr = pSirSmeScanRsp;
829 mmhMsg.bodyval = 0;
830
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530831 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
833 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
834 (uint16_t) resultCode, 0);
835#endif /* FEATURE_WLAN_DIAG_SUPPORT */
836
837 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
838 return;
839
840} /*** lim_post_sme_scan_rsp_message ***/
841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530843 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700845 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800846 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
848 mmhMsg.type = pMsg->type;
849 mmhMsg.bodyptr = pMsg;
850 mmhMsg.bodyval = 0;
851
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530852 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853
854 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
855}
856
857/**
858 * lim_send_sme_disassoc_ntf()
859 *
860 ***FUNCTION:
861 * This function is called by limProcessSmeMessages() to send
862 * eWNI_SME_DISASSOC_RSP/IND message to host
863 *
864 ***PARAMS:
865 *
866 ***LOGIC:
867 *
868 ***ASSUMPTIONS:
869 * NA
870 *
871 ***NOTE:
872 * This function is used for sending eWNI_SME_DISASSOC_CNF,
873 * or eWNI_SME_DISASSOC_IND to host depending on
874 * disassociation trigger.
875 *
876 * @param peerMacAddr Indicates the peer MAC addr to which
877 * disassociate was initiated
878 * @param reasonCode Indicates the reason for Disassociation
879 * @param disassocTrigger Indicates the trigger for Disassociation
880 * @param aid Indicates the STAID. This parameter is
881 * present only on AP.
882 *
883 * @return None
884 */
885void
886lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
887 tSirMacAddr peerMacAddr,
888 tSirResultCodes reasonCode,
889 uint16_t disassocTrigger,
890 uint16_t aid,
891 uint8_t smesessionId,
892 uint16_t smetransactionId, tpPESession psessionEntry)
893{
894
895 uint8_t *pBuf;
896 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
897 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700898 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700900 tpPESession session = NULL;
901 uint16_t i, assoc_id;
902 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530903 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530905 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 disassocTrigger, reasonCode);
907
908 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700909 case eLIM_DUPLICATE_ENTRY:
910 /*
911 * Duplicate entry is removed at LIM.
912 * Initiate new entry for other session
913 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530914 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700915 MAC_ADDR_ARRAY(peerMacAddr));
916
917 for (i = 0; i < pMac->lim.maxBssId; i++) {
918 if ((&pMac->lim.gpSession[i] != NULL) &&
919 (pMac->lim.gpSession[i].valid) &&
920 (pMac->lim.gpSession[i].pePersona ==
921 QDF_SAP_MODE)) {
922 /* Find the sta ds entry in another session */
923 session = &pMac->lim.gpSession[i];
924 sta_ds = dph_lookup_hash_entry(pMac,
925 peerMacAddr, &assoc_id,
926 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530927 if (sta_ds)
928 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700929 }
930 }
931 if (sta_ds
932#ifdef WLAN_FEATURE_11W
933 && (!sta_ds->rmfEnabled)
934#endif
935 ) {
936 if (lim_add_sta(pMac, sta_ds, false, session) !=
937 eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530938 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700939 sta_ds->assocId);
940 }
941 failure = true;
942 break;
943
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 case eLIM_HOST_DISASSOC:
945 /**
946 * Disassociation response due to
947 * host triggered disassociation
948 */
949
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530950 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951 if (NULL == pSirSmeDisassocRsp) {
952 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530953 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954 failure = true;
955 goto error;
956 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530957 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
959 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
960 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
961 /* sessionId */
962 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
963 *pBuf = smesessionId;
964 pBuf++;
965
966 /* transactionId */
967 lim_copy_u16(pBuf, smetransactionId);
968 pBuf += sizeof(uint16_t);
969
970 /* statusCode */
971 lim_copy_u32(pBuf, reasonCode);
972 pBuf += sizeof(tSirResultCodes);
973
974 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530975 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976 pBuf += sizeof(tSirMacAddr);
977
978 /* Clear Station Stats */
979 /* for sta, it is always 1, IBSS is handled at halInitSta */
980
981#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
982
983 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
984 psessionEntry, (uint16_t) reasonCode, 0);
985#endif
986 pMsg = (uint32_t *) pSirSmeDisassocRsp;
987 break;
988
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530989 case eLIM_PEER_ENTITY_DISASSOC:
990 case eLIM_LINK_MONITORING_DISASSOC:
991 sir_sme_dis_ind =
992 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
993 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530994 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530995 return;
996 }
997
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530998 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530999 reasonCode);
1000
1001 sir_sme_dis_ind->message_type =
1002 eWNI_SME_DISCONNECT_DONE_IND;
1003 sir_sme_dis_ind->length =
1004 sizeof(*sir_sme_dis_ind);
1005 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1006 sizeof(tSirMacAddr));
1007 sir_sme_dis_ind->session_id = smesessionId;
1008 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301009 /*
1010 * Instead of sending deauth reason code as 505 which is
1011 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1012 * Send reason code as zero to Supplicant
1013 */
1014 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1015 sir_sme_dis_ind->reason_code = 0;
1016 else
1017 sir_sme_dis_ind->reason_code = reasonCode;
1018
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301019 pMsg = (uint32_t *)sir_sme_dis_ind;
1020
1021 break;
1022
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 default:
1024 /**
1025 * Disassociation indication due to Disassociation
1026 * frame reception from peer entity or due to
1027 * loss of link with peer entity.
1028 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301029 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 if (NULL == pSirSmeDisassocInd) {
1031 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301032 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 failure = true;
1034 goto error;
1035 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301036 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1038 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1039 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1040
1041 /* Update SME session Id and Transaction Id */
1042 pSirSmeDisassocInd->sessionId = smesessionId;
1043 pSirSmeDisassocInd->transactionId = smetransactionId;
1044 pSirSmeDisassocInd->reasonCode = reasonCode;
1045 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1046
1047 lim_copy_u32(pBuf, reasonCode);
1048 pBuf += sizeof(tSirResultCodes);
1049
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301050 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 pBuf += sizeof(tSirMacAddr);
1052
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301053 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054
1055#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1056 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1057 psessionEntry, (uint16_t) reasonCode, 0);
1058#endif
1059 pMsg = (uint32_t *) pSirSmeDisassocInd;
1060
1061 break;
1062 }
1063
1064error:
1065 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001066 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068
1069 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301070 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 (uint32_t *) pMsg);
1072} /*** end lim_send_sme_disassoc_ntf() ***/
1073
1074/** -----------------------------------------------------------------
1075 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1076
1077 After receiving disassociation frame from peer entity, this
1078 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1079 reason code.
1080
1081 \param pMac - global mac structure
1082 \param pStaDs - station dph hash node
1083 \return none
1084 \sa
1085 ----------------------------------------------------------------- */
1086void
1087lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1088 tpPESession psessionEntry)
1089{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001090 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 tSirSmeDisassocInd *pSirSmeDisassocInd;
1092
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301093 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301095 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 return;
1097 }
1098
1099 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1100 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1101
1102 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1103 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301104 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1106
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301107 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301108 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301110 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301111 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112
1113 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1114
1115 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1116 mmhMsg.bodyptr = pSirSmeDisassocInd;
1117 mmhMsg.bodyval = 0;
1118
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301119 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1120 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1122 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1123 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1124#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1125
1126 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1127
1128} /*** end lim_send_sme_disassoc_ind() ***/
1129
1130/** -----------------------------------------------------------------
1131 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1132
1133 After receiving deauthentication frame from peer entity, this
1134 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1135 reason code.
1136
1137 \param pMac - global mac structure
1138 \param pStaDs - station dph hash node
1139 \return none
1140 \sa
1141 ----------------------------------------------------------------- */
1142void
1143lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1144 tpPESession psessionEntry)
1145{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001146 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 tSirSmeDeauthInd *pSirSmeDeauthInd;
1148
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301149 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301151 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 return;
1153 }
1154
1155 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1156 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1157
1158 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1159 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1160 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1161 pSirSmeDeauthInd->statusCode =
1162 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1163 } else {
1164 /* Need to indicatet he reascon code over the air */
1165 pSirSmeDeauthInd->statusCode =
1166 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1167 }
1168 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301169 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301170 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301172 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301173 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1175
1176 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001177 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1178 pStaDs->mlmStaContext.disassocReason)
1179 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180
1181 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1182 mmhMsg.bodyptr = pSirSmeDeauthInd;
1183 mmhMsg.bodyval = 0;
1184
1185 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1186#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1187 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1188 0, pStaDs->mlmStaContext.cleanupTrigger);
1189#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1190
1191 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1192 return;
1193} /*** end lim_send_sme_deauth_ind() ***/
1194
1195#ifdef FEATURE_WLAN_TDLS
1196/**
1197 * lim_send_sme_tdls_del_sta_ind()
1198 *
1199 ***FUNCTION:
1200 * This function is called to send the TDLS STA context deletion to SME.
1201 *
1202 ***LOGIC:
1203 *
1204 ***ASSUMPTIONS:
1205 *
1206 ***NOTE:
1207 * NA
1208 *
1209 * @param pMac - Pointer to global MAC structure
1210 * @param pStaDs - Pointer to internal STA Datastructure
1211 * @param psessionEntry - Pointer to the session entry
1212 * @param reasonCode - Reason for TDLS sta deletion
1213 * @return None
1214 */
1215void
1216lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1217 tpPESession psessionEntry, uint16_t reasonCode)
1218{
Frank Liud1a28462017-09-06 22:55:48 +08001219 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301221 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301222 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Frank Liud1a28462017-09-06 22:55:48 +08001223 info.vdev_id = psessionEntry->smeSessionId;
1224 qdf_mem_copy(info.peermac.bytes, pStaDs->staAddr, QDF_MAC_ADDR_SIZE);
1225 info.message_type = TDLS_PEER_DISCONNECTED;
1226 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227
Frank Liud1a28462017-09-06 22:55:48 +08001228 tgt_tdls_event_handler(pMac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230 return;
1231} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1232
1233/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 * lim_send_sme_mgmt_tx_completion()
1235 *
1236 ***FUNCTION:
1237 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1238 * message to SME.
1239 *
1240 ***LOGIC:
1241 *
1242 ***ASSUMPTIONS:
1243 *
1244 ***NOTE:
1245 * NA
1246 *
1247 * @param pMac - Pointer to global MAC structure
1248 * @param psessionEntry - Pointer to the session entry
1249 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1250 * @return None
1251 */
1252void
1253lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301254 uint32_t sme_session_id,
1255 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001257 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1259
1260 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301261 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301263 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 return;
1265 }
1266 /* messageType */
1267 pSirMgmtTxCompletionInd->messageType =
1268 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1269 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1270
1271 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301272 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273
1274 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1275
1276 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1277 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1278 mmhMsg.bodyval = 0;
1279
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001280 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1281 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1282 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1283 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1285
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286#endif /* FEATURE_WLAN_TDLS */
1287
1288/**
1289 * lim_send_sme_deauth_ntf()
1290 *
1291 ***FUNCTION:
1292 * This function is called by limProcessSmeMessages() to send
1293 * eWNI_SME_DISASSOC_RSP/IND message to host
1294 *
1295 ***PARAMS:
1296 *
1297 ***LOGIC:
1298 *
1299 ***ASSUMPTIONS:
1300 * NA
1301 *
1302 ***NOTE:
1303 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1304 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1305 *
1306 * @param peerMacAddr Indicates the peer MAC addr to which
1307 * deauthentication was initiated
1308 * @param reasonCode Indicates the reason for Deauthetication
1309 * @param deauthTrigger Indicates the trigger for Deauthetication
1310 * @param aid Indicates the STAID. This parameter is present
1311 * only on AP.
1312 *
1313 * @return None
1314 */
1315void
1316lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1317 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1318 uint16_t aid, uint8_t smesessionId,
1319 uint16_t smetransactionId)
1320{
1321 uint8_t *pBuf;
1322 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1323 tSirSmeDeauthInd *pSirSmeDeauthInd;
1324 tpPESession psessionEntry;
1325 uint8_t sessionId;
1326 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301327 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328
1329 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1330 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 case eLIM_HOST_DEAUTH:
1332 /**
1333 * Deauthentication response to host triggered
1334 * deauthentication.
1335 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301336 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 if (NULL == pSirSmeDeauthRsp) {
1338 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301339 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 return;
1341 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301342 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1344 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1345 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1346 pSirSmeDeauthRsp->statusCode = reasonCode;
1347 pSirSmeDeauthRsp->sessionId = smesessionId;
1348 pSirSmeDeauthRsp->transactionId = smetransactionId;
1349
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001350 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301351 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352
1353#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1354 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1355 psessionEntry, 0, (uint16_t) reasonCode);
1356#endif
1357 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1358
1359 break;
1360
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301361 case eLIM_PEER_ENTITY_DEAUTH:
1362 case eLIM_LINK_MONITORING_DEAUTH:
1363 sir_sme_dis_ind =
1364 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1365 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301366 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301367 return;
1368 }
1369
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301370 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301371 reasonCode);
1372
1373 sir_sme_dis_ind->message_type =
1374 eWNI_SME_DISCONNECT_DONE_IND;
1375 sir_sme_dis_ind->length =
1376 sizeof(*sir_sme_dis_ind);
1377 sir_sme_dis_ind->session_id = smesessionId;
1378 sir_sme_dis_ind->reason_code = reasonCode;
1379 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1380 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301381 /*
1382 * Instead of sending deauth reason code as 505 which is
1383 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1384 * Send reason code as zero to Supplicant
1385 */
1386 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1387 sir_sme_dis_ind->reason_code = 0;
1388 else
1389 sir_sme_dis_ind->reason_code = reasonCode;
1390
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301391 pMsg = (uint32_t *)sir_sme_dis_ind;
1392
1393 break;
1394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 default:
1396 /**
1397 * Deauthentication indication due to Deauthentication
1398 * frame reception from peer entity or due to
1399 * loss of link with peer entity.
1400 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301401 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 if (NULL == pSirSmeDeauthInd) {
1403 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301404 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 return;
1406 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301407 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1409 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1410 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1411 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1412
1413 /* sessionId */
1414 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1415 *pBuf++ = smesessionId;
1416
1417 /* transaction ID */
1418 lim_copy_u16(pBuf, smetransactionId);
1419 pBuf += sizeof(uint16_t);
1420
1421 /* status code */
1422 lim_copy_u32(pBuf, reasonCode);
1423 pBuf += sizeof(tSirResultCodes);
1424
1425 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301426 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 pBuf += sizeof(tSirMacAddr);
1428
1429 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301430 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301431 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432
1433#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1434 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1435 psessionEntry, 0, (uint16_t) reasonCode);
1436#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1437 pMsg = (uint32_t *) pSirSmeDeauthInd;
1438
1439 break;
1440 }
1441
1442 /*Delete the PE session created */
1443 if (psessionEntry != NULL) {
1444 pe_delete_session(pMac, psessionEntry);
1445 }
1446
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301447 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 (uint32_t *) pMsg);
1449
1450} /*** end lim_send_sme_deauth_ntf() ***/
1451
1452/**
1453 * lim_send_sme_wm_status_change_ntf() - Send Notification
1454 * @mac_ctx: Global MAC Context
1455 * @status_change_code: Indicates the change in the wireless medium.
1456 * @status_change_info: Indicates the information associated with
1457 * change in the wireless medium.
1458 * @info_len: Indicates the length of status change information
1459 * being sent.
1460 * @session_id SessionID
1461 *
1462 * This function is called by limProcessSmeMessages() to send
1463 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1464 *
1465 * Return: None
1466 */
1467void
1468lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1469 tSirSmeStatusChangeCode status_change_code,
1470 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1471{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001472 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001474 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301476 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001477 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301478 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001479 return;
1480 }
1481
1482 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1483 msg.bodyval = 0;
1484 msg.bodyptr = wm_status_change_ntf;
1485
1486 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001487 case eSIR_SME_AP_CAPS_CHANGED:
1488 max_info_len = sizeof(tSirSmeApNewCaps);
1489 break;
1490 case eSIR_SME_JOINED_NEW_BSS:
1491 max_info_len = sizeof(tSirSmeNewBssInfo);
1492 break;
1493 default:
1494 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1495 break;
1496 }
1497
1498 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 case eSIR_SME_RADAR_DETECTED:
1500 break;
1501 default:
1502 wm_status_change_ntf->messageType =
1503 eWNI_SME_WM_STATUS_CHANGE_NTF;
1504 wm_status_change_ntf->statusChangeCode = status_change_code;
1505 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1506 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001507 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301508 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1510 (uint8_t *) status_change_info, info_len);
1511 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301512 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 status_change_code, info_len);
1514 break;
1515 }
1516
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301517 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301519 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301520 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 }
1522
1523} /*** end lim_send_sme_wm_status_change_ntf() ***/
1524
1525/**
1526 * lim_send_sme_set_context_rsp()
1527 *
1528 ***FUNCTION:
1529 * This function is called by limProcessSmeMessages() to send
1530 * eWNI_SME_SETCONTEXT_RSP message to host
1531 *
1532 ***PARAMS:
1533 *
1534 ***LOGIC:
1535 *
1536 ***ASSUMPTIONS:
1537 * NA
1538 *
1539 ***NOTE:
1540 *
1541 * @param pMac Pointer to Global MAC structure
1542 * @param peerMacAddr Indicates the peer MAC addr to which
1543 * setContext was performed
1544 * @param aid Indicates the aid corresponding to the peer MAC
1545 * address
1546 * @param resultCode Indicates the result of previously issued
1547 * eWNI_SME_SETCONTEXT_RSP message
1548 *
1549 * @return None
1550 */
1551void
1552lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301553 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 tSirResultCodes resultCode,
1555 tpPESession psessionEntry, uint8_t smesessionId,
1556 uint16_t smetransactionId)
1557{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001558 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1560
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301561 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 if (NULL == pSirSmeSetContextRsp) {
1563 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301564 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 return;
1566 }
1567
1568 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1569 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1570 pSirSmeSetContextRsp->statusCode = resultCode;
1571
Anurag Chouhanc5548422016-02-24 18:33:27 +05301572 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573
1574 /* Update SME session and transaction Id */
1575 pSirSmeSetContextRsp->sessionId = smesessionId;
1576 pSirSmeSetContextRsp->transactionId = smetransactionId;
1577
1578 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1579 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1580 mmhMsg.bodyval = 0;
1581 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301582 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1583 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301585 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1586 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 }
1588
1589#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1590 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1591 psessionEntry, (uint16_t) resultCode, 0);
1592#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1593
1594 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1595} /*** end lim_send_sme_set_context_rsp() ***/
1596
1597/**
1598 * lim_send_sme_neighbor_bss_ind()
1599 *
1600 ***FUNCTION:
1601 * This function is called by lim_lookup_nadd_hash_entry() to send
1602 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1603 *
1604 ***PARAMS:
1605 *
1606 ***LOGIC:
1607 *
1608 ***ASSUMPTIONS:
1609 * NA
1610 *
1611 ***NOTE:
1612 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1613 * host upon detecting new BSS during background scanning if CFG
1614 * option is enabled for sending such indication
1615 *
1616 * @param pMac - Pointer to Global MAC structure
1617 * @return None
1618 */
1619
1620void
1621lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1622{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001623 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 uint32_t val;
1625 tSirSmeNeighborBssInd *pNewBssInd;
1626
1627 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1628 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1629 pMac->lim.gLimRspReqd)) {
1630 /* LIM is not in background scan state OR */
1631 /* current scan is initiated by HDD. */
1632 /* No need to send new BSS indication to HDD */
1633 return;
1634 }
1635
1636 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1637 eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301638 pe_err("could not get NEIGHBOR_BSS_IND from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 return;
1640 }
1641
1642 if (val == 0)
1643 return;
1644
1645 /**
1646 * Need to indicate new BSSs found during
1647 * background scanning to host.
1648 * Allocate buffer for sending indication.
1649 * Length of buffer is length of BSS description
1650 * and length of header itself
1651 */
1652 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1653 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301654 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 if (NULL == pNewBssInd) {
1656 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301657 pe_err("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001658 return;
1659 }
1660
1661 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1662 pNewBssInd->length = (uint16_t) val;
1663 pNewBssInd->sessionId = 0;
1664
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301665 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 (uint8_t *) &pBssDescr->bssDescription,
1667 pBssDescr->bssDescription.length + sizeof(uint16_t));
1668
1669 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1670 msgQ.bodyptr = pNewBssInd;
1671 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301672 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1674} /*** end lim_send_sme_neighbor_bss_ind() ***/
1675
1676/** -----------------------------------------------------------------
1677 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1678 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1679 \ SME only looks at rc and tspec field.
1680 \param pMac - global mac structure
1681 \param rspReqd - is SmeAddTsRsp required
1682 \param status - status code of SME_ADD_TS_RSP
1683 \return tspec
1684 \sa
1685 ----------------------------------------------------------------- */
1686void
1687lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1688 tpPESession psessionEntry, tSirMacTspecIE tspec,
1689 uint8_t smesessionId, uint16_t smetransactionId)
1690{
1691 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001692 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693
1694 if (!rspReqd)
1695 return;
1696
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301697 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301699 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 return;
1701 }
1702
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 rsp->messageType = eWNI_SME_ADDTS_RSP;
1704 rsp->rc = status;
1705 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1706 rsp->rsp.tspec = tspec;
1707 /* Update SME session Id and transcation Id */
1708 rsp->sessionId = smesessionId;
1709 rsp->transactionId = smetransactionId;
1710
1711 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1712 mmhMsg.bodyptr = rsp;
1713 mmhMsg.bodyval = 0;
1714 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301715 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1716 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301718 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1719 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 }
1721#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1722 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1723 0);
1724#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1725
1726 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1727 return;
1728}
1729
1730void
1731lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1732 tpPESession psessionEntry, uint8_t smesessionId,
1733 uint16_t smetransactionId)
1734{
1735 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001736 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301738 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 delts->aid,
1740 delts->req.tsinfo.traffic.tsid,
1741 delts->req.tsinfo.traffic.userPrio, status);
1742 if (!delts->rspReqd)
1743 return;
1744
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301745 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 if (NULL == rsp) {
1747 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301748 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 return;
1750 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751
1752 if (psessionEntry != NULL) {
1753
1754 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301755 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301756 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 sizeof(tSirDeltsReqInfo));
1758 }
1759
1760 rsp->messageType = eWNI_SME_DELTS_RSP;
1761 rsp->rc = status;
1762
1763 /* Update SME session Id and transcation Id */
1764 rsp->sessionId = smesessionId;
1765 rsp->transactionId = smetransactionId;
1766
1767 mmhMsg.type = eWNI_SME_DELTS_RSP;
1768 mmhMsg.bodyptr = rsp;
1769 mmhMsg.bodyval = 0;
1770 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301771 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1772 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301774 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1775 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 }
1777#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1778 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1779 (uint16_t) status, 0);
1780#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1781
1782 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1783}
1784
1785void
1786lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1787 tpPESession psessionEntry)
1788{
1789 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001790 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301792 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1794
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301795 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 if (NULL == rsp) {
1797 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301798 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 return;
1800 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801
1802 rsp->messageType = eWNI_SME_DELTS_IND;
1803 rsp->rc = eSIR_SUCCESS;
1804 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301805 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806
1807 /* Update SME session Id and SME transaction Id */
1808
1809 rsp->sessionId = psessionEntry->smeSessionId;
1810 rsp->transactionId = psessionEntry->transactionId;
1811
1812 mmhMsg.type = eWNI_SME_DELTS_IND;
1813 mmhMsg.bodyptr = rsp;
1814 mmhMsg.bodyval = 0;
1815 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1816#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1817 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1818 0);
1819#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1820
1821 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1822}
1823
1824/**
1825 * lim_send_sme_pe_statistics_rsp()
1826 *
1827 ***FUNCTION:
1828 * This function is called to send 802.11 statistics response to HDD.
1829 * This function posts the result back to HDD. This is a response to
1830 * HDD's request for statistics.
1831 *
1832 ***PARAMS:
1833 *
1834 ***LOGIC:
1835 *
1836 ***ASSUMPTIONS:
1837 * NA
1838 *
1839 ***NOTE:
1840 * NA
1841 *
1842 * @param pMac Pointer to Global MAC structure
1843 * @param p80211Stats Statistics sent in response
1844 * @param resultCode TODO:
1845 *
1846 *
1847 * @return none
1848 */
1849
1850void
1851lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1852{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001853 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 uint8_t sessionId;
1855 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1856 tpPESession pPeSessionEntry;
1857
1858 /* Get the Session Id based on Sta Id */
1859 pPeSessionEntry =
1860 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1861
1862 /* Fill the Session Id */
1863 if (NULL != pPeSessionEntry) {
1864 /* Fill the Session Id */
1865 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1866 }
1867
1868 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1869
1870 /* msgType should be WMA_GET_STATISTICS_RSP */
1871 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1872
1873 mmhMsg.bodyptr = stats;
1874 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301875 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1877
1878 return;
1879
1880} /*** end lim_send_sme_pe_statistics_rsp() ***/
1881
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001882#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001884 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1885 * @pMac: Pointer to global pMac structure
1886 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 * This function is called to send tsm stats response to HDD.
1889 * This function posts the result back to HDD. This is a response to
1890 * HDD's request to get tsm stats.
1891 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001892 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001894void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1895 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001897 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 uint8_t sessionId;
1899 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1900 tpPESession pPeSessionEntry = NULL;
1901
1902 /* Get the Session Id based on Sta Id */
1903 pPeSessionEntry =
1904 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1905
1906 /* Fill the Session Id */
1907 if (NULL != pPeSessionEntry) {
1908 /* Fill the Session Id */
1909 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1910 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301911 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301912 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301913 qdf_mem_free(pPeStats->tsmStatsReq);
1914 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 return;
1916 }
1917
1918 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1919 pPeStats->tsmMetrics.RoamingCount
1920 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1921 pPeStats->tsmMetrics.RoamingDly
1922 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1923
1924 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1925 mmhMsg.bodyptr = pStats;
1926 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301927 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1929
1930 return;
1931} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1932
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001933#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001934
1935void
1936lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1937 tSirMacAddr peerMacAddr,
1938 uint16_t staIndex,
1939 uint8_t ucastIdx,
1940 uint8_t bcastIdx,
1941 uint8_t *beacon,
1942 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1943{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001944 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 tSmeIbssPeerInd *pNewPeerInd;
1946
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301947 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301949 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 return;
1951 }
1952
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301953 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301954 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 pNewPeerInd->staId = staIndex;
1956 pNewPeerInd->ucastSig = ucastIdx;
1957 pNewPeerInd->bcastSig = bcastIdx;
1958 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1959 pNewPeerInd->mesgType = msgType;
1960 pNewPeerInd->sessionId = sessionId;
1961
1962 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301963 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1965 beaconLen);
1966 }
1967
1968 mmhMsg.type = msgType;
1969 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301970 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1972
1973}
1974
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001975/**
1976 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1977 * @mac_ctx: pointer to global adapter context
1978 * @csa_params: pointer to CSA parameters
1979 * @chnl_switch_info:pointer to channel switch parameters
1980 * @session_entry: session pointer
1981 *
1982 * Return: None
1983 */
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001984static QDF_STATUS lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001985 struct csa_offload_params *csa_params,
1986 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
1987 tpPESession session_entry)
1988{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001989 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001990 uint8_t ap_new_ch_width;
1991 bool new_ch_width_dfn = false;
1992 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001993 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001994
1995 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001996
1997 pe_info("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1998 csa_params->channel, ap_new_ch_width,
1999 csa_params->new_ch_freq_seg1,
2000 csa_params->new_ch_freq_seg2);
2001
2002 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
2003 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
2004 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
2005 pe_err("CSA wide BW IE has wrong ch_width %d",
2006 csa_params->new_ch_width);
2007 return QDF_STATUS_E_INVAL;
2008 }
2009
2010 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
2011 pe_err("CSA wide BW IE has invalid center freq");
2012 return QDF_STATUS_E_INVAL;
2013 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002014 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2015 csa_params->new_ch_freq_seg2) {
2016 new_ch_width_dfn = true;
2017 if (csa_params->new_ch_freq_seg2 >
2018 csa_params->new_ch_freq_seg1)
2019 center_freq_diff = csa_params->new_ch_freq_seg2 -
2020 csa_params->new_ch_freq_seg1;
2021 else
2022 center_freq_diff = csa_params->new_ch_freq_seg1 -
2023 csa_params->new_ch_freq_seg2;
2024 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2025 ap_new_ch_width = CH_WIDTH_160MHZ;
2026 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2027 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2028 else
2029 ap_new_ch_width = CH_WIDTH_80MHZ;
2030 }
2031 session_entry->gLimChannelSwitch.state =
2032 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2033 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2034 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002035 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
2036 CH_TO_CNTR_FREQ_DIFF_160MHz) {
2037 pe_err("CSA wide BW IE has invalid center freq");
2038 return QDF_STATUS_E_INVAL;
2039 }
2040
2041 if (ap_new_ch_width > fw_vht_ch_wd) {
2042 pe_info("New BW is not supported, setting BW to %d",
2043 fw_vht_ch_wd);
2044 ap_new_ch_width = fw_vht_ch_wd;
2045 }
2046 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002047 wlan_reg_set_channel_params(mac_ctx->pdev,
2048 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002049 ap_new_ch_width = ch_params.ch_width;
2050 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2051 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002052 } else if (!new_ch_width_dfn) {
2053 if (ap_new_ch_width > fw_vht_ch_wd) {
2054 pe_info("New BW is not supported, setting BW to %d",
2055 fw_vht_ch_wd);
2056 ap_new_ch_width = fw_vht_ch_wd;
2057 }
2058 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
2059 CH_TO_CNTR_FREQ_DIFF_80MHz) {
2060 pe_err("CSA wide BW IE has invalid center freq");
2061 return QDF_STATUS_E_INVAL;
2062 }
2063 csa_params->new_ch_freq_seg2 = 0;
2064 }
2065 if (new_ch_width_dfn) {
2066 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
2067 CH_TO_CNTR_FREQ_DIFF_80MHz) {
2068 pe_err("CSA wide BW IE has invalid center freq");
2069 return QDF_STATUS_E_INVAL;
2070 }
2071 if (ap_new_ch_width > fw_vht_ch_wd) {
2072 pe_info("New width is not supported, setting BW to %d",
2073 fw_vht_ch_wd);
2074 ap_new_ch_width = fw_vht_ch_wd;
2075 }
2076 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2077 (csa_params->new_ch_freq_seg1 !=
2078 csa_params->channel +
2079 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
2080 pe_err("wide BW IE has invalid 160M center freq");
2081 csa_params->new_ch_freq_seg2 = 0;
2082 ap_new_ch_width = CH_WIDTH_80MHZ;
2083 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002084 }
2085 chnl_switch_info->newChanWidth = ap_new_ch_width;
2086 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2087 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2088
2089 if (session_entry->ch_width == ap_new_ch_width)
2090 goto prnt_log;
2091
2092 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2093 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2094 chnl_switch_info->newCenterChanFreq1 = 0;
2095 } else {
2096 session_entry->ch_width = ap_new_ch_width;
2097 chnl_switch_info->newChanWidth = ap_new_ch_width;
2098 }
2099prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302100 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002101 csa_params->channel,
2102 chnl_switch_info->newChanWidth,
2103 chnl_switch_info->newCenterChanFreq0,
2104 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002105
2106 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002107}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109/**
2110 * lim_handle_csa_offload_msg() - Handle CSA offload message
2111 * @mac_ctx: pointer to global adapter context
2112 * @msg: Message pointer.
2113 *
2114 * Return: None
2115 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002116void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2117 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118{
2119 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002120 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302121 struct csa_offload_params *csa_params =
2122 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 tpSmeCsaOffloadInd csa_offload_ind;
2124 tpDphHashNode sta_ds = NULL;
2125 uint8_t session_id;
2126 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302127 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002128 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002131 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302133 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302134
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302136 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 return;
2138 }
2139
2140 session_entry =
2141 pe_find_session_by_bssid(mac_ctx,
2142 csa_params->bssId, &session_id);
2143 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302144 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302145 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 goto err;
2147 }
2148
2149 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2150 &session_entry->dph.dphHashTable);
2151
2152 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302153 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 goto err;
2155 }
2156
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002157 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302158 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002159 goto err;
2160 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302161
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002162 /*
2163 * on receiving channel switch announcement from AP, delete all
2164 * TDLS peers before leaving BSS and proceed for channel switch
2165 */
2166 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302167
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002168 lim_ch_switch = &session_entry->gLimChannelSwitch;
2169 session_entry->gLimChannelSwitch.switchMode =
2170 csa_params->switch_mode;
2171 /* timer already started by firmware, switch immediately */
2172 session_entry->gLimChannelSwitch.switchCount = 0;
2173 session_entry->gLimChannelSwitch.primaryChannel =
2174 csa_params->channel;
2175 session_entry->gLimChannelSwitch.state =
2176 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2177 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2178 lim_ch_switch->sec_ch_offset =
2179 session_entry->htSecondaryChannelOffset;
2180 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2181 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2182 chnl_switch_info =
2183 &session_entry->gLimWiderBWChannelSwitch;
2184
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002185 pe_info("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302186 session_entry->vhtCapability,
2187 session_entry->htSupportedChannelWidthSet,
2188 csa_params->ies_present_flag,
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002189 csa_params->channel,
2190 csa_params->sec_chan_offset);
2191 pe_info("seg1: %d seg2: %d width: %d country: %s class: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002192 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302193 csa_params->new_ch_freq_seg2,
2194 csa_params->new_ch_width,
2195 mac_ctx->scan.countryCodeCurrent,
2196 csa_params->new_op_class);
2197
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002198 if (session_entry->vhtCapability &&
2199 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002200 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
2201 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
2202 csa_params, chnl_switch_info,
2203 session_entry))) {
2204 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002205 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05302206 PHY_SINGLE_CHANNEL_CENTERED;
2207 if (chnl_switch_info->newChanWidth) {
2208 if (csa_params->channel <
2209 csa_params->new_ch_freq_seg1)
2210 lim_ch_switch->sec_ch_offset =
2211 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2212 else
2213 lim_ch_switch->sec_ch_offset =
2214 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2215 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002216 } else if (csa_params->ies_present_flag
2217 & lim_xcsa_ie_present) {
2218 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002219 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002220 mac_ctx->scan.countryCodeCurrent,
2221 csa_params->channel,
2222 csa_params->new_op_class);
2223 session_entry->gLimChannelSwitch.state =
2224 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2225
2226 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002228 CH_WIDTH_80MHZ;
2229 } else if (chan_space == 40) {
2230 chnl_switch_info->newChanWidth =
2231 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002233 chnl_switch_info->newChanWidth =
2234 CH_WIDTH_20MHZ;
2235 lim_ch_switch->state =
2236 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2237 }
2238
2239 ch_params.ch_width =
2240 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002241 wlan_reg_set_channel_params(mac_ctx->pdev,
2242 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002243 chnl_switch_info->newCenterChanFreq0 =
2244 ch_params.center_freq_seg0;
2245 /*
2246 * This is not applicable for 20/40/80 MHz.
2247 * Only used when we support 80+80 MHz operation.
2248 * In case of 80+80 MHz, this parameter indicates
2249 * center channel frequency index of 80 MHz
2250 * channel offrequency segment 1.
2251 */
2252 chnl_switch_info->newCenterChanFreq1 =
2253 ch_params.center_freq_seg1;
2254 lim_ch_switch->sec_ch_offset =
2255 ch_params.sec_ch_offset;
2256
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002257 } else {
2258 lim_ch_switch->state =
2259 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2260 ch_params.ch_width = CH_WIDTH_40MHZ;
2261 wlan_reg_set_channel_params(mac_ctx->pdev,
2262 csa_params->channel, 0, &ch_params);
2263 lim_ch_switch->sec_ch_offset =
2264 ch_params.sec_ch_offset;
2265 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
2266 chnl_switch_info->newCenterChanFreq0 =
2267 ch_params.center_freq_seg0;
2268 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002269 }
2270 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2271 chnl_switch_info->newCenterChanFreq0;
2272 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2273 chnl_switch_info->newCenterChanFreq1;
2274 session_entry->gLimChannelSwitch.ch_width =
2275 chnl_switch_info->newChanWidth;
2276
2277 } else if (session_entry->htSupportedChannelWidthSet) {
2278 if (csa_params->ies_present_flag
2279 & lim_xcsa_ie_present) {
2280 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002281 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002282 mac_ctx->scan.countryCodeCurrent,
2283 csa_params->channel,
2284 csa_params->new_op_class);
2285 lim_ch_switch->state =
2286 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2287 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002288 lim_ch_switch->ch_width =
2289 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002290 chnl_switch_info->newChanWidth =
2291 CH_WIDTH_40MHZ;
2292 ch_params.ch_width =
2293 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002294 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002295 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002296 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002297 lim_ch_switch->ch_center_freq_seg0 =
2298 ch_params.center_freq_seg0;
2299 lim_ch_switch->sec_ch_offset =
2300 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002301 } else {
2302 lim_ch_switch->ch_width =
2303 CH_WIDTH_20MHZ;
2304 chnl_switch_info->newChanWidth =
2305 CH_WIDTH_40MHZ;
2306 lim_ch_switch->state =
2307 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2308 lim_ch_switch->sec_ch_offset =
2309 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002311 } else {
2312 lim_ch_switch->ch_width =
2313 CH_WIDTH_40MHZ;
2314 lim_ch_switch->state =
2315 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2316 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002317 wlan_reg_set_channel_params(mac_ctx->pdev,
2318 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002319 lim_ch_switch->ch_center_freq_seg0 =
2320 ch_params.center_freq_seg0;
2321 lim_ch_switch->sec_ch_offset =
2322 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002324
2325 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302326 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302327 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002328 if ((session_entry->currentOperChannel == csa_params->channel) &&
2329 (session_entry->ch_width ==
2330 session_entry->gLimChannelSwitch.ch_width)) {
2331 pe_debug("Ignore CSA, no change in ch and bw");
2332 goto err;
2333 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002335 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2336 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2337 if (NULL == csa_offload_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302338 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002339 goto err;
2340 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002342 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2343 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2344 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2345 QDF_MAC_ADDR_SIZE);
2346 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2347 mmh_msg.bodyptr = csa_offload_ind;
2348 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302349 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002350 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2352#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002353 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2355 eSIR_SUCCESS, eSIR_SUCCESS);
2356#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002357 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358
2359err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302360 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361}
2362
2363/*--------------------------------------------------------------------------
2364 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2365
2366 \param pMac - pointer to global adapter context
2367 \param sessionId - Message pointer.
2368
2369 \sa
2370 --------------------------------------------------------------------------*/
2371
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002372void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373{
2374 tpPESession psessionEntry;
2375 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2376
2377 psessionEntry =
2378 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2379 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302380 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002382 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 return;
2384 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002385
2386 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002387 * During DEL BSS handling, the PE Session will be deleted, but it is
2388 * better to clear this flag if the session is hanging around due
2389 * to some error conditions so that the next DEL_BSS request does
2390 * not take the HO_FAIL path
2391 */
2392 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002393 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002395 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002397 else if (LIM_IS_NDI_ROLE(psessionEntry))
2398 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 else
2400 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2401
2402}
2403
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404/** -----------------------------------------------------------------
2405 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2406 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2407 \ SME only looks at rc and tspec field.
2408 \param pMac - global mac structure
2409 \param rspReqd - is SmeAddTsRsp required
2410 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2411 \return tspec
2412 \sa
2413 ----------------------------------------------------------------- */
2414void
2415lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2416 uint8_t smesessionId)
2417{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002418 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419
2420 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2421 mmhMsg.bodyptr = aggrQosRsp;
2422 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302423 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2424 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2426
2427 return;
2428}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429
2430void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2431 uint8_t smesessionId)
2432{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002433 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 tSmeMaxAssocInd *pSmeMaxAssocInd;
2435
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302436 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302438 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 return;
2440 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302441 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302442 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2444 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2445 pSmeMaxAssocInd->sessionId = smesessionId;
2446 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2447 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302448 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2449 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2450 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302451 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2452 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2454
2455 return;
2456}
2457
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458/*--------------------------------------------------------------------------
2459 \brief lim_send_dfs_chan_sw_ie_update()
2460 This timer handler updates the channel switch IE in beacon template
2461
2462 \param pMac - pointer to global adapter context
2463 \return - channel to scan from valid session else zero.
2464 \sa
2465 --------------------------------------------------------------------------*/
2466static void
2467lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2468{
2469
2470 /* Update the beacon template and send to FW */
2471 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302472 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 return;
2474 }
2475
2476 /* Send update beacon template message */
2477 lim_send_beacon_ind(pMac, psessionEntry);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302478 pe_debug("Updated CSA IE, IE COUNT: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 psessionEntry->gLimChannelSwitch.switchCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480
2481 return;
2482}
2483
2484/** -----------------------------------------------------------------
2485 \brief lim_send_sme_ap_channel_switch_resp() - sends
2486 eWNI_SME_CHANNEL_CHANGE_RSP
2487 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2488 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2489 that the Channel change has been done to the specified target
2490 channel in the Channel change request
2491 \param pMac - global mac structure
2492 \param psessionEntry - session info
2493 \param pChnlParams - Channel switch params
2494 --------------------------------------------------------------------*/
2495void
2496lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2497 tpPESession psessionEntry,
2498 tpSwitchChannelParams pChnlParams)
2499{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002500 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 tpSwitchChannelParams pSmeSwithChnlParams;
2502 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002503 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002504 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002505 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506
2507 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302508 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302510 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511 return;
2512 }
2513
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302514 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 sizeof(tSwitchChannelParams));
2516
2517 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002518 ch_width = pSmeSwithChnlParams->ch_width;
2519 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520
2521 /*
2522 * Pass the sme sessionID to SME instead
2523 * PE session ID.
2524 */
2525 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2526
2527 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2528 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2529 mmhMsg.bodyval = 0;
2530 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2531
2532 /*
2533 * We should start beacon transmission only if the new
2534 * channel after channel change is Non-DFS. For a DFS
2535 * channel, PE will receive an explicit request from
2536 * upper layers to start the beacon transmission .
2537 */
2538
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002539 if (ch_width == CH_WIDTH_160MHZ) {
2540 is_ch_dfs = true;
2541 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002542 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2543 CHANNEL_STATE_DFS ||
2544 wlan_reg_get_channel_state(pMac->pdev,
2545 ch_center_freq_seg1 -
2546 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002547 CHANNEL_STATE_DFS)
2548 is_ch_dfs = true;
2549 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002550 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2551 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002552 is_ch_dfs = true;
2553 }
2554
2555 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 if (channelId == psessionEntry->currentOperChannel) {
2557 lim_apply_configuration(pMac, psessionEntry);
2558 lim_send_beacon_ind(pMac, psessionEntry);
2559 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302560 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002562 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002563
2564 lim_obss_send_detection_cfg(pMac, psessionEntry, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 }
2566 return;
2567}
2568
Peng Xu6363ec62017-05-15 11:06:33 -07002569#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2570/**
2571 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2572 * beacon template
2573 *
2574 * @mac_ctx: pointer to global adapter context
2575 * @session: session pointer
2576 *
2577 * Return: none
2578 */
2579static void
2580lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2581 tpPESession session)
2582{
2583 /* Update the beacon template and send to FW */
2584 if (sch_set_fixed_beacon_fields(mac_ctx, session) != eSIR_SUCCESS) {
2585 pe_err("Unable to set BSS color change IE in beacon");
2586 return;
2587 }
2588
2589 /* Send update beacon template message */
2590 lim_send_beacon_ind(mac_ctx, session);
2591 pe_info("Updated BSS color change countdown = %d",
2592 session->he_bss_color_change.countdown);
2593}
2594
2595static void
2596lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2597 tpPESession session)
2598{
2599 /* handle bss color change IE */
2600 if (LIM_IS_AP_ROLE(session) &&
2601 session->he_op.bss_col_disabled) {
2602 if (session->he_bss_color_change.countdown > 0) {
2603 session->he_bss_color_change.countdown--;
2604 } else {
2605 session->bss_color_changing = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002606 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002607 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002608 session->he_op.bss_color =
2609 session->he_bss_color_change.new_color;
2610 lim_send_obss_color_collision_cfg(mac_ctx,
2611 session,
2612 OBSS_COLOR_COLLISION_DETECTION);
2613 }
Peng Xu6363ec62017-05-15 11:06:33 -07002614 }
2615
2616 lim_send_bss_color_change_ie_update(mac_ctx, session);
2617 }
2618}
2619
2620#else
2621static void
2622lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2623 tpPESession session)
2624{
2625}
2626#endif
2627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628/** -----------------------------------------------------------------
2629 \brief lim_process_beacon_tx_success_ind() - This function is used
2630 explicitely to handle successful beacon transmission indication
2631 from the FW. This is a generic event generated by the FW afer the
2632 first beacon is sent out after the beacon template update by the
2633 host
2634 \param pMac - global mac structure
2635 \param psessionEntry - session info
2636 \return none
2637 \sa
2638 ----------------------------------------------------------------- */
2639void
2640lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2641{
2642 /* Currently, this event is used only for DFS channel switch announcement
2643 * IE update in the template. If required to be used for other IE updates
2644 * add appropriate code by introducing a state variable
2645 */
2646 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002647 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2649 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2650 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2651 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2652 (tSirFirstBeaconTxCompleteInd *) event;
lifeng1c16b6b2017-09-25 13:59:55 +08002653 uint8_t ch, ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654
2655 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2656 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302657 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 return;
2659 }
2660
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302661 pe_debug("role: %d swIe: %d opIe: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302662 GET_LIM_SYSTEM_ROLE(psessionEntry),
2663 psessionEntry->dfsIncludeChanSwIe,
2664 psessionEntry->gLimOperatingMode.present);
2665
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 if (LIM_IS_AP_ROLE(psessionEntry) &&
2667 true == psessionEntry->dfsIncludeChanSwIe) {
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302668
2669 if (psessionEntry->gLimChannelSwitch.switchCount) {
2670 /* Decrement the beacon switch count */
2671 psessionEntry->gLimChannelSwitch.switchCount--;
2672 pe_debug("current beacon count %d",
2673 psessionEntry->gLimChannelSwitch.switchCount);
2674 }
2675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2677 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2678 /*
2679 * Send the next beacon with updated CSA IE count
2680 */
2681 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
lifeng1c16b6b2017-09-25 13:59:55 +08002682
2683 ch = psessionEntry->gLimChannelSwitch.primaryChannel;
2684 ch_width = psessionEntry->gLimChannelSwitch.ch_width;
2685 if (pMac->sap.SapDfsInfo.dfs_beacon_tx_enhanced)
2686 /* Send Action frame after updating beacon */
2687 lim_send_chan_switch_action_frame(pMac,
2688 ch, ch_width, psessionEntry);
2689
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 } else {
2691 /* Done with CSA IE update, send response back to SME */
2692 psessionEntry->gLimChannelSwitch.switchCount = 0;
2693 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2694 psessionEntry->gLimChannelSwitch.switchMode = 0;
2695 psessionEntry->dfsIncludeChanSwIe = false;
2696 psessionEntry->dfsIncludeChanWrapperIe = false;
2697
2698 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302699 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700
2701 if (NULL == pChanSwTxResponse) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302702 pe_err("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 return;
2704 }
2705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 pChanSwTxResponse->sessionId =
2707 psessionEntry->smeSessionId;
2708 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302709 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710
2711 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2712 mmhMsg.bodyptr = pChanSwTxResponse;
2713 mmhMsg.bodyval = 0;
2714 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2715 }
2716 }
2717
2718 if (LIM_IS_AP_ROLE(psessionEntry) &&
2719 psessionEntry->gLimOperatingMode.present) {
2720 /* Done with nss update, send response back to SME */
2721 psessionEntry->gLimOperatingMode.present = 0;
2722 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302723 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302725 pe_err("AllocateMemory failed for beacon_tx_comp_rsp_ptr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 return;
2727 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 beacon_tx_comp_rsp_ptr->session_id =
2729 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302730 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2732 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2733 mmhMsg.bodyval = 0;
2734 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2735 }
Peng Xu6363ec62017-05-15 11:06:33 -07002736
2737 lim_handle_bss_color_change_ie(pMac, psessionEntry);
2738
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 return;
2740}