blob: 411e407c85d15872ef7677e1fd76689f35419a4d [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_send_sme_rspMessages.cc contains the functions
30 * for sending SME response/notification messages to applications
31 * above MAC software.
32 * Author: Chandra Modumudi
33 * Date: 02/13/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38
Anurag Chouhan6d760662016-02-20 16:05:43 +053039#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include "wni_api.h"
41#include "sir_common.h"
42#include "ani_global.h"
43
44#include "wni_cfg.h"
45#include "sys_def.h"
46#include "cfg_api.h"
47
48#include "sch_api.h"
49#include "utils_api.h"
50#include "lim_utils.h"
51#include "lim_security_utils.h"
52#include "lim_ser_des_utils.h"
53#include "lim_send_sme_rsp_messages.h"
54#include "lim_ibss_peer_mgmt.h"
55#include "lim_session_utils.h"
56#include "lim_types.h"
57#include "sir_api.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053058#include "cds_regdomain_common.h"
59#include "lim_send_messages.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
62 tpPESession session_entry, tSirResultCodes result_code,
63 tpSirSmeJoinRsp sme_join_rsp);
64
65/**
66 * lim_send_sme_rsp() - Send Response to upper layers
67 * @mac_ctx: Pointer to Global MAC structure
68 * @msg_type: Indicates message type
69 * @result_code: Indicates the result of previously issued
70 * eWNI_SME_msg_type_REQ message
71 *
72 * This function is called by lim_process_sme_req_messages() to send
73 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
74 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
75 * Software.
76 *
77 * Return: None
78 */
79
80void
81lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
82 tSirResultCodes result_code, uint8_t sme_session_id,
83 uint16_t sme_transaction_id)
84{
85 tSirMsgQ msg;
86 tSirSmeRsp *sme_rsp;
87
88 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
89 lim_msg_str(msg_type), lim_result_code_str(result_code));
90
Anurag Chouhan600c3a02016-03-01 10:33:54 +053091 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092 if (NULL == sme_rsp) {
93 /* Buffer not available. Log error */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053094 QDF_TRACE(QDF_MODULE_ID_PE, LOGP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
96 return;
97 }
98
99 sme_rsp->messageType = msg_type;
100 sme_rsp->length = sizeof(tSirSmeRsp);
101 sme_rsp->statusCode = result_code;
102
103 sme_rsp->sessionId = sme_session_id;
104 sme_rsp->transactionId = sme_transaction_id;
105
106 msg.type = msg_type;
107 msg.bodyptr = sme_rsp;
108 msg.bodyval = 0;
109 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
110
111#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
112 switch (msg_type) {
113 case eWNI_SME_STOP_BSS_RSP:
114 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
115 NULL, (uint16_t) result_code, 0);
116 break;
117 }
118#endif /* FEATURE_WLAN_DIAG_SUPPORT */
119 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
120}
121
122
123
124/**
125 * lim_send_sme_roc_rsp() - Send Response to SME
126 * @mac_ctx: Pointer to Global MAC structure
127 * @status: Resume link status
128 * @result_code: Result of the ROC request
129 * @sme_session_id: SME sesson Id
130 * @scan_id: Scan Identifier
131 *
132 * This function is called to send ROC rsp
133 * message to SME.
134 *
135 * Return: None
136 */
137void
138lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
139 tSirResultCodes result_code, uint8_t sme_session_id,
140 uint32_t scan_id)
141{
142 tSirMsgQ msg;
143 struct sir_roc_rsp *sme_rsp;
144
145 lim_log(mac_ctx, LOG1,
146 FL("Sending message %s with reasonCode %s scanId %d"),
147 lim_msg_str(msg_type), lim_result_code_str(result_code),
148 scan_id);
149
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530150 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 if (NULL == sme_rsp) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530152 QDF_TRACE(QDF_MODULE_ID_PE, LOGP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
154 return;
155 }
156
157 sme_rsp->message_type = msg_type;
158 sme_rsp->length = sizeof(struct sir_roc_rsp);
159 sme_rsp->status = result_code;
160
161 sme_rsp->session_id = sme_session_id;
162 sme_rsp->scan_id = scan_id;
163
164 msg.type = msg_type;
165 msg.bodyptr = sme_rsp;
166 msg.bodyval = 0;
167 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
168 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
169}
170
171
172/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530173 * lim_get_max_rate_flags() - Get rate flags
174 * @mac_ctx: Pointer to global MAC structure
175 * @sta_ds: Pointer to station ds structure
176 *
177 * This function is called to get the rate flags for a connection
178 * from the station ds structure depending on the ht and the vht
179 * channel width supported.
180 *
181 * Return: Returns the populated rate_flags
182 */
183uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
184{
185 uint32_t rate_flags = 0;
186
187 if (sta_ds == NULL) {
188 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
189 return rate_flags;
190 }
191
192 if (!sta_ds->mlmStaContext.htCapability &&
193 !sta_ds->mlmStaContext.vhtCapability) {
194 rate_flags |= eHAL_TX_RATE_LEGACY;
195 } else {
196 if (sta_ds->mlmStaContext.vhtCapability) {
197 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
198 sta_ds->vhtSupportedChannelWidthSet) {
199 rate_flags |= eHAL_TX_RATE_VHT80;
200 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
201 sta_ds->vhtSupportedChannelWidthSet) {
202 if (sta_ds->htSupportedChannelWidthSet)
203 rate_flags |= eHAL_TX_RATE_VHT40;
204 else
205 rate_flags |= eHAL_TX_RATE_VHT20;
206 }
207 } else if (sta_ds->mlmStaContext.htCapability) {
208 if (sta_ds->htSupportedChannelWidthSet)
209 rate_flags |= eHAL_TX_RATE_HT40;
210 else
211 rate_flags |= eHAL_TX_RATE_HT20;
212 }
213 }
214
215 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
216 rate_flags |= eHAL_TX_RATE_SGI;
217
218 return rate_flags;
219}
220
221/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
223 * @mac_ctx Pointer to Global MAC structure
224 * @status Resume link status
225 * @ctx context passed while calling resmune link.
226 * (join response to be sent)
227 *
228 * This function is called to send Join/Reassoc rsp
229 * message to SME after the resume link.
230 *
231 * Return: None
232 */
233static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530234 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235{
236 tSirMsgQ msg;
237 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
238
239 msg.type = sme_join_rsp->messageType;
240 msg.bodyptr = sme_join_rsp;
241 msg.bodyval = 0;
242 MTRACE(mac_trace_msg_tx(mac_ctx, NO_SESSION, msg.type));
243 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
244}
245
246/**
247 * lim_handle_join_rsp_status() - Handle the response.
248 * @mac_ctx: Pointer to Global MAC structure
249 * @session_entry: PE Session Info
250 * @result_code: Indicates the result of previously issued
251 * eWNI_SME_msgType_REQ message
252 * @sme_join_rsp The received response.
253 *
254 * This function will handle both the success and failure status
255 * of the received response.
256 *
257 * Return: None
258 */
259static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
260 tpPESession session_entry, tSirResultCodes result_code,
261 tpSirSmeJoinRsp sme_join_rsp)
262{
263#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
264 tSirSmeHTProfile *ht_profile;
265#endif
266 if (result_code == eSIR_SME_SUCCESS) {
267 if (session_entry->beacon != NULL) {
268 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530269 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270 session_entry->beacon,
271 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530272 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530274 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 lim_log(mac_ctx, LOG1, FL("Beacon=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530276 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 }
278 if (session_entry->assocReq != NULL) {
279 sme_join_rsp->assocReqLength =
280 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530281 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530282 sme_join_rsp->beaconLength,
283 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530285 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530287 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 lim_log(mac_ctx,
289 LOG1, FL("AssocReq=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530290 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 }
292 if (session_entry->assocRsp != NULL) {
293 sme_join_rsp->assocRspLength =
294 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530295 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530296 sme_join_rsp->beaconLength +
297 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 session_entry->assocRsp,
299 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530300 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530302 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 if (session_entry->ricData != NULL) {
305 sme_join_rsp->parsedRicRspLen =
306 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530307 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530308 sme_join_rsp->beaconLength +
309 sme_join_rsp->assocReqLength +
310 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 session_entry->ricData,
312 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530313 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530315 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316 lim_log(mac_ctx, LOG1, FL("RicLength=%d"),
317 sme_join_rsp->parsedRicRspLen);
318 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319#ifdef FEATURE_WLAN_ESE
320 if (session_entry->tspecIes != NULL) {
321 sme_join_rsp->tspecIeLen =
322 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530323 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530324 sme_join_rsp->beaconLength +
325 sme_join_rsp->assocReqLength +
326 sme_join_rsp->assocRspLength +
327 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328 session_entry->tspecIes,
329 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530330 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530332 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 lim_log(mac_ctx, LOG1, FL("ESE-TspecLen=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530334 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 }
336#endif
337 sme_join_rsp->aid = session_entry->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 lim_log(mac_ctx, LOG1, FL("AssocRsp=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530339 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 sme_join_rsp->vht_channel_width =
341 session_entry->ch_width;
342#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
343 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530344 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 ht_profile = &sme_join_rsp->HTProfile;
346 ht_profile->htSupportedChannelWidthSet =
347 session_entry->htSupportedChannelWidthSet;
348 ht_profile->htRecommendedTxWidthSet =
349 session_entry->htRecommendedTxWidthSet;
350 ht_profile->htSecondaryChannelOffset =
351 session_entry->htSecondaryChannelOffset;
352 ht_profile->dot11mode = session_entry->dot11mode;
353 ht_profile->htCapability = session_entry->htCapability;
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);
496 }
497
498 sme_join_rsp->messageType = msg_type;
499 sme_join_rsp->length = (uint16_t) rsp_len;
500 sme_join_rsp->statusCode = result_code;
501 sme_join_rsp->protStatusCode = prot_status_code;
502
503 sme_join_rsp->sessionId = sme_session_id;
504 sme_join_rsp->transactionId = sme_transaction_id;
505
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530506 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 (uint32_t *)sme_join_rsp);
508}
509
510/**
511 * lim_send_sme_start_bss_rsp()
512 *
513 ***FUNCTION:
514 * This function is called to send eWNI_SME_START_BSS_RSP
515 * message to applications above MAC Software.
516 *
517 ***PARAMS:
518 *
519 ***LOGIC:
520 *
521 ***ASSUMPTIONS:
522 * NA
523 *
524 ***NOTE:
525 * NA
526 *
527 * @param pMac Pointer to Global MAC structure
528 * @param msgType Indicates message type
529 * @param resultCode Indicates the result of previously issued
530 * eWNI_SME_msgType_REQ message
531 *
532 * @return None
533 */
534
535void
536lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
537 uint16_t msgType, tSirResultCodes resultCode,
538 tpPESession psessionEntry, uint8_t smesessionId,
539 uint16_t smetransactionId)
540{
541
542 uint16_t size = 0;
543 tSirMsgQ mmhMsg;
544 tSirSmeStartBssRsp *pSirSmeRsp;
545 uint16_t ieLen;
546 uint16_t ieOffset, curLen;
547
548 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
549 lim_msg_str(msgType), lim_result_code_str(resultCode));
550 )
551
552 size = sizeof(tSirSmeStartBssRsp);
553
554 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530555 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 if (NULL == pSirSmeRsp) {
557 /* / Buffer not available. Log error */
558 lim_log(pMac, LOGP,
559 FL
560 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
561 return;
562 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530563 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564
565 } else {
566 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
567 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
568 ieLen = psessionEntry->schBeaconOffsetBegin
569 + psessionEntry->schBeaconOffsetEnd - ieOffset;
570 /* calculate the memory size to allocate */
571 size += ieLen;
572
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530573 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 if (NULL == pSirSmeRsp) {
575 /* / Buffer not available. Log error */
576 lim_log(pMac, LOGP,
577 FL
578 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
579
580 return;
581 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530582 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 size = sizeof(tSirSmeStartBssRsp);
584 if (resultCode == eSIR_SME_SUCCESS) {
585
586 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
587 psessionEntry->bssId);
588
589 /* Read beacon interval from session */
590 pSirSmeRsp->bssDescription.beaconInterval =
591 (uint16_t) psessionEntry->beaconParams.
592 beaconInterval;
593 pSirSmeRsp->bssType = psessionEntry->bssType;
594
595 if (cfg_get_capability_info
596 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
597 psessionEntry)
598 != eSIR_SUCCESS)
599 lim_log(pMac, LOGP,
600 FL
601 ("could not retrieve Capabilities value"));
602
603 lim_get_phy_mode(pMac,
604 (uint32_t *) &pSirSmeRsp->bssDescription.
605 nwType, psessionEntry);
606
607 pSirSmeRsp->bssDescription.channelId =
608 psessionEntry->currentOperChannel;
609
610 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530611 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 ieFields,
613 psessionEntry->pSchBeaconFrameBegin +
614 ieOffset, (uint32_t) curLen);
615
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530616 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 ieFields) + curLen,
618 psessionEntry->pSchBeaconFrameEnd,
619 (uint32_t) psessionEntry->
620 schBeaconOffsetEnd);
621
622 /* subtracting size of length indicator itself and size of pointer to ieFields */
623 pSirSmeRsp->bssDescription.length =
624 sizeof(tSirBssDescription) - sizeof(uint16_t) -
625 sizeof(uint32_t) + ieLen;
626 /* This is the size of the message, subtracting the size of the pointer to ieFields */
627 size += ieLen - sizeof(uint32_t);
628#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
629 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530630 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 pSirSmeRsp->HTProfile.
632 htSupportedChannelWidthSet =
633 psessionEntry->htSupportedChannelWidthSet;
634 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
635 psessionEntry->htRecommendedTxWidthSet;
636 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
637 psessionEntry->htSecondaryChannelOffset;
638 pSirSmeRsp->HTProfile.dot11mode =
639 psessionEntry->dot11mode;
640 pSirSmeRsp->HTProfile.htCapability =
641 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 pSirSmeRsp->HTProfile.vhtCapability =
643 psessionEntry->vhtCapability;
644 pSirSmeRsp->HTProfile.vhtTxChannelWidthSet =
645 psessionEntry->vhtTxChannelWidthSet;
646 pSirSmeRsp->HTProfile.apCenterChan =
647 psessionEntry->ch_center_freq_seg0;
648 pSirSmeRsp->HTProfile.apChanWidth =
649 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 }
651#endif
652 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 pSirSmeRsp->messageType = msgType;
655 pSirSmeRsp->length = size;
656
657 /* Update SME session Id and transaction Id */
658 pSirSmeRsp->sessionId = smesessionId;
659 pSirSmeRsp->transactionId = smetransactionId;
660 pSirSmeRsp->statusCode = resultCode;
661 if (psessionEntry != NULL)
662 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
663
664 mmhMsg.type = msgType;
665 mmhMsg.bodyptr = pSirSmeRsp;
666 mmhMsg.bodyval = 0;
667 if (psessionEntry == NULL) {
668 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
669 } else {
670 MTRACE(mac_trace_msg_tx
671 (pMac, psessionEntry->peSessionId, mmhMsg.type));
672 }
673#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
674 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
675 psessionEntry, (uint16_t) resultCode, 0);
676#endif /* FEATURE_WLAN_DIAG_SUPPORT */
677
678 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
679} /*** end lim_send_sme_start_bss_rsp() ***/
680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681/**
682 * lim_send_sme_scan_rsp() - Send scan response to SME
683 * @pMac: Pointer to Global MAC structure
684 * @length: Indicates length of message
685 * @resultCode: Indicates the result of previously issued
686 * eWNI_SME_SCAN_REQ message
687 * @scan_id: scan identifier
688 *
689 * This function is called by lim_process_sme_req_messages() to send
690 * eWNI_SME_SCAN_RSP message to applications above MAC
691 *
692 * return: None
693 */
694
695void
696lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
697 uint8_t smesessionId, uint16_t smetranscationId,
698 uint32_t scan_id)
699{
700 lim_log(pMac, LOG1,
701 FL("Sending message SME_SCAN_RSP reasonCode %s scanId %d"),
702 lim_result_code_str(resultCode), scan_id);
703 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
704 smetranscationId, scan_id);
705}
706
707/**
708 * lim_post_sme_scan_rsp_message()
709 *
710 ***FUNCTION:
711 * This function is called by lim_send_sme_scan_rsp() to send
712 * eWNI_SME_SCAN_RSP message with failed result code
713 *
714 ***NOTE:
715 * NA
716 *
717 * @param pMac Pointer to Global MAC structure
718 * @param length Indicates length of message
719 * @param resultCode failed result code
720 *
721 * @return None
722 */
723
724void
725lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
726 tSirResultCodes resultCode, uint8_t smesessionId,
727 uint16_t smetransactionId,
728 uint32_t scan_id)
729{
730 tpSirSmeScanRsp pSirSmeScanRsp;
731 tSirMsgQ mmhMsg;
732
733 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
734 lim_result_code_str(resultCode));
735
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530736 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 if (NULL == pSirSmeScanRsp) {
738 lim_log(pMac, LOGP,
739 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
740 return;
741 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530742 qdf_mem_set((void *)pSirSmeScanRsp, sizeof(tSirSmeScanRsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743
744 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
745 pSirSmeScanRsp->statusCode = resultCode;
746
747 /*Update SME session Id and transaction Id */
748 pSirSmeScanRsp->sessionId = smesessionId;
749 pSirSmeScanRsp->transcationId = smetransactionId;
750 pSirSmeScanRsp->scan_id = scan_id;
751
752 mmhMsg.type = eWNI_SME_SCAN_RSP;
753 mmhMsg.bodyptr = pSirSmeScanRsp;
754 mmhMsg.bodyval = 0;
755
756 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
757#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
758 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
759 (uint16_t) resultCode, 0);
760#endif /* FEATURE_WLAN_DIAG_SUPPORT */
761
762 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
763 return;
764
765} /*** lim_post_sme_scan_rsp_message ***/
766
767#ifdef FEATURE_OEM_DATA_SUPPORT
768
769/**
770 * lim_send_sme_oem_data_rsp()
771 *
772 ***FUNCTION:
773 * This function is called by lim_process_sme_req_messages() to send
774 * eWNI_SME_OEM_DATA_RSP message to applications above MAC
775 * Software.
776 *
777 ***PARAMS:
778 *
779 ***LOGIC:
780 *
781 ***ASSUMPTIONS:
782 * NA
783 *
784 ***NOTE:
785 * NA
786 *
787 * @param pMac Pointer to Global MAC structure
788 * @param pMsgBuf Indicates the mlm message
789 * @param resultCode Indicates the result of previously issued
790 * eWNI_SME_OEM_DATA_RSP message
791 *
792 * @return None
793 */
794
795void lim_send_sme_oem_data_rsp(tpAniSirGlobal pMac, uint32_t *pMsgBuf,
796 tSirResultCodes resultCode)
797{
798 tSirMsgQ mmhMsg;
799 tSirOemDataRsp *pSirSmeOemDataRsp = NULL;
800 tLimMlmOemDataRsp *pMlmOemDataRsp = NULL;
801 uint16_t msgLength;
802
803 /* get the pointer to the mlm message */
804 pMlmOemDataRsp = (tLimMlmOemDataRsp *) (pMsgBuf);
805
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800806 msgLength = sizeof(*pSirSmeOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 /* now allocate memory for the char buffer */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800808 pSirSmeOemDataRsp = qdf_mem_malloc(sizeof(*pSirSmeOemDataRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 if (NULL == pSirSmeOemDataRsp) {
810 lim_log(pMac, LOGP,
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800811 FL("malloc failed for pSirSmeOemDataRsp"));
812 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
813 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 return;
815 }
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800816
817 if (pMlmOemDataRsp->rsp_len) {
818 pSirSmeOemDataRsp->oem_data_rsp =
819 qdf_mem_malloc(pMlmOemDataRsp->rsp_len);
820 if (!pSirSmeOemDataRsp->oem_data_rsp) {
821 lim_log(pMac, LOGE,
822 FL("malloc failed for oem_data_rsp"));
823 qdf_mem_free(pSirSmeOemDataRsp);
824 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
825 qdf_mem_free(pMlmOemDataRsp);
826 return;
827 }
828 }
829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830#if defined (ANI_LITTLE_BYTE_ENDIAN)
831 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->length, msgLength);
832 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->messageType,
833 eWNI_SME_OEM_DATA_RSP);
834#else
835 pSirSmeOemDataRsp->length = msgLength;
836 pSirSmeOemDataRsp->messageType = eWNI_SME_OEM_DATA_RSP;
837#endif
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -0800838 pSirSmeOemDataRsp->target_rsp = pMlmOemDataRsp->target_rsp;
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800839 pSirSmeOemDataRsp->rsp_len = pMlmOemDataRsp->rsp_len;
840 if (pSirSmeOemDataRsp->rsp_len)
841 qdf_mem_copy(pSirSmeOemDataRsp->oem_data_rsp,
842 pMlmOemDataRsp->oem_data_rsp,
843 pSirSmeOemDataRsp->rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844
845 /* Now free the memory from MLM Rsp Message */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800846 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530847 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
849 mmhMsg.type = eWNI_SME_OEM_DATA_RSP;
850 mmhMsg.bodyptr = pSirSmeOemDataRsp;
851 mmhMsg.bodyval = 0;
852
853 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
854
855 return;
856} /*** lim_send_sme_oem_data_rsp ***/
857
858#endif
859
860void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530861 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862{
863 tSirMsgQ mmhMsg;
864 tSirMsgQ *pMsg = (tSirMsgQ *) pCtx;
865
866 mmhMsg.type = pMsg->type;
867 mmhMsg.bodyptr = pMsg;
868 mmhMsg.bodyval = 0;
869
870 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
871
872 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
873}
874
875/**
876 * lim_send_sme_disassoc_ntf()
877 *
878 ***FUNCTION:
879 * This function is called by limProcessSmeMessages() to send
880 * eWNI_SME_DISASSOC_RSP/IND message to host
881 *
882 ***PARAMS:
883 *
884 ***LOGIC:
885 *
886 ***ASSUMPTIONS:
887 * NA
888 *
889 ***NOTE:
890 * This function is used for sending eWNI_SME_DISASSOC_CNF,
891 * or eWNI_SME_DISASSOC_IND to host depending on
892 * disassociation trigger.
893 *
894 * @param peerMacAddr Indicates the peer MAC addr to which
895 * disassociate was initiated
896 * @param reasonCode Indicates the reason for Disassociation
897 * @param disassocTrigger Indicates the trigger for Disassociation
898 * @param aid Indicates the STAID. This parameter is
899 * present only on AP.
900 *
901 * @return None
902 */
903void
904lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
905 tSirMacAddr peerMacAddr,
906 tSirResultCodes reasonCode,
907 uint16_t disassocTrigger,
908 uint16_t aid,
909 uint8_t smesessionId,
910 uint16_t smetransactionId, tpPESession psessionEntry)
911{
912
913 uint8_t *pBuf;
914 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
915 tSirSmeDisassocInd *pSirSmeDisassocInd;
916 uint32_t *pMsg;
917 bool failure = false;
918
919 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
920 disassocTrigger, reasonCode);
921
922 switch (disassocTrigger) {
923 case eLIM_PEER_ENTITY_DISASSOC:
924 if (reasonCode != eSIR_SME_STA_NOT_ASSOCIATED) {
925 failure = true;
926 goto error;
927 }
928
929 case eLIM_HOST_DISASSOC:
930 /**
931 * Disassociation response due to
932 * host triggered disassociation
933 */
934
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530935 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 if (NULL == pSirSmeDisassocRsp) {
937 /* Log error */
938 lim_log(pMac, LOGP, FL("Memory allocation failed"));
939 failure = true;
940 goto error;
941 }
942 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
943 "retCode: %d for " MAC_ADDRESS_STR),
944 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
945 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
946 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
947 /* sessionId */
948 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
949 *pBuf = smesessionId;
950 pBuf++;
951
952 /* transactionId */
953 lim_copy_u16(pBuf, smetransactionId);
954 pBuf += sizeof(uint16_t);
955
956 /* statusCode */
957 lim_copy_u32(pBuf, reasonCode);
958 pBuf += sizeof(tSirResultCodes);
959
960 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530961 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 pBuf += sizeof(tSirMacAddr);
963
964 /* Clear Station Stats */
965 /* for sta, it is always 1, IBSS is handled at halInitSta */
966
967#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
968
969 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
970 psessionEntry, (uint16_t) reasonCode, 0);
971#endif
972 pMsg = (uint32_t *) pSirSmeDisassocRsp;
973 break;
974
975 default:
976 /**
977 * Disassociation indication due to Disassociation
978 * frame reception from peer entity or due to
979 * loss of link with peer entity.
980 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530981 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 if (NULL == pSirSmeDisassocInd) {
983 /* Log error */
984 lim_log(pMac, LOGP, FL("Memory allocation failed"));
985 failure = true;
986 goto error;
987 }
988 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
989 "retCode: %d for " MAC_ADDRESS_STR),
990 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
991 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
992 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
993
994 /* Update SME session Id and Transaction Id */
995 pSirSmeDisassocInd->sessionId = smesessionId;
996 pSirSmeDisassocInd->transactionId = smetransactionId;
997 pSirSmeDisassocInd->reasonCode = reasonCode;
998 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
999
1000 lim_copy_u32(pBuf, reasonCode);
1001 pBuf += sizeof(tSirResultCodes);
1002
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301003 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 pBuf += sizeof(tSirMacAddr);
1005
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301006 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007
1008#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1009 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1010 psessionEntry, (uint16_t) reasonCode, 0);
1011#endif
1012 pMsg = (uint32_t *) pSirSmeDisassocInd;
1013
1014 break;
1015 }
1016
1017error:
1018 /* Delete the PE session Created */
1019 if ((psessionEntry != NULL) &&
1020 (LIM_IS_STA_ROLE(psessionEntry) ||
1021 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))) {
1022 pe_delete_session(pMac, psessionEntry);
1023 }
1024
1025 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301026 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 (uint32_t *) pMsg);
1028} /*** end lim_send_sme_disassoc_ntf() ***/
1029
1030/** -----------------------------------------------------------------
1031 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1032
1033 After receiving disassociation frame from peer entity, this
1034 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1035 reason code.
1036
1037 \param pMac - global mac structure
1038 \param pStaDs - station dph hash node
1039 \return none
1040 \sa
1041 ----------------------------------------------------------------- */
1042void
1043lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1044 tpPESession psessionEntry)
1045{
1046 tSirMsgQ mmhMsg;
1047 tSirSmeDisassocInd *pSirSmeDisassocInd;
1048
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301049 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 if (NULL == pSirSmeDisassocInd) {
1051 lim_log(pMac, LOGP,
1052 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1053 return;
1054 }
1055
1056 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1057 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1058
1059 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1060 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
1061 pSirSmeDisassocInd->statusCode = pStaDs->mlmStaContext.disassocReason;
1062 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1063
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301064 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301065 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301067 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301068 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069
1070 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1071
1072 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1073 mmhMsg.bodyptr = pSirSmeDisassocInd;
1074 mmhMsg.bodyval = 0;
1075
1076 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1077#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1078 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1079 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1080#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1081
1082 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1083
1084} /*** end lim_send_sme_disassoc_ind() ***/
1085
1086/** -----------------------------------------------------------------
1087 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1088
1089 After receiving deauthentication frame from peer entity, this
1090 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1091 reason code.
1092
1093 \param pMac - global mac structure
1094 \param pStaDs - station dph hash node
1095 \return none
1096 \sa
1097 ----------------------------------------------------------------- */
1098void
1099lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1100 tpPESession psessionEntry)
1101{
1102 tSirMsgQ mmhMsg;
1103 tSirSmeDeauthInd *pSirSmeDeauthInd;
1104
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301105 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 if (NULL == pSirSmeDeauthInd) {
1107 lim_log(pMac, LOGP,
1108 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1109 return;
1110 }
1111
1112 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1113 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1114
1115 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1116 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1117 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1118 pSirSmeDeauthInd->statusCode =
1119 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1120 } else {
1121 /* Need to indicatet he reascon code over the air */
1122 pSirSmeDeauthInd->statusCode =
1123 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1124 }
1125 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301126 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301127 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301129 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301130 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1132
1133 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001134 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1135 pStaDs->mlmStaContext.disassocReason)
1136 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137
1138 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1139 mmhMsg.bodyptr = pSirSmeDeauthInd;
1140 mmhMsg.bodyval = 0;
1141
1142 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1143#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1144 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1145 0, pStaDs->mlmStaContext.cleanupTrigger);
1146#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1147
1148 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1149 return;
1150} /*** end lim_send_sme_deauth_ind() ***/
1151
1152#ifdef FEATURE_WLAN_TDLS
1153/**
1154 * lim_send_sme_tdls_del_sta_ind()
1155 *
1156 ***FUNCTION:
1157 * This function is called to send the TDLS STA context deletion to SME.
1158 *
1159 ***LOGIC:
1160 *
1161 ***ASSUMPTIONS:
1162 *
1163 ***NOTE:
1164 * NA
1165 *
1166 * @param pMac - Pointer to global MAC structure
1167 * @param pStaDs - Pointer to internal STA Datastructure
1168 * @param psessionEntry - Pointer to the session entry
1169 * @param reasonCode - Reason for TDLS sta deletion
1170 * @return None
1171 */
1172void
1173lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1174 tpPESession psessionEntry, uint16_t reasonCode)
1175{
1176 tSirMsgQ mmhMsg;
1177 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1178
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301179 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 if (NULL == pSirTdlsDelStaInd) {
1181 lim_log(pMac, LOGP,
1182 FL
1183 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1184 return;
1185 }
1186 /* messageType */
1187 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1188 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1189
1190 /* sessionId */
1191 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1192
1193 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301194 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301195 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196
1197 /* staId */
1198 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1199 (uint16_t) pStaDs->staIndex);
1200
1201 /* reasonCode */
1202 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1203
1204 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1205 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1206 mmhMsg.bodyval = 0;
1207
1208 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1209 return;
1210} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1211
1212/**
1213 * lim_send_sme_tdls_delete_all_peer_ind()
1214 *
1215 ***FUNCTION:
1216 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1217 * message to SME.
1218 *
1219 ***LOGIC:
1220 *
1221 ***ASSUMPTIONS:
1222 *
1223 ***NOTE:
1224 * NA
1225 *
1226 * @param pMac - Pointer to global MAC structure
1227 * @param psessionEntry - Pointer to the session entry
1228 * @return None
1229 */
1230void
1231lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1232{
1233 tSirMsgQ mmhMsg;
1234 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1235
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301236 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 if (NULL == pSirTdlsDelAllPeerInd) {
1238 lim_log(pMac, LOGP,
1239 FL
1240 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1241 return;
1242 }
1243 /* messageType */
1244 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1245 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1246
1247 /* sessionId */
1248 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1249
1250 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1251 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1252 mmhMsg.bodyval = 0;
1253
1254 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1255 return;
1256} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1257
1258/**
1259 * lim_send_sme_mgmt_tx_completion()
1260 *
1261 ***FUNCTION:
1262 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1263 * message to SME.
1264 *
1265 ***LOGIC:
1266 *
1267 ***ASSUMPTIONS:
1268 *
1269 ***NOTE:
1270 * NA
1271 *
1272 * @param pMac - Pointer to global MAC structure
1273 * @param psessionEntry - Pointer to the session entry
1274 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1275 * @return None
1276 */
1277void
1278lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
1279 tpPESession psessionEntry, uint32_t txCompleteStatus)
1280{
1281 tSirMsgQ mmhMsg;
1282 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1283
1284 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301285 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 if (NULL == pSirMgmtTxCompletionInd) {
1287 lim_log(pMac, LOGP,
1288 FL
1289 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1290 return;
1291 }
1292 /* messageType */
1293 pSirMgmtTxCompletionInd->messageType =
1294 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1295 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1296
1297 /* sessionId */
1298 pSirMgmtTxCompletionInd->sessionId = psessionEntry->smeSessionId;
1299
1300 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1301
1302 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1303 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1304 mmhMsg.bodyval = 0;
1305
1306 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1307 return;
1308} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1309
1310void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1311 void *events)
1312{
1313 tSirMsgQ mmhMsg;
1314
1315 switch (msgType) {
1316 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1317 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1318 break;
1319 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1320 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1321 break;
1322 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1323 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1324 break;
1325 }
1326
1327 mmhMsg.bodyptr = events;
1328 mmhMsg.bodyval = 0;
1329 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1330 return;
1331}
1332#endif /* FEATURE_WLAN_TDLS */
1333
1334/**
1335 * lim_send_sme_deauth_ntf()
1336 *
1337 ***FUNCTION:
1338 * This function is called by limProcessSmeMessages() to send
1339 * eWNI_SME_DISASSOC_RSP/IND message to host
1340 *
1341 ***PARAMS:
1342 *
1343 ***LOGIC:
1344 *
1345 ***ASSUMPTIONS:
1346 * NA
1347 *
1348 ***NOTE:
1349 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1350 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1351 *
1352 * @param peerMacAddr Indicates the peer MAC addr to which
1353 * deauthentication was initiated
1354 * @param reasonCode Indicates the reason for Deauthetication
1355 * @param deauthTrigger Indicates the trigger for Deauthetication
1356 * @param aid Indicates the STAID. This parameter is present
1357 * only on AP.
1358 *
1359 * @return None
1360 */
1361void
1362lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1363 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1364 uint16_t aid, uint8_t smesessionId,
1365 uint16_t smetransactionId)
1366{
1367 uint8_t *pBuf;
1368 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1369 tSirSmeDeauthInd *pSirSmeDeauthInd;
1370 tpPESession psessionEntry;
1371 uint8_t sessionId;
1372 uint32_t *pMsg;
1373
1374 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1375 switch (deauthTrigger) {
1376 case eLIM_PEER_ENTITY_DEAUTH:
1377 return;
1378
1379 case eLIM_HOST_DEAUTH:
1380 /**
1381 * Deauthentication response to host triggered
1382 * deauthentication.
1383 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301384 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 if (NULL == pSirSmeDeauthRsp) {
1386 /* Log error */
1387 lim_log(pMac, LOGP,
1388 FL
1389 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1390
1391 return;
1392 }
1393 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1394 "retCode: %d for" MAC_ADDRESS_STR),
1395 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1396 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1397 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1398 pSirSmeDeauthRsp->statusCode = reasonCode;
1399 pSirSmeDeauthRsp->sessionId = smesessionId;
1400 pSirSmeDeauthRsp->transactionId = smetransactionId;
1401
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001402 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301403 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404
1405#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1406 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1407 psessionEntry, 0, (uint16_t) reasonCode);
1408#endif
1409 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1410
1411 break;
1412
1413 default:
1414 /**
1415 * Deauthentication indication due to Deauthentication
1416 * frame reception from peer entity or due to
1417 * loss of link with peer entity.
1418 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301419 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 if (NULL == pSirSmeDeauthInd) {
1421 /* Log error */
1422 lim_log(pMac, LOGP,
1423 FL
1424 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1425
1426 return;
1427 }
1428 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1429 "retCode: %d for " MAC_ADDRESS_STR),
1430 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1431 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1432 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1433 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1434
1435 /* sessionId */
1436 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1437 *pBuf++ = smesessionId;
1438
1439 /* transaction ID */
1440 lim_copy_u16(pBuf, smetransactionId);
1441 pBuf += sizeof(uint16_t);
1442
1443 /* status code */
1444 lim_copy_u32(pBuf, reasonCode);
1445 pBuf += sizeof(tSirResultCodes);
1446
1447 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301448 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 pBuf += sizeof(tSirMacAddr);
1450
1451 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301452 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301453 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454
1455#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1456 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1457 psessionEntry, 0, (uint16_t) reasonCode);
1458#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1459 pMsg = (uint32_t *) pSirSmeDeauthInd;
1460
1461 break;
1462 }
1463
1464 /*Delete the PE session created */
1465 if (psessionEntry != NULL) {
1466 pe_delete_session(pMac, psessionEntry);
1467 }
1468
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301469 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 (uint32_t *) pMsg);
1471
1472} /*** end lim_send_sme_deauth_ntf() ***/
1473
1474/**
1475 * lim_send_sme_wm_status_change_ntf() - Send Notification
1476 * @mac_ctx: Global MAC Context
1477 * @status_change_code: Indicates the change in the wireless medium.
1478 * @status_change_info: Indicates the information associated with
1479 * change in the wireless medium.
1480 * @info_len: Indicates the length of status change information
1481 * being sent.
1482 * @session_id SessionID
1483 *
1484 * This function is called by limProcessSmeMessages() to send
1485 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1486 *
1487 * Return: None
1488 */
1489void
1490lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1491 tSirSmeStatusChangeCode status_change_code,
1492 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1493{
1494 tSirMsgQ msg;
1495 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
1496
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301497 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 if (NULL == wm_status_change_ntf) {
1499 lim_log(mac_ctx, LOGE,
1500 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1501 return;
1502 }
1503
1504 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1505 msg.bodyval = 0;
1506 msg.bodyptr = wm_status_change_ntf;
1507
1508 switch (status_change_code) {
1509 case eSIR_SME_RADAR_DETECTED:
1510 break;
1511 default:
1512 wm_status_change_ntf->messageType =
1513 eWNI_SME_WM_STATUS_CHANGE_NTF;
1514 wm_status_change_ntf->statusChangeCode = status_change_code;
1515 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1516 wm_status_change_ntf->sessionId = session_id;
1517 if (sizeof(wm_status_change_ntf->statusChangeInfo) >=
1518 info_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301519 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1521 (uint8_t *) status_change_info, info_len);
1522 }
1523 lim_log(mac_ctx, LOGE,
1524 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1525 status_change_code, info_len);
1526 break;
1527 }
1528
1529 MTRACE(mac_trace_msg_tx(mac_ctx, session_id, msg.type));
1530 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301531 qdf_mem_free(wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 lim_log(mac_ctx, LOGP,
1533 FL("lim_sys_process_mmh_msg_api failed"));
1534 }
1535
1536} /*** end lim_send_sme_wm_status_change_ntf() ***/
1537
1538/**
1539 * lim_send_sme_set_context_rsp()
1540 *
1541 ***FUNCTION:
1542 * This function is called by limProcessSmeMessages() to send
1543 * eWNI_SME_SETCONTEXT_RSP message to host
1544 *
1545 ***PARAMS:
1546 *
1547 ***LOGIC:
1548 *
1549 ***ASSUMPTIONS:
1550 * NA
1551 *
1552 ***NOTE:
1553 *
1554 * @param pMac Pointer to Global MAC structure
1555 * @param peerMacAddr Indicates the peer MAC addr to which
1556 * setContext was performed
1557 * @param aid Indicates the aid corresponding to the peer MAC
1558 * address
1559 * @param resultCode Indicates the result of previously issued
1560 * eWNI_SME_SETCONTEXT_RSP message
1561 *
1562 * @return None
1563 */
1564void
1565lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301566 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 tSirResultCodes resultCode,
1568 tpPESession psessionEntry, uint8_t smesessionId,
1569 uint16_t smetransactionId)
1570{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 tSirMsgQ mmhMsg;
1572 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1573
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301574 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 if (NULL == pSirSmeSetContextRsp) {
1576 /* Log error */
1577 lim_log(pMac, LOGP,
1578 FL
1579 ("call to AllocateMemory failed for SmeSetContextRsp"));
1580
1581 return;
1582 }
1583
1584 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1585 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1586 pSirSmeSetContextRsp->statusCode = resultCode;
1587
Anurag Chouhanc5548422016-02-24 18:33:27 +05301588 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589
1590 /* Update SME session and transaction Id */
1591 pSirSmeSetContextRsp->sessionId = smesessionId;
1592 pSirSmeSetContextRsp->transactionId = smetransactionId;
1593
1594 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1595 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1596 mmhMsg.bodyval = 0;
1597 if (NULL == psessionEntry) {
1598 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1599 } else {
1600 MTRACE(mac_trace_msg_tx
1601 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1602 }
1603
1604#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1605 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1606 psessionEntry, (uint16_t) resultCode, 0);
1607#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1608
1609 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1610} /*** end lim_send_sme_set_context_rsp() ***/
1611
1612/**
1613 * lim_send_sme_neighbor_bss_ind()
1614 *
1615 ***FUNCTION:
1616 * This function is called by lim_lookup_nadd_hash_entry() to send
1617 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1618 *
1619 ***PARAMS:
1620 *
1621 ***LOGIC:
1622 *
1623 ***ASSUMPTIONS:
1624 * NA
1625 *
1626 ***NOTE:
1627 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1628 * host upon detecting new BSS during background scanning if CFG
1629 * option is enabled for sending such indication
1630 *
1631 * @param pMac - Pointer to Global MAC structure
1632 * @return None
1633 */
1634
1635void
1636lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1637{
1638 tSirMsgQ msgQ;
1639 uint32_t val;
1640 tSirSmeNeighborBssInd *pNewBssInd;
1641
1642 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1643 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1644 pMac->lim.gLimRspReqd)) {
1645 /* LIM is not in background scan state OR */
1646 /* current scan is initiated by HDD. */
1647 /* No need to send new BSS indication to HDD */
1648 return;
1649 }
1650
1651 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1652 eSIR_SUCCESS) {
1653 lim_log(pMac, LOGP,
1654 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1655
1656 return;
1657 }
1658
1659 if (val == 0)
1660 return;
1661
1662 /**
1663 * Need to indicate new BSSs found during
1664 * background scanning to host.
1665 * Allocate buffer for sending indication.
1666 * Length of buffer is length of BSS description
1667 * and length of header itself
1668 */
1669 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1670 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301671 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 if (NULL == pNewBssInd) {
1673 /* Log error */
1674 lim_log(pMac, LOGP,
1675 FL
1676 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1677
1678 return;
1679 }
1680
1681 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1682 pNewBssInd->length = (uint16_t) val;
1683 pNewBssInd->sessionId = 0;
1684
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301685 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 (uint8_t *) &pBssDescr->bssDescription,
1687 pBssDescr->bssDescription.length + sizeof(uint16_t));
1688
1689 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1690 msgQ.bodyptr = pNewBssInd;
1691 msgQ.bodyval = 0;
1692 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
1693 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1694} /*** end lim_send_sme_neighbor_bss_ind() ***/
1695
1696/** -----------------------------------------------------------------
1697 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1698 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1699 \ SME only looks at rc and tspec field.
1700 \param pMac - global mac structure
1701 \param rspReqd - is SmeAddTsRsp required
1702 \param status - status code of SME_ADD_TS_RSP
1703 \return tspec
1704 \sa
1705 ----------------------------------------------------------------- */
1706void
1707lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1708 tpPESession psessionEntry, tSirMacTspecIE tspec,
1709 uint8_t smesessionId, uint16_t smetransactionId)
1710{
1711 tpSirAddtsRsp rsp;
1712 tSirMsgQ mmhMsg;
1713
1714 if (!rspReqd)
1715 return;
1716
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301717 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 if (NULL == rsp) {
1719 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1720 return;
1721 }
1722
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301723 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 rsp->messageType = eWNI_SME_ADDTS_RSP;
1725 rsp->rc = status;
1726 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1727 rsp->rsp.tspec = tspec;
1728 /* Update SME session Id and transcation Id */
1729 rsp->sessionId = smesessionId;
1730 rsp->transactionId = smetransactionId;
1731
1732 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1733 mmhMsg.bodyptr = rsp;
1734 mmhMsg.bodyval = 0;
1735 if (NULL == psessionEntry) {
1736 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1737 } else {
1738 MTRACE(mac_trace_msg_tx
1739 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1740 }
1741#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1742 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1743 0);
1744#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1745
1746 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1747 return;
1748}
1749
1750void
1751lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1752 tpPESession psessionEntry, uint8_t smesessionId,
1753 uint16_t smetransactionId)
1754{
1755 tpSirDeltsRsp rsp;
1756 tSirMsgQ mmhMsg;
1757
1758 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1759 delts->aid,
1760 delts->req.tsinfo.traffic.tsid,
1761 delts->req.tsinfo.traffic.userPrio, status);
1762 if (!delts->rspReqd)
1763 return;
1764
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301765 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766 if (NULL == rsp) {
1767 /* Log error */
1768 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1769 return;
1770 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301771 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772
1773 if (psessionEntry != NULL) {
1774
1775 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301776 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301777 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 sizeof(tSirDeltsReqInfo));
1779 }
1780
1781 rsp->messageType = eWNI_SME_DELTS_RSP;
1782 rsp->rc = status;
1783
1784 /* Update SME session Id and transcation Id */
1785 rsp->sessionId = smesessionId;
1786 rsp->transactionId = smetransactionId;
1787
1788 mmhMsg.type = eWNI_SME_DELTS_RSP;
1789 mmhMsg.bodyptr = rsp;
1790 mmhMsg.bodyval = 0;
1791 if (NULL == psessionEntry) {
1792 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1793 } else {
1794 MTRACE(mac_trace_msg_tx
1795 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1796 }
1797#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1798 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1799 (uint16_t) status, 0);
1800#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1801
1802 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1803}
1804
1805void
1806lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1807 tpPESession psessionEntry)
1808{
1809 tpSirDeltsRsp rsp;
1810 tSirMsgQ mmhMsg;
1811
1812 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1813 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1814
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301815 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001816 if (NULL == rsp) {
1817 /* Log error */
1818 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1819 return;
1820 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301821 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822
1823 rsp->messageType = eWNI_SME_DELTS_IND;
1824 rsp->rc = eSIR_SUCCESS;
1825 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301826 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827
1828 /* Update SME session Id and SME transaction Id */
1829
1830 rsp->sessionId = psessionEntry->smeSessionId;
1831 rsp->transactionId = psessionEntry->transactionId;
1832
1833 mmhMsg.type = eWNI_SME_DELTS_IND;
1834 mmhMsg.bodyptr = rsp;
1835 mmhMsg.bodyval = 0;
1836 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1837#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1838 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1839 0);
1840#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1841
1842 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1843}
1844
1845/**
1846 * lim_send_sme_pe_statistics_rsp()
1847 *
1848 ***FUNCTION:
1849 * This function is called to send 802.11 statistics response to HDD.
1850 * This function posts the result back to HDD. This is a response to
1851 * HDD's request for statistics.
1852 *
1853 ***PARAMS:
1854 *
1855 ***LOGIC:
1856 *
1857 ***ASSUMPTIONS:
1858 * NA
1859 *
1860 ***NOTE:
1861 * NA
1862 *
1863 * @param pMac Pointer to Global MAC structure
1864 * @param p80211Stats Statistics sent in response
1865 * @param resultCode TODO:
1866 *
1867 *
1868 * @return none
1869 */
1870
1871void
1872lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1873{
1874 tSirMsgQ mmhMsg;
1875 uint8_t sessionId;
1876 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1877 tpPESession pPeSessionEntry;
1878
1879 /* Get the Session Id based on Sta Id */
1880 pPeSessionEntry =
1881 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1882
1883 /* Fill the Session Id */
1884 if (NULL != pPeSessionEntry) {
1885 /* Fill the Session Id */
1886 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1887 }
1888
1889 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1890
1891 /* msgType should be WMA_GET_STATISTICS_RSP */
1892 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1893
1894 mmhMsg.bodyptr = stats;
1895 mmhMsg.bodyval = 0;
1896 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1897 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1898
1899 return;
1900
1901} /*** end lim_send_sme_pe_statistics_rsp() ***/
1902
1903#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1904/**
1905 * lim_send_sme_pe_ese_tsm_rsp()
1906 *
1907 ***FUNCTION:
1908 * This function is called to send tsm stats response to HDD.
1909 * This function posts the result back to HDD. This is a response to
1910 * HDD's request to get tsm stats.
1911 *
1912 ***PARAMS:
1913 * @param pMac - Pointer to global pMac structure
1914 * @param pStats - Pointer to TSM Stats
1915 *
1916 * @return none
1917 */
1918
1919void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac, tAniGetTsmStatsRsp *pStats)
1920{
1921 tSirMsgQ mmhMsg;
1922 uint8_t sessionId;
1923 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1924 tpPESession pPeSessionEntry = NULL;
1925
1926 /* Get the Session Id based on Sta Id */
1927 pPeSessionEntry =
1928 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1929
1930 /* Fill the Session Id */
1931 if (NULL != pPeSessionEntry) {
1932 /* Fill the Session Id */
1933 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1934 } else {
1935 PELOGE(lim_log
1936 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1937 pPeStats->staId);
1938 )
1939 return;
1940 }
1941
1942 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1943 pPeStats->tsmMetrics.RoamingCount
1944 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1945 pPeStats->tsmMetrics.RoamingDly
1946 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1947
1948 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1949 mmhMsg.bodyptr = pStats;
1950 mmhMsg.bodyval = 0;
1951 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
1952 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1953
1954 return;
1955} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1956
1957#endif /* FEATURE_WLAN_ESE) && FEATURE_WLAN_ESE_UPLOAD */
1958
1959void
1960lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1961 tSirMacAddr peerMacAddr,
1962 uint16_t staIndex,
1963 uint8_t ucastIdx,
1964 uint8_t bcastIdx,
1965 uint8_t *beacon,
1966 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1967{
1968 tSirMsgQ mmhMsg;
1969 tSmeIbssPeerInd *pNewPeerInd;
1970
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301971 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 if (NULL == pNewPeerInd) {
1973 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
1974 return;
1975 }
1976
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301977 qdf_mem_set((void *)pNewPeerInd, (sizeof(tSmeIbssPeerInd) + beaconLen),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 0);
1979
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301980 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301981 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 pNewPeerInd->staId = staIndex;
1983 pNewPeerInd->ucastSig = ucastIdx;
1984 pNewPeerInd->bcastSig = bcastIdx;
1985 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1986 pNewPeerInd->mesgType = msgType;
1987 pNewPeerInd->sessionId = sessionId;
1988
1989 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301990 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1992 beaconLen);
1993 }
1994
1995 mmhMsg.type = msgType;
1996 mmhMsg.bodyptr = pNewPeerInd;
1997 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
1998 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1999
2000}
2001
2002/**
2003 * lim_handle_csa_offload_msg() - Handle CSA offload message
2004 * @mac_ctx: pointer to global adapter context
2005 * @msg: Message pointer.
2006 *
2007 * Return: None
2008 */
2009void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
2010{
2011 tpPESession session_entry;
2012 tSirMsgQ mmh_msg;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302013 struct csa_offload_params *csa_params =
2014 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 tpSmeCsaOffloadInd csa_offload_ind;
2016 tpDphHashNode sta_ds = NULL;
2017 uint8_t session_id;
2018 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302019 uint16_t chan_space = 0;
Amar Singhale4f28ee2015-10-21 14:36:56 -07002020 struct ch_params_s ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302021
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002023 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302025 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 if (!csa_params) {
2028 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2029 return;
2030 }
2031
2032 session_entry =
2033 pe_find_session_by_bssid(mac_ctx,
2034 csa_params->bssId, &session_id);
2035 if (!session_entry) {
2036 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302037 FL("Session does not exists for %pM"),
2038 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 goto err;
2040 }
2041
2042 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2043 &session_entry->dph.dphHashTable);
2044
2045 if (!sta_ds) {
2046 lim_log(mac_ctx, LOGE,
2047 FL("sta_ds does not exist"));
2048 goto err;
2049 }
2050
2051 if (LIM_IS_STA_ROLE(session_entry)) {
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302052 /*
2053 * on receiving channel switch announcement from AP, delete all
2054 * TDLS peers before leaving BSS and proceed for channel switch
2055 */
2056 lim_delete_tdls_peers(mac_ctx, session_entry);
2057
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002058 lim_ch_switch = &session_entry->gLimChannelSwitch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059 session_entry->gLimChannelSwitch.switchMode =
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302060 csa_params->switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061 /* timer already started by firmware, switch immediately */
2062 session_entry->gLimChannelSwitch.switchCount = 0;
2063 session_entry->gLimChannelSwitch.primaryChannel =
2064 csa_params->channel;
2065 session_entry->gLimChannelSwitch.state =
2066 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2067 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002068 lim_ch_switch->sec_ch_offset =
2069 session_entry->htSecondaryChannelOffset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302070 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2071 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2072 chnl_switch_info =
2073 &session_entry->gLimWiderBWChannelSwitch;
2074
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302075 lim_log(mac_ctx, LOG1,
2076 FL("vht:%d ht:%d flag:%x chan:%d seg1:%d seg2:%d width:%d country:%s class:%d"),
2077 session_entry->vhtCapability,
2078 session_entry->htSupportedChannelWidthSet,
2079 csa_params->ies_present_flag,
2080 csa_params->channel, csa_params->new_ch_freq_seg1,
2081 csa_params->new_ch_freq_seg2,
2082 csa_params->new_ch_width,
2083 mac_ctx->scan.countryCodeCurrent,
2084 csa_params->new_op_class);
2085
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 if (session_entry->vhtCapability &&
2087 session_entry->htSupportedChannelWidthSet) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
2089 chnl_switch_info->newChanWidth =
2090 csa_params->new_ch_width;
2091 chnl_switch_info->newCenterChanFreq0 =
2092 csa_params->new_ch_freq_seg1;
2093 chnl_switch_info->newCenterChanFreq1 =
2094 csa_params->new_ch_freq_seg2;
2095 session_entry->gLimChannelSwitch.state =
2096 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2097 session_entry->gLimChannelSwitch.ch_width =
2098 csa_params->new_ch_width + 1;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302099 } else if (csa_params->ies_present_flag
2100 & lim_xcsa_ie_present) {
2101 chan_space =
2102 cds_regdm_get_chanwidth_from_opclass(
2103 mac_ctx->scan.countryCodeCurrent,
2104 csa_params->channel,
2105 csa_params->new_op_class);
2106 session_entry->gLimChannelSwitch.state =
2107 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2108
2109 if (chan_space == 80) {
2110 chnl_switch_info->newChanWidth =
2111 CH_WIDTH_80MHZ;
2112 } else if (chan_space == 40) {
2113 chnl_switch_info->newChanWidth =
2114 CH_WIDTH_40MHZ;
2115 } else {
2116 chnl_switch_info->newChanWidth =
2117 CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002118 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302119 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2120 }
2121
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002122 ch_params.ch_width =
2123 chnl_switch_info->newChanWidth;
2124 cds_set_ch_params(csa_params->channel,
2125 eCSR_DOT11_MODE_11ac,
2126 &ch_params);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302127 chnl_switch_info->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002128 ch_params.center_freq_seg0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302129 /*
2130 * This is not applicable for 20/40/80 MHz.
2131 * Only used when we support 80+80 MHz operation.
2132 * In case of 80+80 MHz, this parameter indicates
2133 * center channel frequency index of 80 MHz
2134 * channel offrequency segment 1.
2135 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002136 chnl_switch_info->newCenterChanFreq1 =
2137 ch_params.center_freq_seg1;
2138 lim_ch_switch->sec_ch_offset =
2139 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 }
Gupta, Kapil121bf212015-11-25 19:21:29 +05302142 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2143 chnl_switch_info->newCenterChanFreq0;
2144 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2145 chnl_switch_info->newCenterChanFreq1;
2146 session_entry->gLimChannelSwitch.ch_width =
2147 chnl_switch_info->newChanWidth;
2148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 } else if (session_entry->htSupportedChannelWidthSet) {
Gupta, Kapil121bf212015-11-25 19:21:29 +05302150 if (csa_params->ies_present_flag
2151 & lim_xcsa_ie_present) {
2152 chan_space =
2153 cds_regdm_get_chanwidth_from_opclass(
2154 mac_ctx->scan.countryCodeCurrent,
2155 csa_params->channel,
2156 csa_params->new_op_class);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002157 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302158 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2159 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002160 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302161 CH_WIDTH_40MHZ;
2162 chnl_switch_info->newChanWidth =
2163 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002164 ch_params.ch_width =
2165 chnl_switch_info->newChanWidth;
2166 cds_set_ch_params(csa_params->channel,
2167 eCSR_DOT11_MODE_11n,
2168 &ch_params);
2169 lim_ch_switch->ch_center_freq_seg0 =
2170 ch_params.center_freq_seg0;
2171 lim_ch_switch->sec_ch_offset =
2172 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302173 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002174 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302175 CH_WIDTH_20MHZ;
2176 chnl_switch_info->newChanWidth =
2177 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002178 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302179 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002180 lim_ch_switch->sec_ch_offset =
2181 PHY_SINGLE_CHANNEL_CENTERED;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302182 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002184 lim_ch_switch->ch_width =
2185 CH_WIDTH_40MHZ;
2186 lim_ch_switch->state =
2187 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2188 ch_params.ch_width = CH_WIDTH_40MHZ;
2189 cds_set_ch_params(csa_params->channel,
2190 eCSR_DOT11_MODE_11n,
2191 &ch_params);
2192 lim_ch_switch->ch_center_freq_seg0 =
2193 ch_params.center_freq_seg0;
2194 lim_ch_switch->sec_ch_offset =
2195 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 }
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 }
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302199 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
2200 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201
2202 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302203 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002204 if (NULL == csa_offload_ind) {
2205 lim_log(mac_ctx, LOGE,
2206 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
2207 goto err;
2208 }
2209
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 qdf_mem_set(csa_offload_ind, sizeof(tSmeCsaOffloadInd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2212 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302213 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302214 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2216 mmh_msg.bodyptr = csa_offload_ind;
2217 mmh_msg.bodyval = 0;
2218 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002219 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 MTRACE(mac_trace_msg_tx
2221 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2222#ifdef FEATURE_WLAN_DIAG_SUPPORT
2223 lim_diag_event_report(mac_ctx,
2224 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2225 eSIR_SUCCESS, eSIR_SUCCESS);
2226#endif
2227 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
2228 }
2229
2230err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302231 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232}
2233
2234/*--------------------------------------------------------------------------
2235 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2236
2237 \param pMac - pointer to global adapter context
2238 \param sessionId - Message pointer.
2239
2240 \sa
2241 --------------------------------------------------------------------------*/
2242
2243void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ MsgQ)
2244{
2245 tpPESession psessionEntry;
2246 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2247
2248 psessionEntry =
2249 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2250 if (psessionEntry == NULL) {
2251 lim_log(pMac, LOGE,
2252 FL("Session Does not exist for given sessionID %d"),
2253 pDelBss->sessionId);
2254 return;
2255 }
2256 if (LIM_IS_IBSS_ROLE(psessionEntry)) {
2257 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
2258 } else if (LIM_IS_UNKNOWN_ROLE(psessionEntry)) {
2259 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
2260 }
2261
2262 else
2263 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2264
2265}
2266
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267/** -----------------------------------------------------------------
2268 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2269 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2270 \ SME only looks at rc and tspec field.
2271 \param pMac - global mac structure
2272 \param rspReqd - is SmeAddTsRsp required
2273 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2274 \return tspec
2275 \sa
2276 ----------------------------------------------------------------- */
2277void
2278lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2279 uint8_t smesessionId)
2280{
2281 tSirMsgQ mmhMsg;
2282
2283 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2284 mmhMsg.bodyptr = aggrQosRsp;
2285 mmhMsg.bodyval = 0;
2286 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2287 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2288
2289 return;
2290}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291
2292void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2293 uint8_t smesessionId)
2294{
2295 tSirMsgQ mmhMsg;
2296 tSmeMaxAssocInd *pSmeMaxAssocInd;
2297
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302298 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 if (NULL == pSmeMaxAssocInd) {
2300 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2301 return;
2302 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302303 qdf_mem_set((void *)pSmeMaxAssocInd, sizeof(tSmeMaxAssocInd), 0);
2304 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302305 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2307 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2308 pSmeMaxAssocInd->sessionId = smesessionId;
2309 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2310 mmhMsg.bodyptr = pSmeMaxAssocInd;
2311 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2312 " sme session id %d"),
2313 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2314 MAC_ADDR_ARRAY(peerMacAddr));
2315 )
2316 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2317 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2318
2319 return;
2320}
2321
2322/** -----------------------------------------------------------------
2323 \brief lim_send_sme_dfs_event_notify() - sends
2324 eWNI_SME_DFS_RADAR_FOUND
2325 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2326 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2327 that a RADAR is found on current operating channel and SAP-
2328 has to move to a new channel.
2329 \param pMac - global mac structure
2330 \param msgType - message type received from lower layer
2331 \param event - event data received from lower layer
2332 \return none
2333 \sa
2334 ----------------------------------------------------------------- */
2335void
2336lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2337{
2338 tSirMsgQ mmhMsg;
2339 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2340 mmhMsg.bodyptr = event;
2341 mmhMsg.bodyval = 0;
2342 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2343 return;
2344}
2345
2346/*--------------------------------------------------------------------------
2347 \brief lim_send_dfs_chan_sw_ie_update()
2348 This timer handler updates the channel switch IE in beacon template
2349
2350 \param pMac - pointer to global adapter context
2351 \return - channel to scan from valid session else zero.
2352 \sa
2353 --------------------------------------------------------------------------*/
2354static void
2355lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2356{
2357
2358 /* Update the beacon template and send to FW */
2359 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2360 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2361 return;
2362 }
2363
2364 /* Send update beacon template message */
2365 lim_send_beacon_ind(pMac, psessionEntry);
2366 PELOG1(lim_log(pMac, LOG1,
2367 FL(" Updated CSA IE, IE COUNT = %d"),
2368 psessionEntry->gLimChannelSwitch.switchCount);
2369 )
2370
2371 return;
2372}
2373
2374/** -----------------------------------------------------------------
2375 \brief lim_send_sme_ap_channel_switch_resp() - sends
2376 eWNI_SME_CHANNEL_CHANGE_RSP
2377 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2378 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2379 that the Channel change has been done to the specified target
2380 channel in the Channel change request
2381 \param pMac - global mac structure
2382 \param psessionEntry - session info
2383 \param pChnlParams - Channel switch params
2384 --------------------------------------------------------------------*/
2385void
2386lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2387 tpPESession psessionEntry,
2388 tpSwitchChannelParams pChnlParams)
2389{
2390 tSirMsgQ mmhMsg;
2391 tpSwitchChannelParams pSmeSwithChnlParams;
2392 uint8_t channelId;
2393
2394 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302395 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 if (NULL == pSmeSwithChnlParams) {
2397 lim_log(pMac, LOGP,
2398 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2399 return;
2400 }
2401
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302402 qdf_mem_set((void *)pSmeSwithChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 sizeof(tSwitchChannelParams), 0);
2404
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302405 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 sizeof(tSwitchChannelParams));
2407
2408 channelId = pSmeSwithChnlParams->channelNumber;
2409
2410 /*
2411 * Pass the sme sessionID to SME instead
2412 * PE session ID.
2413 */
2414 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2415
2416 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2417 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2418 mmhMsg.bodyval = 0;
2419 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2420
2421 /*
2422 * We should start beacon transmission only if the new
2423 * channel after channel change is Non-DFS. For a DFS
2424 * channel, PE will receive an explicit request from
2425 * upper layers to start the beacon transmission .
2426 */
2427
2428 if (CHANNEL_STATE_DFS != cds_get_channel_state(channelId)) {
2429 if (channelId == psessionEntry->currentOperChannel) {
2430 lim_apply_configuration(pMac, psessionEntry);
2431 lim_send_beacon_ind(pMac, psessionEntry);
2432 } else {
2433 PELOG1(lim_log(pMac, LOG1,
2434 FL
2435 ("Failed to Transmit Beacons on channel = %d"
2436 "after AP channel change response"),
2437 psessionEntry->bcnLen);
2438 )
2439 }
2440 }
2441 return;
2442}
2443
2444/** -----------------------------------------------------------------
2445 \brief lim_process_beacon_tx_success_ind() - This function is used
2446 explicitely to handle successful beacon transmission indication
2447 from the FW. This is a generic event generated by the FW afer the
2448 first beacon is sent out after the beacon template update by the
2449 host
2450 \param pMac - global mac structure
2451 \param psessionEntry - session info
2452 \return none
2453 \sa
2454 ----------------------------------------------------------------- */
2455void
2456lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2457{
2458 /* Currently, this event is used only for DFS channel switch announcement
2459 * IE update in the template. If required to be used for other IE updates
2460 * add appropriate code by introducing a state variable
2461 */
2462 tpPESession psessionEntry;
2463 tSirMsgQ mmhMsg;
2464 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2465 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2466 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2467 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2468 (tSirFirstBeaconTxCompleteInd *) event;
2469
2470 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2471 if (psessionEntry == NULL) {
2472 lim_log(pMac, LOGE,
2473 FL("Session Does not exist for given sessionID"));
2474 return;
2475 }
2476
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302477 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2478 GET_LIM_SYSTEM_ROLE(psessionEntry),
2479 psessionEntry->dfsIncludeChanSwIe,
2480 psessionEntry->gLimOperatingMode.present);
2481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 if (LIM_IS_AP_ROLE(psessionEntry) &&
2483 true == psessionEntry->dfsIncludeChanSwIe) {
2484 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2485 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2486 /*
2487 * Send the next beacon with updated CSA IE count
2488 */
2489 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2490 /* Decrement the IE count */
2491 psessionEntry->gLimChannelSwitch.switchCount--;
2492 } else {
2493 /* Done with CSA IE update, send response back to SME */
2494 psessionEntry->gLimChannelSwitch.switchCount = 0;
2495 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2496 psessionEntry->gLimChannelSwitch.switchMode = 0;
2497 psessionEntry->dfsIncludeChanSwIe = false;
2498 psessionEntry->dfsIncludeChanWrapperIe = false;
2499
2500 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302501 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502
2503 if (NULL == pChanSwTxResponse) {
2504 lim_log(pMac, LOGP,
2505 FL
2506 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2507 return;
2508 }
2509
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302510 qdf_mem_set((void *)pChanSwTxResponse, length, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511 pChanSwTxResponse->sessionId =
2512 psessionEntry->smeSessionId;
2513 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302514 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515
2516 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2517 mmhMsg.bodyptr = pChanSwTxResponse;
2518 mmhMsg.bodyval = 0;
2519 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2520 }
2521 }
2522
2523 if (LIM_IS_AP_ROLE(psessionEntry) &&
2524 psessionEntry->gLimOperatingMode.present) {
2525 /* Done with nss update, send response back to SME */
2526 psessionEntry->gLimOperatingMode.present = 0;
2527 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302528 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529 if (NULL == beacon_tx_comp_rsp_ptr) {
2530 lim_log(pMac, LOGP,
2531 FL
2532 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2533 return;
2534 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302535 qdf_mem_set((void *)beacon_tx_comp_rsp_ptr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 sizeof(*beacon_tx_comp_rsp_ptr), 0);
2537 beacon_tx_comp_rsp_ptr->session_id =
2538 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302539 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2541 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2542 mmhMsg.bodyval = 0;
2543 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2544 }
2545 return;
2546}