blob: 17307b0d1d22f7fc8c794e3bc61a42f2e2a0424e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2013 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.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam0fb93dd2014-02-19 00:32:59 -080021
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
Jeff Johnson295189b2012-06-20 16:38:30 -070028/*===========================================================================
29
30 s a p A p i L i n k C n t l . C
31
32 OVERVIEW:
33
34 This software unit holds the implementation of the WLAN SAP modules
35 Link Control functions.
36
37 The functions externalized by this module are to be called ONLY by other
38 WLAN modules (HDD)
39
40 DEPENDENCIES:
41
42 Are listed for each API below.
43
44
45 Copyright (c) 2010 QUALCOMM Incorporated.
46 All Rights Reserved.
47 Qualcomm Confidential and Proprietary
48===========================================================================*/
49
50/*===========================================================================
51
52 EDIT HISTORY FOR FILE
53
54
55 This section contains comments describing changes made to the module.
56 Notice that changes are listed in reverse chronological order.
57
58
59 $Header: /cygdrive/c/Dropbox/M7201JSDCAAPAD52240B/WM/platform/msm7200/Src/Drivers/SD/ClientDrivers/WLAN/QCT_SAP_PAL/CORE/SAP/src/sapApiLinkCntl.c,v 1.7 2008/12/18 19:44:11 jzmuda Exp jzmuda $$DateTime$$Author: jzmuda $
60
61
62 when who what, where, why
63---------- --- --------------------------------------------------------
642010-03-15 Created module
65
66===========================================================================*/
67
68/*----------------------------------------------------------------------------
69 * Include Files
70 * -------------------------------------------------------------------------*/
71#include "vos_trace.h"
72// Pick up the CSR callback definition
73#include "csrApi.h"
74#include "sme_Api.h"
75// SAP Internal API header file
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070076#include "sapInternal.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070077
78/*----------------------------------------------------------------------------
79 * Preprocessor Definitions and Constants
80 * -------------------------------------------------------------------------*/
81#define SAP_DEBUG
82
83/*----------------------------------------------------------------------------
84 * Type Declarations
85 * -------------------------------------------------------------------------*/
86
87/*----------------------------------------------------------------------------
88 * Global Data Definitions
89 * -------------------------------------------------------------------------*/
90
91/*----------------------------------------------------------------------------
92 * Static Variable Definitions
93 * -------------------------------------------------------------------------*/
94
95/*----------------------------------------------------------------------------
96 * Static Function Declarations and Definitions
97 * -------------------------------------------------------------------------*/
98
99/*----------------------------------------------------------------------------
100 * Externalized Function Definitions
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700101 * -------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
103/*----------------------------------------------------------------------------
104 * Function Declarations and Documentation
105 * -------------------------------------------------------------------------*/
106
107/*==========================================================================
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530108 FUNCTION sapSetOperatingChannel()
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530110 DESCRIPTION
111 Set SAP Operating Channel
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530113 DEPENDENCIES
114 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700115
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530116 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
118 IN
Jeff Johnson295189b2012-06-20 16:38:30 -0700119 *pContext : The second context pass in for the caller (sapContext)
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530120 operChannel : SAP Operating Channel
Jeff Johnson295189b2012-06-20 16:38:30 -0700121
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530122 RETURN VALUE
123
124 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700125============================================================================*/
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530126
127void sapSetOperatingChannel(ptSapContext psapContext, v_U8_t operChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -0700128{
Deepthi Gowri0f60c0f2014-09-22 18:13:29 +0530129 v_U8_t i = 0;
Peng Xu2446a892014-09-05 17:21:18 +0530130 v_U32_t event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700131
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530132 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
133 FL("SAP Channel : %d"), psapContext->channel);
Deepthi Gowri0f60c0f2014-09-22 18:13:29 +0530134
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 if (operChannel == SAP_CHANNEL_NOT_SELECTED)
136#ifdef SOFTAP_CHANNEL_RANGE
137 {
Peng Xu2446a892014-09-05 17:21:18 +0530138 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530139 FL("No suitable channel selected"));
Peng Xu2446a892014-09-05 17:21:18 +0530140
141 if ( eCSR_BAND_ALL == psapContext->scanBandPreference ||
142 psapContext->allBandScanned == eSAP_TRUE)
143 {
144 if(psapContext->channelList != NULL)
145 {
Deepthi Gowri0f60c0f2014-09-22 18:13:29 +0530146 psapContext->channel = SAP_DEFAULT_CHANNEL;
147 for ( i = 0 ; i < psapContext->numofChannel ; i++)
148 {
149 if (NV_CHANNEL_ENABLE ==
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530150 vos_nv_getChannelEnabledState(psapContext->channelList[i]))
Deepthi Gowri0f60c0f2014-09-22 18:13:29 +0530151 {
152 psapContext->channel = psapContext->channelList[i];
153 break;
154 }
155 }
Peng Xu2446a892014-09-05 17:21:18 +0530156 }
157 else
158 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530159 /* if the channel list is empty then there is no valid channel
160 in the selected sub-band so select default channel in the
Peng Xu2446a892014-09-05 17:21:18 +0530161 BAND(2.4GHz) as 2.4 channels are available in all the
162 countries*/
163 psapContext->channel = SAP_DEFAULT_CHANNEL;
164 }
165 }
166 else
167 {
168 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530169 FL("Has scan band preference"));
Peng Xu2446a892014-09-05 17:21:18 +0530170 if (eCSR_BAND_24 == psapContext->currentPreferredBand)
171 psapContext->currentPreferredBand = eCSR_BAND_5G;
172 else
173 psapContext->currentPreferredBand = eCSR_BAND_24;
174
175 psapContext->allBandScanned = eSAP_TRUE;
176 //go back to DISCONNECT state, scan next band
177 psapContext->sapsMachine = eSAP_DISCONNECTED;
178 event = eSAP_CHANNEL_SELECTION_FAILED;
179 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 }
181#else
182 psapContext->channel = SAP_DEFAULT_CHANNEL;
183#endif
184 else
185 {
186 psapContext->channel = operChannel;
187 }
Gopichand Nakkala936715f2013-03-18 19:48:10 +0530188
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530189 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
190 FL("SAP Channel : %d"), psapContext->channel);
191}
192
193#ifdef WLAN_FEATURE_AP_HT40_24G
194/*==========================================================================
195 FUNCTION sapCheckFor20MhzObss()
196
197 DESCRIPTION
198 Check 20 MHz Overlapping BSS
199
200 DEPENDENCIES
201 NA.
202
203 PARAMETERS
204
205 IN
206 channelNumber : Peer BSS Operating Channel
207 tpSirProbeRespBeacon: Pointer to Beacon Struct
208 ptSapContext: Pointer to SAP Context
209
210 RETURN VALUE
211 v_U8_t : Success - Found OBSS BSS, Fail - zero
212
213 SIDE EFFECTS
214============================================================================*/
215
216eHalStatus sapCheckFor20MhzObss(v_U8_t channelNumber,
217 tpSirProbeRespBeacon pBeaconStruct,
218 ptSapContext psapCtx)
219{
220
221 v_U16_t secondaryChannelOffset;
222 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
223
224 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
225 FL("channelNumber: %d BSS: %s"), channelNumber,
226 pBeaconStruct->ssId.ssId);
227
228 if (channelNumber < psapCtx->affected_start
229 || channelNumber > psapCtx->affected_end)
230 {
231 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
232 FL("channelNumber: %d out of Affetced Channel Range: [%d,%d]"),
233 channelNumber, psapCtx->affected_start,
234 psapCtx->affected_end);
235 return halStatus;
236 }
237
238 if (!pBeaconStruct->HTCaps.present)
239 {
240 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
241 FL("Found overlapping legacy BSS: %s on Channel : %d"),
242 pBeaconStruct->ssId.ssId, channelNumber);
243 halStatus = eHAL_STATUS_FAILURE;
244 return halStatus;
245 }
246
247 if (pBeaconStruct->HTInfo.present)
248 {
249 secondaryChannelOffset = pBeaconStruct->HTInfo.secondaryChannelOffset;
250 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
251 FL("BSS: %s secondaryChannelOffset: %d on Channel : %d"),
252 pBeaconStruct->ssId.ssId, secondaryChannelOffset,
253 channelNumber);
254 if (PHY_SINGLE_CHANNEL_CENTERED == secondaryChannelOffset)
255 {
256 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
257 FL("Found overlapping 20 MHz HT BSS: %s on Channel : %d"),
258 pBeaconStruct->ssId.ssId, channelNumber);
259 halStatus = eHAL_STATUS_FAILURE;
260 return halStatus;
261 }
262 }
263 return halStatus;
264}
265
266/*==========================================================================
267 FUNCTION sapGetPrimarySecondaryChannelOfBss()
268
269 DESCRIPTION
270 Get Primary & Seconary Channel of Overlapping BSS
271
272 DEPENDENCIES
273 NA.
274
275 PARAMETERS
276
277 IN
278 tpSirProbeRespBeacon: Pointer to Beacon Struct
279 pri_chan : Primary Operating Channel
280 sec_chan : Seconary Operating Channel
281
282 RETURN VALUE
283
284 SIDE EFFECTS
285============================================================================*/
286
287void sapGetPrimarySecondaryChannelOfBss(tpSirProbeRespBeacon pBeaconStruct,
288 v_U32_t *pri_chan, v_U32_t *sec_chan)
289{
290 v_U16_t secondaryChannelOffset;
291 *pri_chan = 0;
292 *sec_chan = 0;
293
294 if (pBeaconStruct->HTInfo.present)
295 {
296 *pri_chan = pBeaconStruct->HTInfo.primaryChannel;
297 secondaryChannelOffset = pBeaconStruct->HTInfo.secondaryChannelOffset;
298 if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY == secondaryChannelOffset)
299 *sec_chan = *pri_chan + 4;
300 else if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == secondaryChannelOffset)
301 *sec_chan = *pri_chan - 4;
302 }
303
304 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
305 FL("BSS Primary & Secondary Channel : %d %d "),
306 *pri_chan, *sec_chan);
307}
308
309/*==========================================================================
310 FUNCTION sapCheckHT40PairIsAllowed()
311
312 DESCRIPTION
313 Check HT40 Channel Pair is Allowed
314
315 DEPENDENCIES
316 NA.
317
318 PARAMETERS
319
320 IN
321 ptSapContext: Pointer to SAP Context
322
323 RETURN VALUE
324 v_U8_t : Success - HT40 Allowed in Selected Channale Pair
325 Fail - HT40 Not Allowed
326
327 SIDE EFFECTS
328============================================================================*/
329
330eHalStatus sapCheckHT40PairIsAllowed(ptSapContext psapCtx)
331{
332 v_U8_t count;
333 v_U8_t fValidChannel = 0;
334 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
335
336 /* Verify that HT40 secondary channel is an allowed 20 MHz
337 * channel */
338 for (count = RF_CHAN_1; count <= RF_CHAN_14; count++)
339 {
340 if ((regChannels[count].enabled)
341 && (rfChannels[count].channelNum == psapCtx->sap_sec_chan))
342 {
343 fValidChannel = TRUE;
344 break;
345 }
346 }
347
348 if (!fValidChannel)
349 {
350 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
351 FL("HT40 In Secondary Channel : %d not allowed"),
352 psapCtx->sap_sec_chan);
353
354 halStatus = eHAL_STATUS_FAILURE;
355 return halStatus;
356 }
357
358 return halStatus;
359}
360
361/*==========================================================================
362 FUNCTION sapGet24GOBSSAffectedChannel()
363
364 DESCRIPTION
365 Get OBSS Affected Channel Range
366
367 DEPENDENCIES
368 NA.
369
370 PARAMETERS
371
372 IN
373 tHalHandle : tHalHandle passed in with Affected Channel
374 ptSapContext: Pointer to SAP Context
375
376 RETURN VALUE
377 v_U8_t : Success - Able to get AffectedChannel
378 Fail - Fail to get AffectedChannel
379
380 SIDE EFFECTS
381============================================================================*/
382
383eHalStatus sapGet24GOBSSAffectedChannel(tHalHandle halHandle,
384 ptSapContext psapCtx)
385{
386
387 v_U8_t cbMode;
388 v_U32_t pri_freq, sec_freq;
389 v_U32_t affected_start_freq, affected_end_freq;
390 eSapPhyMode sapPhyMode;
391 eHalStatus halStatus;
392
393 pri_freq = vos_chan_to_freq(psapCtx->channel);
394
395 sapPhyMode =
396 sapConvertSapPhyModeToCsrPhyMode(psapCtx->csrRoamProfile.phyMode);
397
398 sme_SelectCBMode(halHandle, sapPhyMode, psapCtx->channel);
399
400 cbMode = sme_GetChannelBondingMode24G(halHandle);
401
402 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
403 FL("Selected Channel bonding : %d"), cbMode);
404
405 if (cbMode == eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY)
406 sec_freq = pri_freq - 20;
407 else if (cbMode == eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY)
408 sec_freq = pri_freq + 20;
409 else
410 sec_freq = eCSR_INI_SINGLE_CHANNEL_CENTERED;
411
412 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
413 FL("Primary Freq : %d MHz Secondary Freq : %d MHz"),
414 pri_freq, sec_freq);
415
416 if (sec_freq)
417 {
418 /* As per 802.11 Std, Section 10.15.3.2 */
419 affected_start_freq = (pri_freq + sec_freq) / 2 - 25;
420 affected_end_freq = (pri_freq + sec_freq) / 2 + 25;
421
422 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
423 FL("Affected Start Freq: %d MHz Affected End Freq : %d MHz"),
424 affected_start_freq, affected_end_freq);
425
426 psapCtx->affected_start = vos_freq_to_chan(affected_start_freq);
427
428 /* As there is no channel availabe for 2397 & 2402 Frequency
429 * Hence taking valid channel 1 (Freq 2412) here
430 */
431 if (affected_start_freq < 2412)
432 psapCtx->affected_start = 1;
433
434 psapCtx->affected_end = vos_freq_to_chan(affected_end_freq);
435
436 /* As there is no channel availabe for 2477 & 2482 Frequency
437 * Hence taking lower channel 13 (Freq 2472) here.
438 */
439 if ((2477 == (affected_end_freq)) || (2482 == affected_end_freq))
440 {
441 psapCtx->affected_end = 13;
442 }
443 else if (2487 == affected_end_freq)
444 {
445 /* As there is no channel availabe for 2487 Frequency
446 * Hence taking lower channel 14 (Freq 2484) here.
447 */
448 psapCtx->affected_end = 14;
449 }
450
451 psapCtx->sap_sec_chan = vos_freq_to_chan(sec_freq);
452
453 halStatus = eHAL_STATUS_SUCCESS;
454 return halStatus;
455 }
456 else
457 {
458 psapCtx->affected_start = 0;
459 psapCtx->affected_end = 0;
460 psapCtx->sap_sec_chan = 0;
461 halStatus = eHAL_STATUS_FAILURE;
462 return halStatus;
463 }
464}
465
466/*==========================================================================
467 FUNCTION sapCheck40Mhz24G
468
469 DESCRIPTION
470 Check HT40 is possible in 2.4GHz mode
471
472 DEPENDENCIES
473 NA.
474
475 PARAMETERS
476
477 IN
478 halHandle : Pointer to HAL handle
479 ptSapContext : Pointer to SAP Context
480 pResult : Pointer to tScanResultHandle
481
482 RETURN VALUE
483 v_U8_t : Success - HT40 Possible, Fail - zero
484
485 SIDE EFFECTS
486============================================================================*/
487
488eHalStatus sapCheck40Mhz24G(tHalHandle halHandle, ptSapContext psapCtx,
489 tScanResultHandle pResult)
490{
491 v_U32_t pri_chan, sec_chan;
492 v_U32_t ieLen = 0;
493 v_U8_t channelNumber = 0;
494 tSirProbeRespBeacon *pBeaconStruct;
495 tCsrScanResultInfo *pScanResult;
496 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
497 eHalStatus halStatus = eHAL_STATUS_FAILURE;
498
499 if ( (0 == psapCtx->affected_start) && (0 == psapCtx->affected_end)
500 && (0 == psapCtx->sap_sec_chan))
501 {
502 if (eHAL_STATUS_SUCCESS !=
503 sapGet24GOBSSAffectedChannel(halHandle, psapCtx))
504 {
505 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
506 FL("Failed to get OBSS Affected Channel Range for Channel: %d"),
507 psapCtx->channel);
508 return halStatus;
509 }
510 }
511
512 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
513 FL("40 MHz affected channel range: [%d,%d] MHz"),
514 psapCtx->affected_start, psapCtx->affected_end);
515
516 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
517 FL("SAP Primary & Secondary Channel : [%d,%d] MHz"),
518 psapCtx->channel, psapCtx->sap_sec_chan);
519
520 pBeaconStruct = vos_mem_malloc(sizeof(tSirProbeRespBeacon));
521 if ( NULL == pBeaconStruct )
522 {
523 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
524 FL("Unable to allocate memory \n"));
525 return halStatus;
526 }
527
528 /* Check neighboring BSSes from scan result to see whether 40 MHz is
529 * allowed per IEEE Std 802.11-2012, 10.15.3.2 */
530 pScanResult = sme_ScanResultGetFirst(halHandle, pResult);
531
532 while (pScanResult)
533 {
534
535 /* if the Beacon has channel ID, use it other wise we will
536 * rely on the channelIdSelf
537 */
538 if(pScanResult->BssDescriptor.channelId == 0)
539 channelNumber = pScanResult->BssDescriptor.channelIdSelf;
540 else
541 channelNumber = pScanResult->BssDescriptor.channelId;
542
543 if (channelNumber > SIR_11B_CHANNEL_END)
544 {
545 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
546 FL("channelNumber: %d BSS: %s"),
547 channelNumber, pBeaconStruct->ssId.ssId);
548 goto NextResult;
549 }
550
551 if ((pScanResult->BssDescriptor.ieFields != NULL))
552 {
553 ieLen = (pScanResult->BssDescriptor.length + sizeof(tANI_U16));
554 ieLen += (sizeof(tANI_U32) - sizeof(tSirBssDescription));
555 vos_mem_set((tANI_U8 *) pBeaconStruct,
556 sizeof(tSirProbeRespBeacon), 0);
557
558 if ((eSIR_SUCCESS == sirParseBeaconIE(pMac, pBeaconStruct,
559 (tANI_U8 *)( pScanResult->BssDescriptor.ieFields), ieLen)))
560 {
561 /* SAP Operating channel is not same with other BSS Operating
562 * channel then check for Peer BSS is HT20 or Legacy AP
563 */
564 if (psapCtx->channel != channelNumber)
565 {
566 if (eHAL_STATUS_SUCCESS !=
567 sapCheckFor20MhzObss(channelNumber, pBeaconStruct,
568 psapCtx))
569 {
570 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
571 FL("Overlapping 20 MHz BSS is found"));
572 vos_mem_free(pBeaconStruct);
573 return halStatus;
574 }
575 }
576
577 sapGetPrimarySecondaryChannelOfBss(pBeaconStruct,
578 &pri_chan, &sec_chan);
579
580 /* Check peer BSS Operating channel is not within OBSS affected
581 * channel range
582 */
583 if ((pri_chan < psapCtx->affected_start
584 || pri_chan > psapCtx->affected_end)
585 && (sec_chan < psapCtx->affected_start
586 || sec_chan > psapCtx->affected_end))
587 {
588 goto NextResult; /* not within affected channel range */
589 }
590
591 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
592 FL("Neighboring BSS: %s Primary & Secondary Channel [%d %d]"),
593 pBeaconStruct->ssId.ssId, pri_chan, sec_chan);
594
595 if (sec_chan)
596 {
597 /* Peer BSS is HT40 capable then check peer BSS
598 * primary & secondary channel with SAP
599 * Primary & Secondary channel.
600 */
601 if ((psapCtx->channel != pri_chan)
602 || (psapCtx->sap_sec_chan != sec_chan))
603 {
604 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
605 FL("40 MHz Pri/Sec channel : [%d %d]"
606 " missmatch with BSS: %s"
607 " Pri/Sec channel : [%d %d]"),
608 psapCtx->channel, psapCtx->sap_sec_chan,
609 pBeaconStruct->ssId.ssId, pri_chan, sec_chan);
610 vos_mem_free(pBeaconStruct);
611 return halStatus;
612 }
613 }
614 else
615 {
616 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
617 FL("Channel: %d Overlapping BSS is found"),
618 pri_chan);
619 vos_mem_free(pBeaconStruct);
620 return halStatus;
621 }
622
623 if (pBeaconStruct->HTCaps.present)
624 {
625 /* Check Peer BSS HT capablity has 40MHz Intolerant bit */
626 if (pBeaconStruct->HTCaps.stbcControlFrame)
627 {
628 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
629 FL("Found BSS: %s with 40 MHz"
630 "Intolerant is set on Channel : %d"),
631 pBeaconStruct->ssId.ssId,
632 channelNumber);
633 vos_mem_free(pBeaconStruct);
634 return halStatus;
635 }
636 }
637 }
638 else
639 {
640 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
641 FL("Failed to Parse the Beacon IEs"));
642 }
643 }
644 else
645 {
646 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
647 FL("BSS IEs Failed is NULL in Scan"));
648 }
649
650NextResult:
651 pScanResult = sme_ScanResultGetNext(halHandle, pResult);
652 }
653 vos_mem_free(pBeaconStruct);
654
655 if (psapCtx->sap_sec_chan)
656 {
657 if (eHAL_STATUS_SUCCESS == sapCheckHT40PairIsAllowed(psapCtx))
658 {
659 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
660 FL("Start SAP/P2P GO in HT 40MHz "
661 "Primary & Secondary Channel: [%d %d]"),
662 psapCtx->channel, psapCtx->sap_sec_chan);
663 halStatus = eHAL_STATUS_SUCCESS;
664 return halStatus;
665 }
666 }
667
668 return halStatus;
669}
670#endif
671
672/*==========================================================================
673 FUNCTION WLANSAP_ScanCallback()
674
675 DESCRIPTION
676 Callback for Scan (scan results) Events
677
678 DEPENDENCIES
679 NA.
680
681 PARAMETERS
682
683 IN
684 tHalHandle : tHalHandle passed in with the scan request
685 *pContext : The second context pass in for the caller (sapContext)
686 scanID : scanID got after the scan
687 status : Status of scan -success, failure or abort
688
689 RETURN VALUE
690 The eHalStatus code associated with performing the operation
691
692 eHAL_STATUS_SUCCESS: Success
693
694 SIDE EFFECTS
695============================================================================*/
696eHalStatus
697WLANSAP_ScanCallback
698(
699 tHalHandle halHandle,
700 void *pContext, /* Opaque SAP handle */
701 v_U32_t scanID,
702 eCsrScanStatus scanStatus
703)
704{
705 tScanResultHandle pResult = NULL;
706 eHalStatus scanGetResultStatus = eHAL_STATUS_FAILURE;
707 ptSapContext psapContext = (ptSapContext)pContext;
708 void *pTempHddCtx;
709 tWLAN_SAPEvent sapEvent; /* State machine event */
710 v_U8_t operChannel = 0;
711 VOS_STATUS sapstatus;
712 v_U32_t event;
713 eSapPhyMode sapPhyMode;
714
715 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
716
717 pTempHddCtx = vos_get_context( VOS_MODULE_ID_HDD,
718 psapContext->pvosGCtx);
719 if (NULL == pTempHddCtx)
720 {
721 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL,
722 "HDD context is NULL");
723 return eHAL_STATUS_FAILURE;
724 }
725
726 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
727 "In %s, before switch on scanStatus = %d", __func__, scanStatus);
728
729 switch (scanStatus)
730 {
731 case eCSR_SCAN_SUCCESS:
732 // sapScanCompleteCallback with eCSR_SCAN_SUCCESS
733 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
734 "In %s, CSR scanStatus = %s (%d)", __func__,
735 "eCSR_SCAN_SUCCESS", scanStatus);
736
737 /* Get scan results, Run channel selection algorithm,
738 * select channel and keep in pSapContext->Channel
739 */
740 scanGetResultStatus = sme_ScanGetResult(halHandle, 0, NULL,
741 &pResult);
742
743 event = eSAP_MAC_SCAN_COMPLETE;
744
745 if ((scanGetResultStatus != eHAL_STATUS_SUCCESS)
746 && (scanGetResultStatus != eHAL_STATUS_E_NULL_VALUE))
747 {
748 // No scan results
749 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
750 "In %s, Get scan result failed! ret = %d",
751 __func__, scanGetResultStatus);
752 sapSetOperatingChannel(psapContext, operChannel);
753 break;
754 }
755
756#ifdef WLAN_FEATURE_AP_HT40_24G
757 if (psapContext->channel == AUTO_CHANNEL_SELECT)
758#endif
759 {
760 operChannel = sapSelectChannel(halHandle, psapContext, pResult);
761 sapSetOperatingChannel(psapContext, operChannel);
762 }
763
764#ifdef WLAN_FEATURE_AP_HT40_24G
765 if ((psapContext->channel <= SIR_11B_CHANNEL_END)
766 && (psapContext->channel > 0))
767 {
768 if (eHAL_STATUS_SUCCESS !=
769 sapCheck40Mhz24G(halHandle, psapContext, pResult))
770 {
771 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
772 FL("Starting SAP into HT20"));
773 /* Disable Channel Bonding for 2.4GHz */
774 sme_UpdateChannelBondingMode24G(halHandle,
775 PHY_SINGLE_CHANNEL_CENTERED);
776 }
777 }
778#endif
779 sme_ScanResultPurge(halHandle, pResult);
780 break;
781
782 default:
783 event = eSAP_CHANNEL_SELECTION_FAILED;
784 if (psapContext->channel == AUTO_CHANNEL_SELECT)
785 sapSetOperatingChannel(psapContext, operChannel);
786#ifdef WLAN_FEATURE_AP_HT40_24G
787 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
788 FL("Starting SAP into HT20"));
789 /* Disable Channel Bonding for 2.4GHz */
790 sme_UpdateChannelBondingMode24G(halHandle,
791 PHY_SINGLE_CHANNEL_CENTERED);
792#endif
793 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
794 FL("CSR scanStatus = %s (%d)"),
795 "eCSR_SCAN_ABORT/FAILURE", scanStatus);
796 }
797
798
799 sapPhyMode =
800 sapConvertSapPhyModeToCsrPhyMode(psapContext->csrRoamProfile.phyMode);
801
802#ifdef WLAN_FEATURE_AP_HT40_24G
803 if (psapContext->channel > SIR_11B_CHANNEL_END)
804#endif
805 sme_SelectCBMode(halHandle, sapPhyMode, psapContext->channel);
806
Jeff Johnson295189b2012-06-20 16:38:30 -0700807#ifdef SOFTAP_CHANNEL_RANGE
808 if(psapContext->channelList != NULL)
809 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -0700810 /* Always free up the memory for channel selection whatever
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 * the result */
812 vos_mem_free(psapContext->channelList);
813 psapContext->channelList = NULL;
814 }
815#endif
816
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530817 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
818 "In %s, Channel selected = %d", __func__, psapContext->channel);
Jeff Johnson295189b2012-06-20 16:38:30 -0700819
820 /* Fill in the event structure */
Peng Xu2446a892014-09-05 17:21:18 +0530821 sapEvent.event = event;
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 sapEvent.params = 0; // pCsrRoamInfo;
823 sapEvent.u1 = scanStatus; // roamstatus
824 sapEvent.u2 = 0; // roamResult
825
826 /* Handle event */
827 sapstatus = sapFsm(psapContext, &sapEvent);
828
829 return sapstatus;
830}// WLANSAP_ScanCallback
831
832/*==========================================================================
833 FUNCTION WLANSAP_RoamCallback()
834
835 DESCRIPTION
836 Callback for Roam (connection status) Events
837
838 DEPENDENCIES
839 NA.
840
841 PARAMETERS
842
843 IN
844 pContext : pContext passed in with the roam request
845 pCsrRoamInfo : Pointer to a tCsrRoamInfo, see definition of eRoamCmdStatus and
846 eRoamCmdResult: For detail valid members. It may be NULL
847 roamId : To identify the callback related roam request. 0 means unsolicited
848 roamStatus : Flag indicating the status of the callback
849 roamResult : Result
850
851 RETURN VALUE
852 The eHalStatus code associated with performing the operation
853
854 eHAL_STATUS_SUCCESS: Success
855
856 SIDE EFFECTS
857============================================================================*/
858eHalStatus
859WLANSAP_RoamCallback
860(
861 void *pContext, /* Opaque SAP handle */
862 tCsrRoamInfo *pCsrRoamInfo,
863 v_U32_t roamId,
864 eRoamCmdStatus roamStatus,
865 eCsrRoamResult roamResult
866)
867{
868 /* sapContext value */
869 ptSapContext sapContext = (ptSapContext) pContext;
870 tWLAN_SAPEvent sapEvent; /* State machine event */
871 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
872 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
873
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700874 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, before switch on roamStatus = %d\n", __func__, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 switch(roamStatus)
876 {
877 case eCSR_ROAM_SESSION_OPENED:
878 {
879 /* tHalHandle */
880 tHalHandle hHal = VOS_GET_HAL_CB(sapContext->pvosGCtx);
881
882 if (NULL == hHal)
883 {
884 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700885 "In %s invalid hHal", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 halStatus = eHAL_STATUS_FAILED_ALLOC;
887 }
888 else
889 {
890 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700891 "In %s calling sme_RoamConnect with eCSR_BSS_TYPE_INFRA_AP", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 sapContext->isSapSessionOpen = eSAP_TRUE;
893 halStatus = sme_RoamConnect(hHal, sapContext->sessionId,
894 &sapContext->csrRoamProfile,
895 &sapContext->csrRoamId);
896 }
897 break;
898 }
899
900 case eCSR_ROAM_INFRA_IND:
901 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700902 __func__, "eCSR_ROAM_INFRA_IND", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 if(roamResult == eCSR_ROAM_RESULT_INFRA_START_FAILED)
904 {
905 /* Fill in the event structure */
906 sapEvent.event = eSAP_MAC_START_FAILS;
907 sapEvent.params = pCsrRoamInfo;
908 sapEvent.u1 = roamStatus;
909 sapEvent.u2 = roamResult;
910
911 /* Handle event */
912 vosStatus = sapFsm(sapContext, &sapEvent);
913 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
914 {
915 halStatus = eHAL_STATUS_FAILURE;
916 }
917 }
918 break;
919
920 case eCSR_ROAM_LOSTLINK:
921 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700922 __func__, "eCSR_ROAM_LOSTLINK", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 break;
924
925 case eCSR_ROAM_MIC_ERROR_IND:
926 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700927 __func__, "eCSR_ROAM_MIC_ERROR_IND", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 break;
929
930 case eCSR_ROAM_SET_KEY_COMPLETE:
931 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700932 __func__, "eCSR_ROAM_SET_KEY_COMPLETE", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 if (roamResult == eCSR_ROAM_RESULT_FAILURE )
934 {
935 /* Format the SET KEY complete information pass to HDD... */
936 sapSignalHDDevent(sapContext, pCsrRoamInfo, eSAP_STA_SET_KEY_EVENT,(v_PVOID_t) eSAP_STATUS_FAILURE);
937 }
938 break;
939
940 case eCSR_ROAM_REMOVE_KEY_COMPLETE:
941 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700942 __func__, "eCSR_ROAM_REMOVE_KEY_COMPLETE", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 if (roamResult == eCSR_ROAM_RESULT_FAILURE )
944 {
945 /* Format the SET KEY complete information pass to HDD... */
946 sapSignalHDDevent(sapContext, pCsrRoamInfo, eSAP_STA_DEL_KEY_EVENT, (v_PVOID_t)eSAP_STATUS_FAILURE);
947 }
948 break;
949
950 case eCSR_ROAM_ASSOCIATION_COMPLETION:
951 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700952 __func__, "eCSR_ROAM_ASSOCIATION_COMPLETION", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 if (roamResult == eCSR_ROAM_RESULT_FAILURE )
954 {
955 /* Format the SET KEY complete information pass to HDD... */
956 sapSignalHDDevent(sapContext, pCsrRoamInfo, eSAP_STA_REASSOC_EVENT, (v_PVOID_t)eSAP_STATUS_FAILURE);
957 }
958 break;
959
960 case eCSR_ROAM_DISASSOCIATED:
961 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700962 __func__, "eCSR_ROAM_DISASSOCIATED", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 if (roamResult == eCSR_ROAM_RESULT_MIC_FAILURE)
964 {
965 /* Format the MIC failure event to return... */
966 sapSignalHDDevent(sapContext, pCsrRoamInfo, eSAP_STA_MIC_FAILURE_EVENT,(v_PVOID_t) eSAP_STATUS_FAILURE);
967 }
968 break;
969
970 case eCSR_ROAM_WPS_PBC_PROBE_REQ_IND:
971 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamStatus = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700972 __func__, "eCSR_ROAM_WPS_PBC_PROBE_REQ_IND", roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 break;
974
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 case eCSR_ROAM_INDICATE_MGMT_FRAME:
976 sapSignalHDDevent(sapContext, pCsrRoamInfo,
977 eSAP_INDICATE_MGMT_FRAME,
978 (v_PVOID_t) eSAP_STATUS_SUCCESS);
979 break;
980 case eCSR_ROAM_REMAIN_CHAN_READY:
981 sapSignalHDDevent(sapContext, pCsrRoamInfo,
982 eSAP_REMAIN_CHAN_READY,
983 (v_PVOID_t) eSAP_STATUS_SUCCESS);
984 break;
985 case eCSR_ROAM_SEND_ACTION_CNF:
986 sapSignalHDDevent(sapContext, pCsrRoamInfo,
987 eSAP_SEND_ACTION_CNF,
Arun Kumar Khandavalli022c5452014-02-17 16:20:48 +0530988 (v_PVOID_t)((eSapStatus)((roamResult == eCSR_ROAM_RESULT_NONE)
989 ? eSAP_STATUS_SUCCESS : eSAP_STATUS_FAILURE)));
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800991
992 case eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS:
993 sapSignalHDDevent(sapContext, pCsrRoamInfo,
994 eSAP_DISCONNECT_ALL_P2P_CLIENT,
995 (v_PVOID_t) eSAP_STATUS_SUCCESS );
996 break;
997
998 case eCSR_ROAM_SEND_P2P_STOP_BSS:
999 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, Received stopbss", __func__);
1000 sapSignalHDDevent(sapContext, pCsrRoamInfo,
1001 eSAP_MAC_TRIG_STOP_BSS_EVENT,
1002 (v_PVOID_t) eSAP_STATUS_SUCCESS );
1003 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001004
1005 default:
1006 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "In %s, CSR roamStatus not handled roamStatus = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001007 __func__, get_eRoamCmdStatus_str(roamStatus), roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 break;
1009
1010 }
1011
1012 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, before switch on roamResult = %d\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001013 __func__, roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001014
1015 switch (roamResult)
1016 {
1017 case eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND:
1018 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001019 __func__, "eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 sapContext->nStaWPARSnReqIeLength = pCsrRoamInfo->rsnIELen;
1021
1022 if(sapContext->nStaWPARSnReqIeLength)
1023 vos_mem_copy( sapContext->pStaWpaRsnReqIE,
1024 pCsrRoamInfo->prsnIE, sapContext->nStaWPARSnReqIeLength);
1025
1026 sapContext->nStaAddIeLength = pCsrRoamInfo->addIELen;
1027
1028 if(sapContext->nStaAddIeLength)
1029 vos_mem_copy( sapContext->pStaAddIE,
1030 pCsrRoamInfo->paddIE, sapContext->nStaAddIeLength);
1031
1032 sapContext->SapQosCfg.WmmIsEnabled = pCsrRoamInfo->wmmEnabledSta;
1033 // MAC filtering
1034 vosStatus = sapIsPeerMacAllowed(sapContext, (v_U8_t *)pCsrRoamInfo->peerMac);
1035
1036 if ( VOS_STATUS_SUCCESS == vosStatus )
1037 {
1038 vosStatus = sapSignalHDDevent( sapContext, pCsrRoamInfo, eSAP_STA_ASSOC_IND, (v_PVOID_t)eSAP_STATUS_SUCCESS);
1039 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1040 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08001041 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1042 "In %s, CSR roamResult = (%d) MAC ("
1043 MAC_ADDRESS_STR") fail", __func__, roamResult,
1044 MAC_ADDR_ARRAY(pCsrRoamInfo->peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 halStatus = eHAL_STATUS_FAILURE;
1046 }
1047 }
1048 else
1049 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08001050 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
1051 "In %s, CSR roamResult = (%d) MAC ("
1052 MAC_ADDRESS_STR") not allowed", __func__, roamResult,
1053 MAC_ADDR_ARRAY(pCsrRoamInfo->peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 halStatus = eHAL_STATUS_FAILURE;
1055 }
1056
1057 break;
1058
1059 case eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF:
1060 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001061 __func__, "eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001062
1063 sapContext->nStaWPARSnReqIeLength = pCsrRoamInfo->rsnIELen;
1064 if (sapContext->nStaWPARSnReqIeLength)
1065 vos_mem_copy( sapContext->pStaWpaRsnReqIE,
1066 pCsrRoamInfo->prsnIE, sapContext->nStaWPARSnReqIeLength);
1067
1068 sapContext->nStaAddIeLength = pCsrRoamInfo->addIELen;
1069 if(sapContext->nStaAddIeLength)
1070 vos_mem_copy( sapContext->pStaAddIE,
1071 pCsrRoamInfo->paddIE, sapContext->nStaAddIeLength);
1072
1073 sapContext->SapQosCfg.WmmIsEnabled = pCsrRoamInfo->wmmEnabledSta;
1074 /* Fill in the event structure */
1075 vosStatus = sapSignalHDDevent( sapContext, pCsrRoamInfo, eSAP_STA_ASSOC_EVENT, (v_PVOID_t)eSAP_STATUS_SUCCESS);
1076 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1077 {
1078 halStatus = eHAL_STATUS_FAILURE;
1079 }
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05301080#ifdef WLAN_FEATURE_AP_HT40_24G
1081 else
1082 {
1083 if (pCsrRoamInfo->HT40MHzIntoEnabledSta)
1084 {
1085 sapAddHT40IntolerantSta(sapContext, pCsrRoamInfo);
1086 }
1087 }
1088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 break;
1090
1091 case eCSR_ROAM_RESULT_DISASSOC_IND:
1092 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001093 __func__, "eCSR_ROAM_RESULT_DISASSOC_IND", roamResult);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05301094#ifdef WLAN_FEATURE_AP_HT40_24G
1095 sapRemoveHT40IntolerantSta(sapContext, pCsrRoamInfo);
1096#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 /* Fill in the event structure */
1098 vosStatus = sapSignalHDDevent( sapContext, pCsrRoamInfo, eSAP_STA_DISASSOC_EVENT, (v_PVOID_t)eSAP_STATUS_SUCCESS);
1099 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1100 {
1101 halStatus = eHAL_STATUS_FAILURE;
1102 }
1103 break;
1104
1105 case eCSR_ROAM_RESULT_DEAUTH_IND:
1106 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001107 __func__, "eCSR_ROAM_RESULT_DEAUTH_IND", roamResult);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05301108#ifdef WLAN_FEATURE_AP_HT40_24G
1109 sapRemoveHT40IntolerantSta(sapContext, pCsrRoamInfo);
1110#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 /* Fill in the event structure */
1112 //TODO: we will use the same event inorder to inform HDD to disassociate the station
1113 vosStatus = sapSignalHDDevent( sapContext, pCsrRoamInfo, eSAP_STA_DISASSOC_EVENT, (v_PVOID_t)eSAP_STATUS_SUCCESS);
1114 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1115 {
1116 halStatus = eHAL_STATUS_FAILURE;
1117 }
1118 break;
1119
1120 case eCSR_ROAM_RESULT_MIC_ERROR_GROUP:
1121 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001122 __func__, "eCSR_ROAM_RESULT_MIC_ERROR_GROUP", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 /* Fill in the event structure */
1124 //TODO: support for group key MIC failure event to be handled
1125 vosStatus = sapSignalHDDevent( sapContext, pCsrRoamInfo, eSAP_STA_MIC_FAILURE_EVENT,(v_PVOID_t) NULL);
1126 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1127 {
1128 halStatus = eHAL_STATUS_FAILURE;
1129 }
1130 break;
1131
1132 case eCSR_ROAM_RESULT_MIC_ERROR_UNICAST:
1133 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001134 __func__, "eCSR_ROAM_RESULT_MIC_ERROR_UNICAST", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 /* Fill in the event structure */
1136 //TODO: support for unicast key MIC failure event to be handled
1137 vosStatus = sapSignalHDDevent( sapContext, pCsrRoamInfo, eSAP_STA_MIC_FAILURE_EVENT,(v_PVOID_t) NULL);
1138 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1139 {
1140 halStatus = eHAL_STATUS_FAILURE;
1141 }
1142 break;
1143
1144 case eCSR_ROAM_RESULT_AUTHENTICATED:
1145 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001146 __func__, "eCSR_ROAM_RESULT_AUTHENTICATED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 /* Fill in the event structure */
1148 sapSignalHDDevent( sapContext, pCsrRoamInfo,eSAP_STA_SET_KEY_EVENT, (v_PVOID_t)eSAP_STATUS_SUCCESS);
1149 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1150 {
1151 halStatus = eHAL_STATUS_FAILURE;
1152 }
1153 break;
1154
1155 case eCSR_ROAM_RESULT_ASSOCIATED:
1156 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001157 __func__, "eCSR_ROAM_RESULT_ASSOCIATED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001158 /* Fill in the event structure */
1159 sapSignalHDDevent( sapContext, pCsrRoamInfo,eSAP_STA_REASSOC_EVENT, (v_PVOID_t)eSAP_STATUS_SUCCESS);
1160 break;
1161
1162 case eCSR_ROAM_RESULT_INFRA_STARTED:
1163 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001164 __func__, "eCSR_ROAM_RESULT_INFRA_STARTED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 /* Fill in the event structure */
1166 sapEvent.event = eSAP_MAC_START_BSS_SUCCESS;
1167 sapEvent.params = pCsrRoamInfo;
1168 sapEvent.u1 = roamStatus;
1169 sapEvent.u2 = roamResult;
1170
1171 /* Handle event */
1172 vosStatus = sapFsm(sapContext, &sapEvent);
1173 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1174 {
1175 halStatus = eHAL_STATUS_FAILURE;
1176 }
1177 break;
1178
1179 case eCSR_ROAM_RESULT_INFRA_STOPPED:
1180 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001181 __func__, "eCSR_ROAM_RESULT_INFRA_STOPPED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 /* Fill in the event structure */
1183 sapEvent.event = eSAP_MAC_READY_FOR_CONNECTIONS;
1184 sapEvent.params = pCsrRoamInfo;
1185 sapEvent.u1 = roamStatus;
1186 sapEvent.u2 = roamResult;
1187
1188 /* Handle event */
1189 vosStatus = sapFsm(sapContext, &sapEvent);
1190 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1191 {
1192 halStatus = eHAL_STATUS_FAILURE;
1193 }
1194 break;
1195
1196 case eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND:
1197 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001198 __func__, "eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 /* Fill in the event structure */
1200 //TODO: support for group key MIC failure event to be handled
1201 vosStatus = sapSignalHDDevent( sapContext, pCsrRoamInfo, eSAP_WPS_PBC_PROBE_REQ_EVENT,(v_PVOID_t) NULL);
1202 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1203 {
1204 halStatus = eHAL_STATUS_FAILURE;
1205 }
1206 break;
1207
1208 case eCSR_ROAM_RESULT_FORCED:
1209 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001210 __func__, "eCSR_ROAM_RESULT_FORCED", roamResult);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05301211#ifdef WLAN_FEATURE_AP_HT40_24G
1212 sapRemoveHT40IntolerantSta(sapContext, pCsrRoamInfo);
1213#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 //This event can be used to inform hdd about user triggered disassoc event
1215 /* Fill in the event structure */
1216 sapSignalHDDevent( sapContext, pCsrRoamInfo, eSAP_STA_DISASSOC_EVENT, (v_PVOID_t)eSAP_STATUS_SUCCESS);
1217 break;
1218
1219 case eCSR_ROAM_RESULT_NONE:
1220 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001221 __func__, "eCSR_ROAM_RESULT_NONE", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 //This event can be used to inform hdd about user triggered disassoc event
1223 /* Fill in the event structure */
1224 if ( roamStatus == eCSR_ROAM_SET_KEY_COMPLETE)
1225 {
1226 sapSignalHDDevent( sapContext, pCsrRoamInfo,eSAP_STA_SET_KEY_EVENT,(v_PVOID_t) eSAP_STATUS_SUCCESS);
1227 }
1228 else if (roamStatus == eCSR_ROAM_REMOVE_KEY_COMPLETE )
1229 {
1230 sapSignalHDDevent( sapContext, pCsrRoamInfo,eSAP_STA_DEL_KEY_EVENT,(v_PVOID_t) eSAP_STATUS_SUCCESS);
1231 }
1232 break;
1233
1234 case eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED:
1235 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, CSR roamResult = %s (%d)\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001236 __func__, "eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED", roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001237 /* Fill in the event structure */
1238 vosStatus = sapSignalHDDevent(sapContext, pCsrRoamInfo, eSAP_MAX_ASSOC_EXCEEDED, (v_PVOID_t)NULL);
1239 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1240 {
1241 halStatus = eHAL_STATUS_FAILURE;
1242 }
1243
1244 break;
1245 default:
1246 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "In %s, CSR roamResult = %s (%d) not handled\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001247 __func__,get_eCsrRoamResult_str(roamResult),roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 break;
1249 }
1250
1251 return halStatus;
1252}