blob: 6e9d4947b4e44cfe36e75e47dd830a677853a9bf [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_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"
Gupta, Kapil121bf212015-11-25 19:21:29 +053058#include "cds_regdomain_common.h"
59#include "lim_send_messages.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
62 tpPESession session_entry, tSirResultCodes result_code,
63 tpSirSmeJoinRsp sme_join_rsp);
64
65/**
66 * lim_send_sme_rsp() - Send Response to upper layers
67 * @mac_ctx: Pointer to Global MAC structure
68 * @msg_type: Indicates message type
69 * @result_code: Indicates the result of previously issued
70 * eWNI_SME_msg_type_REQ message
71 *
72 * This function is called by lim_process_sme_req_messages() to send
73 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
74 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
75 * Software.
76 *
77 * Return: None
78 */
79
80void
81lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
82 tSirResultCodes result_code, uint8_t sme_session_id,
83 uint16_t sme_transaction_id)
84{
85 tSirMsgQ msg;
86 tSirSmeRsp *sme_rsp;
87
88 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
89 lim_msg_str(msg_type), lim_result_code_str(result_code));
90
Anurag Chouhan600c3a02016-03-01 10:33:54 +053091 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092 if (NULL == sme_rsp) {
93 /* Buffer not available. Log error */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053094 QDF_TRACE(QDF_MODULE_ID_PE, LOGP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
96 return;
97 }
98
99 sme_rsp->messageType = msg_type;
100 sme_rsp->length = sizeof(tSirSmeRsp);
101 sme_rsp->statusCode = result_code;
102
103 sme_rsp->sessionId = sme_session_id;
104 sme_rsp->transactionId = sme_transaction_id;
105
106 msg.type = msg_type;
107 msg.bodyptr = sme_rsp;
108 msg.bodyval = 0;
109 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
110
111#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
112 switch (msg_type) {
113 case eWNI_SME_STOP_BSS_RSP:
114 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
115 NULL, (uint16_t) result_code, 0);
116 break;
117 }
118#endif /* FEATURE_WLAN_DIAG_SUPPORT */
119 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
120}
121
122
123
124/**
125 * lim_send_sme_roc_rsp() - Send Response to SME
126 * @mac_ctx: Pointer to Global MAC structure
127 * @status: Resume link status
128 * @result_code: Result of the ROC request
129 * @sme_session_id: SME sesson Id
130 * @scan_id: Scan Identifier
131 *
132 * This function is called to send ROC rsp
133 * message to SME.
134 *
135 * Return: None
136 */
137void
138lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
139 tSirResultCodes result_code, uint8_t sme_session_id,
140 uint32_t scan_id)
141{
142 tSirMsgQ msg;
143 struct sir_roc_rsp *sme_rsp;
144
145 lim_log(mac_ctx, LOG1,
146 FL("Sending message %s with reasonCode %s scanId %d"),
147 lim_msg_str(msg_type), lim_result_code_str(result_code),
148 scan_id);
149
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530150 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 if (NULL == sme_rsp) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530152 QDF_TRACE(QDF_MODULE_ID_PE, LOGP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
154 return;
155 }
156
157 sme_rsp->message_type = msg_type;
158 sme_rsp->length = sizeof(struct sir_roc_rsp);
159 sme_rsp->status = result_code;
160
161 sme_rsp->session_id = sme_session_id;
162 sme_rsp->scan_id = scan_id;
163
164 msg.type = msg_type;
165 msg.bodyptr = sme_rsp;
166 msg.bodyval = 0;
167 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
168 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
169}
170
171
172/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530173 * lim_get_max_rate_flags() - Get rate flags
174 * @mac_ctx: Pointer to global MAC structure
175 * @sta_ds: Pointer to station ds structure
176 *
177 * This function is called to get the rate flags for a connection
178 * from the station ds structure depending on the ht and the vht
179 * channel width supported.
180 *
181 * Return: Returns the populated rate_flags
182 */
183uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
184{
185 uint32_t rate_flags = 0;
186
187 if (sta_ds == NULL) {
188 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
189 return rate_flags;
190 }
191
192 if (!sta_ds->mlmStaContext.htCapability &&
193 !sta_ds->mlmStaContext.vhtCapability) {
194 rate_flags |= eHAL_TX_RATE_LEGACY;
195 } else {
196 if (sta_ds->mlmStaContext.vhtCapability) {
197 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
198 sta_ds->vhtSupportedChannelWidthSet) {
199 rate_flags |= eHAL_TX_RATE_VHT80;
200 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
201 sta_ds->vhtSupportedChannelWidthSet) {
202 if (sta_ds->htSupportedChannelWidthSet)
203 rate_flags |= eHAL_TX_RATE_VHT40;
204 else
205 rate_flags |= eHAL_TX_RATE_VHT20;
206 }
207 } else if (sta_ds->mlmStaContext.htCapability) {
208 if (sta_ds->htSupportedChannelWidthSet)
209 rate_flags |= eHAL_TX_RATE_HT40;
210 else
211 rate_flags |= eHAL_TX_RATE_HT20;
212 }
213 }
214
215 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
216 rate_flags |= eHAL_TX_RATE_SGI;
217
218 return rate_flags;
219}
220
221/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
223 * @mac_ctx Pointer to Global MAC structure
224 * @status Resume link status
225 * @ctx context passed while calling resmune link.
226 * (join response to be sent)
227 *
228 * This function is called to send Join/Reassoc rsp
229 * message to SME after the resume link.
230 *
231 * Return: None
232 */
233static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530234 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235{
236 tSirMsgQ msg;
237 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
238
239 msg.type = sme_join_rsp->messageType;
240 msg.bodyptr = sme_join_rsp;
241 msg.bodyval = 0;
242 MTRACE(mac_trace_msg_tx(mac_ctx, NO_SESSION, msg.type));
243 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
244}
245
246/**
247 * lim_handle_join_rsp_status() - Handle the response.
248 * @mac_ctx: Pointer to Global MAC structure
249 * @session_entry: PE Session Info
250 * @result_code: Indicates the result of previously issued
251 * eWNI_SME_msgType_REQ message
252 * @sme_join_rsp The received response.
253 *
254 * This function will handle both the success and failure status
255 * of the received response.
256 *
257 * Return: None
258 */
259static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
260 tpPESession session_entry, tSirResultCodes result_code,
261 tpSirSmeJoinRsp sme_join_rsp)
262{
263#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
264 tSirSmeHTProfile *ht_profile;
265#endif
266 if (result_code == eSIR_SME_SUCCESS) {
267 if (session_entry->beacon != NULL) {
268 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530269 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270 session_entry->beacon,
271 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530272 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530274 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 lim_log(mac_ctx, LOG1, FL("Beacon=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530276 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 }
278 if (session_entry->assocReq != NULL) {
279 sme_join_rsp->assocReqLength =
280 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530281 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530282 sme_join_rsp->beaconLength,
283 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530285 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530287 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 lim_log(mac_ctx,
289 LOG1, FL("AssocReq=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530290 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 }
292 if (session_entry->assocRsp != NULL) {
293 sme_join_rsp->assocRspLength =
294 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530295 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530296 sme_join_rsp->beaconLength +
297 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 session_entry->assocRsp,
299 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530300 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530302 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 if (session_entry->ricData != NULL) {
305 sme_join_rsp->parsedRicRspLen =
306 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530307 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530308 sme_join_rsp->beaconLength +
309 sme_join_rsp->assocReqLength +
310 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 session_entry->ricData,
312 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530313 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530315 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316 lim_log(mac_ctx, LOG1, FL("RicLength=%d"),
317 sme_join_rsp->parsedRicRspLen);
318 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319#ifdef FEATURE_WLAN_ESE
320 if (session_entry->tspecIes != NULL) {
321 sme_join_rsp->tspecIeLen =
322 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530323 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530324 sme_join_rsp->beaconLength +
325 sme_join_rsp->assocReqLength +
326 sme_join_rsp->assocRspLength +
327 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328 session_entry->tspecIes,
329 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530330 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530332 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 lim_log(mac_ctx, LOG1, FL("ESE-TspecLen=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530334 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 }
336#endif
337 sme_join_rsp->aid = session_entry->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 lim_log(mac_ctx, LOG1, FL("AssocRsp=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530339 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 sme_join_rsp->vht_channel_width =
341 session_entry->ch_width;
342#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
343 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530344 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 ht_profile = &sme_join_rsp->HTProfile;
346 ht_profile->htSupportedChannelWidthSet =
347 session_entry->htSupportedChannelWidthSet;
348 ht_profile->htRecommendedTxWidthSet =
349 session_entry->htRecommendedTxWidthSet;
350 ht_profile->htSecondaryChannelOffset =
351 session_entry->htSecondaryChannelOffset;
352 ht_profile->dot11mode = session_entry->dot11mode;
353 ht_profile->htCapability = session_entry->htCapability;
354#ifdef WLAN_FEATURE_11AC
355 ht_profile->vhtCapability =
356 session_entry->vhtCapability;
357 ht_profile->vhtTxChannelWidthSet =
358 session_entry->vhtTxChannelWidthSet;
359 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
360 ht_profile->apChanWidth = session_entry->ch_width;
361#endif
362 }
363#endif
364 } else {
365 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530366 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530368 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 }
370 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530371 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530373 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374 }
375 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530376 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530378 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530381 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530383 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385#ifdef FEATURE_WLAN_ESE
386 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530387 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530389 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 }
391#endif
392 }
393}
394/**
395 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
396 * @mac_ctx: Pointer to Global MAC structure
397 * @msg_type: Indicates message type
398 * @result_code: Indicates the result of previously issued
399 * eWNI_SME_msgType_REQ message
400 * @prot_status_code: Protocol Status Code
401 * @session_entry: PE Session Info
402 * @sme_session_id: SME Session ID
403 * @sme_transaction_id: SME Transaction ID
404 *
405 * This function is called by lim_process_sme_req_messages() to send
406 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
407 * above MAC Software.
408 *
409 * Return: None
410 */
411
412void
413lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
414 tSirResultCodes result_code, uint16_t prot_status_code,
415 tpPESession session_entry, uint8_t sme_session_id,
416 uint16_t sme_transaction_id)
417{
418 tpSirSmeJoinRsp sme_join_rsp;
419 uint32_t rsp_len;
420 tpDphHashNode sta_ds = NULL;
421#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
422 if (msg_type == eWNI_SME_REASSOC_RSP)
423 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
424 session_entry, (uint16_t) result_code, 0);
425 else
426 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
427 session_entry, (uint16_t) result_code, 0);
428#endif /* FEATURE_WLAN_DIAG_SUPPORT */
429
430 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
431 lim_msg_str(msg_type), lim_result_code_str(result_code));
432
433 if (session_entry == NULL) {
434 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530435 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800436 if (NULL == sme_join_rsp) {
437 lim_log(mac_ctx, LOGP,
438 FL("Mem Alloc fail - JOIN/REASSOC_RSP"));
439 return;
440 }
441
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530442 qdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 sme_join_rsp->beaconLength = 0;
444 sme_join_rsp->assocReqLength = 0;
445 sme_join_rsp->assocRspLength = 0;
446 } else {
447 rsp_len = session_entry->assocReqLen +
448 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450#ifdef FEATURE_WLAN_ESE
451 session_entry->tspecLen +
452#endif
453 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530454 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455 if (NULL == sme_join_rsp) {
456 lim_log(mac_ctx, LOGP,
457 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
458 return;
459 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530460 qdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 if (result_code == eSIR_SME_SUCCESS) {
462 sta_ds = dph_get_hash_entry(mac_ctx,
463 DPH_STA_HASH_INDEX_PEER,
464 &session_entry->dph.dphHashTable);
465 if (sta_ds == NULL) {
466 lim_log(mac_ctx, LOGE,
467 FL("Get Self Sta Entry fail"));
468 } else {
469 /* Pass the peer's staId */
470 sme_join_rsp->staId = sta_ds->staIndex;
471 sme_join_rsp->ucastSig =
472 sta_ds->ucUcastSig;
473 sme_join_rsp->bcastSig =
474 sta_ds->ucBcastSig;
475 sme_join_rsp->timingMeasCap =
476 sta_ds->timingMeasCap;
477#ifdef FEATURE_WLAN_TDLS
478 sme_join_rsp->tdls_prohibited =
479 session_entry->tdls_prohibited;
480 sme_join_rsp->tdls_chan_swit_prohibited =
481 session_entry->tdls_chan_swit_prohibited;
482#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530483 sme_join_rsp->nss = sta_ds->nss;
484 sme_join_rsp->max_rate_flags =
485 lim_get_max_rate_flags(mac_ctx, sta_ds);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 }
487 }
488 sme_join_rsp->beaconLength = 0;
489 sme_join_rsp->assocReqLength = 0;
490 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800491 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492#ifdef FEATURE_WLAN_ESE
493 sme_join_rsp->tspecIeLen = 0;
494#endif
495
496 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
497 sme_join_rsp);
498 }
499
500 sme_join_rsp->messageType = msg_type;
501 sme_join_rsp->length = (uint16_t) rsp_len;
502 sme_join_rsp->statusCode = result_code;
503 sme_join_rsp->protStatusCode = prot_status_code;
504
505 sme_join_rsp->sessionId = sme_session_id;
506 sme_join_rsp->transactionId = sme_transaction_id;
507
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530508 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 (uint32_t *)sme_join_rsp);
510}
511
512/**
513 * lim_send_sme_start_bss_rsp()
514 *
515 ***FUNCTION:
516 * This function is called to send eWNI_SME_START_BSS_RSP
517 * message to applications above MAC Software.
518 *
519 ***PARAMS:
520 *
521 ***LOGIC:
522 *
523 ***ASSUMPTIONS:
524 * NA
525 *
526 ***NOTE:
527 * NA
528 *
529 * @param pMac Pointer to Global MAC structure
530 * @param msgType Indicates message type
531 * @param resultCode Indicates the result of previously issued
532 * eWNI_SME_msgType_REQ message
533 *
534 * @return None
535 */
536
537void
538lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
539 uint16_t msgType, tSirResultCodes resultCode,
540 tpPESession psessionEntry, uint8_t smesessionId,
541 uint16_t smetransactionId)
542{
543
544 uint16_t size = 0;
545 tSirMsgQ mmhMsg;
546 tSirSmeStartBssRsp *pSirSmeRsp;
547 uint16_t ieLen;
548 uint16_t ieOffset, curLen;
549
550 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
551 lim_msg_str(msgType), lim_result_code_str(resultCode));
552 )
553
554 size = sizeof(tSirSmeStartBssRsp);
555
556 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530557 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 if (NULL == pSirSmeRsp) {
559 /* / Buffer not available. Log error */
560 lim_log(pMac, LOGP,
561 FL
562 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
563 return;
564 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530565 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566
567 } else {
568 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
569 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
570 ieLen = psessionEntry->schBeaconOffsetBegin
571 + psessionEntry->schBeaconOffsetEnd - ieOffset;
572 /* calculate the memory size to allocate */
573 size += ieLen;
574
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530575 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 if (NULL == pSirSmeRsp) {
577 /* / Buffer not available. Log error */
578 lim_log(pMac, LOGP,
579 FL
580 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
581
582 return;
583 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530584 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 size = sizeof(tSirSmeStartBssRsp);
586 if (resultCode == eSIR_SME_SUCCESS) {
587
588 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
589 psessionEntry->bssId);
590
591 /* Read beacon interval from session */
592 pSirSmeRsp->bssDescription.beaconInterval =
593 (uint16_t) psessionEntry->beaconParams.
594 beaconInterval;
595 pSirSmeRsp->bssType = psessionEntry->bssType;
596
597 if (cfg_get_capability_info
598 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
599 psessionEntry)
600 != eSIR_SUCCESS)
601 lim_log(pMac, LOGP,
602 FL
603 ("could not retrieve Capabilities value"));
604
605 lim_get_phy_mode(pMac,
606 (uint32_t *) &pSirSmeRsp->bssDescription.
607 nwType, psessionEntry);
608
609 pSirSmeRsp->bssDescription.channelId =
610 psessionEntry->currentOperChannel;
611
612 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530613 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 ieFields,
615 psessionEntry->pSchBeaconFrameBegin +
616 ieOffset, (uint32_t) curLen);
617
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530618 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 ieFields) + curLen,
620 psessionEntry->pSchBeaconFrameEnd,
621 (uint32_t) psessionEntry->
622 schBeaconOffsetEnd);
623
624 /* subtracting size of length indicator itself and size of pointer to ieFields */
625 pSirSmeRsp->bssDescription.length =
626 sizeof(tSirBssDescription) - sizeof(uint16_t) -
627 sizeof(uint32_t) + ieLen;
628 /* This is the size of the message, subtracting the size of the pointer to ieFields */
629 size += ieLen - sizeof(uint32_t);
630#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
631 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530632 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 pSirSmeRsp->HTProfile.
634 htSupportedChannelWidthSet =
635 psessionEntry->htSupportedChannelWidthSet;
636 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
637 psessionEntry->htRecommendedTxWidthSet;
638 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
639 psessionEntry->htSecondaryChannelOffset;
640 pSirSmeRsp->HTProfile.dot11mode =
641 psessionEntry->dot11mode;
642 pSirSmeRsp->HTProfile.htCapability =
643 psessionEntry->htCapability;
644#ifdef WLAN_FEATURE_11AC
645 pSirSmeRsp->HTProfile.vhtCapability =
646 psessionEntry->vhtCapability;
647 pSirSmeRsp->HTProfile.vhtTxChannelWidthSet =
648 psessionEntry->vhtTxChannelWidthSet;
649 pSirSmeRsp->HTProfile.apCenterChan =
650 psessionEntry->ch_center_freq_seg0;
651 pSirSmeRsp->HTProfile.apChanWidth =
652 psessionEntry->ch_width;
653#endif
654 }
655#endif
656 }
657
658 }
659
660 pSirSmeRsp->messageType = msgType;
661 pSirSmeRsp->length = size;
662
663 /* Update SME session Id and transaction Id */
664 pSirSmeRsp->sessionId = smesessionId;
665 pSirSmeRsp->transactionId = smetransactionId;
666 pSirSmeRsp->statusCode = resultCode;
667 if (psessionEntry != NULL)
668 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
669
670 mmhMsg.type = msgType;
671 mmhMsg.bodyptr = pSirSmeRsp;
672 mmhMsg.bodyval = 0;
673 if (psessionEntry == NULL) {
674 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
675 } else {
676 MTRACE(mac_trace_msg_tx
677 (pMac, psessionEntry->peSessionId, mmhMsg.type));
678 }
679#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
680 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
681 psessionEntry, (uint16_t) resultCode, 0);
682#endif /* FEATURE_WLAN_DIAG_SUPPORT */
683
684 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
685} /*** end lim_send_sme_start_bss_rsp() ***/
686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687/**
688 * lim_send_sme_scan_rsp() - Send scan response to SME
689 * @pMac: Pointer to Global MAC structure
690 * @length: Indicates length of message
691 * @resultCode: Indicates the result of previously issued
692 * eWNI_SME_SCAN_REQ message
693 * @scan_id: scan identifier
694 *
695 * This function is called by lim_process_sme_req_messages() to send
696 * eWNI_SME_SCAN_RSP message to applications above MAC
697 *
698 * return: None
699 */
700
701void
702lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
703 uint8_t smesessionId, uint16_t smetranscationId,
704 uint32_t scan_id)
705{
706 lim_log(pMac, LOG1,
707 FL("Sending message SME_SCAN_RSP reasonCode %s scanId %d"),
708 lim_result_code_str(resultCode), scan_id);
709 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
710 smetranscationId, scan_id);
711}
712
713/**
714 * lim_post_sme_scan_rsp_message()
715 *
716 ***FUNCTION:
717 * This function is called by lim_send_sme_scan_rsp() to send
718 * eWNI_SME_SCAN_RSP message with failed result code
719 *
720 ***NOTE:
721 * NA
722 *
723 * @param pMac Pointer to Global MAC structure
724 * @param length Indicates length of message
725 * @param resultCode failed result code
726 *
727 * @return None
728 */
729
730void
731lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
732 tSirResultCodes resultCode, uint8_t smesessionId,
733 uint16_t smetransactionId,
734 uint32_t scan_id)
735{
736 tpSirSmeScanRsp pSirSmeScanRsp;
737 tSirMsgQ mmhMsg;
738
739 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
740 lim_result_code_str(resultCode));
741
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530742 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 if (NULL == pSirSmeScanRsp) {
744 lim_log(pMac, LOGP,
745 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
746 return;
747 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530748 qdf_mem_set((void *)pSirSmeScanRsp, sizeof(tSirSmeScanRsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749
750 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
751 pSirSmeScanRsp->statusCode = resultCode;
752
753 /*Update SME session Id and transaction Id */
754 pSirSmeScanRsp->sessionId = smesessionId;
755 pSirSmeScanRsp->transcationId = smetransactionId;
756 pSirSmeScanRsp->scan_id = scan_id;
757
758 mmhMsg.type = eWNI_SME_SCAN_RSP;
759 mmhMsg.bodyptr = pSirSmeScanRsp;
760 mmhMsg.bodyval = 0;
761
762 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
763#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
764 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
765 (uint16_t) resultCode, 0);
766#endif /* FEATURE_WLAN_DIAG_SUPPORT */
767
768 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
769 return;
770
771} /*** lim_post_sme_scan_rsp_message ***/
772
773#ifdef FEATURE_OEM_DATA_SUPPORT
774
775/**
776 * lim_send_sme_oem_data_rsp()
777 *
778 ***FUNCTION:
779 * This function is called by lim_process_sme_req_messages() to send
780 * eWNI_SME_OEM_DATA_RSP message to applications above MAC
781 * Software.
782 *
783 ***PARAMS:
784 *
785 ***LOGIC:
786 *
787 ***ASSUMPTIONS:
788 * NA
789 *
790 ***NOTE:
791 * NA
792 *
793 * @param pMac Pointer to Global MAC structure
794 * @param pMsgBuf Indicates the mlm message
795 * @param resultCode Indicates the result of previously issued
796 * eWNI_SME_OEM_DATA_RSP message
797 *
798 * @return None
799 */
800
801void lim_send_sme_oem_data_rsp(tpAniSirGlobal pMac, uint32_t *pMsgBuf,
802 tSirResultCodes resultCode)
803{
804 tSirMsgQ mmhMsg;
805 tSirOemDataRsp *pSirSmeOemDataRsp = NULL;
806 tLimMlmOemDataRsp *pMlmOemDataRsp = NULL;
807 uint16_t msgLength;
808
809 /* get the pointer to the mlm message */
810 pMlmOemDataRsp = (tLimMlmOemDataRsp *) (pMsgBuf);
811
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800812 msgLength = sizeof(*pSirSmeOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 /* now allocate memory for the char buffer */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800814 pSirSmeOemDataRsp = qdf_mem_malloc(sizeof(*pSirSmeOemDataRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 if (NULL == pSirSmeOemDataRsp) {
816 lim_log(pMac, LOGP,
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800817 FL("malloc failed for pSirSmeOemDataRsp"));
818 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
819 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 return;
821 }
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800822
823 if (pMlmOemDataRsp->rsp_len) {
824 pSirSmeOemDataRsp->oem_data_rsp =
825 qdf_mem_malloc(pMlmOemDataRsp->rsp_len);
826 if (!pSirSmeOemDataRsp->oem_data_rsp) {
827 lim_log(pMac, LOGE,
828 FL("malloc failed for oem_data_rsp"));
829 qdf_mem_free(pSirSmeOemDataRsp);
830 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
831 qdf_mem_free(pMlmOemDataRsp);
832 return;
833 }
834 }
835
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836#if defined (ANI_LITTLE_BYTE_ENDIAN)
837 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->length, msgLength);
838 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->messageType,
839 eWNI_SME_OEM_DATA_RSP);
840#else
841 pSirSmeOemDataRsp->length = msgLength;
842 pSirSmeOemDataRsp->messageType = eWNI_SME_OEM_DATA_RSP;
843#endif
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -0800844 pSirSmeOemDataRsp->target_rsp = pMlmOemDataRsp->target_rsp;
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800845 pSirSmeOemDataRsp->rsp_len = pMlmOemDataRsp->rsp_len;
846 if (pSirSmeOemDataRsp->rsp_len)
847 qdf_mem_copy(pSirSmeOemDataRsp->oem_data_rsp,
848 pMlmOemDataRsp->oem_data_rsp,
849 pSirSmeOemDataRsp->rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850
851 /* Now free the memory from MLM Rsp Message */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800852 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530853 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854
855 mmhMsg.type = eWNI_SME_OEM_DATA_RSP;
856 mmhMsg.bodyptr = pSirSmeOemDataRsp;
857 mmhMsg.bodyval = 0;
858
859 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
860
861 return;
862} /*** lim_send_sme_oem_data_rsp ***/
863
864#endif
865
866void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530867 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868{
869 tSirMsgQ mmhMsg;
870 tSirMsgQ *pMsg = (tSirMsgQ *) pCtx;
871
872 mmhMsg.type = pMsg->type;
873 mmhMsg.bodyptr = pMsg;
874 mmhMsg.bodyval = 0;
875
876 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
877
878 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
879}
880
881/**
882 * lim_send_sme_disassoc_ntf()
883 *
884 ***FUNCTION:
885 * This function is called by limProcessSmeMessages() to send
886 * eWNI_SME_DISASSOC_RSP/IND message to host
887 *
888 ***PARAMS:
889 *
890 ***LOGIC:
891 *
892 ***ASSUMPTIONS:
893 * NA
894 *
895 ***NOTE:
896 * This function is used for sending eWNI_SME_DISASSOC_CNF,
897 * or eWNI_SME_DISASSOC_IND to host depending on
898 * disassociation trigger.
899 *
900 * @param peerMacAddr Indicates the peer MAC addr to which
901 * disassociate was initiated
902 * @param reasonCode Indicates the reason for Disassociation
903 * @param disassocTrigger Indicates the trigger for Disassociation
904 * @param aid Indicates the STAID. This parameter is
905 * present only on AP.
906 *
907 * @return None
908 */
909void
910lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
911 tSirMacAddr peerMacAddr,
912 tSirResultCodes reasonCode,
913 uint16_t disassocTrigger,
914 uint16_t aid,
915 uint8_t smesessionId,
916 uint16_t smetransactionId, tpPESession psessionEntry)
917{
918
919 uint8_t *pBuf;
920 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
921 tSirSmeDisassocInd *pSirSmeDisassocInd;
922 uint32_t *pMsg;
923 bool failure = false;
924
925 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
926 disassocTrigger, reasonCode);
927
928 switch (disassocTrigger) {
929 case eLIM_PEER_ENTITY_DISASSOC:
930 if (reasonCode != eSIR_SME_STA_NOT_ASSOCIATED) {
931 failure = true;
932 goto error;
933 }
934
935 case eLIM_HOST_DISASSOC:
936 /**
937 * Disassociation response due to
938 * host triggered disassociation
939 */
940
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530941 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 if (NULL == pSirSmeDisassocRsp) {
943 /* Log error */
944 lim_log(pMac, LOGP, FL("Memory allocation failed"));
945 failure = true;
946 goto error;
947 }
948 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
949 "retCode: %d for " MAC_ADDRESS_STR),
950 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
951 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
952 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
953 /* sessionId */
954 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
955 *pBuf = smesessionId;
956 pBuf++;
957
958 /* transactionId */
959 lim_copy_u16(pBuf, smetransactionId);
960 pBuf += sizeof(uint16_t);
961
962 /* statusCode */
963 lim_copy_u32(pBuf, reasonCode);
964 pBuf += sizeof(tSirResultCodes);
965
966 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530967 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 pBuf += sizeof(tSirMacAddr);
969
970 /* Clear Station Stats */
971 /* for sta, it is always 1, IBSS is handled at halInitSta */
972
973#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
974
975 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
976 psessionEntry, (uint16_t) reasonCode, 0);
977#endif
978 pMsg = (uint32_t *) pSirSmeDisassocRsp;
979 break;
980
981 default:
982 /**
983 * Disassociation indication due to Disassociation
984 * frame reception from peer entity or due to
985 * loss of link with peer entity.
986 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530987 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 if (NULL == pSirSmeDisassocInd) {
989 /* Log error */
990 lim_log(pMac, LOGP, FL("Memory allocation failed"));
991 failure = true;
992 goto error;
993 }
994 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
995 "retCode: %d for " MAC_ADDRESS_STR),
996 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
997 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
998 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
999
1000 /* Update SME session Id and Transaction Id */
1001 pSirSmeDisassocInd->sessionId = smesessionId;
1002 pSirSmeDisassocInd->transactionId = smetransactionId;
1003 pSirSmeDisassocInd->reasonCode = reasonCode;
1004 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1005
1006 lim_copy_u32(pBuf, reasonCode);
1007 pBuf += sizeof(tSirResultCodes);
1008
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301009 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 pBuf += sizeof(tSirMacAddr);
1011
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301012 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013
1014#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1015 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1016 psessionEntry, (uint16_t) reasonCode, 0);
1017#endif
1018 pMsg = (uint32_t *) pSirSmeDisassocInd;
1019
1020 break;
1021 }
1022
1023error:
1024 /* Delete the PE session Created */
1025 if ((psessionEntry != NULL) &&
1026 (LIM_IS_STA_ROLE(psessionEntry) ||
1027 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))) {
1028 pe_delete_session(pMac, psessionEntry);
1029 }
1030
1031 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301032 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 (uint32_t *) pMsg);
1034} /*** end lim_send_sme_disassoc_ntf() ***/
1035
1036/** -----------------------------------------------------------------
1037 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1038
1039 After receiving disassociation frame from peer entity, this
1040 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1041 reason code.
1042
1043 \param pMac - global mac structure
1044 \param pStaDs - station dph hash node
1045 \return none
1046 \sa
1047 ----------------------------------------------------------------- */
1048void
1049lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1050 tpPESession psessionEntry)
1051{
1052 tSirMsgQ mmhMsg;
1053 tSirSmeDisassocInd *pSirSmeDisassocInd;
1054
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301055 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 if (NULL == pSirSmeDisassocInd) {
1057 lim_log(pMac, LOGP,
1058 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1059 return;
1060 }
1061
1062 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1063 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1064
1065 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1066 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
1067 pSirSmeDisassocInd->statusCode = pStaDs->mlmStaContext.disassocReason;
1068 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1069
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301070 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301071 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301073 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301074 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075
1076 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1077
1078 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1079 mmhMsg.bodyptr = pSirSmeDisassocInd;
1080 mmhMsg.bodyval = 0;
1081
1082 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1083#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1084 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1085 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1086#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1087
1088 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1089
1090} /*** end lim_send_sme_disassoc_ind() ***/
1091
1092/** -----------------------------------------------------------------
1093 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1094
1095 After receiving deauthentication frame from peer entity, this
1096 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1097 reason code.
1098
1099 \param pMac - global mac structure
1100 \param pStaDs - station dph hash node
1101 \return none
1102 \sa
1103 ----------------------------------------------------------------- */
1104void
1105lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1106 tpPESession psessionEntry)
1107{
1108 tSirMsgQ mmhMsg;
1109 tSirSmeDeauthInd *pSirSmeDeauthInd;
1110
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301111 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112 if (NULL == pSirSmeDeauthInd) {
1113 lim_log(pMac, LOGP,
1114 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1115 return;
1116 }
1117
1118 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1119 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1120
1121 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1122 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1123 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1124 pSirSmeDeauthInd->statusCode =
1125 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1126 } else {
1127 /* Need to indicatet he reascon code over the air */
1128 pSirSmeDeauthInd->statusCode =
1129 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1130 }
1131 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301132 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301133 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301135 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301136 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1138
1139 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001140 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1141 pStaDs->mlmStaContext.disassocReason)
1142 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143
1144 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1145 mmhMsg.bodyptr = pSirSmeDeauthInd;
1146 mmhMsg.bodyval = 0;
1147
1148 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1149#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1150 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1151 0, pStaDs->mlmStaContext.cleanupTrigger);
1152#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1153
1154 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1155 return;
1156} /*** end lim_send_sme_deauth_ind() ***/
1157
1158#ifdef FEATURE_WLAN_TDLS
1159/**
1160 * lim_send_sme_tdls_del_sta_ind()
1161 *
1162 ***FUNCTION:
1163 * This function is called to send the TDLS STA context deletion to SME.
1164 *
1165 ***LOGIC:
1166 *
1167 ***ASSUMPTIONS:
1168 *
1169 ***NOTE:
1170 * NA
1171 *
1172 * @param pMac - Pointer to global MAC structure
1173 * @param pStaDs - Pointer to internal STA Datastructure
1174 * @param psessionEntry - Pointer to the session entry
1175 * @param reasonCode - Reason for TDLS sta deletion
1176 * @return None
1177 */
1178void
1179lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1180 tpPESession psessionEntry, uint16_t reasonCode)
1181{
1182 tSirMsgQ mmhMsg;
1183 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1184
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301185 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 if (NULL == pSirTdlsDelStaInd) {
1187 lim_log(pMac, LOGP,
1188 FL
1189 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1190 return;
1191 }
1192 /* 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{
1239 tSirMsgQ mmhMsg;
1240 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) {
1244 lim_log(pMac, LOGP,
1245 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,
1285 tpPESession psessionEntry, uint32_t txCompleteStatus)
1286{
1287 tSirMsgQ mmhMsg;
1288 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1289
1290 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301291 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 if (NULL == pSirMgmtTxCompletionInd) {
1293 lim_log(pMac, LOGP,
1294 FL
1295 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1296 return;
1297 }
1298 /* messageType */
1299 pSirMgmtTxCompletionInd->messageType =
1300 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1301 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1302
1303 /* sessionId */
1304 pSirMgmtTxCompletionInd->sessionId = psessionEntry->smeSessionId;
1305
1306 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1307
1308 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1309 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1310 mmhMsg.bodyval = 0;
1311
1312 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1313 return;
1314} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1315
1316void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1317 void *events)
1318{
1319 tSirMsgQ mmhMsg;
1320
1321 switch (msgType) {
1322 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1323 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1324 break;
1325 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1326 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1327 break;
1328 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1329 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1330 break;
1331 }
1332
1333 mmhMsg.bodyptr = events;
1334 mmhMsg.bodyval = 0;
1335 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1336 return;
1337}
1338#endif /* FEATURE_WLAN_TDLS */
1339
1340/**
1341 * lim_send_sme_deauth_ntf()
1342 *
1343 ***FUNCTION:
1344 * This function is called by limProcessSmeMessages() to send
1345 * eWNI_SME_DISASSOC_RSP/IND message to host
1346 *
1347 ***PARAMS:
1348 *
1349 ***LOGIC:
1350 *
1351 ***ASSUMPTIONS:
1352 * NA
1353 *
1354 ***NOTE:
1355 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1356 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1357 *
1358 * @param peerMacAddr Indicates the peer MAC addr to which
1359 * deauthentication was initiated
1360 * @param reasonCode Indicates the reason for Deauthetication
1361 * @param deauthTrigger Indicates the trigger for Deauthetication
1362 * @param aid Indicates the STAID. This parameter is present
1363 * only on AP.
1364 *
1365 * @return None
1366 */
1367void
1368lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1369 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1370 uint16_t aid, uint8_t smesessionId,
1371 uint16_t smetransactionId)
1372{
1373 uint8_t *pBuf;
1374 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1375 tSirSmeDeauthInd *pSirSmeDeauthInd;
1376 tpPESession psessionEntry;
1377 uint8_t sessionId;
1378 uint32_t *pMsg;
1379
1380 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1381 switch (deauthTrigger) {
1382 case eLIM_PEER_ENTITY_DEAUTH:
1383 return;
1384
1385 case eLIM_HOST_DEAUTH:
1386 /**
1387 * Deauthentication response to host triggered
1388 * deauthentication.
1389 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301390 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391 if (NULL == pSirSmeDeauthRsp) {
1392 /* Log error */
1393 lim_log(pMac, LOGP,
1394 FL
1395 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1396
1397 return;
1398 }
1399 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1400 "retCode: %d for" MAC_ADDRESS_STR),
1401 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1402 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1403 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1404 pSirSmeDeauthRsp->statusCode = reasonCode;
1405 pSirSmeDeauthRsp->sessionId = smesessionId;
1406 pSirSmeDeauthRsp->transactionId = smetransactionId;
1407
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001408 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301409 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410
1411#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1412 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1413 psessionEntry, 0, (uint16_t) reasonCode);
1414#endif
1415 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1416
1417 break;
1418
1419 default:
1420 /**
1421 * Deauthentication indication due to Deauthentication
1422 * frame reception from peer entity or due to
1423 * loss of link with peer entity.
1424 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301425 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 if (NULL == pSirSmeDeauthInd) {
1427 /* Log error */
1428 lim_log(pMac, LOGP,
1429 FL
1430 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1431
1432 return;
1433 }
1434 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1435 "retCode: %d for " MAC_ADDRESS_STR),
1436 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1437 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1438 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1439 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1440
1441 /* sessionId */
1442 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1443 *pBuf++ = smesessionId;
1444
1445 /* transaction ID */
1446 lim_copy_u16(pBuf, smetransactionId);
1447 pBuf += sizeof(uint16_t);
1448
1449 /* status code */
1450 lim_copy_u32(pBuf, reasonCode);
1451 pBuf += sizeof(tSirResultCodes);
1452
1453 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301454 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455 pBuf += sizeof(tSirMacAddr);
1456
1457 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301458 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301459 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460
1461#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1462 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1463 psessionEntry, 0, (uint16_t) reasonCode);
1464#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1465 pMsg = (uint32_t *) pSirSmeDeauthInd;
1466
1467 break;
1468 }
1469
1470 /*Delete the PE session created */
1471 if (psessionEntry != NULL) {
1472 pe_delete_session(pMac, psessionEntry);
1473 }
1474
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301475 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 (uint32_t *) pMsg);
1477
1478} /*** end lim_send_sme_deauth_ntf() ***/
1479
1480/**
1481 * lim_send_sme_wm_status_change_ntf() - Send Notification
1482 * @mac_ctx: Global MAC Context
1483 * @status_change_code: Indicates the change in the wireless medium.
1484 * @status_change_info: Indicates the information associated with
1485 * change in the wireless medium.
1486 * @info_len: Indicates the length of status change information
1487 * being sent.
1488 * @session_id SessionID
1489 *
1490 * This function is called by limProcessSmeMessages() to send
1491 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1492 *
1493 * Return: None
1494 */
1495void
1496lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1497 tSirSmeStatusChangeCode status_change_code,
1498 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1499{
1500 tSirMsgQ msg;
1501 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
1502
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301503 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 if (NULL == wm_status_change_ntf) {
1505 lim_log(mac_ctx, LOGE,
1506 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1507 return;
1508 }
1509
1510 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1511 msg.bodyval = 0;
1512 msg.bodyptr = wm_status_change_ntf;
1513
1514 switch (status_change_code) {
1515 case eSIR_SME_RADAR_DETECTED:
1516 break;
1517 default:
1518 wm_status_change_ntf->messageType =
1519 eWNI_SME_WM_STATUS_CHANGE_NTF;
1520 wm_status_change_ntf->statusChangeCode = status_change_code;
1521 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1522 wm_status_change_ntf->sessionId = session_id;
1523 if (sizeof(wm_status_change_ntf->statusChangeInfo) >=
1524 info_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301525 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1527 (uint8_t *) status_change_info, info_len);
1528 }
1529 lim_log(mac_ctx, LOGE,
1530 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1531 status_change_code, info_len);
1532 break;
1533 }
1534
1535 MTRACE(mac_trace_msg_tx(mac_ctx, session_id, msg.type));
1536 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301537 qdf_mem_free(wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 lim_log(mac_ctx, LOGP,
1539 FL("lim_sys_process_mmh_msg_api failed"));
1540 }
1541
1542} /*** end lim_send_sme_wm_status_change_ntf() ***/
1543
1544/**
1545 * lim_send_sme_set_context_rsp()
1546 *
1547 ***FUNCTION:
1548 * This function is called by limProcessSmeMessages() to send
1549 * eWNI_SME_SETCONTEXT_RSP message to host
1550 *
1551 ***PARAMS:
1552 *
1553 ***LOGIC:
1554 *
1555 ***ASSUMPTIONS:
1556 * NA
1557 *
1558 ***NOTE:
1559 *
1560 * @param pMac Pointer to Global MAC structure
1561 * @param peerMacAddr Indicates the peer MAC addr to which
1562 * setContext was performed
1563 * @param aid Indicates the aid corresponding to the peer MAC
1564 * address
1565 * @param resultCode Indicates the result of previously issued
1566 * eWNI_SME_SETCONTEXT_RSP message
1567 *
1568 * @return None
1569 */
1570void
1571lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301572 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 tSirResultCodes resultCode,
1574 tpPESession psessionEntry, uint8_t smesessionId,
1575 uint16_t smetransactionId)
1576{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001577 tSirMsgQ mmhMsg;
1578 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1579
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301580 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 if (NULL == pSirSmeSetContextRsp) {
1582 /* Log error */
1583 lim_log(pMac, LOGP,
1584 FL
1585 ("call to AllocateMemory failed for SmeSetContextRsp"));
1586
1587 return;
1588 }
1589
1590 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1591 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1592 pSirSmeSetContextRsp->statusCode = resultCode;
1593
Anurag Chouhanc5548422016-02-24 18:33:27 +05301594 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595
1596 /* Update SME session and transaction Id */
1597 pSirSmeSetContextRsp->sessionId = smesessionId;
1598 pSirSmeSetContextRsp->transactionId = smetransactionId;
1599
1600 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1601 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1602 mmhMsg.bodyval = 0;
1603 if (NULL == psessionEntry) {
1604 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1605 } else {
1606 MTRACE(mac_trace_msg_tx
1607 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1608 }
1609
1610#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1611 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1612 psessionEntry, (uint16_t) resultCode, 0);
1613#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1614
1615 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1616} /*** end lim_send_sme_set_context_rsp() ***/
1617
1618/**
1619 * lim_send_sme_neighbor_bss_ind()
1620 *
1621 ***FUNCTION:
1622 * This function is called by lim_lookup_nadd_hash_entry() to send
1623 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1624 *
1625 ***PARAMS:
1626 *
1627 ***LOGIC:
1628 *
1629 ***ASSUMPTIONS:
1630 * NA
1631 *
1632 ***NOTE:
1633 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1634 * host upon detecting new BSS during background scanning if CFG
1635 * option is enabled for sending such indication
1636 *
1637 * @param pMac - Pointer to Global MAC structure
1638 * @return None
1639 */
1640
1641void
1642lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1643{
1644 tSirMsgQ msgQ;
1645 uint32_t val;
1646 tSirSmeNeighborBssInd *pNewBssInd;
1647
1648 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1649 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1650 pMac->lim.gLimRspReqd)) {
1651 /* LIM is not in background scan state OR */
1652 /* current scan is initiated by HDD. */
1653 /* No need to send new BSS indication to HDD */
1654 return;
1655 }
1656
1657 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1658 eSIR_SUCCESS) {
1659 lim_log(pMac, LOGP,
1660 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1661
1662 return;
1663 }
1664
1665 if (val == 0)
1666 return;
1667
1668 /**
1669 * Need to indicate new BSSs found during
1670 * background scanning to host.
1671 * Allocate buffer for sending indication.
1672 * Length of buffer is length of BSS description
1673 * and length of header itself
1674 */
1675 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1676 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301677 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 if (NULL == pNewBssInd) {
1679 /* Log error */
1680 lim_log(pMac, LOGP,
1681 FL
1682 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1683
1684 return;
1685 }
1686
1687 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1688 pNewBssInd->length = (uint16_t) val;
1689 pNewBssInd->sessionId = 0;
1690
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301691 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 (uint8_t *) &pBssDescr->bssDescription,
1693 pBssDescr->bssDescription.length + sizeof(uint16_t));
1694
1695 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1696 msgQ.bodyptr = pNewBssInd;
1697 msgQ.bodyval = 0;
1698 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
1699 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1700} /*** end lim_send_sme_neighbor_bss_ind() ***/
1701
1702/** -----------------------------------------------------------------
1703 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1704 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1705 \ SME only looks at rc and tspec field.
1706 \param pMac - global mac structure
1707 \param rspReqd - is SmeAddTsRsp required
1708 \param status - status code of SME_ADD_TS_RSP
1709 \return tspec
1710 \sa
1711 ----------------------------------------------------------------- */
1712void
1713lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1714 tpPESession psessionEntry, tSirMacTspecIE tspec,
1715 uint8_t smesessionId, uint16_t smetransactionId)
1716{
1717 tpSirAddtsRsp rsp;
1718 tSirMsgQ mmhMsg;
1719
1720 if (!rspReqd)
1721 return;
1722
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301723 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 if (NULL == rsp) {
1725 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1726 return;
1727 }
1728
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301729 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 rsp->messageType = eWNI_SME_ADDTS_RSP;
1731 rsp->rc = status;
1732 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1733 rsp->rsp.tspec = tspec;
1734 /* Update SME session Id and transcation Id */
1735 rsp->sessionId = smesessionId;
1736 rsp->transactionId = smetransactionId;
1737
1738 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1739 mmhMsg.bodyptr = rsp;
1740 mmhMsg.bodyval = 0;
1741 if (NULL == psessionEntry) {
1742 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1743 } else {
1744 MTRACE(mac_trace_msg_tx
1745 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1746 }
1747#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1748 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1749 0);
1750#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1751
1752 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1753 return;
1754}
1755
1756void
1757lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1758 tpPESession psessionEntry, uint8_t smesessionId,
1759 uint16_t smetransactionId)
1760{
1761 tpSirDeltsRsp rsp;
1762 tSirMsgQ mmhMsg;
1763
1764 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1765 delts->aid,
1766 delts->req.tsinfo.traffic.tsid,
1767 delts->req.tsinfo.traffic.userPrio, status);
1768 if (!delts->rspReqd)
1769 return;
1770
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301771 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 if (NULL == rsp) {
1773 /* Log error */
1774 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1775 return;
1776 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301777 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778
1779 if (psessionEntry != NULL) {
1780
1781 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301782 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301783 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 sizeof(tSirDeltsReqInfo));
1785 }
1786
1787 rsp->messageType = eWNI_SME_DELTS_RSP;
1788 rsp->rc = status;
1789
1790 /* Update SME session Id and transcation Id */
1791 rsp->sessionId = smesessionId;
1792 rsp->transactionId = smetransactionId;
1793
1794 mmhMsg.type = eWNI_SME_DELTS_RSP;
1795 mmhMsg.bodyptr = rsp;
1796 mmhMsg.bodyval = 0;
1797 if (NULL == psessionEntry) {
1798 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1799 } else {
1800 MTRACE(mac_trace_msg_tx
1801 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1802 }
1803#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1804 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1805 (uint16_t) status, 0);
1806#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1807
1808 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1809}
1810
1811void
1812lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1813 tpPESession psessionEntry)
1814{
1815 tpSirDeltsRsp rsp;
1816 tSirMsgQ mmhMsg;
1817
1818 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1819 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1820
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301821 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 if (NULL == rsp) {
1823 /* Log error */
1824 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1825 return;
1826 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301827 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828
1829 rsp->messageType = eWNI_SME_DELTS_IND;
1830 rsp->rc = eSIR_SUCCESS;
1831 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301832 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833
1834 /* Update SME session Id and SME transaction Id */
1835
1836 rsp->sessionId = psessionEntry->smeSessionId;
1837 rsp->transactionId = psessionEntry->transactionId;
1838
1839 mmhMsg.type = eWNI_SME_DELTS_IND;
1840 mmhMsg.bodyptr = rsp;
1841 mmhMsg.bodyval = 0;
1842 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1843#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1844 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1845 0);
1846#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1847
1848 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1849}
1850
1851/**
1852 * lim_send_sme_pe_statistics_rsp()
1853 *
1854 ***FUNCTION:
1855 * This function is called to send 802.11 statistics response to HDD.
1856 * This function posts the result back to HDD. This is a response to
1857 * HDD's request for statistics.
1858 *
1859 ***PARAMS:
1860 *
1861 ***LOGIC:
1862 *
1863 ***ASSUMPTIONS:
1864 * NA
1865 *
1866 ***NOTE:
1867 * NA
1868 *
1869 * @param pMac Pointer to Global MAC structure
1870 * @param p80211Stats Statistics sent in response
1871 * @param resultCode TODO:
1872 *
1873 *
1874 * @return none
1875 */
1876
1877void
1878lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1879{
1880 tSirMsgQ mmhMsg;
1881 uint8_t sessionId;
1882 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1883 tpPESession pPeSessionEntry;
1884
1885 /* Get the Session Id based on Sta Id */
1886 pPeSessionEntry =
1887 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1888
1889 /* Fill the Session Id */
1890 if (NULL != pPeSessionEntry) {
1891 /* Fill the Session Id */
1892 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1893 }
1894
1895 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1896
1897 /* msgType should be WMA_GET_STATISTICS_RSP */
1898 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1899
1900 mmhMsg.bodyptr = stats;
1901 mmhMsg.bodyval = 0;
1902 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1903 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1904
1905 return;
1906
1907} /*** end lim_send_sme_pe_statistics_rsp() ***/
1908
1909#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1910/**
1911 * lim_send_sme_pe_ese_tsm_rsp()
1912 *
1913 ***FUNCTION:
1914 * This function is called to send tsm stats response to HDD.
1915 * This function posts the result back to HDD. This is a response to
1916 * HDD's request to get tsm stats.
1917 *
1918 ***PARAMS:
1919 * @param pMac - Pointer to global pMac structure
1920 * @param pStats - Pointer to TSM Stats
1921 *
1922 * @return none
1923 */
1924
1925void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac, tAniGetTsmStatsRsp *pStats)
1926{
1927 tSirMsgQ mmhMsg;
1928 uint8_t sessionId;
1929 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1930 tpPESession pPeSessionEntry = NULL;
1931
1932 /* Get the Session Id based on Sta Id */
1933 pPeSessionEntry =
1934 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1935
1936 /* Fill the Session Id */
1937 if (NULL != pPeSessionEntry) {
1938 /* Fill the Session Id */
1939 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1940 } else {
1941 PELOGE(lim_log
1942 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1943 pPeStats->staId);
1944 )
1945 return;
1946 }
1947
1948 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1949 pPeStats->tsmMetrics.RoamingCount
1950 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1951 pPeStats->tsmMetrics.RoamingDly
1952 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1953
1954 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1955 mmhMsg.bodyptr = pStats;
1956 mmhMsg.bodyval = 0;
1957 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
1958 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1959
1960 return;
1961} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1962
1963#endif /* FEATURE_WLAN_ESE) && FEATURE_WLAN_ESE_UPLOAD */
1964
1965void
1966lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1967 tSirMacAddr peerMacAddr,
1968 uint16_t staIndex,
1969 uint8_t ucastIdx,
1970 uint8_t bcastIdx,
1971 uint8_t *beacon,
1972 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1973{
1974 tSirMsgQ mmhMsg;
1975 tSmeIbssPeerInd *pNewPeerInd;
1976
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301977 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 if (NULL == pNewPeerInd) {
1979 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
1980 return;
1981 }
1982
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301983 qdf_mem_set((void *)pNewPeerInd, (sizeof(tSmeIbssPeerInd) + beaconLen),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984 0);
1985
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301986 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301987 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988 pNewPeerInd->staId = staIndex;
1989 pNewPeerInd->ucastSig = ucastIdx;
1990 pNewPeerInd->bcastSig = bcastIdx;
1991 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1992 pNewPeerInd->mesgType = msgType;
1993 pNewPeerInd->sessionId = sessionId;
1994
1995 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301996 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1998 beaconLen);
1999 }
2000
2001 mmhMsg.type = msgType;
2002 mmhMsg.bodyptr = pNewPeerInd;
2003 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
2004 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2005
2006}
2007
2008/**
2009 * lim_handle_csa_offload_msg() - Handle CSA offload message
2010 * @mac_ctx: pointer to global adapter context
2011 * @msg: Message pointer.
2012 *
2013 * Return: None
2014 */
2015void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
2016{
2017 tpPESession session_entry;
2018 tSirMsgQ mmh_msg;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302019 struct csa_offload_params *csa_params =
2020 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 tpSmeCsaOffloadInd csa_offload_ind;
2022 tpDphHashNode sta_ds = NULL;
2023 uint8_t session_id;
2024 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302025 uint16_t chan_space = 0;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002026 chan_params_t ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002029 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302031 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2032
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 if (!csa_params) {
2034 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2035 return;
2036 }
2037
2038 session_entry =
2039 pe_find_session_by_bssid(mac_ctx,
2040 csa_params->bssId, &session_id);
2041 if (!session_entry) {
2042 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302043 FL("Session does not exists for %pM"),
2044 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 goto err;
2046 }
2047
2048 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2049 &session_entry->dph.dphHashTable);
2050
2051 if (!sta_ds) {
2052 lim_log(mac_ctx, LOGE,
2053 FL("sta_ds does not exist"));
2054 goto err;
2055 }
2056
2057 if (LIM_IS_STA_ROLE(session_entry)) {
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302058 /*
2059 * on receiving channel switch announcement from AP, delete all
2060 * TDLS peers before leaving BSS and proceed for channel switch
2061 */
2062 lim_delete_tdls_peers(mac_ctx, session_entry);
2063
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002064 lim_ch_switch = &session_entry->gLimChannelSwitch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 session_entry->gLimChannelSwitch.switchMode =
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302066 csa_params->switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 /* timer already started by firmware, switch immediately */
2068 session_entry->gLimChannelSwitch.switchCount = 0;
2069 session_entry->gLimChannelSwitch.primaryChannel =
2070 csa_params->channel;
2071 session_entry->gLimChannelSwitch.state =
2072 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2073 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002074 lim_ch_switch->sec_ch_offset =
2075 session_entry->htSecondaryChannelOffset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302076 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2077 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2078 chnl_switch_info =
2079 &session_entry->gLimWiderBWChannelSwitch;
2080
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302081 lim_log(mac_ctx, LOG1,
2082 FL("vht:%d ht:%d flag:%x chan:%d seg1:%d seg2:%d width:%d country:%s class:%d"),
2083 session_entry->vhtCapability,
2084 session_entry->htSupportedChannelWidthSet,
2085 csa_params->ies_present_flag,
2086 csa_params->channel, csa_params->new_ch_freq_seg1,
2087 csa_params->new_ch_freq_seg2,
2088 csa_params->new_ch_width,
2089 mac_ctx->scan.countryCodeCurrent,
2090 csa_params->new_op_class);
2091
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 if (session_entry->vhtCapability &&
2093 session_entry->htSupportedChannelWidthSet) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
2095 chnl_switch_info->newChanWidth =
2096 csa_params->new_ch_width;
2097 chnl_switch_info->newCenterChanFreq0 =
2098 csa_params->new_ch_freq_seg1;
2099 chnl_switch_info->newCenterChanFreq1 =
2100 csa_params->new_ch_freq_seg2;
2101 session_entry->gLimChannelSwitch.state =
2102 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2103 session_entry->gLimChannelSwitch.ch_width =
2104 csa_params->new_ch_width + 1;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302105 } else if (csa_params->ies_present_flag
2106 & lim_xcsa_ie_present) {
2107 chan_space =
2108 cds_regdm_get_chanwidth_from_opclass(
2109 mac_ctx->scan.countryCodeCurrent,
2110 csa_params->channel,
2111 csa_params->new_op_class);
2112 session_entry->gLimChannelSwitch.state =
2113 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2114
2115 if (chan_space == 80) {
2116 chnl_switch_info->newChanWidth =
2117 CH_WIDTH_80MHZ;
2118 } else if (chan_space == 40) {
2119 chnl_switch_info->newChanWidth =
2120 CH_WIDTH_40MHZ;
2121 } else {
2122 chnl_switch_info->newChanWidth =
2123 CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002124 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302125 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2126 }
2127
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002128 ch_params.ch_width =
2129 chnl_switch_info->newChanWidth;
2130 cds_set_ch_params(csa_params->channel,
2131 eCSR_DOT11_MODE_11ac,
2132 &ch_params);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302133 chnl_switch_info->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002134 ch_params.center_freq_seg0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302135 /*
2136 * This is not applicable for 20/40/80 MHz.
2137 * Only used when we support 80+80 MHz operation.
2138 * In case of 80+80 MHz, this parameter indicates
2139 * center channel frequency index of 80 MHz
2140 * channel offrequency segment 1.
2141 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002142 chnl_switch_info->newCenterChanFreq1 =
2143 ch_params.center_freq_seg1;
2144 lim_ch_switch->sec_ch_offset =
2145 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147 }
Gupta, Kapil121bf212015-11-25 19:21:29 +05302148 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2149 chnl_switch_info->newCenterChanFreq0;
2150 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2151 chnl_switch_info->newCenterChanFreq1;
2152 session_entry->gLimChannelSwitch.ch_width =
2153 chnl_switch_info->newChanWidth;
2154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 } else if (session_entry->htSupportedChannelWidthSet) {
Gupta, Kapil121bf212015-11-25 19:21:29 +05302156 if (csa_params->ies_present_flag
2157 & lim_xcsa_ie_present) {
2158 chan_space =
2159 cds_regdm_get_chanwidth_from_opclass(
2160 mac_ctx->scan.countryCodeCurrent,
2161 csa_params->channel,
2162 csa_params->new_op_class);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002163 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302164 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2165 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002166 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302167 CH_WIDTH_40MHZ;
2168 chnl_switch_info->newChanWidth =
2169 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002170 ch_params.ch_width =
2171 chnl_switch_info->newChanWidth;
2172 cds_set_ch_params(csa_params->channel,
2173 eCSR_DOT11_MODE_11n,
2174 &ch_params);
2175 lim_ch_switch->ch_center_freq_seg0 =
2176 ch_params.center_freq_seg0;
2177 lim_ch_switch->sec_ch_offset =
2178 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302179 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002180 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302181 CH_WIDTH_20MHZ;
2182 chnl_switch_info->newChanWidth =
2183 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002184 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302185 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002186 lim_ch_switch->sec_ch_offset =
2187 PHY_SINGLE_CHANNEL_CENTERED;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302188 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002190 lim_ch_switch->ch_width =
2191 CH_WIDTH_40MHZ;
2192 lim_ch_switch->state =
2193 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2194 ch_params.ch_width = CH_WIDTH_40MHZ;
2195 cds_set_ch_params(csa_params->channel,
2196 eCSR_DOT11_MODE_11n,
2197 &ch_params);
2198 lim_ch_switch->ch_center_freq_seg0 =
2199 ch_params.center_freq_seg0;
2200 lim_ch_switch->sec_ch_offset =
2201 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 }
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002204 }
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302205 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
2206 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207
2208 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302209 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210 if (NULL == csa_offload_ind) {
2211 lim_log(mac_ctx, LOGE,
2212 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
2213 goto err;
2214 }
2215
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302216 qdf_mem_set(csa_offload_ind, sizeof(tSmeCsaOffloadInd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2218 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302219 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302220 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2222 mmh_msg.bodyptr = csa_offload_ind;
2223 mmh_msg.bodyval = 0;
2224 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002225 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 MTRACE(mac_trace_msg_tx
2227 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2228#ifdef FEATURE_WLAN_DIAG_SUPPORT
2229 lim_diag_event_report(mac_ctx,
2230 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2231 eSIR_SUCCESS, eSIR_SUCCESS);
2232#endif
2233 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
2234 }
2235
2236err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302237 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238}
2239
2240/*--------------------------------------------------------------------------
2241 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2242
2243 \param pMac - pointer to global adapter context
2244 \param sessionId - Message pointer.
2245
2246 \sa
2247 --------------------------------------------------------------------------*/
2248
2249void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ MsgQ)
2250{
2251 tpPESession psessionEntry;
2252 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2253
2254 psessionEntry =
2255 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2256 if (psessionEntry == NULL) {
2257 lim_log(pMac, LOGE,
2258 FL("Session Does not exist for given sessionID %d"),
2259 pDelBss->sessionId);
2260 return;
2261 }
2262 if (LIM_IS_IBSS_ROLE(psessionEntry)) {
2263 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
2264 } else if (LIM_IS_UNKNOWN_ROLE(psessionEntry)) {
2265 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
2266 }
2267
2268 else
2269 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2270
2271}
2272
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273/** -----------------------------------------------------------------
2274 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2275 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2276 \ SME only looks at rc and tspec field.
2277 \param pMac - global mac structure
2278 \param rspReqd - is SmeAddTsRsp required
2279 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2280 \return tspec
2281 \sa
2282 ----------------------------------------------------------------- */
2283void
2284lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2285 uint8_t smesessionId)
2286{
2287 tSirMsgQ mmhMsg;
2288
2289 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2290 mmhMsg.bodyptr = aggrQosRsp;
2291 mmhMsg.bodyval = 0;
2292 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2293 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2294
2295 return;
2296}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297
2298void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2299 uint8_t smesessionId)
2300{
2301 tSirMsgQ mmhMsg;
2302 tSmeMaxAssocInd *pSmeMaxAssocInd;
2303
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302304 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305 if (NULL == pSmeMaxAssocInd) {
2306 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2307 return;
2308 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302309 qdf_mem_set((void *)pSmeMaxAssocInd, sizeof(tSmeMaxAssocInd), 0);
2310 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302311 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2313 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2314 pSmeMaxAssocInd->sessionId = smesessionId;
2315 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2316 mmhMsg.bodyptr = pSmeMaxAssocInd;
2317 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2318 " sme session id %d"),
2319 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2320 MAC_ADDR_ARRAY(peerMacAddr));
2321 )
2322 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2323 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2324
2325 return;
2326}
2327
2328/** -----------------------------------------------------------------
2329 \brief lim_send_sme_dfs_event_notify() - sends
2330 eWNI_SME_DFS_RADAR_FOUND
2331 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2332 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2333 that a RADAR is found on current operating channel and SAP-
2334 has to move to a new channel.
2335 \param pMac - global mac structure
2336 \param msgType - message type received from lower layer
2337 \param event - event data received from lower layer
2338 \return none
2339 \sa
2340 ----------------------------------------------------------------- */
2341void
2342lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2343{
2344 tSirMsgQ mmhMsg;
2345 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2346 mmhMsg.bodyptr = event;
2347 mmhMsg.bodyval = 0;
2348 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2349 return;
2350}
2351
2352/*--------------------------------------------------------------------------
2353 \brief lim_send_dfs_chan_sw_ie_update()
2354 This timer handler updates the channel switch IE in beacon template
2355
2356 \param pMac - pointer to global adapter context
2357 \return - channel to scan from valid session else zero.
2358 \sa
2359 --------------------------------------------------------------------------*/
2360static void
2361lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2362{
2363
2364 /* Update the beacon template and send to FW */
2365 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2366 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2367 return;
2368 }
2369
2370 /* Send update beacon template message */
2371 lim_send_beacon_ind(pMac, psessionEntry);
2372 PELOG1(lim_log(pMac, LOG1,
2373 FL(" Updated CSA IE, IE COUNT = %d"),
2374 psessionEntry->gLimChannelSwitch.switchCount);
2375 )
2376
2377 return;
2378}
2379
2380/** -----------------------------------------------------------------
2381 \brief lim_send_sme_ap_channel_switch_resp() - sends
2382 eWNI_SME_CHANNEL_CHANGE_RSP
2383 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2384 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2385 that the Channel change has been done to the specified target
2386 channel in the Channel change request
2387 \param pMac - global mac structure
2388 \param psessionEntry - session info
2389 \param pChnlParams - Channel switch params
2390 --------------------------------------------------------------------*/
2391void
2392lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2393 tpPESession psessionEntry,
2394 tpSwitchChannelParams pChnlParams)
2395{
2396 tSirMsgQ mmhMsg;
2397 tpSwitchChannelParams pSmeSwithChnlParams;
2398 uint8_t channelId;
2399
2400 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302401 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402 if (NULL == pSmeSwithChnlParams) {
2403 lim_log(pMac, LOGP,
2404 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2405 return;
2406 }
2407
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302408 qdf_mem_set((void *)pSmeSwithChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 sizeof(tSwitchChannelParams), 0);
2410
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302411 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 sizeof(tSwitchChannelParams));
2413
2414 channelId = pSmeSwithChnlParams->channelNumber;
2415
2416 /*
2417 * Pass the sme sessionID to SME instead
2418 * PE session ID.
2419 */
2420 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2421
2422 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2423 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2424 mmhMsg.bodyval = 0;
2425 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2426
2427 /*
2428 * We should start beacon transmission only if the new
2429 * channel after channel change is Non-DFS. For a DFS
2430 * channel, PE will receive an explicit request from
2431 * upper layers to start the beacon transmission .
2432 */
2433
2434 if (CHANNEL_STATE_DFS != cds_get_channel_state(channelId)) {
2435 if (channelId == psessionEntry->currentOperChannel) {
2436 lim_apply_configuration(pMac, psessionEntry);
2437 lim_send_beacon_ind(pMac, psessionEntry);
2438 } else {
2439 PELOG1(lim_log(pMac, LOG1,
2440 FL
2441 ("Failed to Transmit Beacons on channel = %d"
2442 "after AP channel change response"),
2443 psessionEntry->bcnLen);
2444 )
2445 }
2446 }
2447 return;
2448}
2449
2450/** -----------------------------------------------------------------
2451 \brief lim_process_beacon_tx_success_ind() - This function is used
2452 explicitely to handle successful beacon transmission indication
2453 from the FW. This is a generic event generated by the FW afer the
2454 first beacon is sent out after the beacon template update by the
2455 host
2456 \param pMac - global mac structure
2457 \param psessionEntry - session info
2458 \return none
2459 \sa
2460 ----------------------------------------------------------------- */
2461void
2462lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2463{
2464 /* Currently, this event is used only for DFS channel switch announcement
2465 * IE update in the template. If required to be used for other IE updates
2466 * add appropriate code by introducing a state variable
2467 */
2468 tpPESession psessionEntry;
2469 tSirMsgQ mmhMsg;
2470 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2471 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2472 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2473 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2474 (tSirFirstBeaconTxCompleteInd *) event;
2475
2476 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2477 if (psessionEntry == NULL) {
2478 lim_log(pMac, LOGE,
2479 FL("Session Does not exist for given sessionID"));
2480 return;
2481 }
2482
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302483 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2484 GET_LIM_SYSTEM_ROLE(psessionEntry),
2485 psessionEntry->dfsIncludeChanSwIe,
2486 psessionEntry->gLimOperatingMode.present);
2487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488 if (LIM_IS_AP_ROLE(psessionEntry) &&
2489 true == psessionEntry->dfsIncludeChanSwIe) {
2490 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2491 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2492 /*
2493 * Send the next beacon with updated CSA IE count
2494 */
2495 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2496 /* Decrement the IE count */
2497 psessionEntry->gLimChannelSwitch.switchCount--;
2498 } else {
2499 /* Done with CSA IE update, send response back to SME */
2500 psessionEntry->gLimChannelSwitch.switchCount = 0;
2501 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2502 psessionEntry->gLimChannelSwitch.switchMode = 0;
2503 psessionEntry->dfsIncludeChanSwIe = false;
2504 psessionEntry->dfsIncludeChanWrapperIe = false;
2505
2506 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302507 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508
2509 if (NULL == pChanSwTxResponse) {
2510 lim_log(pMac, LOGP,
2511 FL
2512 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2513 return;
2514 }
2515
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302516 qdf_mem_set((void *)pChanSwTxResponse, length, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 pChanSwTxResponse->sessionId =
2518 psessionEntry->smeSessionId;
2519 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302520 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521
2522 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2523 mmhMsg.bodyptr = pChanSwTxResponse;
2524 mmhMsg.bodyval = 0;
2525 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2526 }
2527 }
2528
2529 if (LIM_IS_AP_ROLE(psessionEntry) &&
2530 psessionEntry->gLimOperatingMode.present) {
2531 /* Done with nss update, send response back to SME */
2532 psessionEntry->gLimOperatingMode.present = 0;
2533 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302534 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535 if (NULL == beacon_tx_comp_rsp_ptr) {
2536 lim_log(pMac, LOGP,
2537 FL
2538 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2539 return;
2540 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302541 qdf_mem_set((void *)beacon_tx_comp_rsp_ptr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 sizeof(*beacon_tx_comp_rsp_ptr), 0);
2543 beacon_tx_comp_rsp_ptr->session_id =
2544 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302545 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2547 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2548 mmhMsg.bodyval = 0;
2549 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2550 }
2551 return;
2552}