blob: 9f6413fdec0d0f9cb1052da0bf8ec806f60550d0 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_send_sme_rspMessages.cc contains the functions
30 * for sending SME response/notification messages to applications
31 * above MAC software.
32 * Author: Chandra Modumudi
33 * Date: 02/13/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38
Anurag Chouhan6d760662016-02-20 16:05:43 +053039#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include "wni_api.h"
41#include "sir_common.h"
42#include "ani_global.h"
43
44#include "wni_cfg.h"
45#include "sys_def.h"
46#include "cfg_api.h"
47
48#include "sch_api.h"
49#include "utils_api.h"
50#include "lim_utils.h"
51#include "lim_security_utils.h"
52#include "lim_ser_des_utils.h"
53#include "lim_send_sme_rsp_messages.h"
54#include "lim_ibss_peer_mgmt.h"
55#include "lim_session_utils.h"
56#include "lim_types.h"
57#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070058#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053059#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070060#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061
62static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
63 tpPESession session_entry, tSirResultCodes result_code,
64 tpSirSmeJoinRsp sme_join_rsp);
65
66/**
67 * lim_send_sme_rsp() - Send Response to upper layers
68 * @mac_ctx: Pointer to Global MAC structure
69 * @msg_type: Indicates message type
70 * @result_code: Indicates the result of previously issued
71 * eWNI_SME_msg_type_REQ message
72 *
73 * This function is called by lim_process_sme_req_messages() to send
74 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
75 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
76 * Software.
77 *
78 * Return: None
79 */
80
81void
82lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
83 tSirResultCodes result_code, uint8_t sme_session_id,
84 uint16_t sme_transaction_id)
85{
86 tSirMsgQ msg;
87 tSirSmeRsp *sme_rsp;
88
89 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
90 lim_msg_str(msg_type), lim_result_code_str(result_code));
91
Anurag Chouhan600c3a02016-03-01 10:33:54 +053092 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093 if (NULL == sme_rsp) {
94 /* Buffer not available. Log error */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053095 QDF_TRACE(QDF_MODULE_ID_PE, LOGP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
97 return;
98 }
99
100 sme_rsp->messageType = msg_type;
101 sme_rsp->length = sizeof(tSirSmeRsp);
102 sme_rsp->statusCode = result_code;
103
104 sme_rsp->sessionId = sme_session_id;
105 sme_rsp->transactionId = sme_transaction_id;
106
107 msg.type = msg_type;
108 msg.bodyptr = sme_rsp;
109 msg.bodyval = 0;
110 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
111
112#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
113 switch (msg_type) {
114 case eWNI_SME_STOP_BSS_RSP:
115 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
116 NULL, (uint16_t) result_code, 0);
117 break;
118 }
119#endif /* FEATURE_WLAN_DIAG_SUPPORT */
120 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
121}
122
123
124
125/**
126 * lim_send_sme_roc_rsp() - Send Response to SME
127 * @mac_ctx: Pointer to Global MAC structure
128 * @status: Resume link status
129 * @result_code: Result of the ROC request
130 * @sme_session_id: SME sesson Id
131 * @scan_id: Scan Identifier
132 *
133 * This function is called to send ROC rsp
134 * message to SME.
135 *
136 * Return: None
137 */
138void
139lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
140 tSirResultCodes result_code, uint8_t sme_session_id,
141 uint32_t scan_id)
142{
143 tSirMsgQ msg;
144 struct sir_roc_rsp *sme_rsp;
145
146 lim_log(mac_ctx, LOG1,
147 FL("Sending message %s with reasonCode %s scanId %d"),
148 lim_msg_str(msg_type), lim_result_code_str(result_code),
149 scan_id);
150
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530151 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 if (NULL == sme_rsp) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530153 QDF_TRACE(QDF_MODULE_ID_PE, LOGP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
155 return;
156 }
157
158 sme_rsp->message_type = msg_type;
159 sme_rsp->length = sizeof(struct sir_roc_rsp);
160 sme_rsp->status = result_code;
161
162 sme_rsp->session_id = sme_session_id;
163 sme_rsp->scan_id = scan_id;
164
165 msg.type = msg_type;
166 msg.bodyptr = sme_rsp;
167 msg.bodyval = 0;
168 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
169 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
170}
171
172
173/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530174 * lim_get_max_rate_flags() - Get rate flags
175 * @mac_ctx: Pointer to global MAC structure
176 * @sta_ds: Pointer to station ds structure
177 *
178 * This function is called to get the rate flags for a connection
179 * from the station ds structure depending on the ht and the vht
180 * channel width supported.
181 *
182 * Return: Returns the populated rate_flags
183 */
184uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
185{
186 uint32_t rate_flags = 0;
187
188 if (sta_ds == NULL) {
189 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
190 return rate_flags;
191 }
192
193 if (!sta_ds->mlmStaContext.htCapability &&
194 !sta_ds->mlmStaContext.vhtCapability) {
195 rate_flags |= eHAL_TX_RATE_LEGACY;
196 } else {
197 if (sta_ds->mlmStaContext.vhtCapability) {
198 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
199 sta_ds->vhtSupportedChannelWidthSet) {
200 rate_flags |= eHAL_TX_RATE_VHT80;
201 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
202 sta_ds->vhtSupportedChannelWidthSet) {
203 if (sta_ds->htSupportedChannelWidthSet)
204 rate_flags |= eHAL_TX_RATE_VHT40;
205 else
206 rate_flags |= eHAL_TX_RATE_VHT20;
207 }
208 } else if (sta_ds->mlmStaContext.htCapability) {
209 if (sta_ds->htSupportedChannelWidthSet)
210 rate_flags |= eHAL_TX_RATE_HT40;
211 else
212 rate_flags |= eHAL_TX_RATE_HT20;
213 }
214 }
215
216 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
217 rate_flags |= eHAL_TX_RATE_SGI;
218
219 return rate_flags;
220}
221
222/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
224 * @mac_ctx Pointer to Global MAC structure
225 * @status Resume link status
226 * @ctx context passed while calling resmune link.
227 * (join response to be sent)
228 *
229 * This function is called to send Join/Reassoc rsp
230 * message to SME after the resume link.
231 *
232 * Return: None
233 */
234static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530235 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236{
237 tSirMsgQ msg;
238 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
239
240 msg.type = sme_join_rsp->messageType;
241 msg.bodyptr = sme_join_rsp;
242 msg.bodyval = 0;
243 MTRACE(mac_trace_msg_tx(mac_ctx, NO_SESSION, msg.type));
244 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
245}
246
247/**
248 * lim_handle_join_rsp_status() - Handle the response.
249 * @mac_ctx: Pointer to Global MAC structure
250 * @session_entry: PE Session Info
251 * @result_code: Indicates the result of previously issued
252 * eWNI_SME_msgType_REQ message
253 * @sme_join_rsp The received response.
254 *
255 * This function will handle both the success and failure status
256 * of the received response.
257 *
258 * Return: None
259 */
260static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
261 tpPESession session_entry, tSirResultCodes result_code,
262 tpSirSmeJoinRsp sme_join_rsp)
263{
264#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
265 tSirSmeHTProfile *ht_profile;
266#endif
267 if (result_code == eSIR_SME_SUCCESS) {
268 if (session_entry->beacon != NULL) {
269 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530270 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800271 session_entry->beacon,
272 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530273 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530275 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 lim_log(mac_ctx, LOG1, FL("Beacon=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530277 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278 }
279 if (session_entry->assocReq != NULL) {
280 sme_join_rsp->assocReqLength =
281 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530282 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530283 sme_join_rsp->beaconLength,
284 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530286 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530288 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289 lim_log(mac_ctx,
290 LOG1, FL("AssocReq=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530291 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 }
293 if (session_entry->assocRsp != NULL) {
294 sme_join_rsp->assocRspLength =
295 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530296 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530297 sme_join_rsp->beaconLength +
298 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 session_entry->assocRsp,
300 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530301 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530303 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 if (session_entry->ricData != NULL) {
306 sme_join_rsp->parsedRicRspLen =
307 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530308 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530309 sme_join_rsp->beaconLength +
310 sme_join_rsp->assocReqLength +
311 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 session_entry->ricData,
313 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530314 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530316 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800317 lim_log(mac_ctx, LOG1, FL("RicLength=%d"),
318 sme_join_rsp->parsedRicRspLen);
319 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320#ifdef FEATURE_WLAN_ESE
321 if (session_entry->tspecIes != NULL) {
322 sme_join_rsp->tspecIeLen =
323 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530324 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530325 sme_join_rsp->beaconLength +
326 sme_join_rsp->assocReqLength +
327 sme_join_rsp->assocRspLength +
328 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 session_entry->tspecIes,
330 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530331 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530333 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334 lim_log(mac_ctx, LOG1, FL("ESE-TspecLen=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530335 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 }
337#endif
338 sme_join_rsp->aid = session_entry->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 lim_log(mac_ctx, LOG1, FL("AssocRsp=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530340 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 sme_join_rsp->vht_channel_width =
342 session_entry->ch_width;
343#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
344 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530345 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 ht_profile = &sme_join_rsp->HTProfile;
347 ht_profile->htSupportedChannelWidthSet =
348 session_entry->htSupportedChannelWidthSet;
349 ht_profile->htRecommendedTxWidthSet =
350 session_entry->htRecommendedTxWidthSet;
351 ht_profile->htSecondaryChannelOffset =
352 session_entry->htSecondaryChannelOffset;
353 ht_profile->dot11mode = session_entry->dot11mode;
354 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 ht_profile->vhtCapability =
356 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
358 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 }
360#endif
361 } else {
362 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530363 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530365 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 }
367 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530368 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530370 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 }
372 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530373 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530375 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530378 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530380 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382#ifdef FEATURE_WLAN_ESE
383 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530384 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530386 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 }
388#endif
389 }
390}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530391
392/**
393 * lim_add_bss_info() - copy data from session entry to join rsp
394 * @session_entry: PE Session Info
395 * @sme_join_rsp: Join response buffer to be filled up
396 *
397 * Return: None
398 */
399void lim_add_bss_info(tpPESession session_entry,
400 tpSirSmeJoinRsp sme_join_rsp)
401{
402 sme_join_rsp->hs20vendor_ie = session_entry->hs20vendor_ie;
403 sme_join_rsp->vht_caps = session_entry->vht_caps;
404 sme_join_rsp->ht_caps = session_entry->ht_caps;
405 sme_join_rsp->ht_operation = session_entry->ht_operation;
406 sme_join_rsp->vht_operation = session_entry->vht_operation;
407}
408
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409/**
410 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
411 * @mac_ctx: Pointer to Global MAC structure
412 * @msg_type: Indicates message type
413 * @result_code: Indicates the result of previously issued
414 * eWNI_SME_msgType_REQ message
415 * @prot_status_code: Protocol Status Code
416 * @session_entry: PE Session Info
417 * @sme_session_id: SME Session ID
418 * @sme_transaction_id: SME Transaction ID
419 *
420 * This function is called by lim_process_sme_req_messages() to send
421 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
422 * above MAC Software.
423 *
424 * Return: None
425 */
426
427void
428lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
429 tSirResultCodes result_code, uint16_t prot_status_code,
430 tpPESession session_entry, uint8_t sme_session_id,
431 uint16_t sme_transaction_id)
432{
433 tpSirSmeJoinRsp sme_join_rsp;
434 uint32_t rsp_len;
435 tpDphHashNode sta_ds = NULL;
436#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
437 if (msg_type == eWNI_SME_REASSOC_RSP)
438 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
439 session_entry, (uint16_t) result_code, 0);
440 else
441 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
442 session_entry, (uint16_t) result_code, 0);
443#endif /* FEATURE_WLAN_DIAG_SUPPORT */
444
445 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
446 lim_msg_str(msg_type), lim_result_code_str(result_code));
447
448 if (session_entry == NULL) {
449 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530450 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 if (NULL == sme_join_rsp) {
452 lim_log(mac_ctx, LOGP,
453 FL("Mem Alloc fail - JOIN/REASSOC_RSP"));
454 return;
455 }
456
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530457 qdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 sme_join_rsp->beaconLength = 0;
459 sme_join_rsp->assocReqLength = 0;
460 sme_join_rsp->assocRspLength = 0;
461 } else {
462 rsp_len = session_entry->assocReqLen +
463 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465#ifdef FEATURE_WLAN_ESE
466 session_entry->tspecLen +
467#endif
468 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530469 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 if (NULL == sme_join_rsp) {
471 lim_log(mac_ctx, LOGP,
472 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
473 return;
474 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530475 qdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 if (result_code == eSIR_SME_SUCCESS) {
477 sta_ds = dph_get_hash_entry(mac_ctx,
478 DPH_STA_HASH_INDEX_PEER,
479 &session_entry->dph.dphHashTable);
480 if (sta_ds == NULL) {
481 lim_log(mac_ctx, LOGE,
482 FL("Get Self Sta Entry fail"));
483 } else {
484 /* Pass the peer's staId */
485 sme_join_rsp->staId = sta_ds->staIndex;
486 sme_join_rsp->ucastSig =
487 sta_ds->ucUcastSig;
488 sme_join_rsp->bcastSig =
489 sta_ds->ucBcastSig;
490 sme_join_rsp->timingMeasCap =
491 sta_ds->timingMeasCap;
492#ifdef FEATURE_WLAN_TDLS
493 sme_join_rsp->tdls_prohibited =
494 session_entry->tdls_prohibited;
495 sme_join_rsp->tdls_chan_swit_prohibited =
496 session_entry->tdls_chan_swit_prohibited;
497#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530498 sme_join_rsp->nss = sta_ds->nss;
499 sme_join_rsp->max_rate_flags =
500 lim_get_max_rate_flags(mac_ctx, sta_ds);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800501 }
502 }
503 sme_join_rsp->beaconLength = 0;
504 sme_join_rsp->assocReqLength = 0;
505 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507#ifdef FEATURE_WLAN_ESE
508 sme_join_rsp->tspecIeLen = 0;
509#endif
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530510 lim_add_bss_info(session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
512 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800513
514 /* Send supported NSS 1x1 to SME */
515 sme_join_rsp->supported_nss_1x1 =
516 session_entry->supported_nss_1x1;
517 lim_log(mac_ctx, LOG1,
518 FL("SME Join Rsp is supported NSS 1X1: %d"),
519 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800520 }
521
522 sme_join_rsp->messageType = msg_type;
523 sme_join_rsp->length = (uint16_t) rsp_len;
524 sme_join_rsp->statusCode = result_code;
525 sme_join_rsp->protStatusCode = prot_status_code;
526
527 sme_join_rsp->sessionId = sme_session_id;
528 sme_join_rsp->transactionId = sme_transaction_id;
529
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530530 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531 (uint32_t *)sme_join_rsp);
532}
533
534/**
535 * lim_send_sme_start_bss_rsp()
536 *
537 ***FUNCTION:
538 * This function is called to send eWNI_SME_START_BSS_RSP
539 * message to applications above MAC Software.
540 *
541 ***PARAMS:
542 *
543 ***LOGIC:
544 *
545 ***ASSUMPTIONS:
546 * NA
547 *
548 ***NOTE:
549 * NA
550 *
551 * @param pMac Pointer to Global MAC structure
552 * @param msgType Indicates message type
553 * @param resultCode Indicates the result of previously issued
554 * eWNI_SME_msgType_REQ message
555 *
556 * @return None
557 */
558
559void
560lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
561 uint16_t msgType, tSirResultCodes resultCode,
562 tpPESession psessionEntry, uint8_t smesessionId,
563 uint16_t smetransactionId)
564{
565
566 uint16_t size = 0;
567 tSirMsgQ mmhMsg;
568 tSirSmeStartBssRsp *pSirSmeRsp;
569 uint16_t ieLen;
570 uint16_t ieOffset, curLen;
571
572 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
573 lim_msg_str(msgType), lim_result_code_str(resultCode));
574 )
575
576 size = sizeof(tSirSmeStartBssRsp);
577
578 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530579 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 if (NULL == pSirSmeRsp) {
581 /* / Buffer not available. Log error */
582 lim_log(pMac, LOGP,
583 FL
584 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
585 return;
586 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530587 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588
589 } else {
590 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
591 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
592 ieLen = psessionEntry->schBeaconOffsetBegin
593 + psessionEntry->schBeaconOffsetEnd - ieOffset;
594 /* calculate the memory size to allocate */
595 size += ieLen;
596
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530597 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 if (NULL == pSirSmeRsp) {
599 /* / Buffer not available. Log error */
600 lim_log(pMac, LOGP,
601 FL
602 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
603
604 return;
605 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530606 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 size = sizeof(tSirSmeStartBssRsp);
608 if (resultCode == eSIR_SME_SUCCESS) {
609
610 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
611 psessionEntry->bssId);
612
613 /* Read beacon interval from session */
614 pSirSmeRsp->bssDescription.beaconInterval =
615 (uint16_t) psessionEntry->beaconParams.
616 beaconInterval;
617 pSirSmeRsp->bssType = psessionEntry->bssType;
618
619 if (cfg_get_capability_info
620 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
621 psessionEntry)
622 != eSIR_SUCCESS)
623 lim_log(pMac, LOGP,
624 FL
625 ("could not retrieve Capabilities value"));
626
627 lim_get_phy_mode(pMac,
628 (uint32_t *) &pSirSmeRsp->bssDescription.
629 nwType, psessionEntry);
630
631 pSirSmeRsp->bssDescription.channelId =
632 psessionEntry->currentOperChannel;
633
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700634 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530636 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 ieFields,
638 psessionEntry->pSchBeaconFrameBegin +
639 ieOffset, (uint32_t) curLen);
640
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530641 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 ieFields) + curLen,
643 psessionEntry->pSchBeaconFrameEnd,
644 (uint32_t) psessionEntry->
645 schBeaconOffsetEnd);
646
647 /* subtracting size of length indicator itself and size of pointer to ieFields */
648 pSirSmeRsp->bssDescription.length =
649 sizeof(tSirBssDescription) - sizeof(uint16_t) -
650 sizeof(uint32_t) + ieLen;
651 /* This is the size of the message, subtracting the size of the pointer to ieFields */
652 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700653 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
655 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530656 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657 pSirSmeRsp->HTProfile.
658 htSupportedChannelWidthSet =
659 psessionEntry->htSupportedChannelWidthSet;
660 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
661 psessionEntry->htRecommendedTxWidthSet;
662 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
663 psessionEntry->htSecondaryChannelOffset;
664 pSirSmeRsp->HTProfile.dot11mode =
665 psessionEntry->dot11mode;
666 pSirSmeRsp->HTProfile.htCapability =
667 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668 pSirSmeRsp->HTProfile.vhtCapability =
669 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 pSirSmeRsp->HTProfile.apCenterChan =
671 psessionEntry->ch_center_freq_seg0;
672 pSirSmeRsp->HTProfile.apChanWidth =
673 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 }
675#endif
676 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678 pSirSmeRsp->messageType = msgType;
679 pSirSmeRsp->length = size;
680
681 /* Update SME session Id and transaction Id */
682 pSirSmeRsp->sessionId = smesessionId;
683 pSirSmeRsp->transactionId = smetransactionId;
684 pSirSmeRsp->statusCode = resultCode;
685 if (psessionEntry != NULL)
686 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
687
688 mmhMsg.type = msgType;
689 mmhMsg.bodyptr = pSirSmeRsp;
690 mmhMsg.bodyval = 0;
691 if (psessionEntry == NULL) {
692 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
693 } else {
694 MTRACE(mac_trace_msg_tx
695 (pMac, psessionEntry->peSessionId, mmhMsg.type));
696 }
697#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
698 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
699 psessionEntry, (uint16_t) resultCode, 0);
700#endif /* FEATURE_WLAN_DIAG_SUPPORT */
701
702 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
703} /*** end lim_send_sme_start_bss_rsp() ***/
704
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705/**
706 * lim_send_sme_scan_rsp() - Send scan response to SME
707 * @pMac: Pointer to Global MAC structure
708 * @length: Indicates length of message
709 * @resultCode: Indicates the result of previously issued
710 * eWNI_SME_SCAN_REQ message
711 * @scan_id: scan identifier
712 *
713 * This function is called by lim_process_sme_req_messages() to send
714 * eWNI_SME_SCAN_RSP message to applications above MAC
715 *
716 * return: None
717 */
718
719void
720lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
721 uint8_t smesessionId, uint16_t smetranscationId,
722 uint32_t scan_id)
723{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
725 smetranscationId, scan_id);
726}
727
728/**
729 * lim_post_sme_scan_rsp_message()
730 *
731 ***FUNCTION:
732 * This function is called by lim_send_sme_scan_rsp() to send
733 * eWNI_SME_SCAN_RSP message with failed result code
734 *
735 ***NOTE:
736 * NA
737 *
738 * @param pMac Pointer to Global MAC structure
739 * @param length Indicates length of message
740 * @param resultCode failed result code
741 *
742 * @return None
743 */
744
745void
746lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
747 tSirResultCodes resultCode, uint8_t smesessionId,
748 uint16_t smetransactionId,
749 uint32_t scan_id)
750{
751 tpSirSmeScanRsp pSirSmeScanRsp;
752 tSirMsgQ mmhMsg;
753
754 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
755 lim_result_code_str(resultCode));
756
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530757 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758 if (NULL == pSirSmeScanRsp) {
759 lim_log(pMac, LOGP,
760 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
761 return;
762 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530763 qdf_mem_set((void *)pSirSmeScanRsp, sizeof(tSirSmeScanRsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764
765 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
766 pSirSmeScanRsp->statusCode = resultCode;
767
768 /*Update SME session Id and transaction Id */
769 pSirSmeScanRsp->sessionId = smesessionId;
770 pSirSmeScanRsp->transcationId = smetransactionId;
771 pSirSmeScanRsp->scan_id = scan_id;
772
773 mmhMsg.type = eWNI_SME_SCAN_RSP;
774 mmhMsg.bodyptr = pSirSmeScanRsp;
775 mmhMsg.bodyval = 0;
776
777 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
778#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
779 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
780 (uint16_t) resultCode, 0);
781#endif /* FEATURE_WLAN_DIAG_SUPPORT */
782
783 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
784 return;
785
786} /*** lim_post_sme_scan_rsp_message ***/
787
788#ifdef FEATURE_OEM_DATA_SUPPORT
789
790/**
791 * lim_send_sme_oem_data_rsp()
792 *
793 ***FUNCTION:
794 * This function is called by lim_process_sme_req_messages() to send
795 * eWNI_SME_OEM_DATA_RSP message to applications above MAC
796 * Software.
797 *
798 ***PARAMS:
799 *
800 ***LOGIC:
801 *
802 ***ASSUMPTIONS:
803 * NA
804 *
805 ***NOTE:
806 * NA
807 *
808 * @param pMac Pointer to Global MAC structure
809 * @param pMsgBuf Indicates the mlm message
810 * @param resultCode Indicates the result of previously issued
811 * eWNI_SME_OEM_DATA_RSP message
812 *
813 * @return None
814 */
815
816void lim_send_sme_oem_data_rsp(tpAniSirGlobal pMac, uint32_t *pMsgBuf,
817 tSirResultCodes resultCode)
818{
819 tSirMsgQ mmhMsg;
820 tSirOemDataRsp *pSirSmeOemDataRsp = NULL;
821 tLimMlmOemDataRsp *pMlmOemDataRsp = NULL;
822 uint16_t msgLength;
823
824 /* get the pointer to the mlm message */
825 pMlmOemDataRsp = (tLimMlmOemDataRsp *) (pMsgBuf);
826
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800827 msgLength = sizeof(*pSirSmeOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 /* now allocate memory for the char buffer */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800829 pSirSmeOemDataRsp = qdf_mem_malloc(sizeof(*pSirSmeOemDataRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 if (NULL == pSirSmeOemDataRsp) {
831 lim_log(pMac, LOGP,
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800832 FL("malloc failed for pSirSmeOemDataRsp"));
833 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
834 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 return;
836 }
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800837
838 if (pMlmOemDataRsp->rsp_len) {
839 pSirSmeOemDataRsp->oem_data_rsp =
840 qdf_mem_malloc(pMlmOemDataRsp->rsp_len);
841 if (!pSirSmeOemDataRsp->oem_data_rsp) {
842 lim_log(pMac, LOGE,
843 FL("malloc failed for oem_data_rsp"));
844 qdf_mem_free(pSirSmeOemDataRsp);
845 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
846 qdf_mem_free(pMlmOemDataRsp);
847 return;
848 }
849 }
850
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851#if defined (ANI_LITTLE_BYTE_ENDIAN)
852 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->length, msgLength);
853 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->messageType,
854 eWNI_SME_OEM_DATA_RSP);
855#else
856 pSirSmeOemDataRsp->length = msgLength;
857 pSirSmeOemDataRsp->messageType = eWNI_SME_OEM_DATA_RSP;
858#endif
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -0800859 pSirSmeOemDataRsp->target_rsp = pMlmOemDataRsp->target_rsp;
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800860 pSirSmeOemDataRsp->rsp_len = pMlmOemDataRsp->rsp_len;
861 if (pSirSmeOemDataRsp->rsp_len)
862 qdf_mem_copy(pSirSmeOemDataRsp->oem_data_rsp,
863 pMlmOemDataRsp->oem_data_rsp,
864 pSirSmeOemDataRsp->rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865
866 /* Now free the memory from MLM Rsp Message */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800867 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530868 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869
870 mmhMsg.type = eWNI_SME_OEM_DATA_RSP;
871 mmhMsg.bodyptr = pSirSmeOemDataRsp;
872 mmhMsg.bodyval = 0;
873
874 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
875
876 return;
877} /*** lim_send_sme_oem_data_rsp ***/
878
879#endif
880
881void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530882 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883{
884 tSirMsgQ mmhMsg;
885 tSirMsgQ *pMsg = (tSirMsgQ *) pCtx;
886
887 mmhMsg.type = pMsg->type;
888 mmhMsg.bodyptr = pMsg;
889 mmhMsg.bodyval = 0;
890
891 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
892
893 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
894}
895
896/**
897 * lim_send_sme_disassoc_ntf()
898 *
899 ***FUNCTION:
900 * This function is called by limProcessSmeMessages() to send
901 * eWNI_SME_DISASSOC_RSP/IND message to host
902 *
903 ***PARAMS:
904 *
905 ***LOGIC:
906 *
907 ***ASSUMPTIONS:
908 * NA
909 *
910 ***NOTE:
911 * This function is used for sending eWNI_SME_DISASSOC_CNF,
912 * or eWNI_SME_DISASSOC_IND to host depending on
913 * disassociation trigger.
914 *
915 * @param peerMacAddr Indicates the peer MAC addr to which
916 * disassociate was initiated
917 * @param reasonCode Indicates the reason for Disassociation
918 * @param disassocTrigger Indicates the trigger for Disassociation
919 * @param aid Indicates the STAID. This parameter is
920 * present only on AP.
921 *
922 * @return None
923 */
924void
925lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
926 tSirMacAddr peerMacAddr,
927 tSirResultCodes reasonCode,
928 uint16_t disassocTrigger,
929 uint16_t aid,
930 uint8_t smesessionId,
931 uint16_t smetransactionId, tpPESession psessionEntry)
932{
933
934 uint8_t *pBuf;
935 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
936 tSirSmeDisassocInd *pSirSmeDisassocInd;
937 uint32_t *pMsg;
938 bool failure = false;
939
940 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
941 disassocTrigger, reasonCode);
942
943 switch (disassocTrigger) {
944 case eLIM_PEER_ENTITY_DISASSOC:
945 if (reasonCode != eSIR_SME_STA_NOT_ASSOCIATED) {
946 failure = true;
947 goto error;
948 }
949
950 case eLIM_HOST_DISASSOC:
951 /**
952 * Disassociation response due to
953 * host triggered disassociation
954 */
955
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530956 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 if (NULL == pSirSmeDisassocRsp) {
958 /* Log error */
959 lim_log(pMac, LOGP, FL("Memory allocation failed"));
960 failure = true;
961 goto error;
962 }
963 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
964 "retCode: %d for " MAC_ADDRESS_STR),
965 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
966 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
967 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
968 /* sessionId */
969 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
970 *pBuf = smesessionId;
971 pBuf++;
972
973 /* transactionId */
974 lim_copy_u16(pBuf, smetransactionId);
975 pBuf += sizeof(uint16_t);
976
977 /* statusCode */
978 lim_copy_u32(pBuf, reasonCode);
979 pBuf += sizeof(tSirResultCodes);
980
981 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530982 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 pBuf += sizeof(tSirMacAddr);
984
985 /* Clear Station Stats */
986 /* for sta, it is always 1, IBSS is handled at halInitSta */
987
988#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
989
990 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
991 psessionEntry, (uint16_t) reasonCode, 0);
992#endif
993 pMsg = (uint32_t *) pSirSmeDisassocRsp;
994 break;
995
996 default:
997 /**
998 * Disassociation indication due to Disassociation
999 * frame reception from peer entity or due to
1000 * loss of link with peer entity.
1001 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301002 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 if (NULL == pSirSmeDisassocInd) {
1004 /* Log error */
1005 lim_log(pMac, LOGP, FL("Memory allocation failed"));
1006 failure = true;
1007 goto error;
1008 }
1009 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
1010 "retCode: %d for " MAC_ADDRESS_STR),
1011 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1012 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1013 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1014
1015 /* Update SME session Id and Transaction Id */
1016 pSirSmeDisassocInd->sessionId = smesessionId;
1017 pSirSmeDisassocInd->transactionId = smetransactionId;
1018 pSirSmeDisassocInd->reasonCode = reasonCode;
1019 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1020
1021 lim_copy_u32(pBuf, reasonCode);
1022 pBuf += sizeof(tSirResultCodes);
1023
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301024 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 pBuf += sizeof(tSirMacAddr);
1026
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301027 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028
1029#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1030 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1031 psessionEntry, (uint16_t) reasonCode, 0);
1032#endif
1033 pMsg = (uint32_t *) pSirSmeDisassocInd;
1034
1035 break;
1036 }
1037
1038error:
1039 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001040 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042
1043 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301044 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 (uint32_t *) pMsg);
1046} /*** end lim_send_sme_disassoc_ntf() ***/
1047
1048/** -----------------------------------------------------------------
1049 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1050
1051 After receiving disassociation frame from peer entity, this
1052 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1053 reason code.
1054
1055 \param pMac - global mac structure
1056 \param pStaDs - station dph hash node
1057 \return none
1058 \sa
1059 ----------------------------------------------------------------- */
1060void
1061lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1062 tpPESession psessionEntry)
1063{
1064 tSirMsgQ mmhMsg;
1065 tSirSmeDisassocInd *pSirSmeDisassocInd;
1066
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301067 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 if (NULL == pSirSmeDisassocInd) {
1069 lim_log(pMac, LOGP,
1070 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1071 return;
1072 }
1073
1074 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1075 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1076
1077 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1078 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
1079 pSirSmeDisassocInd->statusCode = pStaDs->mlmStaContext.disassocReason;
1080 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1081
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301082 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301083 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301085 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301086 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087
1088 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1089
1090 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1091 mmhMsg.bodyptr = pSirSmeDisassocInd;
1092 mmhMsg.bodyval = 0;
1093
1094 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1095#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1096 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1097 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1098#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1099
1100 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1101
1102} /*** end lim_send_sme_disassoc_ind() ***/
1103
1104/** -----------------------------------------------------------------
1105 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1106
1107 After receiving deauthentication frame from peer entity, this
1108 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1109 reason code.
1110
1111 \param pMac - global mac structure
1112 \param pStaDs - station dph hash node
1113 \return none
1114 \sa
1115 ----------------------------------------------------------------- */
1116void
1117lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1118 tpPESession psessionEntry)
1119{
1120 tSirMsgQ mmhMsg;
1121 tSirSmeDeauthInd *pSirSmeDeauthInd;
1122
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301123 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 if (NULL == pSirSmeDeauthInd) {
1125 lim_log(pMac, LOGP,
1126 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1127 return;
1128 }
1129
1130 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1131 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1132
1133 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1134 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1135 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1136 pSirSmeDeauthInd->statusCode =
1137 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1138 } else {
1139 /* Need to indicatet he reascon code over the air */
1140 pSirSmeDeauthInd->statusCode =
1141 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1142 }
1143 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301144 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301145 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301147 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301148 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1150
1151 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001152 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1153 pStaDs->mlmStaContext.disassocReason)
1154 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155
1156 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1157 mmhMsg.bodyptr = pSirSmeDeauthInd;
1158 mmhMsg.bodyval = 0;
1159
1160 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1161#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1162 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1163 0, pStaDs->mlmStaContext.cleanupTrigger);
1164#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1165
1166 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1167 return;
1168} /*** end lim_send_sme_deauth_ind() ***/
1169
1170#ifdef FEATURE_WLAN_TDLS
1171/**
1172 * lim_send_sme_tdls_del_sta_ind()
1173 *
1174 ***FUNCTION:
1175 * This function is called to send the TDLS STA context deletion to SME.
1176 *
1177 ***LOGIC:
1178 *
1179 ***ASSUMPTIONS:
1180 *
1181 ***NOTE:
1182 * NA
1183 *
1184 * @param pMac - Pointer to global MAC structure
1185 * @param pStaDs - Pointer to internal STA Datastructure
1186 * @param psessionEntry - Pointer to the session entry
1187 * @param reasonCode - Reason for TDLS sta deletion
1188 * @return None
1189 */
1190void
1191lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1192 tpPESession psessionEntry, uint16_t reasonCode)
1193{
1194 tSirMsgQ mmhMsg;
1195 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1196
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301197 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 if (NULL == pSirTdlsDelStaInd) {
1199 lim_log(pMac, LOGP,
1200 FL
1201 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1202 return;
1203 }
1204 /* messageType */
1205 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1206 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1207
1208 /* sessionId */
1209 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1210
1211 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301212 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301213 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214
1215 /* staId */
1216 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1217 (uint16_t) pStaDs->staIndex);
1218
1219 /* reasonCode */
1220 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1221
1222 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1223 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1224 mmhMsg.bodyval = 0;
1225
1226 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1227 return;
1228} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1229
1230/**
1231 * lim_send_sme_tdls_delete_all_peer_ind()
1232 *
1233 ***FUNCTION:
1234 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1235 * message to SME.
1236 *
1237 ***LOGIC:
1238 *
1239 ***ASSUMPTIONS:
1240 *
1241 ***NOTE:
1242 * NA
1243 *
1244 * @param pMac - Pointer to global MAC structure
1245 * @param psessionEntry - Pointer to the session entry
1246 * @return None
1247 */
1248void
1249lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1250{
1251 tSirMsgQ mmhMsg;
1252 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1253
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301254 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255 if (NULL == pSirTdlsDelAllPeerInd) {
1256 lim_log(pMac, LOGP,
1257 FL
1258 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1259 return;
1260 }
1261 /* messageType */
1262 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1263 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1264
1265 /* sessionId */
1266 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1267
1268 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1269 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1270 mmhMsg.bodyval = 0;
1271
1272 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1273 return;
1274} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1275
1276/**
1277 * lim_send_sme_mgmt_tx_completion()
1278 *
1279 ***FUNCTION:
1280 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1281 * message to SME.
1282 *
1283 ***LOGIC:
1284 *
1285 ***ASSUMPTIONS:
1286 *
1287 ***NOTE:
1288 * NA
1289 *
1290 * @param pMac - Pointer to global MAC structure
1291 * @param psessionEntry - Pointer to the session entry
1292 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1293 * @return None
1294 */
1295void
1296lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
1297 tpPESession psessionEntry, uint32_t txCompleteStatus)
1298{
1299 tSirMsgQ mmhMsg;
1300 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1301
1302 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301303 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 if (NULL == pSirMgmtTxCompletionInd) {
1305 lim_log(pMac, LOGP,
1306 FL
1307 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1308 return;
1309 }
1310 /* messageType */
1311 pSirMgmtTxCompletionInd->messageType =
1312 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1313 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1314
1315 /* sessionId */
1316 pSirMgmtTxCompletionInd->sessionId = psessionEntry->smeSessionId;
1317
1318 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1319
1320 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1321 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1322 mmhMsg.bodyval = 0;
1323
1324 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1325 return;
1326} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1327
1328void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1329 void *events)
1330{
1331 tSirMsgQ mmhMsg;
1332
1333 switch (msgType) {
1334 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1335 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1336 break;
1337 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1338 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1339 break;
1340 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1341 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1342 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001343 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1344 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1345 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 }
1347
1348 mmhMsg.bodyptr = events;
1349 mmhMsg.bodyval = 0;
1350 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1351 return;
1352}
1353#endif /* FEATURE_WLAN_TDLS */
1354
1355/**
1356 * lim_send_sme_deauth_ntf()
1357 *
1358 ***FUNCTION:
1359 * This function is called by limProcessSmeMessages() to send
1360 * eWNI_SME_DISASSOC_RSP/IND message to host
1361 *
1362 ***PARAMS:
1363 *
1364 ***LOGIC:
1365 *
1366 ***ASSUMPTIONS:
1367 * NA
1368 *
1369 ***NOTE:
1370 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1371 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1372 *
1373 * @param peerMacAddr Indicates the peer MAC addr to which
1374 * deauthentication was initiated
1375 * @param reasonCode Indicates the reason for Deauthetication
1376 * @param deauthTrigger Indicates the trigger for Deauthetication
1377 * @param aid Indicates the STAID. This parameter is present
1378 * only on AP.
1379 *
1380 * @return None
1381 */
1382void
1383lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1384 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1385 uint16_t aid, uint8_t smesessionId,
1386 uint16_t smetransactionId)
1387{
1388 uint8_t *pBuf;
1389 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1390 tSirSmeDeauthInd *pSirSmeDeauthInd;
1391 tpPESession psessionEntry;
1392 uint8_t sessionId;
1393 uint32_t *pMsg;
1394
1395 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1396 switch (deauthTrigger) {
1397 case eLIM_PEER_ENTITY_DEAUTH:
1398 return;
1399
1400 case eLIM_HOST_DEAUTH:
1401 /**
1402 * Deauthentication response to host triggered
1403 * deauthentication.
1404 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301405 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 if (NULL == pSirSmeDeauthRsp) {
1407 /* Log error */
1408 lim_log(pMac, LOGP,
1409 FL
1410 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1411
1412 return;
1413 }
1414 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1415 "retCode: %d for" MAC_ADDRESS_STR),
1416 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1417 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1418 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1419 pSirSmeDeauthRsp->statusCode = reasonCode;
1420 pSirSmeDeauthRsp->sessionId = smesessionId;
1421 pSirSmeDeauthRsp->transactionId = smetransactionId;
1422
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001423 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301424 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425
1426#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1427 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1428 psessionEntry, 0, (uint16_t) reasonCode);
1429#endif
1430 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1431
1432 break;
1433
1434 default:
1435 /**
1436 * Deauthentication indication due to Deauthentication
1437 * frame reception from peer entity or due to
1438 * loss of link with peer entity.
1439 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301440 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 if (NULL == pSirSmeDeauthInd) {
1442 /* Log error */
1443 lim_log(pMac, LOGP,
1444 FL
1445 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1446
1447 return;
1448 }
1449 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1450 "retCode: %d for " MAC_ADDRESS_STR),
1451 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1452 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1453 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1454 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1455
1456 /* sessionId */
1457 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1458 *pBuf++ = smesessionId;
1459
1460 /* transaction ID */
1461 lim_copy_u16(pBuf, smetransactionId);
1462 pBuf += sizeof(uint16_t);
1463
1464 /* status code */
1465 lim_copy_u32(pBuf, reasonCode);
1466 pBuf += sizeof(tSirResultCodes);
1467
1468 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301469 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 pBuf += sizeof(tSirMacAddr);
1471
1472 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301473 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301474 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475
1476#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1477 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1478 psessionEntry, 0, (uint16_t) reasonCode);
1479#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1480 pMsg = (uint32_t *) pSirSmeDeauthInd;
1481
1482 break;
1483 }
1484
1485 /*Delete the PE session created */
1486 if (psessionEntry != NULL) {
1487 pe_delete_session(pMac, psessionEntry);
1488 }
1489
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301490 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 (uint32_t *) pMsg);
1492
1493} /*** end lim_send_sme_deauth_ntf() ***/
1494
1495/**
1496 * lim_send_sme_wm_status_change_ntf() - Send Notification
1497 * @mac_ctx: Global MAC Context
1498 * @status_change_code: Indicates the change in the wireless medium.
1499 * @status_change_info: Indicates the information associated with
1500 * change in the wireless medium.
1501 * @info_len: Indicates the length of status change information
1502 * being sent.
1503 * @session_id SessionID
1504 *
1505 * This function is called by limProcessSmeMessages() to send
1506 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1507 *
1508 * Return: None
1509 */
1510void
1511lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1512 tSirSmeStatusChangeCode status_change_code,
1513 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1514{
1515 tSirMsgQ msg;
1516 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
1517
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301518 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 if (NULL == wm_status_change_ntf) {
1520 lim_log(mac_ctx, LOGE,
1521 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1522 return;
1523 }
1524
1525 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1526 msg.bodyval = 0;
1527 msg.bodyptr = wm_status_change_ntf;
1528
1529 switch (status_change_code) {
1530 case eSIR_SME_RADAR_DETECTED:
1531 break;
1532 default:
1533 wm_status_change_ntf->messageType =
1534 eWNI_SME_WM_STATUS_CHANGE_NTF;
1535 wm_status_change_ntf->statusChangeCode = status_change_code;
1536 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1537 wm_status_change_ntf->sessionId = session_id;
1538 if (sizeof(wm_status_change_ntf->statusChangeInfo) >=
1539 info_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301540 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1542 (uint8_t *) status_change_info, info_len);
1543 }
1544 lim_log(mac_ctx, LOGE,
1545 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1546 status_change_code, info_len);
1547 break;
1548 }
1549
1550 MTRACE(mac_trace_msg_tx(mac_ctx, session_id, msg.type));
1551 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301552 qdf_mem_free(wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 lim_log(mac_ctx, LOGP,
1554 FL("lim_sys_process_mmh_msg_api failed"));
1555 }
1556
1557} /*** end lim_send_sme_wm_status_change_ntf() ***/
1558
1559/**
1560 * lim_send_sme_set_context_rsp()
1561 *
1562 ***FUNCTION:
1563 * This function is called by limProcessSmeMessages() to send
1564 * eWNI_SME_SETCONTEXT_RSP message to host
1565 *
1566 ***PARAMS:
1567 *
1568 ***LOGIC:
1569 *
1570 ***ASSUMPTIONS:
1571 * NA
1572 *
1573 ***NOTE:
1574 *
1575 * @param pMac Pointer to Global MAC structure
1576 * @param peerMacAddr Indicates the peer MAC addr to which
1577 * setContext was performed
1578 * @param aid Indicates the aid corresponding to the peer MAC
1579 * address
1580 * @param resultCode Indicates the result of previously issued
1581 * eWNI_SME_SETCONTEXT_RSP message
1582 *
1583 * @return None
1584 */
1585void
1586lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301587 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 tSirResultCodes resultCode,
1589 tpPESession psessionEntry, uint8_t smesessionId,
1590 uint16_t smetransactionId)
1591{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 tSirMsgQ mmhMsg;
1593 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1594
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301595 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 if (NULL == pSirSmeSetContextRsp) {
1597 /* Log error */
1598 lim_log(pMac, LOGP,
1599 FL
1600 ("call to AllocateMemory failed for SmeSetContextRsp"));
1601
1602 return;
1603 }
1604
1605 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1606 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1607 pSirSmeSetContextRsp->statusCode = resultCode;
1608
Anurag Chouhanc5548422016-02-24 18:33:27 +05301609 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610
1611 /* Update SME session and transaction Id */
1612 pSirSmeSetContextRsp->sessionId = smesessionId;
1613 pSirSmeSetContextRsp->transactionId = smetransactionId;
1614
1615 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1616 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1617 mmhMsg.bodyval = 0;
1618 if (NULL == psessionEntry) {
1619 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1620 } else {
1621 MTRACE(mac_trace_msg_tx
1622 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1623 }
1624
1625#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1626 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1627 psessionEntry, (uint16_t) resultCode, 0);
1628#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1629
1630 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1631} /*** end lim_send_sme_set_context_rsp() ***/
1632
1633/**
1634 * lim_send_sme_neighbor_bss_ind()
1635 *
1636 ***FUNCTION:
1637 * This function is called by lim_lookup_nadd_hash_entry() to send
1638 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1639 *
1640 ***PARAMS:
1641 *
1642 ***LOGIC:
1643 *
1644 ***ASSUMPTIONS:
1645 * NA
1646 *
1647 ***NOTE:
1648 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1649 * host upon detecting new BSS during background scanning if CFG
1650 * option is enabled for sending such indication
1651 *
1652 * @param pMac - Pointer to Global MAC structure
1653 * @return None
1654 */
1655
1656void
1657lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1658{
1659 tSirMsgQ msgQ;
1660 uint32_t val;
1661 tSirSmeNeighborBssInd *pNewBssInd;
1662
1663 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1664 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1665 pMac->lim.gLimRspReqd)) {
1666 /* LIM is not in background scan state OR */
1667 /* current scan is initiated by HDD. */
1668 /* No need to send new BSS indication to HDD */
1669 return;
1670 }
1671
1672 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1673 eSIR_SUCCESS) {
1674 lim_log(pMac, LOGP,
1675 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1676
1677 return;
1678 }
1679
1680 if (val == 0)
1681 return;
1682
1683 /**
1684 * Need to indicate new BSSs found during
1685 * background scanning to host.
1686 * Allocate buffer for sending indication.
1687 * Length of buffer is length of BSS description
1688 * and length of header itself
1689 */
1690 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1691 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301692 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 if (NULL == pNewBssInd) {
1694 /* Log error */
1695 lim_log(pMac, LOGP,
1696 FL
1697 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1698
1699 return;
1700 }
1701
1702 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1703 pNewBssInd->length = (uint16_t) val;
1704 pNewBssInd->sessionId = 0;
1705
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301706 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 (uint8_t *) &pBssDescr->bssDescription,
1708 pBssDescr->bssDescription.length + sizeof(uint16_t));
1709
1710 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1711 msgQ.bodyptr = pNewBssInd;
1712 msgQ.bodyval = 0;
1713 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
1714 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1715} /*** end lim_send_sme_neighbor_bss_ind() ***/
1716
1717/** -----------------------------------------------------------------
1718 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1719 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1720 \ SME only looks at rc and tspec field.
1721 \param pMac - global mac structure
1722 \param rspReqd - is SmeAddTsRsp required
1723 \param status - status code of SME_ADD_TS_RSP
1724 \return tspec
1725 \sa
1726 ----------------------------------------------------------------- */
1727void
1728lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1729 tpPESession psessionEntry, tSirMacTspecIE tspec,
1730 uint8_t smesessionId, uint16_t smetransactionId)
1731{
1732 tpSirAddtsRsp rsp;
1733 tSirMsgQ mmhMsg;
1734
1735 if (!rspReqd)
1736 return;
1737
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301738 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 if (NULL == rsp) {
1740 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1741 return;
1742 }
1743
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301744 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745 rsp->messageType = eWNI_SME_ADDTS_RSP;
1746 rsp->rc = status;
1747 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1748 rsp->rsp.tspec = tspec;
1749 /* Update SME session Id and transcation Id */
1750 rsp->sessionId = smesessionId;
1751 rsp->transactionId = smetransactionId;
1752
1753 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1754 mmhMsg.bodyptr = rsp;
1755 mmhMsg.bodyval = 0;
1756 if (NULL == psessionEntry) {
1757 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1758 } else {
1759 MTRACE(mac_trace_msg_tx
1760 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1761 }
1762#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1763 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1764 0);
1765#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1766
1767 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1768 return;
1769}
1770
1771void
1772lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1773 tpPESession psessionEntry, uint8_t smesessionId,
1774 uint16_t smetransactionId)
1775{
1776 tpSirDeltsRsp rsp;
1777 tSirMsgQ mmhMsg;
1778
1779 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1780 delts->aid,
1781 delts->req.tsinfo.traffic.tsid,
1782 delts->req.tsinfo.traffic.userPrio, status);
1783 if (!delts->rspReqd)
1784 return;
1785
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301786 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 if (NULL == rsp) {
1788 /* Log error */
1789 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1790 return;
1791 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301792 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793
1794 if (psessionEntry != NULL) {
1795
1796 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301797 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301798 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 sizeof(tSirDeltsReqInfo));
1800 }
1801
1802 rsp->messageType = eWNI_SME_DELTS_RSP;
1803 rsp->rc = status;
1804
1805 /* Update SME session Id and transcation Id */
1806 rsp->sessionId = smesessionId;
1807 rsp->transactionId = smetransactionId;
1808
1809 mmhMsg.type = eWNI_SME_DELTS_RSP;
1810 mmhMsg.bodyptr = rsp;
1811 mmhMsg.bodyval = 0;
1812 if (NULL == psessionEntry) {
1813 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1814 } else {
1815 MTRACE(mac_trace_msg_tx
1816 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1817 }
1818#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1819 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1820 (uint16_t) status, 0);
1821#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1822
1823 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1824}
1825
1826void
1827lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1828 tpPESession psessionEntry)
1829{
1830 tpSirDeltsRsp rsp;
1831 tSirMsgQ mmhMsg;
1832
1833 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1834 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1835
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301836 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 if (NULL == rsp) {
1838 /* Log error */
1839 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1840 return;
1841 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301842 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843
1844 rsp->messageType = eWNI_SME_DELTS_IND;
1845 rsp->rc = eSIR_SUCCESS;
1846 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301847 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848
1849 /* Update SME session Id and SME transaction Id */
1850
1851 rsp->sessionId = psessionEntry->smeSessionId;
1852 rsp->transactionId = psessionEntry->transactionId;
1853
1854 mmhMsg.type = eWNI_SME_DELTS_IND;
1855 mmhMsg.bodyptr = rsp;
1856 mmhMsg.bodyval = 0;
1857 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1858#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1859 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1860 0);
1861#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1862
1863 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1864}
1865
1866/**
1867 * lim_send_sme_pe_statistics_rsp()
1868 *
1869 ***FUNCTION:
1870 * This function is called to send 802.11 statistics response to HDD.
1871 * This function posts the result back to HDD. This is a response to
1872 * HDD's request for statistics.
1873 *
1874 ***PARAMS:
1875 *
1876 ***LOGIC:
1877 *
1878 ***ASSUMPTIONS:
1879 * NA
1880 *
1881 ***NOTE:
1882 * NA
1883 *
1884 * @param pMac Pointer to Global MAC structure
1885 * @param p80211Stats Statistics sent in response
1886 * @param resultCode TODO:
1887 *
1888 *
1889 * @return none
1890 */
1891
1892void
1893lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1894{
1895 tSirMsgQ mmhMsg;
1896 uint8_t sessionId;
1897 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1898 tpPESession pPeSessionEntry;
1899
1900 /* Get the Session Id based on Sta Id */
1901 pPeSessionEntry =
1902 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1903
1904 /* Fill the Session Id */
1905 if (NULL != pPeSessionEntry) {
1906 /* Fill the Session Id */
1907 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1908 }
1909
1910 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1911
1912 /* msgType should be WMA_GET_STATISTICS_RSP */
1913 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1914
1915 mmhMsg.bodyptr = stats;
1916 mmhMsg.bodyval = 0;
1917 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1918 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1919
1920 return;
1921
1922} /*** end lim_send_sme_pe_statistics_rsp() ***/
1923
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001924#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001926 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1927 * @pMac: Pointer to global pMac structure
1928 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 * This function is called to send tsm stats response to HDD.
1931 * This function posts the result back to HDD. This is a response to
1932 * HDD's request to get tsm stats.
1933 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001934 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001936void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1937 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938{
1939 tSirMsgQ mmhMsg;
1940 uint8_t sessionId;
1941 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1942 tpPESession pPeSessionEntry = NULL;
1943
1944 /* Get the Session Id based on Sta Id */
1945 pPeSessionEntry =
1946 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1947
1948 /* Fill the Session Id */
1949 if (NULL != pPeSessionEntry) {
1950 /* Fill the Session Id */
1951 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1952 } else {
1953 PELOGE(lim_log
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001954 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1955 pPeStats->staId);)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 return;
1957 }
1958
1959 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1960 pPeStats->tsmMetrics.RoamingCount
1961 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1962 pPeStats->tsmMetrics.RoamingDly
1963 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1964
1965 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1966 mmhMsg.bodyptr = pStats;
1967 mmhMsg.bodyval = 0;
1968 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
1969 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1970
1971 return;
1972} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1973
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001974#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975
1976void
1977lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1978 tSirMacAddr peerMacAddr,
1979 uint16_t staIndex,
1980 uint8_t ucastIdx,
1981 uint8_t bcastIdx,
1982 uint8_t *beacon,
1983 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1984{
1985 tSirMsgQ mmhMsg;
1986 tSmeIbssPeerInd *pNewPeerInd;
1987
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301988 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 if (NULL == pNewPeerInd) {
1990 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
1991 return;
1992 }
1993
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301994 qdf_mem_set((void *)pNewPeerInd, (sizeof(tSmeIbssPeerInd) + beaconLen),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 0);
1996
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301997 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301998 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 pNewPeerInd->staId = staIndex;
2000 pNewPeerInd->ucastSig = ucastIdx;
2001 pNewPeerInd->bcastSig = bcastIdx;
2002 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
2003 pNewPeerInd->mesgType = msgType;
2004 pNewPeerInd->sessionId = sessionId;
2005
2006 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302007 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2009 beaconLen);
2010 }
2011
2012 mmhMsg.type = msgType;
2013 mmhMsg.bodyptr = pNewPeerInd;
2014 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
2015 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2016
2017}
2018
2019/**
2020 * lim_handle_csa_offload_msg() - Handle CSA offload message
2021 * @mac_ctx: pointer to global adapter context
2022 * @msg: Message pointer.
2023 *
2024 * Return: None
2025 */
2026void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
2027{
2028 tpPESession session_entry;
2029 tSirMsgQ mmh_msg;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302030 struct csa_offload_params *csa_params =
2031 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 tpSmeCsaOffloadInd csa_offload_ind;
2033 tpDphHashNode sta_ds = NULL;
2034 uint8_t session_id;
2035 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302036 uint16_t chan_space = 0;
Amar Singhale4f28ee2015-10-21 14:36:56 -07002037 struct ch_params_s ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302038
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002040 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302042 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2043
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 if (!csa_params) {
2045 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2046 return;
2047 }
2048
2049 session_entry =
2050 pe_find_session_by_bssid(mac_ctx,
2051 csa_params->bssId, &session_id);
2052 if (!session_entry) {
2053 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302054 FL("Session does not exists for %pM"),
2055 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 goto err;
2057 }
2058
2059 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2060 &session_entry->dph.dphHashTable);
2061
2062 if (!sta_ds) {
2063 lim_log(mac_ctx, LOGE,
2064 FL("sta_ds does not exist"));
2065 goto err;
2066 }
2067
2068 if (LIM_IS_STA_ROLE(session_entry)) {
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302069 /*
2070 * on receiving channel switch announcement from AP, delete all
2071 * TDLS peers before leaving BSS and proceed for channel switch
2072 */
2073 lim_delete_tdls_peers(mac_ctx, session_entry);
2074
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002075 lim_ch_switch = &session_entry->gLimChannelSwitch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 session_entry->gLimChannelSwitch.switchMode =
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302077 csa_params->switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 /* timer already started by firmware, switch immediately */
2079 session_entry->gLimChannelSwitch.switchCount = 0;
2080 session_entry->gLimChannelSwitch.primaryChannel =
2081 csa_params->channel;
2082 session_entry->gLimChannelSwitch.state =
2083 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2084 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002085 lim_ch_switch->sec_ch_offset =
2086 session_entry->htSecondaryChannelOffset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302087 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2088 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2089 chnl_switch_info =
2090 &session_entry->gLimWiderBWChannelSwitch;
2091
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302092 lim_log(mac_ctx, LOG1,
2093 FL("vht:%d ht:%d flag:%x chan:%d seg1:%d seg2:%d width:%d country:%s class:%d"),
2094 session_entry->vhtCapability,
2095 session_entry->htSupportedChannelWidthSet,
2096 csa_params->ies_present_flag,
2097 csa_params->channel, csa_params->new_ch_freq_seg1,
2098 csa_params->new_ch_freq_seg2,
2099 csa_params->new_ch_width,
2100 mac_ctx->scan.countryCodeCurrent,
2101 csa_params->new_op_class);
2102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 if (session_entry->vhtCapability &&
2104 session_entry->htSupportedChannelWidthSet) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
2106 chnl_switch_info->newChanWidth =
2107 csa_params->new_ch_width;
2108 chnl_switch_info->newCenterChanFreq0 =
2109 csa_params->new_ch_freq_seg1;
2110 chnl_switch_info->newCenterChanFreq1 =
2111 csa_params->new_ch_freq_seg2;
2112 session_entry->gLimChannelSwitch.state =
2113 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2114 session_entry->gLimChannelSwitch.ch_width =
2115 csa_params->new_ch_width + 1;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302116 } else if (csa_params->ies_present_flag
2117 & lim_xcsa_ie_present) {
2118 chan_space =
Amar Singhal22995112016-01-22 10:42:33 -08002119 cds_reg_dmn_get_chanwidth_from_opclass(
Gupta, Kapil121bf212015-11-25 19:21:29 +05302120 mac_ctx->scan.countryCodeCurrent,
2121 csa_params->channel,
2122 csa_params->new_op_class);
2123 session_entry->gLimChannelSwitch.state =
2124 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2125
2126 if (chan_space == 80) {
2127 chnl_switch_info->newChanWidth =
2128 CH_WIDTH_80MHZ;
2129 } else if (chan_space == 40) {
2130 chnl_switch_info->newChanWidth =
2131 CH_WIDTH_40MHZ;
2132 } else {
2133 chnl_switch_info->newChanWidth =
2134 CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002135 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302136 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2137 }
2138
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002139 ch_params.ch_width =
2140 chnl_switch_info->newChanWidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002141 cds_set_channel_params(csa_params->channel,
2142 0, &ch_params);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302143 chnl_switch_info->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002144 ch_params.center_freq_seg0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302145 /*
2146 * This is not applicable for 20/40/80 MHz.
2147 * Only used when we support 80+80 MHz operation.
2148 * In case of 80+80 MHz, this parameter indicates
2149 * center channel frequency index of 80 MHz
2150 * channel offrequency segment 1.
2151 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002152 chnl_switch_info->newCenterChanFreq1 =
2153 ch_params.center_freq_seg1;
2154 lim_ch_switch->sec_ch_offset =
2155 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 }
Gupta, Kapil121bf212015-11-25 19:21:29 +05302158 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2159 chnl_switch_info->newCenterChanFreq0;
2160 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2161 chnl_switch_info->newCenterChanFreq1;
2162 session_entry->gLimChannelSwitch.ch_width =
2163 chnl_switch_info->newChanWidth;
2164
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 } else if (session_entry->htSupportedChannelWidthSet) {
Gupta, Kapil121bf212015-11-25 19:21:29 +05302166 if (csa_params->ies_present_flag
2167 & lim_xcsa_ie_present) {
2168 chan_space =
Amar Singhal22995112016-01-22 10:42:33 -08002169 cds_reg_dmn_get_chanwidth_from_opclass(
Gupta, Kapil121bf212015-11-25 19:21:29 +05302170 mac_ctx->scan.countryCodeCurrent,
2171 csa_params->channel,
2172 csa_params->new_op_class);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002173 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302174 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2175 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002176 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302177 CH_WIDTH_40MHZ;
2178 chnl_switch_info->newChanWidth =
2179 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002180 ch_params.ch_width =
2181 chnl_switch_info->newChanWidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002182 cds_set_channel_params(
2183 csa_params->channel,
2184 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002185 lim_ch_switch->ch_center_freq_seg0 =
2186 ch_params.center_freq_seg0;
2187 lim_ch_switch->sec_ch_offset =
2188 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302189 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002190 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302191 CH_WIDTH_20MHZ;
2192 chnl_switch_info->newChanWidth =
2193 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002194 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302195 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002196 lim_ch_switch->sec_ch_offset =
2197 PHY_SINGLE_CHANNEL_CENTERED;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302198 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002200 lim_ch_switch->ch_width =
2201 CH_WIDTH_40MHZ;
2202 lim_ch_switch->state =
2203 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2204 ch_params.ch_width = CH_WIDTH_40MHZ;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002205 cds_set_channel_params(csa_params->channel,
2206 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002207 lim_ch_switch->ch_center_freq_seg0 =
2208 ch_params.center_freq_seg0;
2209 lim_ch_switch->sec_ch_offset =
2210 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 }
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 }
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302214 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
2215 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216
2217 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302218 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219 if (NULL == csa_offload_ind) {
2220 lim_log(mac_ctx, LOGE,
2221 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
2222 goto err;
2223 }
2224
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302225 qdf_mem_set(csa_offload_ind, sizeof(tSmeCsaOffloadInd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2227 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302228 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302229 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2231 mmh_msg.bodyptr = csa_offload_ind;
2232 mmh_msg.bodyval = 0;
2233 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002234 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 MTRACE(mac_trace_msg_tx
2236 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2237#ifdef FEATURE_WLAN_DIAG_SUPPORT
2238 lim_diag_event_report(mac_ctx,
2239 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2240 eSIR_SUCCESS, eSIR_SUCCESS);
2241#endif
2242 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
2243 }
2244
2245err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302246 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247}
2248
2249/*--------------------------------------------------------------------------
2250 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2251
2252 \param pMac - pointer to global adapter context
2253 \param sessionId - Message pointer.
2254
2255 \sa
2256 --------------------------------------------------------------------------*/
2257
2258void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ MsgQ)
2259{
2260 tpPESession psessionEntry;
2261 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2262
2263 psessionEntry =
2264 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2265 if (psessionEntry == NULL) {
2266 lim_log(pMac, LOGE,
2267 FL("Session Does not exist for given sessionID %d"),
2268 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002269 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 return;
2271 }
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002272 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002274 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002276 else if (LIM_IS_NDI_ROLE(psessionEntry))
2277 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278 else
2279 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2280
2281}
2282
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283/** -----------------------------------------------------------------
2284 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2285 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2286 \ SME only looks at rc and tspec field.
2287 \param pMac - global mac structure
2288 \param rspReqd - is SmeAddTsRsp required
2289 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2290 \return tspec
2291 \sa
2292 ----------------------------------------------------------------- */
2293void
2294lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2295 uint8_t smesessionId)
2296{
2297 tSirMsgQ mmhMsg;
2298
2299 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2300 mmhMsg.bodyptr = aggrQosRsp;
2301 mmhMsg.bodyval = 0;
2302 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2303 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2304
2305 return;
2306}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307
2308void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2309 uint8_t smesessionId)
2310{
2311 tSirMsgQ mmhMsg;
2312 tSmeMaxAssocInd *pSmeMaxAssocInd;
2313
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302314 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 if (NULL == pSmeMaxAssocInd) {
2316 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2317 return;
2318 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302319 qdf_mem_set((void *)pSmeMaxAssocInd, sizeof(tSmeMaxAssocInd), 0);
2320 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302321 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2323 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2324 pSmeMaxAssocInd->sessionId = smesessionId;
2325 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2326 mmhMsg.bodyptr = pSmeMaxAssocInd;
2327 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2328 " sme session id %d"),
2329 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2330 MAC_ADDR_ARRAY(peerMacAddr));
2331 )
2332 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2333 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2334
2335 return;
2336}
2337
2338/** -----------------------------------------------------------------
2339 \brief lim_send_sme_dfs_event_notify() - sends
2340 eWNI_SME_DFS_RADAR_FOUND
2341 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2342 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2343 that a RADAR is found on current operating channel and SAP-
2344 has to move to a new channel.
2345 \param pMac - global mac structure
2346 \param msgType - message type received from lower layer
2347 \param event - event data received from lower layer
2348 \return none
2349 \sa
2350 ----------------------------------------------------------------- */
2351void
2352lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2353{
2354 tSirMsgQ mmhMsg;
2355 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2356 mmhMsg.bodyptr = event;
2357 mmhMsg.bodyval = 0;
2358 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2359 return;
2360}
2361
2362/*--------------------------------------------------------------------------
2363 \brief lim_send_dfs_chan_sw_ie_update()
2364 This timer handler updates the channel switch IE in beacon template
2365
2366 \param pMac - pointer to global adapter context
2367 \return - channel to scan from valid session else zero.
2368 \sa
2369 --------------------------------------------------------------------------*/
2370static void
2371lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2372{
2373
2374 /* Update the beacon template and send to FW */
2375 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2376 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2377 return;
2378 }
2379
2380 /* Send update beacon template message */
2381 lim_send_beacon_ind(pMac, psessionEntry);
2382 PELOG1(lim_log(pMac, LOG1,
2383 FL(" Updated CSA IE, IE COUNT = %d"),
2384 psessionEntry->gLimChannelSwitch.switchCount);
2385 )
2386
2387 return;
2388}
2389
2390/** -----------------------------------------------------------------
2391 \brief lim_send_sme_ap_channel_switch_resp() - sends
2392 eWNI_SME_CHANNEL_CHANGE_RSP
2393 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2394 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2395 that the Channel change has been done to the specified target
2396 channel in the Channel change request
2397 \param pMac - global mac structure
2398 \param psessionEntry - session info
2399 \param pChnlParams - Channel switch params
2400 --------------------------------------------------------------------*/
2401void
2402lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2403 tpPESession psessionEntry,
2404 tpSwitchChannelParams pChnlParams)
2405{
2406 tSirMsgQ mmhMsg;
2407 tpSwitchChannelParams pSmeSwithChnlParams;
2408 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002409 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002410 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002411 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412
2413 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302414 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 if (NULL == pSmeSwithChnlParams) {
2416 lim_log(pMac, LOGP,
2417 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2418 return;
2419 }
2420
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302421 qdf_mem_set((void *)pSmeSwithChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422 sizeof(tSwitchChannelParams), 0);
2423
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302424 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 sizeof(tSwitchChannelParams));
2426
2427 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002428 ch_width = pSmeSwithChnlParams->ch_width;
2429 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430
2431 /*
2432 * Pass the sme sessionID to SME instead
2433 * PE session ID.
2434 */
2435 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2436
2437 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2438 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2439 mmhMsg.bodyval = 0;
2440 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2441
2442 /*
2443 * We should start beacon transmission only if the new
2444 * channel after channel change is Non-DFS. For a DFS
2445 * channel, PE will receive an explicit request from
2446 * upper layers to start the beacon transmission .
2447 */
2448
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002449 if (ch_width == CH_WIDTH_160MHZ) {
2450 is_ch_dfs = true;
2451 } else if (ch_width == CH_WIDTH_80P80MHZ) {
2452 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
2453 cds_get_channel_state(ch_center_freq_seg1 -
2454 SIR_80MHZ_START_CENTER_CH_DIFF) ==
2455 CHANNEL_STATE_DFS)
2456 is_ch_dfs = true;
2457 } else {
2458 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
2459 is_ch_dfs = true;
2460 }
2461
2462 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 if (channelId == psessionEntry->currentOperChannel) {
2464 lim_apply_configuration(pMac, psessionEntry);
2465 lim_send_beacon_ind(pMac, psessionEntry);
2466 } else {
2467 PELOG1(lim_log(pMac, LOG1,
2468 FL
2469 ("Failed to Transmit Beacons on channel = %d"
2470 "after AP channel change response"),
2471 psessionEntry->bcnLen);
2472 )
2473 }
2474 }
2475 return;
2476}
2477
2478/** -----------------------------------------------------------------
2479 \brief lim_process_beacon_tx_success_ind() - This function is used
2480 explicitely to handle successful beacon transmission indication
2481 from the FW. This is a generic event generated by the FW afer the
2482 first beacon is sent out after the beacon template update by the
2483 host
2484 \param pMac - global mac structure
2485 \param psessionEntry - session info
2486 \return none
2487 \sa
2488 ----------------------------------------------------------------- */
2489void
2490lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2491{
2492 /* Currently, this event is used only for DFS channel switch announcement
2493 * IE update in the template. If required to be used for other IE updates
2494 * add appropriate code by introducing a state variable
2495 */
2496 tpPESession psessionEntry;
2497 tSirMsgQ mmhMsg;
2498 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2499 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2500 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2501 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2502 (tSirFirstBeaconTxCompleteInd *) event;
2503
2504 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2505 if (psessionEntry == NULL) {
2506 lim_log(pMac, LOGE,
2507 FL("Session Does not exist for given sessionID"));
2508 return;
2509 }
2510
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302511 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2512 GET_LIM_SYSTEM_ROLE(psessionEntry),
2513 psessionEntry->dfsIncludeChanSwIe,
2514 psessionEntry->gLimOperatingMode.present);
2515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 if (LIM_IS_AP_ROLE(psessionEntry) &&
2517 true == psessionEntry->dfsIncludeChanSwIe) {
2518 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2519 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2520 /*
2521 * Send the next beacon with updated CSA IE count
2522 */
2523 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2524 /* Decrement the IE count */
2525 psessionEntry->gLimChannelSwitch.switchCount--;
2526 } else {
2527 /* Done with CSA IE update, send response back to SME */
2528 psessionEntry->gLimChannelSwitch.switchCount = 0;
2529 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2530 psessionEntry->gLimChannelSwitch.switchMode = 0;
2531 psessionEntry->dfsIncludeChanSwIe = false;
2532 psessionEntry->dfsIncludeChanWrapperIe = false;
2533
2534 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302535 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536
2537 if (NULL == pChanSwTxResponse) {
2538 lim_log(pMac, LOGP,
2539 FL
2540 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2541 return;
2542 }
2543
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302544 qdf_mem_set((void *)pChanSwTxResponse, length, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 pChanSwTxResponse->sessionId =
2546 psessionEntry->smeSessionId;
2547 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302548 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549
2550 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2551 mmhMsg.bodyptr = pChanSwTxResponse;
2552 mmhMsg.bodyval = 0;
2553 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2554 }
2555 }
2556
2557 if (LIM_IS_AP_ROLE(psessionEntry) &&
2558 psessionEntry->gLimOperatingMode.present) {
2559 /* Done with nss update, send response back to SME */
2560 psessionEntry->gLimOperatingMode.present = 0;
2561 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302562 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 if (NULL == beacon_tx_comp_rsp_ptr) {
2564 lim_log(pMac, LOGP,
2565 FL
2566 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2567 return;
2568 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302569 qdf_mem_set((void *)beacon_tx_comp_rsp_ptr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570 sizeof(*beacon_tx_comp_rsp_ptr), 0);
2571 beacon_tx_comp_rsp_ptr->session_id =
2572 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302573 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2575 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2576 mmhMsg.bodyval = 0;
2577 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2578 }
2579 return;
2580}