blob: 270a708ba87d209aaef4796d830b566570ce4c97 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -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.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*===========================================================================
43
44 s a p F s m . C
45
46 OVERVIEW:
47
48 This software unit holds the implementation of the WLAN SAP Finite
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -070049 State Machine modules
Jeff Johnson295189b2012-06-20 16:38:30 -070050
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -070051 DEPENDENCIES:
Jeff Johnson295189b2012-06-20 16:38:30 -070052
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -070053 Are listed for each API below.
Jeff Johnson295189b2012-06-20 16:38:30 -070054
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -070055
Jeff Johnson295189b2012-06-20 16:38:30 -070056 Copyright (c) 2010 QUALCOMM Incorporated.
57 All Rights Reserved.
58 Qualcomm Confidential and Proprietary
59===========================================================================*/
60
61/*===========================================================================
62
63 EDIT HISTORY FOR FILE
64
65
66 This section contains comments describing changes made to the module.
67 Notice that changes are listed in reverse chronological order.
68
69
70
71 when who what, where, why
72---------- --- --------------------------------------------------------
732010-03-15 Created module
74
75===========================================================================*/
76
77
78/*----------------------------------------------------------------------------
79 * Include Files
80 * -------------------------------------------------------------------------*/
81#include "sapInternal.h"
82// Pick up the SME API definitions
83#include "sme_Api.h"
84// Pick up the PMC API definitions
85#include "pmcApi.h"
86#include "wlan_nv.h"
87
88/*----------------------------------------------------------------------------
89 * Preprocessor Definitions and Constants
90 * -------------------------------------------------------------------------*/
91
92/*----------------------------------------------------------------------------
93 * Type Declarations
94 * -------------------------------------------------------------------------*/
95
96/*----------------------------------------------------------------------------
97 * Global Data Definitions
98 * -------------------------------------------------------------------------*/
99
100/*----------------------------------------------------------------------------
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700101 * External declarations for global context
Jeff Johnson295189b2012-06-20 16:38:30 -0700102 * -------------------------------------------------------------------------*/
103
104/*----------------------------------------------------------------------------
105 * Static Variable Definitions
106 * -------------------------------------------------------------------------*/
107
108/*----------------------------------------------------------------------------
109 * Static Function Declarations and Definitions
110 * -------------------------------------------------------------------------*/
111#ifdef SOFTAP_CHANNEL_RANGE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700112static VOS_STATUS sapGetChannelList(ptSapContext sapContext, v_U8_t **channelList,
Jeff Johnson295189b2012-06-20 16:38:30 -0700113 v_U8_t *numberOfChannels);
114#endif
115/*----------------------------------------------------------------------------
116 * Externalized Function Definitions
117* -------------------------------------------------------------------------*/
118
119/*----------------------------------------------------------------------------
120 * Function Declarations and Documentation
121 * -------------------------------------------------------------------------*/
122
123/*==========================================================================
124 FUNCTION sapEventInit
125
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700126 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700127 Function for initializing sWLAN_SAPEvent structure
128
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700129 DEPENDENCIES
130 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700131
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700132 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700133
134 IN
135 sapEvent : State machine event
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700136
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 RETURN VALUE
138
139 None
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700140
141 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700142============================================================================*/
143static inline void sapEventInit(ptWLAN_SAPEvent sapEvent)
144{
145 sapEvent->event = eSAP_MAC_SCAN_COMPLETE;
146 sapEvent->params = 0;
147 sapEvent->u1 = 0;
148 sapEvent->u2 = 0;
149}
150
151/*==========================================================================
152 FUNCTION sapGotoChannelSel
153
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700154 DESCRIPTION
155 Function for initiating scan request for SME
Jeff Johnson295189b2012-06-20 16:38:30 -0700156
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700157 DEPENDENCIES
158 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700159
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700160 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700161
162 IN
163 sapContext : Sap Context value
164 sapEvent : State machine event
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700165
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 RETURN VALUE
167 The VOS_STATUS code associated with performing the operation
168
169 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700170
171 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700172============================================================================*/
173VOS_STATUS
174sapGotoChannelSel
175(
176 ptSapContext sapContext,
177 ptWLAN_SAPEvent sapEvent
178)
179{
180 /* Initiate a SCAN request */
Jeff Johnson43971f52012-07-17 12:26:56 -0700181 eHalStatus halStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700182 tCsrScanRequest scanRequest;/* To be initialised if scan is required */
183 v_U32_t scanRequestID = 0;
184 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
185
186#ifdef SOFTAP_CHANNEL_RANGE
187 v_U8_t *channelList = NULL;
188 v_U8_t numOfChannels = 0 ;
189#endif
190 tHalHandle hHal;
191 tANI_U8 channel;
192
193 hHal = (tHalHandle)vos_get_context( VOS_MODULE_ID_SME, sapContext->pvosGCtx);
194 if (NULL == hHal)
195 {
196 /* we have a serious problem */
197 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700198 "In %s, invalid hHal", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700199 return VOS_STATUS_E_FAULT;
200 }
201
202 /*If STA-AP concurrency is enabled take the concurrent connected channel first. In other cases wpa_supplicant should take care */
203 if (vos_get_concurrency_mode() == VOS_STA_SAP)
204 {
205 channel = sme_GetConcurrentOperationChannel(hHal);
206
207 if (channel)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700208 { /*if a valid channel is returned then use concurrent channel.
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 Else take whatever comes from configuartion*/
210 sapContext->channel = channel;
Kiet Lamef0b0352013-11-12 11:01:08 +0530211 sme_SelectCBMode(hHal,
212 sapConvertSapPhyModeToCsrPhyMode(sapContext->csrRoamProfile.phyMode),
213 channel);
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 }
215 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700216
217 if (sapContext->channel == AUTO_CHANNEL_SELECT)
Jeff Johnson295189b2012-06-20 16:38:30 -0700218 {
219 vos_mem_zero(&scanRequest, sizeof(scanRequest));
220
221 /* Set scanType to Passive scan */
222 scanRequest.scanType = eSIR_PASSIVE_SCAN;
223
224 /* Set min and max channel time to zero */
225 scanRequest.minChnTime = 0;
226 scanRequest.maxChnTime = 0;
227
228 /* Set BSSType to default type */
229 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700230
231#ifndef SOFTAP_CHANNEL_RANGE
Jeff Johnson295189b2012-06-20 16:38:30 -0700232 /*Scan all the channels */
233 scanRequest.ChannelInfo.numOfChannels = 0;
234
235 scanRequest.ChannelInfo.ChannelList = NULL;
236
237 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;//eCSR_SCAN_REQUEST_11D_SCAN;
238
239#else
240
241 sapGetChannelList(sapContext, &channelList, &numOfChannels);
242
243 /*Scan the channels in the list*/
244 scanRequest.ChannelInfo.numOfChannels = numOfChannels;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700245
Jeff Johnson295189b2012-06-20 16:38:30 -0700246 scanRequest.ChannelInfo.ChannelList = channelList;
247
248 scanRequest.requestType = eCSR_SCAN_SOFTAP_CHANNEL_RANGE;
249
250 sapContext->channelList = channelList;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700251
Jeff Johnson295189b2012-06-20 16:38:30 -0700252#endif
253 /* Set requestType to Full scan */
254
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700255 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, calling sme_ScanRequest", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700256
Jeff Johnson43971f52012-07-17 12:26:56 -0700257 halStatus = sme_ScanRequest(hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -0700258 0,//Not used in csrScanRequest
259 &scanRequest,
260 &scanRequestID,//, when ID == 0 11D scan/active scan with callback, min-maxChntime set in csrScanRequest()?
261 &WLANSAP_ScanCallback,//csrScanCompleteCallback callback,
262 sapContext);//void * pContext scanRequestID filled up
Jeff Johnson43971f52012-07-17 12:26:56 -0700263 if (eHAL_STATUS_SUCCESS != halStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700265 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "%s:sme_ScanRequest fail %d!!!", __func__, halStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "SoftAP Configuring for default channel, Ch= %d", sapContext->channel);
267 /* In case of error, switch to default channel */
268 sapContext->channel = SAP_DEFAULT_CHANNEL;
269
270#ifdef SOFTAP_CHANNEL_RANGE
271 if(sapContext->channelList != NULL)
272 {
273 sapContext->channel = sapContext->channelList[0];
274 vos_mem_free(sapContext->channelList);
275 sapContext->channelList = NULL;
276 }
277#endif
278 /* Fill in the event structure */
279 sapEventInit(sapEvent);
280 /* Handle event */
281 vosStatus = sapFsm(sapContext, sapEvent);
282 }
283 else
284 {
285 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, return from sme_ScanRequest, scanRequestID=%d, Ch= %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700286 __func__, scanRequestID, sapContext->channel);
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 }
288
289 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700290 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700292 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, for configured channel, Ch= %d", __func__, sapContext->channel);
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 /* Fill in the event structure */
294 // Eventhough scan was not done, means a user set channel was chosen
295 sapEventInit(sapEvent);
296 /* Handle event */
297 vosStatus = sapFsm(sapContext, sapEvent);
298 }
299
300 /* If scan failed, get default channel and advance state machine as success with default channel */
301 /* Have to wait for the call back to be called to get the channel cannot advance state machine here as said above */
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700302 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, before exiting sapGotoChannelSel channel=%d", __func__, sapContext->channel);
Jeff Johnson295189b2012-06-20 16:38:30 -0700303
304 return VOS_STATUS_SUCCESS;
305}// sapGotoChannelSel
306
307/*==========================================================================
308 FUNCTION sapGotoStarting
309
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700310 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 Function for initiating start bss request for SME
312
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700313 DEPENDENCIES
314 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700315
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700316 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700317
318 IN
319 sapContext : Sap Context value
320 sapEvent : State machine event
321 bssType : Type of bss to start, INRA AP
322 status : Return the SAP status here
323
324 RETURN VALUE
325 The VOS_STATUS code associated with performing the operation
326
327 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700328
329 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700330============================================================================*/
331VOS_STATUS
332sapGotoStarting
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700333(
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 ptSapContext sapContext,
335 ptWLAN_SAPEvent sapEvent,
336 eCsrRoamBssType bssType
337)
338{
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700339 /* tHalHandle */
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 tHalHandle hHal = VOS_GET_HAL_CB(sapContext->pvosGCtx);
341 eHalStatus halStatus;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700342
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 /*- - - - - - - - TODO:once configs from hdd available - - - - - - - - -*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700344 char key_material[32]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1,};
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 sapContext->key_type = 0x05;
346 sapContext->key_length = 32;
347 vos_mem_copy(sapContext->key_material, key_material, sizeof(key_material)); /* Need a key size define */
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700348
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700349 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 if (NULL == hHal)
351 {
352 /* we have a serious problem */
353 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700354 "In %s, invalid hHal", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 return VOS_STATUS_E_FAULT;
356 }
357
358 //TODO: What shall we do if failure????
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700359 halStatus = pmcRequestFullPower( hHal,
360 WLANSAP_pmcFullPwrReqCB,
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 sapContext,
362 eSME_REASON_OTHER);
363
364 /* Open SME Session for Softap */
365 halStatus = sme_OpenSession(hHal,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700366 &WLANSAP_RoamCallback,
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 sapContext,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700368 sapContext->self_mac_addr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 &sapContext->sessionId);
370
371 if(eHAL_STATUS_SUCCESS != halStatus )
372 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700373 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "Error: In %s calling sme_RoamConnect status = %d", __func__, halStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 return VOS_STATUS_E_FAILURE;
375 }
376
377 return VOS_STATUS_SUCCESS;
378}// sapGotoStarting
379
380/*==========================================================================
381 FUNCTION sapGotoDisconnecting
382
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700383 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 Processing of SAP FSM Disconnecting state
385
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700386 DEPENDENCIES
387 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700388
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700389 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700390
391 IN
392 sapContext : Sap Context value
393 status : Return the SAP status here
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700394
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 RETURN VALUE
396 The VOS_STATUS code associated with performing the operation
397
398 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700399
400 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700401============================================================================*/
402VOS_STATUS
403sapGotoDisconnecting
404(
405 ptSapContext sapContext
406)
407{
408 eHalStatus halStatus;
409 tHalHandle hHal;
410
411 hHal = VOS_GET_HAL_CB(sapContext->pvosGCtx);
412 if (NULL == hHal)
413 {
414 /* we have a serious problem */
415 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700416 "In %s, invalid hHal", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700417 return VOS_STATUS_E_FAULT;
418 }
419
420 sapFreeRoamProfile(&sapContext->csrRoamProfile);
421 halStatus = sme_RoamStopBss(hHal, sapContext->sessionId);
422 if(eHAL_STATUS_SUCCESS != halStatus )
423 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700424 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "Error: In %s calling sme_RoamStopBss status = %d", __func__, halStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 return VOS_STATUS_E_FAILURE;
426 }
427
428 return VOS_STATUS_SUCCESS;
429}
430
431static eHalStatus sapRoamSessionCloseCallback(void *pContext)
432{
433 ptSapContext sapContext = (ptSapContext)pContext;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700434 return sapSignalHDDevent(sapContext, NULL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 eSAP_STOP_BSS_EVENT, (v_PVOID_t) eSAP_STATUS_SUCCESS);
436}
437
438/*==========================================================================
439 FUNCTION sapGotoDisconnected
440
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700441 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700442 Function for setting the SAP FSM to Disconnection state
443
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700444 DEPENDENCIES
445 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700446
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700447 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700448
449 IN
450 sapContext : Sap Context value
451 sapEvent : State machine event
452 status : Return the SAP status here
453
454 RETURN VALUE
455 The VOS_STATUS code associated with performing the operation
456
457 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700458
459 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700460============================================================================*/
461VOS_STATUS
462sapGotoDisconnected
463(
464 ptSapContext sapContext
465)
466{
467 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
468 tWLAN_SAPEvent sapEvent;
469 // Processing has to be coded
470 // Clean up stations from TL etc as AP BSS is shut down then set event
471 sapEvent.event = eSAP_MAC_READY_FOR_CONNECTIONS;// hardcoded
472 sapEvent.params = 0;
473 sapEvent.u1 = 0;
474 sapEvent.u2 = 0;
475 /* Handle event */
476 vosStatus = sapFsm(sapContext, &sapEvent);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700477
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 return vosStatus;
479}
480
481/*==========================================================================
482 FUNCTION sapSignalHDDevent
483
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700484 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 Function for HDD to send the event notification using callback
486
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700487 DEPENDENCIES
488 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700489
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700490 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700491
492 IN
493 sapContext : Sap Context value
494 pCsrRoamInfo : Pointer to CSR roam information
495 sapHddevent : SAP HDD event
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700496 context : to pass the element for future support
497
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 RETURN VALUE
499 The VOS_STATUS code associated with performing the operation
500
501 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700502
503 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700504============================================================================*/
505VOS_STATUS
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700506sapSignalHDDevent
507(
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 ptSapContext sapContext, /* sapContext value */
509 tCsrRoamInfo *pCsrRoamInfo,
510 eSapHddEvent sapHddevent,
511 void *context
512)
513{
514 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
515 tSap_Event sapApAppEvent; /* This now encodes ALL event types */
516 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
517
518 /* Format the Start BSS Complete event to return... */
519 VOS_ASSERT(sapContext->pfnSapEventCallback);
520
521 switch (sapHddevent)
522 {
523 case eSAP_STA_ASSOC_IND:
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700524 // TODO - Indicate the assoc request indication to OS
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 sapApAppEvent.sapHddEventCode = eSAP_STA_ASSOC_IND;
526
527 vos_mem_copy( &sapApAppEvent.sapevt.sapAssocIndication.staMac, pCsrRoamInfo->peerMac,sizeof(tSirMacAddr));
528 sapApAppEvent.sapevt.sapAssocIndication.staId = pCsrRoamInfo->staId;
529 sapApAppEvent.sapevt.sapAssocIndication.status = 0;
530 // Required for indicating the frames to upper layer
531 sapApAppEvent.sapevt.sapAssocIndication.beaconLength = pCsrRoamInfo->beaconLength;
532 sapApAppEvent.sapevt.sapAssocIndication.beaconPtr = pCsrRoamInfo->beaconPtr;
533 sapApAppEvent.sapevt.sapAssocIndication.assocReqLength = pCsrRoamInfo->assocReqLength;
534 sapApAppEvent.sapevt.sapAssocIndication.assocReqPtr = pCsrRoamInfo->assocReqPtr;
535 sapApAppEvent.sapevt.sapAssocIndication.fWmmEnabled = pCsrRoamInfo->wmmEnabledSta;
536 if ( pCsrRoamInfo->u.pConnectedProfile != NULL )
537 {
538 sapApAppEvent.sapevt.sapAssocIndication.negotiatedAuthType = pCsrRoamInfo->u.pConnectedProfile->AuthType;
539 sapApAppEvent.sapevt.sapAssocIndication.negotiatedUCEncryptionType = pCsrRoamInfo->u.pConnectedProfile->EncryptionType;
540 sapApAppEvent.sapevt.sapAssocIndication.negotiatedMCEncryptionType = pCsrRoamInfo->u.pConnectedProfile->mcEncryptionType;
541 sapApAppEvent.sapevt.sapAssocIndication.fAuthRequired = pCsrRoamInfo->fAuthRequired;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700542 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 break;
544 case eSAP_START_BSS_EVENT:
545 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700546 __func__, "eSAP_START_BSS_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 sapApAppEvent.sapHddEventCode = eSAP_START_BSS_EVENT;
548 sapApAppEvent.sapevt.sapStartBssCompleteEvent.status = (eSapStatus )context;
549 if(pCsrRoamInfo != NULL ){
550 sapApAppEvent.sapevt.sapStartBssCompleteEvent.staId = pCsrRoamInfo->staId;
551 }
552 else
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700553 sapApAppEvent.sapevt.sapStartBssCompleteEvent.staId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 sapApAppEvent.sapevt.sapStartBssCompleteEvent.operatingChannel = (v_U8_t)sapContext->channel;
555 break;
556
557 case eSAP_STOP_BSS_EVENT:
558 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700559 __func__, "eSAP_STOP_BSS_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 sapApAppEvent.sapHddEventCode = eSAP_STOP_BSS_EVENT;
561 sapApAppEvent.sapevt.sapStopBssCompleteEvent.status = (eSapStatus )context;
562 break;
563
564 case eSAP_STA_ASSOC_EVENT:
565 {
566 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700567 __func__, "eSAP_STA_ASSOC_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700568 if (pCsrRoamInfo->fReassocReq)
569 sapApAppEvent.sapHddEventCode = eSAP_STA_REASSOC_EVENT;
570 else
571 sapApAppEvent.sapHddEventCode = eSAP_STA_ASSOC_EVENT;
572
573 //TODO: Need to fill the SET KEY information and pass to HDD
574 vos_mem_copy( &sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.staMac,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700575 pCsrRoamInfo->peerMac,sizeof(tSirMacAddr));
576 sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.staId = pCsrRoamInfo->staId ;
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.statusCode = pCsrRoamInfo->statusCode;
578 sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.iesLen = pCsrRoamInfo->rsnIELen;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700579 vos_mem_copy(sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.ies, pCsrRoamInfo->prsnIE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 pCsrRoamInfo->rsnIELen);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700581
582 if(pCsrRoamInfo->addIELen)
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 {
584 v_U8_t len = sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.iesLen;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700585 sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.iesLen
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 += pCsrRoamInfo->addIELen;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700587 vos_mem_copy(&sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.ies[len], pCsrRoamInfo->paddIE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 pCsrRoamInfo->addIELen);
589 }
590
591 sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.wmmEnabled = pCsrRoamInfo->wmmEnabledSta;
592 sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.status = (eSapStatus )context;
593 //TODO: Need to fill sapAuthType
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700594 //sapApAppEvent.sapevt.sapStationAssocReassocCompleteEvent.SapAuthType = pCsrRoamInfo->pProfile->negotiatedAuthType;
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 break;
596 }
597
598 case eSAP_STA_DISASSOC_EVENT:
599 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700600 __func__, "eSAP_STA_DISASSOC_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 sapApAppEvent.sapHddEventCode = eSAP_STA_DISASSOC_EVENT;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700602
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 vos_mem_copy( &sapApAppEvent.sapevt.sapStationDisassocCompleteEvent.staMac,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700604 pCsrRoamInfo->peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 sapApAppEvent.sapevt.sapStationDisassocCompleteEvent.staId = pCsrRoamInfo->staId;
606 if (pCsrRoamInfo->reasonCode == eCSR_ROAM_RESULT_FORCED)
607 sapApAppEvent.sapevt.sapStationDisassocCompleteEvent.reason = eSAP_USR_INITATED_DISASSOC;
608 else
609 sapApAppEvent.sapevt.sapStationDisassocCompleteEvent.reason = eSAP_MAC_INITATED_DISASSOC;
610
611 sapApAppEvent.sapevt.sapStationDisassocCompleteEvent.statusCode = pCsrRoamInfo->statusCode;
612 sapApAppEvent.sapevt.sapStationDisassocCompleteEvent.status = (eSapStatus )context;
613 break;
614
615 case eSAP_STA_SET_KEY_EVENT:
616 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700617 __func__, "eSAP_STA_SET_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 sapApAppEvent.sapHddEventCode = eSAP_STA_SET_KEY_EVENT;
619 sapApAppEvent.sapevt.sapStationSetKeyCompleteEvent.status = (eSapStatus )context;
620 vos_mem_copy(&sapApAppEvent.sapevt.sapStationSetKeyCompleteEvent.peerMacAddr,
621 pCsrRoamInfo->peerMac,sizeof(tSirMacAddr));
622 break;
623
624 case eSAP_STA_DEL_KEY_EVENT :
625 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700626 __func__, "eSAP_STA_DEL_KEY_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 sapApAppEvent.sapHddEventCode = eSAP_STA_DEL_KEY_EVENT;
628 sapApAppEvent.sapevt.sapStationDeleteKeyCompleteEvent.status = (eSapStatus )context;
629 //TODO: Should we need to send the key information
630 //sapApAppEvent.sapevt.sapStationDeleteKeyCompleteEvent.keyId = ;
631 break;
632
633 case eSAP_STA_MIC_FAILURE_EVENT :
634 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700635 __func__, "eSAP_STA_MIC_FAILURE_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 sapApAppEvent.sapHddEventCode = eSAP_STA_MIC_FAILURE_EVENT;
637 vos_mem_copy( &sapApAppEvent.sapevt.sapStationMICFailureEvent.srcMacAddr,
638 pCsrRoamInfo->u.pMICFailureInfo->srcMacAddr,
639 sizeof(tSirMacAddr));
640 vos_mem_copy( &sapApAppEvent.sapevt.sapStationMICFailureEvent.staMac,
641 pCsrRoamInfo->u.pMICFailureInfo->taMacAddr,
642 sizeof(tSirMacAddr));
643 vos_mem_copy( &sapApAppEvent.sapevt.sapStationMICFailureEvent.dstMacAddr,
644 pCsrRoamInfo->u.pMICFailureInfo->dstMacAddr,
645 sizeof(tSirMacAddr));
646 sapApAppEvent.sapevt.sapStationMICFailureEvent.multicast = pCsrRoamInfo->u.pMICFailureInfo->multicast;
647 sapApAppEvent.sapevt.sapStationMICFailureEvent.IV1 = pCsrRoamInfo->u.pMICFailureInfo->IV1;
648 sapApAppEvent.sapevt.sapStationMICFailureEvent.keyId = pCsrRoamInfo->u.pMICFailureInfo->keyId;
649 vos_mem_copy( sapApAppEvent.sapevt.sapStationMICFailureEvent.TSC,
650 pCsrRoamInfo->u.pMICFailureInfo->TSC,
651 SIR_CIPHER_SEQ_CTR_SIZE);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700653
654 case eSAP_ASSOC_STA_CALLBACK_EVENT:
655 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700656 __func__, "eSAP_ASSOC_STA_CALLBACK_EVENT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700657 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700658
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 case eSAP_WPS_PBC_PROBE_REQ_EVENT:
660 sapApAppEvent.sapHddEventCode = eSAP_WPS_PBC_PROBE_REQ_EVENT;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700661
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 vos_mem_copy( &sapApAppEvent.sapevt.sapPBCProbeReqEvent.WPSPBCProbeReq,
663 pCsrRoamInfo->u.pWPSPBCProbeReq,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700664 sizeof(tSirWPSPBCProbeReq));
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 break;
666
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 case eSAP_INDICATE_MGMT_FRAME:
668 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
669 "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700670 __func__, "eSAP_INDICATE_MGMT_FRAME");
Jeff Johnson295189b2012-06-20 16:38:30 -0700671 sapApAppEvent.sapHddEventCode = eSAP_INDICATE_MGMT_FRAME;
672 sapApAppEvent.sapevt.sapManagementFrameInfo.nFrameLength
673 = pCsrRoamInfo->nFrameLength;
674 sapApAppEvent.sapevt.sapManagementFrameInfo.pbFrames
675 = pCsrRoamInfo->pbFrames;
676 sapApAppEvent.sapevt.sapManagementFrameInfo.frameType
677 = pCsrRoamInfo->frameType;
678 sapApAppEvent.sapevt.sapManagementFrameInfo.rxChan
679 = pCsrRoamInfo->rxChan;
680
681 break;
682 case eSAP_REMAIN_CHAN_READY:
683 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
684 "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700685 __func__, "eSAP_REMAIN_CHAN_READY");
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 sapApAppEvent.sapHddEventCode = eSAP_REMAIN_CHAN_READY;
687 break;
688 case eSAP_SEND_ACTION_CNF:
689 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
690 "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700691 __func__, "eSAP_SEND_ACTION_CNF");
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 sapApAppEvent.sapHddEventCode = eSAP_SEND_ACTION_CNF;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700693 sapApAppEvent.sapevt.sapActionCnf.actionSendSuccess = (eSapStatus)context;
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -0800695
696 case eSAP_DISCONNECT_ALL_P2P_CLIENT:
697 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
698 "In %s, SAP event callback event = %s",
699 __func__, "eSAP_DISCONNECT_ALL_P2P_CLIENT");
700 sapApAppEvent.sapHddEventCode = eSAP_DISCONNECT_ALL_P2P_CLIENT;
701 sapApAppEvent.sapevt.sapActionCnf.actionSendSuccess = (eSapStatus)context;
702 break;
703
704 case eSAP_MAC_TRIG_STOP_BSS_EVENT :
705 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
706 "In %s, SAP event callback event = %s",
707 __func__, "eSAP_MAC_TRIG_STOP_BSS_EVENT");
708 sapApAppEvent.sapHddEventCode = eSAP_MAC_TRIG_STOP_BSS_EVENT;
709 sapApAppEvent.sapevt.sapActionCnf.actionSendSuccess = (eSapStatus)context;
710 break;
711
Jeff Johnson295189b2012-06-20 16:38:30 -0700712
713 case eSAP_UNKNOWN_STA_JOIN:
714 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
715 "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700716 __func__, "eSAP_UNKNOWN_STA_JOIN");
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 sapApAppEvent.sapHddEventCode = eSAP_UNKNOWN_STA_JOIN;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700718 vos_mem_copy((v_PVOID_t)sapApAppEvent.sapevt.sapUnknownSTAJoin.macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 (v_PVOID_t)context, sizeof(v_MACADDR_t));
720 break;
721
722 case eSAP_MAX_ASSOC_EXCEEDED:
723 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
724 "In %s, SAP event callback event = %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700725 __func__, "eSAP_MAX_ASSOC_EXCEEDED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 sapApAppEvent.sapHddEventCode = eSAP_MAX_ASSOC_EXCEEDED;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700727 vos_mem_copy((v_PVOID_t)sapApAppEvent.sapevt.sapMaxAssocExceeded.macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -0700728 (v_PVOID_t)pCsrRoamInfo->peerMac, sizeof(v_MACADDR_t));
729 break;
730
731 default:
732 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "In %s, SAP Unknown callback event = %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700733 __func__,sapHddevent);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 break;
735 }
736 vosStatus = (*sapContext->pfnSapEventCallback)
737 (
738 &sapApAppEvent,
739 sapContext->pUsrContext//userdataforcallback - hdd opaque handle
740 );
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700741
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 return vosStatus;
743
744} /* sapSignalApAppStartBssEvent */
745
746/*==========================================================================
747 FUNCTION sapFsm
748
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700749 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 SAP State machine entry function
751
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700752 DEPENDENCIES
753 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700754
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700755 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700756
757 IN
758 sapContext : Sap Context value
759 sapEvent : State machine event
760 status : Return the SAP status here
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700761
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 RETURN VALUE
763 The VOS_STATUS code associated with performing the operation
764
765 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700766
767 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700768============================================================================*/
769VOS_STATUS
770sapFsm
771(
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700772 ptSapContext sapContext, /* sapContext value */
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 ptWLAN_SAPEvent sapEvent /* State machine event */
774)
775{
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700776 /* Retrieve the phy link state machine structure
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 * from the sapContext value
778 */
779 eSapFsmStates_t stateVar = sapContext->sapsMachine; /*state var that keeps track of state machine*/
780 tCsrRoamInfo *roamInfo = (tCsrRoamInfo *)(sapEvent->params);
781 v_U32_t msg = sapEvent->event; /* State machine input event message */
782 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
783
784 switch (stateVar)
785 {
786 case eSAP_DISCONNECTED:
787 if ((msg == eSAP_HDD_START_INFRA_BSS))
788 {
789 /* Transition from eSAP_DISCONNECTED to eSAP_CH_SELECT (both without substates) */
790 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, new from state %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700791 __func__, "eSAP_DISCONNECTED", "eSAP_CH_SELECT");
Jeff Johnson295189b2012-06-20 16:38:30 -0700792
793 /* There can be one SAP Session for softap */
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700794 if (sapContext->isSapSessionOpen == eSAP_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 {
796 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700797 "%s:SME Session is already opened\n",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 return VOS_STATUS_E_EXISTS;
799 }
800
801 sapContext->sessionId = 0xff;
802
803 /* Set SAP device role */
804 sapContext->sapsMachine = eSAP_CH_SELECT;
805
806 /* Perform sme_ScanRequest */
807 vosStatus = sapGotoChannelSel(sapContext, sapEvent);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700808
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 /* Transition from eSAP_DISCONNECTED to eSAP_CH_SELECT (both without substates) */
810 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700811 __func__, "eSAP_DISCONNECTED", "eSAP_CH_SELECT");
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700812 }
813 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 {
815 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "In %s, in state %s, event msg %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700816 __func__, "eSAP_DISCONNECTED", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 }
818 break;
819
820 case eSAP_CH_SELECT:
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700821 if (msg == eSAP_MAC_SCAN_COMPLETE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 {
823 /* Transition from eSAP_CH_SELECT to eSAP_STARTING (both without substates) */
824 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700825 __func__, "eSAP_CH_SELECT", "eSAP_STARTING");
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 // Channel selected. Now can sapGotoStarting
827 sapContext->sapsMachine = eSAP_STARTING;
828 // Specify the channel
829 sapContext->csrRoamProfile.ChannelInfo.numOfChannels = 1;
830 sapContext->csrRoamProfile.ChannelInfo.ChannelList = &sapContext->csrRoamProfile.operationChannel;
831 sapContext->csrRoamProfile.operationChannel = (tANI_U8)sapContext->channel;
832 vosStatus = sapGotoStarting( sapContext, sapEvent, eCSR_BSS_TYPE_INFRA_AP);
833 /* Transition from eSAP_CH_SELECT to eSAP_STARTING (both without substates) */
834 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700835 __func__, "eSAP_CH_SELECT", "eSAP_STARTING");
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 }
837 else
838 {
839 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "In %s, in state %s, invalid event msg %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700840 __func__, "eSAP_CH_SELECT", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 }
842 break;
843
844 case eSAP_STARTING:
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700845 if (msg == eSAP_MAC_START_BSS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 {
847 /* Transition from eSAP_STARTING to eSAP_STARTED (both without substates) */
848 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state channel = %d %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700849 __func__,sapContext->channel, "eSAP_STARTING", "eSAP_STARTED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700850
851 sapContext->sapsMachine = eSAP_STARTED;
852 /*Action code for transition */
853 vosStatus = sapSignalHDDevent( sapContext, roamInfo, eSAP_START_BSS_EVENT, (v_PVOID_t)eSAP_STATUS_SUCCESS);
854
855 /* Transition from eSAP_STARTING to eSAP_STARTED (both without substates) */
856 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700857 __func__, "eSAP_STARTING", "eSAP_STARTED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700859 else if (msg == eSAP_MAC_START_FAILS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700861 /*Transition from STARTING to DISCONNECTED (both without substates)*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700863 __func__, "eSAP_STARTING", "eSAP_DISCONNECTED");
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700864
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 /*Action code for transition */
866 vosStatus = sapSignalHDDevent( sapContext, NULL, eSAP_START_BSS_EVENT,(v_PVOID_t) eSAP_STATUS_FAILURE);
867 vosStatus = sapGotoDisconnected(sapContext);
868
869 /*Advance outer statevar */
870 sapContext->sapsMachine = eSAP_DISCONNECTED;
871 }
872 else if (msg == eSAP_HDD_STOP_INFRA_BSS)
873 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700874 /*Transition from eSAP_STARTING to eSAP_DISCONNECTING (both without substates)*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700876 __func__, "eSAP_STARTING", "eSAP_DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -0700877
878 /*Advance outer statevar */
879 sapContext->sapsMachine = eSAP_DISCONNECTED;
880 vosStatus = sapSignalHDDevent( sapContext, NULL, eSAP_START_BSS_EVENT, (v_PVOID_t)eSAP_STATUS_FAILURE);
881 vosStatus = sapGotoDisconnected(sapContext);
882 /* Close the SME session*/
883
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700884 if (eSAP_TRUE == sapContext->isSapSessionOpen)
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 {
886 tHalHandle hHal = VOS_GET_HAL_CB(sapContext->pvosGCtx);
887 if (NULL == hHal)
888 {
889 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
890 "In %s, NULL hHal in state %s, msg %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700891 __func__, "eSAP_STARTING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700893 else if (eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 sme_CloseSession(hHal,
895 sapContext->sessionId, NULL, NULL))
896 {
897 sapContext->isSapSessionOpen = eSAP_FALSE;
898 }
899 }
900 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700901 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 {
903 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
904 "In %s, in state %s, invalid event msg %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700905 __func__, "eSAP_STARTING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 /* Intentionally left blank */
907 }
908 break;
909
910 case eSAP_STARTED:
911 if (msg == eSAP_HDD_STOP_INFRA_BSS)
912 {
913 /* Transition from eSAP_STARTED to eSAP_DISCONNECTING (both without substates) */
914 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700915 __func__, "eSAP_STARTED", "eSAP_DISCONNECTING");
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 sapContext->sapsMachine = eSAP_DISCONNECTING;
917 vosStatus = sapGotoDisconnecting(sapContext);
918 }
919 else
920 {
921 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "In %s, in state %s, invalid event msg %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700922 __func__, "eSAP_STARTED", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 }
924 break;
925
926 case eSAP_DISCONNECTING:
927 if (msg == eSAP_MAC_READY_FOR_CONNECTIONS)
928 {
929 /* Transition from eSAP_DISCONNECTING to eSAP_DISCONNECTED (both without substates) */
930 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "In %s, from state %s => %s",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700931 __func__, "eSAP_DISCONNECTING", "eSAP_DISCONNECTED");
Jeff Johnson295189b2012-06-20 16:38:30 -0700932
933 sapContext->sapsMachine = eSAP_DISCONNECTED;
934 /* Close the SME session*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700935 if (eSAP_TRUE == sapContext->isSapSessionOpen)
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 {
937 tHalHandle hHal = VOS_GET_HAL_CB(sapContext->pvosGCtx);
938
939 if (NULL == hHal)
940 {
941 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
942 "In %s, NULL hHal in state %s, msg %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700943 __func__, "eSAP_DISCONNECTING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 }
945 else
946 {
947 sapContext->isSapSessionOpen = eSAP_FALSE;
948 if (!HAL_STATUS_SUCCESS(
949 sme_CloseSession(hHal,
950 sapContext->sessionId,
951 sapRoamSessionCloseCallback, sapContext)))
952 {
953 vosStatus = sapSignalHDDevent(sapContext, NULL,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700954 eSAP_STOP_BSS_EVENT,
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 (v_PVOID_t) eSAP_STATUS_SUCCESS);
956 }
957 }
958 }
959 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700960 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700962 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 "In %s, in state %s, invalid event msg %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700964 __func__, "eSAP_DISCONNECTING", msg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 }
966 break;
967 }
968 return vosStatus;
969}// sapFsm
970
971
972eSapStatus
973sapconvertToCsrProfile(tsap_Config_t *pconfig_params, eCsrRoamBssType bssType, tCsrRoamProfile *profile)
974{
975 //Create Roam profile for SoftAP to connect
976 profile->BSSType = eCSR_BSS_TYPE_INFRA_AP;
977 profile->SSIDs.numOfSSIDs = 1;
978 profile->csrPersona = pconfig_params->persona;
979
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700980 vos_mem_zero(profile->SSIDs.SSIDList[0].SSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 sizeof(profile->SSIDs.SSIDList[0].SSID.ssId));
982
983 //Flag to not broadcast the SSID information
984 profile->SSIDs.SSIDList[0].ssidHidden = pconfig_params->SSIDinfo.ssidHidden;
985
986 profile->SSIDs.SSIDList[0].SSID.length = pconfig_params->SSIDinfo.ssid.length;
987 vos_mem_copy(&profile->SSIDs.SSIDList[0].SSID.ssId, pconfig_params->SSIDinfo.ssid.ssId,
988 sizeof(pconfig_params->SSIDinfo.ssid.ssId));
989
990 profile->negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
991
992 if (pconfig_params->authType == eSAP_OPEN_SYSTEM)
993 {
994 profile->negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
995 }
996 else if (pconfig_params->authType == eSAP_SHARED_KEY)
997 {
998 profile->negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
999 }
1000 else
1001 {
1002 profile->negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
1003 }
1004
1005 profile->AuthType.numEntries = 1;
1006 profile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1007
1008 //Always set the Encryption Type
1009 profile->EncryptionType.numEntries = 1;
1010 profile->EncryptionType.encryptionType[0] = pconfig_params->RSNEncryptType;
1011
1012 profile->mcEncryptionType.numEntries = 1;
1013 profile->mcEncryptionType.encryptionType[0] = pconfig_params->mcRSNEncryptType;
1014
1015 if (pconfig_params->privacy & eSAP_SHARED_KEY)
1016 {
1017 profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
1018 }
1019
1020 profile->privacy = pconfig_params->privacy;
1021 profile->fwdWPSPBCProbeReq = pconfig_params->fwdWPSPBCProbeReq;
1022
1023 if (pconfig_params->authType == eSAP_SHARED_KEY)
1024 {
1025 profile->csr80211AuthType = eSIR_SHARED_KEY;
1026 }
1027 else if (pconfig_params->authType == eSAP_OPEN_SYSTEM)
1028 {
1029 profile->csr80211AuthType = eSIR_OPEN_SYSTEM;
1030 }
1031 else
1032 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001033 profile->csr80211AuthType = eSIR_AUTO_SWITCH;
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 }
1035
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001036 //Initialize we are not going to use it
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 profile->pWPAReqIE = NULL;
1038 profile->nWPAReqIELength = 0;
1039
1040 //set the RSN/WPA IE
1041 profile->pRSNReqIE = NULL;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001042 profile->nRSNReqIELength = pconfig_params->RSNWPAReqIELength;
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 if (pconfig_params->RSNWPAReqIELength)
1044 {
1045 profile->pRSNReqIE = vos_mem_malloc(pconfig_params->RSNWPAReqIELength);
1046 if( NULL == profile->pRSNReqIE )
1047 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001048 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, " %s Fail to alloc memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 return eSAP_STATUS_FAILURE;
1050 }
1051 vos_mem_copy(profile->pRSNReqIE, pconfig_params->pRSNWPAReqIE, pconfig_params->RSNWPAReqIELength);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001052 profile->nRSNReqIELength = pconfig_params->RSNWPAReqIELength;
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 }
1054
1055 // Turn off CB mode
1056 profile->CBMode = eCSR_CB_OFF;
1057
1058 //set the phyMode to accept anything
1059 //Best means everything because it covers all the things we support
1060 profile->phyMode = pconfig_params->SapHw_mode; /*eCSR_DOT11_MODE_BEST*/
1061
1062 //Configure beaconInterval
1063 profile->beaconInterval = (tANI_U16)pconfig_params->beacon_int;
1064
1065 // set DTIM period
1066 profile->dtimPeriod = pconfig_params->dtim_period;
1067
1068 //set Uapsd enable bit
1069 profile->ApUapsdEnable = pconfig_params->UapsdEnable;
1070
1071 //Enable protection parameters
1072 profile->protEnabled = pconfig_params->protEnabled;
1073 profile->obssProtEnabled = pconfig_params->obssProtEnabled;
1074 profile->cfg_protection = pconfig_params->ht_capab;
1075
1076 //country code
1077 if (pconfig_params->countryCode[0])
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001078 vos_mem_copy(profile->countryCode, pconfig_params->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 profile->ieee80211d = pconfig_params->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 //wps config info
1081 profile->wps_state = pconfig_params->wps_state;
1082
1083 return eSAP_STATUS_SUCCESS; /* Success. */
1084}
1085
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07001086/**
1087 * FUNCTION: sapConvertSapPhyModeToCsrPhyMode
1088 * Called internally by SAP
1089 */
1090eCsrPhyMode sapConvertSapPhyModeToCsrPhyMode( eSapPhyMode sapPhyMode )
1091{
1092 switch (sapPhyMode)
1093 {
1094 case (eSAP_DOT11_MODE_abg):
1095 return eCSR_DOT11_MODE_abg;
1096 case (eSAP_DOT11_MODE_11b):
1097 return eCSR_DOT11_MODE_11b;
1098 case (eSAP_DOT11_MODE_11g):
1099 return eCSR_DOT11_MODE_11g;
1100 case (eSAP_DOT11_MODE_11n):
1101 return eCSR_DOT11_MODE_11n;
1102 case (eSAP_DOT11_MODE_11g_ONLY):
1103 return eCSR_DOT11_MODE_11g_ONLY;
1104 case (eSAP_DOT11_MODE_11n_ONLY):
1105 return eCSR_DOT11_MODE_11n_ONLY;
1106 case (eSAP_DOT11_MODE_11b_ONLY):
1107 return eCSR_DOT11_MODE_11b_ONLY;
1108#ifdef WLAN_FEATURE_11AC
1109 case (eSAP_DOT11_MODE_11ac_ONLY):
1110 return eCSR_DOT11_MODE_11ac_ONLY;
1111 case (eSAP_DOT11_MODE_11ac):
1112 return eCSR_DOT11_MODE_11ac;
1113#endif
1114 default:
1115 return eCSR_DOT11_MODE_AUTO;
1116 }
1117}
Jeff Johnson295189b2012-06-20 16:38:30 -07001118
1119void sapFreeRoamProfile(tCsrRoamProfile *profile)
1120{
1121 if(profile->pRSNReqIE)
1122 {
1123 vos_mem_free(profile->pRSNReqIE);
1124 profile->pRSNReqIE = NULL;
1125 }
1126}
1127
1128
1129void
1130sapSortMacList(v_MACADDR_t *macList, v_U8_t size)
1131{
1132 v_U8_t outer, inner;
1133 v_MACADDR_t temp;
1134 v_SINT_t nRes = -1;
1135
1136 for(outer = 0; outer < size; outer++)
1137 {
1138 for(inner = 0; inner < size - 1; inner++)
1139 {
1140 nRes = vos_mem_compare2((macList + inner)->bytes, (macList + inner + 1)->bytes, sizeof(v_MACADDR_t));
1141 if (nRes > 0)
1142 {
1143 vos_mem_copy(temp.bytes, (macList + inner + 1)->bytes, sizeof(v_MACADDR_t));
1144 vos_mem_copy((macList + inner + 1)->bytes, (macList + inner)->bytes, sizeof(v_MACADDR_t));
1145 vos_mem_copy((macList + inner)->bytes, temp.bytes, sizeof(v_MACADDR_t));
1146 }
1147 }
1148 }
1149}
1150
1151eSapBool
1152sapSearchMacList(v_MACADDR_t *macList, v_U8_t num_mac, v_U8_t *peerMac, v_U8_t *index)
1153{
1154 v_SINT_t nRes = -1;
1155 v_S7_t nStart = 0, nEnd, nMiddle;
1156 nEnd = num_mac - 1;
1157
1158 while (nStart <= nEnd)
1159 {
1160 nMiddle = (nStart + nEnd) / 2;
1161 nRes = vos_mem_compare2(&macList[nMiddle], peerMac, sizeof(v_MACADDR_t));
1162
1163 if (0 == nRes)
1164 {
1165 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
1166 "search SUCC");
1167 // "index equals NULL" means the caller does not need the
1168 // index value of the peerMac being searched
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001169 if (index != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001170 {
1171 *index = (v_U8_t) nMiddle;
1172 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
1173 "index %d", *index);
1174 }
1175 return eSAP_TRUE;
1176 }
1177 if (nRes < 0)
1178 nStart = nMiddle + 1;
1179 else
1180 nEnd = nMiddle - 1;
1181 }
1182
1183 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
1184 "search not succ");
1185 return eSAP_FALSE;
1186}
1187
1188void
1189sapAddMacToACL(v_MACADDR_t *macList, v_U8_t *size, v_U8_t *peerMac)
1190{
1191 v_SINT_t nRes = -1;
1192 int i;
1193 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"add acl entered");
1194 for (i=((*size)-1); i>=0; i--)
1195 {
1196 nRes = vos_mem_compare2(&macList[i], peerMac, sizeof(v_MACADDR_t));
1197 if (nRes > 0)
1198 {
1199 /* Move alphabetically greater mac addresses one index down to allow for insertion
1200 of new mac in sorted order */
1201 vos_mem_copy((macList+i+1)->bytes,(macList+i)->bytes, sizeof(v_MACADDR_t));
1202 }
1203 else
1204 {
1205 break;
1206 }
1207 }
1208 //This should also take care of if the element is the first to be added in the list
1209 vos_mem_copy((macList+i+1)->bytes, peerMac, sizeof(v_MACADDR_t));
1210 // increment the list size
1211 (*size)++;
1212}
1213
1214void
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001215sapRemoveMacFromACL(v_MACADDR_t *macList, v_U8_t *size, v_U8_t index)
Jeff Johnson295189b2012-06-20 16:38:30 -07001216{
1217 int i;
1218 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"remove acl entered");
1219 /* return if the list passed is empty. Ideally this should never happen since this funcn is always
1220 called after sapSearchMacList to get the index of the mac addr to be removed and this will
1221 only get called if the search is successful. Still no harm in having the check */
1222 if (macList==NULL) return;
1223 for (i=index; i<((*size)-1); i++)
1224 {
1225 /* Move mac addresses starting from "index" passed one index up to delete the void
1226 created by deletion of a mac address in ACL */
1227 vos_mem_copy((macList+i)->bytes,(macList+i+1)->bytes, sizeof(v_MACADDR_t));
1228 }
1229 // The last space should be made empty since all mac addesses moved one step up
1230 vos_mem_zero((macList+(*size)-1)->bytes, sizeof(v_MACADDR_t));
1231 //reduce the list size by 1
1232 (*size)--;
1233}
1234
1235void sapPrintACL(v_MACADDR_t *macList, v_U8_t size)
1236{
1237 int i;
Arif Hussain24bafea2013-11-15 15:10:03 -08001238 v_BYTE_t *macArray;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001239 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"print acl entered");
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 if (size==0) return;
1241 for (i=0; i<size; i++)
1242 {
Arif Hussain24bafea2013-11-15 15:10:03 -08001243 macArray = (macList+i)->bytes;
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08001245 "** ACL entry %i - "MAC_ADDRESS_STR, i,
1246 MAC_ADDR_ARRAY(macArray));
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 }
1248 return;
1249}
1250
1251VOS_STATUS
1252sapIsPeerMacAllowed(ptSapContext sapContext, v_U8_t *peerMac)
1253{
1254 if (eSAP_ALLOW_ALL == sapContext->eSapMacAddrAclMode)
1255 return VOS_STATUS_SUCCESS;
1256
1257 if (sapSearchMacList(sapContext->acceptMacList, sapContext->nAcceptMac, peerMac, NULL))
1258 return VOS_STATUS_SUCCESS;
1259
1260 if (sapSearchMacList(sapContext->denyMacList, sapContext->nDenyMac, peerMac, NULL))
1261 {
Arif Hussain24bafea2013-11-15 15:10:03 -08001262 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
1263 "In %s, Peer "MAC_ADDRESS_STR" in deny list",
1264 __func__, MAC_ADDR_ARRAY(peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 return VOS_STATUS_E_FAILURE;
1266 }
1267
1268 // A new station CAN associate, unless in deny list. Less stringent mode
1269 if (eSAP_ACCEPT_UNLESS_DENIED == sapContext->eSapMacAddrAclMode)
1270 return VOS_STATUS_SUCCESS;
1271
1272 // A new station CANNOT associate, unless in accept list. More stringent mode
1273 if (eSAP_DENY_UNLESS_ACCEPTED == sapContext->eSapMacAddrAclMode)
1274 {
Arif Hussain24bafea2013-11-15 15:10:03 -08001275 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
1276 "In %s, Peer "MAC_ADDRESS_STR" denied, Mac filter mode is eSAP_DENY_UNLESS_ACCEPTED",
1277 __func__, MAC_ADDR_ARRAY(peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 return VOS_STATUS_E_FAILURE;
1279 }
1280
1281 /* The new STA is neither in accept list nor in deny list. In this case, deny the association
1282 * but send a wifi event notification indicating the mac address being denied
1283 */
1284 if (eSAP_SUPPORT_ACCEPT_AND_DENY == sapContext->eSapMacAddrAclMode)
1285 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001286 sapSignalHDDevent(sapContext, NULL, eSAP_UNKNOWN_STA_JOIN, (v_PVOID_t)peerMac);
Arif Hussain24bafea2013-11-15 15:10:03 -08001287 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
1288 "In %s, Peer "MAC_ADDRESS_STR" denied, Mac filter mode is eSAP_SUPPORT_ACCEPT_AND_DENY",
1289 __func__, MAC_ADDR_ARRAY(peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 return VOS_STATUS_E_FAILURE;
1291 }
1292 return VOS_STATUS_SUCCESS;
1293}
1294
1295#ifdef SOFTAP_CHANNEL_RANGE
1296static VOS_STATUS sapGetChannelList(ptSapContext sapContext,
1297 v_U8_t **channelList, v_U8_t *numberOfChannels)
1298{
1299 v_U32_t startChannelNum;
1300 v_U32_t endChannelNum;
1301 v_U32_t operatingBand;
1302 v_U8_t loopCount;
1303 v_U8_t *list;
1304 v_U8_t channelCount;
1305 v_U8_t bandStartChannel;
1306 v_U8_t bandEndChannel ;
1307 v_U32_t enableLTECoex;
1308 tHalHandle hHal = VOS_GET_HAL_CB(sapContext->pvosGCtx);
1309
1310 if (NULL == hHal)
1311 {
1312 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1313 "Invalid HAL pointer from pvosGCtx on sapGetChannelList");
1314 *numberOfChannels = 0;
1315 *channelList = NULL;
1316 return VOS_STATUS_E_FAULT;
1317 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001318
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL, &startChannelNum);
1320 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL, &endChannelNum);
1321 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
1322 ccmCfgGetInt(hHal, WNI_CFG_ENABLE_LTE_COEX, &enableLTECoex);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001323
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1325 "%s:sapGetChannelList: startChannel %d,EndChannel %d,Operatingband:%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001326 __func__,startChannelNum,endChannelNum,operatingBand);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001327
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 switch(operatingBand)
1329 {
1330 case RF_SUBBAND_2_4_GHZ:
1331 bandStartChannel = RF_CHAN_1;
1332 bandEndChannel = RF_CHAN_14;
1333 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001334
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 case RF_SUBBAND_5_LOW_GHZ:
1336 bandStartChannel = RF_CHAN_36;
1337 bandEndChannel = RF_CHAN_64;
1338 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001339
Jeff Johnson295189b2012-06-20 16:38:30 -07001340 case RF_SUBBAND_5_MID_GHZ:
1341 bandStartChannel = RF_CHAN_100;
Leo Chang80de3c22013-11-26 10:52:12 -08001342#ifndef FEATURE_WLAN_CH144
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 bandEndChannel = RF_CHAN_140;
Leo Chang80de3c22013-11-26 10:52:12 -08001344#else
1345 bandEndChannel = RF_CHAN_144;
1346#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001348
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 case RF_SUBBAND_5_HIGH_GHZ:
1350 bandStartChannel = RF_CHAN_149;
1351 bandEndChannel = RF_CHAN_165;
1352 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001353
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 default:
1355 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1356 "sapGetChannelList:OperatingBand not valid ");
1357 /* assume 2.4 GHz */
1358 bandStartChannel = RF_CHAN_1;
1359 bandEndChannel = RF_CHAN_14;
1360 break;
1361 }
1362 /*Check if LTE coex is enabled and 2.4GHz is selected*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001363 if (enableLTECoex && (bandStartChannel == RF_CHAN_1)
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 && (bandEndChannel == RF_CHAN_14))
1365 {
1366 /*Set 2.4GHz upper limit to channel 9 for LTE COEX*/
1367 bandEndChannel = RF_CHAN_9;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 /* Allocate the max number of channel supported */
1370 list = (v_U8_t *)vos_mem_malloc(NUM_5GHZ_CHANNELS);
1371 if (NULL == list)
1372 {
1373 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001374 "%s: Unable to allocate channel list", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 *numberOfChannels = 0;
1376 *channelList = NULL;
1377 return VOS_STATUS_E_RESOURCES;
1378 }
1379
1380 /*Search for the Active channels in the given range */
1381 channelCount = 0;
1382 for( loopCount = bandStartChannel; loopCount <= bandEndChannel; loopCount++ )
1383 {
1384 if((startChannelNum <= rfChannels[loopCount].channelNum)&&
1385 (endChannelNum >= rfChannels[loopCount].channelNum ))
1386 {
1387 if( regChannels[loopCount].enabled )
1388 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001389 list[channelCount] = rfChannels[loopCount].channelNum;
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 channelCount++;
1391 }
1392 }
1393 }
1394 if (0 == channelCount)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001395 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1397 "sapGetChannelList:No active channels present in the given range for the current region");
1398 /*LTE COEX: channel range outside the restricted 2.4GHz band limits*/
1399 if (enableLTECoex && (startChannelNum > bandEndChannel))
1400 {
1401 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL,
1402 "sapGetChannelList:SAP cannot be started as LTE COEX restricted 2.4GHz limits");
1403 }
1404 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001405
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 /* return the channel list and number of channels to scan*/
1407 *numberOfChannels = channelCount;
1408 if(channelCount != 0)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001409 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 *channelList = list;
1411 }
1412 else
1413 {
1414 *channelList = NULL;
1415 vos_mem_free(list);
1416 }
1417 return VOS_STATUS_SUCCESS;
1418}
1419#endif