blob: e6109599ec62d1a451eee69a2626e4310e562da4 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh2e45e7d2018-01-29 14:43:14 +05302 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
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 M o d u l e . C
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -070031
Jeff Johnson295189b2012-06-20 16:38:30 -070032 OVERVIEW:
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -070033
Jeff Johnson295189b2012-06-20 16:38:30 -070034 This software unit holds the implementation of the WLAN SAP modules
35 functions providing EXTERNAL APIs. It is also where the global SAP module
36 context gets initialised
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -070037
38 DEPENDENCIES:
Jeff Johnson295189b2012-06-20 16:38:30 -070039
40 Are listed for each API below.
Jeff Johnson295189b2012-06-20 16:38:30 -070041===========================================================================*/
42
43/*===========================================================================
44
45 EDIT HISTORY FOR FILE
46
47
48 This section contains comments describing changes made to the module.
49 Notice that changes are listed in reverse chronological order.
50
51
52
53 when who what, where, why
54---------- --- --------------------------------------------------------
5503/15/10 SOFTAP team Created module
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07005606/03/10 js Added support to hostapd driven
Jeff Johnson295189b2012-06-20 16:38:30 -070057 * deauth/disassoc/mic failure
58
59===========================================================================*/
60
61/* $Header$ */
62
63/*----------------------------------------------------------------------------
64 * Include Files
65 * -------------------------------------------------------------------------*/
66#include "wlan_qct_tl.h"
67#include "vos_trace.h"
68
69// Pick up the sme callback registration API
70#include "sme_Api.h"
71
72// SAP API header file
73
74#include "sapInternal.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070075#include "smeInside.h"
76
77/*----------------------------------------------------------------------------
78 * Preprocessor Definitions and Constants
79 * -------------------------------------------------------------------------*/
80#define SAP_DEBUG
81
82/*----------------------------------------------------------------------------
83 * Type Declarations
84 * -------------------------------------------------------------------------*/
85
86
87/*----------------------------------------------------------------------------
88 * Global Data Definitions
89 * -------------------------------------------------------------------------*/
90
91/*----------------------------------------------------------------------------
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -070092 * External declarations for global context
Jeff Johnson295189b2012-06-20 16:38:30 -070093 * -------------------------------------------------------------------------*/
94// No! Get this from VOS.
95// The main per-Physical Link (per WLAN association) context.
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -070096ptSapContext gpSapCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070097
98/*----------------------------------------------------------------------------
99 * Static Variable Definitions
100 * -------------------------------------------------------------------------*/
101
102/*----------------------------------------------------------------------------
103 * Static Function Declarations and Definitions
104 * -------------------------------------------------------------------------*/
105
106/*----------------------------------------------------------------------------
107 * Externalized Function Definitions
108* -------------------------------------------------------------------------*/
109
110/*----------------------------------------------------------------------------
111 * Function Declarations and Documentation
112 * -------------------------------------------------------------------------*/
113
114/*==========================================================================
115 FUNCTION WLANSAP_Open
116
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700117 DESCRIPTION
118 Called at driver initialization (vos_open). SAP will initialize
119 all its internal resources and will wait for the call to start to
120 register with the other modules.
121
122 DEPENDENCIES
123
124 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700125
126 IN
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700127 pvosGCtx : Pointer to the global vos context; a handle to SAP's
128 control block can be extracted from its context
Jeff Johnson295189b2012-06-20 16:38:30 -0700129
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700130 RETURN VALUE
131 The result code associated with performing the operation
132
133 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
134 fault
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 VOS_STATUS_SUCCESS: Success
136
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700137 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700138============================================================================*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700139VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -0700140WLANSAP_Open
141(
142 v_PVOID_t pvosGCtx
143)
144{
145
146 ptSapContext pSapCtx = NULL;
147 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
148 VOS_ASSERT(pvosGCtx);
149 /*------------------------------------------------------------------------
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700150 Allocate (and sanity check?!) SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 ------------------------------------------------------------------------*/
152 vos_alloc_context(pvosGCtx, VOS_MODULE_ID_SAP, (v_VOID_t **)&pSapCtx, sizeof(tSapContext));
153
154 if (NULL == pSapCtx)
155 {
156 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700157 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 return VOS_STATUS_E_FAULT;
159 }
160
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 /*------------------------------------------------------------------------
162 Clean up SAP control block, initialize all values
163 ------------------------------------------------------------------------*/
164 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANSAP_Open");
165
166 WLANSAP_CleanCB(pSapCtx, 0 /*do not empty*/);
167
Hanumantha Reddy Pothulaf30a2982015-05-15 15:02:30 +0530168 if (!VOS_IS_STATUS_SUCCESS(vos_spin_lock_init(&pSapCtx->staInfo_lock)))
169 {
170 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
171 "WLANSAP_Start failed init staInfo_lock");
172 vos_free_context(pvosGCtx, VOS_MODULE_ID_SAP, pSapCtx);
173 return VOS_STATUS_E_FAULT;
174 }
175
Hanumanth Reddy Pothula9102fbc2018-05-29 13:07:55 +0530176 init_completion(&pSapCtx->ecsa_info.chan_switch_comp);
177
Abhishek Singh10e17cf2018-03-12 14:34:22 +0530178 if (!VOS_IS_STATUS_SUCCESS(
179 vos_spin_lock_init(&pSapCtx->ecsa_info.ecsa_lock)))
180 {
181 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
182 "WLANSAP_Start failed init ecsa_lock");
183 vos_free_context(pvosGCtx, VOS_MODULE_ID_SAP, pSapCtx);
184 return VOS_STATUS_E_FAULT;
185 }
186
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 // Setup the "link back" to the VOSS context
188 pSapCtx->pvosGCtx = pvosGCtx;
189
190 // Store a pointer to the SAP context provided by VOSS
191 gpSapCtx = pSapCtx;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700192
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 /*------------------------------------------------------------------------
194 Allocate internal resources
195 ------------------------------------------------------------------------*/
196
197 return VOS_STATUS_SUCCESS;
198}// WLANSAP_Open
199
200/*==========================================================================
201 FUNCTION WLANSAP_Start
202
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700203 DESCRIPTION
204 Called as part of the overall start procedure (vos_start). SAP will
205 use this call to register with TL as the SAP entity for
206 SAP RSN frames.
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700208 DEPENDENCIES
209
210 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700211
212 IN
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700213 pvosGCtx : Pointer to the global vos context; a handle to SAP's
214 control block can be extracted from its context
Jeff Johnson295189b2012-06-20 16:38:30 -0700215
216 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700217 The result code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -0700218
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700219 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
220 fault
Jeff Johnson295189b2012-06-20 16:38:30 -0700221 VOS_STATUS_SUCCESS: Success
222
223 SIDE EFFECTS
224============================================================================*/
225
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700226VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -0700227WLANSAP_Start
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700228(
229 v_PVOID_t pvosGCtx
Jeff Johnson295189b2012-06-20 16:38:30 -0700230)
231{
Jeff Johnson295189b2012-06-20 16:38:30 -0700232 ptSapContext pSapCtx = NULL;
233
234 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
235
236 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
237 "WLANSAP_Start invoked successfully\n");
238 /*------------------------------------------------------------------------
239 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700240 Extract SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -0700241 ------------------------------------------------------------------------*/
242 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700243 if ( NULL == pSapCtx )
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 {
245 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700246 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 return VOS_STATUS_E_FAULT;
248 }
249
250 /*------------------------------------------------------------------------
251 For now, presume security is not enabled.
252 -----------------------------------------------------------------------*/
253 pSapCtx->ucSecEnabled = WLANSAP_SECURITY_ENABLED_STATE;
254
255
256 /*------------------------------------------------------------------------
257 Now configure the roaming profile links. To SSID and bssid.
258 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700259 // We have room for two SSIDs.
260 pSapCtx->csrRoamProfile.SSIDs.numOfSSIDs = 1; // This is true for now.
261 pSapCtx->csrRoamProfile.SSIDs.SSIDList = pSapCtx->SSIDList; //Array of two
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 pSapCtx->csrRoamProfile.SSIDs.SSIDList[0].SSID.length = 0;
263 pSapCtx->csrRoamProfile.SSIDs.SSIDList[0].handoffPermitted = VOS_FALSE;
264 pSapCtx->csrRoamProfile.SSIDs.SSIDList[0].ssidHidden = pSapCtx->SSIDList[0].ssidHidden;
265
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700266 pSapCtx->csrRoamProfile.BSSIDs.numOfBSSIDs = 1; // This is true for now.
267 pSapCtx->csrRoamProfile.BSSIDs.bssid = &pSapCtx->bssid;
Jeff Johnson295189b2012-06-20 16:38:30 -0700268
269 // Now configure the auth type in the roaming profile. To open.
270 pSapCtx->csrRoamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM; // open is the default
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700271
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pSapCtx->SapGlobalLock)))
273 {
274 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700275 "WLANSAP_Start failed init lock\n");
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 return VOS_STATUS_E_FAULT;
277 }
278
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 return VOS_STATUS_SUCCESS;
280}/* WLANSAP_Start */
281
282/*==========================================================================
283
284 FUNCTION WLANSAP_Stop
285
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700286 DESCRIPTION
287 Called by vos_stop to stop operation in SAP, before close. SAP will suspend all
288 BT-AMP Protocol Adaption Layer operation and will wait for the close
289 request to clean up its resources.
Jeff Johnson295189b2012-06-20 16:38:30 -0700290
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700291 DEPENDENCIES
292
293 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700294
295 IN
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700296 pvosGCtx : Pointer to the global vos context; a handle to SAP's
297 control block can be extracted from its context
Jeff Johnson295189b2012-06-20 16:38:30 -0700298
299 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700300 The result code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -0700301
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700302 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
303 fault
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 VOS_STATUS_SUCCESS: Success
305
306 SIDE EFFECTS
307============================================================================*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700308VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -0700309WLANSAP_Stop
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700310(
311 v_PVOID_t pvosGCtx
Jeff Johnson295189b2012-06-20 16:38:30 -0700312)
313{
314
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 ptSapContext pSapCtx = NULL;
316
317 /*------------------------------------------------------------------------
318 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700319 Extract SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 ------------------------------------------------------------------------*/
321 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
322 "WLANSAP_Stop invoked successfully ");
323
324 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
325 if (NULL == pSapCtx)
326 {
327 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700328 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 return VOS_STATUS_E_FAULT;
330 }
331
332 sapFreeRoamProfile(&pSapCtx->csrRoamProfile);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700333
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pSapCtx->SapGlobalLock ) ) )
335 {
336 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700337 "WLANSAP_Stop failed destroy lock\n");
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 return VOS_STATUS_E_FAULT;
339 }
340 /*------------------------------------------------------------------------
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700341 Stop SAP (de-register RSN handler!?)
Jeff Johnson295189b2012-06-20 16:38:30 -0700342 ------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700343
344 return VOS_STATUS_SUCCESS;
345}/* WLANSAP_Stop */
346
347/*==========================================================================
348 FUNCTION WLANSAP_Close
349
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700350 DESCRIPTION
351 Called by vos_close during general driver close procedure. SAP will clean up
352 all the internal resources.
Jeff Johnson295189b2012-06-20 16:38:30 -0700353
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700354 DEPENDENCIES
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700356 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700357
358 IN
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700359 pvosGCtx : Pointer to the global vos context; a handle to SAP's
360 control block can be extracted from its context
Jeff Johnson295189b2012-06-20 16:38:30 -0700361
362 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700363 The result code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -0700364
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700365 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
366 fault
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 VOS_STATUS_SUCCESS: Success
368
369 SIDE EFFECTS
370============================================================================*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700371VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -0700372WLANSAP_Close
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700373(
374 v_PVOID_t pvosGCtx
Jeff Johnson295189b2012-06-20 16:38:30 -0700375)
376{
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 ptSapContext pSapCtx = NULL;
378 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
379
380 /*------------------------------------------------------------------------
381 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700382 Extract SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 ------------------------------------------------------------------------*/
384 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
385 "WLANSAP_Close invoked");
386
387 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
388 if (NULL == pSapCtx)
389 {
390 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700391 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 return VOS_STATUS_E_FAULT;
393 }
394
395 /*------------------------------------------------------------------------
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700396 Cleanup SAP control block.
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 ------------------------------------------------------------------------*/
398 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANSAP_Close");
399 WLANSAP_CleanCB(pSapCtx, VOS_TRUE /* empty queues/lists/pkts if any*/);
400
401 /*------------------------------------------------------------------------
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700402 Free SAP context from VOSS global
Jeff Johnson295189b2012-06-20 16:38:30 -0700403 ------------------------------------------------------------------------*/
404 vos_free_context(pvosGCtx, VOS_MODULE_ID_SAP, pSapCtx);
405
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 return VOS_STATUS_SUCCESS;
407}/* WLANSAP_Close */
408
409/*----------------------------------------------------------------------------
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700410 * Utility Function implementations
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 * -------------------------------------------------------------------------*/
412
413/*==========================================================================
414
415 FUNCTION WLANSAP_CleanCB
416
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700417 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 Clear out all fields in the SAP context.
419
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700420 DEPENDENCIES
Jeff Johnson295189b2012-06-20 16:38:30 -0700421
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700422 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700423
424 IN
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700425 pvosGCtx : Pointer to the global vos context; a handle to SAP's
426 control block can be extracted from its context
Jeff Johnson295189b2012-06-20 16:38:30 -0700427
428 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700429 The result code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -0700430
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700431 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
432 fault
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 VOS_STATUS_SUCCESS: Success
434
435 SIDE EFFECTS
436============================================================================*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700437VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -0700438WLANSAP_CleanCB
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700439(
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 ptSapContext pSapCtx,
441 v_U32_t freeFlag // 0 /*do not empty*/);
442)
443{
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 /*------------------------------------------------------------------------
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700445 Sanity check SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 ------------------------------------------------------------------------*/
447
448 if (NULL == pSapCtx)
449 {
450 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700451 "%s: Invalid SAP pointer", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 return VOS_STATUS_E_FAULT;
453 }
454
455 /*------------------------------------------------------------------------
456 Clean up SAP control block, initialize all values
457 ------------------------------------------------------------------------*/
458 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "WLANSAP_CleanCB");
459
460 vos_mem_zero( pSapCtx, sizeof(tSapContext));
461
462 pSapCtx->pvosGCtx = NULL;
463
464 pSapCtx->sapsMachine= eSAP_DISCONNECTED;
465
Jeff Johnson797280e2017-09-19 08:36:01 -0700466 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH, "%s: Initializing State: %d, sapContext value = %pK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700467 __func__, pSapCtx->sapsMachine, pSapCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 pSapCtx->sessionId = 0;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700469 pSapCtx->channel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700470
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 return VOS_STATUS_SUCCESS;
472}// WLANSAP_CleanCB
473
474/*==========================================================================
475 FUNCTION WLANSAP_pmcFullPwrReqCB
476
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700477 DESCRIPTION
478 Callback provide to PMC in the pmcRequestFullPower API.
Jeff Johnson295189b2012-06-20 16:38:30 -0700479
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700480 DEPENDENCIES
Jeff Johnson295189b2012-06-20 16:38:30 -0700481
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700482 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700483
484 IN
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700485 callbackContext: The user passed in a context to identify
486 status: The halStatus
Jeff Johnson295189b2012-06-20 16:38:30 -0700487
488 RETURN VALUE
489 None
490
491 SIDE EFFECTS
492============================================================================*/
493void
494WLANSAP_pmcFullPwrReqCB
495(
496 void *callbackContext,
497 eHalStatus status
498)
499{
500 if(HAL_STATUS_SUCCESS(status))
501 {
502 //If success what else to be handled???
503 }
504 else
505 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700506 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 "WLANSAP_pmcFullPwrReqCB: PMC failed to put the chip in Full power\n");
508
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 }
510
511}// WLANSAP_pmcFullPwrReqCB
512/*==========================================================================
513 FUNCTION WLANSAP_getState
514
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700515 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 This api returns the current SAP state to the caller.
517
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700518 DEPENDENCIES
Jeff Johnson295189b2012-06-20 16:38:30 -0700519
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700520 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700521
522 IN
523 pContext : Pointer to Sap Context structure
524
525 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700526 Returns the SAP FSM state.
Jeff Johnson295189b2012-06-20 16:38:30 -0700527============================================================================*/
528
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700529v_U8_t WLANSAP_getState
Jeff Johnson295189b2012-06-20 16:38:30 -0700530(
531 v_PVOID_t pvosGCtx
532)
533{
534 ptSapContext pSapCtx = NULL;
535
536 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
537
538 if ( NULL == pSapCtx )
539 {
540 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700541 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 return VOS_STATUS_E_FAULT;
543 }
544 return pSapCtx->sapsMachine;
545}
Nishank Aggarwalc11826c2016-12-15 18:54:10 +0530546/*==========================================================================
547 FUNCTION WLANSAP_get_sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -0700548
Nishank Aggarwalc11826c2016-12-15 18:54:10 +0530549 DESCRIPTION
550 This api returns the current SAP sessionId to the caller.
551
552 DEPENDENCIES
553
554 PARAMETERS
555
556 IN
557 pContext : Pointer to Sap Context structure
558 v_U8_t : Pointer to sessionID
559
560 RETURN VALUE
561 VOS_STATUS_SUCCESS on success.
562
563 VOS_STATUS_E_INVAL: Pointer to SAP cb is NULL ; access would cause a page
564 fault
565============================================================================*/
566VOS_STATUS WLANSAP_get_sessionId
567(
568 v_PVOID_t pvosGCtx, v_U8_t *sessionId
569)
570{
571 ptSapContext pSapCtx = NULL;
Nishank Aggarwalc11826c2016-12-15 18:54:10 +0530572 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
573
574 if ( NULL == pSapCtx )
575 {
576 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
577 "%s: Invalid SAP pointer from pvosGCtx", __func__);
gaurank kathpalia392e4452018-02-26 15:40:30 +0530578 return VOS_STATUS_E_INVAL;
Nishank Aggarwalc11826c2016-12-15 18:54:10 +0530579 }
580
gaurank kathpalia392e4452018-02-26 15:40:30 +0530581 if (pSapCtx->sapsMachine != eSAP_STARTED)
582 return VOS_STATUS_E_FAILURE;
Nishank Aggarwalc11826c2016-12-15 18:54:10 +0530583
gaurank kathpalia392e4452018-02-26 15:40:30 +0530584 *sessionId = pSapCtx->sessionId;
585 return VOS_STATUS_SUCCESS;
Nishank Aggarwalc11826c2016-12-15 18:54:10 +0530586}
Jeff Johnson295189b2012-06-20 16:38:30 -0700587/*==========================================================================
588 FUNCTION WLANSAP_StartBss
589
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700590 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 This api function provides SAP FSM event eWLAN_SAP_PHYSICAL_LINK_CREATE for
592 starting AP BSS
593
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700594 DEPENDENCIES
Jeff Johnson295189b2012-06-20 16:38:30 -0700595
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700596 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700597
598 IN
599 pContext : Pointer to Sap Context structure
600 pQctCommitConfig : Pointer to configuration structure passed down from HDD(HostApd for Android)
601 hdd_SapEventCallback: Callback function in HDD called by SAP to inform HDD about SAP results
602 pUsrContext : Parameter that will be passed back in all the SAP callback events.
603
604 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700605 The result code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -0700606
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700607 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
608 fault
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 VOS_STATUS_SUCCESS: Success
610
611 SIDE EFFECTS
612============================================================================*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700613VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -0700614WLANSAP_StartBss
615(
616 v_PVOID_t pvosGCtx,//pwextCtx
617 tpWLAN_SAPEventCB pSapEventCallback,
618 tsap_Config_t *pConfig,
619 v_PVOID_t pUsrContext
620)
621{
622 tWLAN_SAPEvent sapEvent; /* State machine event*/
623 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
624 ptSapContext pSapCtx = NULL;
625 tANI_BOOLEAN restartNeeded;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700626 tHalHandle hHal;
627
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
629
630 /*------------------------------------------------------------------------
631 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700632 Extract SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 ------------------------------------------------------------------------*/
634 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
635 "WLANSAP_StartBss");
636
637 if (VOS_STA_SAP_MODE == vos_get_conparam ())
638 {
639 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
640 if ( NULL == pSapCtx )
641 {
642 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700643 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 return VOS_STATUS_E_FAULT;
645 }
646 pSapCtx->sapsMachine = eSAP_DISCONNECTED;
647
648 /* Channel selection is auto or configured */
649 pSapCtx->channel = pConfig->channel;
Peng Xu2446a892014-09-05 17:21:18 +0530650 pSapCtx->scanBandPreference = pConfig->scanBandPreference;
Peng Xuafc34e32014-09-25 13:23:55 +0530651 pSapCtx->acsBandSwitchThreshold = pConfig->acsBandSwitchThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -0700652 pSapCtx->pUsrContext = pUsrContext;
653
654 //Set the BSSID to your "self MAC Addr" read the mac address from Configuation ITEM received from HDD
655 pSapCtx->csrRoamProfile.BSSIDs.numOfBSSIDs = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700656
657 //Save a copy to SAP context
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700658 vos_mem_copy(pSapCtx->csrRoamProfile.BSSIDs.bssid,
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 pConfig->self_macaddr.bytes, sizeof(v_MACADDR_t));
660 vos_mem_copy(pSapCtx->self_mac_addr,
661 pConfig->self_macaddr.bytes, sizeof(v_MACADDR_t));
662
663 //copy the configuration items to csrProfile
664 sapconvertToCsrProfile( pConfig, eCSR_BSS_TYPE_INFRA_AP, &pSapCtx->csrRoamProfile);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700665 hHal = (tHalHandle)VOS_GET_HAL_CB(pvosGCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 if (NULL == hHal)
667 {
668 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700669 "%s: Invalid MAC context from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 }
671 else
672 {
673 //If concurrent session is running that is already associated
674 //then we just follow that sessions country info (whether
675 //present or not doesn't maater as we have to follow whatever
676 //STA session does)
Rajkumar Manoharaned6fd542013-11-26 22:55:16 +0530677 if ((0 == sme_GetConcurrentOperationChannel(hHal)) &&
678 pConfig->ieee80211d)
Jeff Johnson295189b2012-06-20 16:38:30 -0700679 {
680 /* Setting the region/country information */
681 sme_setRegInfo(hHal, pConfig->countryCode);
682 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
683 }
684 }
685
686 // Copy MAC filtering settings to sap context
687 pSapCtx->eSapMacAddrAclMode = pConfig->SapMacaddr_acl;
688 vos_mem_copy(pSapCtx->acceptMacList, pConfig->accept_mac, sizeof(pConfig->accept_mac));
689 pSapCtx->nAcceptMac = pConfig->num_accept_mac;
690 sapSortMacList(pSapCtx->acceptMacList, pSapCtx->nAcceptMac);
691 vos_mem_copy(pSapCtx->denyMacList, pConfig->deny_mac, sizeof(pConfig->deny_mac));
692 pSapCtx->nDenyMac = pConfig->num_deny_mac;
693 sapSortMacList(pSapCtx->denyMacList, pSapCtx->nDenyMac);
694
695 /* Fill in the event structure for FSM */
696 sapEvent.event = eSAP_HDD_START_INFRA_BSS;
697 sapEvent.params = 0;//pSapPhysLinkCreate
698
699 /* Store the HDD callback in SAP context */
700 pSapCtx->pfnSapEventCallback = pSapEventCallback;
701
702 /* Handle event*/
703 vosStatus = sapFsm(pSapCtx, &sapEvent);
704 }
705 else
706 {
707 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
708 "SoftAp role has not been enabled");
709 }
710
711 return vosStatus;
712}// WLANSAP_StartBss
713
714/*==========================================================================
Gopichand Nakkalacb9f2192013-06-25 16:10:38 -0700715 FUNCTION WLANSAP_SetMacACL
716
717 DESCRIPTION
718 This api function provides SAP to set mac list entry in accept list as well
719 as deny list
720
721 DEPENDENCIES
722
723 PARAMETERS
724
725 IN
726 pContext : Pointer to Sap Context structure
727 pQctCommitConfig : Pointer to configuration structure passed down from
728 HDD(HostApd for Android)
729
730 RETURN VALUE
731 The result code associated with performing the operation
732
733 VOS_STATUS_E_FAULT: Pointer to SAP cb is NULL ; access would cause a page
734 fault
735 VOS_STATUS_SUCCESS: Success
736
737 SIDE EFFECTS
738============================================================================*/
739VOS_STATUS
740WLANSAP_SetMacACL
741(
742 v_PVOID_t pvosGCtx, //pwextCtx
743 tsap_Config_t *pConfig
744)
745{
746 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
747 ptSapContext pSapCtx = NULL;
748
749 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
750 "WLANSAP_SetMacACL");
751
752 if (VOS_STA_SAP_MODE == vos_get_conparam ())
753 {
754 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
755 if ( NULL == pSapCtx )
756 {
757 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
758 "%s: Invalid SAP pointer from pvosGCtx", __func__);
759 return VOS_STATUS_E_FAULT;
760 }
761
762 // Copy MAC filtering settings to sap context
763 pSapCtx->eSapMacAddrAclMode = pConfig->SapMacaddr_acl;
764
765 if (eSAP_DENY_UNLESS_ACCEPTED == pSapCtx->eSapMacAddrAclMode)
766 {
767 vos_mem_copy(pSapCtx->acceptMacList, pConfig->accept_mac,
768 sizeof(pConfig->accept_mac));
769 pSapCtx->nAcceptMac = pConfig->num_accept_mac;
770 sapSortMacList(pSapCtx->acceptMacList, pSapCtx->nAcceptMac);
771 }
772 else if (eSAP_ACCEPT_UNLESS_DENIED == pSapCtx->eSapMacAddrAclMode)
773 {
774 vos_mem_copy(pSapCtx->denyMacList, pConfig->deny_mac,
775 sizeof(pConfig->deny_mac));
776 pSapCtx->nDenyMac = pConfig->num_deny_mac;
777 sapSortMacList(pSapCtx->denyMacList, pSapCtx->nDenyMac);
778 }
779 }
780 else
781 {
782 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
783 "%s : SoftAp role has not been enabled", __func__);
784 return VOS_STATUS_E_FAULT;
785 }
786
787 return vosStatus;
788}//WLANSAP_SetMacACL
789
790/*==========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 FUNCTION WLANSAP_StopBss
792
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700793 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 This api function provides SAP FSM event eSAP_HDD_STOP_INFRA_BSS for
795 stopping AP BSS
796
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700797 DEPENDENCIES
Jeff Johnson295189b2012-06-20 16:38:30 -0700798
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700799 PARAMETERS
Jeff Johnson295189b2012-06-20 16:38:30 -0700800
801 IN
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700802 pvosGCtx : Pointer to the global vos context; a handle to SAP's
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 control block can be extracted from its contexe
804
805 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700806 The result code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -0700807
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700808 VOS_STATUS_E_FAULT: Pointer to VOSS GC is NULL ; access would cause a page
809 fault
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 VOS_STATUS_SUCCESS: Success
811
812 SIDE EFFECTS
813============================================================================*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700814VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -0700815WLANSAP_StopBss
816(
817 v_PVOID_t pvosGCtx
818)
819{
820 tWLAN_SAPEvent sapEvent; /* State machine event*/
821 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
822 ptSapContext pSapCtx = NULL;
823 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
824
825 /*------------------------------------------------------------------------
826 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700827 Extract SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 ------------------------------------------------------------------------*/
829 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,
830 "WLANSAP_StopBss");
831
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700832 if ( NULL == pvosGCtx )
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 {
834 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700835 "%s: Invalid Global VOSS handle", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 return VOS_STATUS_E_FAULT;
837 }
838
839 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
840
841 if (NULL == pSapCtx )
842 {
843 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700844 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 return VOS_STATUS_E_FAULT;
846 }
847
848 /* Fill in the event structure for FSM */
849 sapEvent.event = eSAP_HDD_STOP_INFRA_BSS;
850 sapEvent.params = 0;
851
852 /* Handle event*/
853 vosStatus = sapFsm(pSapCtx, &sapEvent);
854
855 return vosStatus;
856}
857
858/*==========================================================================
859 FUNCTION WLANSAP_GetAssocStations
860
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700861 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 This api function is used to probe the list of associated stations from various modules of CORE stack
863
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700864 DEPENDENCIES
865 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700866
867 PARAMETERS
868
869 IN
870 pvosGCtx : Pointer to vos global context structure
871 modId : Module from whom list of associtated stations is supposed to be probed. If an invalid module is passed
872 then by default VOS_MODULE_ID_PE will be probed
873 IN/OUT
874 pAssocStas : Pointer to list of associated stations that are known to the module specified in mod parameter
875
876 NOTE: The memory for this list will be allocated by the caller of this API
877
878 RETURN VALUE
879 The VOS_STATUS code associated with performing the operation
880
881 VOS_STATUS_SUCCESS: Success
882
883 SIDE EFFECTS
884============================================================================*/
885VOS_STATUS
886WLANSAP_GetAssocStations
887(
888 v_PVOID_t pvosGCtx,
889 VOS_MODULE_ID modId,
890 tpSap_AssocMacAddr pAssocStas
891)
892{
893 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
894
895 /*------------------------------------------------------------------------
896 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700897 Extract SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 ------------------------------------------------------------------------*/
899 if (NULL == pSapCtx)
900 {
901 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700902 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 return VOS_STATUS_E_FAULT;
904 }
905
906 sme_RoamGetAssociatedStas( VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId,
907 modId,
908 pSapCtx->pUsrContext,
909 (v_PVOID_t *)pSapCtx->pfnSapEventCallback,
910 (v_U8_t *)pAssocStas );
911
912 return VOS_STATUS_SUCCESS;
913}
914
915
916/*==========================================================================
917 FUNCTION WLANSAP_RemoveWpsSessionOverlap
918
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700919 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700920 This api function provides for Ap App/HDD to remove an entry from session session overlap info.
921
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700922 DEPENDENCIES
923 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700924
925 PARAMETERS
926
927 IN
928 pvosGCtx: Pointer to vos global context structure
929 pRemoveMac: pointer to v_MACADDR_t for session MAC address
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700930
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700932 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -0700933
934 VOS_STATUS_SUCCESS: Success
935 VOS_STATUS_E_FAULT: Session is not dectected. The parameter is function not valid.
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700936
937 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700938============================================================================*/
939VOS_STATUS
940WLANSAP_RemoveWpsSessionOverlap
941
942(
943 v_PVOID_t pvosGCtx,
944 v_MACADDR_t pRemoveMac
945)
946{
947 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
948
949 /*------------------------------------------------------------------------
950 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700951 Extract SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 ------------------------------------------------------------------------*/
953 if (NULL == pSapCtx)
954 {
955 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700956 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 return VOS_STATUS_E_FAULT;
958 }
959
960 sme_RoamGetWpsSessionOverlap( VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId,
961 pSapCtx->pUsrContext,
962 (v_PVOID_t *)pSapCtx->pfnSapEventCallback,
963 pRemoveMac);
964
965 return VOS_STATUS_SUCCESS;
966}
967
968/*==========================================================================
969 FUNCTION WLANSAP_getWpsSessionOverlap
970
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700971 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 This api function provides for Ap App/HDD to get WPS session overlap info.
973
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700974 DEPENDENCIES
975 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -0700976
977 PARAMETERS
978
979 IN
980 pvosGCtx: Pointer to vos global context structure
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700981
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700983 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -0700984
985 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700986
987 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -0700988============================================================================*/
989VOS_STATUS
990WLANSAP_getWpsSessionOverlap
991(
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700992 v_PVOID_t pvosGCtx
Jeff Johnson295189b2012-06-20 16:38:30 -0700993)
994{
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -0700995 v_MACADDR_t pRemoveMac = VOS_MAC_ADDR_ZERO_INITIALIZER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700996
997 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
998
999 /*------------------------------------------------------------------------
1000 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001001 Extract SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 ------------------------------------------------------------------------*/
1003 if (NULL == pSapCtx)
1004 {
1005 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001006 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 return VOS_STATUS_E_FAULT;
1008 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001009
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 sme_RoamGetWpsSessionOverlap( VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId,
1011 pSapCtx->pUsrContext,
1012 (v_PVOID_t *)pSapCtx->pfnSapEventCallback,
1013 pRemoveMac);
1014
1015 return VOS_STATUS_SUCCESS;
1016}
1017
1018
1019/* This routine will set the mode of operation for ACL dynamically*/
1020VOS_STATUS
1021WLANSAP_SetMode ( v_PVOID_t pvosGCtx, v_U32_t mode)
1022{
1023 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1024
1025 if (NULL == pSapCtx)
1026 {
1027 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001028 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 return VOS_STATUS_E_FAULT;
1030 }
1031
1032 pSapCtx->eSapMacAddrAclMode = (eSapMacAddrACL)mode;
1033 return VOS_STATUS_SUCCESS;
1034}
1035
1036/* This routine will clear all the entries in accept list as well as deny list */
1037
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001038VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -07001039WLANSAP_ClearACL( v_PVOID_t pvosGCtx)
1040{
1041 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1042 v_U8_t i;
1043
1044 if (NULL == pSapCtx)
1045 {
1046 return VOS_STATUS_E_RESOURCES;
1047 }
1048
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001049 if (pSapCtx->denyMacList != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 {
1051 for (i = 0; i < (pSapCtx->nDenyMac-1); i++)
1052 {
1053 vos_mem_zero((pSapCtx->denyMacList+i)->bytes, sizeof(v_MACADDR_t));
1054
1055 }
1056 }
1057 sapPrintACL(pSapCtx->denyMacList, pSapCtx->nDenyMac);
1058 pSapCtx->nDenyMac = 0;
1059
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001060 if (pSapCtx->acceptMacList!=NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 {
1062 for (i = 0; i < (pSapCtx->nAcceptMac-1); i++)
1063 {
1064 vos_mem_zero((pSapCtx->acceptMacList+i)->bytes, sizeof(v_MACADDR_t));
1065
1066 }
1067 }
1068 sapPrintACL(pSapCtx->acceptMacList, pSapCtx->nAcceptMac);
1069 pSapCtx->nAcceptMac = 0;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001070
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 return VOS_STATUS_SUCCESS;
1072}
1073
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001074VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -07001075WLANSAP_ModifyACL
1076(
1077 v_PVOID_t pvosGCtx,
1078 v_U8_t *pPeerStaMac,
1079 eSapACLType listType,
1080 eSapACLCmdType cmd
1081)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001082{
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 eSapBool staInWhiteList=eSAP_FALSE, staInBlackList=eSAP_FALSE;
1084 v_U8_t staWLIndex, staBLIndex;
1085 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1086
1087 if (NULL == pSapCtx)
1088 {
1089 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001090 "%s: Invalid SAP Context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 return VOS_STATUS_E_FAULT;
1092 }
1093
1094 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,"Modify ACL entered\n"
1095 "Before modification of ACL\n"
1096 "size of accept and deny lists %d %d",
1097 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
1098 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"*** WHITE LIST ***");
1099 sapPrintACL(pSapCtx->acceptMacList, pSapCtx->nAcceptMac);
1100 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"*** BLACK LIST ***");
1101 sapPrintACL(pSapCtx->denyMacList, pSapCtx->nDenyMac);
1102
1103 /* the expectation is a mac addr will not be in both the lists at the same time.
1104 It is the responsiblity of userspace to ensure this */
1105 staInWhiteList = sapSearchMacList(pSapCtx->acceptMacList, pSapCtx->nAcceptMac, pPeerStaMac, &staWLIndex);
1106 staInBlackList = sapSearchMacList(pSapCtx->denyMacList, pSapCtx->nDenyMac, pPeerStaMac, &staBLIndex);
1107
1108 if (staInWhiteList && staInBlackList)
1109 {
1110 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001111 "Peer mac "MAC_ADDRESS_STR" found in white and black lists."
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001112 "Initial lists passed incorrect. Cannot execute this command.",
Arif Hussain24bafea2013-11-15 15:10:03 -08001113 MAC_ADDR_ARRAY(pPeerStaMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 return VOS_STATUS_E_FAILURE;
1115
1116 }
1117
1118 switch(listType)
1119 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001120 case eSAP_WHITE_LIST:
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW, "cmd %d", cmd);
1122 if (cmd == ADD_STA_TO_ACL)
1123 {
1124 //error check
1125 // if list is already at max, return failure
Gopichand Nakkalacb9f2192013-06-25 16:10:38 -07001126 if (pSapCtx->nAcceptMac == MAX_ACL_MAC_ADDRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 {
1128 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001129 "White list is already maxed out. Cannot accept "MAC_ADDRESS_STR,
1130 MAC_ADDR_ARRAY(pPeerStaMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 return VOS_STATUS_E_FAILURE;
1132 }
1133 if (staInWhiteList)
1134 {
1135 //Do nothing if already present in white list. Just print a warning
1136 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08001137 "MAC address already present in white list "MAC_ADDRESS_STR,
1138 MAC_ADDR_ARRAY(pPeerStaMac));
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001139 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 {
1141 if (staInBlackList)
1142 {
1143 //remove it from black list before adding to the white list
1144 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
1145 "STA present in black list so first remove from it");
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001146 sapRemoveMacFromACL(pSapCtx->denyMacList, &pSapCtx->nDenyMac, staBLIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 }
1148 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001149 "... Now add to the white list");
Jeff Johnson295189b2012-06-20 16:38:30 -07001150 sapAddMacToACL(pSapCtx->acceptMacList, &pSapCtx->nAcceptMac, pPeerStaMac);
1151 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW, "size of accept and deny lists %d %d",
1152 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 }
1155 else if (cmd == DELETE_STA_FROM_ACL)
1156 {
1157 if (staInWhiteList)
1158 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001159 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, "Delete from white list");
1160 sapRemoveMacFromACL(pSapCtx->acceptMacList, &pSapCtx->nAcceptMac, staWLIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07001161 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW, "size of accept and deny lists %d %d",
1162 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
1163 }
1164 else
1165 {
1166 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08001167 "MAC address to be deleted is not present in the white list "MAC_ADDRESS_STR,
1168 MAC_ADDR_ARRAY(pPeerStaMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 return VOS_STATUS_E_FAILURE;
1170 }
1171 }
1172 else
1173 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001174 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "Invalid cmd type passed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 return VOS_STATUS_E_FAILURE;
1176 }
1177 break;
1178
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001179 case eSAP_BLACK_LIST:
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,
1181 "cmd %d", cmd);
1182 if (cmd == ADD_STA_TO_ACL)
1183 {
1184 //error check
1185 // if list is already at max, return failure
Gopichand Nakkalacb9f2192013-06-25 16:10:38 -07001186 if (pSapCtx->nDenyMac == MAX_ACL_MAC_ADDRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 {
1188 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08001189 "Black list is already maxed out. Cannot accept "MAC_ADDRESS_STR,
1190 MAC_ADDR_ARRAY(pPeerStaMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 return VOS_STATUS_E_FAILURE;
1192 }
1193 if (staInBlackList)
1194 {
1195 //Do nothing if already present in white list
1196 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08001197 "MAC address already present in black list "MAC_ADDRESS_STR,
1198 MAC_ADDR_ARRAY(pPeerStaMac));
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001199 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 {
Abhishek Singh2e45e7d2018-01-29 14:43:14 +05301201 struct tagCsrDelStaParams delStaParams;
1202
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 if (staInWhiteList)
1204 {
1205 //remove it from white list before adding to the white list
1206 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
1207 "Present in white list so first remove from it");
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001208 sapRemoveMacFromACL(pSapCtx->acceptMacList, &pSapCtx->nAcceptMac, staWLIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07001209 }
Abhishek Singh2e45e7d2018-01-29 14:43:14 +05301210 /*
1211 * If we are adding a client to the black list;
1212 * if its connected, send deauth
1213 */
1214 WLANSAP_PopulateDelStaParams(pPeerStaMac,
1215 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
1216 SIR_MAC_MGMT_DEAUTH >> 4,
1217 &delStaParams);
1218 WLANSAP_DeauthSta(pSapCtx->pvosGCtx, &delStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001220 "... Now add to black list");
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 sapAddMacToACL(pSapCtx->denyMacList, &pSapCtx->nDenyMac, pPeerStaMac);
1222 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,"size of accept and deny lists %d %d",
1223 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 }
1226 else if (cmd == DELETE_STA_FROM_ACL)
1227 {
1228 if (staInBlackList)
1229 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001230 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO, "Delete from black list");
1231 sapRemoveMacFromACL(pSapCtx->denyMacList, &pSapCtx->nDenyMac, staBLIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,"no accept and deny mac %d %d",
1233 pSapCtx->nAcceptMac, pSapCtx->nDenyMac);
1234 }
1235 else
1236 {
1237 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08001238 "MAC address to be deleted is not present in the black list "MAC_ADDRESS_STR,
1239 MAC_ADDR_ARRAY(pPeerStaMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 return VOS_STATUS_E_FAILURE;
1241 }
1242 }
1243 else
1244 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001245 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR, "Invalid cmd type passed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 return VOS_STATUS_E_FAILURE;
1247 }
1248 break;
1249
1250 default:
1251 {
1252 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1253 "Invalid list type passed %d",listType);
1254 return VOS_STATUS_E_FAILURE;
1255 }
1256 }
1257 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_LOW,"After modification of ACL");
1258 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"*** WHITE LIST ***");
1259 sapPrintACL(pSapCtx->acceptMacList, pSapCtx->nAcceptMac);
1260 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO_HIGH,"*** BLACK LIST ***");
1261 sapPrintACL(pSapCtx->denyMacList, pSapCtx->nDenyMac);
1262 return VOS_STATUS_SUCCESS;
1263}
1264
1265/*==========================================================================
1266 FUNCTION WLANSAP_DisassocSta
1267
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001268 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 This api function provides for Ap App/HDD initiated disassociation of station
1270
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001271 DEPENDENCIES
1272 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07001273
1274 PARAMETERS
1275
1276 IN
1277 pvosGCtx : Pointer to vos global context structure
1278 pPeerStaMac : Mac address of the station to disassociate
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001279
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001281 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07001282
1283 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001284
1285 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07001286============================================================================*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001287VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -07001288WLANSAP_DisassocSta
1289(
1290 v_PVOID_t pvosGCtx,
Anand N Sunkadc205d952015-07-30 15:36:03 +05301291#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
1292 const v_U8_t *pPeerStaMac
1293#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001294 v_U8_t *pPeerStaMac
Anand N Sunkadc205d952015-07-30 15:36:03 +05301295#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001296)
1297{
1298 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1299
1300 /*------------------------------------------------------------------------
1301 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001302 Extract SAP control block
1303 ------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 if (NULL == pSapCtx)
1305 {
1306 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001307 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 return VOS_STATUS_E_FAULT;
1309 }
1310
1311 sme_RoamDisconnectSta(VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId,
1312 pPeerStaMac);
1313
1314 return VOS_STATUS_SUCCESS;
1315}
1316
Jeff Johnson295189b2012-06-20 16:38:30 -07001317/*==========================================================================
1318 FUNCTION WLANSAP_DeauthSta
1319
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001320 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 This api function provides for Ap App/HDD initiated deauthentication of station
1322
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001323 DEPENDENCIES
1324 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07001325
1326 PARAMETERS
1327
1328 IN
1329 pvosGCtx : Pointer to vos global context structure
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +05301330 pDelStaParams : Pointer to parameters of the station to
1331 deauthenticate
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001332
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001334 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07001335
1336 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001337
1338 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07001339============================================================================*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001340VOS_STATUS
Jeff Johnson295189b2012-06-20 16:38:30 -07001341WLANSAP_DeauthSta
1342(
1343 v_PVOID_t pvosGCtx,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +05301344 struct tagCsrDelStaParams *pDelStaParams
Jeff Johnson295189b2012-06-20 16:38:30 -07001345)
1346{
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001347 eHalStatus halStatus = eHAL_STATUS_FAILURE;
1348 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1350
1351 /*------------------------------------------------------------------------
1352 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001353 Extract SAP control block
1354 ------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 if (NULL == pSapCtx)
1356 {
1357 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001358 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001359 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 }
1361
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +05301362 halStatus = sme_RoamDeauthSta(VOS_GET_HAL_CB(pSapCtx->pvosGCtx),
1363 pSapCtx->sessionId, pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001364
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08001365 if (halStatus == eHAL_STATUS_SUCCESS)
1366 {
1367 vosStatus = VOS_STATUS_SUCCESS;
1368 }
1369 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001370}
1371/*==========================================================================
1372 FUNCTION WLANSAP_SetChannelRange
1373
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001374 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 This api function sets the range of channels for AP.
1376
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001377 DEPENDENCIES
1378 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07001379
1380 PARAMETERS
1381
1382 IN
1383 startChannel : start channel
1384 endChannel : End channel
1385 operatingBand : Operating band (2.4GHz/5GHz)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001386
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001388 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07001389
1390 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001391
1392 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07001393============================================================================*/
1394VOS_STATUS
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001395WLANSAP_SetChannelRange(tHalHandle hHal,v_U8_t startChannel, v_U8_t endChannel,
Leela Venkata Kiran Kumar Reddy Chirala9f6566c2014-09-05 19:06:58 +05301396 eSapOperatingBand operatingBand)
Jeff Johnson295189b2012-06-20 16:38:30 -07001397{
1398
1399 v_U8_t validChannelFlag =0;
1400 v_U8_t loopStartCount =0;
1401 v_U8_t loopEndCount =0;
1402 v_U8_t bandStartChannel =0;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001403 v_U8_t bandEndChannel =0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001404
1405 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1406 "WLANSAP_SetChannelRange:startChannel %d,EndChannel %d,Operatingband:%d",
1407 startChannel,endChannel,operatingBand);
1408
1409 /*------------------------------------------------------------------------
1410 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001411 ------------------------------------------------------------------------*/
Jeff Johnsonbacdbcc2013-02-26 21:23:41 -08001412 if (( WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND_STAMIN > operatingBand) ||
1413 (WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND_STAMAX < operatingBand))
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 {
1415 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1416 "Invalid operatingBand on WLANSAP_SetChannelRange");
1417 return VOS_STATUS_E_FAULT;
1418 }
Jeff Johnsonbacdbcc2013-02-26 21:23:41 -08001419 if (( WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL_STAMIN > startChannel) ||
1420 (WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL_STAMAX < startChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 {
1422 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1423 "Invalid startChannel value on WLANSAP_SetChannelRange");
1424 return VOS_STATUS_E_FAULT;
1425 }
Jeff Johnsonbacdbcc2013-02-26 21:23:41 -08001426 if (( WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL_STAMIN > endChannel) ||
1427 (WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL_STAMAX < endChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 {
1429 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1430 "Invalid endChannel value on WLANSAP_SetChannelRange");
1431 return VOS_STATUS_E_FAULT;
1432 }
1433 switch(operatingBand)
1434 {
Deepthi Gowri7db41f32014-10-13 17:02:29 +05301435 case eSAP_RF_SUBBAND_2_4_GHZ:
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 bandStartChannel = RF_CHAN_1;
1437 bandEndChannel = RF_CHAN_14;
1438 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001439
Deepthi Gowri7db41f32014-10-13 17:02:29 +05301440 case eSAP_RF_SUBBAND_5_LOW_GHZ:
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 bandStartChannel = RF_CHAN_36;
1442 bandEndChannel = RF_CHAN_64;
1443 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001444
Deepthi Gowri7db41f32014-10-13 17:02:29 +05301445 case eSAP_RF_SUBBAND_5_MID_GHZ:
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 bandStartChannel = RF_CHAN_100;
Leo Chang80de3c22013-11-26 10:52:12 -08001447#ifndef FEATURE_WLAN_CH144
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 bandEndChannel = RF_CHAN_140;
Leo Chang80de3c22013-11-26 10:52:12 -08001449#else
1450 bandEndChannel = RF_CHAN_144;
1451#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001453
Deepthi Gowri7db41f32014-10-13 17:02:29 +05301454 case eSAP_RF_SUBBAND_5_HIGH_GHZ:
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 bandStartChannel = RF_CHAN_149;
1456 bandEndChannel = RF_CHAN_165;
1457 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001458
Deepthi Gowri7db41f32014-10-13 17:02:29 +05301459 case eSAP_RF_SUBBAND_5_ALL_GHZ:
1460 bandStartChannel = RF_CHAN_36;
1461 bandEndChannel = RF_CHAN_165;
1462 break;
1463
Jeff Johnson295189b2012-06-20 16:38:30 -07001464 default:
1465 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1466 "Invalid operatingBand value on WLANSAP_SetChannelRange");
1467 break;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001468 }
1469
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 /* Validating the start channel is in range or not*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001471 for(loopStartCount = bandStartChannel ; loopStartCount <= bandEndChannel ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 loopStartCount++)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001473 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 if(rfChannels[loopStartCount].channelNum == startChannel )
1475 {
1476 /* start channel is in the range */
1477 break;
1478 }
1479 }
1480 /* Validating the End channel is in range or not*/
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001481 for(loopEndCount = bandStartChannel ; loopEndCount <= bandEndChannel ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001482 loopEndCount++)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001483 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 if(rfChannels[loopEndCount].channelNum == endChannel )
1485 {
1486 /* End channel is in the range */
1487 break;
1488 }
1489 }
1490 if((loopStartCount > bandEndChannel)||(loopEndCount > bandEndChannel))
1491 {
1492 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1493 "%s: Invalid startChannel-%d or EndChannel-%d for band -%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001494 __func__,startChannel,endChannel,operatingBand);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001495 /* Supplied channels are nt in the operating band so set the default
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 channels for the given operating band */
1497 startChannel = rfChannels[bandStartChannel].channelNum;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07001498 endChannel = rfChannels[bandEndChannel].channelNum;
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001500
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 /*Search for the Active channels in the given range */
1502 for( loopStartCount = bandStartChannel; loopStartCount <= bandEndChannel; loopStartCount++ )
1503 {
1504 if((startChannel <= rfChannels[loopStartCount].channelNum)&&
1505 (endChannel >= rfChannels[loopStartCount].channelNum ))
1506 {
1507 if( regChannels[loopStartCount].enabled )
1508 {
1509 validChannelFlag = 1;
1510 break;
1511 }
1512 }
1513 }
1514 if(0 == validChannelFlag)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001515 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1517 "%s-No active channels present in the given range for the current region",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001518 __func__);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001519 /* There is no active channel in the supplied range.Updating the config
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 with the default channels in the given band so that we can select the best channel in the sub-band*/
1521 startChannel = rfChannels[bandStartChannel].channelNum;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07001522 endChannel = rfChannels[bandEndChannel].channelNum;
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001524
1525 if (ccmCfgSetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND,
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 operatingBand, NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1527 {
1528 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1529 "Could not pass on WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND to CCn");
1530 return VOS_STATUS_E_FAULT;
1531 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001532 if (ccmCfgSetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL,
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 startChannel, NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1534 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001535
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1537 "Could not pass on WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL to CCM");
1538 return VOS_STATUS_E_FAULT;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001539
1540 }
1541 if (ccmCfgSetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_END_CHANNEL,
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 endChannel, NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1543 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001544
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1546 "Could not pass on WNI_CFG_SAP_CHANNEL_SELECT_START_CHANNEL to CCM");
1547 return VOS_STATUS_E_FAULT;
1548 }
1549 return VOS_STATUS_SUCCESS;
1550}
Jeff Johnson295189b2012-06-20 16:38:30 -07001551
1552/*==========================================================================
1553 FUNCTION WLANSAP_SetCounterMeasure
1554
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001555 DESCRIPTION
1556 This api function is used to disassociate all the stations and prevent
1557 association for any other station.Whenever Authenticator receives 2 mic failures
1558 within 60 seconds, Authenticator will enable counter measure at SAP Layer.
1559 Authenticator will start the 60 seconds timer. Core stack will not allow any
1560 STA to associate till HDD disables counter meassure. Core stack shall kick out all the
1561 STA which are currently associated and DIASSOC Event will be propogated to HDD for
1562 each STA to clean up the HDD STA table.Once the 60 seconds timer expires, Authenticator
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 will disable the counter meassure at core stack. Now core stack can allow STAs to associate.
1564
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001565 DEPENDENCIES
1566 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07001567
1568 PARAMETERS
1569
1570 IN
1571pvosGCtx: Pointer to vos global context structure
1572bEnable: If TRUE than all stations will be disassociated and no more will be allowed to associate. If FALSE than CORE
1573will come out of this state.
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001574
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001576 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07001577
1578 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001579
1580 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07001581============================================================================*/
1582VOS_STATUS
1583WLANSAP_SetCounterMeasure
1584(
1585 v_PVOID_t pvosGCtx,
1586 v_BOOL_t bEnable
1587)
1588{
1589 ptSapContext pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1590
1591 /*------------------------------------------------------------------------
1592 Sanity check
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001593 Extract SAP control block
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 ------------------------------------------------------------------------*/
1595 if (NULL == pSapCtx)
1596 {
1597 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001598 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 return VOS_STATUS_E_FAULT;
1600 }
1601
1602 sme_RoamTKIPCounterMeasures(VOS_GET_HAL_CB(pSapCtx->pvosGCtx), pSapCtx->sessionId, bEnable);
1603
1604 return VOS_STATUS_SUCCESS;
1605}
1606
1607/*==========================================================================
1608
1609 FUNCTION WLANSAP_SetKeysSta
1610
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001611 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 This api function provides for Ap App/HDD to set key for a station.
1613
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001614 DEPENDENCIES
1615 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07001616
1617 PARAMETERS
1618
1619 IN
1620pvosGCtx: Pointer to vos global context structure
1621pSetKeyInfo: tCsrRoamSetKey structure for the station
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001622
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001624 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07001625
1626 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001627
1628 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07001629============================================================================*/
1630VOS_STATUS
1631WLANSAP_SetKeySta
1632(
1633 v_PVOID_t pvosGCtx, tCsrRoamSetKey *pSetKeyInfo
1634)
1635{
1636 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1637 ptSapContext pSapCtx = NULL;
1638 v_PVOID_t hHal = NULL;
1639 eHalStatus halStatus = eHAL_STATUS_FAILURE;
1640 v_U32_t roamId=0xFF;
1641
1642 if (VOS_STA_SAP_MODE == vos_get_conparam ( ))
1643 {
1644 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1645 if (NULL == pSapCtx)
1646 {
1647 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001648 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 return VOS_STATUS_E_FAULT;
1650 }
1651 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1652 if (NULL == hHal)
1653 {
1654 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001655 "%s: Invalid HAL pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 return VOS_STATUS_E_FAULT;
1657 }
1658 halStatus = sme_RoamSetKey(hHal, pSapCtx->sessionId, pSetKeyInfo, &roamId);
1659
1660 if (halStatus == eHAL_STATUS_SUCCESS)
1661 {
1662 vosStatus = VOS_STATUS_SUCCESS;
1663 } else
1664 {
1665 vosStatus = VOS_STATUS_E_FAULT;
1666 }
1667 }
1668 else
1669 vosStatus = VOS_STATUS_E_FAULT;
1670
1671 return vosStatus;
1672}
1673
1674/*==========================================================================
1675 FUNCTION WLANSAP_DelKeySta
1676
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001677 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 This api function provides for Ap App/HDD to delete key for a station.
1679
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001680 DEPENDENCIES
1681 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07001682
1683 PARAMETERS
1684
1685 IN
1686pvosGCtx: Pointer to vos global context structure
1687pSetKeyInfo: tCsrRoamRemoveKey structure for the station
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001688
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001690 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07001691
1692 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001693
1694 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07001695============================================================================*/
1696VOS_STATUS
1697WLANSAP_DelKeySta
1698(
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001699 v_PVOID_t pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 tCsrRoamRemoveKey *pRemoveKeyInfo
1701)
1702{
1703 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1704 ptSapContext pSapCtx = NULL;
1705 v_PVOID_t hHal = NULL;
1706 eHalStatus halStatus = eHAL_STATUS_FAILURE;
1707 v_U32_t roamId=0xFF;
1708 tCsrRoamRemoveKey RemoveKeyInfo;
1709
1710 if (VOS_STA_SAP_MODE == vos_get_conparam ( ))
1711 {
1712 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1713 if (NULL == pSapCtx)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001714 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001716 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 return VOS_STATUS_E_FAULT;
1718 }
1719
1720 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1721 if (NULL == hHal)
1722 {
1723 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001724 "%s: Invalid HAL pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 return VOS_STATUS_E_FAULT;
1726 }
1727
1728 vos_mem_zero(&RemoveKeyInfo, sizeof(RemoveKeyInfo));
1729 RemoveKeyInfo.encType = pRemoveKeyInfo->encType;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001730 vos_mem_copy(RemoveKeyInfo.peerMac, pRemoveKeyInfo->peerMac, WNI_CFG_BSSID_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 RemoveKeyInfo.keyId = pRemoveKeyInfo->keyId;
1732
1733 halStatus = sme_RoamRemoveKey(hHal, pSapCtx->sessionId, &RemoveKeyInfo, &roamId);
1734
1735 if (HAL_STATUS_SUCCESS(halStatus))
1736 {
1737 vosStatus = VOS_STATUS_SUCCESS;
1738 }
1739 else
1740 {
1741 vosStatus = VOS_STATUS_E_FAULT;
1742 }
1743 }
1744 else
1745 vosStatus = VOS_STATUS_E_FAULT;
1746
1747 return vosStatus;
1748}
1749
1750VOS_STATUS
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001751WLANSap_getstationIE_information(v_PVOID_t pvosGCtx,
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 v_U32_t *pLen,
1753 v_U8_t *pBuf)
1754{
1755 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1756 ptSapContext pSapCtx = NULL;
1757 v_U32_t len = 0;
1758
1759 if (VOS_STA_SAP_MODE == vos_get_conparam ( )){
1760 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1761 if (NULL == pSapCtx)
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001762 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001764 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 return VOS_STATUS_E_FAULT;
1766 }
1767 if (pLen)
1768 {
1769 len = *pLen;
1770 *pLen = pSapCtx->nStaWPARSnReqIeLength;
1771 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001772 "%s: WPAIE len : %x", __func__, *pLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 if(pBuf)
1774 {
1775 if(len >= pSapCtx->nStaWPARSnReqIeLength)
1776 {
1777 vos_mem_copy( pBuf, pSapCtx->pStaWpaRsnReqIE, pSapCtx->nStaWPARSnReqIeLength);
1778 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
1779 "%s: WPAIE: %02x:%02x:%02x:%02x:%02x:%02x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001780 __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 pBuf[0], pBuf[1], pBuf[2],
1782 pBuf[3], pBuf[4], pBuf[5]);
1783 vosStatus = VOS_STATUS_SUCCESS;
1784 }
1785 }
1786 }
1787 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001788
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 if( VOS_STATUS_E_FAILURE == vosStatus)
1790 {
1791 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
1792 "%s: Error unable to populate the RSNWPAIE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001793 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 }
1795
1796 return vosStatus;
1797
1798}
1799
1800/*==========================================================================
1801 FUNCTION WLANSAP_Set_WpsIe
1802
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001803 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 This api function provides for Ap App/HDD to set WPS IE.
1805
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001806 DEPENDENCIES
1807 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07001808
1809 PARAMETERS
1810
1811 IN
1812pvosGCtx: Pointer to vos global context structure
1813pWPSIE: tSap_WPSIE structure that include WPS IEs
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001814
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001816 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07001817
1818 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001819
1820 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07001821============================================================================*/
1822VOS_STATUS
1823WLANSAP_Set_WpsIe
1824(
1825 v_PVOID_t pvosGCtx, tSap_WPSIE *pSap_WPSIe
1826)
1827{
1828 ptSapContext pSapCtx = NULL;
1829 v_PVOID_t hHal = NULL;
1830
1831 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001832 "%s, %d", __func__, __LINE__);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001833
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 if(VOS_STA_SAP_MODE == vos_get_conparam ( )) {
1835 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1836 if ( NULL == pSapCtx )
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001837 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001839 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 return VOS_STATUS_E_FAULT;
1841 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001842
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1844 if ( NULL == hHal ){
1845 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001846 "%s: Invalid HAL pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 return VOS_STATUS_E_FAULT;
1848 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001849
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 if ( sap_AcquireGlobalLock( pSapCtx ) == VOS_STATUS_SUCCESS )
1851 {
1852 if (pSap_WPSIe->sapWPSIECode == eSAP_WPS_BEACON_IE)
1853 {
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001854 vos_mem_copy(&pSapCtx->APWPSIEs.SirWPSBeaconIE, &pSap_WPSIe->sapwpsie.sapWPSBeaconIE, sizeof(tSap_WPSBeaconIE));
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001856 else if (pSap_WPSIe->sapWPSIECode == eSAP_WPS_PROBE_RSP_IE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 {
1858 vos_mem_copy(&pSapCtx->APWPSIEs.SirWPSProbeRspIE, &pSap_WPSIe->sapwpsie.sapWPSProbeRspIE, sizeof(tSap_WPSProbeRspIE));
1859 }
1860 else
1861 {
1862 sap_ReleaseGlobalLock( pSapCtx );
1863 return VOS_STATUS_E_FAULT;
1864 }
1865 sap_ReleaseGlobalLock( pSapCtx );
1866 return VOS_STATUS_SUCCESS;
1867 }
1868 else
1869 return VOS_STATUS_E_FAULT;
1870 }
1871 else
1872 return VOS_STATUS_E_FAULT;
1873}
1874
1875/*==========================================================================
1876 FUNCTION WLANSAP_Update_WpsIe
1877
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001878 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 This api function provides for Ap App/HDD to update WPS IEs.
1880
1881 DEPENDENCIES
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001882 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07001883
1884 PARAMETERS
1885
1886 IN
1887pvosGCtx: Pointer to vos global context structure
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001888
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001890 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07001891
1892 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001893
1894 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07001895============================================================================*/
1896VOS_STATUS
1897WLANSAP_Update_WpsIe
1898(
1899 v_PVOID_t pvosGCtx
1900)
1901{
1902 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
1903 ptSapContext pSapCtx = NULL;
1904 eHalStatus halStatus = eHAL_STATUS_FAILURE;
1905 v_PVOID_t hHal = NULL;
1906
1907 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001908 "%s, %d", __func__, __LINE__);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001909
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
1911 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1912 if ( NULL == pSapCtx )
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001913 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001915 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 return VOS_STATUS_E_FAULT;
1917 }
1918
1919 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1920 if ( NULL == hHal ){
1921 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001922 "%s: Invalid HAL pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 return VOS_STATUS_E_FAULT;
1924 }
1925
1926 halStatus = sme_RoamUpdateAPWPSIE( hHal, pSapCtx->sessionId, &pSapCtx->APWPSIEs);
1927
1928 if(halStatus == eHAL_STATUS_SUCCESS) {
1929 vosStatus = VOS_STATUS_SUCCESS;
1930 } else
1931 {
1932 vosStatus = VOS_STATUS_E_FAULT;
1933 }
1934
1935 }
1936
1937 return vosStatus;
1938}
1939
1940/*==========================================================================
1941 FUNCTION WLANSAP_Get_WPS_State
1942
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001943 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 This api function provides for Ap App/HDD to check if WPS session in process.
1945
1946 DEPENDENCIES
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001947 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07001948
1949 PARAMETERS
1950
1951 IN
1952pvosGCtx: Pointer to vos global context structure
1953
1954 OUT
1955pbWPSState: Pointer to variable to indicate if it is in WPS Registration state
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001956
Jeff Johnson295189b2012-06-20 16:38:30 -07001957 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001958 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07001959
1960 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001961
1962 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07001963============================================================================*/
1964VOS_STATUS
1965WLANSAP_Get_WPS_State
1966(
1967 v_PVOID_t pvosGCtx, v_BOOL_t *bWPSState
1968)
1969{
1970 ptSapContext pSapCtx = NULL;
1971 v_PVOID_t hHal = NULL;
1972
1973 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001974 "%s, %d", __func__, __LINE__);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001975
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001977
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
1979 if ( NULL == pSapCtx )
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001980 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001982 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 return VOS_STATUS_E_FAULT;
1984 }
1985
1986 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
1987 if ( NULL == hHal ){
1988 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001989 "%s: Invalid HAL pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 return VOS_STATUS_E_FAULT;
1991 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001992
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 if ( sap_AcquireGlobalLock(pSapCtx ) == VOS_STATUS_SUCCESS )
1994 {
1995 if(pSapCtx->APWPSIEs.SirWPSProbeRspIE.FieldPresent & SIR_WPS_PROBRSP_SELECTEDREGISTRA_PRESENT)
1996 *bWPSState = eANI_BOOLEAN_TRUE;
1997 else
1998 *bWPSState = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07001999
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 sap_ReleaseGlobalLock( pSapCtx );
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002001
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 return VOS_STATUS_SUCCESS;
2003 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002004 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 return VOS_STATUS_E_FAULT;
2006 }
2007 else
2008 return VOS_STATUS_E_FAULT;
2009
2010}
2011
2012VOS_STATUS
2013sap_AcquireGlobalLock
2014(
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002015 ptSapContext pSapCtx
Jeff Johnson295189b2012-06-20 16:38:30 -07002016)
2017{
2018 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
2019
2020 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &pSapCtx->SapGlobalLock) ) )
2021 {
2022 vosStatus = VOS_STATUS_SUCCESS;
2023 }
2024
2025 return (vosStatus);
2026}
2027
2028VOS_STATUS
2029sap_ReleaseGlobalLock
2030(
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002031 ptSapContext pSapCtx
Jeff Johnson295189b2012-06-20 16:38:30 -07002032)
2033{
2034 VOS_STATUS vosStatus = VOS_STATUS_E_FAULT;
2035
2036 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &pSapCtx->SapGlobalLock) ) )
2037 {
2038 vosStatus = VOS_STATUS_SUCCESS;
2039 }
2040
2041 return (vosStatus);
2042}
2043
2044/*==========================================================================
2045 FUNCTION WLANSAP_Set_WPARSNIes
2046
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002047 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 This api function provides for Ap App/HDD to set AP WPA and RSN IE in its beacon and probe response.
2049
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002050 DEPENDENCIES
2051 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07002052
2053 PARAMETERS
2054
2055 IN
2056 pvosGCtx: Pointer to vos global context structure
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002057 pWPARSNIEs: buffer to the WPA/RSN IEs
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 WPARSNIEsLen: length of WPA/RSN IEs
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002059
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002061 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07002062
2063 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002064
2065 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07002066============================================================================*/
2067VOS_STATUS WLANSAP_Set_WPARSNIes(v_PVOID_t pvosGCtx, v_U8_t *pWPARSNIEs, v_U32_t WPARSNIEsLen)
2068{
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002069
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 ptSapContext pSapCtx = NULL;
2071 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2072 v_PVOID_t hHal = NULL;
2073
2074 if(VOS_STA_SAP_MODE == vos_get_conparam ( )){
2075 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
2076 if ( NULL == pSapCtx )
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002077 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002079 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 return VOS_STATUS_E_FAULT;
2081 }
2082
2083 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2084 if ( NULL == hHal ){
2085 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002086 "%s: Invalid HAL pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 return VOS_STATUS_E_FAULT;
2088 }
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002089
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 pSapCtx->APWPARSNIEs.length = (tANI_U16)WPARSNIEsLen;
2091 vos_mem_copy(pSapCtx->APWPARSNIEs.rsnIEdata, pWPARSNIEs, WPARSNIEsLen);
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002092
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 halStatus = sme_RoamUpdateAPWPARSNIEs( hHal, pSapCtx->sessionId, &pSapCtx->APWPARSNIEs);
2094
2095 if(halStatus == eHAL_STATUS_SUCCESS) {
2096 return VOS_STATUS_SUCCESS;
2097 } else
2098 {
2099 return VOS_STATUS_E_FAULT;
2100 }
2101 }
2102
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002103 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002104}
2105
2106VOS_STATUS WLANSAP_GetStatistics(v_PVOID_t pvosGCtx, tSap_SoftapStats *statBuf, v_BOOL_t bReset)
2107{
2108 if (NULL == pvosGCtx)
2109 {
2110 return VOS_STATUS_E_FAULT;
2111 }
2112
2113 return (WLANTL_GetSoftAPStatistics(pvosGCtx, statBuf, bReset));
2114}
2115
Jeff Johnson295189b2012-06-20 16:38:30 -07002116/*==========================================================================
2117
2118 FUNCTION WLANSAP_SendAction
2119
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002120 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 This api function provides to send action frame sent by upper layer.
2122
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002123 DEPENDENCIES
2124 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07002125
2126 PARAMETERS
2127
2128 IN
2129 pvosGCtx: Pointer to vos global context structure
2130 pBuf: Pointer of the action frame to be transmitted
2131 len: Length of the action frame
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002132
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002134 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07002135
2136 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002137
2138 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07002139============================================================================*/
2140VOS_STATUS WLANSAP_SendAction( v_PVOID_t pvosGCtx, const tANI_U8 *pBuf,
Jeff Johnsone7245742012-09-05 17:12:55 -07002141 tANI_U32 len, tANI_U16 wait )
Jeff Johnson295189b2012-06-20 16:38:30 -07002142{
2143 ptSapContext pSapCtx = NULL;
2144 v_PVOID_t hHal = NULL;
2145 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2146
2147 if( VOS_STA_SAP_MODE == vos_get_conparam ( ) )
2148 {
2149 pSapCtx = VOS_GET_SAP_CB( pvosGCtx );
2150 if (NULL == pSapCtx)
2151 {
2152 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002153 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 return VOS_STATUS_E_FAULT;
2155 }
2156 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2157 if( ( NULL == hHal ) || ( eSAP_TRUE != pSapCtx->isSapSessionOpen ) )
2158 {
2159 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson797280e2017-09-19 08:36:01 -07002160 "%s: HAL pointer (%pK) NULL OR SME session is not open (%d)",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002161 __func__, hHal, pSapCtx->isSapSessionOpen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 return VOS_STATUS_E_FAULT;
2163 }
2164
Jeff Johnsone7245742012-09-05 17:12:55 -07002165 halStatus = sme_sendAction( hHal, pSapCtx->sessionId, pBuf, len, 0 , 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002166
2167 if ( eHAL_STATUS_SUCCESS == halStatus )
2168 {
2169 return VOS_STATUS_SUCCESS;
2170 }
2171 }
2172
2173 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2174 "Failed to Send Action Frame");
2175
2176 return VOS_STATUS_E_FAULT;
2177}
2178
2179/*==========================================================================
2180
2181 FUNCTION WLANSAP_RemainOnChannel
2182
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002183 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 This api function provides to set Remain On channel on specified channel
2185 for specified duration.
2186
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002187 DEPENDENCIES
2188 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07002189
2190 PARAMETERS
2191
2192 IN
2193 pvosGCtx: Pointer to vos global context structure
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002194 channel: Channel on which driver has to listen
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 duration: Duration for which driver has to listen on specified channel
2196 callback: Callback function to be called once Listen is done.
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002197 pContext: Context needs to be called in callback function.
2198
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002200 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07002201
2202 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002203
2204 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07002205============================================================================*/
2206VOS_STATUS WLANSAP_RemainOnChannel( v_PVOID_t pvosGCtx,
2207 tANI_U8 channel, tANI_U32 duration,
2208 remainOnChanCallback callback,
2209 void *pContext )
2210{
2211 ptSapContext pSapCtx = NULL;
2212 v_PVOID_t hHal = NULL;
2213 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2214
2215 if( VOS_STA_SAP_MODE == vos_get_conparam ( ) )
2216 {
2217 pSapCtx = VOS_GET_SAP_CB( pvosGCtx );
2218 if (NULL == pSapCtx)
2219 {
2220 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002221 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 return VOS_STATUS_E_FAULT;
2223 }
2224 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2225 if( ( NULL == hHal ) || ( eSAP_TRUE != pSapCtx->isSapSessionOpen ) )
2226 {
2227 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson797280e2017-09-19 08:36:01 -07002228 "%s: HAL pointer (%pK) NULL OR SME session is not open (%d)",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002229 __func__, hHal, pSapCtx->isSapSessionOpen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 return VOS_STATUS_E_FAULT;
2231 }
2232
2233 halStatus = sme_RemainOnChannel( hHal, pSapCtx->sessionId,
Gopichand Nakkala924e4552013-05-08 19:18:14 +05302234 channel, duration, callback, pContext, TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002235
2236 if( eHAL_STATUS_SUCCESS == halStatus )
2237 {
2238 return VOS_STATUS_SUCCESS;
2239 }
2240 }
2241
2242 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2243 "Failed to Set Remain on Channel");
2244
2245 return VOS_STATUS_E_FAULT;
2246}
2247
2248/*==========================================================================
2249
2250 FUNCTION WLANSAP_CancelRemainOnChannel
2251
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002252 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 This api cancel previous remain on channel request.
2254
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002255 DEPENDENCIES
2256 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07002257
2258 PARAMETERS
2259
2260 IN
2261 pvosGCtx: Pointer to vos global context structure
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002262
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002264 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07002265
2266 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002267
2268 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07002269============================================================================*/
2270VOS_STATUS WLANSAP_CancelRemainOnChannel( v_PVOID_t pvosGCtx )
2271{
2272 ptSapContext pSapCtx = NULL;
2273 v_PVOID_t hHal = NULL;
2274 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2275
Agrawal Ashish9d126602016-09-29 14:22:16 +05302276 pSapCtx = VOS_GET_SAP_CB(pvosGCtx);
2277 if (NULL == pSapCtx)
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 {
Agrawal Ashish9d126602016-09-29 14:22:16 +05302279 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2280 "%s: Invalid SAP pointer from pvosGCtx", __func__);
2281 return VOS_STATUS_E_FAULT;
2282 }
2283 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2284 if ((NULL == hHal) || (eSAP_TRUE != pSapCtx->isSapSessionOpen))
2285 {
2286 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson797280e2017-09-19 08:36:01 -07002287 "%s: HAL pointer (%pK) NULL OR SME session is not open (%d)",
Agrawal Ashish9d126602016-09-29 14:22:16 +05302288 __func__, hHal, pSapCtx->isSapSessionOpen );
2289 return VOS_STATUS_E_FAULT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 }
2291
Agrawal Ashish9d126602016-09-29 14:22:16 +05302292 halStatus = sme_CancelRemainOnChannel(hHal, pSapCtx->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002293
Agrawal Ashish9d126602016-09-29 14:22:16 +05302294 if (eHAL_STATUS_SUCCESS != halStatus)
2295 {
2296 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2297 "Failed to Cancel Remain on Channel");
2298 return VOS_STATUS_E_FAULT;
2299 }
2300 return VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002301}
2302
2303/*==========================================================================
2304
2305 FUNCTION WLANSAP_RegisterMgmtFrame
2306
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002307 DESCRIPTION
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 HDD use this API to register specified type of frame with CORE stack.
2309 On receiving such kind of frame CORE stack should pass this frame to HDD
2310
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002311 DEPENDENCIES
2312 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07002313
2314 PARAMETERS
2315
2316 IN
2317 pvosGCtx: Pointer to vos global context structure
2318 frameType: frameType that needs to be registered with PE.
2319 matchData: Data pointer which should be matched after frame type is matched.
2320 matchLen: Length of the matchData
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002321
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002323 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07002324
2325 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002326
2327 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07002328============================================================================*/
2329VOS_STATUS WLANSAP_RegisterMgmtFrame( v_PVOID_t pvosGCtx, tANI_U16 frameType,
2330 tANI_U8* matchData, tANI_U16 matchLen )
2331{
2332 ptSapContext pSapCtx = NULL;
2333 v_PVOID_t hHal = NULL;
2334 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2335
2336 if( VOS_STA_SAP_MODE == vos_get_conparam ( ) )
2337 {
2338 pSapCtx = VOS_GET_SAP_CB( pvosGCtx );
2339 if (NULL == pSapCtx)
2340 {
2341 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002342 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 return VOS_STATUS_E_FAULT;
2344 }
2345 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2346 if( ( NULL == hHal ) || ( eSAP_TRUE != pSapCtx->isSapSessionOpen ) )
2347 {
2348 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson797280e2017-09-19 08:36:01 -07002349 "%s: HAL pointer (%pK) NULL OR SME session is not open (%d)",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002350 __func__, hHal, pSapCtx->isSapSessionOpen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 return VOS_STATUS_E_FAULT;
2352 }
2353
2354 halStatus = sme_RegisterMgmtFrame(hHal, pSapCtx->sessionId,
2355 frameType, matchData, matchLen);
2356
2357 if( eHAL_STATUS_SUCCESS == halStatus )
2358 {
2359 return VOS_STATUS_SUCCESS;
2360 }
2361 }
2362
2363 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2364 "Failed to Register MGMT frame");
2365
2366 return VOS_STATUS_E_FAULT;
2367}
2368
2369/*==========================================================================
2370
2371 FUNCTION WLANSAP_DeRegisterMgmtFrame
2372
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002373 DESCRIPTION
2374 This API is used to deregister previously registered frame.
Jeff Johnson295189b2012-06-20 16:38:30 -07002375
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002376 DEPENDENCIES
2377 NA.
Jeff Johnson295189b2012-06-20 16:38:30 -07002378
2379 PARAMETERS
2380
2381 IN
2382 pvosGCtx: Pointer to vos global context structure
2383 frameType: frameType that needs to be De-registered with PE.
2384 matchData: Data pointer which should be matched after frame type is matched.
2385 matchLen: Length of the matchData
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002386
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 RETURN VALUE
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002388 The VOS_STATUS code associated with performing the operation
Jeff Johnson295189b2012-06-20 16:38:30 -07002389
2390 VOS_STATUS_SUCCESS: Success
Madan Mohan Koyyalamudi33a178c2012-09-18 18:17:13 -07002391
2392 SIDE EFFECTS
Jeff Johnson295189b2012-06-20 16:38:30 -07002393============================================================================*/
2394VOS_STATUS WLANSAP_DeRegisterMgmtFrame( v_PVOID_t pvosGCtx, tANI_U16 frameType,
2395 tANI_U8* matchData, tANI_U16 matchLen )
2396{
2397 ptSapContext pSapCtx = NULL;
2398 v_PVOID_t hHal = NULL;
2399 eHalStatus halStatus = eHAL_STATUS_FAILURE;
2400
2401 if( VOS_STA_SAP_MODE == vos_get_conparam ( ) )
2402 {
2403 pSapCtx = VOS_GET_SAP_CB( pvosGCtx );
2404 if (NULL == pSapCtx)
2405 {
2406 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002407 "%s: Invalid SAP pointer from pvosGCtx", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 return VOS_STATUS_E_FAULT;
2409 }
2410 hHal = VOS_GET_HAL_CB(pSapCtx->pvosGCtx);
2411 if( ( NULL == hHal ) || ( eSAP_TRUE != pSapCtx->isSapSessionOpen ) )
2412 {
2413 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson797280e2017-09-19 08:36:01 -07002414 "%s: HAL pointer (%pK) NULL OR SME session is not open (%d)",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002415 __func__, hHal, pSapCtx->isSapSessionOpen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 return VOS_STATUS_E_FAULT;
2417 }
2418
2419 halStatus = sme_DeregisterMgmtFrame( hHal, pSapCtx->sessionId,
2420 frameType, matchData, matchLen );
2421
2422 if( eHAL_STATUS_SUCCESS == halStatus )
2423 {
2424 return VOS_STATUS_SUCCESS;
2425 }
2426 }
2427
2428 VOS_TRACE( VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ERROR,
2429 "Failed to Deregister MGMT frame");
2430
2431 return VOS_STATUS_E_FAULT;
2432}
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +05302433
2434/*==========================================================================
2435 FUNCTION WLANSAP_PopulateDelStaParams
2436
2437 DESCRIPTION
2438 This API is used to populate del station parameters
2439 DEPENDENCIES
2440 NA.
2441
2442 PARAMETERS
2443 IN
2444 mac: pointer to peer mac address.
2445 reason_code: Reason code for the disassoc/deauth.
2446 subtype: subtype points to either disassoc/deauth frame.
2447 pDelStaParams: address where parameters to be populated.
2448
2449 RETURN VALUE NONE
2450
2451 SIDE EFFECTS
2452============================================================================*/
2453void WLANSAP_PopulateDelStaParams(const v_U8_t *mac,
2454 v_U16_t reason_code,
2455 v_U8_t subtype,
2456 struct tagCsrDelStaParams *pDelStaParams)
2457{
2458 if (NULL == mac)
2459 memset(pDelStaParams->peerMacAddr, 0xff, VOS_MAC_ADDR_SIZE);
2460 else
2461 vos_mem_copy(pDelStaParams->peerMacAddr, mac, VOS_MAC_ADDR_SIZE);
2462
2463 if (reason_code == 0)
Sushant Kaushik4cd28f62014-12-26 14:23:50 +05302464 pDelStaParams->reason_code = eSIR_MAC_DEAUTH_LEAVING_BSS_REASON;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +05302465 else
2466 pDelStaParams->reason_code = reason_code;
2467
2468 if (subtype == (SIR_MAC_MGMT_DEAUTH >> 4) ||
2469 subtype == (SIR_MAC_MGMT_DISASSOC >> 4))
2470 pDelStaParams->subtype = subtype;
2471 else
2472 pDelStaParams->subtype = (SIR_MAC_MGMT_DEAUTH >> 4);
2473
2474 VOS_TRACE(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_INFO,
2475 FL("Delete STA with RC:%hu subtype:%hhu MAC::" MAC_ADDRESS_STR),
2476 pDelStaParams->reason_code, pDelStaParams->subtype,
2477 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
2478}
Abhishek Singh02605092017-10-25 14:06:12 +05302479
2480/**
2481 * wlansap_validate_phy_mode() -
2482 * validate if the phymode allow the channel to set.
2483 *
2484 * @phy_mode: current phymode
2485 * @channel: target channel number.
2486 *
2487 * Return: true if channel is allowed else false
2488 */
2489static bool wlansap_validate_phy_mode(uint32_t phy_mode, uint32_t channel)
2490{
2491 switch (phy_mode) {
2492 case eSAP_DOT11_MODE_11a:
2493 if (channel <= SIR_11B_CHANNEL_END)
2494 return false;
2495 case eSAP_DOT11_MODE_11b:
2496 case eSAP_DOT11_MODE_11g:
2497 case eSAP_DOT11_MODE_11g_ONLY:
2498 case eSAP_DOT11_MODE_11b_ONLY:
2499 if (channel > SIR_11B_CHANNEL_END)
2500 return false;
2501 default:
2502 return true;
2503 }
2504
2505 return true;
2506}
2507
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302508int wlansap_chk_n_set_chan_change_in_progress(ptSapContext sap_ctx)
2509{
2510 vos_spin_lock_acquire(&sap_ctx->ecsa_info.ecsa_lock);
2511 if (sap_ctx->ecsa_info.channel_switch_in_progress) {
2512 vos_spin_lock_release(&sap_ctx->ecsa_info.ecsa_lock);
2513 hddLog(LOGE, FL("channel switch already in progress"));
2514 return -EALREADY;
2515 }
2516 sap_ctx->ecsa_info.channel_switch_in_progress = true;
2517 vos_spin_lock_release(&sap_ctx->ecsa_info.ecsa_lock);
2518
2519 return 0;
2520}
2521
2522int wlansap_reset_chan_change_in_progress(ptSapContext sap_ctx)
2523{
2524 vos_spin_lock_acquire(&sap_ctx->ecsa_info.ecsa_lock);
2525 sap_ctx->ecsa_info.channel_switch_in_progress = false;
2526 vos_spin_lock_release(&sap_ctx->ecsa_info.ecsa_lock);
2527
2528 return 0;
2529}
2530
2531bool wlansap_get_change_in_progress(ptSapContext sap_ctx)
2532{
2533 bool value;
2534
2535 vos_spin_lock_acquire(&sap_ctx->ecsa_info.ecsa_lock);
2536 value = sap_ctx->ecsa_info.channel_switch_in_progress;
2537 vos_spin_lock_release(&sap_ctx->ecsa_info.ecsa_lock);
2538
2539 return value;
2540}
2541
2542
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302543int wlansap_set_channel_change(v_PVOID_t vos_ctx,
2544 uint32_t new_channel, bool allow_dfs_chan)
Abhishek Singh02605092017-10-25 14:06:12 +05302545{
2546 ptSapContext sap_ctx;
2547 tWLAN_SAPEvent sap_event = {0};
2548 v_PVOID_t hal;
2549 tpAniSirGlobal mac_ctx;
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302550 eNVChannelEnabledType chan_state;
Abhishek Singh02605092017-10-25 14:06:12 +05302551
2552 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
2553
2554 if (!sap_ctx) {
2555 hddLog(LOGE, FL("sap_ctx is NULL"));
2556 return -EINVAL;
2557 }
2558
2559 hal = VOS_GET_HAL_CB(sap_ctx->pvosGCtx);
2560 if (!hal) {
2561 hddLog(LOGE, FL("hal is NULL"));
2562 return -EINVAL;
2563 }
2564 mac_ctx = PMAC_STRUCT(hal);
Abhishek Singh78c691f2017-11-30 13:48:44 +05302565
2566 if (eSAP_STARTED != sap_ctx->sapsMachine) {
2567 hddLog(LOGE, FL("SAP is not in eSAP_STARTED state "));
2568 return -EINVAL;
2569 }
2570
Abhishek Singh02605092017-10-25 14:06:12 +05302571 if (sap_ctx->channel == new_channel) {
2572 hddLog(LOGE, FL("channel %d already set"), new_channel);
2573 return -EALREADY;
2574 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302575
2576 if(!wlansap_get_change_in_progress(sap_ctx)) {
2577 hddLog(LOGE, FL("channel_switch_in_progress should be set before calling channel change"));
2578 return -EINVAL;
Abhishek Singh02605092017-10-25 14:06:12 +05302579 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302580
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302581 chan_state = vos_nv_getChannelEnabledState(new_channel);
2582 if ((chan_state == NV_CHANNEL_DISABLE) ||
2583 (chan_state == NV_CHANNEL_INVALID)) {
2584 hddLog(LOGE,
2585 FL("Channel is disabled, Ignore channel switch "));
2586 return -EINVAL;
2587 } else if (!allow_dfs_chan && (chan_state == NV_CHANNEL_DFS)) {
2588 hddLog(LOGE,
2589 FL("DFS channel ignore channel switch as allow_dfs_chan is false"));
Abhishek Singh02605092017-10-25 14:06:12 +05302590 return -EINVAL;
2591 }
Abhishek Singh02605092017-10-25 14:06:12 +05302592 if (!wlansap_validate_phy_mode(sap_ctx->csrRoamProfile.phyMode,
2593 new_channel)) {
2594 hddLog(LOGE, FL("Channel %d not valid for phyMode %d"), new_channel,
2595 sap_ctx->csrRoamProfile.phyMode);
2596 return -EINVAL;
2597 }
2598
2599 sap_ctx->ecsa_info.new_channel = new_channel;
Abhishek Singh02605092017-10-25 14:06:12 +05302600 /*
2601 * Post the eSAP_CHANNEL_SWITCH_ANNOUNCEMENT_START
2602 * to SAP state machine to process the channel
2603 * request with CSA IE set in the beacons.
2604 */
2605 sap_event.event = eSAP_CHANNEL_SWITCH_ANNOUNCEMENT_START;
2606 sapFsm(sap_ctx, &sap_event);
2607
2608 return 0;
2609}
2610