blob: 8f6684f48d8bdd200161e658ebe0dfd0fb2e335e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Nitesh Shah82c52812016-12-27 12:27:51 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_send_sme_rspMessages.cc contains the functions
30 * for sending SME response/notification messages to applications
31 * above MAC software.
32 * Author: Chandra Modumudi
33 * Date: 02/13/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38
Anurag Chouhan6d760662016-02-20 16:05:43 +053039#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include "wni_api.h"
41#include "sir_common.h"
42#include "ani_global.h"
43
44#include "wni_cfg.h"
45#include "sys_def.h"
46#include "cfg_api.h"
47
48#include "sch_api.h"
49#include "utils_api.h"
50#include "lim_utils.h"
51#include "lim_security_utils.h"
52#include "lim_ser_des_utils.h"
53#include "lim_send_sme_rsp_messages.h"
54#include "lim_ibss_peer_mgmt.h"
55#include "lim_session_utils.h"
56#include "lim_types.h"
57#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070058#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053059#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070060#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070061#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070062#include "wlan_reg_services_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070064#ifdef CONVERGED_TDLS_ENABLE
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070065#include "wlan_tdls_tgt_api.h"
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070066#endif
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
69 tpPESession session_entry, tSirResultCodes result_code,
70 tpSirSmeJoinRsp sme_join_rsp);
71
72/**
73 * lim_send_sme_rsp() - Send Response to upper layers
74 * @mac_ctx: Pointer to Global MAC structure
75 * @msg_type: Indicates message type
76 * @result_code: Indicates the result of previously issued
77 * eWNI_SME_msg_type_REQ message
78 *
79 * This function is called by lim_process_sme_req_messages() to send
80 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
81 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
82 * Software.
83 *
84 * Return: None
85 */
86
87void
88lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
89 tSirResultCodes result_code, uint8_t sme_session_id,
90 uint16_t sme_transaction_id)
91{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070092 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093 tSirSmeRsp *sme_rsp;
94
95 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
96 lim_msg_str(msg_type), lim_result_code_str(result_code));
97
Anurag Chouhan600c3a02016-03-01 10:33:54 +053098 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099 if (NULL == sme_rsp) {
100 /* Buffer not available. Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530101 QDF_TRACE(QDF_MODULE_ID_PE, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
103 return;
104 }
105
106 sme_rsp->messageType = msg_type;
107 sme_rsp->length = sizeof(tSirSmeRsp);
108 sme_rsp->statusCode = result_code;
109
110 sme_rsp->sessionId = sme_session_id;
111 sme_rsp->transactionId = sme_transaction_id;
112
113 msg.type = msg_type;
114 msg.bodyptr = sme_rsp;
115 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530116 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
117 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118
119#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
120 switch (msg_type) {
121 case eWNI_SME_STOP_BSS_RSP:
122 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
123 NULL, (uint16_t) result_code, 0);
124 break;
125 }
126#endif /* FEATURE_WLAN_DIAG_SUPPORT */
127 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
128}
129
130
131
132/**
133 * lim_send_sme_roc_rsp() - Send Response to SME
134 * @mac_ctx: Pointer to Global MAC structure
135 * @status: Resume link status
136 * @result_code: Result of the ROC request
137 * @sme_session_id: SME sesson Id
138 * @scan_id: Scan Identifier
139 *
140 * This function is called to send ROC rsp
141 * message to SME.
142 *
143 * Return: None
144 */
145void
146lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
147 tSirResultCodes result_code, uint8_t sme_session_id,
148 uint32_t scan_id)
149{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700150 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 struct sir_roc_rsp *sme_rsp;
152
153 lim_log(mac_ctx, LOG1,
154 FL("Sending message %s with reasonCode %s scanId %d"),
155 lim_msg_str(msg_type), lim_result_code_str(result_code),
156 scan_id);
157
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530158 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 if (NULL == sme_rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530160 QDF_TRACE(QDF_MODULE_ID_PE, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
162 return;
163 }
164
165 sme_rsp->message_type = msg_type;
166 sme_rsp->length = sizeof(struct sir_roc_rsp);
167 sme_rsp->status = result_code;
168
169 sme_rsp->session_id = sme_session_id;
170 sme_rsp->scan_id = scan_id;
171
172 msg.type = msg_type;
173 msg.bodyptr = sme_rsp;
174 msg.bodyval = 0;
175 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
176 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
177}
178
179
180/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530181 * lim_get_max_rate_flags() - Get rate flags
182 * @mac_ctx: Pointer to global MAC structure
183 * @sta_ds: Pointer to station ds structure
184 *
185 * This function is called to get the rate flags for a connection
186 * from the station ds structure depending on the ht and the vht
187 * channel width supported.
188 *
189 * Return: Returns the populated rate_flags
190 */
191uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
192{
193 uint32_t rate_flags = 0;
194
195 if (sta_ds == NULL) {
196 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
197 return rate_flags;
198 }
199
200 if (!sta_ds->mlmStaContext.htCapability &&
201 !sta_ds->mlmStaContext.vhtCapability) {
202 rate_flags |= eHAL_TX_RATE_LEGACY;
203 } else {
204 if (sta_ds->mlmStaContext.vhtCapability) {
205 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
206 sta_ds->vhtSupportedChannelWidthSet) {
207 rate_flags |= eHAL_TX_RATE_VHT80;
208 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
209 sta_ds->vhtSupportedChannelWidthSet) {
210 if (sta_ds->htSupportedChannelWidthSet)
211 rate_flags |= eHAL_TX_RATE_VHT40;
212 else
213 rate_flags |= eHAL_TX_RATE_VHT20;
214 }
215 } else if (sta_ds->mlmStaContext.htCapability) {
216 if (sta_ds->htSupportedChannelWidthSet)
217 rate_flags |= eHAL_TX_RATE_HT40;
218 else
219 rate_flags |= eHAL_TX_RATE_HT20;
220 }
221 }
222
223 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
224 rate_flags |= eHAL_TX_RATE_SGI;
225
226 return rate_flags;
227}
228
229/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
231 * @mac_ctx Pointer to Global MAC structure
232 * @status Resume link status
233 * @ctx context passed while calling resmune link.
234 * (join response to be sent)
235 *
236 * This function is called to send Join/Reassoc rsp
237 * message to SME after the resume link.
238 *
239 * Return: None
240 */
241static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530242 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700244 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
246
247 msg.type = sme_join_rsp->messageType;
248 msg.bodyptr = sme_join_rsp;
249 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530250 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
252}
253
254/**
255 * lim_handle_join_rsp_status() - Handle the response.
256 * @mac_ctx: Pointer to Global MAC structure
257 * @session_entry: PE Session Info
258 * @result_code: Indicates the result of previously issued
259 * eWNI_SME_msgType_REQ message
260 * @sme_join_rsp The received response.
261 *
262 * This function will handle both the success and failure status
263 * of the received response.
264 *
265 * Return: None
266 */
267static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
268 tpPESession session_entry, tSirResultCodes result_code,
269 tpSirSmeJoinRsp sme_join_rsp)
270{
271#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
272 tSirSmeHTProfile *ht_profile;
273#endif
274 if (result_code == eSIR_SME_SUCCESS) {
275 if (session_entry->beacon != NULL) {
276 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530277 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278 session_entry->beacon,
279 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530280 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530282 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283 lim_log(mac_ctx, LOG1, FL("Beacon=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530284 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285 }
286 if (session_entry->assocReq != NULL) {
287 sme_join_rsp->assocReqLength =
288 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530289 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530290 sme_join_rsp->beaconLength,
291 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530293 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530295 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296 lim_log(mac_ctx,
297 LOG1, FL("AssocReq=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530298 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 }
300 if (session_entry->assocRsp != NULL) {
301 sme_join_rsp->assocRspLength =
302 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530303 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530304 sme_join_rsp->beaconLength +
305 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 session_entry->assocRsp,
307 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530308 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530310 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 if (session_entry->ricData != NULL) {
313 sme_join_rsp->parsedRicRspLen =
314 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530315 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530316 sme_join_rsp->beaconLength +
317 sme_join_rsp->assocReqLength +
318 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 session_entry->ricData,
320 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530321 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530323 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800324 lim_log(mac_ctx, LOG1, FL("RicLength=%d"),
325 sme_join_rsp->parsedRicRspLen);
326 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327#ifdef FEATURE_WLAN_ESE
328 if (session_entry->tspecIes != NULL) {
329 sme_join_rsp->tspecIeLen =
330 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530331 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530332 sme_join_rsp->beaconLength +
333 sme_join_rsp->assocReqLength +
334 sme_join_rsp->assocRspLength +
335 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 session_entry->tspecIes,
337 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530338 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530340 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 lim_log(mac_ctx, LOG1, FL("ESE-TspecLen=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530342 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343 }
344#endif
345 sme_join_rsp->aid = session_entry->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 lim_log(mac_ctx, LOG1, FL("AssocRsp=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530347 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 sme_join_rsp->vht_channel_width =
349 session_entry->ch_width;
350#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
351 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530352 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 ht_profile = &sme_join_rsp->HTProfile;
354 ht_profile->htSupportedChannelWidthSet =
355 session_entry->htSupportedChannelWidthSet;
356 ht_profile->htRecommendedTxWidthSet =
357 session_entry->htRecommendedTxWidthSet;
358 ht_profile->htSecondaryChannelOffset =
359 session_entry->htSecondaryChannelOffset;
360 ht_profile->dot11mode = session_entry->dot11mode;
361 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 ht_profile->vhtCapability =
363 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
365 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 }
367#endif
368 } else {
369 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530370 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530372 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 }
374 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530375 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530377 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 }
379 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530380 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530382 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530385 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530387 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389#ifdef FEATURE_WLAN_ESE
390 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530391 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530393 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394 }
395#endif
396 }
397}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530398
399/**
400 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530401 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530402 * @sme_join_rsp: Join response buffer to be filled up
403 *
404 * Return: None
405 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700406static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530407{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530408 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
409
410 if (parsed_ies->hs20vendor_ie.present)
411 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
412 if (parsed_ies->vht_caps.present)
413 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
414 if (parsed_ies->ht_caps.present)
415 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
416 if (parsed_ies->ht_operation.present)
417 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
418 if (parsed_ies->vht_operation.present)
419 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530420}
421
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422/**
423 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
424 * @mac_ctx: Pointer to Global MAC structure
425 * @msg_type: Indicates message type
426 * @result_code: Indicates the result of previously issued
427 * eWNI_SME_msgType_REQ message
428 * @prot_status_code: Protocol Status Code
429 * @session_entry: PE Session Info
430 * @sme_session_id: SME Session ID
431 * @sme_transaction_id: SME Transaction ID
432 *
433 * This function is called by lim_process_sme_req_messages() to send
434 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
435 * above MAC Software.
436 *
437 * Return: None
438 */
439
440void
441lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
442 tSirResultCodes result_code, uint16_t prot_status_code,
443 tpPESession session_entry, uint8_t sme_session_id,
444 uint16_t sme_transaction_id)
445{
446 tpSirSmeJoinRsp sme_join_rsp;
447 uint32_t rsp_len;
448 tpDphHashNode sta_ds = NULL;
449#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
450 if (msg_type == eWNI_SME_REASSOC_RSP)
451 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
452 session_entry, (uint16_t) result_code, 0);
453 else
454 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
455 session_entry, (uint16_t) result_code, 0);
456#endif /* FEATURE_WLAN_DIAG_SUPPORT */
457
458 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
459 lim_msg_str(msg_type), lim_result_code_str(result_code));
460
461 if (session_entry == NULL) {
462 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530463 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 if (NULL == sme_join_rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530465 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 FL("Mem Alloc fail - JOIN/REASSOC_RSP"));
467 return;
468 }
469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 sme_join_rsp->beaconLength = 0;
471 sme_join_rsp->assocReqLength = 0;
472 sme_join_rsp->assocRspLength = 0;
473 } else {
474 rsp_len = session_entry->assocReqLen +
475 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477#ifdef FEATURE_WLAN_ESE
478 session_entry->tspecLen +
479#endif
480 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530481 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482 if (NULL == sme_join_rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530483 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
485 return;
486 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487 if (result_code == eSIR_SME_SUCCESS) {
488 sta_ds = dph_get_hash_entry(mac_ctx,
489 DPH_STA_HASH_INDEX_PEER,
490 &session_entry->dph.dphHashTable);
491 if (sta_ds == NULL) {
492 lim_log(mac_ctx, LOGE,
493 FL("Get Self Sta Entry fail"));
494 } else {
495 /* Pass the peer's staId */
496 sme_join_rsp->staId = sta_ds->staIndex;
497 sme_join_rsp->ucastSig =
498 sta_ds->ucUcastSig;
499 sme_join_rsp->bcastSig =
500 sta_ds->ucBcastSig;
501 sme_join_rsp->timingMeasCap =
502 sta_ds->timingMeasCap;
503#ifdef FEATURE_WLAN_TDLS
504 sme_join_rsp->tdls_prohibited =
505 session_entry->tdls_prohibited;
506 sme_join_rsp->tdls_chan_swit_prohibited =
507 session_entry->tdls_chan_swit_prohibited;
508#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530509 sme_join_rsp->nss = sta_ds->nss;
510 sme_join_rsp->max_rate_flags =
511 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530512 lim_add_bss_info(sta_ds, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513 }
514 }
515 sme_join_rsp->beaconLength = 0;
516 sme_join_rsp->assocReqLength = 0;
517 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800518 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519#ifdef FEATURE_WLAN_ESE
520 sme_join_rsp->tspecIeLen = 0;
521#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
523 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800524
525 /* Send supported NSS 1x1 to SME */
526 sme_join_rsp->supported_nss_1x1 =
527 session_entry->supported_nss_1x1;
528 lim_log(mac_ctx, LOG1,
529 FL("SME Join Rsp is supported NSS 1X1: %d"),
530 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531 }
532
533 sme_join_rsp->messageType = msg_type;
534 sme_join_rsp->length = (uint16_t) rsp_len;
535 sme_join_rsp->statusCode = result_code;
536 sme_join_rsp->protStatusCode = prot_status_code;
537
538 sme_join_rsp->sessionId = sme_session_id;
539 sme_join_rsp->transactionId = sme_transaction_id;
540
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530541 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800542 (uint32_t *)sme_join_rsp);
543}
544
545/**
546 * lim_send_sme_start_bss_rsp()
547 *
548 ***FUNCTION:
549 * This function is called to send eWNI_SME_START_BSS_RSP
550 * message to applications above MAC Software.
551 *
552 ***PARAMS:
553 *
554 ***LOGIC:
555 *
556 ***ASSUMPTIONS:
557 * NA
558 *
559 ***NOTE:
560 * NA
561 *
562 * @param pMac Pointer to Global MAC structure
563 * @param msgType Indicates message type
564 * @param resultCode Indicates the result of previously issued
565 * eWNI_SME_msgType_REQ message
566 *
567 * @return None
568 */
569
570void
571lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
572 uint16_t msgType, tSirResultCodes resultCode,
573 tpPESession psessionEntry, uint8_t smesessionId,
574 uint16_t smetransactionId)
575{
576
577 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700578 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579 tSirSmeStartBssRsp *pSirSmeRsp;
580 uint16_t ieLen;
581 uint16_t ieOffset, curLen;
582
583 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
584 lim_msg_str(msgType), lim_result_code_str(resultCode));
585 )
586
587 size = sizeof(tSirSmeStartBssRsp);
588
589 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530590 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 if (NULL == pSirSmeRsp) {
592 /* / Buffer not available. Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530593 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 FL
595 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
596 return;
597 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 } else {
599 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
600 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
601 ieLen = psessionEntry->schBeaconOffsetBegin
602 + psessionEntry->schBeaconOffsetEnd - ieOffset;
603 /* calculate the memory size to allocate */
604 size += ieLen;
605
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530606 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 if (NULL == pSirSmeRsp) {
608 /* / Buffer not available. Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530609 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 FL
611 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
612
613 return;
614 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 size = sizeof(tSirSmeStartBssRsp);
616 if (resultCode == eSIR_SME_SUCCESS) {
617
618 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
619 psessionEntry->bssId);
620
621 /* Read beacon interval from session */
622 pSirSmeRsp->bssDescription.beaconInterval =
623 (uint16_t) psessionEntry->beaconParams.
624 beaconInterval;
625 pSirSmeRsp->bssType = psessionEntry->bssType;
626
627 if (cfg_get_capability_info
628 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
629 psessionEntry)
630 != eSIR_SUCCESS)
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530631 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 FL
633 ("could not retrieve Capabilities value"));
634
635 lim_get_phy_mode(pMac,
636 (uint32_t *) &pSirSmeRsp->bssDescription.
637 nwType, psessionEntry);
638
639 pSirSmeRsp->bssDescription.channelId =
640 psessionEntry->currentOperChannel;
641
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700642 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530644 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 ieFields,
646 psessionEntry->pSchBeaconFrameBegin +
647 ieOffset, (uint32_t) curLen);
648
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530649 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 ieFields) + curLen,
651 psessionEntry->pSchBeaconFrameEnd,
652 (uint32_t) psessionEntry->
653 schBeaconOffsetEnd);
654
Abhishek Singh34a4d862016-10-26 16:01:51 +0530655 pSirSmeRsp->bssDescription.length = (uint16_t)
656 (offsetof(tSirBssDescription, ieFields[0])
657 - sizeof(pSirSmeRsp->bssDescription.length)
658 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659 /* This is the size of the message, subtracting the size of the pointer to ieFields */
660 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700661 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
663 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530664 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665 pSirSmeRsp->HTProfile.
666 htSupportedChannelWidthSet =
667 psessionEntry->htSupportedChannelWidthSet;
668 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
669 psessionEntry->htRecommendedTxWidthSet;
670 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
671 psessionEntry->htSecondaryChannelOffset;
672 pSirSmeRsp->HTProfile.dot11mode =
673 psessionEntry->dot11mode;
674 pSirSmeRsp->HTProfile.htCapability =
675 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 pSirSmeRsp->HTProfile.vhtCapability =
677 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678 pSirSmeRsp->HTProfile.apCenterChan =
679 psessionEntry->ch_center_freq_seg0;
680 pSirSmeRsp->HTProfile.apChanWidth =
681 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 }
683#endif
684 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 pSirSmeRsp->messageType = msgType;
687 pSirSmeRsp->length = size;
688
689 /* Update SME session Id and transaction Id */
690 pSirSmeRsp->sessionId = smesessionId;
691 pSirSmeRsp->transactionId = smetransactionId;
692 pSirSmeRsp->statusCode = resultCode;
693 if (psessionEntry != NULL)
694 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
695
696 mmhMsg.type = msgType;
697 mmhMsg.bodyptr = pSirSmeRsp;
698 mmhMsg.bodyval = 0;
699 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530700 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
701 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530703 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
704 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705 }
706#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
707 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
708 psessionEntry, (uint16_t) resultCode, 0);
709#endif /* FEATURE_WLAN_DIAG_SUPPORT */
710
711 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
712} /*** end lim_send_sme_start_bss_rsp() ***/
713
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714/**
715 * lim_send_sme_scan_rsp() - Send scan response to SME
716 * @pMac: Pointer to Global MAC structure
717 * @length: Indicates length of message
718 * @resultCode: Indicates the result of previously issued
719 * eWNI_SME_SCAN_REQ message
720 * @scan_id: scan identifier
721 *
722 * This function is called by lim_process_sme_req_messages() to send
723 * eWNI_SME_SCAN_RSP message to applications above MAC
724 *
725 * return: None
726 */
727
728void
729lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
730 uint8_t smesessionId, uint16_t smetranscationId,
731 uint32_t scan_id)
732{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
734 smetranscationId, scan_id);
735}
736
737/**
738 * lim_post_sme_scan_rsp_message()
739 *
740 ***FUNCTION:
741 * This function is called by lim_send_sme_scan_rsp() to send
742 * eWNI_SME_SCAN_RSP message with failed result code
743 *
744 ***NOTE:
745 * NA
746 *
747 * @param pMac Pointer to Global MAC structure
748 * @param length Indicates length of message
749 * @param resultCode failed result code
750 *
751 * @return None
752 */
753
754void
755lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
756 tSirResultCodes resultCode, uint8_t smesessionId,
757 uint16_t smetransactionId,
758 uint32_t scan_id)
759{
760 tpSirSmeScanRsp pSirSmeScanRsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700761 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762
763 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
764 lim_result_code_str(resultCode));
765
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530766 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767 if (NULL == pSirSmeScanRsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530768 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
770 return;
771 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772
773 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
774 pSirSmeScanRsp->statusCode = resultCode;
775
776 /*Update SME session Id and transaction Id */
777 pSirSmeScanRsp->sessionId = smesessionId;
778 pSirSmeScanRsp->transcationId = smetransactionId;
779 pSirSmeScanRsp->scan_id = scan_id;
780
781 mmhMsg.type = eWNI_SME_SCAN_RSP;
782 mmhMsg.bodyptr = pSirSmeScanRsp;
783 mmhMsg.bodyval = 0;
784
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530785 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
787 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
788 (uint16_t) resultCode, 0);
789#endif /* FEATURE_WLAN_DIAG_SUPPORT */
790
791 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
792 return;
793
794} /*** lim_post_sme_scan_rsp_message ***/
795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530797 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700799 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800800 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801
802 mmhMsg.type = pMsg->type;
803 mmhMsg.bodyptr = pMsg;
804 mmhMsg.bodyval = 0;
805
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530806 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807
808 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
809}
810
811/**
812 * lim_send_sme_disassoc_ntf()
813 *
814 ***FUNCTION:
815 * This function is called by limProcessSmeMessages() to send
816 * eWNI_SME_DISASSOC_RSP/IND message to host
817 *
818 ***PARAMS:
819 *
820 ***LOGIC:
821 *
822 ***ASSUMPTIONS:
823 * NA
824 *
825 ***NOTE:
826 * This function is used for sending eWNI_SME_DISASSOC_CNF,
827 * or eWNI_SME_DISASSOC_IND to host depending on
828 * disassociation trigger.
829 *
830 * @param peerMacAddr Indicates the peer MAC addr to which
831 * disassociate was initiated
832 * @param reasonCode Indicates the reason for Disassociation
833 * @param disassocTrigger Indicates the trigger for Disassociation
834 * @param aid Indicates the STAID. This parameter is
835 * present only on AP.
836 *
837 * @return None
838 */
839void
840lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
841 tSirMacAddr peerMacAddr,
842 tSirResultCodes reasonCode,
843 uint16_t disassocTrigger,
844 uint16_t aid,
845 uint8_t smesessionId,
846 uint16_t smetransactionId, tpPESession psessionEntry)
847{
848
849 uint8_t *pBuf;
850 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
851 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700852 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700854 tpPESession session = NULL;
855 uint16_t i, assoc_id;
856 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530857 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858
859 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
860 disassocTrigger, reasonCode);
861
862 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700863 case eLIM_DUPLICATE_ENTRY:
864 /*
865 * Duplicate entry is removed at LIM.
866 * Initiate new entry for other session
867 */
868 lim_log(pMac, LOG1,
869 FL("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR),
870 MAC_ADDR_ARRAY(peerMacAddr));
871
872 for (i = 0; i < pMac->lim.maxBssId; i++) {
873 if ((&pMac->lim.gpSession[i] != NULL) &&
874 (pMac->lim.gpSession[i].valid) &&
875 (pMac->lim.gpSession[i].pePersona ==
876 QDF_SAP_MODE)) {
877 /* Find the sta ds entry in another session */
878 session = &pMac->lim.gpSession[i];
879 sta_ds = dph_lookup_hash_entry(pMac,
880 peerMacAddr, &assoc_id,
881 &session->dph.dphHashTable);
882 }
883 }
884 if (sta_ds
885#ifdef WLAN_FEATURE_11W
886 && (!sta_ds->rmfEnabled)
887#endif
888 ) {
889 if (lim_add_sta(pMac, sta_ds, false, session) !=
890 eSIR_SUCCESS)
891 lim_log(pMac, LOGE,
892 FL("could not Add STA with assocId=%d"),
893 sta_ds->assocId);
894 }
895 failure = true;
896 break;
897
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 case eLIM_HOST_DISASSOC:
899 /**
900 * Disassociation response due to
901 * host triggered disassociation
902 */
903
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530904 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 if (NULL == pSirSmeDisassocRsp) {
906 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530907 lim_log(pMac, LOGE, FL("Memory allocation failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 failure = true;
909 goto error;
910 }
911 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
912 "retCode: %d for " MAC_ADDRESS_STR),
913 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
914 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
915 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
916 /* sessionId */
917 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
918 *pBuf = smesessionId;
919 pBuf++;
920
921 /* transactionId */
922 lim_copy_u16(pBuf, smetransactionId);
923 pBuf += sizeof(uint16_t);
924
925 /* statusCode */
926 lim_copy_u32(pBuf, reasonCode);
927 pBuf += sizeof(tSirResultCodes);
928
929 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530930 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 pBuf += sizeof(tSirMacAddr);
932
933 /* Clear Station Stats */
934 /* for sta, it is always 1, IBSS is handled at halInitSta */
935
936#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
937
938 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
939 psessionEntry, (uint16_t) reasonCode, 0);
940#endif
941 pMsg = (uint32_t *) pSirSmeDisassocRsp;
942 break;
943
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530944 case eLIM_PEER_ENTITY_DISASSOC:
945 case eLIM_LINK_MONITORING_DISASSOC:
946 sir_sme_dis_ind =
947 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
948 if (!sir_sme_dis_ind) {
949 lim_log(pMac, LOGE,
950 FL("call to AllocateMemory failed for disconnect indication"));
951 return;
952 }
953
954 lim_log(pMac, LOG1,
955 FL("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d"),
956 reasonCode);
957
958 sir_sme_dis_ind->message_type =
959 eWNI_SME_DISCONNECT_DONE_IND;
960 sir_sme_dis_ind->length =
961 sizeof(*sir_sme_dis_ind);
962 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
963 sizeof(tSirMacAddr));
964 sir_sme_dis_ind->session_id = smesessionId;
965 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +0530966 /*
967 * Instead of sending deauth reason code as 505 which is
968 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
969 * Send reason code as zero to Supplicant
970 */
971 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
972 sir_sme_dis_ind->reason_code = 0;
973 else
974 sir_sme_dis_ind->reason_code = reasonCode;
975
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530976 pMsg = (uint32_t *)sir_sme_dis_ind;
977
978 break;
979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 default:
981 /**
982 * Disassociation indication due to Disassociation
983 * frame reception from peer entity or due to
984 * loss of link with peer entity.
985 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530986 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 if (NULL == pSirSmeDisassocInd) {
988 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530989 lim_log(pMac, LOGE, FL("Memory allocation failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 failure = true;
991 goto error;
992 }
993 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
994 "retCode: %d for " MAC_ADDRESS_STR),
995 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
996 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
997 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
998
999 /* Update SME session Id and Transaction Id */
1000 pSirSmeDisassocInd->sessionId = smesessionId;
1001 pSirSmeDisassocInd->transactionId = smetransactionId;
1002 pSirSmeDisassocInd->reasonCode = reasonCode;
1003 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1004
1005 lim_copy_u32(pBuf, reasonCode);
1006 pBuf += sizeof(tSirResultCodes);
1007
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301008 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 pBuf += sizeof(tSirMacAddr);
1010
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301011 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012
1013#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1014 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1015 psessionEntry, (uint16_t) reasonCode, 0);
1016#endif
1017 pMsg = (uint32_t *) pSirSmeDisassocInd;
1018
1019 break;
1020 }
1021
1022error:
1023 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001024 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026
1027 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301028 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 (uint32_t *) pMsg);
1030} /*** end lim_send_sme_disassoc_ntf() ***/
1031
1032/** -----------------------------------------------------------------
1033 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1034
1035 After receiving disassociation frame from peer entity, this
1036 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1037 reason code.
1038
1039 \param pMac - global mac structure
1040 \param pStaDs - station dph hash node
1041 \return none
1042 \sa
1043 ----------------------------------------------------------------- */
1044void
1045lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1046 tpPESession psessionEntry)
1047{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001048 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 tSirSmeDisassocInd *pSirSmeDisassocInd;
1050
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301051 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301053 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1055 return;
1056 }
1057
1058 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1059 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1060
1061 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1062 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301063 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1065
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301066 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301067 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301069 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301070 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071
1072 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1073
1074 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1075 mmhMsg.bodyptr = pSirSmeDisassocInd;
1076 mmhMsg.bodyval = 0;
1077
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301078 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1079 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1081 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1082 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1083#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1084
1085 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1086
1087} /*** end lim_send_sme_disassoc_ind() ***/
1088
1089/** -----------------------------------------------------------------
1090 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1091
1092 After receiving deauthentication frame from peer entity, this
1093 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1094 reason code.
1095
1096 \param pMac - global mac structure
1097 \param pStaDs - station dph hash node
1098 \return none
1099 \sa
1100 ----------------------------------------------------------------- */
1101void
1102lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1103 tpPESession psessionEntry)
1104{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001105 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 tSirSmeDeauthInd *pSirSmeDeauthInd;
1107
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301108 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301110 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1112 return;
1113 }
1114
1115 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1116 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1117
1118 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1119 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1120 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1121 pSirSmeDeauthInd->statusCode =
1122 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1123 } else {
1124 /* Need to indicatet he reascon code over the air */
1125 pSirSmeDeauthInd->statusCode =
1126 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1127 }
1128 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301129 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301130 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301132 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301133 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1135
1136 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001137 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1138 pStaDs->mlmStaContext.disassocReason)
1139 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140
1141 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1142 mmhMsg.bodyptr = pSirSmeDeauthInd;
1143 mmhMsg.bodyval = 0;
1144
1145 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1146#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1147 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1148 0, pStaDs->mlmStaContext.cleanupTrigger);
1149#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1150
1151 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1152 return;
1153} /*** end lim_send_sme_deauth_ind() ***/
1154
1155#ifdef FEATURE_WLAN_TDLS
1156/**
1157 * lim_send_sme_tdls_del_sta_ind()
1158 *
1159 ***FUNCTION:
1160 * This function is called to send the TDLS STA context deletion to SME.
1161 *
1162 ***LOGIC:
1163 *
1164 ***ASSUMPTIONS:
1165 *
1166 ***NOTE:
1167 * NA
1168 *
1169 * @param pMac - Pointer to global MAC structure
1170 * @param pStaDs - Pointer to internal STA Datastructure
1171 * @param psessionEntry - Pointer to the session entry
1172 * @param reasonCode - Reason for TDLS sta deletion
1173 * @return None
1174 */
1175void
1176lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1177 tpPESession psessionEntry, uint16_t reasonCode)
1178{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001179 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1181
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301182 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001183 if (NULL == pSirTdlsDelStaInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301184 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001185 FL
1186 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1187 return;
1188 }
Nitesh Shah82c52812016-12-27 12:27:51 +05301189 lim_log(pMac, LOG1, FL("Delete TDLS Peer "MAC_ADDRESS_STR
1190 "with reason code %d"),
1191 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 /* messageType */
1193 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1194 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1195
1196 /* sessionId */
1197 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1198
1199 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301200 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301201 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202
1203 /* staId */
1204 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1205 (uint16_t) pStaDs->staIndex);
1206
1207 /* reasonCode */
1208 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1209
1210 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1211 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1212 mmhMsg.bodyval = 0;
1213
1214 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1215 return;
1216} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1217
1218/**
1219 * lim_send_sme_tdls_delete_all_peer_ind()
1220 *
1221 ***FUNCTION:
1222 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1223 * message to SME.
1224 *
1225 ***LOGIC:
1226 *
1227 ***ASSUMPTIONS:
1228 *
1229 ***NOTE:
1230 * NA
1231 *
1232 * @param pMac - Pointer to global MAC structure
1233 * @param psessionEntry - Pointer to the session entry
1234 * @return None
1235 */
1236void
1237lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1238{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001239 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1241
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301242 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 if (NULL == pSirTdlsDelAllPeerInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301244 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 FL
1246 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1247 return;
1248 }
1249 /* messageType */
1250 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1251 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1252
1253 /* sessionId */
1254 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1255
1256 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1257 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1258 mmhMsg.bodyval = 0;
1259
1260 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1261 return;
1262} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1263
1264/**
1265 * lim_send_sme_mgmt_tx_completion()
1266 *
1267 ***FUNCTION:
1268 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1269 * message to SME.
1270 *
1271 ***LOGIC:
1272 *
1273 ***ASSUMPTIONS:
1274 *
1275 ***NOTE:
1276 * NA
1277 *
1278 * @param pMac - Pointer to global MAC structure
1279 * @param psessionEntry - Pointer to the session entry
1280 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1281 * @return None
1282 */
1283void
1284lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301285 uint32_t sme_session_id,
1286 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001288 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1290
1291 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301292 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301294 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 FL
1296 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1297 return;
1298 }
1299 /* messageType */
1300 pSirMgmtTxCompletionInd->messageType =
1301 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1302 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1303
1304 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301305 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306
1307 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1308
1309 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1310 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1311 mmhMsg.bodyval = 0;
1312
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001313#ifdef CONVERGED_TDLS_ENABLE
1314 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1315 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1316 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1317 return;
1318#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1320 return;
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001321#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1323
1324void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1325 void *events)
1326{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001327 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328
1329 switch (msgType) {
1330 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1331 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1332 break;
1333 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1334 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1335 break;
1336 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1337 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1338 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001339 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1340 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1341 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 }
1343
1344 mmhMsg.bodyptr = events;
1345 mmhMsg.bodyval = 0;
1346 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1347 return;
1348}
1349#endif /* FEATURE_WLAN_TDLS */
1350
1351/**
1352 * lim_send_sme_deauth_ntf()
1353 *
1354 ***FUNCTION:
1355 * This function is called by limProcessSmeMessages() to send
1356 * eWNI_SME_DISASSOC_RSP/IND message to host
1357 *
1358 ***PARAMS:
1359 *
1360 ***LOGIC:
1361 *
1362 ***ASSUMPTIONS:
1363 * NA
1364 *
1365 ***NOTE:
1366 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1367 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1368 *
1369 * @param peerMacAddr Indicates the peer MAC addr to which
1370 * deauthentication was initiated
1371 * @param reasonCode Indicates the reason for Deauthetication
1372 * @param deauthTrigger Indicates the trigger for Deauthetication
1373 * @param aid Indicates the STAID. This parameter is present
1374 * only on AP.
1375 *
1376 * @return None
1377 */
1378void
1379lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1380 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1381 uint16_t aid, uint8_t smesessionId,
1382 uint16_t smetransactionId)
1383{
1384 uint8_t *pBuf;
1385 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1386 tSirSmeDeauthInd *pSirSmeDeauthInd;
1387 tpPESession psessionEntry;
1388 uint8_t sessionId;
1389 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301390 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391
1392 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1393 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 case eLIM_HOST_DEAUTH:
1395 /**
1396 * Deauthentication response to host triggered
1397 * deauthentication.
1398 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301399 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 if (NULL == pSirSmeDeauthRsp) {
1401 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301402 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 FL
1404 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1405
1406 return;
1407 }
1408 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1409 "retCode: %d for" MAC_ADDRESS_STR),
1410 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1411 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1412 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1413 pSirSmeDeauthRsp->statusCode = reasonCode;
1414 pSirSmeDeauthRsp->sessionId = smesessionId;
1415 pSirSmeDeauthRsp->transactionId = smetransactionId;
1416
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001417 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301418 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419
1420#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1421 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1422 psessionEntry, 0, (uint16_t) reasonCode);
1423#endif
1424 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1425
1426 break;
1427
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301428 case eLIM_PEER_ENTITY_DEAUTH:
1429 case eLIM_LINK_MONITORING_DEAUTH:
1430 sir_sme_dis_ind =
1431 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1432 if (!sir_sme_dis_ind) {
1433 lim_log(pMac, LOGE,
1434 FL("call to AllocateMemory failed for disconnect indication"));
1435 return;
1436 }
1437
1438 lim_log(pMac, LOG1,
1439 FL("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d"),
1440 reasonCode);
1441
1442 sir_sme_dis_ind->message_type =
1443 eWNI_SME_DISCONNECT_DONE_IND;
1444 sir_sme_dis_ind->length =
1445 sizeof(*sir_sme_dis_ind);
1446 sir_sme_dis_ind->session_id = smesessionId;
1447 sir_sme_dis_ind->reason_code = reasonCode;
1448 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1449 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301450 /*
1451 * Instead of sending deauth reason code as 505 which is
1452 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1453 * Send reason code as zero to Supplicant
1454 */
1455 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1456 sir_sme_dis_ind->reason_code = 0;
1457 else
1458 sir_sme_dis_ind->reason_code = reasonCode;
1459
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301460 pMsg = (uint32_t *)sir_sme_dis_ind;
1461
1462 break;
1463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 default:
1465 /**
1466 * Deauthentication indication due to Deauthentication
1467 * frame reception from peer entity or due to
1468 * loss of link with peer entity.
1469 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301470 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471 if (NULL == pSirSmeDeauthInd) {
1472 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301473 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 FL
1475 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1476
1477 return;
1478 }
1479 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1480 "retCode: %d for " MAC_ADDRESS_STR),
1481 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1482 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1483 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1484 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1485
1486 /* sessionId */
1487 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1488 *pBuf++ = smesessionId;
1489
1490 /* transaction ID */
1491 lim_copy_u16(pBuf, smetransactionId);
1492 pBuf += sizeof(uint16_t);
1493
1494 /* status code */
1495 lim_copy_u32(pBuf, reasonCode);
1496 pBuf += sizeof(tSirResultCodes);
1497
1498 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301499 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500 pBuf += sizeof(tSirMacAddr);
1501
1502 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301503 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301504 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505
1506#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1507 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1508 psessionEntry, 0, (uint16_t) reasonCode);
1509#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1510 pMsg = (uint32_t *) pSirSmeDeauthInd;
1511
1512 break;
1513 }
1514
1515 /*Delete the PE session created */
1516 if (psessionEntry != NULL) {
1517 pe_delete_session(pMac, psessionEntry);
1518 }
1519
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301520 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 (uint32_t *) pMsg);
1522
1523} /*** end lim_send_sme_deauth_ntf() ***/
1524
1525/**
1526 * lim_send_sme_wm_status_change_ntf() - Send Notification
1527 * @mac_ctx: Global MAC Context
1528 * @status_change_code: Indicates the change in the wireless medium.
1529 * @status_change_info: Indicates the information associated with
1530 * change in the wireless medium.
1531 * @info_len: Indicates the length of status change information
1532 * being sent.
1533 * @session_id SessionID
1534 *
1535 * This function is called by limProcessSmeMessages() to send
1536 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1537 *
1538 * Return: None
1539 */
1540void
1541lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1542 tSirSmeStatusChangeCode status_change_code,
1543 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1544{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001545 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001547 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301549 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 if (NULL == wm_status_change_ntf) {
1551 lim_log(mac_ctx, LOGE,
1552 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1553 return;
1554 }
1555
1556 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1557 msg.bodyval = 0;
1558 msg.bodyptr = wm_status_change_ntf;
1559
1560 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001561 case eSIR_SME_AP_CAPS_CHANGED:
1562 max_info_len = sizeof(tSirSmeApNewCaps);
1563 break;
1564 case eSIR_SME_JOINED_NEW_BSS:
1565 max_info_len = sizeof(tSirSmeNewBssInfo);
1566 break;
1567 default:
1568 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1569 break;
1570 }
1571
1572 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 case eSIR_SME_RADAR_DETECTED:
1574 break;
1575 default:
1576 wm_status_change_ntf->messageType =
1577 eWNI_SME_WM_STATUS_CHANGE_NTF;
1578 wm_status_change_ntf->statusChangeCode = status_change_code;
1579 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1580 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001581 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301582 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1584 (uint8_t *) status_change_info, info_len);
1585 }
1586 lim_log(mac_ctx, LOGE,
1587 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1588 status_change_code, info_len);
1589 break;
1590 }
1591
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301592 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301594 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301595 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 FL("lim_sys_process_mmh_msg_api failed"));
1597 }
1598
1599} /*** end lim_send_sme_wm_status_change_ntf() ***/
1600
1601/**
1602 * lim_send_sme_set_context_rsp()
1603 *
1604 ***FUNCTION:
1605 * This function is called by limProcessSmeMessages() to send
1606 * eWNI_SME_SETCONTEXT_RSP message to host
1607 *
1608 ***PARAMS:
1609 *
1610 ***LOGIC:
1611 *
1612 ***ASSUMPTIONS:
1613 * NA
1614 *
1615 ***NOTE:
1616 *
1617 * @param pMac Pointer to Global MAC structure
1618 * @param peerMacAddr Indicates the peer MAC addr to which
1619 * setContext was performed
1620 * @param aid Indicates the aid corresponding to the peer MAC
1621 * address
1622 * @param resultCode Indicates the result of previously issued
1623 * eWNI_SME_SETCONTEXT_RSP message
1624 *
1625 * @return None
1626 */
1627void
1628lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301629 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 tSirResultCodes resultCode,
1631 tpPESession psessionEntry, uint8_t smesessionId,
1632 uint16_t smetransactionId)
1633{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001634 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1636
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301637 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 if (NULL == pSirSmeSetContextRsp) {
1639 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301640 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 FL
1642 ("call to AllocateMemory failed for SmeSetContextRsp"));
1643
1644 return;
1645 }
1646
1647 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1648 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1649 pSirSmeSetContextRsp->statusCode = resultCode;
1650
Anurag Chouhanc5548422016-02-24 18:33:27 +05301651 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652
1653 /* Update SME session and transaction Id */
1654 pSirSmeSetContextRsp->sessionId = smesessionId;
1655 pSirSmeSetContextRsp->transactionId = smetransactionId;
1656
1657 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1658 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1659 mmhMsg.bodyval = 0;
1660 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301661 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1662 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301664 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1665 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 }
1667
1668#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1669 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1670 psessionEntry, (uint16_t) resultCode, 0);
1671#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1672
1673 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1674} /*** end lim_send_sme_set_context_rsp() ***/
1675
1676/**
1677 * lim_send_sme_neighbor_bss_ind()
1678 *
1679 ***FUNCTION:
1680 * This function is called by lim_lookup_nadd_hash_entry() to send
1681 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1682 *
1683 ***PARAMS:
1684 *
1685 ***LOGIC:
1686 *
1687 ***ASSUMPTIONS:
1688 * NA
1689 *
1690 ***NOTE:
1691 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1692 * host upon detecting new BSS during background scanning if CFG
1693 * option is enabled for sending such indication
1694 *
1695 * @param pMac - Pointer to Global MAC structure
1696 * @return None
1697 */
1698
1699void
1700lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1701{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001702 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 uint32_t val;
1704 tSirSmeNeighborBssInd *pNewBssInd;
1705
1706 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1707 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1708 pMac->lim.gLimRspReqd)) {
1709 /* LIM is not in background scan state OR */
1710 /* current scan is initiated by HDD. */
1711 /* No need to send new BSS indication to HDD */
1712 return;
1713 }
1714
1715 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1716 eSIR_SUCCESS) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301717 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1719
1720 return;
1721 }
1722
1723 if (val == 0)
1724 return;
1725
1726 /**
1727 * Need to indicate new BSSs found during
1728 * background scanning to host.
1729 * Allocate buffer for sending indication.
1730 * Length of buffer is length of BSS description
1731 * and length of header itself
1732 */
1733 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1734 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301735 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 if (NULL == pNewBssInd) {
1737 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301738 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 FL
1740 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1741
1742 return;
1743 }
1744
1745 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1746 pNewBssInd->length = (uint16_t) val;
1747 pNewBssInd->sessionId = 0;
1748
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301749 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 (uint8_t *) &pBssDescr->bssDescription,
1751 pBssDescr->bssDescription.length + sizeof(uint16_t));
1752
1753 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1754 msgQ.bodyptr = pNewBssInd;
1755 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301756 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1758} /*** end lim_send_sme_neighbor_bss_ind() ***/
1759
1760/** -----------------------------------------------------------------
1761 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1762 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1763 \ SME only looks at rc and tspec field.
1764 \param pMac - global mac structure
1765 \param rspReqd - is SmeAddTsRsp required
1766 \param status - status code of SME_ADD_TS_RSP
1767 \return tspec
1768 \sa
1769 ----------------------------------------------------------------- */
1770void
1771lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1772 tpPESession psessionEntry, tSirMacTspecIE tspec,
1773 uint8_t smesessionId, uint16_t smetransactionId)
1774{
1775 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001776 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777
1778 if (!rspReqd)
1779 return;
1780
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301781 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 if (NULL == rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301783 lim_log(pMac, LOGE, FL("AllocateMemory failed for ADDTS_RSP"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 return;
1785 }
1786
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 rsp->messageType = eWNI_SME_ADDTS_RSP;
1788 rsp->rc = status;
1789 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1790 rsp->rsp.tspec = tspec;
1791 /* Update SME session Id and transcation Id */
1792 rsp->sessionId = smesessionId;
1793 rsp->transactionId = smetransactionId;
1794
1795 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1796 mmhMsg.bodyptr = rsp;
1797 mmhMsg.bodyval = 0;
1798 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301799 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1800 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301802 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1803 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 }
1805#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1806 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1807 0);
1808#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1809
1810 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1811 return;
1812}
1813
1814void
1815lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1816 tpPESession psessionEntry, uint8_t smesessionId,
1817 uint16_t smetransactionId)
1818{
1819 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001820 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301822 lim_log(pMac, LOGD, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 delts->aid,
1824 delts->req.tsinfo.traffic.tsid,
1825 delts->req.tsinfo.traffic.userPrio, status);
1826 if (!delts->rspReqd)
1827 return;
1828
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301829 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 if (NULL == rsp) {
1831 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301832 lim_log(pMac, LOGE, FL("AllocateMemory failed for DELTS_RSP"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 return;
1834 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835
1836 if (psessionEntry != NULL) {
1837
1838 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301839 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301840 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 sizeof(tSirDeltsReqInfo));
1842 }
1843
1844 rsp->messageType = eWNI_SME_DELTS_RSP;
1845 rsp->rc = status;
1846
1847 /* Update SME session Id and transcation Id */
1848 rsp->sessionId = smesessionId;
1849 rsp->transactionId = smetransactionId;
1850
1851 mmhMsg.type = eWNI_SME_DELTS_RSP;
1852 mmhMsg.bodyptr = rsp;
1853 mmhMsg.bodyval = 0;
1854 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301855 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1856 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301858 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1859 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 }
1861#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1862 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1863 (uint16_t) status, 0);
1864#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1865
1866 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1867}
1868
1869void
1870lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1871 tpPESession psessionEntry)
1872{
1873 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001874 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301876 lim_log(pMac, LOGD, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1878
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301879 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 if (NULL == rsp) {
1881 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301882 lim_log(pMac, LOGE, FL("AllocateMemory failed for DELTS_IND"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 return;
1884 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885
1886 rsp->messageType = eWNI_SME_DELTS_IND;
1887 rsp->rc = eSIR_SUCCESS;
1888 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301889 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890
1891 /* Update SME session Id and SME transaction Id */
1892
1893 rsp->sessionId = psessionEntry->smeSessionId;
1894 rsp->transactionId = psessionEntry->transactionId;
1895
1896 mmhMsg.type = eWNI_SME_DELTS_IND;
1897 mmhMsg.bodyptr = rsp;
1898 mmhMsg.bodyval = 0;
1899 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1900#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1901 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1902 0);
1903#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1904
1905 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1906}
1907
1908/**
1909 * lim_send_sme_pe_statistics_rsp()
1910 *
1911 ***FUNCTION:
1912 * This function is called to send 802.11 statistics response to HDD.
1913 * This function posts the result back to HDD. This is a response to
1914 * HDD's request for statistics.
1915 *
1916 ***PARAMS:
1917 *
1918 ***LOGIC:
1919 *
1920 ***ASSUMPTIONS:
1921 * NA
1922 *
1923 ***NOTE:
1924 * NA
1925 *
1926 * @param pMac Pointer to Global MAC structure
1927 * @param p80211Stats Statistics sent in response
1928 * @param resultCode TODO:
1929 *
1930 *
1931 * @return none
1932 */
1933
1934void
1935lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1936{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001937 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 uint8_t sessionId;
1939 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1940 tpPESession pPeSessionEntry;
1941
1942 /* Get the Session Id based on Sta Id */
1943 pPeSessionEntry =
1944 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1945
1946 /* Fill the Session Id */
1947 if (NULL != pPeSessionEntry) {
1948 /* Fill the Session Id */
1949 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1950 }
1951
1952 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1953
1954 /* msgType should be WMA_GET_STATISTICS_RSP */
1955 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1956
1957 mmhMsg.bodyptr = stats;
1958 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301959 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1961
1962 return;
1963
1964} /*** end lim_send_sme_pe_statistics_rsp() ***/
1965
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001966#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001968 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1969 * @pMac: Pointer to global pMac structure
1970 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 * This function is called to send tsm stats response to HDD.
1973 * This function posts the result back to HDD. This is a response to
1974 * HDD's request to get tsm stats.
1975 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001976 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001978void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1979 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001981 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 uint8_t sessionId;
1983 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1984 tpPESession pPeSessionEntry = NULL;
1985
1986 /* Get the Session Id based on Sta Id */
1987 pPeSessionEntry =
1988 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1989
1990 /* Fill the Session Id */
1991 if (NULL != pPeSessionEntry) {
1992 /* Fill the Session Id */
1993 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1994 } else {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301995 lim_log(pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1996 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301997 qdf_mem_free(pPeStats->tsmStatsReq);
1998 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 return;
2000 }
2001
2002 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
2003 pPeStats->tsmMetrics.RoamingCount
2004 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
2005 pPeStats->tsmMetrics.RoamingDly
2006 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
2007
2008 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
2009 mmhMsg.bodyptr = pStats;
2010 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302011 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2013
2014 return;
2015} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
2016
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002017#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018
2019void
2020lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
2021 tSirMacAddr peerMacAddr,
2022 uint16_t staIndex,
2023 uint8_t ucastIdx,
2024 uint8_t bcastIdx,
2025 uint8_t *beacon,
2026 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
2027{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002028 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 tSmeIbssPeerInd *pNewPeerInd;
2030
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302031 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 if (NULL == pNewPeerInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302033 lim_log(pMac, LOGE, FL("Failed to allocate memory"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 return;
2035 }
2036
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302037 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302038 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 pNewPeerInd->staId = staIndex;
2040 pNewPeerInd->ucastSig = ucastIdx;
2041 pNewPeerInd->bcastSig = bcastIdx;
2042 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
2043 pNewPeerInd->mesgType = msgType;
2044 pNewPeerInd->sessionId = sessionId;
2045
2046 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302047 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2049 beaconLen);
2050 }
2051
2052 mmhMsg.type = msgType;
2053 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302054 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2056
2057}
2058
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002059/**
2060 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
2061 * @mac_ctx: pointer to global adapter context
2062 * @csa_params: pointer to CSA parameters
2063 * @chnl_switch_info:pointer to channel switch parameters
2064 * @session_entry: session pointer
2065 *
2066 * Return: None
2067 */
2068static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002069 struct csa_offload_params *csa_params,
2070 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
2071 tpPESession session_entry)
2072{
Amar Singhal5cccafe2017-02-15 12:42:58 -08002073 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002074 uint8_t ap_new_ch_width;
2075 bool new_ch_width_dfn = false;
2076 uint8_t center_freq_diff;
2077
2078 ap_new_ch_width = csa_params->new_ch_width + 1;
2079 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2080 csa_params->new_ch_freq_seg2) {
2081 new_ch_width_dfn = true;
2082 if (csa_params->new_ch_freq_seg2 >
2083 csa_params->new_ch_freq_seg1)
2084 center_freq_diff = csa_params->new_ch_freq_seg2 -
2085 csa_params->new_ch_freq_seg1;
2086 else
2087 center_freq_diff = csa_params->new_ch_freq_seg1 -
2088 csa_params->new_ch_freq_seg2;
2089 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2090 ap_new_ch_width = CH_WIDTH_160MHZ;
2091 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2092 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2093 else
2094 ap_new_ch_width = CH_WIDTH_80MHZ;
2095 }
2096 session_entry->gLimChannelSwitch.state =
2097 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2098 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2099 !new_ch_width_dfn) {
2100 ch_params.ch_width = CH_WIDTH_160MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002101 wlan_reg_set_channel_params(mac_ctx->pdev,
2102 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002103 ap_new_ch_width = ch_params.ch_width;
2104 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2105 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2106 }
2107 chnl_switch_info->newChanWidth = ap_new_ch_width;
2108 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2109 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2110
2111 if (session_entry->ch_width == ap_new_ch_width)
2112 goto prnt_log;
2113
2114 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2115 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2116 chnl_switch_info->newCenterChanFreq1 = 0;
2117 } else {
2118 session_entry->ch_width = ap_new_ch_width;
2119 chnl_switch_info->newChanWidth = ap_new_ch_width;
2120 }
2121prnt_log:
2122 lim_log(mac_ctx, LOG1,
2123 FL("new channel: %d new_ch_width:%d seg0:%d seg1:%d"),
2124 csa_params->channel,
2125 chnl_switch_info->newChanWidth,
2126 chnl_switch_info->newCenterChanFreq0,
2127 chnl_switch_info->newCenterChanFreq1);
2128}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129/**
2130 * lim_handle_csa_offload_msg() - Handle CSA offload message
2131 * @mac_ctx: pointer to global adapter context
2132 * @msg: Message pointer.
2133 *
2134 * Return: None
2135 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002136void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2137 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138{
2139 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002140 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302141 struct csa_offload_params *csa_params =
2142 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143 tpSmeCsaOffloadInd csa_offload_ind;
2144 tpDphHashNode sta_ds = NULL;
2145 uint8_t session_id;
2146 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302147 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002148 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302149
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002151 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302153 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 if (!csa_params) {
2156 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2157 return;
2158 }
2159
2160 session_entry =
2161 pe_find_session_by_bssid(mac_ctx,
2162 csa_params->bssId, &session_id);
2163 if (!session_entry) {
2164 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302165 FL("Session does not exists for %pM"),
2166 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 goto err;
2168 }
2169
2170 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2171 &session_entry->dph.dphHashTable);
2172
2173 if (!sta_ds) {
2174 lim_log(mac_ctx, LOGE,
2175 FL("sta_ds does not exist"));
2176 goto err;
2177 }
2178
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002179 if (!LIM_IS_STA_ROLE(session_entry)) {
2180 lim_log(mac_ctx, LOG1, FL("Invalid role to handle CSA"));
2181 goto err;
2182 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302183
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002184 /*
2185 * on receiving channel switch announcement from AP, delete all
2186 * TDLS peers before leaving BSS and proceed for channel switch
2187 */
2188 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302189
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002190 lim_ch_switch = &session_entry->gLimChannelSwitch;
2191 session_entry->gLimChannelSwitch.switchMode =
2192 csa_params->switch_mode;
2193 /* timer already started by firmware, switch immediately */
2194 session_entry->gLimChannelSwitch.switchCount = 0;
2195 session_entry->gLimChannelSwitch.primaryChannel =
2196 csa_params->channel;
2197 session_entry->gLimChannelSwitch.state =
2198 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2199 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2200 lim_ch_switch->sec_ch_offset =
2201 session_entry->htSecondaryChannelOffset;
2202 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2203 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2204 chnl_switch_info =
2205 &session_entry->gLimWiderBWChannelSwitch;
2206
2207 lim_log(mac_ctx, LOG1,
2208 FL("vht:%d ht:%d flag:%x chan:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302209 session_entry->vhtCapability,
2210 session_entry->htSupportedChannelWidthSet,
2211 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002212 csa_params->channel);
2213 lim_log(mac_ctx, LOG1,
2214 FL("seg1:%d seg2:%d width:%d country:%s class:%d"),
2215 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302216 csa_params->new_ch_freq_seg2,
2217 csa_params->new_ch_width,
2218 mac_ctx->scan.countryCodeCurrent,
2219 csa_params->new_op_class);
2220
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002221 if (session_entry->vhtCapability &&
2222 session_entry->htSupportedChannelWidthSet) {
2223 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002224 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002225 chnl_switch_info, session_entry);
2226 lim_ch_switch->sec_ch_offset =
2227 csa_params->sec_chan_offset;
2228 } else if (csa_params->ies_present_flag
2229 & lim_xcsa_ie_present) {
2230 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002231 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002232 mac_ctx->scan.countryCodeCurrent,
2233 csa_params->channel,
2234 csa_params->new_op_class);
2235 session_entry->gLimChannelSwitch.state =
2236 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2237
2238 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002240 CH_WIDTH_80MHZ;
2241 } else if (chan_space == 40) {
2242 chnl_switch_info->newChanWidth =
2243 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002245 chnl_switch_info->newChanWidth =
2246 CH_WIDTH_20MHZ;
2247 lim_ch_switch->state =
2248 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2249 }
2250
2251 ch_params.ch_width =
2252 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002253 wlan_reg_set_channel_params(mac_ctx->pdev,
2254 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002255 chnl_switch_info->newCenterChanFreq0 =
2256 ch_params.center_freq_seg0;
2257 /*
2258 * This is not applicable for 20/40/80 MHz.
2259 * Only used when we support 80+80 MHz operation.
2260 * In case of 80+80 MHz, this parameter indicates
2261 * center channel frequency index of 80 MHz
2262 * channel offrequency segment 1.
2263 */
2264 chnl_switch_info->newCenterChanFreq1 =
2265 ch_params.center_freq_seg1;
2266 lim_ch_switch->sec_ch_offset =
2267 ch_params.sec_ch_offset;
2268
2269 }
2270 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2271 chnl_switch_info->newCenterChanFreq0;
2272 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2273 chnl_switch_info->newCenterChanFreq1;
2274 session_entry->gLimChannelSwitch.ch_width =
2275 chnl_switch_info->newChanWidth;
2276
2277 } else if (session_entry->htSupportedChannelWidthSet) {
2278 if (csa_params->ies_present_flag
2279 & lim_xcsa_ie_present) {
2280 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002281 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002282 mac_ctx->scan.countryCodeCurrent,
2283 csa_params->channel,
2284 csa_params->new_op_class);
2285 lim_ch_switch->state =
2286 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2287 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002288 lim_ch_switch->ch_width =
2289 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002290 chnl_switch_info->newChanWidth =
2291 CH_WIDTH_40MHZ;
2292 ch_params.ch_width =
2293 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002294 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002295 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002296 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002297 lim_ch_switch->ch_center_freq_seg0 =
2298 ch_params.center_freq_seg0;
2299 lim_ch_switch->sec_ch_offset =
2300 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002301 } else {
2302 lim_ch_switch->ch_width =
2303 CH_WIDTH_20MHZ;
2304 chnl_switch_info->newChanWidth =
2305 CH_WIDTH_40MHZ;
2306 lim_ch_switch->state =
2307 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2308 lim_ch_switch->sec_ch_offset =
2309 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002311 } else {
2312 lim_ch_switch->ch_width =
2313 CH_WIDTH_40MHZ;
2314 lim_ch_switch->state =
2315 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2316 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002317 wlan_reg_set_channel_params(mac_ctx->pdev,
2318 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002319 lim_ch_switch->ch_center_freq_seg0 =
2320 ch_params.center_freq_seg0;
2321 lim_ch_switch->sec_ch_offset =
2322 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002324
2325 }
2326 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302327 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002329 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2330 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2331 if (NULL == csa_offload_ind) {
2332 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002334 goto err;
2335 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002337 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2338 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2339 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2340 QDF_MAC_ADDR_SIZE);
2341 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2342 mmh_msg.bodyptr = csa_offload_ind;
2343 mmh_msg.bodyval = 0;
2344 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002345 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002346 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2348#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002349 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2351 eSIR_SUCCESS, eSIR_SUCCESS);
2352#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002353 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354
2355err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302356 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357}
2358
2359/*--------------------------------------------------------------------------
2360 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2361
2362 \param pMac - pointer to global adapter context
2363 \param sessionId - Message pointer.
2364
2365 \sa
2366 --------------------------------------------------------------------------*/
2367
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002368void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369{
2370 tpPESession psessionEntry;
2371 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2372
2373 psessionEntry =
2374 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2375 if (psessionEntry == NULL) {
2376 lim_log(pMac, LOGE,
2377 FL("Session Does not exist for given sessionID %d"),
2378 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002379 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 return;
2381 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002382 /*
2383 * During DEL BSS handling, the PE Session will be deleted, but it is
2384 * better to clear this flag if the session is hanging around due
2385 * to some error conditions so that the next DEL_BSS request does
2386 * not take the HO_FAIL path
2387 */
2388 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002389 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002390 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002391 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002392 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002393 else if (LIM_IS_NDI_ROLE(psessionEntry))
2394 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 else
2396 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2397
2398}
2399
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400/** -----------------------------------------------------------------
2401 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2402 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2403 \ SME only looks at rc and tspec field.
2404 \param pMac - global mac structure
2405 \param rspReqd - is SmeAddTsRsp required
2406 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2407 \return tspec
2408 \sa
2409 ----------------------------------------------------------------- */
2410void
2411lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2412 uint8_t smesessionId)
2413{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002414 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415
2416 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2417 mmhMsg.bodyptr = aggrQosRsp;
2418 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302419 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2420 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2422
2423 return;
2424}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425
2426void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2427 uint8_t smesessionId)
2428{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002429 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 tSmeMaxAssocInd *pSmeMaxAssocInd;
2431
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302432 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302434 lim_log(pMac, LOGE, FL("Failed to allocate memory"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 return;
2436 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302437 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302438 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2440 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2441 pSmeMaxAssocInd->sessionId = smesessionId;
2442 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2443 mmhMsg.bodyptr = pSmeMaxAssocInd;
2444 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2445 " sme session id %d"),
2446 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2447 MAC_ADDR_ARRAY(peerMacAddr));
2448 )
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302449 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2450 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2452
2453 return;
2454}
2455
2456/** -----------------------------------------------------------------
2457 \brief lim_send_sme_dfs_event_notify() - sends
2458 eWNI_SME_DFS_RADAR_FOUND
2459 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2460 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2461 that a RADAR is found on current operating channel and SAP-
2462 has to move to a new channel.
2463 \param pMac - global mac structure
2464 \param msgType - message type received from lower layer
2465 \param event - event data received from lower layer
2466 \return none
2467 \sa
2468 ----------------------------------------------------------------- */
2469void
2470lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2471{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002472 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2474 mmhMsg.bodyptr = event;
2475 mmhMsg.bodyval = 0;
2476 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2477 return;
2478}
2479
2480/*--------------------------------------------------------------------------
2481 \brief lim_send_dfs_chan_sw_ie_update()
2482 This timer handler updates the channel switch IE in beacon template
2483
2484 \param pMac - pointer to global adapter context
2485 \return - channel to scan from valid session else zero.
2486 \sa
2487 --------------------------------------------------------------------------*/
2488static void
2489lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2490{
2491
2492 /* Update the beacon template and send to FW */
2493 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302494 lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495 return;
2496 }
2497
2498 /* Send update beacon template message */
2499 lim_send_beacon_ind(pMac, psessionEntry);
2500 PELOG1(lim_log(pMac, LOG1,
2501 FL(" Updated CSA IE, IE COUNT = %d"),
2502 psessionEntry->gLimChannelSwitch.switchCount);
2503 )
2504
2505 return;
2506}
2507
2508/** -----------------------------------------------------------------
2509 \brief lim_send_sme_ap_channel_switch_resp() - sends
2510 eWNI_SME_CHANNEL_CHANGE_RSP
2511 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2512 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2513 that the Channel change has been done to the specified target
2514 channel in the Channel change request
2515 \param pMac - global mac structure
2516 \param psessionEntry - session info
2517 \param pChnlParams - Channel switch params
2518 --------------------------------------------------------------------*/
2519void
2520lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2521 tpPESession psessionEntry,
2522 tpSwitchChannelParams pChnlParams)
2523{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002524 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 tpSwitchChannelParams pSmeSwithChnlParams;
2526 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002527 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002528 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002529 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530
2531 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302532 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302534 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2536 return;
2537 }
2538
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302539 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 sizeof(tSwitchChannelParams));
2541
2542 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002543 ch_width = pSmeSwithChnlParams->ch_width;
2544 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545
2546 /*
2547 * Pass the sme sessionID to SME instead
2548 * PE session ID.
2549 */
2550 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2551
2552 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2553 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2554 mmhMsg.bodyval = 0;
2555 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2556
2557 /*
2558 * We should start beacon transmission only if the new
2559 * channel after channel change is Non-DFS. For a DFS
2560 * channel, PE will receive an explicit request from
2561 * upper layers to start the beacon transmission .
2562 */
2563
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002564 if (ch_width == CH_WIDTH_160MHZ) {
2565 is_ch_dfs = true;
2566 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002567 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2568 CHANNEL_STATE_DFS ||
2569 wlan_reg_get_channel_state(pMac->pdev,
2570 ch_center_freq_seg1 -
2571 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002572 CHANNEL_STATE_DFS)
2573 is_ch_dfs = true;
2574 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002575 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2576 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002577 is_ch_dfs = true;
2578 }
2579
2580 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 if (channelId == psessionEntry->currentOperChannel) {
2582 lim_apply_configuration(pMac, psessionEntry);
2583 lim_send_beacon_ind(pMac, psessionEntry);
2584 } else {
2585 PELOG1(lim_log(pMac, LOG1,
2586 FL
2587 ("Failed to Transmit Beacons on channel = %d"
2588 "after AP channel change response"),
2589 psessionEntry->bcnLen);
2590 )
2591 }
2592 }
2593 return;
2594}
2595
2596/** -----------------------------------------------------------------
2597 \brief lim_process_beacon_tx_success_ind() - This function is used
2598 explicitely to handle successful beacon transmission indication
2599 from the FW. This is a generic event generated by the FW afer the
2600 first beacon is sent out after the beacon template update by the
2601 host
2602 \param pMac - global mac structure
2603 \param psessionEntry - session info
2604 \return none
2605 \sa
2606 ----------------------------------------------------------------- */
2607void
2608lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2609{
2610 /* Currently, this event is used only for DFS channel switch announcement
2611 * IE update in the template. If required to be used for other IE updates
2612 * add appropriate code by introducing a state variable
2613 */
2614 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002615 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2617 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2618 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2619 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2620 (tSirFirstBeaconTxCompleteInd *) event;
2621
2622 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2623 if (psessionEntry == NULL) {
2624 lim_log(pMac, LOGE,
2625 FL("Session Does not exist for given sessionID"));
2626 return;
2627 }
2628
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302629 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2630 GET_LIM_SYSTEM_ROLE(psessionEntry),
2631 psessionEntry->dfsIncludeChanSwIe,
2632 psessionEntry->gLimOperatingMode.present);
2633
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634 if (LIM_IS_AP_ROLE(psessionEntry) &&
2635 true == psessionEntry->dfsIncludeChanSwIe) {
2636 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2637 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2638 /*
2639 * Send the next beacon with updated CSA IE count
2640 */
2641 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2642 /* Decrement the IE count */
2643 psessionEntry->gLimChannelSwitch.switchCount--;
2644 } else {
2645 /* Done with CSA IE update, send response back to SME */
2646 psessionEntry->gLimChannelSwitch.switchCount = 0;
2647 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2648 psessionEntry->gLimChannelSwitch.switchMode = 0;
2649 psessionEntry->dfsIncludeChanSwIe = false;
2650 psessionEntry->dfsIncludeChanWrapperIe = false;
2651
2652 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302653 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654
2655 if (NULL == pChanSwTxResponse) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302656 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 FL
2658 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2659 return;
2660 }
2661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 pChanSwTxResponse->sessionId =
2663 psessionEntry->smeSessionId;
2664 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302665 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666
2667 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2668 mmhMsg.bodyptr = pChanSwTxResponse;
2669 mmhMsg.bodyval = 0;
2670 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2671 }
2672 }
2673
2674 if (LIM_IS_AP_ROLE(psessionEntry) &&
2675 psessionEntry->gLimOperatingMode.present) {
2676 /* Done with nss update, send response back to SME */
2677 psessionEntry->gLimOperatingMode.present = 0;
2678 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302679 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302681 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 FL
2683 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2684 return;
2685 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 beacon_tx_comp_rsp_ptr->session_id =
2687 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302688 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2690 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2691 mmhMsg.bodyval = 0;
2692 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2693 }
2694 return;
2695}