blob: eab94390b401eb1c634daec133c65b18c140a39f [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}
391/**
392 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
393 * @mac_ctx: Pointer to Global MAC structure
394 * @msg_type: Indicates message type
395 * @result_code: Indicates the result of previously issued
396 * eWNI_SME_msgType_REQ message
397 * @prot_status_code: Protocol Status Code
398 * @session_entry: PE Session Info
399 * @sme_session_id: SME Session ID
400 * @sme_transaction_id: SME Transaction ID
401 *
402 * This function is called by lim_process_sme_req_messages() to send
403 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
404 * above MAC Software.
405 *
406 * Return: None
407 */
408
409void
410lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
411 tSirResultCodes result_code, uint16_t prot_status_code,
412 tpPESession session_entry, uint8_t sme_session_id,
413 uint16_t sme_transaction_id)
414{
415 tpSirSmeJoinRsp sme_join_rsp;
416 uint32_t rsp_len;
417 tpDphHashNode sta_ds = NULL;
418#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
419 if (msg_type == eWNI_SME_REASSOC_RSP)
420 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
421 session_entry, (uint16_t) result_code, 0);
422 else
423 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
424 session_entry, (uint16_t) result_code, 0);
425#endif /* FEATURE_WLAN_DIAG_SUPPORT */
426
427 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
428 lim_msg_str(msg_type), lim_result_code_str(result_code));
429
430 if (session_entry == NULL) {
431 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530432 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433 if (NULL == sme_join_rsp) {
434 lim_log(mac_ctx, LOGP,
435 FL("Mem Alloc fail - JOIN/REASSOC_RSP"));
436 return;
437 }
438
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530439 qdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 sme_join_rsp->beaconLength = 0;
441 sme_join_rsp->assocReqLength = 0;
442 sme_join_rsp->assocRspLength = 0;
443 } else {
444 rsp_len = session_entry->assocReqLen +
445 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447#ifdef FEATURE_WLAN_ESE
448 session_entry->tspecLen +
449#endif
450 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530451 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452 if (NULL == sme_join_rsp) {
453 lim_log(mac_ctx, LOGP,
454 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
455 return;
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 if (result_code == eSIR_SME_SUCCESS) {
459 sta_ds = dph_get_hash_entry(mac_ctx,
460 DPH_STA_HASH_INDEX_PEER,
461 &session_entry->dph.dphHashTable);
462 if (sta_ds == NULL) {
463 lim_log(mac_ctx, LOGE,
464 FL("Get Self Sta Entry fail"));
465 } else {
466 /* Pass the peer's staId */
467 sme_join_rsp->staId = sta_ds->staIndex;
468 sme_join_rsp->ucastSig =
469 sta_ds->ucUcastSig;
470 sme_join_rsp->bcastSig =
471 sta_ds->ucBcastSig;
472 sme_join_rsp->timingMeasCap =
473 sta_ds->timingMeasCap;
474#ifdef FEATURE_WLAN_TDLS
475 sme_join_rsp->tdls_prohibited =
476 session_entry->tdls_prohibited;
477 sme_join_rsp->tdls_chan_swit_prohibited =
478 session_entry->tdls_chan_swit_prohibited;
479#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530480 sme_join_rsp->nss = sta_ds->nss;
481 sme_join_rsp->max_rate_flags =
482 lim_get_max_rate_flags(mac_ctx, sta_ds);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 }
484 }
485 sme_join_rsp->beaconLength = 0;
486 sme_join_rsp->assocReqLength = 0;
487 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489#ifdef FEATURE_WLAN_ESE
490 sme_join_rsp->tspecIeLen = 0;
491#endif
492
493 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
494 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800495
496 /* Send supported NSS 1x1 to SME */
497 sme_join_rsp->supported_nss_1x1 =
498 session_entry->supported_nss_1x1;
499 lim_log(mac_ctx, LOG1,
500 FL("SME Join Rsp is supported NSS 1X1: %d"),
501 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 }
503
504 sme_join_rsp->messageType = msg_type;
505 sme_join_rsp->length = (uint16_t) rsp_len;
506 sme_join_rsp->statusCode = result_code;
507 sme_join_rsp->protStatusCode = prot_status_code;
508
509 sme_join_rsp->sessionId = sme_session_id;
510 sme_join_rsp->transactionId = sme_transaction_id;
511
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530512 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513 (uint32_t *)sme_join_rsp);
514}
515
516/**
517 * lim_send_sme_start_bss_rsp()
518 *
519 ***FUNCTION:
520 * This function is called to send eWNI_SME_START_BSS_RSP
521 * message to applications above MAC Software.
522 *
523 ***PARAMS:
524 *
525 ***LOGIC:
526 *
527 ***ASSUMPTIONS:
528 * NA
529 *
530 ***NOTE:
531 * NA
532 *
533 * @param pMac Pointer to Global MAC structure
534 * @param msgType Indicates message type
535 * @param resultCode Indicates the result of previously issued
536 * eWNI_SME_msgType_REQ message
537 *
538 * @return None
539 */
540
541void
542lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
543 uint16_t msgType, tSirResultCodes resultCode,
544 tpPESession psessionEntry, uint8_t smesessionId,
545 uint16_t smetransactionId)
546{
547
548 uint16_t size = 0;
549 tSirMsgQ mmhMsg;
550 tSirSmeStartBssRsp *pSirSmeRsp;
551 uint16_t ieLen;
552 uint16_t ieOffset, curLen;
553
554 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
555 lim_msg_str(msgType), lim_result_code_str(resultCode));
556 )
557
558 size = sizeof(tSirSmeStartBssRsp);
559
560 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530561 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 if (NULL == pSirSmeRsp) {
563 /* / Buffer not available. Log error */
564 lim_log(pMac, LOGP,
565 FL
566 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
567 return;
568 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530569 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570
571 } else {
572 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
573 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
574 ieLen = psessionEntry->schBeaconOffsetBegin
575 + psessionEntry->schBeaconOffsetEnd - ieOffset;
576 /* calculate the memory size to allocate */
577 size += ieLen;
578
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
586 return;
587 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530588 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589 size = sizeof(tSirSmeStartBssRsp);
590 if (resultCode == eSIR_SME_SUCCESS) {
591
592 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
593 psessionEntry->bssId);
594
595 /* Read beacon interval from session */
596 pSirSmeRsp->bssDescription.beaconInterval =
597 (uint16_t) psessionEntry->beaconParams.
598 beaconInterval;
599 pSirSmeRsp->bssType = psessionEntry->bssType;
600
601 if (cfg_get_capability_info
602 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
603 psessionEntry)
604 != eSIR_SUCCESS)
605 lim_log(pMac, LOGP,
606 FL
607 ("could not retrieve Capabilities value"));
608
609 lim_get_phy_mode(pMac,
610 (uint32_t *) &pSirSmeRsp->bssDescription.
611 nwType, psessionEntry);
612
613 pSirSmeRsp->bssDescription.channelId =
614 psessionEntry->currentOperChannel;
615
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700616 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530618 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 ieFields,
620 psessionEntry->pSchBeaconFrameBegin +
621 ieOffset, (uint32_t) curLen);
622
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530623 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 ieFields) + curLen,
625 psessionEntry->pSchBeaconFrameEnd,
626 (uint32_t) psessionEntry->
627 schBeaconOffsetEnd);
628
629 /* subtracting size of length indicator itself and size of pointer to ieFields */
630 pSirSmeRsp->bssDescription.length =
631 sizeof(tSirBssDescription) - sizeof(uint16_t) -
632 sizeof(uint32_t) + ieLen;
633 /* This is the size of the message, subtracting the size of the pointer to ieFields */
634 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700635 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
637 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530638 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 pSirSmeRsp->HTProfile.
640 htSupportedChannelWidthSet =
641 psessionEntry->htSupportedChannelWidthSet;
642 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
643 psessionEntry->htRecommendedTxWidthSet;
644 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
645 psessionEntry->htSecondaryChannelOffset;
646 pSirSmeRsp->HTProfile.dot11mode =
647 psessionEntry->dot11mode;
648 pSirSmeRsp->HTProfile.htCapability =
649 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 pSirSmeRsp->HTProfile.vhtCapability =
651 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 pSirSmeRsp->HTProfile.apCenterChan =
653 psessionEntry->ch_center_freq_seg0;
654 pSirSmeRsp->HTProfile.apChanWidth =
655 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656 }
657#endif
658 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 pSirSmeRsp->messageType = msgType;
661 pSirSmeRsp->length = size;
662
663 /* Update SME session Id and transaction Id */
664 pSirSmeRsp->sessionId = smesessionId;
665 pSirSmeRsp->transactionId = smetransactionId;
666 pSirSmeRsp->statusCode = resultCode;
667 if (psessionEntry != NULL)
668 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
669
670 mmhMsg.type = msgType;
671 mmhMsg.bodyptr = pSirSmeRsp;
672 mmhMsg.bodyval = 0;
673 if (psessionEntry == NULL) {
674 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
675 } else {
676 MTRACE(mac_trace_msg_tx
677 (pMac, psessionEntry->peSessionId, mmhMsg.type));
678 }
679#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
680 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
681 psessionEntry, (uint16_t) resultCode, 0);
682#endif /* FEATURE_WLAN_DIAG_SUPPORT */
683
684 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
685} /*** end lim_send_sme_start_bss_rsp() ***/
686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687/**
688 * lim_send_sme_scan_rsp() - Send scan response to SME
689 * @pMac: Pointer to Global MAC structure
690 * @length: Indicates length of message
691 * @resultCode: Indicates the result of previously issued
692 * eWNI_SME_SCAN_REQ message
693 * @scan_id: scan identifier
694 *
695 * This function is called by lim_process_sme_req_messages() to send
696 * eWNI_SME_SCAN_RSP message to applications above MAC
697 *
698 * return: None
699 */
700
701void
702lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
703 uint8_t smesessionId, uint16_t smetranscationId,
704 uint32_t scan_id)
705{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
707 smetranscationId, scan_id);
708}
709
710/**
711 * lim_post_sme_scan_rsp_message()
712 *
713 ***FUNCTION:
714 * This function is called by lim_send_sme_scan_rsp() to send
715 * eWNI_SME_SCAN_RSP message with failed result code
716 *
717 ***NOTE:
718 * NA
719 *
720 * @param pMac Pointer to Global MAC structure
721 * @param length Indicates length of message
722 * @param resultCode failed result code
723 *
724 * @return None
725 */
726
727void
728lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
729 tSirResultCodes resultCode, uint8_t smesessionId,
730 uint16_t smetransactionId,
731 uint32_t scan_id)
732{
733 tpSirSmeScanRsp pSirSmeScanRsp;
734 tSirMsgQ mmhMsg;
735
736 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
737 lim_result_code_str(resultCode));
738
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530739 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 if (NULL == pSirSmeScanRsp) {
741 lim_log(pMac, LOGP,
742 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
743 return;
744 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530745 qdf_mem_set((void *)pSirSmeScanRsp, sizeof(tSirSmeScanRsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746
747 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
748 pSirSmeScanRsp->statusCode = resultCode;
749
750 /*Update SME session Id and transaction Id */
751 pSirSmeScanRsp->sessionId = smesessionId;
752 pSirSmeScanRsp->transcationId = smetransactionId;
753 pSirSmeScanRsp->scan_id = scan_id;
754
755 mmhMsg.type = eWNI_SME_SCAN_RSP;
756 mmhMsg.bodyptr = pSirSmeScanRsp;
757 mmhMsg.bodyval = 0;
758
759 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
760#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
761 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
762 (uint16_t) resultCode, 0);
763#endif /* FEATURE_WLAN_DIAG_SUPPORT */
764
765 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
766 return;
767
768} /*** lim_post_sme_scan_rsp_message ***/
769
770#ifdef FEATURE_OEM_DATA_SUPPORT
771
772/**
773 * lim_send_sme_oem_data_rsp()
774 *
775 ***FUNCTION:
776 * This function is called by lim_process_sme_req_messages() to send
777 * eWNI_SME_OEM_DATA_RSP message to applications above MAC
778 * Software.
779 *
780 ***PARAMS:
781 *
782 ***LOGIC:
783 *
784 ***ASSUMPTIONS:
785 * NA
786 *
787 ***NOTE:
788 * NA
789 *
790 * @param pMac Pointer to Global MAC structure
791 * @param pMsgBuf Indicates the mlm message
792 * @param resultCode Indicates the result of previously issued
793 * eWNI_SME_OEM_DATA_RSP message
794 *
795 * @return None
796 */
797
798void lim_send_sme_oem_data_rsp(tpAniSirGlobal pMac, uint32_t *pMsgBuf,
799 tSirResultCodes resultCode)
800{
801 tSirMsgQ mmhMsg;
802 tSirOemDataRsp *pSirSmeOemDataRsp = NULL;
803 tLimMlmOemDataRsp *pMlmOemDataRsp = NULL;
804 uint16_t msgLength;
805
806 /* get the pointer to the mlm message */
807 pMlmOemDataRsp = (tLimMlmOemDataRsp *) (pMsgBuf);
808
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800809 msgLength = sizeof(*pSirSmeOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 /* now allocate memory for the char buffer */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800811 pSirSmeOemDataRsp = qdf_mem_malloc(sizeof(*pSirSmeOemDataRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 if (NULL == pSirSmeOemDataRsp) {
813 lim_log(pMac, LOGP,
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800814 FL("malloc failed for pSirSmeOemDataRsp"));
815 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
816 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 return;
818 }
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800819
820 if (pMlmOemDataRsp->rsp_len) {
821 pSirSmeOemDataRsp->oem_data_rsp =
822 qdf_mem_malloc(pMlmOemDataRsp->rsp_len);
823 if (!pSirSmeOemDataRsp->oem_data_rsp) {
824 lim_log(pMac, LOGE,
825 FL("malloc failed for oem_data_rsp"));
826 qdf_mem_free(pSirSmeOemDataRsp);
827 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
828 qdf_mem_free(pMlmOemDataRsp);
829 return;
830 }
831 }
832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800833#if defined (ANI_LITTLE_BYTE_ENDIAN)
834 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->length, msgLength);
835 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->messageType,
836 eWNI_SME_OEM_DATA_RSP);
837#else
838 pSirSmeOemDataRsp->length = msgLength;
839 pSirSmeOemDataRsp->messageType = eWNI_SME_OEM_DATA_RSP;
840#endif
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -0800841 pSirSmeOemDataRsp->target_rsp = pMlmOemDataRsp->target_rsp;
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800842 pSirSmeOemDataRsp->rsp_len = pMlmOemDataRsp->rsp_len;
843 if (pSirSmeOemDataRsp->rsp_len)
844 qdf_mem_copy(pSirSmeOemDataRsp->oem_data_rsp,
845 pMlmOemDataRsp->oem_data_rsp,
846 pSirSmeOemDataRsp->rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
848 /* Now free the memory from MLM Rsp Message */
Krishna Kumaar Natarajan608291e2015-12-14 18:17:27 -0800849 qdf_mem_free(pMlmOemDataRsp->oem_data_rsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530850 qdf_mem_free(pMlmOemDataRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851
852 mmhMsg.type = eWNI_SME_OEM_DATA_RSP;
853 mmhMsg.bodyptr = pSirSmeOemDataRsp;
854 mmhMsg.bodyval = 0;
855
856 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
857
858 return;
859} /*** lim_send_sme_oem_data_rsp ***/
860
861#endif
862
863void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530864 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865{
866 tSirMsgQ mmhMsg;
867 tSirMsgQ *pMsg = (tSirMsgQ *) pCtx;
868
869 mmhMsg.type = pMsg->type;
870 mmhMsg.bodyptr = pMsg;
871 mmhMsg.bodyval = 0;
872
873 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
874
875 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
876}
877
878/**
879 * lim_send_sme_disassoc_ntf()
880 *
881 ***FUNCTION:
882 * This function is called by limProcessSmeMessages() to send
883 * eWNI_SME_DISASSOC_RSP/IND message to host
884 *
885 ***PARAMS:
886 *
887 ***LOGIC:
888 *
889 ***ASSUMPTIONS:
890 * NA
891 *
892 ***NOTE:
893 * This function is used for sending eWNI_SME_DISASSOC_CNF,
894 * or eWNI_SME_DISASSOC_IND to host depending on
895 * disassociation trigger.
896 *
897 * @param peerMacAddr Indicates the peer MAC addr to which
898 * disassociate was initiated
899 * @param reasonCode Indicates the reason for Disassociation
900 * @param disassocTrigger Indicates the trigger for Disassociation
901 * @param aid Indicates the STAID. This parameter is
902 * present only on AP.
903 *
904 * @return None
905 */
906void
907lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
908 tSirMacAddr peerMacAddr,
909 tSirResultCodes reasonCode,
910 uint16_t disassocTrigger,
911 uint16_t aid,
912 uint8_t smesessionId,
913 uint16_t smetransactionId, tpPESession psessionEntry)
914{
915
916 uint8_t *pBuf;
917 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
918 tSirSmeDisassocInd *pSirSmeDisassocInd;
919 uint32_t *pMsg;
920 bool failure = false;
921
922 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
923 disassocTrigger, reasonCode);
924
925 switch (disassocTrigger) {
926 case eLIM_PEER_ENTITY_DISASSOC:
927 if (reasonCode != eSIR_SME_STA_NOT_ASSOCIATED) {
928 failure = true;
929 goto error;
930 }
931
932 case eLIM_HOST_DISASSOC:
933 /**
934 * Disassociation response due to
935 * host triggered disassociation
936 */
937
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530938 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939 if (NULL == pSirSmeDisassocRsp) {
940 /* Log error */
941 lim_log(pMac, LOGP, FL("Memory allocation failed"));
942 failure = true;
943 goto error;
944 }
945 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
946 "retCode: %d for " MAC_ADDRESS_STR),
947 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
948 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
949 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
950 /* sessionId */
951 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
952 *pBuf = smesessionId;
953 pBuf++;
954
955 /* transactionId */
956 lim_copy_u16(pBuf, smetransactionId);
957 pBuf += sizeof(uint16_t);
958
959 /* statusCode */
960 lim_copy_u32(pBuf, reasonCode);
961 pBuf += sizeof(tSirResultCodes);
962
963 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530964 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 pBuf += sizeof(tSirMacAddr);
966
967 /* Clear Station Stats */
968 /* for sta, it is always 1, IBSS is handled at halInitSta */
969
970#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
971
972 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
973 psessionEntry, (uint16_t) reasonCode, 0);
974#endif
975 pMsg = (uint32_t *) pSirSmeDisassocRsp;
976 break;
977
978 default:
979 /**
980 * Disassociation indication due to Disassociation
981 * frame reception from peer entity or due to
982 * loss of link with peer entity.
983 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530984 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985 if (NULL == pSirSmeDisassocInd) {
986 /* Log error */
987 lim_log(pMac, LOGP, FL("Memory allocation failed"));
988 failure = true;
989 goto error;
990 }
991 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
992 "retCode: %d for " MAC_ADDRESS_STR),
993 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
994 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
995 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
996
997 /* Update SME session Id and Transaction Id */
998 pSirSmeDisassocInd->sessionId = smesessionId;
999 pSirSmeDisassocInd->transactionId = smetransactionId;
1000 pSirSmeDisassocInd->reasonCode = reasonCode;
1001 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1002
1003 lim_copy_u32(pBuf, reasonCode);
1004 pBuf += sizeof(tSirResultCodes);
1005
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301006 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007 pBuf += sizeof(tSirMacAddr);
1008
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301009 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010
1011#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1012 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1013 psessionEntry, (uint16_t) reasonCode, 0);
1014#endif
1015 pMsg = (uint32_t *) pSirSmeDisassocInd;
1016
1017 break;
1018 }
1019
1020error:
1021 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001022 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024
1025 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301026 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 (uint32_t *) pMsg);
1028} /*** end lim_send_sme_disassoc_ntf() ***/
1029
1030/** -----------------------------------------------------------------
1031 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1032
1033 After receiving disassociation frame from peer entity, this
1034 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1035 reason code.
1036
1037 \param pMac - global mac structure
1038 \param pStaDs - station dph hash node
1039 \return none
1040 \sa
1041 ----------------------------------------------------------------- */
1042void
1043lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1044 tpPESession psessionEntry)
1045{
1046 tSirMsgQ mmhMsg;
1047 tSirSmeDisassocInd *pSirSmeDisassocInd;
1048
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301049 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 if (NULL == pSirSmeDisassocInd) {
1051 lim_log(pMac, LOGP,
1052 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1053 return;
1054 }
1055
1056 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1057 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1058
1059 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1060 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
1061 pSirSmeDisassocInd->statusCode = pStaDs->mlmStaContext.disassocReason;
1062 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1063
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301064 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301065 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301067 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301068 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069
1070 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1071
1072 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1073 mmhMsg.bodyptr = pSirSmeDisassocInd;
1074 mmhMsg.bodyval = 0;
1075
1076 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1077#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1078 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1079 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1080#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1081
1082 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1083
1084} /*** end lim_send_sme_disassoc_ind() ***/
1085
1086/** -----------------------------------------------------------------
1087 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1088
1089 After receiving deauthentication frame from peer entity, this
1090 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1091 reason code.
1092
1093 \param pMac - global mac structure
1094 \param pStaDs - station dph hash node
1095 \return none
1096 \sa
1097 ----------------------------------------------------------------- */
1098void
1099lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1100 tpPESession psessionEntry)
1101{
1102 tSirMsgQ mmhMsg;
1103 tSirSmeDeauthInd *pSirSmeDeauthInd;
1104
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301105 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 if (NULL == pSirSmeDeauthInd) {
1107 lim_log(pMac, LOGP,
1108 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1109 return;
1110 }
1111
1112 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1113 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1114
1115 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1116 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1117 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1118 pSirSmeDeauthInd->statusCode =
1119 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1120 } else {
1121 /* Need to indicatet he reascon code over the air */
1122 pSirSmeDeauthInd->statusCode =
1123 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1124 }
1125 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301126 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301127 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301129 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301130 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1132
1133 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001134 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1135 pStaDs->mlmStaContext.disassocReason)
1136 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137
1138 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1139 mmhMsg.bodyptr = pSirSmeDeauthInd;
1140 mmhMsg.bodyval = 0;
1141
1142 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1143#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1144 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1145 0, pStaDs->mlmStaContext.cleanupTrigger);
1146#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1147
1148 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1149 return;
1150} /*** end lim_send_sme_deauth_ind() ***/
1151
1152#ifdef FEATURE_WLAN_TDLS
1153/**
1154 * lim_send_sme_tdls_del_sta_ind()
1155 *
1156 ***FUNCTION:
1157 * This function is called to send the TDLS STA context deletion to SME.
1158 *
1159 ***LOGIC:
1160 *
1161 ***ASSUMPTIONS:
1162 *
1163 ***NOTE:
1164 * NA
1165 *
1166 * @param pMac - Pointer to global MAC structure
1167 * @param pStaDs - Pointer to internal STA Datastructure
1168 * @param psessionEntry - Pointer to the session entry
1169 * @param reasonCode - Reason for TDLS sta deletion
1170 * @return None
1171 */
1172void
1173lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1174 tpPESession psessionEntry, uint16_t reasonCode)
1175{
1176 tSirMsgQ mmhMsg;
1177 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1178
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301179 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 if (NULL == pSirTdlsDelStaInd) {
1181 lim_log(pMac, LOGP,
1182 FL
1183 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1184 return;
1185 }
1186 /* messageType */
1187 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1188 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1189
1190 /* sessionId */
1191 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1192
1193 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301194 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301195 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196
1197 /* staId */
1198 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1199 (uint16_t) pStaDs->staIndex);
1200
1201 /* reasonCode */
1202 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1203
1204 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1205 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1206 mmhMsg.bodyval = 0;
1207
1208 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1209 return;
1210} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1211
1212/**
1213 * lim_send_sme_tdls_delete_all_peer_ind()
1214 *
1215 ***FUNCTION:
1216 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1217 * message to SME.
1218 *
1219 ***LOGIC:
1220 *
1221 ***ASSUMPTIONS:
1222 *
1223 ***NOTE:
1224 * NA
1225 *
1226 * @param pMac - Pointer to global MAC structure
1227 * @param psessionEntry - Pointer to the session entry
1228 * @return None
1229 */
1230void
1231lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1232{
1233 tSirMsgQ mmhMsg;
1234 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1235
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301236 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 if (NULL == pSirTdlsDelAllPeerInd) {
1238 lim_log(pMac, LOGP,
1239 FL
1240 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1241 return;
1242 }
1243 /* messageType */
1244 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1245 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1246
1247 /* sessionId */
1248 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1249
1250 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1251 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1252 mmhMsg.bodyval = 0;
1253
1254 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1255 return;
1256} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1257
1258/**
1259 * lim_send_sme_mgmt_tx_completion()
1260 *
1261 ***FUNCTION:
1262 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1263 * message to SME.
1264 *
1265 ***LOGIC:
1266 *
1267 ***ASSUMPTIONS:
1268 *
1269 ***NOTE:
1270 * NA
1271 *
1272 * @param pMac - Pointer to global MAC structure
1273 * @param psessionEntry - Pointer to the session entry
1274 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1275 * @return None
1276 */
1277void
1278lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
1279 tpPESession psessionEntry, uint32_t txCompleteStatus)
1280{
1281 tSirMsgQ mmhMsg;
1282 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1283
1284 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301285 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 if (NULL == pSirMgmtTxCompletionInd) {
1287 lim_log(pMac, LOGP,
1288 FL
1289 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1290 return;
1291 }
1292 /* messageType */
1293 pSirMgmtTxCompletionInd->messageType =
1294 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1295 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1296
1297 /* sessionId */
1298 pSirMgmtTxCompletionInd->sessionId = psessionEntry->smeSessionId;
1299
1300 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1301
1302 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1303 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1304 mmhMsg.bodyval = 0;
1305
1306 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1307 return;
1308} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1309
1310void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1311 void *events)
1312{
1313 tSirMsgQ mmhMsg;
1314
1315 switch (msgType) {
1316 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1317 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1318 break;
1319 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1320 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1321 break;
1322 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1323 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1324 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001325 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1326 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1327 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 }
1329
1330 mmhMsg.bodyptr = events;
1331 mmhMsg.bodyval = 0;
1332 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1333 return;
1334}
1335#endif /* FEATURE_WLAN_TDLS */
1336
1337/**
1338 * lim_send_sme_deauth_ntf()
1339 *
1340 ***FUNCTION:
1341 * This function is called by limProcessSmeMessages() to send
1342 * eWNI_SME_DISASSOC_RSP/IND message to host
1343 *
1344 ***PARAMS:
1345 *
1346 ***LOGIC:
1347 *
1348 ***ASSUMPTIONS:
1349 * NA
1350 *
1351 ***NOTE:
1352 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1353 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1354 *
1355 * @param peerMacAddr Indicates the peer MAC addr to which
1356 * deauthentication was initiated
1357 * @param reasonCode Indicates the reason for Deauthetication
1358 * @param deauthTrigger Indicates the trigger for Deauthetication
1359 * @param aid Indicates the STAID. This parameter is present
1360 * only on AP.
1361 *
1362 * @return None
1363 */
1364void
1365lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1366 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1367 uint16_t aid, uint8_t smesessionId,
1368 uint16_t smetransactionId)
1369{
1370 uint8_t *pBuf;
1371 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1372 tSirSmeDeauthInd *pSirSmeDeauthInd;
1373 tpPESession psessionEntry;
1374 uint8_t sessionId;
1375 uint32_t *pMsg;
1376
1377 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1378 switch (deauthTrigger) {
1379 case eLIM_PEER_ENTITY_DEAUTH:
1380 return;
1381
1382 case eLIM_HOST_DEAUTH:
1383 /**
1384 * Deauthentication response to host triggered
1385 * deauthentication.
1386 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301387 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001388 if (NULL == pSirSmeDeauthRsp) {
1389 /* Log error */
1390 lim_log(pMac, LOGP,
1391 FL
1392 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1393
1394 return;
1395 }
1396 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1397 "retCode: %d for" MAC_ADDRESS_STR),
1398 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1399 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1400 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1401 pSirSmeDeauthRsp->statusCode = reasonCode;
1402 pSirSmeDeauthRsp->sessionId = smesessionId;
1403 pSirSmeDeauthRsp->transactionId = smetransactionId;
1404
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001405 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301406 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407
1408#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1409 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1410 psessionEntry, 0, (uint16_t) reasonCode);
1411#endif
1412 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1413
1414 break;
1415
1416 default:
1417 /**
1418 * Deauthentication indication due to Deauthentication
1419 * frame reception from peer entity or due to
1420 * loss of link with peer entity.
1421 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301422 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 if (NULL == pSirSmeDeauthInd) {
1424 /* Log error */
1425 lim_log(pMac, LOGP,
1426 FL
1427 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1428
1429 return;
1430 }
1431 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1432 "retCode: %d for " MAC_ADDRESS_STR),
1433 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1434 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1435 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1436 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1437
1438 /* sessionId */
1439 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1440 *pBuf++ = smesessionId;
1441
1442 /* transaction ID */
1443 lim_copy_u16(pBuf, smetransactionId);
1444 pBuf += sizeof(uint16_t);
1445
1446 /* status code */
1447 lim_copy_u32(pBuf, reasonCode);
1448 pBuf += sizeof(tSirResultCodes);
1449
1450 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301451 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 pBuf += sizeof(tSirMacAddr);
1453
1454 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301455 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301456 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457
1458#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1459 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1460 psessionEntry, 0, (uint16_t) reasonCode);
1461#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1462 pMsg = (uint32_t *) pSirSmeDeauthInd;
1463
1464 break;
1465 }
1466
1467 /*Delete the PE session created */
1468 if (psessionEntry != NULL) {
1469 pe_delete_session(pMac, psessionEntry);
1470 }
1471
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301472 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 (uint32_t *) pMsg);
1474
1475} /*** end lim_send_sme_deauth_ntf() ***/
1476
1477/**
1478 * lim_send_sme_wm_status_change_ntf() - Send Notification
1479 * @mac_ctx: Global MAC Context
1480 * @status_change_code: Indicates the change in the wireless medium.
1481 * @status_change_info: Indicates the information associated with
1482 * change in the wireless medium.
1483 * @info_len: Indicates the length of status change information
1484 * being sent.
1485 * @session_id SessionID
1486 *
1487 * This function is called by limProcessSmeMessages() to send
1488 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1489 *
1490 * Return: None
1491 */
1492void
1493lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1494 tSirSmeStatusChangeCode status_change_code,
1495 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1496{
1497 tSirMsgQ msg;
1498 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
1499
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301500 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 if (NULL == wm_status_change_ntf) {
1502 lim_log(mac_ctx, LOGE,
1503 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1504 return;
1505 }
1506
1507 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1508 msg.bodyval = 0;
1509 msg.bodyptr = wm_status_change_ntf;
1510
1511 switch (status_change_code) {
1512 case eSIR_SME_RADAR_DETECTED:
1513 break;
1514 default:
1515 wm_status_change_ntf->messageType =
1516 eWNI_SME_WM_STATUS_CHANGE_NTF;
1517 wm_status_change_ntf->statusChangeCode = status_change_code;
1518 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1519 wm_status_change_ntf->sessionId = session_id;
1520 if (sizeof(wm_status_change_ntf->statusChangeInfo) >=
1521 info_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301522 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1524 (uint8_t *) status_change_info, info_len);
1525 }
1526 lim_log(mac_ctx, LOGE,
1527 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1528 status_change_code, info_len);
1529 break;
1530 }
1531
1532 MTRACE(mac_trace_msg_tx(mac_ctx, session_id, msg.type));
1533 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301534 qdf_mem_free(wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 lim_log(mac_ctx, LOGP,
1536 FL("lim_sys_process_mmh_msg_api failed"));
1537 }
1538
1539} /*** end lim_send_sme_wm_status_change_ntf() ***/
1540
1541/**
1542 * lim_send_sme_set_context_rsp()
1543 *
1544 ***FUNCTION:
1545 * This function is called by limProcessSmeMessages() to send
1546 * eWNI_SME_SETCONTEXT_RSP message to host
1547 *
1548 ***PARAMS:
1549 *
1550 ***LOGIC:
1551 *
1552 ***ASSUMPTIONS:
1553 * NA
1554 *
1555 ***NOTE:
1556 *
1557 * @param pMac Pointer to Global MAC structure
1558 * @param peerMacAddr Indicates the peer MAC addr to which
1559 * setContext was performed
1560 * @param aid Indicates the aid corresponding to the peer MAC
1561 * address
1562 * @param resultCode Indicates the result of previously issued
1563 * eWNI_SME_SETCONTEXT_RSP message
1564 *
1565 * @return None
1566 */
1567void
1568lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301569 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570 tSirResultCodes resultCode,
1571 tpPESession psessionEntry, uint8_t smesessionId,
1572 uint16_t smetransactionId)
1573{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 tSirMsgQ mmhMsg;
1575 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1576
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301577 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 if (NULL == pSirSmeSetContextRsp) {
1579 /* Log error */
1580 lim_log(pMac, LOGP,
1581 FL
1582 ("call to AllocateMemory failed for SmeSetContextRsp"));
1583
1584 return;
1585 }
1586
1587 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1588 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1589 pSirSmeSetContextRsp->statusCode = resultCode;
1590
Anurag Chouhanc5548422016-02-24 18:33:27 +05301591 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592
1593 /* Update SME session and transaction Id */
1594 pSirSmeSetContextRsp->sessionId = smesessionId;
1595 pSirSmeSetContextRsp->transactionId = smetransactionId;
1596
1597 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1598 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1599 mmhMsg.bodyval = 0;
1600 if (NULL == psessionEntry) {
1601 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1602 } else {
1603 MTRACE(mac_trace_msg_tx
1604 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1605 }
1606
1607#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1608 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1609 psessionEntry, (uint16_t) resultCode, 0);
1610#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1611
1612 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1613} /*** end lim_send_sme_set_context_rsp() ***/
1614
1615/**
1616 * lim_send_sme_neighbor_bss_ind()
1617 *
1618 ***FUNCTION:
1619 * This function is called by lim_lookup_nadd_hash_entry() to send
1620 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1621 *
1622 ***PARAMS:
1623 *
1624 ***LOGIC:
1625 *
1626 ***ASSUMPTIONS:
1627 * NA
1628 *
1629 ***NOTE:
1630 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1631 * host upon detecting new BSS during background scanning if CFG
1632 * option is enabled for sending such indication
1633 *
1634 * @param pMac - Pointer to Global MAC structure
1635 * @return None
1636 */
1637
1638void
1639lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1640{
1641 tSirMsgQ msgQ;
1642 uint32_t val;
1643 tSirSmeNeighborBssInd *pNewBssInd;
1644
1645 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1646 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1647 pMac->lim.gLimRspReqd)) {
1648 /* LIM is not in background scan state OR */
1649 /* current scan is initiated by HDD. */
1650 /* No need to send new BSS indication to HDD */
1651 return;
1652 }
1653
1654 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1655 eSIR_SUCCESS) {
1656 lim_log(pMac, LOGP,
1657 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1658
1659 return;
1660 }
1661
1662 if (val == 0)
1663 return;
1664
1665 /**
1666 * Need to indicate new BSSs found during
1667 * background scanning to host.
1668 * Allocate buffer for sending indication.
1669 * Length of buffer is length of BSS description
1670 * and length of header itself
1671 */
1672 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1673 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301674 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 if (NULL == pNewBssInd) {
1676 /* Log error */
1677 lim_log(pMac, LOGP,
1678 FL
1679 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1680
1681 return;
1682 }
1683
1684 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1685 pNewBssInd->length = (uint16_t) val;
1686 pNewBssInd->sessionId = 0;
1687
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301688 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 (uint8_t *) &pBssDescr->bssDescription,
1690 pBssDescr->bssDescription.length + sizeof(uint16_t));
1691
1692 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1693 msgQ.bodyptr = pNewBssInd;
1694 msgQ.bodyval = 0;
1695 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
1696 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1697} /*** end lim_send_sme_neighbor_bss_ind() ***/
1698
1699/** -----------------------------------------------------------------
1700 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1701 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1702 \ SME only looks at rc and tspec field.
1703 \param pMac - global mac structure
1704 \param rspReqd - is SmeAddTsRsp required
1705 \param status - status code of SME_ADD_TS_RSP
1706 \return tspec
1707 \sa
1708 ----------------------------------------------------------------- */
1709void
1710lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1711 tpPESession psessionEntry, tSirMacTspecIE tspec,
1712 uint8_t smesessionId, uint16_t smetransactionId)
1713{
1714 tpSirAddtsRsp rsp;
1715 tSirMsgQ mmhMsg;
1716
1717 if (!rspReqd)
1718 return;
1719
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301720 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 if (NULL == rsp) {
1722 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1723 return;
1724 }
1725
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301726 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 rsp->messageType = eWNI_SME_ADDTS_RSP;
1728 rsp->rc = status;
1729 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1730 rsp->rsp.tspec = tspec;
1731 /* Update SME session Id and transcation Id */
1732 rsp->sessionId = smesessionId;
1733 rsp->transactionId = smetransactionId;
1734
1735 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1736 mmhMsg.bodyptr = rsp;
1737 mmhMsg.bodyval = 0;
1738 if (NULL == psessionEntry) {
1739 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1740 } else {
1741 MTRACE(mac_trace_msg_tx
1742 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1743 }
1744#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1745 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1746 0);
1747#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1748
1749 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1750 return;
1751}
1752
1753void
1754lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1755 tpPESession psessionEntry, uint8_t smesessionId,
1756 uint16_t smetransactionId)
1757{
1758 tpSirDeltsRsp rsp;
1759 tSirMsgQ mmhMsg;
1760
1761 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1762 delts->aid,
1763 delts->req.tsinfo.traffic.tsid,
1764 delts->req.tsinfo.traffic.userPrio, status);
1765 if (!delts->rspReqd)
1766 return;
1767
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301768 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 if (NULL == rsp) {
1770 /* Log error */
1771 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1772 return;
1773 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301774 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775
1776 if (psessionEntry != NULL) {
1777
1778 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301779 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301780 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 sizeof(tSirDeltsReqInfo));
1782 }
1783
1784 rsp->messageType = eWNI_SME_DELTS_RSP;
1785 rsp->rc = status;
1786
1787 /* Update SME session Id and transcation Id */
1788 rsp->sessionId = smesessionId;
1789 rsp->transactionId = smetransactionId;
1790
1791 mmhMsg.type = eWNI_SME_DELTS_RSP;
1792 mmhMsg.bodyptr = rsp;
1793 mmhMsg.bodyval = 0;
1794 if (NULL == psessionEntry) {
1795 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1796 } else {
1797 MTRACE(mac_trace_msg_tx
1798 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1799 }
1800#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1801 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1802 (uint16_t) status, 0);
1803#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1804
1805 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1806}
1807
1808void
1809lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1810 tpPESession psessionEntry)
1811{
1812 tpSirDeltsRsp rsp;
1813 tSirMsgQ mmhMsg;
1814
1815 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1816 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1817
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301818 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 if (NULL == rsp) {
1820 /* Log error */
1821 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1822 return;
1823 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301824 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825
1826 rsp->messageType = eWNI_SME_DELTS_IND;
1827 rsp->rc = eSIR_SUCCESS;
1828 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301829 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830
1831 /* Update SME session Id and SME transaction Id */
1832
1833 rsp->sessionId = psessionEntry->smeSessionId;
1834 rsp->transactionId = psessionEntry->transactionId;
1835
1836 mmhMsg.type = eWNI_SME_DELTS_IND;
1837 mmhMsg.bodyptr = rsp;
1838 mmhMsg.bodyval = 0;
1839 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1840#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1841 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1842 0);
1843#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1844
1845 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1846}
1847
1848/**
1849 * lim_send_sme_pe_statistics_rsp()
1850 *
1851 ***FUNCTION:
1852 * This function is called to send 802.11 statistics response to HDD.
1853 * This function posts the result back to HDD. This is a response to
1854 * HDD's request for statistics.
1855 *
1856 ***PARAMS:
1857 *
1858 ***LOGIC:
1859 *
1860 ***ASSUMPTIONS:
1861 * NA
1862 *
1863 ***NOTE:
1864 * NA
1865 *
1866 * @param pMac Pointer to Global MAC structure
1867 * @param p80211Stats Statistics sent in response
1868 * @param resultCode TODO:
1869 *
1870 *
1871 * @return none
1872 */
1873
1874void
1875lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1876{
1877 tSirMsgQ mmhMsg;
1878 uint8_t sessionId;
1879 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1880 tpPESession pPeSessionEntry;
1881
1882 /* Get the Session Id based on Sta Id */
1883 pPeSessionEntry =
1884 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1885
1886 /* Fill the Session Id */
1887 if (NULL != pPeSessionEntry) {
1888 /* Fill the Session Id */
1889 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1890 }
1891
1892 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1893
1894 /* msgType should be WMA_GET_STATISTICS_RSP */
1895 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1896
1897 mmhMsg.bodyptr = stats;
1898 mmhMsg.bodyval = 0;
1899 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1900 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1901
1902 return;
1903
1904} /*** end lim_send_sme_pe_statistics_rsp() ***/
1905
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001906#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001908 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1909 * @pMac: Pointer to global pMac structure
1910 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 * This function is called to send tsm stats response to HDD.
1913 * This function posts the result back to HDD. This is a response to
1914 * HDD's request to get tsm stats.
1915 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001916 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001918void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1919 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920{
1921 tSirMsgQ mmhMsg;
1922 uint8_t sessionId;
1923 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1924 tpPESession pPeSessionEntry = NULL;
1925
1926 /* Get the Session Id based on Sta Id */
1927 pPeSessionEntry =
1928 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1929
1930 /* Fill the Session Id */
1931 if (NULL != pPeSessionEntry) {
1932 /* Fill the Session Id */
1933 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1934 } else {
1935 PELOGE(lim_log
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001936 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1937 pPeStats->staId);)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 return;
1939 }
1940
1941 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1942 pPeStats->tsmMetrics.RoamingCount
1943 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1944 pPeStats->tsmMetrics.RoamingDly
1945 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1946
1947 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1948 mmhMsg.bodyptr = pStats;
1949 mmhMsg.bodyval = 0;
1950 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
1951 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1952
1953 return;
1954} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1955
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001956#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957
1958void
1959lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1960 tSirMacAddr peerMacAddr,
1961 uint16_t staIndex,
1962 uint8_t ucastIdx,
1963 uint8_t bcastIdx,
1964 uint8_t *beacon,
1965 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1966{
1967 tSirMsgQ mmhMsg;
1968 tSmeIbssPeerInd *pNewPeerInd;
1969
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301970 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 if (NULL == pNewPeerInd) {
1972 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
1973 return;
1974 }
1975
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301976 qdf_mem_set((void *)pNewPeerInd, (sizeof(tSmeIbssPeerInd) + beaconLen),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977 0);
1978
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301979 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301980 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 pNewPeerInd->staId = staIndex;
1982 pNewPeerInd->ucastSig = ucastIdx;
1983 pNewPeerInd->bcastSig = bcastIdx;
1984 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1985 pNewPeerInd->mesgType = msgType;
1986 pNewPeerInd->sessionId = sessionId;
1987
1988 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301989 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1991 beaconLen);
1992 }
1993
1994 mmhMsg.type = msgType;
1995 mmhMsg.bodyptr = pNewPeerInd;
1996 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
1997 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1998
1999}
2000
2001/**
2002 * lim_handle_csa_offload_msg() - Handle CSA offload message
2003 * @mac_ctx: pointer to global adapter context
2004 * @msg: Message pointer.
2005 *
2006 * Return: None
2007 */
2008void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
2009{
2010 tpPESession session_entry;
2011 tSirMsgQ mmh_msg;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302012 struct csa_offload_params *csa_params =
2013 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 tpSmeCsaOffloadInd csa_offload_ind;
2015 tpDphHashNode sta_ds = NULL;
2016 uint8_t session_id;
2017 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302018 uint16_t chan_space = 0;
Amar Singhale4f28ee2015-10-21 14:36:56 -07002019 struct ch_params_s ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002022 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302024 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2025
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 if (!csa_params) {
2027 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2028 return;
2029 }
2030
2031 session_entry =
2032 pe_find_session_by_bssid(mac_ctx,
2033 csa_params->bssId, &session_id);
2034 if (!session_entry) {
2035 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302036 FL("Session does not exists for %pM"),
2037 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 goto err;
2039 }
2040
2041 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2042 &session_entry->dph.dphHashTable);
2043
2044 if (!sta_ds) {
2045 lim_log(mac_ctx, LOGE,
2046 FL("sta_ds does not exist"));
2047 goto err;
2048 }
2049
2050 if (LIM_IS_STA_ROLE(session_entry)) {
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302051 /*
2052 * on receiving channel switch announcement from AP, delete all
2053 * TDLS peers before leaving BSS and proceed for channel switch
2054 */
2055 lim_delete_tdls_peers(mac_ctx, session_entry);
2056
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002057 lim_ch_switch = &session_entry->gLimChannelSwitch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 session_entry->gLimChannelSwitch.switchMode =
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302059 csa_params->switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 /* timer already started by firmware, switch immediately */
2061 session_entry->gLimChannelSwitch.switchCount = 0;
2062 session_entry->gLimChannelSwitch.primaryChannel =
2063 csa_params->channel;
2064 session_entry->gLimChannelSwitch.state =
2065 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2066 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002067 lim_ch_switch->sec_ch_offset =
2068 session_entry->htSecondaryChannelOffset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302069 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2070 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2071 chnl_switch_info =
2072 &session_entry->gLimWiderBWChannelSwitch;
2073
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302074 lim_log(mac_ctx, LOG1,
2075 FL("vht:%d ht:%d flag:%x chan:%d seg1:%d seg2:%d width:%d country:%s class:%d"),
2076 session_entry->vhtCapability,
2077 session_entry->htSupportedChannelWidthSet,
2078 csa_params->ies_present_flag,
2079 csa_params->channel, csa_params->new_ch_freq_seg1,
2080 csa_params->new_ch_freq_seg2,
2081 csa_params->new_ch_width,
2082 mac_ctx->scan.countryCodeCurrent,
2083 csa_params->new_op_class);
2084
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 if (session_entry->vhtCapability &&
2086 session_entry->htSupportedChannelWidthSet) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
2088 chnl_switch_info->newChanWidth =
2089 csa_params->new_ch_width;
2090 chnl_switch_info->newCenterChanFreq0 =
2091 csa_params->new_ch_freq_seg1;
2092 chnl_switch_info->newCenterChanFreq1 =
2093 csa_params->new_ch_freq_seg2;
2094 session_entry->gLimChannelSwitch.state =
2095 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2096 session_entry->gLimChannelSwitch.ch_width =
2097 csa_params->new_ch_width + 1;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302098 } else if (csa_params->ies_present_flag
2099 & lim_xcsa_ie_present) {
2100 chan_space =
Amar Singhal22995112016-01-22 10:42:33 -08002101 cds_reg_dmn_get_chanwidth_from_opclass(
Gupta, Kapil121bf212015-11-25 19:21:29 +05302102 mac_ctx->scan.countryCodeCurrent,
2103 csa_params->channel,
2104 csa_params->new_op_class);
2105 session_entry->gLimChannelSwitch.state =
2106 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2107
2108 if (chan_space == 80) {
2109 chnl_switch_info->newChanWidth =
2110 CH_WIDTH_80MHZ;
2111 } else if (chan_space == 40) {
2112 chnl_switch_info->newChanWidth =
2113 CH_WIDTH_40MHZ;
2114 } else {
2115 chnl_switch_info->newChanWidth =
2116 CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002117 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302118 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2119 }
2120
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002121 ch_params.ch_width =
2122 chnl_switch_info->newChanWidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002123 cds_set_channel_params(csa_params->channel,
2124 0, &ch_params);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302125 chnl_switch_info->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002126 ch_params.center_freq_seg0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302127 /*
2128 * This is not applicable for 20/40/80 MHz.
2129 * Only used when we support 80+80 MHz operation.
2130 * In case of 80+80 MHz, this parameter indicates
2131 * center channel frequency index of 80 MHz
2132 * channel offrequency segment 1.
2133 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002134 chnl_switch_info->newCenterChanFreq1 =
2135 ch_params.center_freq_seg1;
2136 lim_ch_switch->sec_ch_offset =
2137 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302138
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 }
Gupta, Kapil121bf212015-11-25 19:21:29 +05302140 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2141 chnl_switch_info->newCenterChanFreq0;
2142 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2143 chnl_switch_info->newCenterChanFreq1;
2144 session_entry->gLimChannelSwitch.ch_width =
2145 chnl_switch_info->newChanWidth;
2146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147 } else if (session_entry->htSupportedChannelWidthSet) {
Gupta, Kapil121bf212015-11-25 19:21:29 +05302148 if (csa_params->ies_present_flag
2149 & lim_xcsa_ie_present) {
2150 chan_space =
Amar Singhal22995112016-01-22 10:42:33 -08002151 cds_reg_dmn_get_chanwidth_from_opclass(
Gupta, Kapil121bf212015-11-25 19:21:29 +05302152 mac_ctx->scan.countryCodeCurrent,
2153 csa_params->channel,
2154 csa_params->new_op_class);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002155 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302156 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2157 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002158 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302159 CH_WIDTH_40MHZ;
2160 chnl_switch_info->newChanWidth =
2161 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002162 ch_params.ch_width =
2163 chnl_switch_info->newChanWidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002164 cds_set_channel_params(
2165 csa_params->channel,
2166 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002167 lim_ch_switch->ch_center_freq_seg0 =
2168 ch_params.center_freq_seg0;
2169 lim_ch_switch->sec_ch_offset =
2170 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302171 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002172 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302173 CH_WIDTH_20MHZ;
2174 chnl_switch_info->newChanWidth =
2175 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002176 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302177 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002178 lim_ch_switch->sec_ch_offset =
2179 PHY_SINGLE_CHANNEL_CENTERED;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302180 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002182 lim_ch_switch->ch_width =
2183 CH_WIDTH_40MHZ;
2184 lim_ch_switch->state =
2185 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2186 ch_params.ch_width = CH_WIDTH_40MHZ;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002187 cds_set_channel_params(csa_params->channel,
2188 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002189 lim_ch_switch->ch_center_freq_seg0 =
2190 ch_params.center_freq_seg0;
2191 lim_ch_switch->sec_ch_offset =
2192 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 }
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002194
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002195 }
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302196 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
2197 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198
2199 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302200 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 if (NULL == csa_offload_ind) {
2202 lim_log(mac_ctx, LOGE,
2203 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
2204 goto err;
2205 }
2206
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302207 qdf_mem_set(csa_offload_ind, sizeof(tSmeCsaOffloadInd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2209 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302211 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2213 mmh_msg.bodyptr = csa_offload_ind;
2214 mmh_msg.bodyval = 0;
2215 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002216 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 MTRACE(mac_trace_msg_tx
2218 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2219#ifdef FEATURE_WLAN_DIAG_SUPPORT
2220 lim_diag_event_report(mac_ctx,
2221 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2222 eSIR_SUCCESS, eSIR_SUCCESS);
2223#endif
2224 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
2225 }
2226
2227err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302228 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229}
2230
2231/*--------------------------------------------------------------------------
2232 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2233
2234 \param pMac - pointer to global adapter context
2235 \param sessionId - Message pointer.
2236
2237 \sa
2238 --------------------------------------------------------------------------*/
2239
2240void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ MsgQ)
2241{
2242 tpPESession psessionEntry;
2243 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2244
2245 psessionEntry =
2246 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2247 if (psessionEntry == NULL) {
2248 lim_log(pMac, LOGE,
2249 FL("Session Does not exist for given sessionID %d"),
2250 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002251 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252 return;
2253 }
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002254 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002256 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002258 else if (LIM_IS_NDI_ROLE(psessionEntry))
2259 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260 else
2261 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2262
2263}
2264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265/** -----------------------------------------------------------------
2266 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2267 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2268 \ SME only looks at rc and tspec field.
2269 \param pMac - global mac structure
2270 \param rspReqd - is SmeAddTsRsp required
2271 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2272 \return tspec
2273 \sa
2274 ----------------------------------------------------------------- */
2275void
2276lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2277 uint8_t smesessionId)
2278{
2279 tSirMsgQ mmhMsg;
2280
2281 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2282 mmhMsg.bodyptr = aggrQosRsp;
2283 mmhMsg.bodyval = 0;
2284 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2285 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2286
2287 return;
2288}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289
2290void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2291 uint8_t smesessionId)
2292{
2293 tSirMsgQ mmhMsg;
2294 tSmeMaxAssocInd *pSmeMaxAssocInd;
2295
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302296 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 if (NULL == pSmeMaxAssocInd) {
2298 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2299 return;
2300 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302301 qdf_mem_set((void *)pSmeMaxAssocInd, sizeof(tSmeMaxAssocInd), 0);
2302 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302303 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2305 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2306 pSmeMaxAssocInd->sessionId = smesessionId;
2307 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2308 mmhMsg.bodyptr = pSmeMaxAssocInd;
2309 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2310 " sme session id %d"),
2311 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2312 MAC_ADDR_ARRAY(peerMacAddr));
2313 )
2314 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2315 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2316
2317 return;
2318}
2319
2320/** -----------------------------------------------------------------
2321 \brief lim_send_sme_dfs_event_notify() - sends
2322 eWNI_SME_DFS_RADAR_FOUND
2323 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2324 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2325 that a RADAR is found on current operating channel and SAP-
2326 has to move to a new channel.
2327 \param pMac - global mac structure
2328 \param msgType - message type received from lower layer
2329 \param event - event data received from lower layer
2330 \return none
2331 \sa
2332 ----------------------------------------------------------------- */
2333void
2334lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2335{
2336 tSirMsgQ mmhMsg;
2337 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2338 mmhMsg.bodyptr = event;
2339 mmhMsg.bodyval = 0;
2340 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2341 return;
2342}
2343
2344/*--------------------------------------------------------------------------
2345 \brief lim_send_dfs_chan_sw_ie_update()
2346 This timer handler updates the channel switch IE in beacon template
2347
2348 \param pMac - pointer to global adapter context
2349 \return - channel to scan from valid session else zero.
2350 \sa
2351 --------------------------------------------------------------------------*/
2352static void
2353lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2354{
2355
2356 /* Update the beacon template and send to FW */
2357 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2358 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2359 return;
2360 }
2361
2362 /* Send update beacon template message */
2363 lim_send_beacon_ind(pMac, psessionEntry);
2364 PELOG1(lim_log(pMac, LOG1,
2365 FL(" Updated CSA IE, IE COUNT = %d"),
2366 psessionEntry->gLimChannelSwitch.switchCount);
2367 )
2368
2369 return;
2370}
2371
2372/** -----------------------------------------------------------------
2373 \brief lim_send_sme_ap_channel_switch_resp() - sends
2374 eWNI_SME_CHANNEL_CHANGE_RSP
2375 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2376 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2377 that the Channel change has been done to the specified target
2378 channel in the Channel change request
2379 \param pMac - global mac structure
2380 \param psessionEntry - session info
2381 \param pChnlParams - Channel switch params
2382 --------------------------------------------------------------------*/
2383void
2384lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2385 tpPESession psessionEntry,
2386 tpSwitchChannelParams pChnlParams)
2387{
2388 tSirMsgQ mmhMsg;
2389 tpSwitchChannelParams pSmeSwithChnlParams;
2390 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002391 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002392 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002393 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394
2395 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302396 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 if (NULL == pSmeSwithChnlParams) {
2398 lim_log(pMac, LOGP,
2399 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2400 return;
2401 }
2402
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302403 qdf_mem_set((void *)pSmeSwithChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 sizeof(tSwitchChannelParams), 0);
2405
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302406 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 sizeof(tSwitchChannelParams));
2408
2409 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002410 ch_width = pSmeSwithChnlParams->ch_width;
2411 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412
2413 /*
2414 * Pass the sme sessionID to SME instead
2415 * PE session ID.
2416 */
2417 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2418
2419 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2420 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2421 mmhMsg.bodyval = 0;
2422 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2423
2424 /*
2425 * We should start beacon transmission only if the new
2426 * channel after channel change is Non-DFS. For a DFS
2427 * channel, PE will receive an explicit request from
2428 * upper layers to start the beacon transmission .
2429 */
2430
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002431 if (ch_width == CH_WIDTH_160MHZ) {
2432 is_ch_dfs = true;
2433 } else if (ch_width == CH_WIDTH_80P80MHZ) {
2434 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
2435 cds_get_channel_state(ch_center_freq_seg1 -
2436 SIR_80MHZ_START_CENTER_CH_DIFF) ==
2437 CHANNEL_STATE_DFS)
2438 is_ch_dfs = true;
2439 } else {
2440 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
2441 is_ch_dfs = true;
2442 }
2443
2444 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002445 if (channelId == psessionEntry->currentOperChannel) {
2446 lim_apply_configuration(pMac, psessionEntry);
2447 lim_send_beacon_ind(pMac, psessionEntry);
2448 } else {
2449 PELOG1(lim_log(pMac, LOG1,
2450 FL
2451 ("Failed to Transmit Beacons on channel = %d"
2452 "after AP channel change response"),
2453 psessionEntry->bcnLen);
2454 )
2455 }
2456 }
2457 return;
2458}
2459
2460/** -----------------------------------------------------------------
2461 \brief lim_process_beacon_tx_success_ind() - This function is used
2462 explicitely to handle successful beacon transmission indication
2463 from the FW. This is a generic event generated by the FW afer the
2464 first beacon is sent out after the beacon template update by the
2465 host
2466 \param pMac - global mac structure
2467 \param psessionEntry - session info
2468 \return none
2469 \sa
2470 ----------------------------------------------------------------- */
2471void
2472lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2473{
2474 /* Currently, this event is used only for DFS channel switch announcement
2475 * IE update in the template. If required to be used for other IE updates
2476 * add appropriate code by introducing a state variable
2477 */
2478 tpPESession psessionEntry;
2479 tSirMsgQ mmhMsg;
2480 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2481 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2482 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2483 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2484 (tSirFirstBeaconTxCompleteInd *) event;
2485
2486 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2487 if (psessionEntry == NULL) {
2488 lim_log(pMac, LOGE,
2489 FL("Session Does not exist for given sessionID"));
2490 return;
2491 }
2492
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302493 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2494 GET_LIM_SYSTEM_ROLE(psessionEntry),
2495 psessionEntry->dfsIncludeChanSwIe,
2496 psessionEntry->gLimOperatingMode.present);
2497
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 if (LIM_IS_AP_ROLE(psessionEntry) &&
2499 true == psessionEntry->dfsIncludeChanSwIe) {
2500 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2501 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2502 /*
2503 * Send the next beacon with updated CSA IE count
2504 */
2505 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2506 /* Decrement the IE count */
2507 psessionEntry->gLimChannelSwitch.switchCount--;
2508 } else {
2509 /* Done with CSA IE update, send response back to SME */
2510 psessionEntry->gLimChannelSwitch.switchCount = 0;
2511 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2512 psessionEntry->gLimChannelSwitch.switchMode = 0;
2513 psessionEntry->dfsIncludeChanSwIe = false;
2514 psessionEntry->dfsIncludeChanWrapperIe = false;
2515
2516 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302517 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518
2519 if (NULL == pChanSwTxResponse) {
2520 lim_log(pMac, LOGP,
2521 FL
2522 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2523 return;
2524 }
2525
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302526 qdf_mem_set((void *)pChanSwTxResponse, length, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002527 pChanSwTxResponse->sessionId =
2528 psessionEntry->smeSessionId;
2529 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302530 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531
2532 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2533 mmhMsg.bodyptr = pChanSwTxResponse;
2534 mmhMsg.bodyval = 0;
2535 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2536 }
2537 }
2538
2539 if (LIM_IS_AP_ROLE(psessionEntry) &&
2540 psessionEntry->gLimOperatingMode.present) {
2541 /* Done with nss update, send response back to SME */
2542 psessionEntry->gLimOperatingMode.present = 0;
2543 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302544 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 if (NULL == beacon_tx_comp_rsp_ptr) {
2546 lim_log(pMac, LOGP,
2547 FL
2548 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2549 return;
2550 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302551 qdf_mem_set((void *)beacon_tx_comp_rsp_ptr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 sizeof(*beacon_tx_comp_rsp_ptr), 0);
2553 beacon_tx_comp_rsp_ptr->session_id =
2554 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302555 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2557 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2558 mmhMsg.bodyval = 0;
2559 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2560 }
2561 return;
2562}