blob: 78ccb8967d007dcb008a3f651e188e491d3d5583 [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070063#ifdef CONVERGED_TDLS_ENABLE
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070064#include "wlan_tdls_tgt_api.h"
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070065#endif
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
68 tpPESession session_entry, tSirResultCodes result_code,
69 tpSirSmeJoinRsp sme_join_rsp);
70
71/**
72 * lim_send_sme_rsp() - Send Response to upper layers
73 * @mac_ctx: Pointer to Global MAC structure
74 * @msg_type: Indicates message type
75 * @result_code: Indicates the result of previously issued
76 * eWNI_SME_msg_type_REQ message
77 *
78 * This function is called by lim_process_sme_req_messages() to send
79 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
80 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
81 * Software.
82 *
83 * Return: None
84 */
85
86void
87lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
88 tSirResultCodes result_code, uint8_t sme_session_id,
89 uint16_t sme_transaction_id)
90{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070091 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092 tSirSmeRsp *sme_rsp;
93
94 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
95 lim_msg_str(msg_type), lim_result_code_str(result_code));
96
Anurag Chouhan600c3a02016-03-01 10:33:54 +053097 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098 if (NULL == sme_rsp) {
99 /* Buffer not available. Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530100 QDF_TRACE(QDF_MODULE_ID_PE, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
102 return;
103 }
104
105 sme_rsp->messageType = msg_type;
106 sme_rsp->length = sizeof(tSirSmeRsp);
107 sme_rsp->statusCode = result_code;
108
109 sme_rsp->sessionId = sme_session_id;
110 sme_rsp->transactionId = sme_transaction_id;
111
112 msg.type = msg_type;
113 msg.bodyptr = sme_rsp;
114 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530115 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
116 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117
118#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
119 switch (msg_type) {
120 case eWNI_SME_STOP_BSS_RSP:
121 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
122 NULL, (uint16_t) result_code, 0);
123 break;
124 }
125#endif /* FEATURE_WLAN_DIAG_SUPPORT */
126 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
127}
128
129
130
131/**
132 * lim_send_sme_roc_rsp() - Send Response to SME
133 * @mac_ctx: Pointer to Global MAC structure
134 * @status: Resume link status
135 * @result_code: Result of the ROC request
136 * @sme_session_id: SME sesson Id
137 * @scan_id: Scan Identifier
138 *
139 * This function is called to send ROC rsp
140 * message to SME.
141 *
142 * Return: None
143 */
144void
145lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
146 tSirResultCodes result_code, uint8_t sme_session_id,
147 uint32_t scan_id)
148{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700149 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150 struct sir_roc_rsp *sme_rsp;
151
152 lim_log(mac_ctx, LOG1,
153 FL("Sending message %s with reasonCode %s scanId %d"),
154 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 Aggarwald5941bb2017-03-11 14:41:24 +0530159 QDF_TRACE(QDF_MODULE_ID_PE, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
161 return;
162 }
163
164 sme_rsp->message_type = msg_type;
165 sme_rsp->length = sizeof(struct sir_roc_rsp);
166 sme_rsp->status = result_code;
167
168 sme_rsp->session_id = sme_session_id;
169 sme_rsp->scan_id = scan_id;
170
171 msg.type = msg_type;
172 msg.bodyptr = sme_rsp;
173 msg.bodyval = 0;
174 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
175 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
176}
177
178
179/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530180 * lim_get_max_rate_flags() - Get rate flags
181 * @mac_ctx: Pointer to global MAC structure
182 * @sta_ds: Pointer to station ds structure
183 *
184 * This function is called to get the rate flags for a connection
185 * from the station ds structure depending on the ht and the vht
186 * channel width supported.
187 *
188 * Return: Returns the populated rate_flags
189 */
190uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
191{
192 uint32_t rate_flags = 0;
193
194 if (sta_ds == NULL) {
195 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
196 return rate_flags;
197 }
198
199 if (!sta_ds->mlmStaContext.htCapability &&
200 !sta_ds->mlmStaContext.vhtCapability) {
201 rate_flags |= eHAL_TX_RATE_LEGACY;
202 } else {
203 if (sta_ds->mlmStaContext.vhtCapability) {
204 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
205 sta_ds->vhtSupportedChannelWidthSet) {
206 rate_flags |= eHAL_TX_RATE_VHT80;
207 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
208 sta_ds->vhtSupportedChannelWidthSet) {
209 if (sta_ds->htSupportedChannelWidthSet)
210 rate_flags |= eHAL_TX_RATE_VHT40;
211 else
212 rate_flags |= eHAL_TX_RATE_VHT20;
213 }
214 } else if (sta_ds->mlmStaContext.htCapability) {
215 if (sta_ds->htSupportedChannelWidthSet)
216 rate_flags |= eHAL_TX_RATE_HT40;
217 else
218 rate_flags |= eHAL_TX_RATE_HT20;
219 }
220 }
221
222 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
223 rate_flags |= eHAL_TX_RATE_SGI;
224
225 return rate_flags;
226}
227
228/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
230 * @mac_ctx Pointer to Global MAC structure
231 * @status Resume link status
232 * @ctx context passed while calling resmune link.
233 * (join response to be sent)
234 *
235 * This function is called to send Join/Reassoc rsp
236 * message to SME after the resume link.
237 *
238 * Return: None
239 */
240static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530241 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700243 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
245
246 msg.type = sme_join_rsp->messageType;
247 msg.bodyptr = sme_join_rsp;
248 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530249 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
251}
252
253/**
254 * lim_handle_join_rsp_status() - Handle the response.
255 * @mac_ctx: Pointer to Global MAC structure
256 * @session_entry: PE Session Info
257 * @result_code: Indicates the result of previously issued
258 * eWNI_SME_msgType_REQ message
259 * @sme_join_rsp The received response.
260 *
261 * This function will handle both the success and failure status
262 * of the received response.
263 *
264 * Return: None
265 */
266static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
267 tpPESession session_entry, tSirResultCodes result_code,
268 tpSirSmeJoinRsp sme_join_rsp)
269{
270#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
271 tSirSmeHTProfile *ht_profile;
272#endif
273 if (result_code == eSIR_SME_SUCCESS) {
274 if (session_entry->beacon != NULL) {
275 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530276 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 session_entry->beacon,
278 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530279 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800280 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530281 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282 lim_log(mac_ctx, LOG1, FL("Beacon=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530283 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 }
285 if (session_entry->assocReq != NULL) {
286 sme_join_rsp->assocReqLength =
287 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530288 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530289 sme_join_rsp->beaconLength,
290 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530292 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800293 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530294 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 lim_log(mac_ctx,
296 LOG1, FL("AssocReq=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530297 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 }
299 if (session_entry->assocRsp != NULL) {
300 sme_join_rsp->assocRspLength =
301 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530302 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530303 sme_join_rsp->beaconLength +
304 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 session_entry->assocRsp,
306 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530307 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530309 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 if (session_entry->ricData != NULL) {
312 sme_join_rsp->parsedRicRspLen =
313 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530314 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530315 sme_join_rsp->beaconLength +
316 sme_join_rsp->assocReqLength +
317 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800318 session_entry->ricData,
319 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530320 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530322 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 lim_log(mac_ctx, LOG1, FL("RicLength=%d"),
324 sme_join_rsp->parsedRicRspLen);
325 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326#ifdef FEATURE_WLAN_ESE
327 if (session_entry->tspecIes != NULL) {
328 sme_join_rsp->tspecIeLen =
329 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530330 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530331 sme_join_rsp->beaconLength +
332 sme_join_rsp->assocReqLength +
333 sme_join_rsp->assocRspLength +
334 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 session_entry->tspecIes,
336 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530337 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530339 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 lim_log(mac_ctx, LOG1, FL("ESE-TspecLen=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530341 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 }
343#endif
344 sme_join_rsp->aid = session_entry->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 lim_log(mac_ctx, LOG1, FL("AssocRsp=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530346 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347 sme_join_rsp->vht_channel_width =
348 session_entry->ch_width;
349#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
350 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530351 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352 ht_profile = &sme_join_rsp->HTProfile;
353 ht_profile->htSupportedChannelWidthSet =
354 session_entry->htSupportedChannelWidthSet;
355 ht_profile->htRecommendedTxWidthSet =
356 session_entry->htRecommendedTxWidthSet;
357 ht_profile->htSecondaryChannelOffset =
358 session_entry->htSecondaryChannelOffset;
359 ht_profile->dot11mode = session_entry->dot11mode;
360 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361 ht_profile->vhtCapability =
362 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
364 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 }
366#endif
367 } else {
368 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530369 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800370 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530371 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 }
373 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530374 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530376 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 }
378 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530379 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530381 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530384 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530386 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388#ifdef FEATURE_WLAN_ESE
389 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530390 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530392 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393 }
394#endif
395 }
396}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530397
398/**
399 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530400 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530401 * @sme_join_rsp: Join response buffer to be filled up
402 *
403 * Return: None
404 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700405static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530406{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530407 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
408
409 if (parsed_ies->hs20vendor_ie.present)
410 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
411 if (parsed_ies->vht_caps.present)
412 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
413 if (parsed_ies->ht_caps.present)
414 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
415 if (parsed_ies->ht_operation.present)
416 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
417 if (parsed_ies->vht_operation.present)
418 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530419}
420
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421/**
422 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
423 * @mac_ctx: Pointer to Global MAC structure
424 * @msg_type: Indicates message type
425 * @result_code: Indicates the result of previously issued
426 * eWNI_SME_msgType_REQ message
427 * @prot_status_code: Protocol Status Code
428 * @session_entry: PE Session Info
429 * @sme_session_id: SME Session ID
430 * @sme_transaction_id: SME Transaction ID
431 *
432 * This function is called by lim_process_sme_req_messages() to send
433 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
434 * above MAC Software.
435 *
436 * Return: None
437 */
438
439void
440lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
441 tSirResultCodes result_code, uint16_t prot_status_code,
442 tpPESession session_entry, uint8_t sme_session_id,
443 uint16_t sme_transaction_id)
444{
445 tpSirSmeJoinRsp sme_join_rsp;
446 uint32_t rsp_len;
447 tpDphHashNode sta_ds = NULL;
448#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
449 if (msg_type == eWNI_SME_REASSOC_RSP)
450 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
451 session_entry, (uint16_t) result_code, 0);
452 else
453 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
454 session_entry, (uint16_t) result_code, 0);
455#endif /* FEATURE_WLAN_DIAG_SUPPORT */
456
457 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
458 lim_msg_str(msg_type), lim_result_code_str(result_code));
459
460 if (session_entry == NULL) {
461 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530462 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463 if (NULL == sme_join_rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530464 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 FL("Mem Alloc fail - JOIN/REASSOC_RSP"));
466 return;
467 }
468
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469 sme_join_rsp->beaconLength = 0;
470 sme_join_rsp->assocReqLength = 0;
471 sme_join_rsp->assocRspLength = 0;
472 } else {
473 rsp_len = session_entry->assocReqLen +
474 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476#ifdef FEATURE_WLAN_ESE
477 session_entry->tspecLen +
478#endif
479 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530480 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481 if (NULL == sme_join_rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530482 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
484 return;
485 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 if (result_code == eSIR_SME_SUCCESS) {
487 sta_ds = dph_get_hash_entry(mac_ctx,
488 DPH_STA_HASH_INDEX_PEER,
489 &session_entry->dph.dphHashTable);
490 if (sta_ds == NULL) {
491 lim_log(mac_ctx, LOGE,
492 FL("Get Self Sta Entry fail"));
493 } else {
494 /* Pass the peer's staId */
495 sme_join_rsp->staId = sta_ds->staIndex;
496 sme_join_rsp->ucastSig =
497 sta_ds->ucUcastSig;
498 sme_join_rsp->bcastSig =
499 sta_ds->ucBcastSig;
500 sme_join_rsp->timingMeasCap =
501 sta_ds->timingMeasCap;
502#ifdef FEATURE_WLAN_TDLS
503 sme_join_rsp->tdls_prohibited =
504 session_entry->tdls_prohibited;
505 sme_join_rsp->tdls_chan_swit_prohibited =
506 session_entry->tdls_chan_swit_prohibited;
507#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530508 sme_join_rsp->nss = sta_ds->nss;
509 sme_join_rsp->max_rate_flags =
510 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530511 lim_add_bss_info(sta_ds, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512 }
513 }
514 sme_join_rsp->beaconLength = 0;
515 sme_join_rsp->assocReqLength = 0;
516 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800518#ifdef FEATURE_WLAN_ESE
519 sme_join_rsp->tspecIeLen = 0;
520#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
522 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800523
524 /* Send supported NSS 1x1 to SME */
525 sme_join_rsp->supported_nss_1x1 =
526 session_entry->supported_nss_1x1;
527 lim_log(mac_ctx, LOG1,
528 FL("SME Join Rsp is supported NSS 1X1: %d"),
529 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 }
531
532 sme_join_rsp->messageType = msg_type;
533 sme_join_rsp->length = (uint16_t) rsp_len;
534 sme_join_rsp->statusCode = result_code;
535 sme_join_rsp->protStatusCode = prot_status_code;
536
537 sme_join_rsp->sessionId = sme_session_id;
538 sme_join_rsp->transactionId = sme_transaction_id;
539
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530540 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541 (uint32_t *)sme_join_rsp);
542}
543
544/**
545 * lim_send_sme_start_bss_rsp()
546 *
547 ***FUNCTION:
548 * This function is called to send eWNI_SME_START_BSS_RSP
549 * message to applications above MAC Software.
550 *
551 ***PARAMS:
552 *
553 ***LOGIC:
554 *
555 ***ASSUMPTIONS:
556 * NA
557 *
558 ***NOTE:
559 * NA
560 *
561 * @param pMac Pointer to Global MAC structure
562 * @param msgType Indicates message type
563 * @param resultCode Indicates the result of previously issued
564 * eWNI_SME_msgType_REQ message
565 *
566 * @return None
567 */
568
569void
570lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
571 uint16_t msgType, tSirResultCodes resultCode,
572 tpPESession psessionEntry, uint8_t smesessionId,
573 uint16_t smetransactionId)
574{
575
576 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700577 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 tSirSmeStartBssRsp *pSirSmeRsp;
579 uint16_t ieLen;
580 uint16_t ieOffset, curLen;
581
582 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
583 lim_msg_str(msgType), lim_result_code_str(resultCode));
584 )
585
586 size = sizeof(tSirSmeStartBssRsp);
587
588 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530589 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 if (NULL == pSirSmeRsp) {
591 /* / Buffer not available. Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530592 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 FL
594 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
595 return;
596 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 } else {
598 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
599 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
600 ieLen = psessionEntry->schBeaconOffsetBegin
601 + psessionEntry->schBeaconOffsetEnd - ieOffset;
602 /* calculate the memory size to allocate */
603 size += ieLen;
604
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530605 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800606 if (NULL == pSirSmeRsp) {
607 /* / Buffer not available. Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530608 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 FL
610 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
611
612 return;
613 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 size = sizeof(tSirSmeStartBssRsp);
615 if (resultCode == eSIR_SME_SUCCESS) {
616
617 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
618 psessionEntry->bssId);
619
620 /* Read beacon interval from session */
621 pSirSmeRsp->bssDescription.beaconInterval =
622 (uint16_t) psessionEntry->beaconParams.
623 beaconInterval;
624 pSirSmeRsp->bssType = psessionEntry->bssType;
625
626 if (cfg_get_capability_info
627 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
628 psessionEntry)
629 != eSIR_SUCCESS)
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530630 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 FL
632 ("could not retrieve Capabilities value"));
633
634 lim_get_phy_mode(pMac,
635 (uint32_t *) &pSirSmeRsp->bssDescription.
636 nwType, psessionEntry);
637
638 pSirSmeRsp->bssDescription.channelId =
639 psessionEntry->currentOperChannel;
640
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700641 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530643 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 ieFields,
645 psessionEntry->pSchBeaconFrameBegin +
646 ieOffset, (uint32_t) curLen);
647
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530648 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 ieFields) + curLen,
650 psessionEntry->pSchBeaconFrameEnd,
651 (uint32_t) psessionEntry->
652 schBeaconOffsetEnd);
653
Abhishek Singh34a4d862016-10-26 16:01:51 +0530654 pSirSmeRsp->bssDescription.length = (uint16_t)
655 (offsetof(tSirBssDescription, ieFields[0])
656 - sizeof(pSirSmeRsp->bssDescription.length)
657 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 /* This is the size of the message, subtracting the size of the pointer to ieFields */
659 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700660 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
662 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530663 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664 pSirSmeRsp->HTProfile.
665 htSupportedChannelWidthSet =
666 psessionEntry->htSupportedChannelWidthSet;
667 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
668 psessionEntry->htRecommendedTxWidthSet;
669 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
670 psessionEntry->htSecondaryChannelOffset;
671 pSirSmeRsp->HTProfile.dot11mode =
672 psessionEntry->dot11mode;
673 pSirSmeRsp->HTProfile.htCapability =
674 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 pSirSmeRsp->HTProfile.vhtCapability =
676 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 pSirSmeRsp->HTProfile.apCenterChan =
678 psessionEntry->ch_center_freq_seg0;
679 pSirSmeRsp->HTProfile.apChanWidth =
680 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 }
682#endif
683 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685 pSirSmeRsp->messageType = msgType;
686 pSirSmeRsp->length = size;
687
688 /* Update SME session Id and transaction Id */
689 pSirSmeRsp->sessionId = smesessionId;
690 pSirSmeRsp->transactionId = smetransactionId;
691 pSirSmeRsp->statusCode = resultCode;
692 if (psessionEntry != NULL)
693 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
694
695 mmhMsg.type = msgType;
696 mmhMsg.bodyptr = pSirSmeRsp;
697 mmhMsg.bodyval = 0;
698 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530699 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
700 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530702 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
703 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 }
705#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
706 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
707 psessionEntry, (uint16_t) resultCode, 0);
708#endif /* FEATURE_WLAN_DIAG_SUPPORT */
709
710 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
711} /*** end lim_send_sme_start_bss_rsp() ***/
712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713/**
714 * lim_send_sme_scan_rsp() - Send scan response to SME
715 * @pMac: Pointer to Global MAC structure
716 * @length: Indicates length of message
717 * @resultCode: Indicates the result of previously issued
718 * eWNI_SME_SCAN_REQ message
719 * @scan_id: scan identifier
720 *
721 * This function is called by lim_process_sme_req_messages() to send
722 * eWNI_SME_SCAN_RSP message to applications above MAC
723 *
724 * return: None
725 */
726
727void
728lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
729 uint8_t smesessionId, uint16_t smetranscationId,
730 uint32_t scan_id)
731{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
733 smetranscationId, scan_id);
734}
735
736/**
737 * lim_post_sme_scan_rsp_message()
738 *
739 ***FUNCTION:
740 * This function is called by lim_send_sme_scan_rsp() to send
741 * eWNI_SME_SCAN_RSP message with failed result code
742 *
743 ***NOTE:
744 * NA
745 *
746 * @param pMac Pointer to Global MAC structure
747 * @param length Indicates length of message
748 * @param resultCode failed result code
749 *
750 * @return None
751 */
752
753void
754lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
755 tSirResultCodes resultCode, uint8_t smesessionId,
756 uint16_t smetransactionId,
757 uint32_t scan_id)
758{
759 tpSirSmeScanRsp pSirSmeScanRsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700760 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761
762 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
763 lim_result_code_str(resultCode));
764
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530765 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 if (NULL == pSirSmeScanRsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530767 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
769 return;
770 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771
772 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
773 pSirSmeScanRsp->statusCode = resultCode;
774
775 /*Update SME session Id and transaction Id */
776 pSirSmeScanRsp->sessionId = smesessionId;
777 pSirSmeScanRsp->transcationId = smetransactionId;
778 pSirSmeScanRsp->scan_id = scan_id;
779
780 mmhMsg.type = eWNI_SME_SCAN_RSP;
781 mmhMsg.bodyptr = pSirSmeScanRsp;
782 mmhMsg.bodyval = 0;
783
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530784 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
786 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
787 (uint16_t) resultCode, 0);
788#endif /* FEATURE_WLAN_DIAG_SUPPORT */
789
790 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
791 return;
792
793} /*** lim_post_sme_scan_rsp_message ***/
794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530796 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700798 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800799 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800
801 mmhMsg.type = pMsg->type;
802 mmhMsg.bodyptr = pMsg;
803 mmhMsg.bodyval = 0;
804
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530805 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806
807 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
808}
809
810/**
811 * lim_send_sme_disassoc_ntf()
812 *
813 ***FUNCTION:
814 * This function is called by limProcessSmeMessages() to send
815 * eWNI_SME_DISASSOC_RSP/IND message to host
816 *
817 ***PARAMS:
818 *
819 ***LOGIC:
820 *
821 ***ASSUMPTIONS:
822 * NA
823 *
824 ***NOTE:
825 * This function is used for sending eWNI_SME_DISASSOC_CNF,
826 * or eWNI_SME_DISASSOC_IND to host depending on
827 * disassociation trigger.
828 *
829 * @param peerMacAddr Indicates the peer MAC addr to which
830 * disassociate was initiated
831 * @param reasonCode Indicates the reason for Disassociation
832 * @param disassocTrigger Indicates the trigger for Disassociation
833 * @param aid Indicates the STAID. This parameter is
834 * present only on AP.
835 *
836 * @return None
837 */
838void
839lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
840 tSirMacAddr peerMacAddr,
841 tSirResultCodes reasonCode,
842 uint16_t disassocTrigger,
843 uint16_t aid,
844 uint8_t smesessionId,
845 uint16_t smetransactionId, tpPESession psessionEntry)
846{
847
848 uint8_t *pBuf;
849 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
850 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700851 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700853 tpPESession session = NULL;
854 uint16_t i, assoc_id;
855 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530856 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857
858 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
859 disassocTrigger, reasonCode);
860
861 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700862 case eLIM_DUPLICATE_ENTRY:
863 /*
864 * Duplicate entry is removed at LIM.
865 * Initiate new entry for other session
866 */
867 lim_log(pMac, LOG1,
868 FL("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR),
869 MAC_ADDR_ARRAY(peerMacAddr));
870
871 for (i = 0; i < pMac->lim.maxBssId; i++) {
872 if ((&pMac->lim.gpSession[i] != NULL) &&
873 (pMac->lim.gpSession[i].valid) &&
874 (pMac->lim.gpSession[i].pePersona ==
875 QDF_SAP_MODE)) {
876 /* Find the sta ds entry in another session */
877 session = &pMac->lim.gpSession[i];
878 sta_ds = dph_lookup_hash_entry(pMac,
879 peerMacAddr, &assoc_id,
880 &session->dph.dphHashTable);
881 }
882 }
883 if (sta_ds
884#ifdef WLAN_FEATURE_11W
885 && (!sta_ds->rmfEnabled)
886#endif
887 ) {
888 if (lim_add_sta(pMac, sta_ds, false, session) !=
889 eSIR_SUCCESS)
890 lim_log(pMac, LOGE,
891 FL("could not Add STA with assocId=%d"),
892 sta_ds->assocId);
893 }
894 failure = true;
895 break;
896
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 case eLIM_HOST_DISASSOC:
898 /**
899 * Disassociation response due to
900 * host triggered disassociation
901 */
902
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530903 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 if (NULL == pSirSmeDisassocRsp) {
905 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530906 lim_log(pMac, LOGE, FL("Memory allocation failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 failure = true;
908 goto error;
909 }
910 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
911 "retCode: %d for " MAC_ADDRESS_STR),
912 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
913 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
914 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
915 /* sessionId */
916 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
917 *pBuf = smesessionId;
918 pBuf++;
919
920 /* transactionId */
921 lim_copy_u16(pBuf, smetransactionId);
922 pBuf += sizeof(uint16_t);
923
924 /* statusCode */
925 lim_copy_u32(pBuf, reasonCode);
926 pBuf += sizeof(tSirResultCodes);
927
928 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530929 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 pBuf += sizeof(tSirMacAddr);
931
932 /* Clear Station Stats */
933 /* for sta, it is always 1, IBSS is handled at halInitSta */
934
935#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
936
937 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
938 psessionEntry, (uint16_t) reasonCode, 0);
939#endif
940 pMsg = (uint32_t *) pSirSmeDisassocRsp;
941 break;
942
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530943 case eLIM_PEER_ENTITY_DISASSOC:
944 case eLIM_LINK_MONITORING_DISASSOC:
945 sir_sme_dis_ind =
946 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
947 if (!sir_sme_dis_ind) {
948 lim_log(pMac, LOGE,
949 FL("call to AllocateMemory failed for disconnect indication"));
950 return;
951 }
952
953 lim_log(pMac, LOG1,
954 FL("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d"),
955 reasonCode);
956
957 sir_sme_dis_ind->message_type =
958 eWNI_SME_DISCONNECT_DONE_IND;
959 sir_sme_dis_ind->length =
960 sizeof(*sir_sme_dis_ind);
961 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
962 sizeof(tSirMacAddr));
963 sir_sme_dis_ind->session_id = smesessionId;
964 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +0530965 /*
966 * Instead of sending deauth reason code as 505 which is
967 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
968 * Send reason code as zero to Supplicant
969 */
970 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
971 sir_sme_dis_ind->reason_code = 0;
972 else
973 sir_sme_dis_ind->reason_code = reasonCode;
974
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530975 pMsg = (uint32_t *)sir_sme_dis_ind;
976
977 break;
978
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 default:
980 /**
981 * Disassociation indication due to Disassociation
982 * frame reception from peer entity or due to
983 * loss of link with peer entity.
984 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530985 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 if (NULL == pSirSmeDisassocInd) {
987 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530988 lim_log(pMac, LOGE, FL("Memory allocation failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 failure = true;
990 goto error;
991 }
992 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
993 "retCode: %d for " MAC_ADDRESS_STR),
994 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
995 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
996 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
997
998 /* Update SME session Id and Transaction Id */
999 pSirSmeDisassocInd->sessionId = smesessionId;
1000 pSirSmeDisassocInd->transactionId = smetransactionId;
1001 pSirSmeDisassocInd->reasonCode = reasonCode;
1002 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1003
1004 lim_copy_u32(pBuf, reasonCode);
1005 pBuf += sizeof(tSirResultCodes);
1006
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301007 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 pBuf += sizeof(tSirMacAddr);
1009
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301010 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011
1012#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1013 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1014 psessionEntry, (uint16_t) reasonCode, 0);
1015#endif
1016 pMsg = (uint32_t *) pSirSmeDisassocInd;
1017
1018 break;
1019 }
1020
1021error:
1022 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001023 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025
1026 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301027 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 (uint32_t *) pMsg);
1029} /*** end lim_send_sme_disassoc_ntf() ***/
1030
1031/** -----------------------------------------------------------------
1032 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1033
1034 After receiving disassociation frame from peer entity, this
1035 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1036 reason code.
1037
1038 \param pMac - global mac structure
1039 \param pStaDs - station dph hash node
1040 \return none
1041 \sa
1042 ----------------------------------------------------------------- */
1043void
1044lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1045 tpPESession psessionEntry)
1046{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001047 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 tSirSmeDisassocInd *pSirSmeDisassocInd;
1049
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301050 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301052 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1054 return;
1055 }
1056
1057 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1058 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1059
1060 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1061 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301062 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1064
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301065 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301066 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301068 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301069 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070
1071 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1072
1073 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1074 mmhMsg.bodyptr = pSirSmeDisassocInd;
1075 mmhMsg.bodyval = 0;
1076
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301077 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1078 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1080 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1081 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1082#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1083
1084 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1085
1086} /*** end lim_send_sme_disassoc_ind() ***/
1087
1088/** -----------------------------------------------------------------
1089 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1090
1091 After receiving deauthentication frame from peer entity, this
1092 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1093 reason code.
1094
1095 \param pMac - global mac structure
1096 \param pStaDs - station dph hash node
1097 \return none
1098 \sa
1099 ----------------------------------------------------------------- */
1100void
1101lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1102 tpPESession psessionEntry)
1103{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001104 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105 tSirSmeDeauthInd *pSirSmeDeauthInd;
1106
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301107 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301109 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1111 return;
1112 }
1113
1114 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1115 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1116
1117 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1118 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1119 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1120 pSirSmeDeauthInd->statusCode =
1121 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1122 } else {
1123 /* Need to indicatet he reascon code over the air */
1124 pSirSmeDeauthInd->statusCode =
1125 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1126 }
1127 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301128 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301129 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301131 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301132 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1134
1135 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001136 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1137 pStaDs->mlmStaContext.disassocReason)
1138 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139
1140 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1141 mmhMsg.bodyptr = pSirSmeDeauthInd;
1142 mmhMsg.bodyval = 0;
1143
1144 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1145#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1146 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1147 0, pStaDs->mlmStaContext.cleanupTrigger);
1148#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1149
1150 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1151 return;
1152} /*** end lim_send_sme_deauth_ind() ***/
1153
1154#ifdef FEATURE_WLAN_TDLS
1155/**
1156 * lim_send_sme_tdls_del_sta_ind()
1157 *
1158 ***FUNCTION:
1159 * This function is called to send the TDLS STA context deletion to SME.
1160 *
1161 ***LOGIC:
1162 *
1163 ***ASSUMPTIONS:
1164 *
1165 ***NOTE:
1166 * NA
1167 *
1168 * @param pMac - Pointer to global MAC structure
1169 * @param pStaDs - Pointer to internal STA Datastructure
1170 * @param psessionEntry - Pointer to the session entry
1171 * @param reasonCode - Reason for TDLS sta deletion
1172 * @return None
1173 */
1174void
1175lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1176 tpPESession psessionEntry, uint16_t reasonCode)
1177{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001178 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001179 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1180
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301181 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182 if (NULL == pSirTdlsDelStaInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301183 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184 FL
1185 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1186 return;
1187 }
Nitesh Shah82c52812016-12-27 12:27:51 +05301188 lim_log(pMac, LOG1, FL("Delete TDLS Peer "MAC_ADDRESS_STR
1189 "with reason code %d"),
1190 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 /* messageType */
1192 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1193 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1194
1195 /* sessionId */
1196 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1197
1198 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301199 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301200 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201
1202 /* staId */
1203 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1204 (uint16_t) pStaDs->staIndex);
1205
1206 /* reasonCode */
1207 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1208
1209 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1210 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1211 mmhMsg.bodyval = 0;
1212
1213 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1214 return;
1215} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1216
1217/**
1218 * lim_send_sme_tdls_delete_all_peer_ind()
1219 *
1220 ***FUNCTION:
1221 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1222 * message to SME.
1223 *
1224 ***LOGIC:
1225 *
1226 ***ASSUMPTIONS:
1227 *
1228 ***NOTE:
1229 * NA
1230 *
1231 * @param pMac - Pointer to global MAC structure
1232 * @param psessionEntry - Pointer to the session entry
1233 * @return None
1234 */
1235void
1236lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1237{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001238 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1240
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301241 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242 if (NULL == pSirTdlsDelAllPeerInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301243 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 FL
1245 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1246 return;
1247 }
1248 /* messageType */
1249 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1250 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1251
1252 /* sessionId */
1253 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1254
1255 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1256 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1257 mmhMsg.bodyval = 0;
1258
1259 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1260 return;
1261} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1262
1263/**
1264 * lim_send_sme_mgmt_tx_completion()
1265 *
1266 ***FUNCTION:
1267 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1268 * message to SME.
1269 *
1270 ***LOGIC:
1271 *
1272 ***ASSUMPTIONS:
1273 *
1274 ***NOTE:
1275 * NA
1276 *
1277 * @param pMac - Pointer to global MAC structure
1278 * @param psessionEntry - Pointer to the session entry
1279 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1280 * @return None
1281 */
1282void
1283lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301284 uint32_t sme_session_id,
1285 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001287 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1289
1290 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301291 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301293 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 FL
1295 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1296 return;
1297 }
1298 /* messageType */
1299 pSirMgmtTxCompletionInd->messageType =
1300 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1301 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1302
1303 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301304 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305
1306 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1307
1308 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1309 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1310 mmhMsg.bodyval = 0;
1311
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001312#ifdef CONVERGED_TDLS_ENABLE
1313 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1314 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1315 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1316 return;
1317#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1319 return;
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001320#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1322
1323void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1324 void *events)
1325{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001326 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327
1328 switch (msgType) {
1329 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1330 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1331 break;
1332 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1333 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1334 break;
1335 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1336 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1337 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001338 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1339 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1340 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 }
1342
1343 mmhMsg.bodyptr = events;
1344 mmhMsg.bodyval = 0;
1345 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1346 return;
1347}
1348#endif /* FEATURE_WLAN_TDLS */
1349
1350/**
1351 * lim_send_sme_deauth_ntf()
1352 *
1353 ***FUNCTION:
1354 * This function is called by limProcessSmeMessages() to send
1355 * eWNI_SME_DISASSOC_RSP/IND message to host
1356 *
1357 ***PARAMS:
1358 *
1359 ***LOGIC:
1360 *
1361 ***ASSUMPTIONS:
1362 * NA
1363 *
1364 ***NOTE:
1365 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1366 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1367 *
1368 * @param peerMacAddr Indicates the peer MAC addr to which
1369 * deauthentication was initiated
1370 * @param reasonCode Indicates the reason for Deauthetication
1371 * @param deauthTrigger Indicates the trigger for Deauthetication
1372 * @param aid Indicates the STAID. This parameter is present
1373 * only on AP.
1374 *
1375 * @return None
1376 */
1377void
1378lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1379 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1380 uint16_t aid, uint8_t smesessionId,
1381 uint16_t smetransactionId)
1382{
1383 uint8_t *pBuf;
1384 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1385 tSirSmeDeauthInd *pSirSmeDeauthInd;
1386 tpPESession psessionEntry;
1387 uint8_t sessionId;
1388 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301389 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390
1391 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1392 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393 case eLIM_HOST_DEAUTH:
1394 /**
1395 * Deauthentication response to host triggered
1396 * deauthentication.
1397 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301398 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 if (NULL == pSirSmeDeauthRsp) {
1400 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301401 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 FL
1403 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1404
1405 return;
1406 }
1407 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1408 "retCode: %d for" MAC_ADDRESS_STR),
1409 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1410 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1411 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1412 pSirSmeDeauthRsp->statusCode = reasonCode;
1413 pSirSmeDeauthRsp->sessionId = smesessionId;
1414 pSirSmeDeauthRsp->transactionId = smetransactionId;
1415
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001416 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301417 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418
1419#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1420 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1421 psessionEntry, 0, (uint16_t) reasonCode);
1422#endif
1423 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1424
1425 break;
1426
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301427 case eLIM_PEER_ENTITY_DEAUTH:
1428 case eLIM_LINK_MONITORING_DEAUTH:
1429 sir_sme_dis_ind =
1430 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1431 if (!sir_sme_dis_ind) {
1432 lim_log(pMac, LOGE,
1433 FL("call to AllocateMemory failed for disconnect indication"));
1434 return;
1435 }
1436
1437 lim_log(pMac, LOG1,
1438 FL("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d"),
1439 reasonCode);
1440
1441 sir_sme_dis_ind->message_type =
1442 eWNI_SME_DISCONNECT_DONE_IND;
1443 sir_sme_dis_ind->length =
1444 sizeof(*sir_sme_dis_ind);
1445 sir_sme_dis_ind->session_id = smesessionId;
1446 sir_sme_dis_ind->reason_code = reasonCode;
1447 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1448 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301449 /*
1450 * Instead of sending deauth reason code as 505 which is
1451 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1452 * Send reason code as zero to Supplicant
1453 */
1454 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1455 sir_sme_dis_ind->reason_code = 0;
1456 else
1457 sir_sme_dis_ind->reason_code = reasonCode;
1458
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301459 pMsg = (uint32_t *)sir_sme_dis_ind;
1460
1461 break;
1462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 default:
1464 /**
1465 * Deauthentication indication due to Deauthentication
1466 * frame reception from peer entity or due to
1467 * loss of link with peer entity.
1468 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301469 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 if (NULL == pSirSmeDeauthInd) {
1471 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301472 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 FL
1474 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1475
1476 return;
1477 }
1478 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1479 "retCode: %d for " MAC_ADDRESS_STR),
1480 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1481 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1482 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1483 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1484
1485 /* sessionId */
1486 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1487 *pBuf++ = smesessionId;
1488
1489 /* transaction ID */
1490 lim_copy_u16(pBuf, smetransactionId);
1491 pBuf += sizeof(uint16_t);
1492
1493 /* status code */
1494 lim_copy_u32(pBuf, reasonCode);
1495 pBuf += sizeof(tSirResultCodes);
1496
1497 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301498 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 pBuf += sizeof(tSirMacAddr);
1500
1501 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301502 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301503 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504
1505#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1506 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1507 psessionEntry, 0, (uint16_t) reasonCode);
1508#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1509 pMsg = (uint32_t *) pSirSmeDeauthInd;
1510
1511 break;
1512 }
1513
1514 /*Delete the PE session created */
1515 if (psessionEntry != NULL) {
1516 pe_delete_session(pMac, psessionEntry);
1517 }
1518
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301519 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520 (uint32_t *) pMsg);
1521
1522} /*** end lim_send_sme_deauth_ntf() ***/
1523
1524/**
1525 * lim_send_sme_wm_status_change_ntf() - Send Notification
1526 * @mac_ctx: Global MAC Context
1527 * @status_change_code: Indicates the change in the wireless medium.
1528 * @status_change_info: Indicates the information associated with
1529 * change in the wireless medium.
1530 * @info_len: Indicates the length of status change information
1531 * being sent.
1532 * @session_id SessionID
1533 *
1534 * This function is called by limProcessSmeMessages() to send
1535 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1536 *
1537 * Return: None
1538 */
1539void
1540lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1541 tSirSmeStatusChangeCode status_change_code,
1542 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1543{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001544 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001546 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301548 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 if (NULL == wm_status_change_ntf) {
1550 lim_log(mac_ctx, LOGE,
1551 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1552 return;
1553 }
1554
1555 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1556 msg.bodyval = 0;
1557 msg.bodyptr = wm_status_change_ntf;
1558
1559 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001560 case eSIR_SME_AP_CAPS_CHANGED:
1561 max_info_len = sizeof(tSirSmeApNewCaps);
1562 break;
1563 case eSIR_SME_JOINED_NEW_BSS:
1564 max_info_len = sizeof(tSirSmeNewBssInfo);
1565 break;
1566 default:
1567 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1568 break;
1569 }
1570
1571 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 case eSIR_SME_RADAR_DETECTED:
1573 break;
1574 default:
1575 wm_status_change_ntf->messageType =
1576 eWNI_SME_WM_STATUS_CHANGE_NTF;
1577 wm_status_change_ntf->statusChangeCode = status_change_code;
1578 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1579 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001580 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1583 (uint8_t *) status_change_info, info_len);
1584 }
1585 lim_log(mac_ctx, LOGE,
1586 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1587 status_change_code, info_len);
1588 break;
1589 }
1590
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301591 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301593 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301594 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 FL("lim_sys_process_mmh_msg_api failed"));
1596 }
1597
1598} /*** end lim_send_sme_wm_status_change_ntf() ***/
1599
1600/**
1601 * lim_send_sme_set_context_rsp()
1602 *
1603 ***FUNCTION:
1604 * This function is called by limProcessSmeMessages() to send
1605 * eWNI_SME_SETCONTEXT_RSP message to host
1606 *
1607 ***PARAMS:
1608 *
1609 ***LOGIC:
1610 *
1611 ***ASSUMPTIONS:
1612 * NA
1613 *
1614 ***NOTE:
1615 *
1616 * @param pMac Pointer to Global MAC structure
1617 * @param peerMacAddr Indicates the peer MAC addr to which
1618 * setContext was performed
1619 * @param aid Indicates the aid corresponding to the peer MAC
1620 * address
1621 * @param resultCode Indicates the result of previously issued
1622 * eWNI_SME_SETCONTEXT_RSP message
1623 *
1624 * @return None
1625 */
1626void
1627lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301628 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 tSirResultCodes resultCode,
1630 tpPESession psessionEntry, uint8_t smesessionId,
1631 uint16_t smetransactionId)
1632{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001633 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1635
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301636 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 if (NULL == pSirSmeSetContextRsp) {
1638 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301639 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 FL
1641 ("call to AllocateMemory failed for SmeSetContextRsp"));
1642
1643 return;
1644 }
1645
1646 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1647 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1648 pSirSmeSetContextRsp->statusCode = resultCode;
1649
Anurag Chouhanc5548422016-02-24 18:33:27 +05301650 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651
1652 /* Update SME session and transaction Id */
1653 pSirSmeSetContextRsp->sessionId = smesessionId;
1654 pSirSmeSetContextRsp->transactionId = smetransactionId;
1655
1656 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1657 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1658 mmhMsg.bodyval = 0;
1659 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301660 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1661 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301663 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1664 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 }
1666
1667#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1668 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1669 psessionEntry, (uint16_t) resultCode, 0);
1670#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1671
1672 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1673} /*** end lim_send_sme_set_context_rsp() ***/
1674
1675/**
1676 * lim_send_sme_neighbor_bss_ind()
1677 *
1678 ***FUNCTION:
1679 * This function is called by lim_lookup_nadd_hash_entry() to send
1680 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1681 *
1682 ***PARAMS:
1683 *
1684 ***LOGIC:
1685 *
1686 ***ASSUMPTIONS:
1687 * NA
1688 *
1689 ***NOTE:
1690 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1691 * host upon detecting new BSS during background scanning if CFG
1692 * option is enabled for sending such indication
1693 *
1694 * @param pMac - Pointer to Global MAC structure
1695 * @return None
1696 */
1697
1698void
1699lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1700{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001701 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 uint32_t val;
1703 tSirSmeNeighborBssInd *pNewBssInd;
1704
1705 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1706 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1707 pMac->lim.gLimRspReqd)) {
1708 /* LIM is not in background scan state OR */
1709 /* current scan is initiated by HDD. */
1710 /* No need to send new BSS indication to HDD */
1711 return;
1712 }
1713
1714 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1715 eSIR_SUCCESS) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301716 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1718
1719 return;
1720 }
1721
1722 if (val == 0)
1723 return;
1724
1725 /**
1726 * Need to indicate new BSSs found during
1727 * background scanning to host.
1728 * Allocate buffer for sending indication.
1729 * Length of buffer is length of BSS description
1730 * and length of header itself
1731 */
1732 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1733 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301734 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 if (NULL == pNewBssInd) {
1736 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301737 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 FL
1739 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1740
1741 return;
1742 }
1743
1744 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1745 pNewBssInd->length = (uint16_t) val;
1746 pNewBssInd->sessionId = 0;
1747
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301748 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 (uint8_t *) &pBssDescr->bssDescription,
1750 pBssDescr->bssDescription.length + sizeof(uint16_t));
1751
1752 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1753 msgQ.bodyptr = pNewBssInd;
1754 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301755 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1757} /*** end lim_send_sme_neighbor_bss_ind() ***/
1758
1759/** -----------------------------------------------------------------
1760 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1761 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1762 \ SME only looks at rc and tspec field.
1763 \param pMac - global mac structure
1764 \param rspReqd - is SmeAddTsRsp required
1765 \param status - status code of SME_ADD_TS_RSP
1766 \return tspec
1767 \sa
1768 ----------------------------------------------------------------- */
1769void
1770lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1771 tpPESession psessionEntry, tSirMacTspecIE tspec,
1772 uint8_t smesessionId, uint16_t smetransactionId)
1773{
1774 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001775 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776
1777 if (!rspReqd)
1778 return;
1779
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301780 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 if (NULL == rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301782 lim_log(pMac, LOGE, FL("AllocateMemory failed for ADDTS_RSP"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 return;
1784 }
1785
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 rsp->messageType = eWNI_SME_ADDTS_RSP;
1787 rsp->rc = status;
1788 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1789 rsp->rsp.tspec = tspec;
1790 /* Update SME session Id and transcation Id */
1791 rsp->sessionId = smesessionId;
1792 rsp->transactionId = smetransactionId;
1793
1794 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1795 mmhMsg.bodyptr = rsp;
1796 mmhMsg.bodyval = 0;
1797 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301798 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1799 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301801 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1802 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 }
1804#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1805 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1806 0);
1807#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1808
1809 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1810 return;
1811}
1812
1813void
1814lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1815 tpPESession psessionEntry, uint8_t smesessionId,
1816 uint16_t smetransactionId)
1817{
1818 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001819 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301821 lim_log(pMac, LOGD, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 delts->aid,
1823 delts->req.tsinfo.traffic.tsid,
1824 delts->req.tsinfo.traffic.userPrio, status);
1825 if (!delts->rspReqd)
1826 return;
1827
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301828 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 if (NULL == rsp) {
1830 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301831 lim_log(pMac, LOGE, FL("AllocateMemory failed for DELTS_RSP"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 return;
1833 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834
1835 if (psessionEntry != NULL) {
1836
1837 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301838 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301839 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 sizeof(tSirDeltsReqInfo));
1841 }
1842
1843 rsp->messageType = eWNI_SME_DELTS_RSP;
1844 rsp->rc = status;
1845
1846 /* Update SME session Id and transcation Id */
1847 rsp->sessionId = smesessionId;
1848 rsp->transactionId = smetransactionId;
1849
1850 mmhMsg.type = eWNI_SME_DELTS_RSP;
1851 mmhMsg.bodyptr = rsp;
1852 mmhMsg.bodyval = 0;
1853 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301854 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1855 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301857 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1858 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 }
1860#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1861 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1862 (uint16_t) status, 0);
1863#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1864
1865 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1866}
1867
1868void
1869lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1870 tpPESession psessionEntry)
1871{
1872 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001873 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301875 lim_log(pMac, LOGD, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1877
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301878 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 if (NULL == rsp) {
1880 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301881 lim_log(pMac, LOGE, FL("AllocateMemory failed for DELTS_IND"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 return;
1883 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884
1885 rsp->messageType = eWNI_SME_DELTS_IND;
1886 rsp->rc = eSIR_SUCCESS;
1887 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301888 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889
1890 /* Update SME session Id and SME transaction Id */
1891
1892 rsp->sessionId = psessionEntry->smeSessionId;
1893 rsp->transactionId = psessionEntry->transactionId;
1894
1895 mmhMsg.type = eWNI_SME_DELTS_IND;
1896 mmhMsg.bodyptr = rsp;
1897 mmhMsg.bodyval = 0;
1898 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1899#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1900 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1901 0);
1902#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1903
1904 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1905}
1906
1907/**
1908 * lim_send_sme_pe_statistics_rsp()
1909 *
1910 ***FUNCTION:
1911 * This function is called to send 802.11 statistics response to HDD.
1912 * This function posts the result back to HDD. This is a response to
1913 * HDD's request for statistics.
1914 *
1915 ***PARAMS:
1916 *
1917 ***LOGIC:
1918 *
1919 ***ASSUMPTIONS:
1920 * NA
1921 *
1922 ***NOTE:
1923 * NA
1924 *
1925 * @param pMac Pointer to Global MAC structure
1926 * @param p80211Stats Statistics sent in response
1927 * @param resultCode TODO:
1928 *
1929 *
1930 * @return none
1931 */
1932
1933void
1934lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1935{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001936 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 uint8_t sessionId;
1938 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1939 tpPESession pPeSessionEntry;
1940
1941 /* Get the Session Id based on Sta Id */
1942 pPeSessionEntry =
1943 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1944
1945 /* Fill the Session Id */
1946 if (NULL != pPeSessionEntry) {
1947 /* Fill the Session Id */
1948 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1949 }
1950
1951 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1952
1953 /* msgType should be WMA_GET_STATISTICS_RSP */
1954 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1955
1956 mmhMsg.bodyptr = stats;
1957 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301958 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1960
1961 return;
1962
1963} /*** end lim_send_sme_pe_statistics_rsp() ***/
1964
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001965#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001967 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1968 * @pMac: Pointer to global pMac structure
1969 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 * This function is called to send tsm stats response to HDD.
1972 * This function posts the result back to HDD. This is a response to
1973 * HDD's request to get tsm stats.
1974 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001975 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001977void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1978 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001980 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 uint8_t sessionId;
1982 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1983 tpPESession pPeSessionEntry = NULL;
1984
1985 /* Get the Session Id based on Sta Id */
1986 pPeSessionEntry =
1987 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1988
1989 /* Fill the Session Id */
1990 if (NULL != pPeSessionEntry) {
1991 /* Fill the Session Id */
1992 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1993 } else {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301994 lim_log(pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1995 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301996 qdf_mem_free(pPeStats->tsmStatsReq);
1997 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 return;
1999 }
2000
2001 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
2002 pPeStats->tsmMetrics.RoamingCount
2003 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
2004 pPeStats->tsmMetrics.RoamingDly
2005 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
2006
2007 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
2008 mmhMsg.bodyptr = pStats;
2009 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302010 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2012
2013 return;
2014} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
2015
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002016#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017
2018void
2019lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
2020 tSirMacAddr peerMacAddr,
2021 uint16_t staIndex,
2022 uint8_t ucastIdx,
2023 uint8_t bcastIdx,
2024 uint8_t *beacon,
2025 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
2026{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002027 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 tSmeIbssPeerInd *pNewPeerInd;
2029
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302030 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 if (NULL == pNewPeerInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302032 lim_log(pMac, LOGE, FL("Failed to allocate memory"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 return;
2034 }
2035
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302036 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302037 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 pNewPeerInd->staId = staIndex;
2039 pNewPeerInd->ucastSig = ucastIdx;
2040 pNewPeerInd->bcastSig = bcastIdx;
2041 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
2042 pNewPeerInd->mesgType = msgType;
2043 pNewPeerInd->sessionId = sessionId;
2044
2045 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302046 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2048 beaconLen);
2049 }
2050
2051 mmhMsg.type = msgType;
2052 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302053 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2055
2056}
2057
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002058/**
2059 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
2060 * @mac_ctx: pointer to global adapter context
2061 * @csa_params: pointer to CSA parameters
2062 * @chnl_switch_info:pointer to channel switch parameters
2063 * @session_entry: session pointer
2064 *
2065 * Return: None
2066 */
2067static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002068 struct csa_offload_params *csa_params,
2069 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
2070 tpPESession session_entry)
2071{
Amar Singhal5cccafe2017-02-15 12:42:58 -08002072 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002073 uint8_t ap_new_ch_width;
2074 bool new_ch_width_dfn = false;
2075 uint8_t center_freq_diff;
2076
2077 ap_new_ch_width = csa_params->new_ch_width + 1;
2078 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2079 csa_params->new_ch_freq_seg2) {
2080 new_ch_width_dfn = true;
2081 if (csa_params->new_ch_freq_seg2 >
2082 csa_params->new_ch_freq_seg1)
2083 center_freq_diff = csa_params->new_ch_freq_seg2 -
2084 csa_params->new_ch_freq_seg1;
2085 else
2086 center_freq_diff = csa_params->new_ch_freq_seg1 -
2087 csa_params->new_ch_freq_seg2;
2088 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2089 ap_new_ch_width = CH_WIDTH_160MHZ;
2090 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2091 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2092 else
2093 ap_new_ch_width = CH_WIDTH_80MHZ;
2094 }
2095 session_entry->gLimChannelSwitch.state =
2096 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2097 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2098 !new_ch_width_dfn) {
2099 ch_params.ch_width = CH_WIDTH_160MHZ;
2100 cds_set_channel_params(csa_params->channel, 0,
2101 &ch_params);
2102 ap_new_ch_width = ch_params.ch_width;
2103 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2104 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2105 }
2106 chnl_switch_info->newChanWidth = ap_new_ch_width;
2107 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2108 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2109
2110 if (session_entry->ch_width == ap_new_ch_width)
2111 goto prnt_log;
2112
2113 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2114 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2115 chnl_switch_info->newCenterChanFreq1 = 0;
2116 } else {
2117 session_entry->ch_width = ap_new_ch_width;
2118 chnl_switch_info->newChanWidth = ap_new_ch_width;
2119 }
2120prnt_log:
2121 lim_log(mac_ctx, LOG1,
2122 FL("new channel: %d new_ch_width:%d seg0:%d seg1:%d"),
2123 csa_params->channel,
2124 chnl_switch_info->newChanWidth,
2125 chnl_switch_info->newCenterChanFreq0,
2126 chnl_switch_info->newCenterChanFreq1);
2127}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128/**
2129 * lim_handle_csa_offload_msg() - Handle CSA offload message
2130 * @mac_ctx: pointer to global adapter context
2131 * @msg: Message pointer.
2132 *
2133 * Return: None
2134 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002135void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2136 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137{
2138 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002139 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302140 struct csa_offload_params *csa_params =
2141 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 tpSmeCsaOffloadInd csa_offload_ind;
2143 tpDphHashNode sta_ds = NULL;
2144 uint8_t session_id;
2145 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302146 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002147 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002150 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302152 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 if (!csa_params) {
2155 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2156 return;
2157 }
2158
2159 session_entry =
2160 pe_find_session_by_bssid(mac_ctx,
2161 csa_params->bssId, &session_id);
2162 if (!session_entry) {
2163 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302164 FL("Session does not exists for %pM"),
2165 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 goto err;
2167 }
2168
2169 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2170 &session_entry->dph.dphHashTable);
2171
2172 if (!sta_ds) {
2173 lim_log(mac_ctx, LOGE,
2174 FL("sta_ds does not exist"));
2175 goto err;
2176 }
2177
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002178 if (!LIM_IS_STA_ROLE(session_entry)) {
2179 lim_log(mac_ctx, LOG1, FL("Invalid role to handle CSA"));
2180 goto err;
2181 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302182
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002183 /*
2184 * on receiving channel switch announcement from AP, delete all
2185 * TDLS peers before leaving BSS and proceed for channel switch
2186 */
2187 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302188
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002189 lim_ch_switch = &session_entry->gLimChannelSwitch;
2190 session_entry->gLimChannelSwitch.switchMode =
2191 csa_params->switch_mode;
2192 /* timer already started by firmware, switch immediately */
2193 session_entry->gLimChannelSwitch.switchCount = 0;
2194 session_entry->gLimChannelSwitch.primaryChannel =
2195 csa_params->channel;
2196 session_entry->gLimChannelSwitch.state =
2197 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2198 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2199 lim_ch_switch->sec_ch_offset =
2200 session_entry->htSecondaryChannelOffset;
2201 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2202 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2203 chnl_switch_info =
2204 &session_entry->gLimWiderBWChannelSwitch;
2205
2206 lim_log(mac_ctx, LOG1,
2207 FL("vht:%d ht:%d flag:%x chan:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302208 session_entry->vhtCapability,
2209 session_entry->htSupportedChannelWidthSet,
2210 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002211 csa_params->channel);
2212 lim_log(mac_ctx, LOG1,
2213 FL("seg1:%d seg2:%d width:%d country:%s class:%d"),
2214 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302215 csa_params->new_ch_freq_seg2,
2216 csa_params->new_ch_width,
2217 mac_ctx->scan.countryCodeCurrent,
2218 csa_params->new_op_class);
2219
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002220 if (session_entry->vhtCapability &&
2221 session_entry->htSupportedChannelWidthSet) {
2222 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002223 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002224 chnl_switch_info, session_entry);
2225 lim_ch_switch->sec_ch_offset =
2226 csa_params->sec_chan_offset;
2227 } else if (csa_params->ies_present_flag
2228 & lim_xcsa_ie_present) {
2229 chan_space =
2230 cds_reg_dmn_get_chanwidth_from_opclass(
2231 mac_ctx->scan.countryCodeCurrent,
2232 csa_params->channel,
2233 csa_params->new_op_class);
2234 session_entry->gLimChannelSwitch.state =
2235 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2236
2237 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002239 CH_WIDTH_80MHZ;
2240 } else if (chan_space == 40) {
2241 chnl_switch_info->newChanWidth =
2242 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002244 chnl_switch_info->newChanWidth =
2245 CH_WIDTH_20MHZ;
2246 lim_ch_switch->state =
2247 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2248 }
2249
2250 ch_params.ch_width =
2251 chnl_switch_info->newChanWidth;
2252 cds_set_channel_params(csa_params->channel,
2253 0, &ch_params);
2254 chnl_switch_info->newCenterChanFreq0 =
2255 ch_params.center_freq_seg0;
2256 /*
2257 * This is not applicable for 20/40/80 MHz.
2258 * Only used when we support 80+80 MHz operation.
2259 * In case of 80+80 MHz, this parameter indicates
2260 * center channel frequency index of 80 MHz
2261 * channel offrequency segment 1.
2262 */
2263 chnl_switch_info->newCenterChanFreq1 =
2264 ch_params.center_freq_seg1;
2265 lim_ch_switch->sec_ch_offset =
2266 ch_params.sec_ch_offset;
2267
2268 }
2269 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2270 chnl_switch_info->newCenterChanFreq0;
2271 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2272 chnl_switch_info->newCenterChanFreq1;
2273 session_entry->gLimChannelSwitch.ch_width =
2274 chnl_switch_info->newChanWidth;
2275
2276 } else if (session_entry->htSupportedChannelWidthSet) {
2277 if (csa_params->ies_present_flag
2278 & lim_xcsa_ie_present) {
2279 chan_space =
2280 cds_reg_dmn_get_chanwidth_from_opclass(
2281 mac_ctx->scan.countryCodeCurrent,
2282 csa_params->channel,
2283 csa_params->new_op_class);
2284 lim_ch_switch->state =
2285 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2286 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002287 lim_ch_switch->ch_width =
2288 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002289 chnl_switch_info->newChanWidth =
2290 CH_WIDTH_40MHZ;
2291 ch_params.ch_width =
2292 chnl_switch_info->newChanWidth;
2293 cds_set_channel_params(
2294 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002295 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002296 lim_ch_switch->ch_center_freq_seg0 =
2297 ch_params.center_freq_seg0;
2298 lim_ch_switch->sec_ch_offset =
2299 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002300 } else {
2301 lim_ch_switch->ch_width =
2302 CH_WIDTH_20MHZ;
2303 chnl_switch_info->newChanWidth =
2304 CH_WIDTH_40MHZ;
2305 lim_ch_switch->state =
2306 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2307 lim_ch_switch->sec_ch_offset =
2308 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002310 } else {
2311 lim_ch_switch->ch_width =
2312 CH_WIDTH_40MHZ;
2313 lim_ch_switch->state =
2314 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2315 ch_params.ch_width = CH_WIDTH_40MHZ;
2316 cds_set_channel_params(csa_params->channel,
2317 0, &ch_params);
2318 lim_ch_switch->ch_center_freq_seg0 =
2319 ch_params.center_freq_seg0;
2320 lim_ch_switch->sec_ch_offset =
2321 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002323
2324 }
2325 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302326 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002328 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2329 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2330 if (NULL == csa_offload_ind) {
2331 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002333 goto err;
2334 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002336 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2337 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2338 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2339 QDF_MAC_ADDR_SIZE);
2340 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2341 mmh_msg.bodyptr = csa_offload_ind;
2342 mmh_msg.bodyval = 0;
2343 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002344 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002345 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2347#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002348 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2350 eSIR_SUCCESS, eSIR_SUCCESS);
2351#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002352 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353
2354err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302355 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356}
2357
2358/*--------------------------------------------------------------------------
2359 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2360
2361 \param pMac - pointer to global adapter context
2362 \param sessionId - Message pointer.
2363
2364 \sa
2365 --------------------------------------------------------------------------*/
2366
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002367void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368{
2369 tpPESession psessionEntry;
2370 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2371
2372 psessionEntry =
2373 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2374 if (psessionEntry == NULL) {
2375 lim_log(pMac, LOGE,
2376 FL("Session Does not exist for given sessionID %d"),
2377 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002378 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002379 return;
2380 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002381 /*
2382 * During DEL BSS handling, the PE Session will be deleted, but it is
2383 * better to clear this flag if the session is hanging around due
2384 * to some error conditions so that the next DEL_BSS request does
2385 * not take the HO_FAIL path
2386 */
2387 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002388 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002390 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002392 else if (LIM_IS_NDI_ROLE(psessionEntry))
2393 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 else
2395 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2396
2397}
2398
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399/** -----------------------------------------------------------------
2400 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2401 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2402 \ SME only looks at rc and tspec field.
2403 \param pMac - global mac structure
2404 \param rspReqd - is SmeAddTsRsp required
2405 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2406 \return tspec
2407 \sa
2408 ----------------------------------------------------------------- */
2409void
2410lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2411 uint8_t smesessionId)
2412{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002413 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414
2415 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2416 mmhMsg.bodyptr = aggrQosRsp;
2417 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302418 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2419 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2421
2422 return;
2423}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424
2425void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2426 uint8_t smesessionId)
2427{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002428 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 tSmeMaxAssocInd *pSmeMaxAssocInd;
2430
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302431 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302433 lim_log(pMac, LOGE, FL("Failed to allocate memory"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 return;
2435 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302436 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302437 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2439 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2440 pSmeMaxAssocInd->sessionId = smesessionId;
2441 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2442 mmhMsg.bodyptr = pSmeMaxAssocInd;
2443 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2444 " sme session id %d"),
2445 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2446 MAC_ADDR_ARRAY(peerMacAddr));
2447 )
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302448 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2449 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2451
2452 return;
2453}
2454
2455/** -----------------------------------------------------------------
2456 \brief lim_send_sme_dfs_event_notify() - sends
2457 eWNI_SME_DFS_RADAR_FOUND
2458 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2459 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2460 that a RADAR is found on current operating channel and SAP-
2461 has to move to a new channel.
2462 \param pMac - global mac structure
2463 \param msgType - message type received from lower layer
2464 \param event - event data received from lower layer
2465 \return none
2466 \sa
2467 ----------------------------------------------------------------- */
2468void
2469lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2470{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002471 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2473 mmhMsg.bodyptr = event;
2474 mmhMsg.bodyval = 0;
2475 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2476 return;
2477}
2478
2479/*--------------------------------------------------------------------------
2480 \brief lim_send_dfs_chan_sw_ie_update()
2481 This timer handler updates the channel switch IE in beacon template
2482
2483 \param pMac - pointer to global adapter context
2484 \return - channel to scan from valid session else zero.
2485 \sa
2486 --------------------------------------------------------------------------*/
2487static void
2488lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2489{
2490
2491 /* Update the beacon template and send to FW */
2492 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302493 lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494 return;
2495 }
2496
2497 /* Send update beacon template message */
2498 lim_send_beacon_ind(pMac, psessionEntry);
2499 PELOG1(lim_log(pMac, LOG1,
2500 FL(" Updated CSA IE, IE COUNT = %d"),
2501 psessionEntry->gLimChannelSwitch.switchCount);
2502 )
2503
2504 return;
2505}
2506
2507/** -----------------------------------------------------------------
2508 \brief lim_send_sme_ap_channel_switch_resp() - sends
2509 eWNI_SME_CHANNEL_CHANGE_RSP
2510 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2511 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2512 that the Channel change has been done to the specified target
2513 channel in the Channel change request
2514 \param pMac - global mac structure
2515 \param psessionEntry - session info
2516 \param pChnlParams - Channel switch params
2517 --------------------------------------------------------------------*/
2518void
2519lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2520 tpPESession psessionEntry,
2521 tpSwitchChannelParams pChnlParams)
2522{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002523 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524 tpSwitchChannelParams pSmeSwithChnlParams;
2525 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002526 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002527 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002528 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529
2530 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302531 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302533 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2535 return;
2536 }
2537
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302538 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539 sizeof(tSwitchChannelParams));
2540
2541 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002542 ch_width = pSmeSwithChnlParams->ch_width;
2543 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544
2545 /*
2546 * Pass the sme sessionID to SME instead
2547 * PE session ID.
2548 */
2549 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2550
2551 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2552 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2553 mmhMsg.bodyval = 0;
2554 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2555
2556 /*
2557 * We should start beacon transmission only if the new
2558 * channel after channel change is Non-DFS. For a DFS
2559 * channel, PE will receive an explicit request from
2560 * upper layers to start the beacon transmission .
2561 */
2562
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002563 if (ch_width == CH_WIDTH_160MHZ) {
2564 is_ch_dfs = true;
2565 } else if (ch_width == CH_WIDTH_80P80MHZ) {
2566 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
2567 cds_get_channel_state(ch_center_freq_seg1 -
2568 SIR_80MHZ_START_CENTER_CH_DIFF) ==
2569 CHANNEL_STATE_DFS)
2570 is_ch_dfs = true;
2571 } else {
2572 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
2573 is_ch_dfs = true;
2574 }
2575
2576 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 if (channelId == psessionEntry->currentOperChannel) {
2578 lim_apply_configuration(pMac, psessionEntry);
2579 lim_send_beacon_ind(pMac, psessionEntry);
2580 } else {
2581 PELOG1(lim_log(pMac, LOG1,
2582 FL
2583 ("Failed to Transmit Beacons on channel = %d"
2584 "after AP channel change response"),
2585 psessionEntry->bcnLen);
2586 )
2587 }
2588 }
2589 return;
2590}
2591
2592/** -----------------------------------------------------------------
2593 \brief lim_process_beacon_tx_success_ind() - This function is used
2594 explicitely to handle successful beacon transmission indication
2595 from the FW. This is a generic event generated by the FW afer the
2596 first beacon is sent out after the beacon template update by the
2597 host
2598 \param pMac - global mac structure
2599 \param psessionEntry - session info
2600 \return none
2601 \sa
2602 ----------------------------------------------------------------- */
2603void
2604lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2605{
2606 /* Currently, this event is used only for DFS channel switch announcement
2607 * IE update in the template. If required to be used for other IE updates
2608 * add appropriate code by introducing a state variable
2609 */
2610 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002611 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2613 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2614 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2615 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2616 (tSirFirstBeaconTxCompleteInd *) event;
2617
2618 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2619 if (psessionEntry == NULL) {
2620 lim_log(pMac, LOGE,
2621 FL("Session Does not exist for given sessionID"));
2622 return;
2623 }
2624
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302625 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2626 GET_LIM_SYSTEM_ROLE(psessionEntry),
2627 psessionEntry->dfsIncludeChanSwIe,
2628 psessionEntry->gLimOperatingMode.present);
2629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 if (LIM_IS_AP_ROLE(psessionEntry) &&
2631 true == psessionEntry->dfsIncludeChanSwIe) {
2632 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2633 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2634 /*
2635 * Send the next beacon with updated CSA IE count
2636 */
2637 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2638 /* Decrement the IE count */
2639 psessionEntry->gLimChannelSwitch.switchCount--;
2640 } else {
2641 /* Done with CSA IE update, send response back to SME */
2642 psessionEntry->gLimChannelSwitch.switchCount = 0;
2643 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2644 psessionEntry->gLimChannelSwitch.switchMode = 0;
2645 psessionEntry->dfsIncludeChanSwIe = false;
2646 psessionEntry->dfsIncludeChanWrapperIe = false;
2647
2648 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302649 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650
2651 if (NULL == pChanSwTxResponse) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302652 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 FL
2654 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2655 return;
2656 }
2657
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 pChanSwTxResponse->sessionId =
2659 psessionEntry->smeSessionId;
2660 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302661 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662
2663 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2664 mmhMsg.bodyptr = pChanSwTxResponse;
2665 mmhMsg.bodyval = 0;
2666 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2667 }
2668 }
2669
2670 if (LIM_IS_AP_ROLE(psessionEntry) &&
2671 psessionEntry->gLimOperatingMode.present) {
2672 /* Done with nss update, send response back to SME */
2673 psessionEntry->gLimOperatingMode.present = 0;
2674 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302675 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302677 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 FL
2679 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2680 return;
2681 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 beacon_tx_comp_rsp_ptr->session_id =
2683 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302684 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2686 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2687 mmhMsg.bodyval = 0;
2688 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2689 }
2690 return;
2691}