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