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