blob: 653ff560b02de9b04a7d0e5e2a08c8caceebbdbb [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;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530110 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
111 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112
113#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
114 switch (msg_type) {
115 case eWNI_SME_STOP_BSS_RSP:
116 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
117 NULL, (uint16_t) result_code, 0);
118 break;
119 }
120#endif /* FEATURE_WLAN_DIAG_SUPPORT */
121 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
122}
123
124
125
126/**
127 * lim_send_sme_roc_rsp() - Send Response to SME
128 * @mac_ctx: Pointer to Global MAC structure
129 * @status: Resume link status
130 * @result_code: Result of the ROC request
131 * @sme_session_id: SME sesson Id
132 * @scan_id: Scan Identifier
133 *
134 * This function is called to send ROC rsp
135 * message to SME.
136 *
137 * Return: None
138 */
139void
140lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
141 tSirResultCodes result_code, uint8_t sme_session_id,
142 uint32_t scan_id)
143{
144 tSirMsgQ msg;
145 struct sir_roc_rsp *sme_rsp;
146
147 lim_log(mac_ctx, LOG1,
148 FL("Sending message %s with reasonCode %s scanId %d"),
149 lim_msg_str(msg_type), lim_result_code_str(result_code),
150 scan_id);
151
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530152 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 if (NULL == sme_rsp) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530154 QDF_TRACE(QDF_MODULE_ID_PE, LOGP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
156 return;
157 }
158
159 sme_rsp->message_type = msg_type;
160 sme_rsp->length = sizeof(struct sir_roc_rsp);
161 sme_rsp->status = result_code;
162
163 sme_rsp->session_id = sme_session_id;
164 sme_rsp->scan_id = scan_id;
165
166 msg.type = msg_type;
167 msg.bodyptr = sme_rsp;
168 msg.bodyval = 0;
169 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
170 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
171}
172
173
174/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530175 * lim_get_max_rate_flags() - Get rate flags
176 * @mac_ctx: Pointer to global MAC structure
177 * @sta_ds: Pointer to station ds structure
178 *
179 * This function is called to get the rate flags for a connection
180 * from the station ds structure depending on the ht and the vht
181 * channel width supported.
182 *
183 * Return: Returns the populated rate_flags
184 */
185uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
186{
187 uint32_t rate_flags = 0;
188
189 if (sta_ds == NULL) {
190 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
191 return rate_flags;
192 }
193
194 if (!sta_ds->mlmStaContext.htCapability &&
195 !sta_ds->mlmStaContext.vhtCapability) {
196 rate_flags |= eHAL_TX_RATE_LEGACY;
197 } else {
198 if (sta_ds->mlmStaContext.vhtCapability) {
199 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
200 sta_ds->vhtSupportedChannelWidthSet) {
201 rate_flags |= eHAL_TX_RATE_VHT80;
202 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
203 sta_ds->vhtSupportedChannelWidthSet) {
204 if (sta_ds->htSupportedChannelWidthSet)
205 rate_flags |= eHAL_TX_RATE_VHT40;
206 else
207 rate_flags |= eHAL_TX_RATE_VHT20;
208 }
209 } else if (sta_ds->mlmStaContext.htCapability) {
210 if (sta_ds->htSupportedChannelWidthSet)
211 rate_flags |= eHAL_TX_RATE_HT40;
212 else
213 rate_flags |= eHAL_TX_RATE_HT20;
214 }
215 }
216
217 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
218 rate_flags |= eHAL_TX_RATE_SGI;
219
220 return rate_flags;
221}
222
223/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
225 * @mac_ctx Pointer to Global MAC structure
226 * @status Resume link status
227 * @ctx context passed while calling resmune link.
228 * (join response to be sent)
229 *
230 * This function is called to send Join/Reassoc rsp
231 * message to SME after the resume link.
232 *
233 * Return: None
234 */
235static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530236 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237{
238 tSirMsgQ msg;
239 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
240
241 msg.type = sme_join_rsp->messageType;
242 msg.bodyptr = sme_join_rsp;
243 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530244 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
246}
247
248/**
249 * lim_handle_join_rsp_status() - Handle the response.
250 * @mac_ctx: Pointer to Global MAC structure
251 * @session_entry: PE Session Info
252 * @result_code: Indicates the result of previously issued
253 * eWNI_SME_msgType_REQ message
254 * @sme_join_rsp The received response.
255 *
256 * This function will handle both the success and failure status
257 * of the received response.
258 *
259 * Return: None
260 */
261static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
262 tpPESession session_entry, tSirResultCodes result_code,
263 tpSirSmeJoinRsp sme_join_rsp)
264{
265#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
266 tSirSmeHTProfile *ht_profile;
267#endif
268 if (result_code == eSIR_SME_SUCCESS) {
269 if (session_entry->beacon != NULL) {
270 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530271 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 session_entry->beacon,
273 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530274 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530276 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 lim_log(mac_ctx, LOG1, FL("Beacon=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530278 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 }
280 if (session_entry->assocReq != NULL) {
281 sme_join_rsp->assocReqLength =
282 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530283 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530284 sme_join_rsp->beaconLength,
285 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530287 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530289 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800290 lim_log(mac_ctx,
291 LOG1, FL("AssocReq=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530292 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800293 }
294 if (session_entry->assocRsp != NULL) {
295 sme_join_rsp->assocRspLength =
296 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530297 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530298 sme_join_rsp->beaconLength +
299 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 session_entry->assocRsp,
301 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530302 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530304 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 if (session_entry->ricData != NULL) {
307 sme_join_rsp->parsedRicRspLen =
308 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530309 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530310 sme_join_rsp->beaconLength +
311 sme_join_rsp->assocReqLength +
312 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313 session_entry->ricData,
314 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530315 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530317 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800318 lim_log(mac_ctx, LOG1, FL("RicLength=%d"),
319 sme_join_rsp->parsedRicRspLen);
320 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321#ifdef FEATURE_WLAN_ESE
322 if (session_entry->tspecIes != NULL) {
323 sme_join_rsp->tspecIeLen =
324 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530325 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530326 sme_join_rsp->beaconLength +
327 sme_join_rsp->assocReqLength +
328 sme_join_rsp->assocRspLength +
329 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 session_entry->tspecIes,
331 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530332 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530334 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 lim_log(mac_ctx, LOG1, FL("ESE-TspecLen=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530336 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 }
338#endif
339 sme_join_rsp->aid = session_entry->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 lim_log(mac_ctx, LOG1, FL("AssocRsp=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530341 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 sme_join_rsp->vht_channel_width =
343 session_entry->ch_width;
344#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
345 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530346 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347 ht_profile = &sme_join_rsp->HTProfile;
348 ht_profile->htSupportedChannelWidthSet =
349 session_entry->htSupportedChannelWidthSet;
350 ht_profile->htRecommendedTxWidthSet =
351 session_entry->htRecommendedTxWidthSet;
352 ht_profile->htSecondaryChannelOffset =
353 session_entry->htSecondaryChannelOffset;
354 ht_profile->dot11mode = session_entry->dot11mode;
355 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 ht_profile->vhtCapability =
357 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
359 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 }
361#endif
362 } else {
363 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530364 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530366 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 }
368 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530369 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800370 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530371 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 }
373 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530374 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530376 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530379 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530381 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383#ifdef FEATURE_WLAN_ESE
384 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530385 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530387 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 }
389#endif
390 }
391}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530392
393/**
394 * lim_add_bss_info() - copy data from session entry to join rsp
395 * @session_entry: PE Session Info
396 * @sme_join_rsp: Join response buffer to be filled up
397 *
398 * Return: None
399 */
400void lim_add_bss_info(tpPESession session_entry,
401 tpSirSmeJoinRsp sme_join_rsp)
402{
403 sme_join_rsp->hs20vendor_ie = session_entry->hs20vendor_ie;
404 sme_join_rsp->vht_caps = session_entry->vht_caps;
405 sme_join_rsp->ht_caps = session_entry->ht_caps;
406 sme_join_rsp->ht_operation = session_entry->ht_operation;
407 sme_join_rsp->vht_operation = session_entry->vht_operation;
408}
409
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410/**
411 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
412 * @mac_ctx: Pointer to Global MAC structure
413 * @msg_type: Indicates message type
414 * @result_code: Indicates the result of previously issued
415 * eWNI_SME_msgType_REQ message
416 * @prot_status_code: Protocol Status Code
417 * @session_entry: PE Session Info
418 * @sme_session_id: SME Session ID
419 * @sme_transaction_id: SME Transaction ID
420 *
421 * This function is called by lim_process_sme_req_messages() to send
422 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
423 * above MAC Software.
424 *
425 * Return: None
426 */
427
428void
429lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
430 tSirResultCodes result_code, uint16_t prot_status_code,
431 tpPESession session_entry, uint8_t sme_session_id,
432 uint16_t sme_transaction_id)
433{
434 tpSirSmeJoinRsp sme_join_rsp;
435 uint32_t rsp_len;
436 tpDphHashNode sta_ds = NULL;
437#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
438 if (msg_type == eWNI_SME_REASSOC_RSP)
439 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
440 session_entry, (uint16_t) result_code, 0);
441 else
442 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
443 session_entry, (uint16_t) result_code, 0);
444#endif /* FEATURE_WLAN_DIAG_SUPPORT */
445
446 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
447 lim_msg_str(msg_type), lim_result_code_str(result_code));
448
449 if (session_entry == NULL) {
450 rsp_len = sizeof(tSirSmeJoinRsp);
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("Mem Alloc fail - JOIN/REASSOC_RSP"));
455 return;
456 }
457
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530458 qdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 sme_join_rsp->beaconLength = 0;
460 sme_join_rsp->assocReqLength = 0;
461 sme_join_rsp->assocRspLength = 0;
462 } else {
463 rsp_len = session_entry->assocReqLen +
464 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466#ifdef FEATURE_WLAN_ESE
467 session_entry->tspecLen +
468#endif
469 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530470 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 if (NULL == sme_join_rsp) {
472 lim_log(mac_ctx, LOGP,
473 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
474 return;
475 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530476 qdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 if (result_code == eSIR_SME_SUCCESS) {
478 sta_ds = dph_get_hash_entry(mac_ctx,
479 DPH_STA_HASH_INDEX_PEER,
480 &session_entry->dph.dphHashTable);
481 if (sta_ds == NULL) {
482 lim_log(mac_ctx, LOGE,
483 FL("Get Self Sta Entry fail"));
484 } else {
485 /* Pass the peer's staId */
486 sme_join_rsp->staId = sta_ds->staIndex;
487 sme_join_rsp->ucastSig =
488 sta_ds->ucUcastSig;
489 sme_join_rsp->bcastSig =
490 sta_ds->ucBcastSig;
491 sme_join_rsp->timingMeasCap =
492 sta_ds->timingMeasCap;
493#ifdef FEATURE_WLAN_TDLS
494 sme_join_rsp->tdls_prohibited =
495 session_entry->tdls_prohibited;
496 sme_join_rsp->tdls_chan_swit_prohibited =
497 session_entry->tdls_chan_swit_prohibited;
498#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530499 sme_join_rsp->nss = sta_ds->nss;
500 sme_join_rsp->max_rate_flags =
501 lim_get_max_rate_flags(mac_ctx, sta_ds);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 }
503 }
504 sme_join_rsp->beaconLength = 0;
505 sme_join_rsp->assocReqLength = 0;
506 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508#ifdef FEATURE_WLAN_ESE
509 sme_join_rsp->tspecIeLen = 0;
510#endif
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530511 lim_add_bss_info(session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
513 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800514
515 /* Send supported NSS 1x1 to SME */
516 sme_join_rsp->supported_nss_1x1 =
517 session_entry->supported_nss_1x1;
518 lim_log(mac_ctx, LOG1,
519 FL("SME Join Rsp is supported NSS 1X1: %d"),
520 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 }
522
523 sme_join_rsp->messageType = msg_type;
524 sme_join_rsp->length = (uint16_t) rsp_len;
525 sme_join_rsp->statusCode = result_code;
526 sme_join_rsp->protStatusCode = prot_status_code;
527
528 sme_join_rsp->sessionId = sme_session_id;
529 sme_join_rsp->transactionId = sme_transaction_id;
530
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530531 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800532 (uint32_t *)sme_join_rsp);
533}
534
535/**
536 * lim_send_sme_start_bss_rsp()
537 *
538 ***FUNCTION:
539 * This function is called to send eWNI_SME_START_BSS_RSP
540 * message to applications above MAC Software.
541 *
542 ***PARAMS:
543 *
544 ***LOGIC:
545 *
546 ***ASSUMPTIONS:
547 * NA
548 *
549 ***NOTE:
550 * NA
551 *
552 * @param pMac Pointer to Global MAC structure
553 * @param msgType Indicates message type
554 * @param resultCode Indicates the result of previously issued
555 * eWNI_SME_msgType_REQ message
556 *
557 * @return None
558 */
559
560void
561lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
562 uint16_t msgType, tSirResultCodes resultCode,
563 tpPESession psessionEntry, uint8_t smesessionId,
564 uint16_t smetransactionId)
565{
566
567 uint16_t size = 0;
568 tSirMsgQ mmhMsg;
569 tSirSmeStartBssRsp *pSirSmeRsp;
570 uint16_t ieLen;
571 uint16_t ieOffset, curLen;
572
573 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
574 lim_msg_str(msgType), lim_result_code_str(resultCode));
575 )
576
577 size = sizeof(tSirSmeStartBssRsp);
578
579 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530580 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 if (NULL == pSirSmeRsp) {
582 /* / Buffer not available. Log error */
583 lim_log(pMac, LOGP,
584 FL
585 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
586 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
590 } else {
591 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
592 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
593 ieLen = psessionEntry->schBeaconOffsetBegin
594 + psessionEntry->schBeaconOffsetEnd - ieOffset;
595 /* calculate the memory size to allocate */
596 size += ieLen;
597
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530598 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 if (NULL == pSirSmeRsp) {
600 /* / Buffer not available. Log error */
601 lim_log(pMac, LOGP,
602 FL
603 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
604
605 return;
606 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530607 qdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 size = sizeof(tSirSmeStartBssRsp);
609 if (resultCode == eSIR_SME_SUCCESS) {
610
611 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
612 psessionEntry->bssId);
613
614 /* Read beacon interval from session */
615 pSirSmeRsp->bssDescription.beaconInterval =
616 (uint16_t) psessionEntry->beaconParams.
617 beaconInterval;
618 pSirSmeRsp->bssType = psessionEntry->bssType;
619
620 if (cfg_get_capability_info
621 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
622 psessionEntry)
623 != eSIR_SUCCESS)
624 lim_log(pMac, LOGP,
625 FL
626 ("could not retrieve Capabilities value"));
627
628 lim_get_phy_mode(pMac,
629 (uint32_t *) &pSirSmeRsp->bssDescription.
630 nwType, psessionEntry);
631
632 pSirSmeRsp->bssDescription.channelId =
633 psessionEntry->currentOperChannel;
634
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700635 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530637 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638 ieFields,
639 psessionEntry->pSchBeaconFrameBegin +
640 ieOffset, (uint32_t) curLen);
641
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530642 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 ieFields) + curLen,
644 psessionEntry->pSchBeaconFrameEnd,
645 (uint32_t) psessionEntry->
646 schBeaconOffsetEnd);
647
648 /* subtracting size of length indicator itself and size of pointer to ieFields */
649 pSirSmeRsp->bssDescription.length =
650 sizeof(tSirBssDescription) - sizeof(uint16_t) -
651 sizeof(uint32_t) + ieLen;
652 /* This is the size of the message, subtracting the size of the pointer to ieFields */
653 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700654 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
656 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530657 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 pSirSmeRsp->HTProfile.
659 htSupportedChannelWidthSet =
660 psessionEntry->htSupportedChannelWidthSet;
661 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
662 psessionEntry->htRecommendedTxWidthSet;
663 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
664 psessionEntry->htSecondaryChannelOffset;
665 pSirSmeRsp->HTProfile.dot11mode =
666 psessionEntry->dot11mode;
667 pSirSmeRsp->HTProfile.htCapability =
668 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 pSirSmeRsp->HTProfile.vhtCapability =
670 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 pSirSmeRsp->HTProfile.apCenterChan =
672 psessionEntry->ch_center_freq_seg0;
673 pSirSmeRsp->HTProfile.apChanWidth =
674 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 }
676#endif
677 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 pSirSmeRsp->messageType = msgType;
680 pSirSmeRsp->length = size;
681
682 /* Update SME session Id and transaction Id */
683 pSirSmeRsp->sessionId = smesessionId;
684 pSirSmeRsp->transactionId = smetransactionId;
685 pSirSmeRsp->statusCode = resultCode;
686 if (psessionEntry != NULL)
687 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
688
689 mmhMsg.type = msgType;
690 mmhMsg.bodyptr = pSirSmeRsp;
691 mmhMsg.bodyval = 0;
692 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530693 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
694 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530696 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
697 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 }
699#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
700 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
701 psessionEntry, (uint16_t) resultCode, 0);
702#endif /* FEATURE_WLAN_DIAG_SUPPORT */
703
704 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
705} /*** end lim_send_sme_start_bss_rsp() ***/
706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707/**
708 * lim_send_sme_scan_rsp() - Send scan response to SME
709 * @pMac: Pointer to Global MAC structure
710 * @length: Indicates length of message
711 * @resultCode: Indicates the result of previously issued
712 * eWNI_SME_SCAN_REQ message
713 * @scan_id: scan identifier
714 *
715 * This function is called by lim_process_sme_req_messages() to send
716 * eWNI_SME_SCAN_RSP message to applications above MAC
717 *
718 * return: None
719 */
720
721void
722lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
723 uint8_t smesessionId, uint16_t smetranscationId,
724 uint32_t scan_id)
725{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
727 smetranscationId, scan_id);
728}
729
730/**
731 * lim_post_sme_scan_rsp_message()
732 *
733 ***FUNCTION:
734 * This function is called by lim_send_sme_scan_rsp() to send
735 * eWNI_SME_SCAN_RSP message with failed result code
736 *
737 ***NOTE:
738 * NA
739 *
740 * @param pMac Pointer to Global MAC structure
741 * @param length Indicates length of message
742 * @param resultCode failed result code
743 *
744 * @return None
745 */
746
747void
748lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
749 tSirResultCodes resultCode, uint8_t smesessionId,
750 uint16_t smetransactionId,
751 uint32_t scan_id)
752{
753 tpSirSmeScanRsp pSirSmeScanRsp;
754 tSirMsgQ mmhMsg;
755
756 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
757 lim_result_code_str(resultCode));
758
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530759 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 if (NULL == pSirSmeScanRsp) {
761 lim_log(pMac, LOGP,
762 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
763 return;
764 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530765 qdf_mem_set((void *)pSirSmeScanRsp, sizeof(tSirSmeScanRsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766
767 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
768 pSirSmeScanRsp->statusCode = resultCode;
769
770 /*Update SME session Id and transaction Id */
771 pSirSmeScanRsp->sessionId = smesessionId;
772 pSirSmeScanRsp->transcationId = smetransactionId;
773 pSirSmeScanRsp->scan_id = scan_id;
774
775 mmhMsg.type = eWNI_SME_SCAN_RSP;
776 mmhMsg.bodyptr = pSirSmeScanRsp;
777 mmhMsg.bodyval = 0;
778
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530779 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
781 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
782 (uint16_t) resultCode, 0);
783#endif /* FEATURE_WLAN_DIAG_SUPPORT */
784
785 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
786 return;
787
788} /*** lim_post_sme_scan_rsp_message ***/
789
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530791 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792{
793 tSirMsgQ mmhMsg;
794 tSirMsgQ *pMsg = (tSirMsgQ *) pCtx;
795
796 mmhMsg.type = pMsg->type;
797 mmhMsg.bodyptr = pMsg;
798 mmhMsg.bodyval = 0;
799
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530800 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801
802 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
803}
804
805/**
806 * lim_send_sme_disassoc_ntf()
807 *
808 ***FUNCTION:
809 * This function is called by limProcessSmeMessages() to send
810 * eWNI_SME_DISASSOC_RSP/IND message to host
811 *
812 ***PARAMS:
813 *
814 ***LOGIC:
815 *
816 ***ASSUMPTIONS:
817 * NA
818 *
819 ***NOTE:
820 * This function is used for sending eWNI_SME_DISASSOC_CNF,
821 * or eWNI_SME_DISASSOC_IND to host depending on
822 * disassociation trigger.
823 *
824 * @param peerMacAddr Indicates the peer MAC addr to which
825 * disassociate was initiated
826 * @param reasonCode Indicates the reason for Disassociation
827 * @param disassocTrigger Indicates the trigger for Disassociation
828 * @param aid Indicates the STAID. This parameter is
829 * present only on AP.
830 *
831 * @return None
832 */
833void
834lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
835 tSirMacAddr peerMacAddr,
836 tSirResultCodes reasonCode,
837 uint16_t disassocTrigger,
838 uint16_t aid,
839 uint8_t smesessionId,
840 uint16_t smetransactionId, tpPESession psessionEntry)
841{
842
843 uint8_t *pBuf;
844 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
845 tSirSmeDisassocInd *pSirSmeDisassocInd;
846 uint32_t *pMsg;
847 bool failure = false;
848
849 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
850 disassocTrigger, reasonCode);
851
852 switch (disassocTrigger) {
853 case eLIM_PEER_ENTITY_DISASSOC:
854 if (reasonCode != eSIR_SME_STA_NOT_ASSOCIATED) {
855 failure = true;
856 goto error;
857 }
858
859 case eLIM_HOST_DISASSOC:
860 /**
861 * Disassociation response due to
862 * host triggered disassociation
863 */
864
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530865 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866 if (NULL == pSirSmeDisassocRsp) {
867 /* Log error */
868 lim_log(pMac, LOGP, FL("Memory allocation failed"));
869 failure = true;
870 goto error;
871 }
872 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
873 "retCode: %d for " MAC_ADDRESS_STR),
874 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
875 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
876 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
877 /* sessionId */
878 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
879 *pBuf = smesessionId;
880 pBuf++;
881
882 /* transactionId */
883 lim_copy_u16(pBuf, smetransactionId);
884 pBuf += sizeof(uint16_t);
885
886 /* statusCode */
887 lim_copy_u32(pBuf, reasonCode);
888 pBuf += sizeof(tSirResultCodes);
889
890 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530891 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 pBuf += sizeof(tSirMacAddr);
893
894 /* Clear Station Stats */
895 /* for sta, it is always 1, IBSS is handled at halInitSta */
896
897#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
898
899 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
900 psessionEntry, (uint16_t) reasonCode, 0);
901#endif
902 pMsg = (uint32_t *) pSirSmeDisassocRsp;
903 break;
904
905 default:
906 /**
907 * Disassociation indication due to Disassociation
908 * frame reception from peer entity or due to
909 * loss of link with peer entity.
910 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530911 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 if (NULL == pSirSmeDisassocInd) {
913 /* Log error */
914 lim_log(pMac, LOGP, FL("Memory allocation failed"));
915 failure = true;
916 goto error;
917 }
918 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
919 "retCode: %d for " MAC_ADDRESS_STR),
920 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
921 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
922 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
923
924 /* Update SME session Id and Transaction Id */
925 pSirSmeDisassocInd->sessionId = smesessionId;
926 pSirSmeDisassocInd->transactionId = smetransactionId;
927 pSirSmeDisassocInd->reasonCode = reasonCode;
928 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
929
930 lim_copy_u32(pBuf, reasonCode);
931 pBuf += sizeof(tSirResultCodes);
932
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530933 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 pBuf += sizeof(tSirMacAddr);
935
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530936 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937
938#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
939 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
940 psessionEntry, (uint16_t) reasonCode, 0);
941#endif
942 pMsg = (uint32_t *) pSirSmeDisassocInd;
943
944 break;
945 }
946
947error:
948 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700949 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
952 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530953 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954 (uint32_t *) pMsg);
955} /*** end lim_send_sme_disassoc_ntf() ***/
956
957/** -----------------------------------------------------------------
958 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
959
960 After receiving disassociation frame from peer entity, this
961 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
962 reason code.
963
964 \param pMac - global mac structure
965 \param pStaDs - station dph hash node
966 \return none
967 \sa
968 ----------------------------------------------------------------- */
969void
970lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
971 tpPESession psessionEntry)
972{
973 tSirMsgQ mmhMsg;
974 tSirSmeDisassocInd *pSirSmeDisassocInd;
975
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530976 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 if (NULL == pSirSmeDisassocInd) {
978 lim_log(pMac, LOGP,
979 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
980 return;
981 }
982
983 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
984 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
985
986 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
987 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
988 pSirSmeDisassocInd->statusCode = pStaDs->mlmStaContext.disassocReason;
989 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
990
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530991 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530992 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530994 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530995 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996
997 pSirSmeDisassocInd->staId = pStaDs->staIndex;
998
999 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1000 mmhMsg.bodyptr = pSirSmeDisassocInd;
1001 mmhMsg.bodyval = 0;
1002
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301003 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1004 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1006 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1007 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1008#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1009
1010 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1011
1012} /*** end lim_send_sme_disassoc_ind() ***/
1013
1014/** -----------------------------------------------------------------
1015 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1016
1017 After receiving deauthentication frame from peer entity, this
1018 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1019 reason code.
1020
1021 \param pMac - global mac structure
1022 \param pStaDs - station dph hash node
1023 \return none
1024 \sa
1025 ----------------------------------------------------------------- */
1026void
1027lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1028 tpPESession psessionEntry)
1029{
1030 tSirMsgQ mmhMsg;
1031 tSirSmeDeauthInd *pSirSmeDeauthInd;
1032
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301033 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 if (NULL == pSirSmeDeauthInd) {
1035 lim_log(pMac, LOGP,
1036 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1037 return;
1038 }
1039
1040 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1041 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1042
1043 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1044 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1045 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1046 pSirSmeDeauthInd->statusCode =
1047 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1048 } else {
1049 /* Need to indicatet he reascon code over the air */
1050 pSirSmeDeauthInd->statusCode =
1051 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1052 }
1053 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301054 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301055 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301057 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301058 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1060
1061 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001062 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1063 pStaDs->mlmStaContext.disassocReason)
1064 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065
1066 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1067 mmhMsg.bodyptr = pSirSmeDeauthInd;
1068 mmhMsg.bodyval = 0;
1069
1070 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1071#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1072 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1073 0, pStaDs->mlmStaContext.cleanupTrigger);
1074#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1075
1076 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1077 return;
1078} /*** end lim_send_sme_deauth_ind() ***/
1079
1080#ifdef FEATURE_WLAN_TDLS
1081/**
1082 * lim_send_sme_tdls_del_sta_ind()
1083 *
1084 ***FUNCTION:
1085 * This function is called to send the TDLS STA context deletion to SME.
1086 *
1087 ***LOGIC:
1088 *
1089 ***ASSUMPTIONS:
1090 *
1091 ***NOTE:
1092 * NA
1093 *
1094 * @param pMac - Pointer to global MAC structure
1095 * @param pStaDs - Pointer to internal STA Datastructure
1096 * @param psessionEntry - Pointer to the session entry
1097 * @param reasonCode - Reason for TDLS sta deletion
1098 * @return None
1099 */
1100void
1101lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1102 tpPESession psessionEntry, uint16_t reasonCode)
1103{
1104 tSirMsgQ mmhMsg;
1105 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1106
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301107 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 if (NULL == pSirTdlsDelStaInd) {
1109 lim_log(pMac, LOGP,
1110 FL
1111 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1112 return;
1113 }
1114 /* messageType */
1115 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1116 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1117
1118 /* sessionId */
1119 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1120
1121 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301122 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301123 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124
1125 /* staId */
1126 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1127 (uint16_t) pStaDs->staIndex);
1128
1129 /* reasonCode */
1130 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1131
1132 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1133 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1134 mmhMsg.bodyval = 0;
1135
1136 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1137 return;
1138} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1139
1140/**
1141 * lim_send_sme_tdls_delete_all_peer_ind()
1142 *
1143 ***FUNCTION:
1144 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1145 * message to SME.
1146 *
1147 ***LOGIC:
1148 *
1149 ***ASSUMPTIONS:
1150 *
1151 ***NOTE:
1152 * NA
1153 *
1154 * @param pMac - Pointer to global MAC structure
1155 * @param psessionEntry - Pointer to the session entry
1156 * @return None
1157 */
1158void
1159lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1160{
1161 tSirMsgQ mmhMsg;
1162 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1163
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301164 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001165 if (NULL == pSirTdlsDelAllPeerInd) {
1166 lim_log(pMac, LOGP,
1167 FL
1168 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1169 return;
1170 }
1171 /* messageType */
1172 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1173 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1174
1175 /* sessionId */
1176 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1177
1178 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1179 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1180 mmhMsg.bodyval = 0;
1181
1182 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1183 return;
1184} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1185
1186/**
1187 * lim_send_sme_mgmt_tx_completion()
1188 *
1189 ***FUNCTION:
1190 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1191 * message to SME.
1192 *
1193 ***LOGIC:
1194 *
1195 ***ASSUMPTIONS:
1196 *
1197 ***NOTE:
1198 * NA
1199 *
1200 * @param pMac - Pointer to global MAC structure
1201 * @param psessionEntry - Pointer to the session entry
1202 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1203 * @return None
1204 */
1205void
1206lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
1207 tpPESession psessionEntry, uint32_t txCompleteStatus)
1208{
1209 tSirMsgQ mmhMsg;
1210 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1211
1212 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301213 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 if (NULL == pSirMgmtTxCompletionInd) {
1215 lim_log(pMac, LOGP,
1216 FL
1217 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1218 return;
1219 }
1220 /* messageType */
1221 pSirMgmtTxCompletionInd->messageType =
1222 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1223 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1224
1225 /* sessionId */
1226 pSirMgmtTxCompletionInd->sessionId = psessionEntry->smeSessionId;
1227
1228 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1229
1230 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1231 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1232 mmhMsg.bodyval = 0;
1233
1234 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1235 return;
1236} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1237
1238void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1239 void *events)
1240{
1241 tSirMsgQ mmhMsg;
1242
1243 switch (msgType) {
1244 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1245 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1246 break;
1247 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1248 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1249 break;
1250 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1251 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1252 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001253 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1254 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1255 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 }
1257
1258 mmhMsg.bodyptr = events;
1259 mmhMsg.bodyval = 0;
1260 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1261 return;
1262}
1263#endif /* FEATURE_WLAN_TDLS */
1264
1265/**
1266 * lim_send_sme_deauth_ntf()
1267 *
1268 ***FUNCTION:
1269 * This function is called by limProcessSmeMessages() to send
1270 * eWNI_SME_DISASSOC_RSP/IND message to host
1271 *
1272 ***PARAMS:
1273 *
1274 ***LOGIC:
1275 *
1276 ***ASSUMPTIONS:
1277 * NA
1278 *
1279 ***NOTE:
1280 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1281 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1282 *
1283 * @param peerMacAddr Indicates the peer MAC addr to which
1284 * deauthentication was initiated
1285 * @param reasonCode Indicates the reason for Deauthetication
1286 * @param deauthTrigger Indicates the trigger for Deauthetication
1287 * @param aid Indicates the STAID. This parameter is present
1288 * only on AP.
1289 *
1290 * @return None
1291 */
1292void
1293lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1294 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1295 uint16_t aid, uint8_t smesessionId,
1296 uint16_t smetransactionId)
1297{
1298 uint8_t *pBuf;
1299 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1300 tSirSmeDeauthInd *pSirSmeDeauthInd;
1301 tpPESession psessionEntry;
1302 uint8_t sessionId;
1303 uint32_t *pMsg;
1304
1305 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1306 switch (deauthTrigger) {
1307 case eLIM_PEER_ENTITY_DEAUTH:
1308 return;
1309
1310 case eLIM_HOST_DEAUTH:
1311 /**
1312 * Deauthentication response to host triggered
1313 * deauthentication.
1314 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301315 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316 if (NULL == pSirSmeDeauthRsp) {
1317 /* Log error */
1318 lim_log(pMac, LOGP,
1319 FL
1320 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1321
1322 return;
1323 }
1324 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1325 "retCode: %d for" MAC_ADDRESS_STR),
1326 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1327 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1328 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1329 pSirSmeDeauthRsp->statusCode = reasonCode;
1330 pSirSmeDeauthRsp->sessionId = smesessionId;
1331 pSirSmeDeauthRsp->transactionId = smetransactionId;
1332
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001333 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301334 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335
1336#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1337 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1338 psessionEntry, 0, (uint16_t) reasonCode);
1339#endif
1340 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1341
1342 break;
1343
1344 default:
1345 /**
1346 * Deauthentication indication due to Deauthentication
1347 * frame reception from peer entity or due to
1348 * loss of link with peer entity.
1349 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301350 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 if (NULL == pSirSmeDeauthInd) {
1352 /* Log error */
1353 lim_log(pMac, LOGP,
1354 FL
1355 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1356
1357 return;
1358 }
1359 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1360 "retCode: %d for " MAC_ADDRESS_STR),
1361 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1362 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1363 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1364 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1365
1366 /* sessionId */
1367 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1368 *pBuf++ = smesessionId;
1369
1370 /* transaction ID */
1371 lim_copy_u16(pBuf, smetransactionId);
1372 pBuf += sizeof(uint16_t);
1373
1374 /* status code */
1375 lim_copy_u32(pBuf, reasonCode);
1376 pBuf += sizeof(tSirResultCodes);
1377
1378 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301379 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 pBuf += sizeof(tSirMacAddr);
1381
1382 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301383 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301384 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385
1386#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1387 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1388 psessionEntry, 0, (uint16_t) reasonCode);
1389#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1390 pMsg = (uint32_t *) pSirSmeDeauthInd;
1391
1392 break;
1393 }
1394
1395 /*Delete the PE session created */
1396 if (psessionEntry != NULL) {
1397 pe_delete_session(pMac, psessionEntry);
1398 }
1399
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301400 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 (uint32_t *) pMsg);
1402
1403} /*** end lim_send_sme_deauth_ntf() ***/
1404
1405/**
1406 * lim_send_sme_wm_status_change_ntf() - Send Notification
1407 * @mac_ctx: Global MAC Context
1408 * @status_change_code: Indicates the change in the wireless medium.
1409 * @status_change_info: Indicates the information associated with
1410 * change in the wireless medium.
1411 * @info_len: Indicates the length of status change information
1412 * being sent.
1413 * @session_id SessionID
1414 *
1415 * This function is called by limProcessSmeMessages() to send
1416 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1417 *
1418 * Return: None
1419 */
1420void
1421lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1422 tSirSmeStatusChangeCode status_change_code,
1423 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1424{
1425 tSirMsgQ msg;
1426 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
1427
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301428 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 if (NULL == wm_status_change_ntf) {
1430 lim_log(mac_ctx, LOGE,
1431 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1432 return;
1433 }
1434
1435 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1436 msg.bodyval = 0;
1437 msg.bodyptr = wm_status_change_ntf;
1438
1439 switch (status_change_code) {
1440 case eSIR_SME_RADAR_DETECTED:
1441 break;
1442 default:
1443 wm_status_change_ntf->messageType =
1444 eWNI_SME_WM_STATUS_CHANGE_NTF;
1445 wm_status_change_ntf->statusChangeCode = status_change_code;
1446 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1447 wm_status_change_ntf->sessionId = session_id;
1448 if (sizeof(wm_status_change_ntf->statusChangeInfo) >=
1449 info_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301450 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1452 (uint8_t *) status_change_info, info_len);
1453 }
1454 lim_log(mac_ctx, LOGE,
1455 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1456 status_change_code, info_len);
1457 break;
1458 }
1459
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301460 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301462 qdf_mem_free(wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 lim_log(mac_ctx, LOGP,
1464 FL("lim_sys_process_mmh_msg_api failed"));
1465 }
1466
1467} /*** end lim_send_sme_wm_status_change_ntf() ***/
1468
1469/**
1470 * lim_send_sme_set_context_rsp()
1471 *
1472 ***FUNCTION:
1473 * This function is called by limProcessSmeMessages() to send
1474 * eWNI_SME_SETCONTEXT_RSP message to host
1475 *
1476 ***PARAMS:
1477 *
1478 ***LOGIC:
1479 *
1480 ***ASSUMPTIONS:
1481 * NA
1482 *
1483 ***NOTE:
1484 *
1485 * @param pMac Pointer to Global MAC structure
1486 * @param peerMacAddr Indicates the peer MAC addr to which
1487 * setContext was performed
1488 * @param aid Indicates the aid corresponding to the peer MAC
1489 * address
1490 * @param resultCode Indicates the result of previously issued
1491 * eWNI_SME_SETCONTEXT_RSP message
1492 *
1493 * @return None
1494 */
1495void
1496lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301497 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 tSirResultCodes resultCode,
1499 tpPESession psessionEntry, uint8_t smesessionId,
1500 uint16_t smetransactionId)
1501{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 tSirMsgQ mmhMsg;
1503 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1504
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301505 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 if (NULL == pSirSmeSetContextRsp) {
1507 /* Log error */
1508 lim_log(pMac, LOGP,
1509 FL
1510 ("call to AllocateMemory failed for SmeSetContextRsp"));
1511
1512 return;
1513 }
1514
1515 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1516 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1517 pSirSmeSetContextRsp->statusCode = resultCode;
1518
Anurag Chouhanc5548422016-02-24 18:33:27 +05301519 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520
1521 /* Update SME session and transaction Id */
1522 pSirSmeSetContextRsp->sessionId = smesessionId;
1523 pSirSmeSetContextRsp->transactionId = smetransactionId;
1524
1525 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1526 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1527 mmhMsg.bodyval = 0;
1528 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301529 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1530 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301532 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1533 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 }
1535
1536#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1537 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1538 psessionEntry, (uint16_t) resultCode, 0);
1539#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1540
1541 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1542} /*** end lim_send_sme_set_context_rsp() ***/
1543
1544/**
1545 * lim_send_sme_neighbor_bss_ind()
1546 *
1547 ***FUNCTION:
1548 * This function is called by lim_lookup_nadd_hash_entry() to send
1549 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1550 *
1551 ***PARAMS:
1552 *
1553 ***LOGIC:
1554 *
1555 ***ASSUMPTIONS:
1556 * NA
1557 *
1558 ***NOTE:
1559 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1560 * host upon detecting new BSS during background scanning if CFG
1561 * option is enabled for sending such indication
1562 *
1563 * @param pMac - Pointer to Global MAC structure
1564 * @return None
1565 */
1566
1567void
1568lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1569{
1570 tSirMsgQ msgQ;
1571 uint32_t val;
1572 tSirSmeNeighborBssInd *pNewBssInd;
1573
1574 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1575 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1576 pMac->lim.gLimRspReqd)) {
1577 /* LIM is not in background scan state OR */
1578 /* current scan is initiated by HDD. */
1579 /* No need to send new BSS indication to HDD */
1580 return;
1581 }
1582
1583 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1584 eSIR_SUCCESS) {
1585 lim_log(pMac, LOGP,
1586 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1587
1588 return;
1589 }
1590
1591 if (val == 0)
1592 return;
1593
1594 /**
1595 * Need to indicate new BSSs found during
1596 * background scanning to host.
1597 * Allocate buffer for sending indication.
1598 * Length of buffer is length of BSS description
1599 * and length of header itself
1600 */
1601 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1602 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301603 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 if (NULL == pNewBssInd) {
1605 /* Log error */
1606 lim_log(pMac, LOGP,
1607 FL
1608 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1609
1610 return;
1611 }
1612
1613 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1614 pNewBssInd->length = (uint16_t) val;
1615 pNewBssInd->sessionId = 0;
1616
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301617 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 (uint8_t *) &pBssDescr->bssDescription,
1619 pBssDescr->bssDescription.length + sizeof(uint16_t));
1620
1621 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1622 msgQ.bodyptr = pNewBssInd;
1623 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301624 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1626} /*** end lim_send_sme_neighbor_bss_ind() ***/
1627
1628/** -----------------------------------------------------------------
1629 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1630 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1631 \ SME only looks at rc and tspec field.
1632 \param pMac - global mac structure
1633 \param rspReqd - is SmeAddTsRsp required
1634 \param status - status code of SME_ADD_TS_RSP
1635 \return tspec
1636 \sa
1637 ----------------------------------------------------------------- */
1638void
1639lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1640 tpPESession psessionEntry, tSirMacTspecIE tspec,
1641 uint8_t smesessionId, uint16_t smetransactionId)
1642{
1643 tpSirAddtsRsp rsp;
1644 tSirMsgQ mmhMsg;
1645
1646 if (!rspReqd)
1647 return;
1648
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301649 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 if (NULL == rsp) {
1651 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1652 return;
1653 }
1654
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301655 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 rsp->messageType = eWNI_SME_ADDTS_RSP;
1657 rsp->rc = status;
1658 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1659 rsp->rsp.tspec = tspec;
1660 /* Update SME session Id and transcation Id */
1661 rsp->sessionId = smesessionId;
1662 rsp->transactionId = smetransactionId;
1663
1664 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1665 mmhMsg.bodyptr = rsp;
1666 mmhMsg.bodyval = 0;
1667 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301668 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1669 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301671 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1672 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 }
1674#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1675 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1676 0);
1677#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1678
1679 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1680 return;
1681}
1682
1683void
1684lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1685 tpPESession psessionEntry, uint8_t smesessionId,
1686 uint16_t smetransactionId)
1687{
1688 tpSirDeltsRsp rsp;
1689 tSirMsgQ mmhMsg;
1690
1691 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1692 delts->aid,
1693 delts->req.tsinfo.traffic.tsid,
1694 delts->req.tsinfo.traffic.userPrio, status);
1695 if (!delts->rspReqd)
1696 return;
1697
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301698 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 if (NULL == rsp) {
1700 /* Log error */
1701 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1702 return;
1703 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301704 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705
1706 if (psessionEntry != NULL) {
1707
1708 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301709 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301710 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 sizeof(tSirDeltsReqInfo));
1712 }
1713
1714 rsp->messageType = eWNI_SME_DELTS_RSP;
1715 rsp->rc = status;
1716
1717 /* Update SME session Id and transcation Id */
1718 rsp->sessionId = smesessionId;
1719 rsp->transactionId = smetransactionId;
1720
1721 mmhMsg.type = eWNI_SME_DELTS_RSP;
1722 mmhMsg.bodyptr = rsp;
1723 mmhMsg.bodyval = 0;
1724 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301725 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1726 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301728 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1729 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 }
1731#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1732 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1733 (uint16_t) status, 0);
1734#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1735
1736 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1737}
1738
1739void
1740lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1741 tpPESession psessionEntry)
1742{
1743 tpSirDeltsRsp rsp;
1744 tSirMsgQ mmhMsg;
1745
1746 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1747 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1748
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301749 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 if (NULL == rsp) {
1751 /* Log error */
1752 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1753 return;
1754 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301755 qdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756
1757 rsp->messageType = eWNI_SME_DELTS_IND;
1758 rsp->rc = eSIR_SUCCESS;
1759 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301760 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761
1762 /* Update SME session Id and SME transaction Id */
1763
1764 rsp->sessionId = psessionEntry->smeSessionId;
1765 rsp->transactionId = psessionEntry->transactionId;
1766
1767 mmhMsg.type = eWNI_SME_DELTS_IND;
1768 mmhMsg.bodyptr = rsp;
1769 mmhMsg.bodyval = 0;
1770 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1771#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1772 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1773 0);
1774#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1775
1776 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1777}
1778
1779/**
1780 * lim_send_sme_pe_statistics_rsp()
1781 *
1782 ***FUNCTION:
1783 * This function is called to send 802.11 statistics response to HDD.
1784 * This function posts the result back to HDD. This is a response to
1785 * HDD's request for statistics.
1786 *
1787 ***PARAMS:
1788 *
1789 ***LOGIC:
1790 *
1791 ***ASSUMPTIONS:
1792 * NA
1793 *
1794 ***NOTE:
1795 * NA
1796 *
1797 * @param pMac Pointer to Global MAC structure
1798 * @param p80211Stats Statistics sent in response
1799 * @param resultCode TODO:
1800 *
1801 *
1802 * @return none
1803 */
1804
1805void
1806lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1807{
1808 tSirMsgQ mmhMsg;
1809 uint8_t sessionId;
1810 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1811 tpPESession pPeSessionEntry;
1812
1813 /* Get the Session Id based on Sta Id */
1814 pPeSessionEntry =
1815 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1816
1817 /* Fill the Session Id */
1818 if (NULL != pPeSessionEntry) {
1819 /* Fill the Session Id */
1820 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1821 }
1822
1823 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1824
1825 /* msgType should be WMA_GET_STATISTICS_RSP */
1826 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1827
1828 mmhMsg.bodyptr = stats;
1829 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301830 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1832
1833 return;
1834
1835} /*** end lim_send_sme_pe_statistics_rsp() ***/
1836
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001837#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001839 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1840 * @pMac: Pointer to global pMac structure
1841 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 * This function is called to send tsm stats response to HDD.
1844 * This function posts the result back to HDD. This is a response to
1845 * HDD's request to get tsm stats.
1846 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001847 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001849void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1850 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851{
1852 tSirMsgQ mmhMsg;
1853 uint8_t sessionId;
1854 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1855 tpPESession pPeSessionEntry = NULL;
1856
1857 /* Get the Session Id based on Sta Id */
1858 pPeSessionEntry =
1859 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1860
1861 /* Fill the Session Id */
1862 if (NULL != pPeSessionEntry) {
1863 /* Fill the Session Id */
1864 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1865 } else {
1866 PELOGE(lim_log
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001867 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1868 pPeStats->staId);)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 return;
1870 }
1871
1872 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1873 pPeStats->tsmMetrics.RoamingCount
1874 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1875 pPeStats->tsmMetrics.RoamingDly
1876 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1877
1878 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1879 mmhMsg.bodyptr = pStats;
1880 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301881 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1883
1884 return;
1885} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1886
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001887#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888
1889void
1890lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1891 tSirMacAddr peerMacAddr,
1892 uint16_t staIndex,
1893 uint8_t ucastIdx,
1894 uint8_t bcastIdx,
1895 uint8_t *beacon,
1896 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1897{
1898 tSirMsgQ mmhMsg;
1899 tSmeIbssPeerInd *pNewPeerInd;
1900
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301901 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 if (NULL == pNewPeerInd) {
1903 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
1904 return;
1905 }
1906
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301907 qdf_mem_set((void *)pNewPeerInd, (sizeof(tSmeIbssPeerInd) + beaconLen),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 0);
1909
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301910 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301911 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 pNewPeerInd->staId = staIndex;
1913 pNewPeerInd->ucastSig = ucastIdx;
1914 pNewPeerInd->bcastSig = bcastIdx;
1915 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1916 pNewPeerInd->mesgType = msgType;
1917 pNewPeerInd->sessionId = sessionId;
1918
1919 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301920 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1922 beaconLen);
1923 }
1924
1925 mmhMsg.type = msgType;
1926 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301927 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1929
1930}
1931
1932/**
1933 * lim_handle_csa_offload_msg() - Handle CSA offload message
1934 * @mac_ctx: pointer to global adapter context
1935 * @msg: Message pointer.
1936 *
1937 * Return: None
1938 */
1939void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
1940{
1941 tpPESession session_entry;
1942 tSirMsgQ mmh_msg;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301943 struct csa_offload_params *csa_params =
1944 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 tpSmeCsaOffloadInd csa_offload_ind;
1946 tpDphHashNode sta_ds = NULL;
1947 uint8_t session_id;
1948 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301949 uint16_t chan_space = 0;
Amar Singhale4f28ee2015-10-21 14:36:56 -07001950 struct ch_params_s ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301951
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001953 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301955 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
1956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 if (!csa_params) {
1958 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
1959 return;
1960 }
1961
1962 session_entry =
1963 pe_find_session_by_bssid(mac_ctx,
1964 csa_params->bssId, &session_id);
1965 if (!session_entry) {
1966 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301967 FL("Session does not exists for %pM"),
1968 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 goto err;
1970 }
1971
1972 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1973 &session_entry->dph.dphHashTable);
1974
1975 if (!sta_ds) {
1976 lim_log(mac_ctx, LOGE,
1977 FL("sta_ds does not exist"));
1978 goto err;
1979 }
1980
1981 if (LIM_IS_STA_ROLE(session_entry)) {
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05301982 /*
1983 * on receiving channel switch announcement from AP, delete all
1984 * TDLS peers before leaving BSS and proceed for channel switch
1985 */
1986 lim_delete_tdls_peers(mac_ctx, session_entry);
1987
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001988 lim_ch_switch = &session_entry->gLimChannelSwitch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 session_entry->gLimChannelSwitch.switchMode =
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301990 csa_params->switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 /* timer already started by firmware, switch immediately */
1992 session_entry->gLimChannelSwitch.switchCount = 0;
1993 session_entry->gLimChannelSwitch.primaryChannel =
1994 csa_params->channel;
1995 session_entry->gLimChannelSwitch.state =
1996 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1997 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001998 lim_ch_switch->sec_ch_offset =
1999 session_entry->htSecondaryChannelOffset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302000 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2001 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2002 chnl_switch_info =
2003 &session_entry->gLimWiderBWChannelSwitch;
2004
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302005 lim_log(mac_ctx, LOG1,
2006 FL("vht:%d ht:%d flag:%x chan:%d seg1:%d seg2:%d width:%d country:%s class:%d"),
2007 session_entry->vhtCapability,
2008 session_entry->htSupportedChannelWidthSet,
2009 csa_params->ies_present_flag,
2010 csa_params->channel, csa_params->new_ch_freq_seg1,
2011 csa_params->new_ch_freq_seg2,
2012 csa_params->new_ch_width,
2013 mac_ctx->scan.countryCodeCurrent,
2014 csa_params->new_op_class);
2015
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 if (session_entry->vhtCapability &&
2017 session_entry->htSupportedChannelWidthSet) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
2019 chnl_switch_info->newChanWidth =
2020 csa_params->new_ch_width;
2021 chnl_switch_info->newCenterChanFreq0 =
2022 csa_params->new_ch_freq_seg1;
2023 chnl_switch_info->newCenterChanFreq1 =
2024 csa_params->new_ch_freq_seg2;
2025 session_entry->gLimChannelSwitch.state =
2026 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2027 session_entry->gLimChannelSwitch.ch_width =
2028 csa_params->new_ch_width + 1;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302029 } else if (csa_params->ies_present_flag
2030 & lim_xcsa_ie_present) {
2031 chan_space =
Amar Singhal22995112016-01-22 10:42:33 -08002032 cds_reg_dmn_get_chanwidth_from_opclass(
Gupta, Kapil121bf212015-11-25 19:21:29 +05302033 mac_ctx->scan.countryCodeCurrent,
2034 csa_params->channel,
2035 csa_params->new_op_class);
2036 session_entry->gLimChannelSwitch.state =
2037 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2038
2039 if (chan_space == 80) {
2040 chnl_switch_info->newChanWidth =
2041 CH_WIDTH_80MHZ;
2042 } else if (chan_space == 40) {
2043 chnl_switch_info->newChanWidth =
2044 CH_WIDTH_40MHZ;
2045 } else {
2046 chnl_switch_info->newChanWidth =
2047 CH_WIDTH_20MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002048 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302049 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2050 }
2051
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002052 ch_params.ch_width =
2053 chnl_switch_info->newChanWidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002054 cds_set_channel_params(csa_params->channel,
2055 0, &ch_params);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302056 chnl_switch_info->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002057 ch_params.center_freq_seg0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302058 /*
2059 * This is not applicable for 20/40/80 MHz.
2060 * Only used when we support 80+80 MHz operation.
2061 * In case of 80+80 MHz, this parameter indicates
2062 * center channel frequency index of 80 MHz
2063 * channel offrequency segment 1.
2064 */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002065 chnl_switch_info->newCenterChanFreq1 =
2066 ch_params.center_freq_seg1;
2067 lim_ch_switch->sec_ch_offset =
2068 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302069
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 }
Gupta, Kapil121bf212015-11-25 19:21:29 +05302071 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2072 chnl_switch_info->newCenterChanFreq0;
2073 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2074 chnl_switch_info->newCenterChanFreq1;
2075 session_entry->gLimChannelSwitch.ch_width =
2076 chnl_switch_info->newChanWidth;
2077
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 } else if (session_entry->htSupportedChannelWidthSet) {
Gupta, Kapil121bf212015-11-25 19:21:29 +05302079 if (csa_params->ies_present_flag
2080 & lim_xcsa_ie_present) {
2081 chan_space =
Amar Singhal22995112016-01-22 10:42:33 -08002082 cds_reg_dmn_get_chanwidth_from_opclass(
Gupta, Kapil121bf212015-11-25 19:21:29 +05302083 mac_ctx->scan.countryCodeCurrent,
2084 csa_params->channel,
2085 csa_params->new_op_class);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002086 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302087 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2088 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002089 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302090 CH_WIDTH_40MHZ;
2091 chnl_switch_info->newChanWidth =
2092 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002093 ch_params.ch_width =
2094 chnl_switch_info->newChanWidth;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002095 cds_set_channel_params(
2096 csa_params->channel,
2097 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002098 lim_ch_switch->ch_center_freq_seg0 =
2099 ch_params.center_freq_seg0;
2100 lim_ch_switch->sec_ch_offset =
2101 ch_params.sec_ch_offset;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302102 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002103 lim_ch_switch->ch_width =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302104 CH_WIDTH_20MHZ;
2105 chnl_switch_info->newChanWidth =
2106 CH_WIDTH_40MHZ;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002107 lim_ch_switch->state =
Gupta, Kapil121bf212015-11-25 19:21:29 +05302108 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002109 lim_ch_switch->sec_ch_offset =
2110 PHY_SINGLE_CHANNEL_CENTERED;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302111 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 } else {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002113 lim_ch_switch->ch_width =
2114 CH_WIDTH_40MHZ;
2115 lim_ch_switch->state =
2116 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2117 ch_params.ch_width = CH_WIDTH_40MHZ;
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002118 cds_set_channel_params(csa_params->channel,
2119 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002120 lim_ch_switch->ch_center_freq_seg0 =
2121 ch_params.center_freq_seg0;
2122 lim_ch_switch->sec_ch_offset =
2123 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 }
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002125
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 }
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302127 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
2128 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129
2130 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302131 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 if (NULL == csa_offload_ind) {
2133 lim_log(mac_ctx, LOGE,
2134 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
2135 goto err;
2136 }
2137
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302138 qdf_mem_set(csa_offload_ind, sizeof(tSmeCsaOffloadInd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2140 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302141 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302142 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2144 mmh_msg.bodyptr = csa_offload_ind;
2145 mmh_msg.bodyval = 0;
2146 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002147 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 MTRACE(mac_trace_msg_tx
2149 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2150#ifdef FEATURE_WLAN_DIAG_SUPPORT
2151 lim_diag_event_report(mac_ctx,
2152 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2153 eSIR_SUCCESS, eSIR_SUCCESS);
2154#endif
2155 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
2156 }
2157
2158err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302159 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160}
2161
2162/*--------------------------------------------------------------------------
2163 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2164
2165 \param pMac - pointer to global adapter context
2166 \param sessionId - Message pointer.
2167
2168 \sa
2169 --------------------------------------------------------------------------*/
2170
2171void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ MsgQ)
2172{
2173 tpPESession psessionEntry;
2174 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2175
2176 psessionEntry =
2177 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2178 if (psessionEntry == NULL) {
2179 lim_log(pMac, LOGE,
2180 FL("Session Does not exist for given sessionID %d"),
2181 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002182 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 return;
2184 }
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002185 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002187 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002189 else if (LIM_IS_NDI_ROLE(psessionEntry))
2190 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191 else
2192 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2193
2194}
2195
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196/** -----------------------------------------------------------------
2197 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2198 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2199 \ SME only looks at rc and tspec field.
2200 \param pMac - global mac structure
2201 \param rspReqd - is SmeAddTsRsp required
2202 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2203 \return tspec
2204 \sa
2205 ----------------------------------------------------------------- */
2206void
2207lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2208 uint8_t smesessionId)
2209{
2210 tSirMsgQ mmhMsg;
2211
2212 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2213 mmhMsg.bodyptr = aggrQosRsp;
2214 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302215 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2216 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2218
2219 return;
2220}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221
2222void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2223 uint8_t smesessionId)
2224{
2225 tSirMsgQ mmhMsg;
2226 tSmeMaxAssocInd *pSmeMaxAssocInd;
2227
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302228 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 if (NULL == pSmeMaxAssocInd) {
2230 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2231 return;
2232 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302233 qdf_mem_set((void *)pSmeMaxAssocInd, sizeof(tSmeMaxAssocInd), 0);
2234 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302235 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2237 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2238 pSmeMaxAssocInd->sessionId = smesessionId;
2239 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2240 mmhMsg.bodyptr = pSmeMaxAssocInd;
2241 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2242 " sme session id %d"),
2243 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2244 MAC_ADDR_ARRAY(peerMacAddr));
2245 )
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302246 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2247 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2249
2250 return;
2251}
2252
2253/** -----------------------------------------------------------------
2254 \brief lim_send_sme_dfs_event_notify() - sends
2255 eWNI_SME_DFS_RADAR_FOUND
2256 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2257 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2258 that a RADAR is found on current operating channel and SAP-
2259 has to move to a new channel.
2260 \param pMac - global mac structure
2261 \param msgType - message type received from lower layer
2262 \param event - event data received from lower layer
2263 \return none
2264 \sa
2265 ----------------------------------------------------------------- */
2266void
2267lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2268{
2269 tSirMsgQ mmhMsg;
2270 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2271 mmhMsg.bodyptr = event;
2272 mmhMsg.bodyval = 0;
2273 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2274 return;
2275}
2276
2277/*--------------------------------------------------------------------------
2278 \brief lim_send_dfs_chan_sw_ie_update()
2279 This timer handler updates the channel switch IE in beacon template
2280
2281 \param pMac - pointer to global adapter context
2282 \return - channel to scan from valid session else zero.
2283 \sa
2284 --------------------------------------------------------------------------*/
2285static void
2286lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2287{
2288
2289 /* Update the beacon template and send to FW */
2290 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2291 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2292 return;
2293 }
2294
2295 /* Send update beacon template message */
2296 lim_send_beacon_ind(pMac, psessionEntry);
2297 PELOG1(lim_log(pMac, LOG1,
2298 FL(" Updated CSA IE, IE COUNT = %d"),
2299 psessionEntry->gLimChannelSwitch.switchCount);
2300 )
2301
2302 return;
2303}
2304
2305/** -----------------------------------------------------------------
2306 \brief lim_send_sme_ap_channel_switch_resp() - sends
2307 eWNI_SME_CHANNEL_CHANGE_RSP
2308 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2309 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2310 that the Channel change has been done to the specified target
2311 channel in the Channel change request
2312 \param pMac - global mac structure
2313 \param psessionEntry - session info
2314 \param pChnlParams - Channel switch params
2315 --------------------------------------------------------------------*/
2316void
2317lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2318 tpPESession psessionEntry,
2319 tpSwitchChannelParams pChnlParams)
2320{
2321 tSirMsgQ mmhMsg;
2322 tpSwitchChannelParams pSmeSwithChnlParams;
2323 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002324 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002325 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002326 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327
2328 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302329 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 if (NULL == pSmeSwithChnlParams) {
2331 lim_log(pMac, LOGP,
2332 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2333 return;
2334 }
2335
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302336 qdf_mem_set((void *)pSmeSwithChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 sizeof(tSwitchChannelParams), 0);
2338
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302339 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 sizeof(tSwitchChannelParams));
2341
2342 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002343 ch_width = pSmeSwithChnlParams->ch_width;
2344 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345
2346 /*
2347 * Pass the sme sessionID to SME instead
2348 * PE session ID.
2349 */
2350 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2351
2352 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2353 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2354 mmhMsg.bodyval = 0;
2355 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2356
2357 /*
2358 * We should start beacon transmission only if the new
2359 * channel after channel change is Non-DFS. For a DFS
2360 * channel, PE will receive an explicit request from
2361 * upper layers to start the beacon transmission .
2362 */
2363
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002364 if (ch_width == CH_WIDTH_160MHZ) {
2365 is_ch_dfs = true;
2366 } else if (ch_width == CH_WIDTH_80P80MHZ) {
2367 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
2368 cds_get_channel_state(ch_center_freq_seg1 -
2369 SIR_80MHZ_START_CENTER_CH_DIFF) ==
2370 CHANNEL_STATE_DFS)
2371 is_ch_dfs = true;
2372 } else {
2373 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
2374 is_ch_dfs = true;
2375 }
2376
2377 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 if (channelId == psessionEntry->currentOperChannel) {
2379 lim_apply_configuration(pMac, psessionEntry);
2380 lim_send_beacon_ind(pMac, psessionEntry);
2381 } else {
2382 PELOG1(lim_log(pMac, LOG1,
2383 FL
2384 ("Failed to Transmit Beacons on channel = %d"
2385 "after AP channel change response"),
2386 psessionEntry->bcnLen);
2387 )
2388 }
2389 }
2390 return;
2391}
2392
2393/** -----------------------------------------------------------------
2394 \brief lim_process_beacon_tx_success_ind() - This function is used
2395 explicitely to handle successful beacon transmission indication
2396 from the FW. This is a generic event generated by the FW afer the
2397 first beacon is sent out after the beacon template update by the
2398 host
2399 \param pMac - global mac structure
2400 \param psessionEntry - session info
2401 \return none
2402 \sa
2403 ----------------------------------------------------------------- */
2404void
2405lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2406{
2407 /* Currently, this event is used only for DFS channel switch announcement
2408 * IE update in the template. If required to be used for other IE updates
2409 * add appropriate code by introducing a state variable
2410 */
2411 tpPESession psessionEntry;
2412 tSirMsgQ mmhMsg;
2413 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2414 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2415 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2416 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2417 (tSirFirstBeaconTxCompleteInd *) event;
2418
2419 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2420 if (psessionEntry == NULL) {
2421 lim_log(pMac, LOGE,
2422 FL("Session Does not exist for given sessionID"));
2423 return;
2424 }
2425
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302426 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2427 GET_LIM_SYSTEM_ROLE(psessionEntry),
2428 psessionEntry->dfsIncludeChanSwIe,
2429 psessionEntry->gLimOperatingMode.present);
2430
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 if (LIM_IS_AP_ROLE(psessionEntry) &&
2432 true == psessionEntry->dfsIncludeChanSwIe) {
2433 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2434 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2435 /*
2436 * Send the next beacon with updated CSA IE count
2437 */
2438 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2439 /* Decrement the IE count */
2440 psessionEntry->gLimChannelSwitch.switchCount--;
2441 } else {
2442 /* Done with CSA IE update, send response back to SME */
2443 psessionEntry->gLimChannelSwitch.switchCount = 0;
2444 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2445 psessionEntry->gLimChannelSwitch.switchMode = 0;
2446 psessionEntry->dfsIncludeChanSwIe = false;
2447 psessionEntry->dfsIncludeChanWrapperIe = false;
2448
2449 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302450 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451
2452 if (NULL == pChanSwTxResponse) {
2453 lim_log(pMac, LOGP,
2454 FL
2455 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2456 return;
2457 }
2458
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302459 qdf_mem_set((void *)pChanSwTxResponse, length, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 pChanSwTxResponse->sessionId =
2461 psessionEntry->smeSessionId;
2462 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302463 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464
2465 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2466 mmhMsg.bodyptr = pChanSwTxResponse;
2467 mmhMsg.bodyval = 0;
2468 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2469 }
2470 }
2471
2472 if (LIM_IS_AP_ROLE(psessionEntry) &&
2473 psessionEntry->gLimOperatingMode.present) {
2474 /* Done with nss update, send response back to SME */
2475 psessionEntry->gLimOperatingMode.present = 0;
2476 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302477 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 if (NULL == beacon_tx_comp_rsp_ptr) {
2479 lim_log(pMac, LOGP,
2480 FL
2481 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2482 return;
2483 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302484 qdf_mem_set((void *)beacon_tx_comp_rsp_ptr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 sizeof(*beacon_tx_comp_rsp_ptr), 0);
2486 beacon_tx_comp_rsp_ptr->session_id =
2487 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302488 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2490 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2491 mmhMsg.bodyval = 0;
2492 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2493 }
2494 return;
2495}