blob: 67728c641f4abe31bc725e6f2937a319bab97eee [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Nitesh Shah82c52812016-12-27 12:27:51 +05302 * Copyright (c) 2012-2017 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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070064#ifdef CONVERGED_TDLS_ENABLE
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070065#include "wlan_tdls_tgt_api.h"
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070066#endif
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053067#include "lim_process_fils.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
Wu Gao2968fc92017-06-19 19:18:34 +0800370 pe_debug("pLimJoinReq:%p, pLimReAssocReq:%p",
371 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 Rawatc4a0e662017-05-19 08:06:57 -0700388 is_vendor_ap_1_present = (cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
389 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 &&
393 is_vendor_ap_1_present && (session_entry->nss == 2) &&
394 (mac_ctx->lteCoexAntShare == 0 ||
395 IS_5G_CH(session_entry->currentOperChannel))) {
396 /* 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);
927 }
928 }
929 if (sta_ds
930#ifdef WLAN_FEATURE_11W
931 && (!sta_ds->rmfEnabled)
932#endif
933 ) {
934 if (lim_add_sta(pMac, sta_ds, false, session) !=
935 eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530936 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700937 sta_ds->assocId);
938 }
939 failure = true;
940 break;
941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 case eLIM_HOST_DISASSOC:
943 /**
944 * Disassociation response due to
945 * host triggered disassociation
946 */
947
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530948 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949 if (NULL == pSirSmeDisassocRsp) {
950 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530951 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952 failure = true;
953 goto error;
954 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530955 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
957 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
958 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
959 /* sessionId */
960 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
961 *pBuf = smesessionId;
962 pBuf++;
963
964 /* transactionId */
965 lim_copy_u16(pBuf, smetransactionId);
966 pBuf += sizeof(uint16_t);
967
968 /* statusCode */
969 lim_copy_u32(pBuf, reasonCode);
970 pBuf += sizeof(tSirResultCodes);
971
972 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530973 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800974 pBuf += sizeof(tSirMacAddr);
975
976 /* Clear Station Stats */
977 /* for sta, it is always 1, IBSS is handled at halInitSta */
978
979#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
980
981 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
982 psessionEntry, (uint16_t) reasonCode, 0);
983#endif
984 pMsg = (uint32_t *) pSirSmeDisassocRsp;
985 break;
986
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530987 case eLIM_PEER_ENTITY_DISASSOC:
988 case eLIM_LINK_MONITORING_DISASSOC:
989 sir_sme_dis_ind =
990 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
991 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530992 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530993 return;
994 }
995
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530996 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530997 reasonCode);
998
999 sir_sme_dis_ind->message_type =
1000 eWNI_SME_DISCONNECT_DONE_IND;
1001 sir_sme_dis_ind->length =
1002 sizeof(*sir_sme_dis_ind);
1003 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1004 sizeof(tSirMacAddr));
1005 sir_sme_dis_ind->session_id = smesessionId;
1006 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301007 /*
1008 * Instead of sending deauth reason code as 505 which is
1009 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1010 * Send reason code as zero to Supplicant
1011 */
1012 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1013 sir_sme_dis_ind->reason_code = 0;
1014 else
1015 sir_sme_dis_ind->reason_code = reasonCode;
1016
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301017 pMsg = (uint32_t *)sir_sme_dis_ind;
1018
1019 break;
1020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 default:
1022 /**
1023 * Disassociation indication due to Disassociation
1024 * frame reception from peer entity or due to
1025 * loss of link with peer entity.
1026 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301027 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 if (NULL == pSirSmeDisassocInd) {
1029 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301030 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 failure = true;
1032 goto error;
1033 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301034 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1036 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1037 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1038
1039 /* Update SME session Id and Transaction Id */
1040 pSirSmeDisassocInd->sessionId = smesessionId;
1041 pSirSmeDisassocInd->transactionId = smetransactionId;
1042 pSirSmeDisassocInd->reasonCode = reasonCode;
1043 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1044
1045 lim_copy_u32(pBuf, reasonCode);
1046 pBuf += sizeof(tSirResultCodes);
1047
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301048 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 pBuf += sizeof(tSirMacAddr);
1050
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301051 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052
1053#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1054 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1055 psessionEntry, (uint16_t) reasonCode, 0);
1056#endif
1057 pMsg = (uint32_t *) pSirSmeDisassocInd;
1058
1059 break;
1060 }
1061
1062error:
1063 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001064 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066
1067 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301068 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 (uint32_t *) pMsg);
1070} /*** end lim_send_sme_disassoc_ntf() ***/
1071
1072/** -----------------------------------------------------------------
1073 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1074
1075 After receiving disassociation frame from peer entity, this
1076 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1077 reason code.
1078
1079 \param pMac - global mac structure
1080 \param pStaDs - station dph hash node
1081 \return none
1082 \sa
1083 ----------------------------------------------------------------- */
1084void
1085lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1086 tpPESession psessionEntry)
1087{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001088 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 tSirSmeDisassocInd *pSirSmeDisassocInd;
1090
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301091 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301093 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 return;
1095 }
1096
1097 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1098 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1099
1100 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1101 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301102 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1104
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301105 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301106 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301108 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301109 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110
1111 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1112
1113 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1114 mmhMsg.bodyptr = pSirSmeDisassocInd;
1115 mmhMsg.bodyval = 0;
1116
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301117 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1118 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1120 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1121 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1122#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1123
1124 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1125
1126} /*** end lim_send_sme_disassoc_ind() ***/
1127
1128/** -----------------------------------------------------------------
1129 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1130
1131 After receiving deauthentication frame from peer entity, this
1132 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1133 reason code.
1134
1135 \param pMac - global mac structure
1136 \param pStaDs - station dph hash node
1137 \return none
1138 \sa
1139 ----------------------------------------------------------------- */
1140void
1141lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1142 tpPESession psessionEntry)
1143{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001144 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 tSirSmeDeauthInd *pSirSmeDeauthInd;
1146
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301147 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301149 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 return;
1151 }
1152
1153 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1154 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1155
1156 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1157 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1158 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1159 pSirSmeDeauthInd->statusCode =
1160 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1161 } else {
1162 /* Need to indicatet he reascon code over the air */
1163 pSirSmeDeauthInd->statusCode =
1164 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1165 }
1166 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301167 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301168 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301170 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301171 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1173
1174 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001175 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1176 pStaDs->mlmStaContext.disassocReason)
1177 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178
1179 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1180 mmhMsg.bodyptr = pSirSmeDeauthInd;
1181 mmhMsg.bodyval = 0;
1182
1183 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1184#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1185 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1186 0, pStaDs->mlmStaContext.cleanupTrigger);
1187#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1188
1189 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1190 return;
1191} /*** end lim_send_sme_deauth_ind() ***/
1192
1193#ifdef FEATURE_WLAN_TDLS
1194/**
1195 * lim_send_sme_tdls_del_sta_ind()
1196 *
1197 ***FUNCTION:
1198 * This function is called to send the TDLS STA context deletion to SME.
1199 *
1200 ***LOGIC:
1201 *
1202 ***ASSUMPTIONS:
1203 *
1204 ***NOTE:
1205 * NA
1206 *
1207 * @param pMac - Pointer to global MAC structure
1208 * @param pStaDs - Pointer to internal STA Datastructure
1209 * @param psessionEntry - Pointer to the session entry
1210 * @param reasonCode - Reason for TDLS sta deletion
1211 * @return None
1212 */
1213void
1214lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1215 tpPESession psessionEntry, uint16_t reasonCode)
1216{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001217 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1219
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301220 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 if (NULL == pSirTdlsDelStaInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301222 pe_err("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 return;
1224 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301225 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301226 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 /* messageType */
1228 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1229 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1230
1231 /* sessionId */
1232 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1233
1234 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301235 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301236 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237
1238 /* staId */
1239 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1240 (uint16_t) pStaDs->staIndex);
1241
1242 /* reasonCode */
1243 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1244
1245 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1246 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1247 mmhMsg.bodyval = 0;
1248
1249 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1250 return;
1251} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1252
1253/**
1254 * lim_send_sme_tdls_delete_all_peer_ind()
1255 *
1256 ***FUNCTION:
1257 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1258 * message to SME.
1259 *
1260 ***LOGIC:
1261 *
1262 ***ASSUMPTIONS:
1263 *
1264 ***NOTE:
1265 * NA
1266 *
1267 * @param pMac - Pointer to global MAC structure
1268 * @param psessionEntry - Pointer to the session entry
1269 * @return None
1270 */
1271void
1272lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1273{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001274 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1276
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301277 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278 if (NULL == pSirTdlsDelAllPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301279 pe_err("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 return;
1281 }
1282 /* messageType */
1283 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1284 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1285
1286 /* sessionId */
1287 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1288
1289 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1290 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1291 mmhMsg.bodyval = 0;
1292
1293 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1294 return;
1295} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1296
1297/**
1298 * lim_send_sme_mgmt_tx_completion()
1299 *
1300 ***FUNCTION:
1301 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1302 * message to SME.
1303 *
1304 ***LOGIC:
1305 *
1306 ***ASSUMPTIONS:
1307 *
1308 ***NOTE:
1309 * NA
1310 *
1311 * @param pMac - Pointer to global MAC structure
1312 * @param psessionEntry - Pointer to the session entry
1313 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1314 * @return None
1315 */
1316void
1317lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301318 uint32_t sme_session_id,
1319 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001321 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1323
1324 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301325 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301327 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 return;
1329 }
1330 /* messageType */
1331 pSirMgmtTxCompletionInd->messageType =
1332 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1333 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1334
1335 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301336 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337
1338 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1339
1340 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1341 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1342 mmhMsg.bodyval = 0;
1343
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001344#ifdef CONVERGED_TDLS_ENABLE
1345 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1346 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1347 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1348 return;
1349#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1351 return;
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001352#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1354
1355void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1356 void *events)
1357{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001358 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359
1360 switch (msgType) {
1361 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1362 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1363 break;
1364 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1365 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1366 break;
1367 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1368 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1369 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001370 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1371 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1372 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 }
1374
1375 mmhMsg.bodyptr = events;
1376 mmhMsg.bodyval = 0;
1377 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1378 return;
1379}
1380#endif /* FEATURE_WLAN_TDLS */
1381
1382/**
1383 * lim_send_sme_deauth_ntf()
1384 *
1385 ***FUNCTION:
1386 * This function is called by limProcessSmeMessages() to send
1387 * eWNI_SME_DISASSOC_RSP/IND message to host
1388 *
1389 ***PARAMS:
1390 *
1391 ***LOGIC:
1392 *
1393 ***ASSUMPTIONS:
1394 * NA
1395 *
1396 ***NOTE:
1397 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1398 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1399 *
1400 * @param peerMacAddr Indicates the peer MAC addr to which
1401 * deauthentication was initiated
1402 * @param reasonCode Indicates the reason for Deauthetication
1403 * @param deauthTrigger Indicates the trigger for Deauthetication
1404 * @param aid Indicates the STAID. This parameter is present
1405 * only on AP.
1406 *
1407 * @return None
1408 */
1409void
1410lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1411 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1412 uint16_t aid, uint8_t smesessionId,
1413 uint16_t smetransactionId)
1414{
1415 uint8_t *pBuf;
1416 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1417 tSirSmeDeauthInd *pSirSmeDeauthInd;
1418 tpPESession psessionEntry;
1419 uint8_t sessionId;
1420 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301421 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422
1423 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1424 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 case eLIM_HOST_DEAUTH:
1426 /**
1427 * Deauthentication response to host triggered
1428 * deauthentication.
1429 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301430 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 if (NULL == pSirSmeDeauthRsp) {
1432 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301433 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 return;
1435 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301436 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1438 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1439 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1440 pSirSmeDeauthRsp->statusCode = reasonCode;
1441 pSirSmeDeauthRsp->sessionId = smesessionId;
1442 pSirSmeDeauthRsp->transactionId = smetransactionId;
1443
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001444 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301445 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446
1447#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1448 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1449 psessionEntry, 0, (uint16_t) reasonCode);
1450#endif
1451 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1452
1453 break;
1454
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301455 case eLIM_PEER_ENTITY_DEAUTH:
1456 case eLIM_LINK_MONITORING_DEAUTH:
1457 sir_sme_dis_ind =
1458 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1459 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301460 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301461 return;
1462 }
1463
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301464 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301465 reasonCode);
1466
1467 sir_sme_dis_ind->message_type =
1468 eWNI_SME_DISCONNECT_DONE_IND;
1469 sir_sme_dis_ind->length =
1470 sizeof(*sir_sme_dis_ind);
1471 sir_sme_dis_ind->session_id = smesessionId;
1472 sir_sme_dis_ind->reason_code = reasonCode;
1473 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1474 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301475 /*
1476 * Instead of sending deauth reason code as 505 which is
1477 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1478 * Send reason code as zero to Supplicant
1479 */
1480 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1481 sir_sme_dis_ind->reason_code = 0;
1482 else
1483 sir_sme_dis_ind->reason_code = reasonCode;
1484
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301485 pMsg = (uint32_t *)sir_sme_dis_ind;
1486
1487 break;
1488
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 default:
1490 /**
1491 * Deauthentication indication due to Deauthentication
1492 * frame reception from peer entity or due to
1493 * loss of link with peer entity.
1494 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301495 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 if (NULL == pSirSmeDeauthInd) {
1497 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301498 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 return;
1500 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301501 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1503 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1504 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1505 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1506
1507 /* sessionId */
1508 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1509 *pBuf++ = smesessionId;
1510
1511 /* transaction ID */
1512 lim_copy_u16(pBuf, smetransactionId);
1513 pBuf += sizeof(uint16_t);
1514
1515 /* status code */
1516 lim_copy_u32(pBuf, reasonCode);
1517 pBuf += sizeof(tSirResultCodes);
1518
1519 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301520 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 pBuf += sizeof(tSirMacAddr);
1522
1523 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301524 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301525 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526
1527#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1528 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1529 psessionEntry, 0, (uint16_t) reasonCode);
1530#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1531 pMsg = (uint32_t *) pSirSmeDeauthInd;
1532
1533 break;
1534 }
1535
1536 /*Delete the PE session created */
1537 if (psessionEntry != NULL) {
1538 pe_delete_session(pMac, psessionEntry);
1539 }
1540
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301541 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 (uint32_t *) pMsg);
1543
1544} /*** end lim_send_sme_deauth_ntf() ***/
1545
1546/**
1547 * lim_send_sme_wm_status_change_ntf() - Send Notification
1548 * @mac_ctx: Global MAC Context
1549 * @status_change_code: Indicates the change in the wireless medium.
1550 * @status_change_info: Indicates the information associated with
1551 * change in the wireless medium.
1552 * @info_len: Indicates the length of status change information
1553 * being sent.
1554 * @session_id SessionID
1555 *
1556 * This function is called by limProcessSmeMessages() to send
1557 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1558 *
1559 * Return: None
1560 */
1561void
1562lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1563 tSirSmeStatusChangeCode status_change_code,
1564 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1565{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001566 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001568 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301570 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301572 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 return;
1574 }
1575
1576 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1577 msg.bodyval = 0;
1578 msg.bodyptr = wm_status_change_ntf;
1579
1580 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001581 case eSIR_SME_AP_CAPS_CHANGED:
1582 max_info_len = sizeof(tSirSmeApNewCaps);
1583 break;
1584 case eSIR_SME_JOINED_NEW_BSS:
1585 max_info_len = sizeof(tSirSmeNewBssInfo);
1586 break;
1587 default:
1588 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1589 break;
1590 }
1591
1592 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 case eSIR_SME_RADAR_DETECTED:
1594 break;
1595 default:
1596 wm_status_change_ntf->messageType =
1597 eWNI_SME_WM_STATUS_CHANGE_NTF;
1598 wm_status_change_ntf->statusChangeCode = status_change_code;
1599 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1600 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001601 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301602 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1604 (uint8_t *) status_change_info, info_len);
1605 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301606 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 status_change_code, info_len);
1608 break;
1609 }
1610
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301611 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301613 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301614 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 }
1616
1617} /*** end lim_send_sme_wm_status_change_ntf() ***/
1618
1619/**
1620 * lim_send_sme_set_context_rsp()
1621 *
1622 ***FUNCTION:
1623 * This function is called by limProcessSmeMessages() to send
1624 * eWNI_SME_SETCONTEXT_RSP message to host
1625 *
1626 ***PARAMS:
1627 *
1628 ***LOGIC:
1629 *
1630 ***ASSUMPTIONS:
1631 * NA
1632 *
1633 ***NOTE:
1634 *
1635 * @param pMac Pointer to Global MAC structure
1636 * @param peerMacAddr Indicates the peer MAC addr to which
1637 * setContext was performed
1638 * @param aid Indicates the aid corresponding to the peer MAC
1639 * address
1640 * @param resultCode Indicates the result of previously issued
1641 * eWNI_SME_SETCONTEXT_RSP message
1642 *
1643 * @return None
1644 */
1645void
1646lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301647 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 tSirResultCodes resultCode,
1649 tpPESession psessionEntry, uint8_t smesessionId,
1650 uint16_t smetransactionId)
1651{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001652 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1654
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301655 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 if (NULL == pSirSmeSetContextRsp) {
1657 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301658 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 return;
1660 }
1661
1662 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1663 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1664 pSirSmeSetContextRsp->statusCode = resultCode;
1665
Anurag Chouhanc5548422016-02-24 18:33:27 +05301666 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667
1668 /* Update SME session and transaction Id */
1669 pSirSmeSetContextRsp->sessionId = smesessionId;
1670 pSirSmeSetContextRsp->transactionId = smetransactionId;
1671
1672 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1673 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1674 mmhMsg.bodyval = 0;
1675 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301676 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1677 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301679 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1680 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 }
1682
1683#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1684 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1685 psessionEntry, (uint16_t) resultCode, 0);
1686#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1687
1688 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1689} /*** end lim_send_sme_set_context_rsp() ***/
1690
1691/**
1692 * lim_send_sme_neighbor_bss_ind()
1693 *
1694 ***FUNCTION:
1695 * This function is called by lim_lookup_nadd_hash_entry() to send
1696 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1697 *
1698 ***PARAMS:
1699 *
1700 ***LOGIC:
1701 *
1702 ***ASSUMPTIONS:
1703 * NA
1704 *
1705 ***NOTE:
1706 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1707 * host upon detecting new BSS during background scanning if CFG
1708 * option is enabled for sending such indication
1709 *
1710 * @param pMac - Pointer to Global MAC structure
1711 * @return None
1712 */
1713
1714void
1715lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1716{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001717 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 uint32_t val;
1719 tSirSmeNeighborBssInd *pNewBssInd;
1720
1721 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1722 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1723 pMac->lim.gLimRspReqd)) {
1724 /* LIM is not in background scan state OR */
1725 /* current scan is initiated by HDD. */
1726 /* No need to send new BSS indication to HDD */
1727 return;
1728 }
1729
1730 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1731 eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301732 pe_err("could not get NEIGHBOR_BSS_IND from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 return;
1734 }
1735
1736 if (val == 0)
1737 return;
1738
1739 /**
1740 * Need to indicate new BSSs found during
1741 * background scanning to host.
1742 * Allocate buffer for sending indication.
1743 * Length of buffer is length of BSS description
1744 * and length of header itself
1745 */
1746 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1747 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301748 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 if (NULL == pNewBssInd) {
1750 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301751 pe_err("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001752 return;
1753 }
1754
1755 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1756 pNewBssInd->length = (uint16_t) val;
1757 pNewBssInd->sessionId = 0;
1758
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301759 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 (uint8_t *) &pBssDescr->bssDescription,
1761 pBssDescr->bssDescription.length + sizeof(uint16_t));
1762
1763 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1764 msgQ.bodyptr = pNewBssInd;
1765 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301766 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1768} /*** end lim_send_sme_neighbor_bss_ind() ***/
1769
1770/** -----------------------------------------------------------------
1771 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1772 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1773 \ SME only looks at rc and tspec field.
1774 \param pMac - global mac structure
1775 \param rspReqd - is SmeAddTsRsp required
1776 \param status - status code of SME_ADD_TS_RSP
1777 \return tspec
1778 \sa
1779 ----------------------------------------------------------------- */
1780void
1781lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1782 tpPESession psessionEntry, tSirMacTspecIE tspec,
1783 uint8_t smesessionId, uint16_t smetransactionId)
1784{
1785 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001786 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787
1788 if (!rspReqd)
1789 return;
1790
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301791 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301793 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 return;
1795 }
1796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 rsp->messageType = eWNI_SME_ADDTS_RSP;
1798 rsp->rc = status;
1799 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1800 rsp->rsp.tspec = tspec;
1801 /* Update SME session Id and transcation Id */
1802 rsp->sessionId = smesessionId;
1803 rsp->transactionId = smetransactionId;
1804
1805 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1806 mmhMsg.bodyptr = rsp;
1807 mmhMsg.bodyval = 0;
1808 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301809 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1810 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301812 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1813 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 }
1815#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1816 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1817 0);
1818#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1819
1820 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1821 return;
1822}
1823
1824void
1825lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1826 tpPESession psessionEntry, uint8_t smesessionId,
1827 uint16_t smetransactionId)
1828{
1829 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001830 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301832 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 delts->aid,
1834 delts->req.tsinfo.traffic.tsid,
1835 delts->req.tsinfo.traffic.userPrio, status);
1836 if (!delts->rspReqd)
1837 return;
1838
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301839 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 if (NULL == rsp) {
1841 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301842 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 return;
1844 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845
1846 if (psessionEntry != NULL) {
1847
1848 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301849 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301850 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 sizeof(tSirDeltsReqInfo));
1852 }
1853
1854 rsp->messageType = eWNI_SME_DELTS_RSP;
1855 rsp->rc = status;
1856
1857 /* Update SME session Id and transcation Id */
1858 rsp->sessionId = smesessionId;
1859 rsp->transactionId = smetransactionId;
1860
1861 mmhMsg.type = eWNI_SME_DELTS_RSP;
1862 mmhMsg.bodyptr = rsp;
1863 mmhMsg.bodyval = 0;
1864 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301865 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1866 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301868 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1869 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 }
1871#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1872 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1873 (uint16_t) status, 0);
1874#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1875
1876 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1877}
1878
1879void
1880lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1881 tpPESession psessionEntry)
1882{
1883 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001884 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301886 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1888
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301889 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 if (NULL == rsp) {
1891 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301892 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 return;
1894 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895
1896 rsp->messageType = eWNI_SME_DELTS_IND;
1897 rsp->rc = eSIR_SUCCESS;
1898 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301899 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900
1901 /* Update SME session Id and SME transaction Id */
1902
1903 rsp->sessionId = psessionEntry->smeSessionId;
1904 rsp->transactionId = psessionEntry->transactionId;
1905
1906 mmhMsg.type = eWNI_SME_DELTS_IND;
1907 mmhMsg.bodyptr = rsp;
1908 mmhMsg.bodyval = 0;
1909 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1910#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1911 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1912 0);
1913#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1914
1915 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1916}
1917
1918/**
1919 * lim_send_sme_pe_statistics_rsp()
1920 *
1921 ***FUNCTION:
1922 * This function is called to send 802.11 statistics response to HDD.
1923 * This function posts the result back to HDD. This is a response to
1924 * HDD's request for statistics.
1925 *
1926 ***PARAMS:
1927 *
1928 ***LOGIC:
1929 *
1930 ***ASSUMPTIONS:
1931 * NA
1932 *
1933 ***NOTE:
1934 * NA
1935 *
1936 * @param pMac Pointer to Global MAC structure
1937 * @param p80211Stats Statistics sent in response
1938 * @param resultCode TODO:
1939 *
1940 *
1941 * @return none
1942 */
1943
1944void
1945lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1946{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001947 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 uint8_t sessionId;
1949 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1950 tpPESession pPeSessionEntry;
1951
1952 /* Get the Session Id based on Sta Id */
1953 pPeSessionEntry =
1954 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1955
1956 /* Fill the Session Id */
1957 if (NULL != pPeSessionEntry) {
1958 /* Fill the Session Id */
1959 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1960 }
1961
1962 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1963
1964 /* msgType should be WMA_GET_STATISTICS_RSP */
1965 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1966
1967 mmhMsg.bodyptr = stats;
1968 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301969 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1971
1972 return;
1973
1974} /*** end lim_send_sme_pe_statistics_rsp() ***/
1975
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001976#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001978 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1979 * @pMac: Pointer to global pMac structure
1980 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 * This function is called to send tsm stats response to HDD.
1983 * This function posts the result back to HDD. This is a response to
1984 * HDD's request to get tsm stats.
1985 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001986 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001988void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1989 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001991 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 uint8_t sessionId;
1993 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1994 tpPESession pPeSessionEntry = NULL;
1995
1996 /* Get the Session Id based on Sta Id */
1997 pPeSessionEntry =
1998 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1999
2000 /* Fill the Session Id */
2001 if (NULL != pPeSessionEntry) {
2002 /* Fill the Session Id */
2003 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
2004 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302005 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302006 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05302007 qdf_mem_free(pPeStats->tsmStatsReq);
2008 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 return;
2010 }
2011
2012 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
2013 pPeStats->tsmMetrics.RoamingCount
2014 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
2015 pPeStats->tsmMetrics.RoamingDly
2016 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
2017
2018 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
2019 mmhMsg.bodyptr = pStats;
2020 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302021 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2023
2024 return;
2025} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
2026
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002027#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028
2029void
2030lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
2031 tSirMacAddr peerMacAddr,
2032 uint16_t staIndex,
2033 uint8_t ucastIdx,
2034 uint8_t bcastIdx,
2035 uint8_t *beacon,
2036 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
2037{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002038 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 tSmeIbssPeerInd *pNewPeerInd;
2040
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302041 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302043 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 return;
2045 }
2046
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302047 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302048 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 pNewPeerInd->staId = staIndex;
2050 pNewPeerInd->ucastSig = ucastIdx;
2051 pNewPeerInd->bcastSig = bcastIdx;
2052 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
2053 pNewPeerInd->mesgType = msgType;
2054 pNewPeerInd->sessionId = sessionId;
2055
2056 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302057 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2059 beaconLen);
2060 }
2061
2062 mmhMsg.type = msgType;
2063 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302064 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2066
2067}
2068
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002069/**
2070 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
2071 * @mac_ctx: pointer to global adapter context
2072 * @csa_params: pointer to CSA parameters
2073 * @chnl_switch_info:pointer to channel switch parameters
2074 * @session_entry: session pointer
2075 *
2076 * Return: None
2077 */
2078static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002079 struct csa_offload_params *csa_params,
2080 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
2081 tpPESession session_entry)
2082{
Amar Singhal5cccafe2017-02-15 12:42:58 -08002083 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002084 uint8_t ap_new_ch_width;
2085 bool new_ch_width_dfn = false;
2086 uint8_t center_freq_diff;
2087
2088 ap_new_ch_width = csa_params->new_ch_width + 1;
2089 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2090 csa_params->new_ch_freq_seg2) {
2091 new_ch_width_dfn = true;
2092 if (csa_params->new_ch_freq_seg2 >
2093 csa_params->new_ch_freq_seg1)
2094 center_freq_diff = csa_params->new_ch_freq_seg2 -
2095 csa_params->new_ch_freq_seg1;
2096 else
2097 center_freq_diff = csa_params->new_ch_freq_seg1 -
2098 csa_params->new_ch_freq_seg2;
2099 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2100 ap_new_ch_width = CH_WIDTH_160MHZ;
2101 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2102 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2103 else
2104 ap_new_ch_width = CH_WIDTH_80MHZ;
2105 }
2106 session_entry->gLimChannelSwitch.state =
2107 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2108 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2109 !new_ch_width_dfn) {
2110 ch_params.ch_width = CH_WIDTH_160MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002111 wlan_reg_set_channel_params(mac_ctx->pdev,
2112 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002113 ap_new_ch_width = ch_params.ch_width;
2114 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2115 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2116 }
2117 chnl_switch_info->newChanWidth = ap_new_ch_width;
2118 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2119 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2120
2121 if (session_entry->ch_width == ap_new_ch_width)
2122 goto prnt_log;
2123
2124 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2125 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2126 chnl_switch_info->newCenterChanFreq1 = 0;
2127 } else {
2128 session_entry->ch_width = ap_new_ch_width;
2129 chnl_switch_info->newChanWidth = ap_new_ch_width;
2130 }
2131prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302132 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002133 csa_params->channel,
2134 chnl_switch_info->newChanWidth,
2135 chnl_switch_info->newCenterChanFreq0,
2136 chnl_switch_info->newCenterChanFreq1);
2137}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138/**
2139 * lim_handle_csa_offload_msg() - Handle CSA offload message
2140 * @mac_ctx: pointer to global adapter context
2141 * @msg: Message pointer.
2142 *
2143 * Return: None
2144 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002145void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2146 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147{
2148 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002149 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302150 struct csa_offload_params *csa_params =
2151 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 tpSmeCsaOffloadInd csa_offload_ind;
2153 tpDphHashNode sta_ds = NULL;
2154 uint8_t session_id;
2155 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302156 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002157 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002160 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302162 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302163
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302165 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 return;
2167 }
2168
2169 session_entry =
2170 pe_find_session_by_bssid(mac_ctx,
2171 csa_params->bssId, &session_id);
2172 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302173 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302174 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 goto err;
2176 }
2177
2178 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2179 &session_entry->dph.dphHashTable);
2180
2181 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302182 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 goto err;
2184 }
2185
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002186 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302187 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002188 goto err;
2189 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302190
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002191 /*
2192 * on receiving channel switch announcement from AP, delete all
2193 * TDLS peers before leaving BSS and proceed for channel switch
2194 */
2195 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302196
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002197 lim_ch_switch = &session_entry->gLimChannelSwitch;
2198 session_entry->gLimChannelSwitch.switchMode =
2199 csa_params->switch_mode;
2200 /* timer already started by firmware, switch immediately */
2201 session_entry->gLimChannelSwitch.switchCount = 0;
2202 session_entry->gLimChannelSwitch.primaryChannel =
2203 csa_params->channel;
2204 session_entry->gLimChannelSwitch.state =
2205 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2206 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2207 lim_ch_switch->sec_ch_offset =
2208 session_entry->htSecondaryChannelOffset;
2209 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2210 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2211 chnl_switch_info =
2212 &session_entry->gLimWiderBWChannelSwitch;
2213
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302214 pe_debug("vht: %d ht: %d flag: %x chan: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302215 session_entry->vhtCapability,
2216 session_entry->htSupportedChannelWidthSet,
2217 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002218 csa_params->channel);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302219 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002220 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302221 csa_params->new_ch_freq_seg2,
2222 csa_params->new_ch_width,
2223 mac_ctx->scan.countryCodeCurrent,
2224 csa_params->new_op_class);
2225
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002226 if (session_entry->vhtCapability &&
2227 session_entry->htSupportedChannelWidthSet) {
2228 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002229 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002230 chnl_switch_info, session_entry);
2231 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05302232 PHY_SINGLE_CHANNEL_CENTERED;
2233 if (chnl_switch_info->newChanWidth) {
2234 if (csa_params->channel <
2235 csa_params->new_ch_freq_seg1)
2236 lim_ch_switch->sec_ch_offset =
2237 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2238 else
2239 lim_ch_switch->sec_ch_offset =
2240 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2241 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002242 } else if (csa_params->ies_present_flag
2243 & lim_xcsa_ie_present) {
2244 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002245 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002246 mac_ctx->scan.countryCodeCurrent,
2247 csa_params->channel,
2248 csa_params->new_op_class);
2249 session_entry->gLimChannelSwitch.state =
2250 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2251
2252 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002254 CH_WIDTH_80MHZ;
2255 } else if (chan_space == 40) {
2256 chnl_switch_info->newChanWidth =
2257 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002259 chnl_switch_info->newChanWidth =
2260 CH_WIDTH_20MHZ;
2261 lim_ch_switch->state =
2262 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2263 }
2264
2265 ch_params.ch_width =
2266 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002267 wlan_reg_set_channel_params(mac_ctx->pdev,
2268 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002269 chnl_switch_info->newCenterChanFreq0 =
2270 ch_params.center_freq_seg0;
2271 /*
2272 * This is not applicable for 20/40/80 MHz.
2273 * Only used when we support 80+80 MHz operation.
2274 * In case of 80+80 MHz, this parameter indicates
2275 * center channel frequency index of 80 MHz
2276 * channel offrequency segment 1.
2277 */
2278 chnl_switch_info->newCenterChanFreq1 =
2279 ch_params.center_freq_seg1;
2280 lim_ch_switch->sec_ch_offset =
2281 ch_params.sec_ch_offset;
2282
2283 }
2284 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2285 chnl_switch_info->newCenterChanFreq0;
2286 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2287 chnl_switch_info->newCenterChanFreq1;
2288 session_entry->gLimChannelSwitch.ch_width =
2289 chnl_switch_info->newChanWidth;
2290
2291 } else if (session_entry->htSupportedChannelWidthSet) {
2292 if (csa_params->ies_present_flag
2293 & lim_xcsa_ie_present) {
2294 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002295 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002296 mac_ctx->scan.countryCodeCurrent,
2297 csa_params->channel,
2298 csa_params->new_op_class);
2299 lim_ch_switch->state =
2300 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2301 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002302 lim_ch_switch->ch_width =
2303 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002304 chnl_switch_info->newChanWidth =
2305 CH_WIDTH_40MHZ;
2306 ch_params.ch_width =
2307 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002308 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002309 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002310 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002311 lim_ch_switch->ch_center_freq_seg0 =
2312 ch_params.center_freq_seg0;
2313 lim_ch_switch->sec_ch_offset =
2314 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002315 } else {
2316 lim_ch_switch->ch_width =
2317 CH_WIDTH_20MHZ;
2318 chnl_switch_info->newChanWidth =
2319 CH_WIDTH_40MHZ;
2320 lim_ch_switch->state =
2321 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2322 lim_ch_switch->sec_ch_offset =
2323 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002325 } else {
2326 lim_ch_switch->ch_width =
2327 CH_WIDTH_40MHZ;
2328 lim_ch_switch->state =
2329 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2330 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002331 wlan_reg_set_channel_params(mac_ctx->pdev,
2332 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002333 lim_ch_switch->ch_center_freq_seg0 =
2334 ch_params.center_freq_seg0;
2335 lim_ch_switch->sec_ch_offset =
2336 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002338
2339 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302340 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302341 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002342 if ((session_entry->currentOperChannel == csa_params->channel) &&
2343 (session_entry->ch_width ==
2344 session_entry->gLimChannelSwitch.ch_width)) {
2345 pe_debug("Ignore CSA, no change in ch and bw");
2346 goto err;
2347 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002349 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2350 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2351 if (NULL == csa_offload_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302352 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002353 goto err;
2354 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002356 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2357 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2358 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2359 QDF_MAC_ADDR_SIZE);
2360 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2361 mmh_msg.bodyptr = csa_offload_ind;
2362 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302363 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002364 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2366#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002367 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2369 eSIR_SUCCESS, eSIR_SUCCESS);
2370#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002371 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372
2373err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302374 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375}
2376
2377/*--------------------------------------------------------------------------
2378 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2379
2380 \param pMac - pointer to global adapter context
2381 \param sessionId - Message pointer.
2382
2383 \sa
2384 --------------------------------------------------------------------------*/
2385
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002386void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387{
2388 tpPESession psessionEntry;
2389 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2390
2391 psessionEntry =
2392 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2393 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302394 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002396 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 return;
2398 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002399 /*
2400 * During DEL BSS handling, the PE Session will be deleted, but it is
2401 * better to clear this flag if the session is hanging around due
2402 * to some error conditions so that the next DEL_BSS request does
2403 * not take the HO_FAIL path
2404 */
2405 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002406 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002408 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002410 else if (LIM_IS_NDI_ROLE(psessionEntry))
2411 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 else
2413 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2414
2415}
2416
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417/** -----------------------------------------------------------------
2418 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2419 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2420 \ SME only looks at rc and tspec field.
2421 \param pMac - global mac structure
2422 \param rspReqd - is SmeAddTsRsp required
2423 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2424 \return tspec
2425 \sa
2426 ----------------------------------------------------------------- */
2427void
2428lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2429 uint8_t smesessionId)
2430{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002431 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432
2433 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2434 mmhMsg.bodyptr = aggrQosRsp;
2435 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302436 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2437 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2439
2440 return;
2441}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442
2443void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2444 uint8_t smesessionId)
2445{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002446 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 tSmeMaxAssocInd *pSmeMaxAssocInd;
2448
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302449 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302451 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 return;
2453 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302454 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302455 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2457 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2458 pSmeMaxAssocInd->sessionId = smesessionId;
2459 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2460 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302461 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2462 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2463 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302464 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2465 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2467
2468 return;
2469}
2470
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471/*--------------------------------------------------------------------------
2472 \brief lim_send_dfs_chan_sw_ie_update()
2473 This timer handler updates the channel switch IE in beacon template
2474
2475 \param pMac - pointer to global adapter context
2476 \return - channel to scan from valid session else zero.
2477 \sa
2478 --------------------------------------------------------------------------*/
2479static void
2480lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2481{
2482
2483 /* Update the beacon template and send to FW */
2484 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302485 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 return;
2487 }
2488
2489 /* Send update beacon template message */
2490 lim_send_beacon_ind(pMac, psessionEntry);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302491 pe_debug("Updated CSA IE, IE COUNT: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 psessionEntry->gLimChannelSwitch.switchCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493
2494 return;
2495}
2496
2497/** -----------------------------------------------------------------
2498 \brief lim_send_sme_ap_channel_switch_resp() - sends
2499 eWNI_SME_CHANNEL_CHANGE_RSP
2500 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2501 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2502 that the Channel change has been done to the specified target
2503 channel in the Channel change request
2504 \param pMac - global mac structure
2505 \param psessionEntry - session info
2506 \param pChnlParams - Channel switch params
2507 --------------------------------------------------------------------*/
2508void
2509lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2510 tpPESession psessionEntry,
2511 tpSwitchChannelParams pChnlParams)
2512{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002513 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 tpSwitchChannelParams pSmeSwithChnlParams;
2515 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002516 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002517 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002518 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519
2520 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302521 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302523 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524 return;
2525 }
2526
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302527 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 sizeof(tSwitchChannelParams));
2529
2530 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002531 ch_width = pSmeSwithChnlParams->ch_width;
2532 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533
2534 /*
2535 * Pass the sme sessionID to SME instead
2536 * PE session ID.
2537 */
2538 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2539
2540 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2541 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2542 mmhMsg.bodyval = 0;
2543 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2544
2545 /*
2546 * We should start beacon transmission only if the new
2547 * channel after channel change is Non-DFS. For a DFS
2548 * channel, PE will receive an explicit request from
2549 * upper layers to start the beacon transmission .
2550 */
2551
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002552 if (ch_width == CH_WIDTH_160MHZ) {
2553 is_ch_dfs = true;
2554 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002555 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2556 CHANNEL_STATE_DFS ||
2557 wlan_reg_get_channel_state(pMac->pdev,
2558 ch_center_freq_seg1 -
2559 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002560 CHANNEL_STATE_DFS)
2561 is_ch_dfs = true;
2562 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002563 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2564 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002565 is_ch_dfs = true;
2566 }
2567
2568 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 if (channelId == psessionEntry->currentOperChannel) {
2570 lim_apply_configuration(pMac, psessionEntry);
2571 lim_send_beacon_ind(pMac, psessionEntry);
2572 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302573 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 }
2576 }
2577 return;
2578}
2579
Peng Xu6363ec62017-05-15 11:06:33 -07002580#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2581/**
2582 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2583 * beacon template
2584 *
2585 * @mac_ctx: pointer to global adapter context
2586 * @session: session pointer
2587 *
2588 * Return: none
2589 */
2590static void
2591lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2592 tpPESession session)
2593{
2594 /* Update the beacon template and send to FW */
2595 if (sch_set_fixed_beacon_fields(mac_ctx, session) != eSIR_SUCCESS) {
2596 pe_err("Unable to set BSS color change IE in beacon");
2597 return;
2598 }
2599
2600 /* Send update beacon template message */
2601 lim_send_beacon_ind(mac_ctx, session);
2602 pe_info("Updated BSS color change countdown = %d",
2603 session->he_bss_color_change.countdown);
2604}
2605
2606static void
2607lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2608 tpPESession session)
2609{
2610 /* handle bss color change IE */
2611 if (LIM_IS_AP_ROLE(session) &&
2612 session->he_op.bss_col_disabled) {
2613 if (session->he_bss_color_change.countdown > 0) {
2614 session->he_bss_color_change.countdown--;
2615 } else {
2616 session->bss_color_changing = 0;
2617 if (session->he_bss_color_change.new_color != 0)
2618 session->he_op.bss_col_disabled = 0;
2619 }
2620
2621 lim_send_bss_color_change_ie_update(mac_ctx, session);
2622 }
2623}
2624
2625#else
2626static void
2627lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2628 tpPESession session)
2629{
2630}
2631#endif
2632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633/** -----------------------------------------------------------------
2634 \brief lim_process_beacon_tx_success_ind() - This function is used
2635 explicitely to handle successful beacon transmission indication
2636 from the FW. This is a generic event generated by the FW afer the
2637 first beacon is sent out after the beacon template update by the
2638 host
2639 \param pMac - global mac structure
2640 \param psessionEntry - session info
2641 \return none
2642 \sa
2643 ----------------------------------------------------------------- */
2644void
2645lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2646{
2647 /* Currently, this event is used only for DFS channel switch announcement
2648 * IE update in the template. If required to be used for other IE updates
2649 * add appropriate code by introducing a state variable
2650 */
2651 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002652 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2654 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2655 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2656 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2657 (tSirFirstBeaconTxCompleteInd *) event;
2658
2659 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2660 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302661 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 return;
2663 }
2664
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302665 pe_debug("role: %d swIe: %d opIe: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302666 GET_LIM_SYSTEM_ROLE(psessionEntry),
2667 psessionEntry->dfsIncludeChanSwIe,
2668 psessionEntry->gLimOperatingMode.present);
2669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 if (LIM_IS_AP_ROLE(psessionEntry) &&
2671 true == psessionEntry->dfsIncludeChanSwIe) {
2672 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2673 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2674 /*
2675 * Send the next beacon with updated CSA IE count
2676 */
2677 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2678 /* Decrement the IE count */
2679 psessionEntry->gLimChannelSwitch.switchCount--;
2680 } else {
2681 /* Done with CSA IE update, send response back to SME */
2682 psessionEntry->gLimChannelSwitch.switchCount = 0;
2683 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2684 psessionEntry->gLimChannelSwitch.switchMode = 0;
2685 psessionEntry->dfsIncludeChanSwIe = false;
2686 psessionEntry->dfsIncludeChanWrapperIe = false;
2687
2688 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302689 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690
2691 if (NULL == pChanSwTxResponse) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302692 pe_err("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 return;
2694 }
2695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 pChanSwTxResponse->sessionId =
2697 psessionEntry->smeSessionId;
2698 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302699 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700
2701 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2702 mmhMsg.bodyptr = pChanSwTxResponse;
2703 mmhMsg.bodyval = 0;
2704 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2705 }
2706 }
2707
2708 if (LIM_IS_AP_ROLE(psessionEntry) &&
2709 psessionEntry->gLimOperatingMode.present) {
2710 /* Done with nss update, send response back to SME */
2711 psessionEntry->gLimOperatingMode.present = 0;
2712 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302713 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302715 pe_err("AllocateMemory failed for beacon_tx_comp_rsp_ptr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 return;
2717 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 beacon_tx_comp_rsp_ptr->session_id =
2719 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302720 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2722 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2723 mmhMsg.bodyval = 0;
2724 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2725 }
Peng Xu6363ec62017-05-15 11:06:33 -07002726
2727 lim_handle_bss_color_change_ie(pMac, psessionEntry);
2728
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 return;
2730}