blob: 17d44927d859488c3a9bf1ade65fd76c54ac860a [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"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070058#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053059#include "lim_send_messages.h"
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;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 ht_profile->vhtCapability =
355 session_entry->vhtCapability;
356 ht_profile->vhtTxChannelWidthSet =
357 session_entry->vhtTxChannelWidthSet;
358 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
359 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 }
361#endif
362 } else {
363 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530364 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530366 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 }
368 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530369 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800370 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530371 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 }
373 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530374 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530376 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530379 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530381 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383#ifdef FEATURE_WLAN_ESE
384 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530385 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530387 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 }
389#endif
390 }
391}
392/**
393 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
394 * @mac_ctx: Pointer to Global MAC structure
395 * @msg_type: Indicates message type
396 * @result_code: Indicates the result of previously issued
397 * eWNI_SME_msgType_REQ message
398 * @prot_status_code: Protocol Status Code
399 * @session_entry: PE Session Info
400 * @sme_session_id: SME Session ID
401 * @sme_transaction_id: SME Transaction ID
402 *
403 * This function is called by lim_process_sme_req_messages() to send
404 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
405 * above MAC Software.
406 *
407 * Return: None
408 */
409
410void
411lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
412 tSirResultCodes result_code, uint16_t prot_status_code,
413 tpPESession session_entry, uint8_t sme_session_id,
414 uint16_t sme_transaction_id)
415{
416 tpSirSmeJoinRsp sme_join_rsp;
417 uint32_t rsp_len;
418 tpDphHashNode sta_ds = NULL;
419#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
420 if (msg_type == eWNI_SME_REASSOC_RSP)
421 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
422 session_entry, (uint16_t) result_code, 0);
423 else
424 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
425 session_entry, (uint16_t) result_code, 0);
426#endif /* FEATURE_WLAN_DIAG_SUPPORT */
427
428 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
429 lim_msg_str(msg_type), lim_result_code_str(result_code));
430
431 if (session_entry == NULL) {
432 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530433 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 if (NULL == sme_join_rsp) {
435 lim_log(mac_ctx, LOGP,
436 FL("Mem Alloc fail - JOIN/REASSOC_RSP"));
437 return;
438 }
439
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530440 qdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441 sme_join_rsp->beaconLength = 0;
442 sme_join_rsp->assocReqLength = 0;
443 sme_join_rsp->assocRspLength = 0;
444 } else {
445 rsp_len = session_entry->assocReqLen +
446 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448#ifdef FEATURE_WLAN_ESE
449 session_entry->tspecLen +
450#endif
451 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530452 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453 if (NULL == sme_join_rsp) {
454 lim_log(mac_ctx, LOGP,
455 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
456 return;
457 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530458 qdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 if (result_code == eSIR_SME_SUCCESS) {
460 sta_ds = dph_get_hash_entry(mac_ctx,
461 DPH_STA_HASH_INDEX_PEER,
462 &session_entry->dph.dphHashTable);
463 if (sta_ds == NULL) {
464 lim_log(mac_ctx, LOGE,
465 FL("Get Self Sta Entry fail"));
466 } else {
467 /* Pass the peer's staId */
468 sme_join_rsp->staId = sta_ds->staIndex;
469 sme_join_rsp->ucastSig =
470 sta_ds->ucUcastSig;
471 sme_join_rsp->bcastSig =
472 sta_ds->ucBcastSig;
473 sme_join_rsp->timingMeasCap =
474 sta_ds->timingMeasCap;
475#ifdef FEATURE_WLAN_TDLS
476 sme_join_rsp->tdls_prohibited =
477 session_entry->tdls_prohibited;
478 sme_join_rsp->tdls_chan_swit_prohibited =
479 session_entry->tdls_chan_swit_prohibited;
480#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530481 sme_join_rsp->nss = sta_ds->nss;
482 sme_join_rsp->max_rate_flags =
483 lim_get_max_rate_flags(mac_ctx, sta_ds);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484 }
485 }
486 sme_join_rsp->beaconLength = 0;
487 sme_join_rsp->assocReqLength = 0;
488 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490#ifdef FEATURE_WLAN_ESE
491 sme_join_rsp->tspecIeLen = 0;
492#endif
493
494 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
495 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800496
497 /* Send supported NSS 1x1 to SME */
498 sme_join_rsp->supported_nss_1x1 =
499 session_entry->supported_nss_1x1;
500 lim_log(mac_ctx, LOG1,
501 FL("SME Join Rsp is supported NSS 1X1: %d"),
502 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 }
504
505 sme_join_rsp->messageType = msg_type;
506 sme_join_rsp->length = (uint16_t) rsp_len;
507 sme_join_rsp->statusCode = result_code;
508 sme_join_rsp->protStatusCode = prot_status_code;
509
510 sme_join_rsp->sessionId = sme_session_id;
511 sme_join_rsp->transactionId = sme_transaction_id;
512
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530513 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514 (uint32_t *)sme_join_rsp);
515}
516
517/**
518 * lim_send_sme_start_bss_rsp()
519 *
520 ***FUNCTION:
521 * This function is called to send eWNI_SME_START_BSS_RSP
522 * message to applications above MAC Software.
523 *
524 ***PARAMS:
525 *
526 ***LOGIC:
527 *
528 ***ASSUMPTIONS:
529 * NA
530 *
531 ***NOTE:
532 * NA
533 *
534 * @param pMac Pointer to Global MAC structure
535 * @param msgType Indicates message type
536 * @param resultCode Indicates the result of previously issued
537 * eWNI_SME_msgType_REQ message
538 *
539 * @return None
540 */
541
542void
543lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
544 uint16_t msgType, tSirResultCodes resultCode,
545 tpPESession psessionEntry, uint8_t smesessionId,
546 uint16_t smetransactionId)
547{
548
549 uint16_t size = 0;
550 tSirMsgQ mmhMsg;
551 tSirSmeStartBssRsp *pSirSmeRsp;
552 uint16_t ieLen;
553 uint16_t ieOffset, curLen;
554
555 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
556 lim_msg_str(msgType), lim_result_code_str(resultCode));
557 )
558
559 size = sizeof(tSirSmeStartBssRsp);
560
561 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530562 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563 if (NULL == pSirSmeRsp) {
564 /* / Buffer not available. Log error */
565 lim_log(pMac, LOGP,
566 FL
567 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
568 return;
569 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530570 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571
572 } else {
573 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
574 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
575 ieLen = psessionEntry->schBeaconOffsetBegin
576 + psessionEntry->schBeaconOffsetEnd - ieOffset;
577 /* calculate the memory size to allocate */
578 size += ieLen;
579
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530580 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 if (NULL == pSirSmeRsp) {
582 /* / Buffer not available. Log error */
583 lim_log(pMac, LOGP,
584 FL
585 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
586
587 return;
588 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530589 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 size = sizeof(tSirSmeStartBssRsp);
591 if (resultCode == eSIR_SME_SUCCESS) {
592
593 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
594 psessionEntry->bssId);
595
596 /* Read beacon interval from session */
597 pSirSmeRsp->bssDescription.beaconInterval =
598 (uint16_t) psessionEntry->beaconParams.
599 beaconInterval;
600 pSirSmeRsp->bssType = psessionEntry->bssType;
601
602 if (cfg_get_capability_info
603 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
604 psessionEntry)
605 != eSIR_SUCCESS)
606 lim_log(pMac, LOGP,
607 FL
608 ("could not retrieve Capabilities value"));
609
610 lim_get_phy_mode(pMac,
611 (uint32_t *) &pSirSmeRsp->bssDescription.
612 nwType, psessionEntry);
613
614 pSirSmeRsp->bssDescription.channelId =
615 psessionEntry->currentOperChannel;
616
617 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530618 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 ieFields,
620 psessionEntry->pSchBeaconFrameBegin +
621 ieOffset, (uint32_t) curLen);
622
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530623 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 ieFields) + curLen,
625 psessionEntry->pSchBeaconFrameEnd,
626 (uint32_t) psessionEntry->
627 schBeaconOffsetEnd);
628
629 /* subtracting size of length indicator itself and size of pointer to ieFields */
630 pSirSmeRsp->bssDescription.length =
631 sizeof(tSirBssDescription) - sizeof(uint16_t) -
632 sizeof(uint32_t) + ieLen;
633 /* This is the size of the message, subtracting the size of the pointer to ieFields */
634 size += ieLen - sizeof(uint32_t);
635#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
636 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530637 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638 pSirSmeRsp->HTProfile.
639 htSupportedChannelWidthSet =
640 psessionEntry->htSupportedChannelWidthSet;
641 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
642 psessionEntry->htRecommendedTxWidthSet;
643 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
644 psessionEntry->htSecondaryChannelOffset;
645 pSirSmeRsp->HTProfile.dot11mode =
646 psessionEntry->dot11mode;
647 pSirSmeRsp->HTProfile.htCapability =
648 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 pSirSmeRsp->HTProfile.vhtCapability =
650 psessionEntry->vhtCapability;
651 pSirSmeRsp->HTProfile.vhtTxChannelWidthSet =
652 psessionEntry->vhtTxChannelWidthSet;
653 pSirSmeRsp->HTProfile.apCenterChan =
654 psessionEntry->ch_center_freq_seg0;
655 pSirSmeRsp->HTProfile.apChanWidth =
656 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657 }
658#endif
659 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661 pSirSmeRsp->messageType = msgType;
662 pSirSmeRsp->length = size;
663
664 /* Update SME session Id and transaction Id */
665 pSirSmeRsp->sessionId = smesessionId;
666 pSirSmeRsp->transactionId = smetransactionId;
667 pSirSmeRsp->statusCode = resultCode;
668 if (psessionEntry != NULL)
669 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
670
671 mmhMsg.type = msgType;
672 mmhMsg.bodyptr = pSirSmeRsp;
673 mmhMsg.bodyval = 0;
674 if (psessionEntry == NULL) {
675 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
676 } else {
677 MTRACE(mac_trace_msg_tx
678 (pMac, psessionEntry->peSessionId, mmhMsg.type));
679 }
680#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
681 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
682 psessionEntry, (uint16_t) resultCode, 0);
683#endif /* FEATURE_WLAN_DIAG_SUPPORT */
684
685 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
686} /*** end lim_send_sme_start_bss_rsp() ***/
687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688/**
689 * lim_send_sme_scan_rsp() - Send scan response to SME
690 * @pMac: Pointer to Global MAC structure
691 * @length: Indicates length of message
692 * @resultCode: Indicates the result of previously issued
693 * eWNI_SME_SCAN_REQ message
694 * @scan_id: scan identifier
695 *
696 * This function is called by lim_process_sme_req_messages() to send
697 * eWNI_SME_SCAN_RSP message to applications above MAC
698 *
699 * return: None
700 */
701
702void
703lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
704 uint8_t smesessionId, uint16_t smetranscationId,
705 uint32_t scan_id)
706{
707 lim_log(pMac, LOG1,
708 FL("Sending message SME_SCAN_RSP reasonCode %s scanId %d"),
709 lim_result_code_str(resultCode), scan_id);
710 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
711 smetranscationId, scan_id);
712}
713
714/**
715 * lim_post_sme_scan_rsp_message()
716 *
717 ***FUNCTION:
718 * This function is called by lim_send_sme_scan_rsp() to send
719 * eWNI_SME_SCAN_RSP message with failed result code
720 *
721 ***NOTE:
722 * NA
723 *
724 * @param pMac Pointer to Global MAC structure
725 * @param length Indicates length of message
726 * @param resultCode failed result code
727 *
728 * @return None
729 */
730
731void
732lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
733 tSirResultCodes resultCode, uint8_t smesessionId,
734 uint16_t smetransactionId,
735 uint32_t scan_id)
736{
737 tpSirSmeScanRsp pSirSmeScanRsp;
738 tSirMsgQ mmhMsg;
739
740 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
741 lim_result_code_str(resultCode));
742
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530743 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 if (NULL == pSirSmeScanRsp) {
745 lim_log(pMac, LOGP,
746 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
747 return;
748 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530749 qdf_mem_set((void *)pSirSmeScanRsp, sizeof(tSirSmeScanRsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750
751 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
752 pSirSmeScanRsp->statusCode = resultCode;
753
754 /*Update SME session Id and transaction Id */
755 pSirSmeScanRsp->sessionId = smesessionId;
756 pSirSmeScanRsp->transcationId = smetransactionId;
757 pSirSmeScanRsp->scan_id = scan_id;
758
759 mmhMsg.type = eWNI_SME_SCAN_RSP;
760 mmhMsg.bodyptr = pSirSmeScanRsp;
761 mmhMsg.bodyval = 0;
762
763 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
764#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
765 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
766 (uint16_t) resultCode, 0);
767#endif /* FEATURE_WLAN_DIAG_SUPPORT */
768
769 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
770 return;
771
772} /*** lim_post_sme_scan_rsp_message ***/
773
774#ifdef FEATURE_OEM_DATA_SUPPORT
775
776/**
777 * lim_send_sme_oem_data_rsp()
778 *
779 ***FUNCTION:
780 * This function is called by lim_process_sme_req_messages() to send
781 * eWNI_SME_OEM_DATA_RSP message to applications above MAC
782 * Software.
783 *
784 ***PARAMS:
785 *
786 ***LOGIC:
787 *
788 ***ASSUMPTIONS:
789 * NA
790 *
791 ***NOTE:
792 * NA
793 *
794 * @param pMac Pointer to Global MAC structure
795 * @param pMsgBuf Indicates the mlm message
796 * @param resultCode Indicates the result of previously issued
797 * eWNI_SME_OEM_DATA_RSP message
798 *
799 * @return None
800 */
801
802void lim_send_sme_oem_data_rsp(tpAniSirGlobal pMac, uint32_t *pMsgBuf,
803 tSirResultCodes resultCode)
804{
805 tSirMsgQ mmhMsg;
806 tSirOemDataRsp *pSirSmeOemDataRsp = NULL;
807 tLimMlmOemDataRsp *pMlmOemDataRsp = NULL;
808 uint16_t msgLength;
809
810 /* get the pointer to the mlm message */
811 pMlmOemDataRsp = (tLimMlmOemDataRsp *) (pMsgBuf);
812
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800813 msgLength = sizeof(*pSirSmeOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 /* now allocate memory for the char buffer */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800815 pSirSmeOemDataRsp = qdf_mem_malloc(sizeof(*pSirSmeOemDataRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 if (NULL == pSirSmeOemDataRsp) {
817 lim_log(pMac, LOGP,
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800818 FL("malloc failed for pSirSmeOemDataRsp"));
819 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
820 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 return;
822 }
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800823
824 if (pMlmOemDataRsp->rsp_len) {
825 pSirSmeOemDataRsp->oem_data_rsp =
826 qdf_mem_malloc(pMlmOemDataRsp->rsp_len);
827 if (!pSirSmeOemDataRsp->oem_data_rsp) {
828 lim_log(pMac, LOGE,
829 FL("malloc failed for oem_data_rsp"));
830 qdf_mem_free(pSirSmeOemDataRsp);
831 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
832 qdf_mem_free(pMlmOemDataRsp);
833 return;
834 }
835 }
836
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837#if defined (ANI_LITTLE_BYTE_ENDIAN)
838 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->length, msgLength);
839 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->messageType,
840 eWNI_SME_OEM_DATA_RSP);
841#else
842 pSirSmeOemDataRsp->length = msgLength;
843 pSirSmeOemDataRsp->messageType = eWNI_SME_OEM_DATA_RSP;
844#endif
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -0800845 pSirSmeOemDataRsp->target_rsp = pMlmOemDataRsp->target_rsp;
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800846 pSirSmeOemDataRsp->rsp_len = pMlmOemDataRsp->rsp_len;
847 if (pSirSmeOemDataRsp->rsp_len)
848 qdf_mem_copy(pSirSmeOemDataRsp->oem_data_rsp,
849 pMlmOemDataRsp->oem_data_rsp,
850 pSirSmeOemDataRsp->rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851
852 /* Now free the memory from MLM Rsp Message */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800853 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530854 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855
856 mmhMsg.type = eWNI_SME_OEM_DATA_RSP;
857 mmhMsg.bodyptr = pSirSmeOemDataRsp;
858 mmhMsg.bodyval = 0;
859
860 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
861
862 return;
863} /*** lim_send_sme_oem_data_rsp ***/
864
865#endif
866
867void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530868 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869{
870 tSirMsgQ mmhMsg;
871 tSirMsgQ *pMsg = (tSirMsgQ *) pCtx;
872
873 mmhMsg.type = pMsg->type;
874 mmhMsg.bodyptr = pMsg;
875 mmhMsg.bodyval = 0;
876
877 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
878
879 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
880}
881
882/**
883 * lim_send_sme_disassoc_ntf()
884 *
885 ***FUNCTION:
886 * This function is called by limProcessSmeMessages() to send
887 * eWNI_SME_DISASSOC_RSP/IND message to host
888 *
889 ***PARAMS:
890 *
891 ***LOGIC:
892 *
893 ***ASSUMPTIONS:
894 * NA
895 *
896 ***NOTE:
897 * This function is used for sending eWNI_SME_DISASSOC_CNF,
898 * or eWNI_SME_DISASSOC_IND to host depending on
899 * disassociation trigger.
900 *
901 * @param peerMacAddr Indicates the peer MAC addr to which
902 * disassociate was initiated
903 * @param reasonCode Indicates the reason for Disassociation
904 * @param disassocTrigger Indicates the trigger for Disassociation
905 * @param aid Indicates the STAID. This parameter is
906 * present only on AP.
907 *
908 * @return None
909 */
910void
911lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
912 tSirMacAddr peerMacAddr,
913 tSirResultCodes reasonCode,
914 uint16_t disassocTrigger,
915 uint16_t aid,
916 uint8_t smesessionId,
917 uint16_t smetransactionId, tpPESession psessionEntry)
918{
919
920 uint8_t *pBuf;
921 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
922 tSirSmeDisassocInd *pSirSmeDisassocInd;
923 uint32_t *pMsg;
924 bool failure = false;
925
926 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
927 disassocTrigger, reasonCode);
928
929 switch (disassocTrigger) {
930 case eLIM_PEER_ENTITY_DISASSOC:
931 if (reasonCode != eSIR_SME_STA_NOT_ASSOCIATED) {
932 failure = true;
933 goto error;
934 }
935
936 case eLIM_HOST_DISASSOC:
937 /**
938 * Disassociation response due to
939 * host triggered disassociation
940 */
941
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530942 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 if (NULL == pSirSmeDisassocRsp) {
944 /* Log error */
945 lim_log(pMac, LOGP, FL("Memory allocation failed"));
946 failure = true;
947 goto error;
948 }
949 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
950 "retCode: %d for " MAC_ADDRESS_STR),
951 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
952 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
953 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
954 /* sessionId */
955 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
956 *pBuf = smesessionId;
957 pBuf++;
958
959 /* transactionId */
960 lim_copy_u16(pBuf, smetransactionId);
961 pBuf += sizeof(uint16_t);
962
963 /* statusCode */
964 lim_copy_u32(pBuf, reasonCode);
965 pBuf += sizeof(tSirResultCodes);
966
967 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530968 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 pBuf += sizeof(tSirMacAddr);
970
971 /* Clear Station Stats */
972 /* for sta, it is always 1, IBSS is handled at halInitSta */
973
974#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
975
976 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
977 psessionEntry, (uint16_t) reasonCode, 0);
978#endif
979 pMsg = (uint32_t *) pSirSmeDisassocRsp;
980 break;
981
982 default:
983 /**
984 * Disassociation indication due to Disassociation
985 * frame reception from peer entity or due to
986 * loss of link with peer entity.
987 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530988 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 if (NULL == pSirSmeDisassocInd) {
990 /* Log error */
991 lim_log(pMac, LOGP, FL("Memory allocation failed"));
992 failure = true;
993 goto error;
994 }
995 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
996 "retCode: %d for " MAC_ADDRESS_STR),
997 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
998 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
999 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1000
1001 /* Update SME session Id and Transaction Id */
1002 pSirSmeDisassocInd->sessionId = smesessionId;
1003 pSirSmeDisassocInd->transactionId = smetransactionId;
1004 pSirSmeDisassocInd->reasonCode = reasonCode;
1005 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1006
1007 lim_copy_u32(pBuf, reasonCode);
1008 pBuf += sizeof(tSirResultCodes);
1009
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301010 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011 pBuf += sizeof(tSirMacAddr);
1012
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301013 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014
1015#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1016 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1017 psessionEntry, (uint16_t) reasonCode, 0);
1018#endif
1019 pMsg = (uint32_t *) pSirSmeDisassocInd;
1020
1021 break;
1022 }
1023
1024error:
1025 /* Delete the PE session Created */
1026 if ((psessionEntry != NULL) &&
1027 (LIM_IS_STA_ROLE(psessionEntry) ||
1028 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))) {
1029 pe_delete_session(pMac, psessionEntry);
1030 }
1031
1032 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301033 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 (uint32_t *) pMsg);
1035} /*** end lim_send_sme_disassoc_ntf() ***/
1036
1037/** -----------------------------------------------------------------
1038 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1039
1040 After receiving disassociation frame from peer entity, this
1041 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1042 reason code.
1043
1044 \param pMac - global mac structure
1045 \param pStaDs - station dph hash node
1046 \return none
1047 \sa
1048 ----------------------------------------------------------------- */
1049void
1050lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1051 tpPESession psessionEntry)
1052{
1053 tSirMsgQ mmhMsg;
1054 tSirSmeDisassocInd *pSirSmeDisassocInd;
1055
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301056 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 if (NULL == pSirSmeDisassocInd) {
1058 lim_log(pMac, LOGP,
1059 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1060 return;
1061 }
1062
1063 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1064 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1065
1066 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1067 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
1068 pSirSmeDisassocInd->statusCode = pStaDs->mlmStaContext.disassocReason;
1069 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1070
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301071 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301072 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301074 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301075 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076
1077 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1078
1079 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1080 mmhMsg.bodyptr = pSirSmeDisassocInd;
1081 mmhMsg.bodyval = 0;
1082
1083 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1084#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1085 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1086 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1087#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1088
1089 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1090
1091} /*** end lim_send_sme_disassoc_ind() ***/
1092
1093/** -----------------------------------------------------------------
1094 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1095
1096 After receiving deauthentication frame from peer entity, this
1097 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1098 reason code.
1099
1100 \param pMac - global mac structure
1101 \param pStaDs - station dph hash node
1102 \return none
1103 \sa
1104 ----------------------------------------------------------------- */
1105void
1106lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1107 tpPESession psessionEntry)
1108{
1109 tSirMsgQ mmhMsg;
1110 tSirSmeDeauthInd *pSirSmeDeauthInd;
1111
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301112 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113 if (NULL == pSirSmeDeauthInd) {
1114 lim_log(pMac, LOGP,
1115 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1116 return;
1117 }
1118
1119 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1120 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1121
1122 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1123 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1124 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1125 pSirSmeDeauthInd->statusCode =
1126 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1127 } else {
1128 /* Need to indicatet he reascon code over the air */
1129 pSirSmeDeauthInd->statusCode =
1130 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1131 }
1132 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301133 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301134 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301136 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301137 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1139
1140 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001141 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1142 pStaDs->mlmStaContext.disassocReason)
1143 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144
1145 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1146 mmhMsg.bodyptr = pSirSmeDeauthInd;
1147 mmhMsg.bodyval = 0;
1148
1149 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1150#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1151 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1152 0, pStaDs->mlmStaContext.cleanupTrigger);
1153#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1154
1155 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1156 return;
1157} /*** end lim_send_sme_deauth_ind() ***/
1158
1159#ifdef FEATURE_WLAN_TDLS
1160/**
1161 * lim_send_sme_tdls_del_sta_ind()
1162 *
1163 ***FUNCTION:
1164 * This function is called to send the TDLS STA context deletion to SME.
1165 *
1166 ***LOGIC:
1167 *
1168 ***ASSUMPTIONS:
1169 *
1170 ***NOTE:
1171 * NA
1172 *
1173 * @param pMac - Pointer to global MAC structure
1174 * @param pStaDs - Pointer to internal STA Datastructure
1175 * @param psessionEntry - Pointer to the session entry
1176 * @param reasonCode - Reason for TDLS sta deletion
1177 * @return None
1178 */
1179void
1180lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1181 tpPESession psessionEntry, uint16_t reasonCode)
1182{
1183 tSirMsgQ mmhMsg;
1184 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1185
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301186 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187 if (NULL == pSirTdlsDelStaInd) {
1188 lim_log(pMac, LOGP,
1189 FL
1190 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1191 return;
1192 }
1193 /* messageType */
1194 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1195 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1196
1197 /* sessionId */
1198 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1199
1200 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301201 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301202 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203
1204 /* staId */
1205 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1206 (uint16_t) pStaDs->staIndex);
1207
1208 /* reasonCode */
1209 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1210
1211 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1212 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1213 mmhMsg.bodyval = 0;
1214
1215 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1216 return;
1217} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1218
1219/**
1220 * lim_send_sme_tdls_delete_all_peer_ind()
1221 *
1222 ***FUNCTION:
1223 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1224 * message to SME.
1225 *
1226 ***LOGIC:
1227 *
1228 ***ASSUMPTIONS:
1229 *
1230 ***NOTE:
1231 * NA
1232 *
1233 * @param pMac - Pointer to global MAC structure
1234 * @param psessionEntry - Pointer to the session entry
1235 * @return None
1236 */
1237void
1238lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1239{
1240 tSirMsgQ mmhMsg;
1241 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1242
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301243 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 if (NULL == pSirTdlsDelAllPeerInd) {
1245 lim_log(pMac, LOGP,
1246 FL
1247 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1248 return;
1249 }
1250 /* messageType */
1251 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1252 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1253
1254 /* sessionId */
1255 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1256
1257 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1258 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1259 mmhMsg.bodyval = 0;
1260
1261 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1262 return;
1263} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1264
1265/**
1266 * lim_send_sme_mgmt_tx_completion()
1267 *
1268 ***FUNCTION:
1269 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1270 * message to SME.
1271 *
1272 ***LOGIC:
1273 *
1274 ***ASSUMPTIONS:
1275 *
1276 ***NOTE:
1277 * NA
1278 *
1279 * @param pMac - Pointer to global MAC structure
1280 * @param psessionEntry - Pointer to the session entry
1281 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1282 * @return None
1283 */
1284void
1285lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
1286 tpPESession psessionEntry, uint32_t txCompleteStatus)
1287{
1288 tSirMsgQ mmhMsg;
1289 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1290
1291 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301292 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 if (NULL == pSirMgmtTxCompletionInd) {
1294 lim_log(pMac, LOGP,
1295 FL
1296 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1297 return;
1298 }
1299 /* messageType */
1300 pSirMgmtTxCompletionInd->messageType =
1301 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1302 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1303
1304 /* sessionId */
1305 pSirMgmtTxCompletionInd->sessionId = psessionEntry->smeSessionId;
1306
1307 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1308
1309 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1310 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1311 mmhMsg.bodyval = 0;
1312
1313 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1314 return;
1315} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1316
1317void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1318 void *events)
1319{
1320 tSirMsgQ mmhMsg;
1321
1322 switch (msgType) {
1323 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1324 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1325 break;
1326 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1327 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1328 break;
1329 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1330 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1331 break;
1332 }
1333
1334 mmhMsg.bodyptr = events;
1335 mmhMsg.bodyval = 0;
1336 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1337 return;
1338}
1339#endif /* FEATURE_WLAN_TDLS */
1340
1341/**
1342 * lim_send_sme_deauth_ntf()
1343 *
1344 ***FUNCTION:
1345 * This function is called by limProcessSmeMessages() to send
1346 * eWNI_SME_DISASSOC_RSP/IND message to host
1347 *
1348 ***PARAMS:
1349 *
1350 ***LOGIC:
1351 *
1352 ***ASSUMPTIONS:
1353 * NA
1354 *
1355 ***NOTE:
1356 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1357 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1358 *
1359 * @param peerMacAddr Indicates the peer MAC addr to which
1360 * deauthentication was initiated
1361 * @param reasonCode Indicates the reason for Deauthetication
1362 * @param deauthTrigger Indicates the trigger for Deauthetication
1363 * @param aid Indicates the STAID. This parameter is present
1364 * only on AP.
1365 *
1366 * @return None
1367 */
1368void
1369lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1370 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1371 uint16_t aid, uint8_t smesessionId,
1372 uint16_t smetransactionId)
1373{
1374 uint8_t *pBuf;
1375 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1376 tSirSmeDeauthInd *pSirSmeDeauthInd;
1377 tpPESession psessionEntry;
1378 uint8_t sessionId;
1379 uint32_t *pMsg;
1380
1381 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1382 switch (deauthTrigger) {
1383 case eLIM_PEER_ENTITY_DEAUTH:
1384 return;
1385
1386 case eLIM_HOST_DEAUTH:
1387 /**
1388 * Deauthentication response to host triggered
1389 * deauthentication.
1390 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301391 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 if (NULL == pSirSmeDeauthRsp) {
1393 /* Log error */
1394 lim_log(pMac, LOGP,
1395 FL
1396 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1397
1398 return;
1399 }
1400 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1401 "retCode: %d for" MAC_ADDRESS_STR),
1402 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1403 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1404 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1405 pSirSmeDeauthRsp->statusCode = reasonCode;
1406 pSirSmeDeauthRsp->sessionId = smesessionId;
1407 pSirSmeDeauthRsp->transactionId = smetransactionId;
1408
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001409 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301410 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411
1412#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1413 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1414 psessionEntry, 0, (uint16_t) reasonCode);
1415#endif
1416 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1417
1418 break;
1419
1420 default:
1421 /**
1422 * Deauthentication indication due to Deauthentication
1423 * frame reception from peer entity or due to
1424 * loss of link with peer entity.
1425 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301426 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 if (NULL == pSirSmeDeauthInd) {
1428 /* Log error */
1429 lim_log(pMac, LOGP,
1430 FL
1431 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1432
1433 return;
1434 }
1435 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1436 "retCode: %d for " MAC_ADDRESS_STR),
1437 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1438 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1439 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1440 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1441
1442 /* sessionId */
1443 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1444 *pBuf++ = smesessionId;
1445
1446 /* transaction ID */
1447 lim_copy_u16(pBuf, smetransactionId);
1448 pBuf += sizeof(uint16_t);
1449
1450 /* status code */
1451 lim_copy_u32(pBuf, reasonCode);
1452 pBuf += sizeof(tSirResultCodes);
1453
1454 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301455 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 pBuf += sizeof(tSirMacAddr);
1457
1458 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301459 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301460 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461
1462#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1463 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1464 psessionEntry, 0, (uint16_t) reasonCode);
1465#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1466 pMsg = (uint32_t *) pSirSmeDeauthInd;
1467
1468 break;
1469 }
1470
1471 /*Delete the PE session created */
1472 if (psessionEntry != NULL) {
1473 pe_delete_session(pMac, psessionEntry);
1474 }
1475
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301476 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001477 (uint32_t *) pMsg);
1478
1479} /*** end lim_send_sme_deauth_ntf() ***/
1480
1481/**
1482 * lim_send_sme_wm_status_change_ntf() - Send Notification
1483 * @mac_ctx: Global MAC Context
1484 * @status_change_code: Indicates the change in the wireless medium.
1485 * @status_change_info: Indicates the information associated with
1486 * change in the wireless medium.
1487 * @info_len: Indicates the length of status change information
1488 * being sent.
1489 * @session_id SessionID
1490 *
1491 * This function is called by limProcessSmeMessages() to send
1492 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1493 *
1494 * Return: None
1495 */
1496void
1497lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1498 tSirSmeStatusChangeCode status_change_code,
1499 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1500{
1501 tSirMsgQ msg;
1502 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
1503
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301504 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 if (NULL == wm_status_change_ntf) {
1506 lim_log(mac_ctx, LOGE,
1507 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1508 return;
1509 }
1510
1511 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1512 msg.bodyval = 0;
1513 msg.bodyptr = wm_status_change_ntf;
1514
1515 switch (status_change_code) {
1516 case eSIR_SME_RADAR_DETECTED:
1517 break;
1518 default:
1519 wm_status_change_ntf->messageType =
1520 eWNI_SME_WM_STATUS_CHANGE_NTF;
1521 wm_status_change_ntf->statusChangeCode = status_change_code;
1522 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1523 wm_status_change_ntf->sessionId = session_id;
1524 if (sizeof(wm_status_change_ntf->statusChangeInfo) >=
1525 info_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301526 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1528 (uint8_t *) status_change_info, info_len);
1529 }
1530 lim_log(mac_ctx, LOGE,
1531 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1532 status_change_code, info_len);
1533 break;
1534 }
1535
1536 MTRACE(mac_trace_msg_tx(mac_ctx, session_id, msg.type));
1537 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301538 qdf_mem_free(wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 lim_log(mac_ctx, LOGP,
1540 FL("lim_sys_process_mmh_msg_api failed"));
1541 }
1542
1543} /*** end lim_send_sme_wm_status_change_ntf() ***/
1544
1545/**
1546 * lim_send_sme_set_context_rsp()
1547 *
1548 ***FUNCTION:
1549 * This function is called by limProcessSmeMessages() to send
1550 * eWNI_SME_SETCONTEXT_RSP message to host
1551 *
1552 ***PARAMS:
1553 *
1554 ***LOGIC:
1555 *
1556 ***ASSUMPTIONS:
1557 * NA
1558 *
1559 ***NOTE:
1560 *
1561 * @param pMac Pointer to Global MAC structure
1562 * @param peerMacAddr Indicates the peer MAC addr to which
1563 * setContext was performed
1564 * @param aid Indicates the aid corresponding to the peer MAC
1565 * address
1566 * @param resultCode Indicates the result of previously issued
1567 * eWNI_SME_SETCONTEXT_RSP message
1568 *
1569 * @return None
1570 */
1571void
1572lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301573 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 tSirResultCodes resultCode,
1575 tpPESession psessionEntry, uint8_t smesessionId,
1576 uint16_t smetransactionId)
1577{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 tSirMsgQ mmhMsg;
1579 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1580
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 if (NULL == pSirSmeSetContextRsp) {
1583 /* Log error */
1584 lim_log(pMac, LOGP,
1585 FL
1586 ("call to AllocateMemory failed for SmeSetContextRsp"));
1587
1588 return;
1589 }
1590
1591 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1592 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1593 pSirSmeSetContextRsp->statusCode = resultCode;
1594
Anurag Chouhanc5548422016-02-24 18:33:27 +05301595 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596
1597 /* Update SME session and transaction Id */
1598 pSirSmeSetContextRsp->sessionId = smesessionId;
1599 pSirSmeSetContextRsp->transactionId = smetransactionId;
1600
1601 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1602 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1603 mmhMsg.bodyval = 0;
1604 if (NULL == psessionEntry) {
1605 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1606 } else {
1607 MTRACE(mac_trace_msg_tx
1608 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1609 }
1610
1611#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1612 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1613 psessionEntry, (uint16_t) resultCode, 0);
1614#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1615
1616 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1617} /*** end lim_send_sme_set_context_rsp() ***/
1618
1619/**
1620 * lim_send_sme_neighbor_bss_ind()
1621 *
1622 ***FUNCTION:
1623 * This function is called by lim_lookup_nadd_hash_entry() to send
1624 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1625 *
1626 ***PARAMS:
1627 *
1628 ***LOGIC:
1629 *
1630 ***ASSUMPTIONS:
1631 * NA
1632 *
1633 ***NOTE:
1634 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1635 * host upon detecting new BSS during background scanning if CFG
1636 * option is enabled for sending such indication
1637 *
1638 * @param pMac - Pointer to Global MAC structure
1639 * @return None
1640 */
1641
1642void
1643lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1644{
1645 tSirMsgQ msgQ;
1646 uint32_t val;
1647 tSirSmeNeighborBssInd *pNewBssInd;
1648
1649 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1650 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1651 pMac->lim.gLimRspReqd)) {
1652 /* LIM is not in background scan state OR */
1653 /* current scan is initiated by HDD. */
1654 /* No need to send new BSS indication to HDD */
1655 return;
1656 }
1657
1658 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1659 eSIR_SUCCESS) {
1660 lim_log(pMac, LOGP,
1661 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1662
1663 return;
1664 }
1665
1666 if (val == 0)
1667 return;
1668
1669 /**
1670 * Need to indicate new BSSs found during
1671 * background scanning to host.
1672 * Allocate buffer for sending indication.
1673 * Length of buffer is length of BSS description
1674 * and length of header itself
1675 */
1676 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1677 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301678 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 if (NULL == pNewBssInd) {
1680 /* Log error */
1681 lim_log(pMac, LOGP,
1682 FL
1683 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1684
1685 return;
1686 }
1687
1688 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1689 pNewBssInd->length = (uint16_t) val;
1690 pNewBssInd->sessionId = 0;
1691
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301692 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 (uint8_t *) &pBssDescr->bssDescription,
1694 pBssDescr->bssDescription.length + sizeof(uint16_t));
1695
1696 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1697 msgQ.bodyptr = pNewBssInd;
1698 msgQ.bodyval = 0;
1699 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
1700 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1701} /*** end lim_send_sme_neighbor_bss_ind() ***/
1702
1703/** -----------------------------------------------------------------
1704 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1705 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1706 \ SME only looks at rc and tspec field.
1707 \param pMac - global mac structure
1708 \param rspReqd - is SmeAddTsRsp required
1709 \param status - status code of SME_ADD_TS_RSP
1710 \return tspec
1711 \sa
1712 ----------------------------------------------------------------- */
1713void
1714lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1715 tpPESession psessionEntry, tSirMacTspecIE tspec,
1716 uint8_t smesessionId, uint16_t smetransactionId)
1717{
1718 tpSirAddtsRsp rsp;
1719 tSirMsgQ mmhMsg;
1720
1721 if (!rspReqd)
1722 return;
1723
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301724 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 if (NULL == rsp) {
1726 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1727 return;
1728 }
1729
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301730 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 rsp->messageType = eWNI_SME_ADDTS_RSP;
1732 rsp->rc = status;
1733 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1734 rsp->rsp.tspec = tspec;
1735 /* Update SME session Id and transcation Id */
1736 rsp->sessionId = smesessionId;
1737 rsp->transactionId = smetransactionId;
1738
1739 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1740 mmhMsg.bodyptr = rsp;
1741 mmhMsg.bodyval = 0;
1742 if (NULL == psessionEntry) {
1743 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1744 } else {
1745 MTRACE(mac_trace_msg_tx
1746 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1747 }
1748#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1749 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1750 0);
1751#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1752
1753 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1754 return;
1755}
1756
1757void
1758lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1759 tpPESession psessionEntry, uint8_t smesessionId,
1760 uint16_t smetransactionId)
1761{
1762 tpSirDeltsRsp rsp;
1763 tSirMsgQ mmhMsg;
1764
1765 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1766 delts->aid,
1767 delts->req.tsinfo.traffic.tsid,
1768 delts->req.tsinfo.traffic.userPrio, status);
1769 if (!delts->rspReqd)
1770 return;
1771
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301772 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 if (NULL == rsp) {
1774 /* Log error */
1775 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1776 return;
1777 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301778 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779
1780 if (psessionEntry != NULL) {
1781
1782 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301783 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301784 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 sizeof(tSirDeltsReqInfo));
1786 }
1787
1788 rsp->messageType = eWNI_SME_DELTS_RSP;
1789 rsp->rc = status;
1790
1791 /* Update SME session Id and transcation Id */
1792 rsp->sessionId = smesessionId;
1793 rsp->transactionId = smetransactionId;
1794
1795 mmhMsg.type = eWNI_SME_DELTS_RSP;
1796 mmhMsg.bodyptr = rsp;
1797 mmhMsg.bodyval = 0;
1798 if (NULL == psessionEntry) {
1799 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1800 } else {
1801 MTRACE(mac_trace_msg_tx
1802 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1803 }
1804#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1805 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1806 (uint16_t) status, 0);
1807#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1808
1809 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1810}
1811
1812void
1813lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1814 tpPESession psessionEntry)
1815{
1816 tpSirDeltsRsp rsp;
1817 tSirMsgQ mmhMsg;
1818
1819 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1820 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1821
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301822 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 if (NULL == rsp) {
1824 /* Log error */
1825 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1826 return;
1827 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301828 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
1830 rsp->messageType = eWNI_SME_DELTS_IND;
1831 rsp->rc = eSIR_SUCCESS;
1832 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301833 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834
1835 /* Update SME session Id and SME transaction Id */
1836
1837 rsp->sessionId = psessionEntry->smeSessionId;
1838 rsp->transactionId = psessionEntry->transactionId;
1839
1840 mmhMsg.type = eWNI_SME_DELTS_IND;
1841 mmhMsg.bodyptr = rsp;
1842 mmhMsg.bodyval = 0;
1843 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1844#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1845 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1846 0);
1847#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1848
1849 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1850}
1851
1852/**
1853 * lim_send_sme_pe_statistics_rsp()
1854 *
1855 ***FUNCTION:
1856 * This function is called to send 802.11 statistics response to HDD.
1857 * This function posts the result back to HDD. This is a response to
1858 * HDD's request for statistics.
1859 *
1860 ***PARAMS:
1861 *
1862 ***LOGIC:
1863 *
1864 ***ASSUMPTIONS:
1865 * NA
1866 *
1867 ***NOTE:
1868 * NA
1869 *
1870 * @param pMac Pointer to Global MAC structure
1871 * @param p80211Stats Statistics sent in response
1872 * @param resultCode TODO:
1873 *
1874 *
1875 * @return none
1876 */
1877
1878void
1879lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1880{
1881 tSirMsgQ mmhMsg;
1882 uint8_t sessionId;
1883 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1884 tpPESession pPeSessionEntry;
1885
1886 /* Get the Session Id based on Sta Id */
1887 pPeSessionEntry =
1888 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1889
1890 /* Fill the Session Id */
1891 if (NULL != pPeSessionEntry) {
1892 /* Fill the Session Id */
1893 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1894 }
1895
1896 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1897
1898 /* msgType should be WMA_GET_STATISTICS_RSP */
1899 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1900
1901 mmhMsg.bodyptr = stats;
1902 mmhMsg.bodyval = 0;
1903 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1904 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1905
1906 return;
1907
1908} /*** end lim_send_sme_pe_statistics_rsp() ***/
1909
1910#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1911/**
1912 * lim_send_sme_pe_ese_tsm_rsp()
1913 *
1914 ***FUNCTION:
1915 * This function is called to send tsm stats response to HDD.
1916 * This function posts the result back to HDD. This is a response to
1917 * HDD's request to get tsm stats.
1918 *
1919 ***PARAMS:
1920 * @param pMac - Pointer to global pMac structure
1921 * @param pStats - Pointer to TSM Stats
1922 *
1923 * @return none
1924 */
1925
1926void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac, tAniGetTsmStatsRsp *pStats)
1927{
1928 tSirMsgQ mmhMsg;
1929 uint8_t sessionId;
1930 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1931 tpPESession pPeSessionEntry = NULL;
1932
1933 /* Get the Session Id based on Sta Id */
1934 pPeSessionEntry =
1935 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1936
1937 /* Fill the Session Id */
1938 if (NULL != pPeSessionEntry) {
1939 /* Fill the Session Id */
1940 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1941 } else {
1942 PELOGE(lim_log
1943 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1944 pPeStats->staId);
1945 )
1946 return;
1947 }
1948
1949 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1950 pPeStats->tsmMetrics.RoamingCount
1951 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1952 pPeStats->tsmMetrics.RoamingDly
1953 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1954
1955 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1956 mmhMsg.bodyptr = pStats;
1957 mmhMsg.bodyval = 0;
1958 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
1959 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1960
1961 return;
1962} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1963
1964#endif /* FEATURE_WLAN_ESE) && FEATURE_WLAN_ESE_UPLOAD */
1965
1966void
1967lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1968 tSirMacAddr peerMacAddr,
1969 uint16_t staIndex,
1970 uint8_t ucastIdx,
1971 uint8_t bcastIdx,
1972 uint8_t *beacon,
1973 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1974{
1975 tSirMsgQ mmhMsg;
1976 tSmeIbssPeerInd *pNewPeerInd;
1977
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301978 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 if (NULL == pNewPeerInd) {
1980 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
1981 return;
1982 }
1983
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301984 qdf_mem_set((void *)pNewPeerInd, (sizeof(tSmeIbssPeerInd) + beaconLen),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 0);
1986
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301987 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301988 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 pNewPeerInd->staId = staIndex;
1990 pNewPeerInd->ucastSig = ucastIdx;
1991 pNewPeerInd->bcastSig = bcastIdx;
1992 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1993 pNewPeerInd->mesgType = msgType;
1994 pNewPeerInd->sessionId = sessionId;
1995
1996 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301997 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1999 beaconLen);
2000 }
2001
2002 mmhMsg.type = msgType;
2003 mmhMsg.bodyptr = pNewPeerInd;
2004 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
2005 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2006
2007}
2008
2009/**
2010 * lim_handle_csa_offload_msg() - Handle CSA offload message
2011 * @mac_ctx: pointer to global adapter context
2012 * @msg: Message pointer.
2013 *
2014 * Return: None
2015 */
2016void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
2017{
2018 tpPESession session_entry;
2019 tSirMsgQ mmh_msg;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302020 struct csa_offload_params *csa_params =
2021 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 tpSmeCsaOffloadInd csa_offload_ind;
2023 tpDphHashNode sta_ds = NULL;
2024 uint8_t session_id;
2025 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302026 uint16_t chan_space = 0;
Amar Singhale4f28ee2015-10-21 14:36:56 -07002027 struct ch_params_s ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302028
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002030 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302032 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 if (!csa_params) {
2035 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2036 return;
2037 }
2038
2039 session_entry =
2040 pe_find_session_by_bssid(mac_ctx,
2041 csa_params->bssId, &session_id);
2042 if (!session_entry) {
2043 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302044 FL("Session does not exists for %pM"),
2045 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 goto err;
2047 }
2048
2049 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2050 &session_entry->dph.dphHashTable);
2051
2052 if (!sta_ds) {
2053 lim_log(mac_ctx, LOGE,
2054 FL("sta_ds does not exist"));
2055 goto err;
2056 }
2057
2058 if (LIM_IS_STA_ROLE(session_entry)) {
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302059 /*
2060 * on receiving channel switch announcement from AP, delete all
2061 * TDLS peers before leaving BSS and proceed for channel switch
2062 */
2063 lim_delete_tdls_peers(mac_ctx, session_entry);
2064
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002065 lim_ch_switch = &session_entry->gLimChannelSwitch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 session_entry->gLimChannelSwitch.switchMode =
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302067 csa_params->switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068 /* timer already started by firmware, switch immediately */
2069 session_entry->gLimChannelSwitch.switchCount = 0;
2070 session_entry->gLimChannelSwitch.primaryChannel =
2071 csa_params->channel;
2072 session_entry->gLimChannelSwitch.state =
2073 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2074 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002075 lim_ch_switch->sec_ch_offset =
2076 session_entry->htSecondaryChannelOffset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302077 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2078 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2079 chnl_switch_info =
2080 &session_entry->gLimWiderBWChannelSwitch;
2081
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302082 lim_log(mac_ctx, LOG1,
2083 FL("vht:%d ht:%d flag:%x chan:%d seg1:%d seg2:%d width:%d country:%s class:%d"),
2084 session_entry->vhtCapability,
2085 session_entry->htSupportedChannelWidthSet,
2086 csa_params->ies_present_flag,
2087 csa_params->channel, csa_params->new_ch_freq_seg1,
2088 csa_params->new_ch_freq_seg2,
2089 csa_params->new_ch_width,
2090 mac_ctx->scan.countryCodeCurrent,
2091 csa_params->new_op_class);
2092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 if (session_entry->vhtCapability &&
2094 session_entry->htSupportedChannelWidthSet) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
2096 chnl_switch_info->newChanWidth =
2097 csa_params->new_ch_width;
2098 chnl_switch_info->newCenterChanFreq0 =
2099 csa_params->new_ch_freq_seg1;
2100 chnl_switch_info->newCenterChanFreq1 =
2101 csa_params->new_ch_freq_seg2;
2102 session_entry->gLimChannelSwitch.state =
2103 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2104 session_entry->gLimChannelSwitch.ch_width =
2105 csa_params->new_ch_width + 1;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302106 } else if (csa_params->ies_present_flag
2107 & lim_xcsa_ie_present) {
2108 chan_space =
2109 cds_regdm_get_chanwidth_from_opclass(
2110 mac_ctx->scan.countryCodeCurrent,
2111 csa_params->channel,
2112 csa_params->new_op_class);
2113 session_entry->gLimChannelSwitch.state =
2114 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2115
2116 if (chan_space == 80) {
2117 chnl_switch_info->newChanWidth =
2118 CH_WIDTH_80MHZ;
2119 } else if (chan_space == 40) {
2120 chnl_switch_info->newChanWidth =
2121 CH_WIDTH_40MHZ;
2122 } else {
2123 chnl_switch_info->newChanWidth =
2124 CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002125 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302126 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2127 }
2128
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002129 ch_params.ch_width =
2130 chnl_switch_info->newChanWidth;
2131 cds_set_ch_params(csa_params->channel,
2132 eCSR_DOT11_MODE_11ac,
2133 &ch_params);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302134 chnl_switch_info->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002135 ch_params.center_freq_seg0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302136 /*
2137 * This is not applicable for 20/40/80 MHz.
2138 * Only used when we support 80+80 MHz operation.
2139 * In case of 80+80 MHz, this parameter indicates
2140 * center channel frequency index of 80 MHz
2141 * channel offrequency segment 1.
2142 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002143 chnl_switch_info->newCenterChanFreq1 =
2144 ch_params.center_freq_seg1;
2145 lim_ch_switch->sec_ch_offset =
2146 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302147
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 }
Gupta, Kapil121bf212015-11-25 19:21:29 +05302149 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2150 chnl_switch_info->newCenterChanFreq0;
2151 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2152 chnl_switch_info->newCenterChanFreq1;
2153 session_entry->gLimChannelSwitch.ch_width =
2154 chnl_switch_info->newChanWidth;
2155
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156 } else if (session_entry->htSupportedChannelWidthSet) {
Gupta, Kapil121bf212015-11-25 19:21:29 +05302157 if (csa_params->ies_present_flag
2158 & lim_xcsa_ie_present) {
2159 chan_space =
2160 cds_regdm_get_chanwidth_from_opclass(
2161 mac_ctx->scan.countryCodeCurrent,
2162 csa_params->channel,
2163 csa_params->new_op_class);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002164 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302165 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2166 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002167 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302168 CH_WIDTH_40MHZ;
2169 chnl_switch_info->newChanWidth =
2170 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002171 ch_params.ch_width =
2172 chnl_switch_info->newChanWidth;
2173 cds_set_ch_params(csa_params->channel,
2174 eCSR_DOT11_MODE_11n,
2175 &ch_params);
2176 lim_ch_switch->ch_center_freq_seg0 =
2177 ch_params.center_freq_seg0;
2178 lim_ch_switch->sec_ch_offset =
2179 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302180 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002181 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302182 CH_WIDTH_20MHZ;
2183 chnl_switch_info->newChanWidth =
2184 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002185 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302186 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002187 lim_ch_switch->sec_ch_offset =
2188 PHY_SINGLE_CHANNEL_CENTERED;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302189 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002191 lim_ch_switch->ch_width =
2192 CH_WIDTH_40MHZ;
2193 lim_ch_switch->state =
2194 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2195 ch_params.ch_width = CH_WIDTH_40MHZ;
2196 cds_set_ch_params(csa_params->channel,
2197 eCSR_DOT11_MODE_11n,
2198 &ch_params);
2199 lim_ch_switch->ch_center_freq_seg0 =
2200 ch_params.center_freq_seg0;
2201 lim_ch_switch->sec_ch_offset =
2202 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 }
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 }
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302206 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
2207 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208
2209 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 if (NULL == csa_offload_ind) {
2212 lim_log(mac_ctx, LOGE,
2213 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
2214 goto err;
2215 }
2216
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302217 qdf_mem_set(csa_offload_ind, sizeof(tSmeCsaOffloadInd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2219 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302220 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302221 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2223 mmh_msg.bodyptr = csa_offload_ind;
2224 mmh_msg.bodyval = 0;
2225 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002226 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 MTRACE(mac_trace_msg_tx
2228 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2229#ifdef FEATURE_WLAN_DIAG_SUPPORT
2230 lim_diag_event_report(mac_ctx,
2231 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2232 eSIR_SUCCESS, eSIR_SUCCESS);
2233#endif
2234 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
2235 }
2236
2237err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302238 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239}
2240
2241/*--------------------------------------------------------------------------
2242 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2243
2244 \param pMac - pointer to global adapter context
2245 \param sessionId - Message pointer.
2246
2247 \sa
2248 --------------------------------------------------------------------------*/
2249
2250void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ MsgQ)
2251{
2252 tpPESession psessionEntry;
2253 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2254
2255 psessionEntry =
2256 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2257 if (psessionEntry == NULL) {
2258 lim_log(pMac, LOGE,
2259 FL("Session Does not exist for given sessionID %d"),
2260 pDelBss->sessionId);
2261 return;
2262 }
2263 if (LIM_IS_IBSS_ROLE(psessionEntry)) {
2264 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
2265 } else if (LIM_IS_UNKNOWN_ROLE(psessionEntry)) {
2266 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
2267 }
2268
2269 else
2270 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2271
2272}
2273
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274/** -----------------------------------------------------------------
2275 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2276 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2277 \ SME only looks at rc and tspec field.
2278 \param pMac - global mac structure
2279 \param rspReqd - is SmeAddTsRsp required
2280 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2281 \return tspec
2282 \sa
2283 ----------------------------------------------------------------- */
2284void
2285lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2286 uint8_t smesessionId)
2287{
2288 tSirMsgQ mmhMsg;
2289
2290 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2291 mmhMsg.bodyptr = aggrQosRsp;
2292 mmhMsg.bodyval = 0;
2293 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2294 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2295
2296 return;
2297}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298
2299void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2300 uint8_t smesessionId)
2301{
2302 tSirMsgQ mmhMsg;
2303 tSmeMaxAssocInd *pSmeMaxAssocInd;
2304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302305 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 if (NULL == pSmeMaxAssocInd) {
2307 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2308 return;
2309 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302310 qdf_mem_set((void *)pSmeMaxAssocInd, sizeof(tSmeMaxAssocInd), 0);
2311 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302312 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2314 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2315 pSmeMaxAssocInd->sessionId = smesessionId;
2316 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2317 mmhMsg.bodyptr = pSmeMaxAssocInd;
2318 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2319 " sme session id %d"),
2320 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2321 MAC_ADDR_ARRAY(peerMacAddr));
2322 )
2323 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2324 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2325
2326 return;
2327}
2328
2329/** -----------------------------------------------------------------
2330 \brief lim_send_sme_dfs_event_notify() - sends
2331 eWNI_SME_DFS_RADAR_FOUND
2332 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2333 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2334 that a RADAR is found on current operating channel and SAP-
2335 has to move to a new channel.
2336 \param pMac - global mac structure
2337 \param msgType - message type received from lower layer
2338 \param event - event data received from lower layer
2339 \return none
2340 \sa
2341 ----------------------------------------------------------------- */
2342void
2343lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2344{
2345 tSirMsgQ mmhMsg;
2346 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2347 mmhMsg.bodyptr = event;
2348 mmhMsg.bodyval = 0;
2349 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2350 return;
2351}
2352
2353/*--------------------------------------------------------------------------
2354 \brief lim_send_dfs_chan_sw_ie_update()
2355 This timer handler updates the channel switch IE in beacon template
2356
2357 \param pMac - pointer to global adapter context
2358 \return - channel to scan from valid session else zero.
2359 \sa
2360 --------------------------------------------------------------------------*/
2361static void
2362lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2363{
2364
2365 /* Update the beacon template and send to FW */
2366 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2367 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2368 return;
2369 }
2370
2371 /* Send update beacon template message */
2372 lim_send_beacon_ind(pMac, psessionEntry);
2373 PELOG1(lim_log(pMac, LOG1,
2374 FL(" Updated CSA IE, IE COUNT = %d"),
2375 psessionEntry->gLimChannelSwitch.switchCount);
2376 )
2377
2378 return;
2379}
2380
2381/** -----------------------------------------------------------------
2382 \brief lim_send_sme_ap_channel_switch_resp() - sends
2383 eWNI_SME_CHANNEL_CHANGE_RSP
2384 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2385 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2386 that the Channel change has been done to the specified target
2387 channel in the Channel change request
2388 \param pMac - global mac structure
2389 \param psessionEntry - session info
2390 \param pChnlParams - Channel switch params
2391 --------------------------------------------------------------------*/
2392void
2393lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2394 tpPESession psessionEntry,
2395 tpSwitchChannelParams pChnlParams)
2396{
2397 tSirMsgQ mmhMsg;
2398 tpSwitchChannelParams pSmeSwithChnlParams;
2399 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002400 bool is_ch_dfs = false;
2401 enum ch_width ch_width;
2402 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403
2404 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302405 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 if (NULL == pSmeSwithChnlParams) {
2407 lim_log(pMac, LOGP,
2408 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2409 return;
2410 }
2411
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302412 qdf_mem_set((void *)pSmeSwithChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413 sizeof(tSwitchChannelParams), 0);
2414
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302415 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 sizeof(tSwitchChannelParams));
2417
2418 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002419 ch_width = pSmeSwithChnlParams->ch_width;
2420 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421
2422 /*
2423 * Pass the sme sessionID to SME instead
2424 * PE session ID.
2425 */
2426 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2427
2428 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2429 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2430 mmhMsg.bodyval = 0;
2431 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2432
2433 /*
2434 * We should start beacon transmission only if the new
2435 * channel after channel change is Non-DFS. For a DFS
2436 * channel, PE will receive an explicit request from
2437 * upper layers to start the beacon transmission .
2438 */
2439
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002440 if (ch_width == CH_WIDTH_160MHZ) {
2441 is_ch_dfs = true;
2442 } else if (ch_width == CH_WIDTH_80P80MHZ) {
2443 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
2444 cds_get_channel_state(ch_center_freq_seg1 -
2445 SIR_80MHZ_START_CENTER_CH_DIFF) ==
2446 CHANNEL_STATE_DFS)
2447 is_ch_dfs = true;
2448 } else {
2449 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
2450 is_ch_dfs = true;
2451 }
2452
2453 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 if (channelId == psessionEntry->currentOperChannel) {
2455 lim_apply_configuration(pMac, psessionEntry);
2456 lim_send_beacon_ind(pMac, psessionEntry);
2457 } else {
2458 PELOG1(lim_log(pMac, LOG1,
2459 FL
2460 ("Failed to Transmit Beacons on channel = %d"
2461 "after AP channel change response"),
2462 psessionEntry->bcnLen);
2463 )
2464 }
2465 }
2466 return;
2467}
2468
2469/** -----------------------------------------------------------------
2470 \brief lim_process_beacon_tx_success_ind() - This function is used
2471 explicitely to handle successful beacon transmission indication
2472 from the FW. This is a generic event generated by the FW afer the
2473 first beacon is sent out after the beacon template update by the
2474 host
2475 \param pMac - global mac structure
2476 \param psessionEntry - session info
2477 \return none
2478 \sa
2479 ----------------------------------------------------------------- */
2480void
2481lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2482{
2483 /* Currently, this event is used only for DFS channel switch announcement
2484 * IE update in the template. If required to be used for other IE updates
2485 * add appropriate code by introducing a state variable
2486 */
2487 tpPESession psessionEntry;
2488 tSirMsgQ mmhMsg;
2489 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2490 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2491 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2492 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2493 (tSirFirstBeaconTxCompleteInd *) event;
2494
2495 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2496 if (psessionEntry == NULL) {
2497 lim_log(pMac, LOGE,
2498 FL("Session Does not exist for given sessionID"));
2499 return;
2500 }
2501
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302502 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2503 GET_LIM_SYSTEM_ROLE(psessionEntry),
2504 psessionEntry->dfsIncludeChanSwIe,
2505 psessionEntry->gLimOperatingMode.present);
2506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507 if (LIM_IS_AP_ROLE(psessionEntry) &&
2508 true == psessionEntry->dfsIncludeChanSwIe) {
2509 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2510 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2511 /*
2512 * Send the next beacon with updated CSA IE count
2513 */
2514 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2515 /* Decrement the IE count */
2516 psessionEntry->gLimChannelSwitch.switchCount--;
2517 } else {
2518 /* Done with CSA IE update, send response back to SME */
2519 psessionEntry->gLimChannelSwitch.switchCount = 0;
2520 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2521 psessionEntry->gLimChannelSwitch.switchMode = 0;
2522 psessionEntry->dfsIncludeChanSwIe = false;
2523 psessionEntry->dfsIncludeChanWrapperIe = false;
2524
2525 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302526 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002527
2528 if (NULL == pChanSwTxResponse) {
2529 lim_log(pMac, LOGP,
2530 FL
2531 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2532 return;
2533 }
2534
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302535 qdf_mem_set((void *)pChanSwTxResponse, length, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 pChanSwTxResponse->sessionId =
2537 psessionEntry->smeSessionId;
2538 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302539 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540
2541 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2542 mmhMsg.bodyptr = pChanSwTxResponse;
2543 mmhMsg.bodyval = 0;
2544 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2545 }
2546 }
2547
2548 if (LIM_IS_AP_ROLE(psessionEntry) &&
2549 psessionEntry->gLimOperatingMode.present) {
2550 /* Done with nss update, send response back to SME */
2551 psessionEntry->gLimOperatingMode.present = 0;
2552 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302553 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 if (NULL == beacon_tx_comp_rsp_ptr) {
2555 lim_log(pMac, LOGP,
2556 FL
2557 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2558 return;
2559 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302560 qdf_mem_set((void *)beacon_tx_comp_rsp_ptr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561 sizeof(*beacon_tx_comp_rsp_ptr), 0);
2562 beacon_tx_comp_rsp_ptr->session_id =
2563 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302564 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2566 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2567 mmhMsg.bodyval = 0;
2568 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2569 }
2570 return;
2571}