blob: ec18e49165a5351eab87e03e807ee5cb82ba4fcb [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
3 *
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
39#include "cdf_types.h"
40#include "wni_api.h"
41#include "sir_common.h"
42#include "ani_global.h"
43
44#include "wni_cfg.h"
45#include "sys_def.h"
46#include "cfg_api.h"
47
48#include "sch_api.h"
49#include "utils_api.h"
50#include "lim_utils.h"
51#include "lim_security_utils.h"
52#include "lim_ser_des_utils.h"
53#include "lim_send_sme_rsp_messages.h"
54#include "lim_ibss_peer_mgmt.h"
55#include "lim_session_utils.h"
56#include "lim_types.h"
57#include "sir_api.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053058#include "cds_regdomain_common.h"
59#include "lim_send_messages.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
62 tpPESession session_entry, tSirResultCodes result_code,
63 tpSirSmeJoinRsp sme_join_rsp);
64
65/**
66 * lim_send_sme_rsp() - Send Response to upper layers
67 * @mac_ctx: Pointer to Global MAC structure
68 * @msg_type: Indicates message type
69 * @result_code: Indicates the result of previously issued
70 * eWNI_SME_msg_type_REQ message
71 *
72 * This function is called by lim_process_sme_req_messages() to send
73 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
74 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
75 * Software.
76 *
77 * Return: None
78 */
79
80void
81lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
82 tSirResultCodes result_code, uint8_t sme_session_id,
83 uint16_t sme_transaction_id)
84{
85 tSirMsgQ msg;
86 tSirSmeRsp *sme_rsp;
87
88 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
89 lim_msg_str(msg_type), lim_result_code_str(result_code));
90
91 sme_rsp = cdf_mem_malloc(sizeof(tSirSmeRsp));
92 if (NULL == sme_rsp) {
93 /* Buffer not available. Log error */
94 CDF_TRACE(CDF_MODULE_ID_PE, LOGP,
95 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
96 return;
97 }
98
99 sme_rsp->messageType = msg_type;
100 sme_rsp->length = sizeof(tSirSmeRsp);
101 sme_rsp->statusCode = result_code;
102
103 sme_rsp->sessionId = sme_session_id;
104 sme_rsp->transactionId = sme_transaction_id;
105
106 msg.type = msg_type;
107 msg.bodyptr = sme_rsp;
108 msg.bodyval = 0;
109 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
110
111#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
112 switch (msg_type) {
113 case eWNI_SME_STOP_BSS_RSP:
114 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
115 NULL, (uint16_t) result_code, 0);
116 break;
117 }
118#endif /* FEATURE_WLAN_DIAG_SUPPORT */
119 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
120}
121
122
123
124/**
125 * lim_send_sme_roc_rsp() - Send Response to SME
126 * @mac_ctx: Pointer to Global MAC structure
127 * @status: Resume link status
128 * @result_code: Result of the ROC request
129 * @sme_session_id: SME sesson Id
130 * @scan_id: Scan Identifier
131 *
132 * This function is called to send ROC rsp
133 * message to SME.
134 *
135 * Return: None
136 */
137void
138lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
139 tSirResultCodes result_code, uint8_t sme_session_id,
140 uint32_t scan_id)
141{
142 tSirMsgQ msg;
143 struct sir_roc_rsp *sme_rsp;
144
145 lim_log(mac_ctx, LOG1,
146 FL("Sending message %s with reasonCode %s scanId %d"),
147 lim_msg_str(msg_type), lim_result_code_str(result_code),
148 scan_id);
149
150 sme_rsp = cdf_mem_malloc(sizeof(struct sir_roc_rsp));
151 if (NULL == sme_rsp) {
152 CDF_TRACE(CDF_MODULE_ID_PE, LOGP,
153 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
154 return;
155 }
156
157 sme_rsp->message_type = msg_type;
158 sme_rsp->length = sizeof(struct sir_roc_rsp);
159 sme_rsp->status = result_code;
160
161 sme_rsp->session_id = sme_session_id;
162 sme_rsp->scan_id = scan_id;
163
164 msg.type = msg_type;
165 msg.bodyptr = sme_rsp;
166 msg.bodyval = 0;
167 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
168 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
169}
170
171
172/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530173 * lim_get_max_rate_flags() - Get rate flags
174 * @mac_ctx: Pointer to global MAC structure
175 * @sta_ds: Pointer to station ds structure
176 *
177 * This function is called to get the rate flags for a connection
178 * from the station ds structure depending on the ht and the vht
179 * channel width supported.
180 *
181 * Return: Returns the populated rate_flags
182 */
183uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
184{
185 uint32_t rate_flags = 0;
186
187 if (sta_ds == NULL) {
188 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
189 return rate_flags;
190 }
191
192 if (!sta_ds->mlmStaContext.htCapability &&
193 !sta_ds->mlmStaContext.vhtCapability) {
194 rate_flags |= eHAL_TX_RATE_LEGACY;
195 } else {
196 if (sta_ds->mlmStaContext.vhtCapability) {
197 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
198 sta_ds->vhtSupportedChannelWidthSet) {
199 rate_flags |= eHAL_TX_RATE_VHT80;
200 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
201 sta_ds->vhtSupportedChannelWidthSet) {
202 if (sta_ds->htSupportedChannelWidthSet)
203 rate_flags |= eHAL_TX_RATE_VHT40;
204 else
205 rate_flags |= eHAL_TX_RATE_VHT20;
206 }
207 } else if (sta_ds->mlmStaContext.htCapability) {
208 if (sta_ds->htSupportedChannelWidthSet)
209 rate_flags |= eHAL_TX_RATE_HT40;
210 else
211 rate_flags |= eHAL_TX_RATE_HT20;
212 }
213 }
214
215 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
216 rate_flags |= eHAL_TX_RATE_SGI;
217
218 return rate_flags;
219}
220
221/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
223 * @mac_ctx Pointer to Global MAC structure
224 * @status Resume link status
225 * @ctx context passed while calling resmune link.
226 * (join response to be sent)
227 *
228 * This function is called to send Join/Reassoc rsp
229 * message to SME after the resume link.
230 *
231 * Return: None
232 */
233static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
234 CDF_STATUS status, uint32_t *ctx)
235{
236 tSirMsgQ msg;
237 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
238
239 msg.type = sme_join_rsp->messageType;
240 msg.bodyptr = sme_join_rsp;
241 msg.bodyval = 0;
242 MTRACE(mac_trace_msg_tx(mac_ctx, NO_SESSION, msg.type));
243 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
244}
245
246/**
247 * lim_handle_join_rsp_status() - Handle the response.
248 * @mac_ctx: Pointer to Global MAC structure
249 * @session_entry: PE Session Info
250 * @result_code: Indicates the result of previously issued
251 * eWNI_SME_msgType_REQ message
252 * @sme_join_rsp The received response.
253 *
254 * This function will handle both the success and failure status
255 * of the received response.
256 *
257 * Return: None
258 */
259static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
260 tpPESession session_entry, tSirResultCodes result_code,
261 tpSirSmeJoinRsp sme_join_rsp)
262{
263#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
264 tSirSmeHTProfile *ht_profile;
265#endif
266 if (result_code == eSIR_SME_SUCCESS) {
267 if (session_entry->beacon != NULL) {
268 sme_join_rsp->beaconLength = session_entry->bcnLen;
269 cdf_mem_copy(sme_join_rsp->frames,
270 session_entry->beacon,
271 sme_join_rsp->beaconLength);
272 cdf_mem_free(session_entry->beacon);
273 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530274 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
276 lim_log(mac_ctx, LOG1, FL("Beacon=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530277 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278#endif
279 }
280 if (session_entry->assocReq != NULL) {
281 sme_join_rsp->assocReqLength =
282 session_entry->assocReqLen;
283 cdf_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);
287 cdf_mem_free(session_entry->assocReq);
288 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530289 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800290#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
291 lim_log(mac_ctx,
292 LOG1, FL("AssocReq=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530293 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294#endif
295 }
296 if (session_entry->assocRsp != NULL) {
297 sme_join_rsp->assocRspLength =
298 session_entry->assocRspLen;
299 cdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530300 sme_join_rsp->beaconLength +
301 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 session_entry->assocRsp,
303 sme_join_rsp->assocRspLength);
304 cdf_mem_free(session_entry->assocRsp);
305 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530306 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 }
308#ifdef WLAN_FEATURE_VOWIFI_11R
309 if (session_entry->ricData != NULL) {
310 sme_join_rsp->parsedRicRspLen =
311 session_entry->RICDataLen;
312 cdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530313 sme_join_rsp->beaconLength +
314 sme_join_rsp->assocReqLength +
315 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316 session_entry->ricData,
317 sme_join_rsp->parsedRicRspLen);
318 cdf_mem_free(session_entry->ricData);
319 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530320 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321 lim_log(mac_ctx, LOG1, FL("RicLength=%d"),
322 sme_join_rsp->parsedRicRspLen);
323 }
324#endif
325#ifdef FEATURE_WLAN_ESE
326 if (session_entry->tspecIes != NULL) {
327 sme_join_rsp->tspecIeLen =
328 session_entry->tspecLen;
329 cdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530330 sme_join_rsp->beaconLength +
331 sme_join_rsp->assocReqLength +
332 sme_join_rsp->assocRspLength +
333 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334 session_entry->tspecIes,
335 sme_join_rsp->tspecIeLen);
336 cdf_mem_free(session_entry->tspecIes);
337 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530338 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 lim_log(mac_ctx, LOG1, FL("ESE-TspecLen=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530340 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 }
342#endif
343 sme_join_rsp->aid = session_entry->limAID;
344#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
345 lim_log(mac_ctx, LOG1, FL("AssocRsp=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530346 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347#endif
348 sme_join_rsp->vht_channel_width =
349 session_entry->ch_width;
350#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
351 if (session_entry->cc_switch_mode !=
352 CDF_MCC_TO_SCC_SWITCH_DISABLE) {
353 ht_profile = &sme_join_rsp->HTProfile;
354 ht_profile->htSupportedChannelWidthSet =
355 session_entry->htSupportedChannelWidthSet;
356 ht_profile->htRecommendedTxWidthSet =
357 session_entry->htRecommendedTxWidthSet;
358 ht_profile->htSecondaryChannelOffset =
359 session_entry->htSecondaryChannelOffset;
360 ht_profile->dot11mode = session_entry->dot11mode;
361 ht_profile->htCapability = session_entry->htCapability;
362#ifdef WLAN_FEATURE_11AC
363 ht_profile->vhtCapability =
364 session_entry->vhtCapability;
365 ht_profile->vhtTxChannelWidthSet =
366 session_entry->vhtTxChannelWidthSet;
367 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
368 ht_profile->apChanWidth = session_entry->ch_width;
369#endif
370 }
371#endif
372 } else {
373 if (session_entry->beacon != NULL) {
374 cdf_mem_free(session_entry->beacon);
375 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530376 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 }
378 if (session_entry->assocReq != NULL) {
379 cdf_mem_free(session_entry->assocReq);
380 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530381 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 }
383 if (session_entry->assocRsp != NULL) {
384 cdf_mem_free(session_entry->assocRsp);
385 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530386 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 }
388#ifdef WLAN_FEATURE_VOWIFI_11R
389 if (session_entry->ricData != NULL) {
390 cdf_mem_free(session_entry->ricData);
391 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530392 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393 }
394#endif
395#ifdef FEATURE_WLAN_ESE
396 if (session_entry->tspecIes != NULL) {
397 cdf_mem_free(session_entry->tspecIes);
398 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530399 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400 }
401#endif
402 }
403}
404/**
405 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
406 * @mac_ctx: Pointer to Global MAC structure
407 * @msg_type: Indicates message type
408 * @result_code: Indicates the result of previously issued
409 * eWNI_SME_msgType_REQ message
410 * @prot_status_code: Protocol Status Code
411 * @session_entry: PE Session Info
412 * @sme_session_id: SME Session ID
413 * @sme_transaction_id: SME Transaction ID
414 *
415 * This function is called by lim_process_sme_req_messages() to send
416 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
417 * above MAC Software.
418 *
419 * Return: None
420 */
421
422void
423lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
424 tSirResultCodes result_code, uint16_t prot_status_code,
425 tpPESession session_entry, uint8_t sme_session_id,
426 uint16_t sme_transaction_id)
427{
428 tpSirSmeJoinRsp sme_join_rsp;
429 uint32_t rsp_len;
430 tpDphHashNode sta_ds = NULL;
431#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
432 if (msg_type == eWNI_SME_REASSOC_RSP)
433 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
434 session_entry, (uint16_t) result_code, 0);
435 else
436 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
437 session_entry, (uint16_t) result_code, 0);
438#endif /* FEATURE_WLAN_DIAG_SUPPORT */
439
440 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
441 lim_msg_str(msg_type), lim_result_code_str(result_code));
442
443 if (session_entry == NULL) {
444 rsp_len = sizeof(tSirSmeJoinRsp);
445 sme_join_rsp = cdf_mem_malloc(rsp_len);
446 if (NULL == sme_join_rsp) {
447 lim_log(mac_ctx, LOGP,
448 FL("Mem Alloc fail - JOIN/REASSOC_RSP"));
449 return;
450 }
451
452 cdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
453 sme_join_rsp->beaconLength = 0;
454 sme_join_rsp->assocReqLength = 0;
455 sme_join_rsp->assocRspLength = 0;
456 } else {
457 rsp_len = session_entry->assocReqLen +
458 session_entry->assocRspLen + session_entry->bcnLen +
459#ifdef WLAN_FEATURE_VOWIFI_11R
460 session_entry->RICDataLen +
461#endif
462#ifdef FEATURE_WLAN_ESE
463 session_entry->tspecLen +
464#endif
465 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
466 sme_join_rsp = cdf_mem_malloc(rsp_len);
467 if (NULL == sme_join_rsp) {
468 lim_log(mac_ctx, LOGP,
469 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
470 return;
471 }
472 cdf_mem_set((uint8_t *) sme_join_rsp, rsp_len, 0);
473 if (result_code == eSIR_SME_SUCCESS) {
474 sta_ds = dph_get_hash_entry(mac_ctx,
475 DPH_STA_HASH_INDEX_PEER,
476 &session_entry->dph.dphHashTable);
477 if (sta_ds == NULL) {
478 lim_log(mac_ctx, LOGE,
479 FL("Get Self Sta Entry fail"));
480 } else {
481 /* Pass the peer's staId */
482 sme_join_rsp->staId = sta_ds->staIndex;
483 sme_join_rsp->ucastSig =
484 sta_ds->ucUcastSig;
485 sme_join_rsp->bcastSig =
486 sta_ds->ucBcastSig;
487 sme_join_rsp->timingMeasCap =
488 sta_ds->timingMeasCap;
489#ifdef FEATURE_WLAN_TDLS
490 sme_join_rsp->tdls_prohibited =
491 session_entry->tdls_prohibited;
492 sme_join_rsp->tdls_chan_swit_prohibited =
493 session_entry->tdls_chan_swit_prohibited;
494#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530495 sme_join_rsp->nss = sta_ds->nss;
496 sme_join_rsp->max_rate_flags =
497 lim_get_max_rate_flags(mac_ctx, sta_ds);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 }
499 }
500 sme_join_rsp->beaconLength = 0;
501 sme_join_rsp->assocReqLength = 0;
502 sme_join_rsp->assocRspLength = 0;
503#ifdef WLAN_FEATURE_VOWIFI_11R
504 sme_join_rsp->parsedRicRspLen = 0;
505#endif
506#ifdef FEATURE_WLAN_ESE
507 sme_join_rsp->tspecIeLen = 0;
508#endif
509
510 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
511 sme_join_rsp);
512 }
513
514 sme_join_rsp->messageType = msg_type;
515 sme_join_rsp->length = (uint16_t) rsp_len;
516 sme_join_rsp->statusCode = result_code;
517 sme_join_rsp->protStatusCode = prot_status_code;
518
519 sme_join_rsp->sessionId = sme_session_id;
520 sme_join_rsp->transactionId = sme_transaction_id;
521
522 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, CDF_STATUS_SUCCESS,
523 (uint32_t *)sme_join_rsp);
524}
525
526/**
527 * lim_send_sme_start_bss_rsp()
528 *
529 ***FUNCTION:
530 * This function is called to send eWNI_SME_START_BSS_RSP
531 * message to applications above MAC Software.
532 *
533 ***PARAMS:
534 *
535 ***LOGIC:
536 *
537 ***ASSUMPTIONS:
538 * NA
539 *
540 ***NOTE:
541 * NA
542 *
543 * @param pMac Pointer to Global MAC structure
544 * @param msgType Indicates message type
545 * @param resultCode Indicates the result of previously issued
546 * eWNI_SME_msgType_REQ message
547 *
548 * @return None
549 */
550
551void
552lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
553 uint16_t msgType, tSirResultCodes resultCode,
554 tpPESession psessionEntry, uint8_t smesessionId,
555 uint16_t smetransactionId)
556{
557
558 uint16_t size = 0;
559 tSirMsgQ mmhMsg;
560 tSirSmeStartBssRsp *pSirSmeRsp;
561 uint16_t ieLen;
562 uint16_t ieOffset, curLen;
563
564 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
565 lim_msg_str(msgType), lim_result_code_str(resultCode));
566 )
567
568 size = sizeof(tSirSmeStartBssRsp);
569
570 if (psessionEntry == NULL) {
571 pSirSmeRsp = cdf_mem_malloc(size);
572 if (NULL == pSirSmeRsp) {
573 /* / Buffer not available. Log error */
574 lim_log(pMac, LOGP,
575 FL
576 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
577 return;
578 }
579 cdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
580
581 } else {
582 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
583 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
584 ieLen = psessionEntry->schBeaconOffsetBegin
585 + psessionEntry->schBeaconOffsetEnd - ieOffset;
586 /* calculate the memory size to allocate */
587 size += ieLen;
588
589 pSirSmeRsp = cdf_mem_malloc(size);
590 if (NULL == pSirSmeRsp) {
591 /* / Buffer not available. Log error */
592 lim_log(pMac, LOGP,
593 FL
594 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
595
596 return;
597 }
598 cdf_mem_set((uint8_t *) pSirSmeRsp, size, 0);
599 size = sizeof(tSirSmeStartBssRsp);
600 if (resultCode == eSIR_SME_SUCCESS) {
601
602 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
603 psessionEntry->bssId);
604
605 /* Read beacon interval from session */
606 pSirSmeRsp->bssDescription.beaconInterval =
607 (uint16_t) psessionEntry->beaconParams.
608 beaconInterval;
609 pSirSmeRsp->bssType = psessionEntry->bssType;
610
611 if (cfg_get_capability_info
612 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
613 psessionEntry)
614 != eSIR_SUCCESS)
615 lim_log(pMac, LOGP,
616 FL
617 ("could not retrieve Capabilities value"));
618
619 lim_get_phy_mode(pMac,
620 (uint32_t *) &pSirSmeRsp->bssDescription.
621 nwType, psessionEntry);
622
623 pSirSmeRsp->bssDescription.channelId =
624 psessionEntry->currentOperChannel;
625
626 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
627 cdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
628 ieFields,
629 psessionEntry->pSchBeaconFrameBegin +
630 ieOffset, (uint32_t) curLen);
631
632 cdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
633 ieFields) + curLen,
634 psessionEntry->pSchBeaconFrameEnd,
635 (uint32_t) psessionEntry->
636 schBeaconOffsetEnd);
637
638 /* subtracting size of length indicator itself and size of pointer to ieFields */
639 pSirSmeRsp->bssDescription.length =
640 sizeof(tSirBssDescription) - sizeof(uint16_t) -
641 sizeof(uint32_t) + ieLen;
642 /* This is the size of the message, subtracting the size of the pointer to ieFields */
643 size += ieLen - sizeof(uint32_t);
644#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
645 if (psessionEntry->cc_switch_mode
646 != CDF_MCC_TO_SCC_SWITCH_DISABLE) {
647 pSirSmeRsp->HTProfile.
648 htSupportedChannelWidthSet =
649 psessionEntry->htSupportedChannelWidthSet;
650 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
651 psessionEntry->htRecommendedTxWidthSet;
652 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
653 psessionEntry->htSecondaryChannelOffset;
654 pSirSmeRsp->HTProfile.dot11mode =
655 psessionEntry->dot11mode;
656 pSirSmeRsp->HTProfile.htCapability =
657 psessionEntry->htCapability;
658#ifdef WLAN_FEATURE_11AC
659 pSirSmeRsp->HTProfile.vhtCapability =
660 psessionEntry->vhtCapability;
661 pSirSmeRsp->HTProfile.vhtTxChannelWidthSet =
662 psessionEntry->vhtTxChannelWidthSet;
663 pSirSmeRsp->HTProfile.apCenterChan =
664 psessionEntry->ch_center_freq_seg0;
665 pSirSmeRsp->HTProfile.apChanWidth =
666 psessionEntry->ch_width;
667#endif
668 }
669#endif
670 }
671
672 }
673
674 pSirSmeRsp->messageType = msgType;
675 pSirSmeRsp->length = size;
676
677 /* Update SME session Id and transaction Id */
678 pSirSmeRsp->sessionId = smesessionId;
679 pSirSmeRsp->transactionId = smetransactionId;
680 pSirSmeRsp->statusCode = resultCode;
681 if (psessionEntry != NULL)
682 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
683
684 mmhMsg.type = msgType;
685 mmhMsg.bodyptr = pSirSmeRsp;
686 mmhMsg.bodyval = 0;
687 if (psessionEntry == NULL) {
688 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
689 } else {
690 MTRACE(mac_trace_msg_tx
691 (pMac, psessionEntry->peSessionId, mmhMsg.type));
692 }
693#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
694 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
695 psessionEntry, (uint16_t) resultCode, 0);
696#endif /* FEATURE_WLAN_DIAG_SUPPORT */
697
698 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
699} /*** end lim_send_sme_start_bss_rsp() ***/
700
701#define LIM_MAX_NUM_OF_SCAN_RESULTS_REPORTED 20
702#define LIM_SIZE_OF_EACH_BSS 400 /* this is a rough estimate */
703
704/**
705 * lim_send_sme_scan_rsp() - Send scan response to SME
706 * @pMac: Pointer to Global MAC structure
707 * @length: Indicates length of message
708 * @resultCode: Indicates the result of previously issued
709 * eWNI_SME_SCAN_REQ message
710 * @scan_id: scan identifier
711 *
712 * This function is called by lim_process_sme_req_messages() to send
713 * eWNI_SME_SCAN_RSP message to applications above MAC
714 *
715 * return: None
716 */
717
718void
719lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
720 uint8_t smesessionId, uint16_t smetranscationId,
721 uint32_t scan_id)
722{
723 lim_log(pMac, LOG1,
724 FL("Sending message SME_SCAN_RSP reasonCode %s scanId %d"),
725 lim_result_code_str(resultCode), scan_id);
726 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
759 pSirSmeScanRsp = cdf_mem_malloc(sizeof(tSirSmeScanRsp));
760 if (NULL == pSirSmeScanRsp) {
761 lim_log(pMac, LOGP,
762 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
763 return;
764 }
765 cdf_mem_set((void *)pSirSmeScanRsp, sizeof(tSirSmeScanRsp), 0);
766
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
779 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
780#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
790#ifdef FEATURE_OEM_DATA_SUPPORT
791
792/**
793 * lim_send_sme_oem_data_rsp()
794 *
795 ***FUNCTION:
796 * This function is called by lim_process_sme_req_messages() to send
797 * eWNI_SME_OEM_DATA_RSP message to applications above MAC
798 * Software.
799 *
800 ***PARAMS:
801 *
802 ***LOGIC:
803 *
804 ***ASSUMPTIONS:
805 * NA
806 *
807 ***NOTE:
808 * NA
809 *
810 * @param pMac Pointer to Global MAC structure
811 * @param pMsgBuf Indicates the mlm message
812 * @param resultCode Indicates the result of previously issued
813 * eWNI_SME_OEM_DATA_RSP message
814 *
815 * @return None
816 */
817
818void lim_send_sme_oem_data_rsp(tpAniSirGlobal pMac, uint32_t *pMsgBuf,
819 tSirResultCodes resultCode)
820{
821 tSirMsgQ mmhMsg;
822 tSirOemDataRsp *pSirSmeOemDataRsp = NULL;
823 tLimMlmOemDataRsp *pMlmOemDataRsp = NULL;
824 uint16_t msgLength;
825
826 /* get the pointer to the mlm message */
827 pMlmOemDataRsp = (tLimMlmOemDataRsp *) (pMsgBuf);
828
829 msgLength = sizeof(tSirOemDataRsp);
830
831 /* now allocate memory for the char buffer */
832 pSirSmeOemDataRsp = cdf_mem_malloc(msgLength);
833 if (NULL == pSirSmeOemDataRsp) {
834 lim_log(pMac, LOGP,
835 FL
836 ("call to AllocateMemory failed for pSirSmeOemDataRsp"));
837 return;
838 }
839#if defined (ANI_LITTLE_BYTE_ENDIAN)
840 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->length, msgLength);
841 sir_store_u16_n((uint8_t *) &pSirSmeOemDataRsp->messageType,
842 eWNI_SME_OEM_DATA_RSP);
843#else
844 pSirSmeOemDataRsp->length = msgLength;
845 pSirSmeOemDataRsp->messageType = eWNI_SME_OEM_DATA_RSP;
846#endif
847
848 cdf_mem_copy(pSirSmeOemDataRsp->oemDataRsp, pMlmOemDataRsp->oemDataRsp,
849 OEM_DATA_RSP_SIZE);
850
851 /* Now free the memory from MLM Rsp Message */
852 cdf_mem_free(pMlmOemDataRsp);
853
854 mmhMsg.type = eWNI_SME_OEM_DATA_RSP;
855 mmhMsg.bodyptr = pSirSmeOemDataRsp;
856 mmhMsg.bodyval = 0;
857
858 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
859
860 return;
861} /*** lim_send_sme_oem_data_rsp ***/
862
863#endif
864
865void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
866 CDF_STATUS status, uint32_t *pCtx)
867{
868 tSirMsgQ mmhMsg;
869 tSirMsgQ *pMsg = (tSirMsgQ *) pCtx;
870
871 mmhMsg.type = pMsg->type;
872 mmhMsg.bodyptr = pMsg;
873 mmhMsg.bodyval = 0;
874
875 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
876
877 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
878}
879
880/**
881 * lim_send_sme_disassoc_ntf()
882 *
883 ***FUNCTION:
884 * This function is called by limProcessSmeMessages() to send
885 * eWNI_SME_DISASSOC_RSP/IND message to host
886 *
887 ***PARAMS:
888 *
889 ***LOGIC:
890 *
891 ***ASSUMPTIONS:
892 * NA
893 *
894 ***NOTE:
895 * This function is used for sending eWNI_SME_DISASSOC_CNF,
896 * or eWNI_SME_DISASSOC_IND to host depending on
897 * disassociation trigger.
898 *
899 * @param peerMacAddr Indicates the peer MAC addr to which
900 * disassociate was initiated
901 * @param reasonCode Indicates the reason for Disassociation
902 * @param disassocTrigger Indicates the trigger for Disassociation
903 * @param aid Indicates the STAID. This parameter is
904 * present only on AP.
905 *
906 * @return None
907 */
908void
909lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
910 tSirMacAddr peerMacAddr,
911 tSirResultCodes reasonCode,
912 uint16_t disassocTrigger,
913 uint16_t aid,
914 uint8_t smesessionId,
915 uint16_t smetransactionId, tpPESession psessionEntry)
916{
917
918 uint8_t *pBuf;
919 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
920 tSirSmeDisassocInd *pSirSmeDisassocInd;
921 uint32_t *pMsg;
922 bool failure = false;
923
924 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
925 disassocTrigger, reasonCode);
926
927 switch (disassocTrigger) {
928 case eLIM_PEER_ENTITY_DISASSOC:
929 if (reasonCode != eSIR_SME_STA_NOT_ASSOCIATED) {
930 failure = true;
931 goto error;
932 }
933
934 case eLIM_HOST_DISASSOC:
935 /**
936 * Disassociation response due to
937 * host triggered disassociation
938 */
939
940 pSirSmeDisassocRsp = cdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
941 if (NULL == pSirSmeDisassocRsp) {
942 /* Log error */
943 lim_log(pMac, LOGP, FL("Memory allocation failed"));
944 failure = true;
945 goto error;
946 }
947 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
948 "retCode: %d for " MAC_ADDRESS_STR),
949 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
950 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
951 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
952 /* sessionId */
953 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
954 *pBuf = smesessionId;
955 pBuf++;
956
957 /* transactionId */
958 lim_copy_u16(pBuf, smetransactionId);
959 pBuf += sizeof(uint16_t);
960
961 /* statusCode */
962 lim_copy_u32(pBuf, reasonCode);
963 pBuf += sizeof(tSirResultCodes);
964
965 /* peerMacAddr */
966 cdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
967 pBuf += sizeof(tSirMacAddr);
968
969 /* Clear Station Stats */
970 /* for sta, it is always 1, IBSS is handled at halInitSta */
971
972#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
973
974 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
975 psessionEntry, (uint16_t) reasonCode, 0);
976#endif
977 pMsg = (uint32_t *) pSirSmeDisassocRsp;
978 break;
979
980 default:
981 /**
982 * Disassociation indication due to Disassociation
983 * frame reception from peer entity or due to
984 * loss of link with peer entity.
985 */
986 pSirSmeDisassocInd = cdf_mem_malloc(sizeof(tSirSmeDisassocInd));
987 if (NULL == pSirSmeDisassocInd) {
988 /* Log error */
989 lim_log(pMac, LOGP, FL("Memory allocation failed"));
990 failure = true;
991 goto error;
992 }
993 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
994 "retCode: %d for " MAC_ADDRESS_STR),
995 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
996 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
997 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
998
999 /* Update SME session Id and Transaction Id */
1000 pSirSmeDisassocInd->sessionId = smesessionId;
1001 pSirSmeDisassocInd->transactionId = smetransactionId;
1002 pSirSmeDisassocInd->reasonCode = reasonCode;
1003 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1004
1005 lim_copy_u32(pBuf, reasonCode);
1006 pBuf += sizeof(tSirResultCodes);
1007
1008 cdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
1009 pBuf += sizeof(tSirMacAddr);
1010
1011 cdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
1012
1013#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1014 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1015 psessionEntry, (uint16_t) reasonCode, 0);
1016#endif
1017 pMsg = (uint32_t *) pSirSmeDisassocInd;
1018
1019 break;
1020 }
1021
1022error:
1023 /* Delete the PE session Created */
1024 if ((psessionEntry != NULL) &&
1025 (LIM_IS_STA_ROLE(psessionEntry) ||
1026 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))) {
1027 pe_delete_session(pMac, psessionEntry);
1028 }
1029
1030 if (false == failure)
1031 lim_send_sme_disassoc_deauth_ntf(pMac, CDF_STATUS_SUCCESS,
1032 (uint32_t *) pMsg);
1033} /*** end lim_send_sme_disassoc_ntf() ***/
1034
1035/** -----------------------------------------------------------------
1036 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1037
1038 After receiving disassociation frame from peer entity, this
1039 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1040 reason code.
1041
1042 \param pMac - global mac structure
1043 \param pStaDs - station dph hash node
1044 \return none
1045 \sa
1046 ----------------------------------------------------------------- */
1047void
1048lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1049 tpPESession psessionEntry)
1050{
1051 tSirMsgQ mmhMsg;
1052 tSirSmeDisassocInd *pSirSmeDisassocInd;
1053
1054 pSirSmeDisassocInd = cdf_mem_malloc(sizeof(tSirSmeDisassocInd));
1055 if (NULL == pSirSmeDisassocInd) {
1056 lim_log(pMac, LOGP,
1057 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1058 return;
1059 }
1060
1061 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1062 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1063
1064 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1065 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
1066 pSirSmeDisassocInd->statusCode = pStaDs->mlmStaContext.disassocReason;
1067 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1068
1069 cdf_mem_copy(pSirSmeDisassocInd->bssId, psessionEntry->bssId,
1070 sizeof(tSirMacAddr));
1071
1072 cdf_mem_copy(pSirSmeDisassocInd->peerMacAddr, pStaDs->staAddr,
1073 sizeof(tSirMacAddr));
1074
1075 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1076
1077 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1078 mmhMsg.bodyptr = pSirSmeDisassocInd;
1079 mmhMsg.bodyval = 0;
1080
1081 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1082#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1083 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1084 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1085#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1086
1087 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1088
1089} /*** end lim_send_sme_disassoc_ind() ***/
1090
1091/** -----------------------------------------------------------------
1092 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1093
1094 After receiving deauthentication frame from peer entity, this
1095 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1096 reason code.
1097
1098 \param pMac - global mac structure
1099 \param pStaDs - station dph hash node
1100 \return none
1101 \sa
1102 ----------------------------------------------------------------- */
1103void
1104lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1105 tpPESession psessionEntry)
1106{
1107 tSirMsgQ mmhMsg;
1108 tSirSmeDeauthInd *pSirSmeDeauthInd;
1109
1110 pSirSmeDeauthInd = cdf_mem_malloc(sizeof(tSirSmeDeauthInd));
1111 if (NULL == pSirSmeDeauthInd) {
1112 lim_log(pMac, LOGP,
1113 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1114 return;
1115 }
1116
1117 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1118 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1119
1120 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1121 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1122 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1123 pSirSmeDeauthInd->statusCode =
1124 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1125 } else {
1126 /* Need to indicatet he reascon code over the air */
1127 pSirSmeDeauthInd->statusCode =
1128 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1129 }
1130 /* BSSID */
1131 cdf_mem_copy(pSirSmeDeauthInd->bssId, psessionEntry->bssId,
1132 sizeof(tSirMacAddr));
1133 /* peerMacAddr */
1134 cdf_mem_copy(pSirSmeDeauthInd->peerMacAddr, pStaDs->staAddr,
1135 sizeof(tSirMacAddr));
1136 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1137
1138 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001139 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1140 pStaDs->mlmStaContext.disassocReason)
1141 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142
1143 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1144 mmhMsg.bodyptr = pSirSmeDeauthInd;
1145 mmhMsg.bodyval = 0;
1146
1147 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1148#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1149 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1150 0, pStaDs->mlmStaContext.cleanupTrigger);
1151#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1152
1153 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1154 return;
1155} /*** end lim_send_sme_deauth_ind() ***/
1156
1157#ifdef FEATURE_WLAN_TDLS
1158/**
1159 * lim_send_sme_tdls_del_sta_ind()
1160 *
1161 ***FUNCTION:
1162 * This function is called to send the TDLS STA context deletion to SME.
1163 *
1164 ***LOGIC:
1165 *
1166 ***ASSUMPTIONS:
1167 *
1168 ***NOTE:
1169 * NA
1170 *
1171 * @param pMac - Pointer to global MAC structure
1172 * @param pStaDs - Pointer to internal STA Datastructure
1173 * @param psessionEntry - Pointer to the session entry
1174 * @param reasonCode - Reason for TDLS sta deletion
1175 * @return None
1176 */
1177void
1178lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1179 tpPESession psessionEntry, uint16_t reasonCode)
1180{
1181 tSirMsgQ mmhMsg;
1182 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1183
1184 pSirTdlsDelStaInd = cdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
1185 if (NULL == pSirTdlsDelStaInd) {
1186 lim_log(pMac, LOGP,
1187 FL
1188 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1189 return;
1190 }
1191 /* messageType */
1192 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1193 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1194
1195 /* sessionId */
1196 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1197
1198 /* peerMacAddr */
Srinivas Girigowda84f42922015-11-19 16:28:05 -08001199 cdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
1200 CDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201
1202 /* staId */
1203 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1204 (uint16_t) pStaDs->staIndex);
1205
1206 /* reasonCode */
1207 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1208
1209 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1210 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1211 mmhMsg.bodyval = 0;
1212
1213 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1214 return;
1215} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1216
1217/**
1218 * lim_send_sme_tdls_delete_all_peer_ind()
1219 *
1220 ***FUNCTION:
1221 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1222 * message to SME.
1223 *
1224 ***LOGIC:
1225 *
1226 ***ASSUMPTIONS:
1227 *
1228 ***NOTE:
1229 * NA
1230 *
1231 * @param pMac - Pointer to global MAC structure
1232 * @param psessionEntry - Pointer to the session entry
1233 * @return None
1234 */
1235void
1236lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1237{
1238 tSirMsgQ mmhMsg;
1239 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1240
1241 pSirTdlsDelAllPeerInd = cdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
1242 if (NULL == pSirTdlsDelAllPeerInd) {
1243 lim_log(pMac, LOGP,
1244 FL
1245 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1246 return;
1247 }
1248 /* messageType */
1249 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1250 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1251
1252 /* sessionId */
1253 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1254
1255 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1256 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1257 mmhMsg.bodyval = 0;
1258
1259 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1260 return;
1261} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1262
1263/**
1264 * lim_send_sme_mgmt_tx_completion()
1265 *
1266 ***FUNCTION:
1267 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1268 * message to SME.
1269 *
1270 ***LOGIC:
1271 *
1272 ***ASSUMPTIONS:
1273 *
1274 ***NOTE:
1275 * NA
1276 *
1277 * @param pMac - Pointer to global MAC structure
1278 * @param psessionEntry - Pointer to the session entry
1279 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1280 * @return None
1281 */
1282void
1283lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
1284 tpPESession psessionEntry, uint32_t txCompleteStatus)
1285{
1286 tSirMsgQ mmhMsg;
1287 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1288
1289 pSirMgmtTxCompletionInd =
1290 cdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
1291 if (NULL == pSirMgmtTxCompletionInd) {
1292 lim_log(pMac, LOGP,
1293 FL
1294 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1295 return;
1296 }
1297 /* messageType */
1298 pSirMgmtTxCompletionInd->messageType =
1299 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1300 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1301
1302 /* sessionId */
1303 pSirMgmtTxCompletionInd->sessionId = psessionEntry->smeSessionId;
1304
1305 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1306
1307 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1308 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1309 mmhMsg.bodyval = 0;
1310
1311 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1312 return;
1313} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1314
1315void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1316 void *events)
1317{
1318 tSirMsgQ mmhMsg;
1319
1320 switch (msgType) {
1321 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1322 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1323 break;
1324 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1325 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1326 break;
1327 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1328 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1329 break;
1330 }
1331
1332 mmhMsg.bodyptr = events;
1333 mmhMsg.bodyval = 0;
1334 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1335 return;
1336}
1337#endif /* FEATURE_WLAN_TDLS */
1338
1339/**
1340 * lim_send_sme_deauth_ntf()
1341 *
1342 ***FUNCTION:
1343 * This function is called by limProcessSmeMessages() to send
1344 * eWNI_SME_DISASSOC_RSP/IND message to host
1345 *
1346 ***PARAMS:
1347 *
1348 ***LOGIC:
1349 *
1350 ***ASSUMPTIONS:
1351 * NA
1352 *
1353 ***NOTE:
1354 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1355 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1356 *
1357 * @param peerMacAddr Indicates the peer MAC addr to which
1358 * deauthentication was initiated
1359 * @param reasonCode Indicates the reason for Deauthetication
1360 * @param deauthTrigger Indicates the trigger for Deauthetication
1361 * @param aid Indicates the STAID. This parameter is present
1362 * only on AP.
1363 *
1364 * @return None
1365 */
1366void
1367lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1368 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1369 uint16_t aid, uint8_t smesessionId,
1370 uint16_t smetransactionId)
1371{
1372 uint8_t *pBuf;
1373 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1374 tSirSmeDeauthInd *pSirSmeDeauthInd;
1375 tpPESession psessionEntry;
1376 uint8_t sessionId;
1377 uint32_t *pMsg;
1378
1379 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1380 switch (deauthTrigger) {
1381 case eLIM_PEER_ENTITY_DEAUTH:
1382 return;
1383
1384 case eLIM_HOST_DEAUTH:
1385 /**
1386 * Deauthentication response to host triggered
1387 * deauthentication.
1388 */
1389 pSirSmeDeauthRsp = cdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
1390 if (NULL == pSirSmeDeauthRsp) {
1391 /* Log error */
1392 lim_log(pMac, LOGP,
1393 FL
1394 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1395
1396 return;
1397 }
1398 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1399 "retCode: %d for" MAC_ADDRESS_STR),
1400 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1401 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1402 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1403 pSirSmeDeauthRsp->statusCode = reasonCode;
1404 pSirSmeDeauthRsp->sessionId = smesessionId;
1405 pSirSmeDeauthRsp->transactionId = smetransactionId;
1406
1407 pBuf = (uint8_t *) pSirSmeDeauthRsp->peerMacAddr;
1408 cdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
1409
1410#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1411 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1412 psessionEntry, 0, (uint16_t) reasonCode);
1413#endif
1414 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1415
1416 break;
1417
1418 default:
1419 /**
1420 * Deauthentication indication due to Deauthentication
1421 * frame reception from peer entity or due to
1422 * loss of link with peer entity.
1423 */
1424 pSirSmeDeauthInd = cdf_mem_malloc(sizeof(tSirSmeDeauthInd));
1425 if (NULL == pSirSmeDeauthInd) {
1426 /* Log error */
1427 lim_log(pMac, LOGP,
1428 FL
1429 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1430
1431 return;
1432 }
1433 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1434 "retCode: %d for " MAC_ADDRESS_STR),
1435 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1436 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1437 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1438 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1439
1440 /* sessionId */
1441 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1442 *pBuf++ = smesessionId;
1443
1444 /* transaction ID */
1445 lim_copy_u16(pBuf, smetransactionId);
1446 pBuf += sizeof(uint16_t);
1447
1448 /* status code */
1449 lim_copy_u32(pBuf, reasonCode);
1450 pBuf += sizeof(tSirResultCodes);
1451
1452 /* bssId */
1453 cdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
1454 pBuf += sizeof(tSirMacAddr);
1455
1456 /* peerMacAddr */
1457 cdf_mem_copy(pSirSmeDeauthInd->peerMacAddr, peerMacAddr,
1458 sizeof(tSirMacAddr));
1459
1460#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1461 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1462 psessionEntry, 0, (uint16_t) reasonCode);
1463#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1464 pMsg = (uint32_t *) pSirSmeDeauthInd;
1465
1466 break;
1467 }
1468
1469 /*Delete the PE session created */
1470 if (psessionEntry != NULL) {
1471 pe_delete_session(pMac, psessionEntry);
1472 }
1473
1474 lim_send_sme_disassoc_deauth_ntf(pMac, CDF_STATUS_SUCCESS,
1475 (uint32_t *) pMsg);
1476
1477} /*** end lim_send_sme_deauth_ntf() ***/
1478
1479/**
1480 * lim_send_sme_wm_status_change_ntf() - Send Notification
1481 * @mac_ctx: Global MAC Context
1482 * @status_change_code: Indicates the change in the wireless medium.
1483 * @status_change_info: Indicates the information associated with
1484 * change in the wireless medium.
1485 * @info_len: Indicates the length of status change information
1486 * being sent.
1487 * @session_id SessionID
1488 *
1489 * This function is called by limProcessSmeMessages() to send
1490 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1491 *
1492 * Return: None
1493 */
1494void
1495lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1496 tSirSmeStatusChangeCode status_change_code,
1497 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1498{
1499 tSirMsgQ msg;
1500 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
1501
1502 wm_status_change_ntf = cdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
1503 if (NULL == wm_status_change_ntf) {
1504 lim_log(mac_ctx, LOGE,
1505 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1506 return;
1507 }
1508
1509 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1510 msg.bodyval = 0;
1511 msg.bodyptr = wm_status_change_ntf;
1512
1513 switch (status_change_code) {
1514 case eSIR_SME_RADAR_DETECTED:
1515 break;
1516 default:
1517 wm_status_change_ntf->messageType =
1518 eWNI_SME_WM_STATUS_CHANGE_NTF;
1519 wm_status_change_ntf->statusChangeCode = status_change_code;
1520 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1521 wm_status_change_ntf->sessionId = session_id;
1522 if (sizeof(wm_status_change_ntf->statusChangeInfo) >=
1523 info_len) {
1524 cdf_mem_copy(
1525 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1526 (uint8_t *) status_change_info, info_len);
1527 }
1528 lim_log(mac_ctx, LOGE,
1529 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1530 status_change_code, info_len);
1531 break;
1532 }
1533
1534 MTRACE(mac_trace_msg_tx(mac_ctx, session_id, msg.type));
1535 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
1536 cdf_mem_free(wm_status_change_ntf);
1537 lim_log(mac_ctx, LOGP,
1538 FL("lim_sys_process_mmh_msg_api failed"));
1539 }
1540
1541} /*** end lim_send_sme_wm_status_change_ntf() ***/
1542
1543/**
1544 * lim_send_sme_set_context_rsp()
1545 *
1546 ***FUNCTION:
1547 * This function is called by limProcessSmeMessages() to send
1548 * eWNI_SME_SETCONTEXT_RSP message to host
1549 *
1550 ***PARAMS:
1551 *
1552 ***LOGIC:
1553 *
1554 ***ASSUMPTIONS:
1555 * NA
1556 *
1557 ***NOTE:
1558 *
1559 * @param pMac Pointer to Global MAC structure
1560 * @param peerMacAddr Indicates the peer MAC addr to which
1561 * setContext was performed
1562 * @param aid Indicates the aid corresponding to the peer MAC
1563 * address
1564 * @param resultCode Indicates the result of previously issued
1565 * eWNI_SME_SETCONTEXT_RSP message
1566 *
1567 * @return None
1568 */
1569void
1570lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
1571 tSirMacAddr peerMacAddr, uint16_t aid,
1572 tSirResultCodes resultCode,
1573 tpPESession psessionEntry, uint8_t smesessionId,
1574 uint16_t smetransactionId)
1575{
1576
1577 uint8_t *pBuf;
1578 tSirMsgQ mmhMsg;
1579 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1580
1581 pSirSmeSetContextRsp = cdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
1582 if (NULL == pSirSmeSetContextRsp) {
1583 /* Log error */
1584 lim_log(pMac, LOGP,
1585 FL
1586 ("call to AllocateMemory failed for SmeSetContextRsp"));
1587
1588 return;
1589 }
1590
1591 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1592 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1593 pSirSmeSetContextRsp->statusCode = resultCode;
1594
1595 pBuf = pSirSmeSetContextRsp->peerMacAddr;
1596
1597 cdf_mem_copy(pBuf, (uint8_t *) peerMacAddr, sizeof(tSirMacAddr));
1598 pBuf += sizeof(tSirMacAddr);
1599
1600 /* Update SME session and transaction Id */
1601 pSirSmeSetContextRsp->sessionId = smesessionId;
1602 pSirSmeSetContextRsp->transactionId = smetransactionId;
1603
1604 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1605 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1606 mmhMsg.bodyval = 0;
1607 if (NULL == psessionEntry) {
1608 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1609 } else {
1610 MTRACE(mac_trace_msg_tx
1611 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1612 }
1613
1614#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1615 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1616 psessionEntry, (uint16_t) resultCode, 0);
1617#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1618
1619 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1620} /*** end lim_send_sme_set_context_rsp() ***/
1621
1622/**
1623 * lim_send_sme_neighbor_bss_ind()
1624 *
1625 ***FUNCTION:
1626 * This function is called by lim_lookup_nadd_hash_entry() to send
1627 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1628 *
1629 ***PARAMS:
1630 *
1631 ***LOGIC:
1632 *
1633 ***ASSUMPTIONS:
1634 * NA
1635 *
1636 ***NOTE:
1637 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1638 * host upon detecting new BSS during background scanning if CFG
1639 * option is enabled for sending such indication
1640 *
1641 * @param pMac - Pointer to Global MAC structure
1642 * @return None
1643 */
1644
1645void
1646lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1647{
1648 tSirMsgQ msgQ;
1649 uint32_t val;
1650 tSirSmeNeighborBssInd *pNewBssInd;
1651
1652 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1653 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1654 pMac->lim.gLimRspReqd)) {
1655 /* LIM is not in background scan state OR */
1656 /* current scan is initiated by HDD. */
1657 /* No need to send new BSS indication to HDD */
1658 return;
1659 }
1660
1661 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1662 eSIR_SUCCESS) {
1663 lim_log(pMac, LOGP,
1664 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1665
1666 return;
1667 }
1668
1669 if (val == 0)
1670 return;
1671
1672 /**
1673 * Need to indicate new BSSs found during
1674 * background scanning to host.
1675 * Allocate buffer for sending indication.
1676 * Length of buffer is length of BSS description
1677 * and length of header itself
1678 */
1679 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1680 sizeof(uint32_t) + sizeof(uint8_t);
1681 pNewBssInd = cdf_mem_malloc(val);
1682 if (NULL == pNewBssInd) {
1683 /* Log error */
1684 lim_log(pMac, LOGP,
1685 FL
1686 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1687
1688 return;
1689 }
1690
1691 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1692 pNewBssInd->length = (uint16_t) val;
1693 pNewBssInd->sessionId = 0;
1694
1695 cdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
1696 (uint8_t *) &pBssDescr->bssDescription,
1697 pBssDescr->bssDescription.length + sizeof(uint16_t));
1698
1699 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1700 msgQ.bodyptr = pNewBssInd;
1701 msgQ.bodyval = 0;
1702 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
1703 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1704} /*** end lim_send_sme_neighbor_bss_ind() ***/
1705
1706/** -----------------------------------------------------------------
1707 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1708 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1709 \ SME only looks at rc and tspec field.
1710 \param pMac - global mac structure
1711 \param rspReqd - is SmeAddTsRsp required
1712 \param status - status code of SME_ADD_TS_RSP
1713 \return tspec
1714 \sa
1715 ----------------------------------------------------------------- */
1716void
1717lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1718 tpPESession psessionEntry, tSirMacTspecIE tspec,
1719 uint8_t smesessionId, uint16_t smetransactionId)
1720{
1721 tpSirAddtsRsp rsp;
1722 tSirMsgQ mmhMsg;
1723
1724 if (!rspReqd)
1725 return;
1726
1727 rsp = cdf_mem_malloc(sizeof(tSirAddtsRsp));
1728 if (NULL == rsp) {
1729 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1730 return;
1731 }
1732
1733 cdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
1734 rsp->messageType = eWNI_SME_ADDTS_RSP;
1735 rsp->rc = status;
1736 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1737 rsp->rsp.tspec = tspec;
1738 /* Update SME session Id and transcation Id */
1739 rsp->sessionId = smesessionId;
1740 rsp->transactionId = smetransactionId;
1741
1742 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1743 mmhMsg.bodyptr = rsp;
1744 mmhMsg.bodyval = 0;
1745 if (NULL == psessionEntry) {
1746 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1747 } else {
1748 MTRACE(mac_trace_msg_tx
1749 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1750 }
1751#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1752 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1753 0);
1754#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1755
1756 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1757 return;
1758}
1759
1760void
1761lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1762 tpPESession psessionEntry, uint8_t smesessionId,
1763 uint16_t smetransactionId)
1764{
1765 tpSirDeltsRsp rsp;
1766 tSirMsgQ mmhMsg;
1767
1768 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1769 delts->aid,
1770 delts->req.tsinfo.traffic.tsid,
1771 delts->req.tsinfo.traffic.userPrio, status);
1772 if (!delts->rspReqd)
1773 return;
1774
1775 rsp = cdf_mem_malloc(sizeof(tSirDeltsRsp));
1776 if (NULL == rsp) {
1777 /* Log error */
1778 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1779 return;
1780 }
1781 cdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
1782
1783 if (psessionEntry != NULL) {
1784
1785 rsp->aid = delts->aid;
1786 cdf_mem_copy((uint8_t *) &rsp->macAddr[0],
1787 (uint8_t *) &delts->macAddr[0], 6);
1788 cdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
1789 sizeof(tSirDeltsReqInfo));
1790 }
1791
1792 rsp->messageType = eWNI_SME_DELTS_RSP;
1793 rsp->rc = status;
1794
1795 /* Update SME session Id and transcation Id */
1796 rsp->sessionId = smesessionId;
1797 rsp->transactionId = smetransactionId;
1798
1799 mmhMsg.type = eWNI_SME_DELTS_RSP;
1800 mmhMsg.bodyptr = rsp;
1801 mmhMsg.bodyval = 0;
1802 if (NULL == psessionEntry) {
1803 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1804 } else {
1805 MTRACE(mac_trace_msg_tx
1806 (pMac, psessionEntry->peSessionId, mmhMsg.type));
1807 }
1808#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1809 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1810 (uint16_t) status, 0);
1811#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1812
1813 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1814}
1815
1816void
1817lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1818 tpPESession psessionEntry)
1819{
1820 tpSirDeltsRsp rsp;
1821 tSirMsgQ mmhMsg;
1822
1823 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1824 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1825
1826 rsp = cdf_mem_malloc(sizeof(tSirDeltsRsp));
1827 if (NULL == rsp) {
1828 /* Log error */
1829 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1830 return;
1831 }
1832 cdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
1833
1834 rsp->messageType = eWNI_SME_DELTS_IND;
1835 rsp->rc = eSIR_SUCCESS;
1836 rsp->aid = aid;
1837 cdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
1838
1839 /* Update SME session Id and SME transaction Id */
1840
1841 rsp->sessionId = psessionEntry->smeSessionId;
1842 rsp->transactionId = psessionEntry->transactionId;
1843
1844 mmhMsg.type = eWNI_SME_DELTS_IND;
1845 mmhMsg.bodyptr = rsp;
1846 mmhMsg.bodyval = 0;
1847 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1848#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1849 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1850 0);
1851#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1852
1853 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1854}
1855
1856/**
1857 * lim_send_sme_pe_statistics_rsp()
1858 *
1859 ***FUNCTION:
1860 * This function is called to send 802.11 statistics response to HDD.
1861 * This function posts the result back to HDD. This is a response to
1862 * HDD's request for statistics.
1863 *
1864 ***PARAMS:
1865 *
1866 ***LOGIC:
1867 *
1868 ***ASSUMPTIONS:
1869 * NA
1870 *
1871 ***NOTE:
1872 * NA
1873 *
1874 * @param pMac Pointer to Global MAC structure
1875 * @param p80211Stats Statistics sent in response
1876 * @param resultCode TODO:
1877 *
1878 *
1879 * @return none
1880 */
1881
1882void
1883lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1884{
1885 tSirMsgQ mmhMsg;
1886 uint8_t sessionId;
1887 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1888 tpPESession pPeSessionEntry;
1889
1890 /* Get the Session Id based on Sta Id */
1891 pPeSessionEntry =
1892 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1893
1894 /* Fill the Session Id */
1895 if (NULL != pPeSessionEntry) {
1896 /* Fill the Session Id */
1897 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1898 }
1899
1900 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1901
1902 /* msgType should be WMA_GET_STATISTICS_RSP */
1903 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1904
1905 mmhMsg.bodyptr = stats;
1906 mmhMsg.bodyval = 0;
1907 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
1908 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1909
1910 return;
1911
1912} /*** end lim_send_sme_pe_statistics_rsp() ***/
1913
1914#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1915/**
1916 * lim_send_sme_pe_ese_tsm_rsp()
1917 *
1918 ***FUNCTION:
1919 * This function is called to send tsm stats response to HDD.
1920 * This function posts the result back to HDD. This is a response to
1921 * HDD's request to get tsm stats.
1922 *
1923 ***PARAMS:
1924 * @param pMac - Pointer to global pMac structure
1925 * @param pStats - Pointer to TSM Stats
1926 *
1927 * @return none
1928 */
1929
1930void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac, tAniGetTsmStatsRsp *pStats)
1931{
1932 tSirMsgQ mmhMsg;
1933 uint8_t sessionId;
1934 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1935 tpPESession pPeSessionEntry = NULL;
1936
1937 /* Get the Session Id based on Sta Id */
1938 pPeSessionEntry =
1939 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1940
1941 /* Fill the Session Id */
1942 if (NULL != pPeSessionEntry) {
1943 /* Fill the Session Id */
1944 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1945 } else {
1946 PELOGE(lim_log
1947 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1948 pPeStats->staId);
1949 )
1950 return;
1951 }
1952
1953 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1954 pPeStats->tsmMetrics.RoamingCount
1955 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1956 pPeStats->tsmMetrics.RoamingDly
1957 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1958
1959 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1960 mmhMsg.bodyptr = pStats;
1961 mmhMsg.bodyval = 0;
1962 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
1963 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1964
1965 return;
1966} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1967
1968#endif /* FEATURE_WLAN_ESE) && FEATURE_WLAN_ESE_UPLOAD */
1969
1970void
1971lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1972 tSirMacAddr peerMacAddr,
1973 uint16_t staIndex,
1974 uint8_t ucastIdx,
1975 uint8_t bcastIdx,
1976 uint8_t *beacon,
1977 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1978{
1979 tSirMsgQ mmhMsg;
1980 tSmeIbssPeerInd *pNewPeerInd;
1981
1982 pNewPeerInd = cdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
1983 if (NULL == pNewPeerInd) {
1984 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
1985 return;
1986 }
1987
1988 cdf_mem_set((void *)pNewPeerInd, (sizeof(tSmeIbssPeerInd) + beaconLen),
1989 0);
1990
1991 cdf_mem_copy((uint8_t *) pNewPeerInd->peerAddr,
1992 peerMacAddr, sizeof(tSirMacAddr));
1993 pNewPeerInd->staId = staIndex;
1994 pNewPeerInd->ucastSig = ucastIdx;
1995 pNewPeerInd->bcastSig = bcastIdx;
1996 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1997 pNewPeerInd->mesgType = msgType;
1998 pNewPeerInd->sessionId = sessionId;
1999
2000 if (beacon != NULL) {
2001 cdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
2002 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2003 beaconLen);
2004 }
2005
2006 mmhMsg.type = msgType;
2007 mmhMsg.bodyptr = pNewPeerInd;
2008 MTRACE(mac_trace_msg_tx(pMac, sessionId, mmhMsg.type));
2009 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2010
2011}
2012
2013/**
2014 * lim_handle_csa_offload_msg() - Handle CSA offload message
2015 * @mac_ctx: pointer to global adapter context
2016 * @msg: Message pointer.
2017 *
2018 * Return: None
2019 */
2020void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
2021{
2022 tpPESession session_entry;
2023 tSirMsgQ mmh_msg;
2024 tpCSAOffloadParams csa_params = (tpCSAOffloadParams) (msg->bodyptr);
2025 tpSmeCsaOffloadInd csa_offload_ind;
2026 tpDphHashNode sta_ds = NULL;
2027 uint8_t session_id;
2028 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302029 uint16_t chan_space = 0;
2030 int cb_mode = 0;
2031
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
2033
2034 if (!csa_params) {
2035 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2036 return;
2037 }
2038
2039 session_entry =
2040 pe_find_session_by_bssid(mac_ctx,
2041 csa_params->bssId, &session_id);
2042 if (!session_entry) {
2043 lim_log(mac_ctx, LOGE,
2044 FL("Session does not exist"));
2045 goto err;
2046 }
2047
2048 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2049 &session_entry->dph.dphHashTable);
2050
2051 if (!sta_ds) {
2052 lim_log(mac_ctx, LOGE,
2053 FL("sta_ds does not exist"));
2054 goto err;
2055 }
2056
2057 if (LIM_IS_STA_ROLE(session_entry)) {
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302058 /*
2059 * on receiving channel switch announcement from AP, delete all
2060 * TDLS peers before leaving BSS and proceed for channel switch
2061 */
2062 lim_delete_tdls_peers(mac_ctx, session_entry);
2063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 session_entry->gLimChannelSwitch.switchMode =
2065 csa_params->switchmode;
2066 /* timer already started by firmware, switch immediately */
2067 session_entry->gLimChannelSwitch.switchCount = 0;
2068 session_entry->gLimChannelSwitch.primaryChannel =
2069 csa_params->channel;
2070 session_entry->gLimChannelSwitch.state =
2071 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2072 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2073
Gupta, Kapil121bf212015-11-25 19:21:29 +05302074 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2075 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2076 chnl_switch_info =
2077 &session_entry->gLimWiderBWChannelSwitch;
2078
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 if (session_entry->vhtCapability &&
2080 session_entry->htSupportedChannelWidthSet) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002081 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
2082 chnl_switch_info->newChanWidth =
2083 csa_params->new_ch_width;
2084 chnl_switch_info->newCenterChanFreq0 =
2085 csa_params->new_ch_freq_seg1;
2086 chnl_switch_info->newCenterChanFreq1 =
2087 csa_params->new_ch_freq_seg2;
2088 session_entry->gLimChannelSwitch.state =
2089 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2090 session_entry->gLimChannelSwitch.ch_width =
2091 csa_params->new_ch_width + 1;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302092 } else if (csa_params->ies_present_flag
2093 & lim_xcsa_ie_present) {
2094 chan_space =
2095 cds_regdm_get_chanwidth_from_opclass(
2096 mac_ctx->scan.countryCodeCurrent,
2097 csa_params->channel,
2098 csa_params->new_op_class);
2099 session_entry->gLimChannelSwitch.state =
2100 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2101
2102 if (chan_space == 80) {
2103 chnl_switch_info->newChanWidth =
2104 CH_WIDTH_80MHZ;
2105 } else if (chan_space == 40) {
2106 chnl_switch_info->newChanWidth =
2107 CH_WIDTH_40MHZ;
2108 } else {
2109 chnl_switch_info->newChanWidth =
2110 CH_WIDTH_20MHZ;
2111 session_entry->gLimChannelSwitch.state =
2112 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2113 }
2114
2115 cb_mode = lim_select_cb_mode_for_sta(
2116 session_entry,
2117 csa_params->channel,
2118 chan_space);
2119
2120 chnl_switch_info->newCenterChanFreq0 =
2121 lim_get_center_channel(mac_ctx,
2122 csa_params->channel,
2123 cb_mode,
2124 chnl_switch_info->newChanWidth);
2125 /*
2126 * This is not applicable for 20/40/80 MHz.
2127 * Only used when we support 80+80 MHz operation.
2128 * In case of 80+80 MHz, this parameter indicates
2129 * center channel frequency index of 80 MHz
2130 * channel offrequency segment 1.
2131 */
2132 chnl_switch_info->newCenterChanFreq1 = 0;
2133
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 }
Gupta, Kapil121bf212015-11-25 19:21:29 +05302135 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2136 chnl_switch_info->newCenterChanFreq0;
2137 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2138 chnl_switch_info->newCenterChanFreq1;
2139 session_entry->gLimChannelSwitch.ch_width =
2140 chnl_switch_info->newChanWidth;
2141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 } else if (session_entry->htSupportedChannelWidthSet) {
Gupta, Kapil121bf212015-11-25 19:21:29 +05302143 if (csa_params->ies_present_flag
2144 & lim_xcsa_ie_present) {
2145 chan_space =
2146 cds_regdm_get_chanwidth_from_opclass(
2147 mac_ctx->scan.countryCodeCurrent,
2148 csa_params->channel,
2149 csa_params->new_op_class);
2150 session_entry->gLimChannelSwitch.state =
2151 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2152 if (chan_space == 40) {
2153 session_entry->
2154 gLimChannelSwitch.ch_width =
2155 CH_WIDTH_40MHZ;
2156 chnl_switch_info->newChanWidth =
2157 CH_WIDTH_40MHZ;
2158 cb_mode = lim_select_cb_mode_for_sta(
2159 session_entry,
2160 csa_params->channel,
2161 chan_space);
2162 if (cb_mode ==
2163 PHY_DOUBLE_CHANNEL_LOW_PRIMARY) {
2164 session_entry->
2165 gLimChannelSwitch.
2166 ch_center_freq_seg0 =
2167 csa_params->channel + 2;
2168 } else if (cb_mode ==
2169 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) {
2170 session_entry->
2171 gLimChannelSwitch.
2172 ch_center_freq_seg0 =
2173 csa_params->channel - 2;
2174 }
2175
2176 } else {
2177 session_entry->
2178 gLimChannelSwitch.ch_width =
2179 CH_WIDTH_20MHZ;
2180 chnl_switch_info->newChanWidth =
2181 CH_WIDTH_40MHZ;
2182 session_entry->gLimChannelSwitch.state =
2183 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2184 }
2185
2186
2187 }
2188
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 if (csa_params->sec_chan_offset) {
2190 session_entry->gLimChannelSwitch.ch_width =
2191 CH_WIDTH_40MHZ;
2192 session_entry->gLimChannelSwitch.state =
2193 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2194 } else {
2195 session_entry->htSupportedChannelWidthSet =
2196 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
2197 session_entry->htRecommendedTxWidthSet =
2198 session_entry->htSupportedChannelWidthSet;
2199 }
2200 }
2201 lim_log(mac_ctx, LOG1, FL("new ch width = %d"),
2202 session_entry->gLimChannelSwitch.ch_width);
2203
2204 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2205 csa_offload_ind = cdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2206 if (NULL == csa_offload_ind) {
2207 lim_log(mac_ctx, LOGE,
2208 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
2209 goto err;
2210 }
2211
2212 cdf_mem_set(csa_offload_ind, sizeof(tSmeCsaOffloadInd), 0);
2213 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2214 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002215 cdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2216 CDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2218 mmh_msg.bodyptr = csa_offload_ind;
2219 mmh_msg.bodyval = 0;
2220 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002221 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 MTRACE(mac_trace_msg_tx
2223 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2224#ifdef FEATURE_WLAN_DIAG_SUPPORT
2225 lim_diag_event_report(mac_ctx,
2226 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2227 eSIR_SUCCESS, eSIR_SUCCESS);
2228#endif
2229 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
2230 }
2231
2232err:
2233 cdf_mem_free(csa_params);
2234}
2235
2236/*--------------------------------------------------------------------------
2237 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2238
2239 \param pMac - pointer to global adapter context
2240 \param sessionId - Message pointer.
2241
2242 \sa
2243 --------------------------------------------------------------------------*/
2244
2245void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ MsgQ)
2246{
2247 tpPESession psessionEntry;
2248 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2249
2250 psessionEntry =
2251 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2252 if (psessionEntry == NULL) {
2253 lim_log(pMac, LOGE,
2254 FL("Session Does not exist for given sessionID %d"),
2255 pDelBss->sessionId);
2256 return;
2257 }
2258 if (LIM_IS_IBSS_ROLE(psessionEntry)) {
2259 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
2260 } else if (LIM_IS_UNKNOWN_ROLE(psessionEntry)) {
2261 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
2262 }
2263
2264 else
2265 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2266
2267}
2268
2269#ifdef WLAN_FEATURE_VOWIFI_11R
2270/** -----------------------------------------------------------------
2271 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2272 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2273 \ SME only looks at rc and tspec field.
2274 \param pMac - global mac structure
2275 \param rspReqd - is SmeAddTsRsp required
2276 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2277 \return tspec
2278 \sa
2279 ----------------------------------------------------------------- */
2280void
2281lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2282 uint8_t smesessionId)
2283{
2284 tSirMsgQ mmhMsg;
2285
2286 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2287 mmhMsg.bodyptr = aggrQosRsp;
2288 mmhMsg.bodyval = 0;
2289 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2290 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2291
2292 return;
2293}
2294#endif
2295
2296void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2297 uint8_t smesessionId)
2298{
2299 tSirMsgQ mmhMsg;
2300 tSmeMaxAssocInd *pSmeMaxAssocInd;
2301
2302 pSmeMaxAssocInd = cdf_mem_malloc(sizeof(tSmeMaxAssocInd));
2303 if (NULL == pSmeMaxAssocInd) {
2304 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2305 return;
2306 }
2307 cdf_mem_set((void *)pSmeMaxAssocInd, sizeof(tSmeMaxAssocInd), 0);
2308 cdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peerMac,
2309 (uint8_t *) peerMacAddr, sizeof(tSirMacAddr));
2310 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2311 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2312 pSmeMaxAssocInd->sessionId = smesessionId;
2313 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2314 mmhMsg.bodyptr = pSmeMaxAssocInd;
2315 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2316 " sme session id %d"),
2317 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2318 MAC_ADDR_ARRAY(peerMacAddr));
2319 )
2320 MTRACE(mac_trace_msg_tx(pMac, smesessionId, mmhMsg.type));
2321 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2322
2323 return;
2324}
2325
2326/** -----------------------------------------------------------------
2327 \brief lim_send_sme_dfs_event_notify() - sends
2328 eWNI_SME_DFS_RADAR_FOUND
2329 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2330 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2331 that a RADAR is found on current operating channel and SAP-
2332 has to move to a new channel.
2333 \param pMac - global mac structure
2334 \param msgType - message type received from lower layer
2335 \param event - event data received from lower layer
2336 \return none
2337 \sa
2338 ----------------------------------------------------------------- */
2339void
2340lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2341{
2342 tSirMsgQ mmhMsg;
2343 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2344 mmhMsg.bodyptr = event;
2345 mmhMsg.bodyval = 0;
2346 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2347 return;
2348}
2349
2350/*--------------------------------------------------------------------------
2351 \brief lim_send_dfs_chan_sw_ie_update()
2352 This timer handler updates the channel switch IE in beacon template
2353
2354 \param pMac - pointer to global adapter context
2355 \return - channel to scan from valid session else zero.
2356 \sa
2357 --------------------------------------------------------------------------*/
2358static void
2359lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2360{
2361
2362 /* Update the beacon template and send to FW */
2363 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2364 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2365 return;
2366 }
2367
2368 /* Send update beacon template message */
2369 lim_send_beacon_ind(pMac, psessionEntry);
2370 PELOG1(lim_log(pMac, LOG1,
2371 FL(" Updated CSA IE, IE COUNT = %d"),
2372 psessionEntry->gLimChannelSwitch.switchCount);
2373 )
2374
2375 return;
2376}
2377
2378/** -----------------------------------------------------------------
2379 \brief lim_send_sme_ap_channel_switch_resp() - sends
2380 eWNI_SME_CHANNEL_CHANGE_RSP
2381 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2382 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2383 that the Channel change has been done to the specified target
2384 channel in the Channel change request
2385 \param pMac - global mac structure
2386 \param psessionEntry - session info
2387 \param pChnlParams - Channel switch params
2388 --------------------------------------------------------------------*/
2389void
2390lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2391 tpPESession psessionEntry,
2392 tpSwitchChannelParams pChnlParams)
2393{
2394 tSirMsgQ mmhMsg;
2395 tpSwitchChannelParams pSmeSwithChnlParams;
2396 uint8_t channelId;
2397
2398 pSmeSwithChnlParams = (tSwitchChannelParams *)
2399 cdf_mem_malloc(sizeof(tSwitchChannelParams));
2400 if (NULL == pSmeSwithChnlParams) {
2401 lim_log(pMac, LOGP,
2402 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2403 return;
2404 }
2405
2406 cdf_mem_set((void *)pSmeSwithChnlParams,
2407 sizeof(tSwitchChannelParams), 0);
2408
2409 cdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
2410 sizeof(tSwitchChannelParams));
2411
2412 channelId = pSmeSwithChnlParams->channelNumber;
2413
2414 /*
2415 * Pass the sme sessionID to SME instead
2416 * PE session ID.
2417 */
2418 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2419
2420 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2421 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2422 mmhMsg.bodyval = 0;
2423 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2424
2425 /*
2426 * We should start beacon transmission only if the new
2427 * channel after channel change is Non-DFS. For a DFS
2428 * channel, PE will receive an explicit request from
2429 * upper layers to start the beacon transmission .
2430 */
2431
2432 if (CHANNEL_STATE_DFS != cds_get_channel_state(channelId)) {
2433 if (channelId == psessionEntry->currentOperChannel) {
2434 lim_apply_configuration(pMac, psessionEntry);
2435 lim_send_beacon_ind(pMac, psessionEntry);
2436 } else {
2437 PELOG1(lim_log(pMac, LOG1,
2438 FL
2439 ("Failed to Transmit Beacons on channel = %d"
2440 "after AP channel change response"),
2441 psessionEntry->bcnLen);
2442 )
2443 }
2444 }
2445 return;
2446}
2447
2448/** -----------------------------------------------------------------
2449 \brief lim_process_beacon_tx_success_ind() - This function is used
2450 explicitely to handle successful beacon transmission indication
2451 from the FW. This is a generic event generated by the FW afer the
2452 first beacon is sent out after the beacon template update by the
2453 host
2454 \param pMac - global mac structure
2455 \param psessionEntry - session info
2456 \return none
2457 \sa
2458 ----------------------------------------------------------------- */
2459void
2460lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2461{
2462 /* Currently, this event is used only for DFS channel switch announcement
2463 * IE update in the template. If required to be used for other IE updates
2464 * add appropriate code by introducing a state variable
2465 */
2466 tpPESession psessionEntry;
2467 tSirMsgQ mmhMsg;
2468 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2469 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2470 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2471 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2472 (tSirFirstBeaconTxCompleteInd *) event;
2473
2474 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2475 if (psessionEntry == NULL) {
2476 lim_log(pMac, LOGE,
2477 FL("Session Does not exist for given sessionID"));
2478 return;
2479 }
2480
2481 if (LIM_IS_AP_ROLE(psessionEntry) &&
2482 true == psessionEntry->dfsIncludeChanSwIe) {
2483 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2484 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2485 /*
2486 * Send the next beacon with updated CSA IE count
2487 */
2488 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2489 /* Decrement the IE count */
2490 psessionEntry->gLimChannelSwitch.switchCount--;
2491 } else {
2492 /* Done with CSA IE update, send response back to SME */
2493 psessionEntry->gLimChannelSwitch.switchCount = 0;
2494 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2495 psessionEntry->gLimChannelSwitch.switchMode = 0;
2496 psessionEntry->dfsIncludeChanSwIe = false;
2497 psessionEntry->dfsIncludeChanWrapperIe = false;
2498
2499 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
2500 cdf_mem_malloc(length);
2501
2502 if (NULL == pChanSwTxResponse) {
2503 lim_log(pMac, LOGP,
2504 FL
2505 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2506 return;
2507 }
2508
2509 cdf_mem_set((void *)pChanSwTxResponse, length, 0);
2510 pChanSwTxResponse->sessionId =
2511 psessionEntry->smeSessionId;
2512 pChanSwTxResponse->chanSwIeTxStatus =
2513 CDF_STATUS_SUCCESS;
2514
2515 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2516 mmhMsg.bodyptr = pChanSwTxResponse;
2517 mmhMsg.bodyval = 0;
2518 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2519 }
2520 }
2521
2522 if (LIM_IS_AP_ROLE(psessionEntry) &&
2523 psessionEntry->gLimOperatingMode.present) {
2524 /* Done with nss update, send response back to SME */
2525 psessionEntry->gLimOperatingMode.present = 0;
2526 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
2527 cdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
2528 if (NULL == beacon_tx_comp_rsp_ptr) {
2529 lim_log(pMac, LOGP,
2530 FL
2531 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2532 return;
2533 }
2534 cdf_mem_set((void *)beacon_tx_comp_rsp_ptr,
2535 sizeof(*beacon_tx_comp_rsp_ptr), 0);
2536 beacon_tx_comp_rsp_ptr->session_id =
2537 psessionEntry->smeSessionId;
2538 beacon_tx_comp_rsp_ptr->tx_status = CDF_STATUS_SUCCESS;
2539 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2540 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2541 mmhMsg.bodyval = 0;
2542 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2543 }
2544 return;
2545}