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