blob: f36968e346a0051bb4da5941e9c1340af961e308 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/**=========================================================================
43
44 \file smeApi.c
45
46 \brief Definitions for SME APIs
47
48 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
49
50 Qualcomm Confidential and Proprietary.
51
52 ========================================================================*/
53
54/*===========================================================================
55
56 EDIT HISTORY FOR FILE
57
58
59 This section contains comments describing changes made to the module.
60 Notice that changes are listed in reverse chronological order.
61
62
63
64 when who what, where, why
65---------- --- --------------------------------------------------------
6606/03/10 js Added support to hostapd driven
67 * deauth/disassoc/mic failure
68
69===========================================================================*/
70
71/*--------------------------------------------------------------------------
72 Include Files
73 ------------------------------------------------------------------------*/
74
Jeff Johnson295189b2012-06-20 16:38:30 -070075
76#include "smsDebug.h"
77#include "sme_Api.h"
78#include "csrInsideApi.h"
79#include "smeInside.h"
80#include "csrInternal.h"
81#include "wlan_qct_wda.h"
82#include "halMsgApi.h"
Katya Nigam70d68332013-09-16 16:49:45 +053083#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070084#include "sapApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070085
86
87
Jeff Johnson295189b2012-06-20 16:38:30 -070088extern tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb);
89
90#include <wlan_qct_pal_api.h>
Katya Nigam70d68332013-09-16 16:49:45 +053091#define LOG_SIZE 256
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -080092#define READ_MEMORY_DUMP_CMD 9
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053093#define TL_INIT_STATE 0
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -080094
Jeff Johnson295189b2012-06-20 16:38:30 -070095// TxMB Functions
96extern eHalStatus pmcPrepareCommand( tpAniSirGlobal pMac, eSmeCommandType cmdType, void *pvParam,
97 tANI_U32 size, tSmeCmd **ppCmd );
98extern void pmcReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
99extern void qosReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700100extern eHalStatus p2pProcessRemainOnChannelCmd(tpAniSirGlobal pMac, tSmeCmd *p2pRemainonChn);
101extern eHalStatus sme_remainOnChnRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg);
102extern eHalStatus sme_mgmtFrmInd( tHalHandle hHal, tpSirSmeMgmtFrameInd pSmeMgmtFrm);
103extern eHalStatus sme_remainOnChnReady( tHalHandle hHal, tANI_U8* pMsg);
104extern eHalStatus sme_sendActionCnf( tHalHandle hHal, tANI_U8* pMsg);
105extern eHalStatus p2pProcessNoAReq(tpAniSirGlobal pMac, tSmeCmd *pNoACmd);
Jeff Johnson295189b2012-06-20 16:38:30 -0700106
107static eHalStatus initSmeCmdList(tpAniSirGlobal pMac);
108static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping );
109
110eCsrPhyMode sme_GetPhyMode(tHalHandle hHal);
111
112eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf);
113
114eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal);
115
116eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal);
117
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -0700118#ifdef FEATURE_WLAN_LFR
119tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac);
120#endif
121
Chet Lanctot186b5732013-03-18 10:26:30 -0700122#ifdef WLAN_FEATURE_11W
123eHalStatus sme_UnprotectedMgmtFrmInd( tHalHandle hHal,
124 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm );
125#endif
126
Jeff Johnson295189b2012-06-20 16:38:30 -0700127//Internal SME APIs
128eHalStatus sme_AcquireGlobalLock( tSmeStruct *psSme)
129{
130 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
131
132 if(psSme)
133 {
134 if( VOS_IS_STATUS_SUCCESS( vos_lock_acquire( &psSme->lkSmeGlobalLock) ) )
135 {
136 status = eHAL_STATUS_SUCCESS;
137 }
138 }
139
140 return (status);
141}
142
143
144eHalStatus sme_ReleaseGlobalLock( tSmeStruct *psSme)
145{
146 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
147
148 if(psSme)
149 {
150 if( VOS_IS_STATUS_SUCCESS( vos_lock_release( &psSme->lkSmeGlobalLock) ) )
151 {
152 status = eHAL_STATUS_SUCCESS;
153 }
154 }
155
156 return (status);
157}
158
159
160
161static eHalStatus initSmeCmdList(tpAniSirGlobal pMac)
162{
163 eHalStatus status;
164 tSmeCmd *pCmd;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530165 tANI_U32 cmd_idx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700166
167 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530168 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
169 &pMac->sme.smeCmdActiveList)))
170 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -0700171
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530172 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
173 &pMac->sme.smeCmdPendingList)))
174 goto end;
175
176 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
177 &pMac->sme.smeScanCmdActiveList)))
178 goto end;
179
180 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
181 &pMac->sme.smeScanCmdPendingList)))
182 goto end;
183
184 if (!HAL_STATUS_SUCCESS(status = csrLLOpen(pMac->hHdd,
185 &pMac->sme.smeCmdFreeList)))
186 goto end;
187
Kiet Lam64c1b492013-07-12 13:56:44 +0530188 pCmd = vos_mem_malloc(sizeof(tSmeCmd) * pMac->sme.totalSmeCmd);
189 if ( NULL == pCmd )
190 status = eHAL_STATUS_FAILURE;
191 else
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530192 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530193 status = eHAL_STATUS_SUCCESS;
194
195 vos_mem_set(pCmd, sizeof(tSmeCmd) * pMac->sme.totalSmeCmd, 0);
196 pMac->sme.pSmeCmdBufAddr = pCmd;
197
198 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++)
199 {
200 csrLLInsertTail(&pMac->sme.smeCmdFreeList,
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530201 &pCmd[cmd_idx].Link, LL_ACCESS_LOCK);
Kiet Lam64c1b492013-07-12 13:56:44 +0530202 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700203 }
204
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530205end:
206 if (!HAL_STATUS_SUCCESS(status))
207 smsLog(pMac, LOGE, "failed to initialize sme command list:%d\n",
208 status);
209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210 return (status);
211}
212
213
214void smeReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCmd)
215{
216 pCmd->command = eSmeNoCommand;
217 csrLLInsertTail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
218}
219
220
221
222static void smeReleaseCmdList(tpAniSirGlobal pMac, tDblLinkList *pList)
223{
224 tListElem *pEntry;
225 tSmeCmd *pCommand;
226
227 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_LOCK)) != NULL)
228 {
229 //TODO: base on command type to call release functions
230 //reinitialize different command types so they can be reused
231 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
232 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
233 }
234}
235
236static void purgeSmeCmdList(tpAniSirGlobal pMac)
237{
238 //release any out standing commands back to free command list
239 smeReleaseCmdList(pMac, &pMac->sme.smeCmdPendingList);
240 smeReleaseCmdList(pMac, &pMac->sme.smeCmdActiveList);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530241 smeReleaseCmdList(pMac, &pMac->sme.smeScanCmdPendingList);
242 smeReleaseCmdList(pMac, &pMac->sme.smeScanCmdActiveList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700243}
244
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +0530245void purgeSmeSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
246 tDblLinkList *pList)
Jeff Johnson295189b2012-06-20 16:38:30 -0700247{
248 //release any out standing commands back to free command list
249 tListElem *pEntry, *pNext;
250 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -0700251 tDblLinkList localList;
252
253 vos_mem_zero(&localList, sizeof(tDblLinkList));
254 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
255 {
256 smsLog(pMac, LOGE, FL(" failed to open list"));
257 return;
258 }
259
260 csrLLLock(pList);
261 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
262 while(pEntry != NULL)
263 {
264 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
265 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
266 if(pCommand->sessionId == sessionId)
267 {
268 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
269 {
270 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
271 }
272 }
273 pEntry = pNext;
274 }
275 csrLLUnlock(pList);
276
277 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
278 {
279 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
280 smeAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
281 }
282 csrLLClose(&localList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700283}
284
285
286static eHalStatus freeSmeCmdList(tpAniSirGlobal pMac)
287{
288 eHalStatus status = eHAL_STATUS_SUCCESS;
289
290 purgeSmeCmdList(pMac);
291 csrLLClose(&pMac->sme.smeCmdPendingList);
292 csrLLClose(&pMac->sme.smeCmdActiveList);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530293 csrLLClose(&pMac->sme.smeScanCmdPendingList);
294 csrLLClose(&pMac->sme.smeScanCmdActiveList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 csrLLClose(&pMac->sme.smeCmdFreeList);
296
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800297 status = vos_lock_acquire(&pMac->sme.lkSmeGlobalLock);
298 if(status != eHAL_STATUS_SUCCESS)
299 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800300 smsLog(pMac, LOGE,
301 FL("Failed to acquire the lock status = %d"), status);
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800302 goto done;
303 }
304
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 if(NULL != pMac->sme.pSmeCmdBufAddr)
306 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530307 vos_mem_free(pMac->sme.pSmeCmdBufAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700308 pMac->sme.pSmeCmdBufAddr = NULL;
309 }
310
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800311 status = vos_lock_release(&pMac->sme.lkSmeGlobalLock);
312 if(status != eHAL_STATUS_SUCCESS)
313 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800314 smsLog(pMac, LOGE,
315 FL("Failed to release the lock status = %d"), status);
Madan Mohan Koyyalamudi7a5fb7e2012-12-06 13:05:42 -0800316 }
317done:
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 return (status);
319}
320
321
322void dumpCsrCommandInfo(tpAniSirGlobal pMac, tSmeCmd *pCmd)
323{
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 switch( pCmd->command )
325 {
326 case eSmeCommandScan:
327 smsLog( pMac, LOGE, " scan command reason is %d", pCmd->u.scanCmd.reason );
328 break;
329
330 case eSmeCommandRoam:
331 smsLog( pMac, LOGE, " roam command reason is %d", pCmd->u.roamCmd.roamReason );
332 break;
333
334 case eSmeCommandWmStatusChange:
335 smsLog( pMac, LOGE, " WMStatusChange command type is %d", pCmd->u.wmStatusChangeCmd.Type );
336 break;
337
338 case eSmeCommandSetKey:
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800339 smsLog( pMac, LOGE, " setKey command auth(%d) enc(%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType );
341 break;
342
343 case eSmeCommandRemoveKey:
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800344 smsLog( pMac, LOGE, " removeKey command auth(%d) enc(%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 pCmd->u.removeKeyCmd.authType, pCmd->u.removeKeyCmd.encType );
346 break;
347
348 default:
349 break;
350 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700351}
352
353tSmeCmd *smeGetCommandBuffer( tpAniSirGlobal pMac )
354{
355 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
356 tListElem *pEntry;
357
358 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK );
359
360 // If we can get another MS Msg buffer, then we are ok. Just link
361 // the entry onto the linked list. (We are using the linked list
362 // to keep track of tfhe message buffers).
363 if ( pEntry )
364 {
365 pRetCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
366 }
367 else {
368 int idx = 1;
369
370 //Cannot change pRetCmd here since it needs to return later.
371 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
372 if( pEntry )
373 {
374 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
375 }
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800376 smsLog( pMac, LOGE, "Out of command buffer.... command (0x%X) stuck",
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
378 if(pTempCmd)
379 {
380 if( eSmeCsrCommandMask & pTempCmd->command )
381 {
382 //CSR command is stuck. See what the reason code is for that command
383 dumpCsrCommandInfo(pMac, pTempCmd);
384 }
385 } //if(pTempCmd)
386
387 //dump what is in the pending queue
388 csrLLLock(&pMac->sme.smeCmdPendingList);
389 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
390 while(pEntry)
391 {
392 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800393 smsLog( pMac, LOGE, "Out of command buffer.... SME pending command #%d (0x%X)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 idx++, pTempCmd->command );
395 if( eSmeCsrCommandMask & pTempCmd->command )
396 {
397 //CSR command is stuck. See what the reason code is for that command
398 dumpCsrCommandInfo(pMac, pTempCmd);
399 }
400 pEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
401 }
402 csrLLUnlock(&pMac->sme.smeCmdPendingList);
403
404 //There may be some more command in CSR's own pending queue
405 csrLLLock(&pMac->roam.roamCmdPendingList);
406 pEntry = csrLLPeekHead( &pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK );
407 while(pEntry)
408 {
409 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800410 smsLog( pMac, LOGE, "Out of command buffer.... CSR pending command #%d (0x%X)",
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 idx++, pTempCmd->command );
412 dumpCsrCommandInfo(pMac, pTempCmd);
413 pEntry = csrLLNext( &pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
414 }
415 csrLLUnlock(&pMac->roam.roamCmdPendingList);
416 }
417
418 return( pRetCmd );
419}
420
421
422void smePushCommand( tpAniSirGlobal pMac, tSmeCmd *pCmd, tANI_BOOLEAN fHighPriority )
423{
424 if ( fHighPriority )
425 {
426 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
427 }
428 else
429 {
430 csrLLInsertTail( &pMac->sme.smeCmdPendingList, &pCmd->Link, LL_ACCESS_LOCK );
431 }
432
433 // process the command queue...
434 smeProcessPendingQueue( pMac );
435
436 return;
437}
438
439
440static eSmeCommandType smeIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand )
441{
442 eSmeCommandType pmcCommand = eSmeNoCommand;
443 tANI_BOOLEAN fFullPowerNeeded = eANI_BOOLEAN_FALSE;
444 tPmcState pmcState;
445 eHalStatus status;
446
447 do
448 {
449 pmcState = pmcGetPmcState(pMac);
450
451 status = csrIsFullPowerNeeded( pMac, pCommand, NULL, &fFullPowerNeeded );
452 if( !HAL_STATUS_SUCCESS(status) )
453 {
454 //PMC state is not right for the command, drop it
455 return ( eSmeDropCommand );
456 }
457 if( fFullPowerNeeded ) break;
458 fFullPowerNeeded = ( ( eSmeCommandAddTs == pCommand->command ) ||
459 ( eSmeCommandDelTs == pCommand->command ) );
460 if( fFullPowerNeeded ) break;
Jeff Johnsone7245742012-09-05 17:12:55 -0700461#ifdef FEATURE_OEM_DATA_SUPPORT
462 fFullPowerNeeded = (pmcState == IMPS &&
463 eSmeCommandOemDataReq == pCommand->command);
464 if(fFullPowerNeeded) break;
465#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 fFullPowerNeeded = (pmcState == IMPS &&
467 eSmeCommandRemainOnChannel == pCommand->command);
468 if(fFullPowerNeeded) break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 } while(0);
470
471 if( fFullPowerNeeded )
472 {
473 switch( pmcState )
474 {
475 case IMPS:
476 case STANDBY:
477 pmcCommand = eSmeCommandExitImps;
478 break;
479
480 case BMPS:
481 pmcCommand = eSmeCommandExitBmps;
482 break;
483
484 case UAPSD:
485 pmcCommand = eSmeCommandExitUapsd;
486 break;
487
488 case WOWL:
489 pmcCommand = eSmeCommandExitWowl;
490 break;
491
492 default:
493 break;
494 }
495 }
496
497 return ( pmcCommand );
498}
499
500
501//For commands that need to do extra cleanup.
502static void smeAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
503{
504 if( eSmePmcCommandMask & pCommand->command )
505 {
506 pmcAbortCommand( pMac, pCommand, fStopping );
507 }
508 else if ( eSmeCsrCommandMask & pCommand->command )
509 {
510 csrAbortCommand( pMac, pCommand, fStopping );
511 }
512 else
513 {
514 switch( pCommand->command )
515 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 case eSmeCommandRemainOnChannel:
517 if (NULL != pCommand->u.remainChlCmd.callback)
518 {
519 remainOnChanCallback callback =
520 pCommand->u.remainChlCmd.callback;
521 /* process the msg */
522 if( callback )
523 {
524 callback(pMac, pCommand->u.remainChlCmd.callbackCtx,
525 eCSR_SCAN_ABORT );
526 }
527 }
528 smeReleaseCommand( pMac, pCommand );
529 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 default:
531 smeReleaseCommand( pMac, pCommand );
532 break;
533 }
534 }
535}
536
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530537tListElem *csrGetCmdToProcess(tpAniSirGlobal pMac, tDblLinkList *pList,
538 tANI_U8 sessionId, tANI_BOOLEAN fInterlocked)
539{
540 tListElem *pCurEntry = NULL;
541 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -0700542
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530543 /* Go through the list and return the command whose session id is not
544 * matching with the current ongoing scan cmd sessionId */
545 pCurEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK );
546 while (pCurEntry)
547 {
548 pCommand = GET_BASE_ADDR(pCurEntry, tSmeCmd, Link);
549 if (pCommand->sessionId != sessionId)
550 {
551 smsLog(pMac, LOG1, "selected the command with different sessionId");
552 return pCurEntry;
553 }
554
555 pCurEntry = csrLLNext(pList, pCurEntry, fInterlocked);
556 }
557
558 smsLog(pMac, LOG1, "No command pending with different sessionId");
559 return NULL;
560}
561
562tANI_BOOLEAN smeProcessScanQueue(tpAniSirGlobal pMac)
563{
564 tListElem *pEntry;
565 tSmeCmd *pCommand;
566 tListElem *pSmeEntry;
567 tSmeCmd *pSmeCommand;
568 tANI_BOOLEAN status = eANI_BOOLEAN_TRUE;
569
570 csrLLLock( &pMac->sme.smeScanCmdActiveList );
571 if (csrLLIsListEmpty( &pMac->sme.smeScanCmdActiveList,
572 LL_ACCESS_NOLOCK ))
573 {
574 if (!csrLLIsListEmpty(&pMac->sme.smeScanCmdPendingList,
575 LL_ACCESS_LOCK))
576 {
577 pEntry = csrLLPeekHead( &pMac->sme.smeScanCmdPendingList,
578 LL_ACCESS_LOCK );
579 if (pEntry)
580 {
581 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
582 //We cannot execute any command in wait-for-key state until setKey is through.
583 if (CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId))
584 {
585 if (!CSR_IS_SET_KEY_COMMAND(pCommand))
586 {
587 smsLog(pMac, LOGE,
588 " Cannot process command(%d) while waiting for key",
589 pCommand->command);
590 status = eANI_BOOLEAN_FALSE;
591 goto end;
592 }
593 }
594
595 if ((!csrLLIsListEmpty(&pMac->sme.smeCmdActiveList,
596 LL_ACCESS_LOCK )))
597 {
598 pSmeEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList,
599 LL_ACCESS_LOCK);
600 if (pEntry)
601 {
602 pSmeCommand = GET_BASE_ADDR(pEntry, tSmeCmd,
603 Link) ;
604
605 /* if scan is running on one interface and SME recei
606 ves the next command on the same interface then
607 dont the allow the command to be queued to
608 smeCmdPendingList. If next scan is allowed on
609 the same interface the CSR state machine will
610 get screwed up. */
611 if (pSmeCommand->sessionId == pCommand->sessionId)
612 {
613 status = eANI_BOOLEAN_FALSE;
614 goto end;
615 }
616 }
617 }
618 if ( csrLLRemoveEntry( &pMac->sme.smeScanCmdPendingList,
619 pEntry, LL_ACCESS_LOCK ) )
620 {
621 csrLLInsertHead( &pMac->sme.smeScanCmdActiveList,
622 &pCommand->Link, LL_ACCESS_NOLOCK );
623
624 switch (pCommand->command)
625 {
626 case eSmeCommandScan:
627 smsLog(pMac, LOG1,
628 " Processing scan offload command ");
629 csrProcessScanCommand( pMac, pCommand );
630 break;
631 default:
632 smsLog(pMac, LOGE,
633 " Something wrong, wrong command enqueued"
634 " to smeScanCmdPendingList");
635 pEntry = csrLLRemoveHead(
636 &pMac->sme.smeScanCmdActiveList,
637 LL_ACCESS_NOLOCK );
638 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
639 smeReleaseCommand( pMac, pCommand );
640 break;
641 }
642 }
643 }
644 }
645 }
646end:
647 csrLLUnlock(&pMac->sme.smeScanCmdActiveList);
648 return status;
649}
Jeff Johnson295189b2012-06-20 16:38:30 -0700650
651tANI_BOOLEAN smeProcessCommand( tpAniSirGlobal pMac )
652{
653 tANI_BOOLEAN fContinue = eANI_BOOLEAN_FALSE;
654 eHalStatus status = eHAL_STATUS_SUCCESS;
655 tListElem *pEntry;
656 tSmeCmd *pCommand;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530657 tListElem *pSmeEntry;
658 tSmeCmd *pSmeCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 eSmeCommandType pmcCommand = eSmeNoCommand;
660
661 // if the ActiveList is empty, then nothing is active so we can process a
662 // pending command...
663 //alwasy lock active list before locking pending list
664 csrLLLock( &pMac->sme.smeCmdActiveList );
665 if ( csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) )
666 {
667 if(!csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK))
668 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530669 /* If scan command is pending in the smeScanCmdActive list
670 * then pick the command from smeCmdPendingList which is
671 * not matching with the scan command session id.
672 * At any point of time only one command will be allowed
673 * on a single session. */
674 if ((pMac->fScanOffload) &&
675 (!csrLLIsListEmpty(&pMac->sme.smeScanCmdActiveList,
676 LL_ACCESS_LOCK)))
677 {
678 pSmeEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList,
679 LL_ACCESS_LOCK);
680 if (pSmeEntry)
681 {
682 pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
683
684 pEntry = csrGetCmdToProcess(pMac,
685 &pMac->sme.smeCmdPendingList,
686 pSmeCommand->sessionId,
687 LL_ACCESS_LOCK);
688 goto sme_process_cmd;
689 }
690 }
691
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 //Peek the command
693 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK );
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530694sme_process_cmd:
Jeff Johnson295189b2012-06-20 16:38:30 -0700695 if( pEntry )
696 {
697 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530698
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 //We cannot execute any command in wait-for-key state until setKey is through.
700 if( CSR_IS_WAIT_FOR_KEY( pMac, pCommand->sessionId ) )
701 {
702 if( !CSR_IS_SET_KEY_COMMAND( pCommand ) )
703 {
704 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800705 smsLog(pMac, LOGE, " Cannot process command(%d) while waiting for key", pCommand->command);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530706 fContinue = eANI_BOOLEAN_FALSE;
707 goto sme_process_scan_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 }
709 }
710 pmcCommand = smeIsFullPowerNeeded( pMac, pCommand );
711 if( eSmeDropCommand == pmcCommand )
712 {
713 //This command is not ok for current PMC state
714 if( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
715 {
716 smeAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE );
717 }
718 csrLLUnlock( &pMac->sme.smeCmdActiveList );
719 //tell caller to continue
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530720 fContinue = eANI_BOOLEAN_TRUE;
721 goto sme_process_scan_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 }
723 else if( eSmeNoCommand != pmcCommand )
724 {
725 tExitBmpsInfo exitBmpsInfo;
726 void *pv = NULL;
727 tANI_U32 size = 0;
728 tSmeCmd *pPmcCmd = NULL;
729
730 if( eSmeCommandExitBmps == pmcCommand )
731 {
732 exitBmpsInfo.exitBmpsReason = eSME_REASON_OTHER;
733 pv = (void *)&exitBmpsInfo;
734 size = sizeof(tExitBmpsInfo);
735 }
736 //pmcCommand has to be one of the exit power save command
737 status = pmcPrepareCommand( pMac, pmcCommand, pv, size, &pPmcCmd );
738 if( HAL_STATUS_SUCCESS( status ) && pPmcCmd )
739 {
740 //Force this command to wake up the chip
741 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK );
742 csrLLUnlock( &pMac->sme.smeCmdActiveList );
743 fContinue = pmcProcessCommand( pMac, pPmcCmd );
744 if( fContinue )
745 {
746 //The command failed, remove it
747 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, &pPmcCmd->Link, LL_ACCESS_NOLOCK ) )
748 {
749 pmcReleaseCommand( pMac, pPmcCmd );
750 }
751 }
752 }
753 else
754 {
755 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800756 smsLog( pMac, LOGE, FL( "Cannot issue command(0x%X) to wake up the chip. Status = %d"), pmcCommand, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 //Let it retry
758 fContinue = eANI_BOOLEAN_TRUE;
759 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530760 goto sme_process_scan_queue;
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 }
762 if ( csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_LOCK ) )
763 {
764 // we can reuse the pCommand
765
766 // Insert the command onto the ActiveList...
767 csrLLInsertHead( &pMac->sme.smeCmdActiveList, &pCommand->Link, LL_ACCESS_NOLOCK );
768
769 // .... and process the command.
770
771 switch ( pCommand->command )
772 {
773
774 case eSmeCommandScan:
775 csrLLUnlock( &pMac->sme.smeCmdActiveList );
776 status = csrProcessScanCommand( pMac, pCommand );
777 break;
778
779 case eSmeCommandRoam:
780 csrLLUnlock( &pMac->sme.smeCmdActiveList );
781 status = csrRoamProcessCommand( pMac, pCommand );
Madan Mohan Koyyalamudi59efbe02013-01-10 15:38:42 -0800782 if(!HAL_STATUS_SUCCESS(status))
783 {
784 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
785 &pCommand->Link, LL_ACCESS_LOCK ) )
786 {
787 csrReleaseCommandRoam( pMac, pCommand );
788 }
789 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700790 break;
791
792 case eSmeCommandWmStatusChange:
793 csrLLUnlock( &pMac->sme.smeCmdActiveList );
794 csrRoamProcessWmStatusChangeCommand(pMac, pCommand);
795 break;
796
797 case eSmeCommandSetKey:
798 csrLLUnlock( &pMac->sme.smeCmdActiveList );
799 status = csrRoamProcessSetKeyCommand( pMac, pCommand );
800 if(!HAL_STATUS_SUCCESS(status))
801 {
802 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
803 &pCommand->Link, LL_ACCESS_LOCK ) )
804 {
805 csrReleaseCommandSetKey( pMac, pCommand );
806 }
807 }
808 break;
809
810 case eSmeCommandRemoveKey:
811 csrLLUnlock( &pMac->sme.smeCmdActiveList );
812 status = csrRoamProcessRemoveKeyCommand( pMac, pCommand );
813 if(!HAL_STATUS_SUCCESS(status))
814 {
815 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
816 &pCommand->Link, LL_ACCESS_LOCK ) )
817 {
818 csrReleaseCommandRemoveKey( pMac, pCommand );
819 }
820 }
821 break;
822
823 case eSmeCommandAddStaSession:
824 csrLLUnlock( &pMac->sme.smeCmdActiveList );
825 csrProcessAddStaSessionCommand( pMac, pCommand );
826 break;
827 case eSmeCommandDelStaSession:
828 csrLLUnlock( &pMac->sme.smeCmdActiveList );
829 csrProcessDelStaSessionCommand( pMac, pCommand );
830 break;
831
Jeff Johnsone7245742012-09-05 17:12:55 -0700832#ifdef FEATURE_OEM_DATA_SUPPORT
833 case eSmeCommandOemDataReq:
834 csrLLUnlock(&pMac->sme.smeCmdActiveList);
835 oemData_ProcessOemDataReqCommand(pMac, pCommand);
836 break;
837#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 case eSmeCommandRemainOnChannel:
839 csrLLUnlock(&pMac->sme.smeCmdActiveList);
840 p2pProcessRemainOnChannelCmd(pMac, pCommand);
841 break;
842 case eSmeCommandNoAUpdate:
843 csrLLUnlock( &pMac->sme.smeCmdActiveList );
844 p2pProcessNoAReq(pMac,pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 case eSmeCommandEnterImps:
846 case eSmeCommandExitImps:
847 case eSmeCommandEnterBmps:
848 case eSmeCommandExitBmps:
849 case eSmeCommandEnterUapsd:
850 case eSmeCommandExitUapsd:
851 case eSmeCommandEnterWowl:
852 case eSmeCommandExitWowl:
853 csrLLUnlock( &pMac->sme.smeCmdActiveList );
854 fContinue = pmcProcessCommand( pMac, pCommand );
855 if( fContinue )
856 {
857 //The command failed, remove it
858 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
859 &pCommand->Link, LL_ACCESS_LOCK ) )
860 {
861 pmcReleaseCommand( pMac, pCommand );
862 }
863 }
864 break;
865
866 //Treat standby differently here because caller may not be able to handle
867 //the failure so we do our best here
868 case eSmeCommandEnterStandby:
869 if( csrIsConnStateDisconnected( pMac, pCommand->sessionId ) )
870 {
871 //It can continue
872 csrLLUnlock( &pMac->sme.smeCmdActiveList );
873 fContinue = pmcProcessCommand( pMac, pCommand );
874 if( fContinue )
875 {
876 //The command failed, remove it
877 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
878 &pCommand->Link, LL_ACCESS_LOCK ) )
879 {
880 pmcReleaseCommand( pMac, pCommand );
881 }
882 }
883 }
884 else
885 {
886 //Need to issue a disconnect first before processing this command
887 tSmeCmd *pNewCmd;
888
889 //We need to re-run the command
890 fContinue = eANI_BOOLEAN_TRUE;
891 //Pull off the standby command first
892 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
893 &pCommand->Link, LL_ACCESS_NOLOCK ) )
894 {
895 csrLLUnlock( &pMac->sme.smeCmdActiveList );
896 //Need to call CSR function here because the disconnect command
897 //is handled by CSR
898 pNewCmd = csrGetCommandBuffer( pMac );
899 if( NULL != pNewCmd )
900 {
901 //Put the standby command to the head of the pending list first
902 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pCommand->Link,
903 LL_ACCESS_LOCK );
904 pNewCmd->command = eSmeCommandRoam;
905 pNewCmd->u.roamCmd.roamReason = eCsrForcedDisassoc;
906 //Put the disassoc command before the standby command
907 csrLLInsertHead( &pMac->sme.smeCmdPendingList, &pNewCmd->Link,
908 LL_ACCESS_LOCK );
909 }
910 else
911 {
912 //Continue the command here
913 fContinue = pmcProcessCommand( pMac, pCommand );
914 if( fContinue )
915 {
916 //The command failed, remove it
917 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
918 &pCommand->Link, LL_ACCESS_LOCK ) )
919 {
920 pmcReleaseCommand( pMac, pCommand );
921 }
922 }
923 }
924 }
925 else
926 {
927 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800928 smsLog( pMac, LOGE, FL(" failed to remove standby command") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 VOS_ASSERT(0);
930 }
931 }
932 break;
933
934 case eSmeCommandAddTs:
935 case eSmeCommandDelTs:
936 csrLLUnlock( &pMac->sme.smeCmdActiveList );
937#ifndef WLAN_MDM_CODE_REDUCTION_OPT
938 fContinue = qosProcessCommand( pMac, pCommand );
939 if( fContinue )
940 {
941 //The command failed, remove it
942 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList,
943 &pCommand->Link, LL_ACCESS_NOLOCK ) )
944 {
945//#ifndef WLAN_MDM_CODE_REDUCTION_OPT
946 qosReleaseCommand( pMac, pCommand );
947//#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
948 }
949 }
950#endif
951 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800952#ifdef FEATURE_WLAN_TDLS
953 case eSmeCommandTdlsSendMgmt:
954 case eSmeCommandTdlsAddPeer:
955 case eSmeCommandTdlsDelPeer:
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530956 case eSmeCommandTdlsLinkEstablish:
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800957#ifdef FEATURE_WLAN_TDLS_INTERNAL
958 case eSmeCommandTdlsDiscovery:
959 case eSmeCommandTdlsLinkSetup:
960 case eSmeCommandTdlsLinkTear:
961 case eSmeCommandTdlsEnterUapsd:
962 case eSmeCommandTdlsExitUapsd:
963#endif
964 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -0800965 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800966 "sending TDLS Command 0x%x to PE", pCommand->command);
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800967
968 csrLLUnlock( &pMac->sme.smeCmdActiveList );
969 status = csrTdlsProcessCmd( pMac, pCommand );
970 }
971 break ;
972#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700973
974 default:
975 //something is wrong
976 //remove it from the active list
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -0800977 smsLog(pMac, LOGE, " csrProcessCommand processes an unknown command %d", pCommand->command);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 pEntry = csrLLRemoveHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK );
979 csrLLUnlock( &pMac->sme.smeCmdActiveList );
980 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
981 smeReleaseCommand( pMac, pCommand );
982 status = eHAL_STATUS_FAILURE;
983 break;
984 }
985 if(!HAL_STATUS_SUCCESS(status))
986 {
987 fContinue = eANI_BOOLEAN_TRUE;
988 }
989 }//if(pEntry)
990 else
991 {
992 //This is odd. Some one else pull off the command.
993 csrLLUnlock( &pMac->sme.smeCmdActiveList );
994 }
995 }
996 else
997 {
998 csrLLUnlock( &pMac->sme.smeCmdActiveList );
999 }
1000 }
1001 else
1002 {
1003 //No command waiting
1004 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1005 //This is only used to restart an idle mode scan, it means at least one other idle scan has finished.
1006 if(pMac->scan.fRestartIdleScan && eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
1007 {
1008 tANI_U32 nTime = 0;
1009
1010 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
1011 if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime)))
1012 {
1013 csrScanStartIdleScanTimer(pMac, nTime);
1014 }
1015 }
1016 }
1017 }
1018 else {
1019 csrLLUnlock( &pMac->sme.smeCmdActiveList );
1020 }
1021
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05301022sme_process_scan_queue:
1023 if (pMac->fScanOffload && !(smeProcessScanQueue(pMac)))
1024 fContinue = eANI_BOOLEAN_FALSE;
1025
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 return ( fContinue );
1027}
1028
1029void smeProcessPendingQueue( tpAniSirGlobal pMac )
1030{
1031 while( smeProcessCommand( pMac ) );
1032}
1033
1034
1035tANI_BOOLEAN smeCommandPending(tpAniSirGlobal pMac)
1036{
1037 return ( !csrLLIsListEmpty( &pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK ) ||
1038 !csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK) );
1039}
1040
1041
1042
1043//Global APIs
1044
1045/*--------------------------------------------------------------------------
1046
1047 \brief sme_Open() - Initialze all SME modules and put them at idle state
1048
1049 The function initializes each module inside SME, PMC, CCM, CSR, etc. . Upon
1050 successfully return, all modules are at idle state ready to start.
1051
1052 smeOpen must be called before any other SME APIs can be involved.
1053 smeOpen must be called after macOpen.
Srinivas Girigowdade697412013-02-14 16:31:48 -08001054 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 \param hHal - The handle returned by macOpen.
1056
1057 \return eHAL_STATUS_SUCCESS - SME is successfully initialized.
1058
1059 Other status means SME is failed to be initialized
1060 \sa
1061
1062 --------------------------------------------------------------------------*/
1063eHalStatus sme_Open(tHalHandle hHal)
1064{
1065 eHalStatus status = eHAL_STATUS_FAILURE;
1066 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1067
1068 do {
1069 pMac->sme.state = SME_STATE_STOP;
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07001070 pMac->sme.currDeviceMode = VOS_STA_MODE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 if( !VOS_IS_STATUS_SUCCESS( vos_lock_init( &pMac->sme.lkSmeGlobalLock ) ) )
1072 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001073 smsLog( pMac, LOGE, "sme_Open failed init lock" );
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 status = eHAL_STATUS_FAILURE;
1075 break;
1076 }
1077
1078 status = ccmOpen(hHal);
1079 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1080 smsLog( pMac, LOGE,
1081 "ccmOpen failed during initialization with status=%d", status );
1082 break;
1083 }
1084
1085 status = csrOpen(pMac);
1086 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1087 smsLog( pMac, LOGE,
1088 "csrOpen failed during initialization with status=%d", status );
1089 break;
1090 }
1091
1092 status = pmcOpen(hHal);
1093 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1094 smsLog( pMac, LOGE,
1095 "pmcOpen failed during initialization with status=%d", status );
1096 break;
1097 }
1098
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07001099#ifdef FEATURE_WLAN_TDLS
1100 pMac->isTdlsPowerSaveProhibited = 0;
1101#endif
1102
Jeff Johnson295189b2012-06-20 16:38:30 -07001103#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1104 status = sme_QosOpen(pMac);
1105 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1106 smsLog( pMac, LOGE,
1107 "Qos open failed during initialization with status=%d", status );
1108 break;
1109 }
1110
1111 status = btcOpen(pMac);
1112 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1113 smsLog( pMac, LOGE,
1114 "btcOpen open failed during initialization with status=%d", status );
1115 break;
1116 }
1117#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001118#ifdef FEATURE_OEM_DATA_SUPPORT
1119 status = oemData_OemDataReqOpen(pMac);
1120 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1121 smsLog(pMac, LOGE,
1122 "oemData_OemDataReqOpen failed during initialization with status=%d", status );
1123 break;
1124 }
1125#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001126
1127 if(!HAL_STATUS_SUCCESS((status = initSmeCmdList(pMac))))
1128 break;
1129
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 {
1131 v_PVOID_t pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SAP, NULL);
1132 if ( NULL == pvosGCtx ){
1133 smsLog( pMac, LOGE, "WLANSAP_Open open failed during initialization");
1134 status = eHAL_STATUS_FAILURE;
1135 break;
1136 }
1137
1138 status = WLANSAP_Open( pvosGCtx );
1139 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1140 smsLog( pMac, LOGE,
1141 "WLANSAP_Open open failed during initialization with status=%d", status );
1142 break;
1143 }
1144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001145#if defined WLAN_FEATURE_VOWIFI
1146 status = rrmOpen(pMac);
1147 if ( ! HAL_STATUS_SUCCESS( status ) ) {
1148 smsLog( pMac, LOGE,
1149 "rrmOpen open failed during initialization with status=%d", status );
1150 break;
1151 }
1152#endif
1153
1154#if defined WLAN_FEATURE_VOWIFI_11R
1155 sme_FTOpen(pMac);
1156#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001157 sme_p2pOpen(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001158
1159 }while (0);
1160
1161 return status;
1162}
1163
Jeff Johnson295189b2012-06-20 16:38:30 -07001164/*--------------------------------------------------------------------------
1165
1166 \brief sme_set11dinfo() - Set the 11d information about valid channels
1167 and there power using information from nvRAM
1168 This function is called only for AP.
1169
Srinivas Girigowdade697412013-02-14 16:31:48 -08001170 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001171
1172 \param hHal - The handle returned by macOpen.
1173 \Param pSmeConfigParams - a pointer to a caller allocated object of
1174 typedef struct _smeConfigParams.
1175
1176 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1177
1178 Other status means SME is failed to update the config parameters.
1179 \sa
1180--------------------------------------------------------------------------*/
1181
1182eHalStatus sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1183{
1184 eHalStatus status = eHAL_STATUS_FAILURE;
1185 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1186
1187 if (NULL == pSmeConfigParams ) {
1188 smsLog( pMac, LOGE,
1189 "Empty config param structure for SME, nothing to update");
1190 return status;
1191 }
1192
1193 status = csrSetChannels(hHal, &pSmeConfigParams->csrConfig );
1194 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001195 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 status );
1197 }
1198 return status;
1199}
1200
1201/*--------------------------------------------------------------------------
1202
1203 \brief sme_getSoftApDomain() - Get the current regulatory domain of softAp.
1204
Srinivas Girigowdade697412013-02-14 16:31:48 -08001205 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001206
1207 \param hHal - The handle returned by HostapdAdapter.
1208 \Param v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
1209
1210 \return eHAL_STATUS_SUCCESS - SME successfully completed the request.
1211
1212 Other status means, failed to get the current regulatory domain.
1213 \sa
1214--------------------------------------------------------------------------*/
1215
1216eHalStatus sme_getSoftApDomain(tHalHandle hHal, v_REGDOMAIN_t *domainIdSoftAp)
1217{
1218 eHalStatus status = eHAL_STATUS_FAILURE;
1219 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1220
1221 if (NULL == domainIdSoftAp ) {
1222 smsLog( pMac, LOGE, "Uninitialized domain Id");
1223 return status;
1224 }
1225
1226 *domainIdSoftAp = pMac->scan.domainIdCurrent;
1227 status = eHAL_STATUS_SUCCESS;
1228
1229 return status;
1230}
1231
1232
1233eHalStatus sme_setRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
1234{
1235 eHalStatus status = eHAL_STATUS_FAILURE;
1236 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1237
1238 if (NULL == apCntryCode ) {
1239 smsLog( pMac, LOGE, "Empty Country Code, nothing to update");
1240 return status;
1241 }
1242
1243 status = csrSetRegInfo(hHal, apCntryCode );
1244 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001245 smsLog( pMac, LOGE, "csrSetRegInfo failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 status );
1247 }
1248 return status;
1249}
1250
Jeff Johnson295189b2012-06-20 16:38:30 -07001251#ifdef FEATURE_WLAN_SCAN_PNO
1252/*--------------------------------------------------------------------------
1253
1254 \brief sme_UpdateChannelConfig() - Update channel configuration in RIVA.
1255
1256 It is used at driver start up to inform RIVA of the default channel
1257 configuration.
1258
Srinivas Girigowdade697412013-02-14 16:31:48 -08001259 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001260
1261 \param hHal - The handle returned by macOpen.
1262
1263 \return eHAL_STATUS_SUCCESS - SME update the channel config successfully.
1264
1265 Other status means SME is failed to update the channel config.
1266 \sa
1267
1268 --------------------------------------------------------------------------*/
1269eHalStatus sme_UpdateChannelConfig(tHalHandle hHal)
1270{
1271 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1272
1273 pmcUpdateScanParams( pMac, &(pMac->roam.configParam),
1274 &pMac->scan.base20MHzChannels, FALSE);
1275 return eHAL_STATUS_SUCCESS;
1276}
1277#endif // FEATURE_WLAN_SCAN_PNLO
1278
1279/*--------------------------------------------------------------------------
1280
1281 \brief sme_UpdateConfig() - Change configurations for all SME moduels
1282
1283 The function updates some configuration for modules in SME, CCM, CSR, etc
1284 during SMEs close open sequence.
1285
1286 Modules inside SME apply the new configuration at the next transaction.
1287
Srinivas Girigowdade697412013-02-14 16:31:48 -08001288 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001289
1290 \param hHal - The handle returned by macOpen.
1291 \Param pSmeConfigParams - a pointer to a caller allocated object of
1292 typedef struct _smeConfigParams.
1293
1294 \return eHAL_STATUS_SUCCESS - SME update the config parameters successfully.
1295
1296 Other status means SME is failed to update the config parameters.
1297 \sa
1298
1299 --------------------------------------------------------------------------*/
1300eHalStatus sme_UpdateConfig(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
1301{
1302 eHalStatus status = eHAL_STATUS_FAILURE;
1303 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1304
1305 if (NULL == pSmeConfigParams ) {
1306 smsLog( pMac, LOGE,
1307 "Empty config param structure for SME, nothing to update");
1308 return status;
1309 }
1310
1311 status = csrChangeDefaultConfigParam(pMac, &pSmeConfigParams->csrConfig);
1312
1313 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001314 smsLog( pMac, LOGE, "csrChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 status );
1316 }
1317#if defined WLAN_FEATURE_P2P_INTERNAL
1318 status = p2pChangeDefaultConfigParam(pMac, &pSmeConfigParams->p2pConfig);
1319
1320 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001321 smsLog( pMac, LOGE, "p2pChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 status );
1323 }
1324#endif
1325#if defined WLAN_FEATURE_VOWIFI
1326 status = rrmChangeDefaultConfigParam(hHal, &pSmeConfigParams->rrmConfig);
1327
1328 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001329 smsLog( pMac, LOGE, "rrmChangeDefaultConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 status );
1331 }
1332#endif
1333 //For SOC, CFG is set before start
1334 //We don't want to apply global CFG in connect state because that may cause some side affect
1335 if(
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 csrIsAllSessionDisconnected( pMac) )
1337 {
1338 csrSetGlobalCfgs(pMac);
1339 }
1340
Gopichand Nakkala86e42662013-06-11 17:44:11 +05301341 /* update the directed scan offload setting */
1342 pMac->fScanOffload = pSmeConfigParams->fScanOffload;
1343
Madan Mohan Koyyalamudid89feb72013-07-31 15:47:12 +05301344 if (pMac->fScanOffload)
1345 {
1346 /* If scan offload is enabled then lim has allow the sending of
1347 scan request to firmware even in powersave mode. The firmware has
1348 to take care of exiting from power save mode */
1349 status = ccmCfgSetInt(hHal, WNI_CFG_SCAN_IN_POWERSAVE,
1350 eANI_BOOLEAN_TRUE, NULL, eANI_BOOLEAN_FALSE);
1351
1352 if (eHAL_STATUS_SUCCESS != status)
1353 {
1354 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1355 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CCM");
1356 }
1357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 return status;
1359}
1360
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301361#ifdef WLAN_FEATURE_GTK_OFFLOAD
1362void sme_ProcessGetGtkInfoRsp( tHalHandle hHal,
1363 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
1364{
1365 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1366
1367 if (NULL == pMac)
1368 {
1369 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1370 "%s: pMac is null", __func__);
1371 return ;
1372 }
1373 if (pMac->pmc.GtkOffloadGetInfoCB == NULL)
1374 {
1375 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1376 "%s: HDD callback is null", __func__);
1377 return ;
1378 }
1379 pMac->pmc.GtkOffloadGetInfoCB(pMac->pmc.GtkOffloadGetInfoCBContext,
1380 pGtkOffloadGetInfoRsp);
1381}
1382#endif
1383
Jeff Johnson295189b2012-06-20 16:38:30 -07001384/* ---------------------------------------------------------------------------
1385 \fn sme_ChangeConfigParams
1386 \brief The SME API exposed for HDD to provide config params to SME during
1387 SMEs stop -> start sequence.
1388
1389 If HDD changed the domain that will cause a reset. This function will
1390 provide the new set of 11d information for the new domain. Currrently this
1391 API provides info regarding 11d only at reset but we can extend this for
1392 other params (PMC, QoS) which needs to be initialized again at reset.
1393
Srinivas Girigowdade697412013-02-14 16:31:48 -08001394 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001395
1396 \param hHal - The handle returned by macOpen.
1397
1398 \Param
1399 pUpdateConfigParam - a pointer to a structure (tCsrUpdateConfigParam) that
1400 currently provides 11d related information like Country code,
1401 Regulatory domain, valid channel list, Tx power per channel, a
1402 list with active/passive scan allowed per valid channel.
1403
1404 \return eHalStatus
1405 ---------------------------------------------------------------------------*/
1406eHalStatus sme_ChangeConfigParams(tHalHandle hHal,
1407 tCsrUpdateConfigParam *pUpdateConfigParam)
1408{
1409 eHalStatus status = eHAL_STATUS_FAILURE;
1410 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1411
1412 if (NULL == pUpdateConfigParam ) {
1413 smsLog( pMac, LOGE,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001414 "Empty config param structure for SME, nothing to reset");
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 return status;
1416 }
1417
1418 status = csrChangeConfigParams(pMac, pUpdateConfigParam);
1419
1420 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001421 smsLog( pMac, LOGE, "csrUpdateConfigParam failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 status );
1423 }
1424
1425 return status;
1426
1427}
1428
1429/*--------------------------------------------------------------------------
1430
1431 \brief sme_HDDReadyInd() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1432 that the NIC is ready tio run.
1433
1434 The function is called by HDD at the end of initialization stage so PE/HAL can
1435 enable the NIC to running state.
1436
Srinivas Girigowdade697412013-02-14 16:31:48 -08001437 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001438 \param hHal - The handle returned by macOpen.
1439
1440 \return eHAL_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1441 successfully.
1442
1443 Other status means SME failed to send the message to PE.
1444 \sa
1445
1446 --------------------------------------------------------------------------*/
1447eHalStatus sme_HDDReadyInd(tHalHandle hHal)
1448{
1449 tSirSmeReadyReq Msg;
1450 eHalStatus status = eHAL_STATUS_FAILURE;
1451 tPmcPowerState powerState;
1452 tPmcSwitchState hwWlanSwitchState;
1453 tPmcSwitchState swWlanSwitchState;
1454 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1455
1456 do
1457 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001458
1459 Msg.messageType = eWNI_SME_SYS_READY_IND;
1460 Msg.length = sizeof( tSirSmeReadyReq );
1461
1462 if (eSIR_FAILURE != uMacPostCtrlMsg( hHal, (tSirMbMsg*)&Msg ))
1463 {
1464 status = eHAL_STATUS_SUCCESS;
1465 }
1466 else
1467 {
1468 smsLog( pMac, LOGE,
1469 "uMacPostCtrlMsg failed to send eWNI_SME_SYS_READY_IND");
1470 break;
1471 }
1472
1473 status = pmcQueryPowerState( hHal, &powerState,
1474 &hwWlanSwitchState, &swWlanSwitchState );
1475 if ( ! HAL_STATUS_SUCCESS( status ) )
1476 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001477 smsLog( pMac, LOGE, "pmcQueryPowerState failed with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 status );
1479 break;
1480 }
1481
1482 if ( (ePMC_SWITCH_OFF != hwWlanSwitchState) &&
1483 (ePMC_SWITCH_OFF != swWlanSwitchState) )
1484 {
1485 status = csrReady(pMac);
1486 if ( ! HAL_STATUS_SUCCESS( status ) )
1487 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001488 smsLog( pMac, LOGE, "csrReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 break;
1490 }
1491 status = pmcReady(hHal);
1492 if ( ! HAL_STATUS_SUCCESS( status ) )
1493 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001494 smsLog( pMac, LOGE, "pmcReady failed with status=%d", status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 break;
1496 }
1497#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1498 if(VOS_STATUS_SUCCESS != btcReady(hHal))
1499 {
1500 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001501 smsLog( pMac, LOGE, "btcReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 break;
1503 }
1504#endif
1505
1506#if defined WLAN_FEATURE_VOWIFI
1507 if(VOS_STATUS_SUCCESS != rrmReady(hHal))
1508 {
1509 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001510 smsLog( pMac, LOGE, "rrmReady failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 break;
1512 }
1513#endif
1514 }
1515 pMac->sme.state = SME_STATE_READY;
1516 } while( 0 );
1517
1518 return status;
1519}
1520
1521/*--------------------------------------------------------------------------
1522
1523 \brief sme_Start() - Put all SME modules at ready state.
1524
1525 The function starts each module in SME, PMC, CCM, CSR, etc. . Upon
1526 successfully return, all modules are ready to run.
Srinivas Girigowdade697412013-02-14 16:31:48 -08001527 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 \param hHal - The handle returned by macOpen.
1529
1530 \return eHAL_STATUS_SUCCESS - SME is ready.
1531
1532 Other status means SME is failed to start
1533 \sa
1534
1535 --------------------------------------------------------------------------*/
1536eHalStatus sme_Start(tHalHandle hHal)
1537{
1538 eHalStatus status = eHAL_STATUS_FAILURE;
1539 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1540
1541 do
1542 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 status = csrStart(pMac);
1544 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001545 smsLog( pMac, LOGE, "csrStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 status );
1547 break;
1548 }
1549
1550 status = pmcStart(hHal);
1551 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001552 smsLog( pMac, LOGE, "pmcStart failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 status );
1554 break;
1555 }
1556
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 status = WLANSAP_Start(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
1558 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001559 smsLog( pMac, LOGE, "WLANSAP_Start failed during smeStart with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 status );
1561 break;
1562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 pMac->sme.state = SME_STATE_START;
1564 }while (0);
1565
1566 return status;
1567}
1568
1569
1570#ifdef WLAN_FEATURE_PACKET_FILTERING
1571/******************************************************************************
1572*
1573* Name: sme_PCFilterMatchCountResponseHandler
1574*
1575* Description:
1576* Invoke Packet Coalescing Filter Match Count callback routine
1577*
1578* Parameters:
1579* hHal - HAL handle for device
1580* pMsg - Pointer to tRcvFltPktMatchRsp structure
1581*
1582* Returns: eHalStatus
1583*
1584******************************************************************************/
1585eHalStatus sme_PCFilterMatchCountResponseHandler(tHalHandle hHal, void* pMsg)
1586{
1587 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1588 eHalStatus status = eHAL_STATUS_SUCCESS;
1589 tpSirRcvFltPktMatchRsp pRcvFltPktMatchRsp = (tpSirRcvFltPktMatchRsp)pMsg;
1590
1591 if (NULL == pMsg)
1592 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001593 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 status = eHAL_STATUS_FAILURE;
1595 }
1596 else
1597 {
1598 smsLog(pMac, LOG2, "SME: entering "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001599 "sme_FilterMatchCountResponseHandler");
Jeff Johnson295189b2012-06-20 16:38:30 -07001600
1601 /* Call Packet Coalescing Filter Match Count callback routine. */
1602 if (pMac->pmc.FilterMatchCountCB != NULL)
1603 pMac->pmc.FilterMatchCountCB(pMac->pmc.FilterMatchCountCBContext,
1604 pRcvFltPktMatchRsp);
1605
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001606 smsLog(pMac, LOG1, "%s: status=0x%x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 pRcvFltPktMatchRsp->status);
1608
1609 pMac->pmc.FilterMatchCountCB = NULL;
1610 pMac->pmc.FilterMatchCountCBContext = NULL;
1611 }
1612
1613 return(status);
1614}
1615#endif // WLAN_FEATURE_PACKET_FILTERING
1616
1617
Chet Lanctot186b5732013-03-18 10:26:30 -07001618#ifdef WLAN_FEATURE_11W
1619/*------------------------------------------------------------------
1620 *
1621 * Handle the unprotected management frame indication from LIM and
1622 * forward it to HDD.
1623 *
1624 *------------------------------------------------------------------*/
1625
1626eHalStatus sme_UnprotectedMgmtFrmInd( tHalHandle hHal,
1627 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1628{
1629 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1630 eHalStatus status = eHAL_STATUS_SUCCESS;
1631 tCsrRoamInfo pRoamInfo = {0};
1632 tANI_U32 SessionId = pSmeMgmtFrm->sessionId;
1633
1634 pRoamInfo.nFrameLength = pSmeMgmtFrm->frameLen;
1635 pRoamInfo.pbFrames = pSmeMgmtFrm->frameBuf;
1636 pRoamInfo.frameType = pSmeMgmtFrm->frameType;
1637
1638 /* forward the mgmt frame to HDD */
1639 csrRoamCallCallback(pMac, SessionId, &pRoamInfo, 0, eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1640
1641 return status;
1642}
1643#endif
1644
1645
Jeff Johnson295189b2012-06-20 16:38:30 -07001646/*--------------------------------------------------------------------------
1647
1648 \brief sme_ProcessMsg() - The main message processor for SME.
1649
1650 The function is called by a message dispatcher when to process a message
1651 targeted for SME.
1652
Srinivas Girigowdade697412013-02-14 16:31:48 -08001653 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 \param hHal - The handle returned by macOpen.
1655 \param pMsg - A pointer to a caller allocated object of tSirMsgQ.
1656
1657 \return eHAL_STATUS_SUCCESS - SME successfully process the message.
1658
1659 Other status means SME failed to process the message to HAL.
1660 \sa
1661
1662 --------------------------------------------------------------------------*/
1663eHalStatus sme_ProcessMsg(tHalHandle hHal, vos_msg_t* pMsg)
1664{
1665 eHalStatus status = eHAL_STATUS_FAILURE;
1666 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1667
1668 if (pMsg == NULL) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001669 smsLog( pMac, LOGE, "Empty message for SME, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 return status;
1671 }
1672
1673 status = sme_AcquireGlobalLock( &pMac->sme );
1674 if ( HAL_STATUS_SUCCESS( status ) )
1675 {
1676 if( SME_IS_START(pMac) )
1677 {
1678 switch (pMsg->type) { // TODO: Will be modified to do a range check for msgs instead of having cases for each msgs
1679 case eWNI_PMC_ENTER_BMPS_RSP:
1680 case eWNI_PMC_EXIT_BMPS_RSP:
1681 case eWNI_PMC_EXIT_BMPS_IND:
1682 case eWNI_PMC_ENTER_IMPS_RSP:
1683 case eWNI_PMC_EXIT_IMPS_RSP:
1684 case eWNI_PMC_SMPS_STATE_IND:
1685 case eWNI_PMC_ENTER_UAPSD_RSP:
1686 case eWNI_PMC_EXIT_UAPSD_RSP:
1687 case eWNI_PMC_ENTER_WOWL_RSP:
1688 case eWNI_PMC_EXIT_WOWL_RSP:
1689 //PMC
1690 if (pMsg->bodyptr)
1691 {
1692 pmcMessageProcessor(hHal, pMsg->bodyptr);
1693 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +05301694 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001696 smsLog( pMac, LOGE, "Empty rsp message for PMC, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 }
1698 break;
1699
1700 case WNI_CFG_SET_CNF:
1701 case WNI_CFG_DNLD_CNF:
1702 case WNI_CFG_GET_RSP:
1703 case WNI_CFG_ADD_GRP_ADDR_CNF:
1704 case WNI_CFG_DEL_GRP_ADDR_CNF:
1705 //CCM
1706 if (pMsg->bodyptr)
1707 {
1708 ccmCfgCnfMsgHandler(hHal, pMsg->bodyptr);
1709 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +05301710 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001712 smsLog( pMac, LOGE, "Empty rsp message for CCM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 }
1714 break;
1715
1716 case eWNI_SME_ADDTS_RSP:
1717 case eWNI_SME_DELTS_RSP:
1718 case eWNI_SME_DELTS_IND:
1719#ifdef WLAN_FEATURE_VOWIFI_11R
1720 case eWNI_SME_FT_AGGR_QOS_RSP:
1721#endif
1722 //QoS
1723 if (pMsg->bodyptr)
1724 {
1725#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1726 status = sme_QosMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05301727 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001728#endif
1729 } else {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001730 smsLog( pMac, LOGE, "Empty rsp message for QoS, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 }
1732 break;
1733#if defined WLAN_FEATURE_VOWIFI
1734 case eWNI_SME_NEIGHBOR_REPORT_IND:
1735 case eWNI_SME_BEACON_REPORT_REQ_IND:
1736#if defined WLAN_VOWIFI_DEBUG
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001737 smsLog( pMac, LOGE, "Received RRM message. Message Id = %d", pMsg->type );
Jeff Johnson295189b2012-06-20 16:38:30 -07001738#endif
1739 if ( pMsg->bodyptr )
1740 {
1741 status = sme_RrmMsgProcessor( pMac, pMsg->type, pMsg->bodyptr );
Kiet Lam64c1b492013-07-12 13:56:44 +05301742 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 }
1744 else
1745 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001746 smsLog( pMac, LOGE, "Empty message for RRM, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 }
1748 break;
1749#endif
1750
Jeff Johnsone7245742012-09-05 17:12:55 -07001751#ifdef FEATURE_OEM_DATA_SUPPORT
1752 //Handle the eWNI_SME_OEM_DATA_RSP:
1753 case eWNI_SME_OEM_DATA_RSP:
1754 if(pMsg->bodyptr)
1755 {
1756 status = sme_HandleOemDataRsp(pMac, pMsg->bodyptr);
1757 vos_mem_free(pMsg->bodyptr);
1758 }
1759 else
1760 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001761 smsLog( pMac, LOGE, "Empty rsp message for oemData_ (eWNI_SME_OEM_DATA_RSP), nothing to process");
Jeff Johnsone7245742012-09-05 17:12:55 -07001762 }
1763 smeProcessPendingQueue( pMac );
1764 break;
1765#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001766
1767 case eWNI_SME_ADD_STA_SELF_RSP:
1768 if(pMsg->bodyptr)
1769 {
1770 status = csrProcessAddStaSessionRsp(pMac, pMsg->bodyptr);
1771 vos_mem_free(pMsg->bodyptr);
1772 }
1773 else
1774 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001775 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ADD_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 }
1777 break;
1778 case eWNI_SME_DEL_STA_SELF_RSP:
1779 if(pMsg->bodyptr)
1780 {
1781 status = csrProcessDelStaSessionRsp(pMac, pMsg->bodyptr);
1782 vos_mem_free(pMsg->bodyptr);
1783 }
1784 else
1785 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001786 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_DEL_STA_SELF_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 }
1788 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 case eWNI_SME_REMAIN_ON_CHN_RSP:
1790 if(pMsg->bodyptr)
1791 {
1792 status = sme_remainOnChnRsp(pMac, pMsg->bodyptr);
1793 vos_mem_free(pMsg->bodyptr);
1794 }
1795 else
1796 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001797 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 }
1799 break;
1800 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
1801 if(pMsg->bodyptr)
1802 {
1803 status = sme_remainOnChnReady(pMac, pMsg->bodyptr);
1804 vos_mem_free(pMsg->bodyptr);
1805 }
1806 else
1807 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001808 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_REMAIN_ON_CHN_RDY_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 }
1810 break;
1811 case eWNI_SME_MGMT_FRM_IND:
1812 if(pMsg->bodyptr)
1813 {
1814 sme_mgmtFrmInd(pMac, pMsg->bodyptr);
1815 vos_mem_free(pMsg->bodyptr);
1816 }
1817 else
1818 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001819 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_MGMT_FRM_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 }
1821 break;
1822 case eWNI_SME_ACTION_FRAME_SEND_CNF:
1823 if(pMsg->bodyptr)
1824 {
1825 status = sme_sendActionCnf(pMac, pMsg->bodyptr);
1826 vos_mem_free(pMsg->bodyptr);
1827 }
1828 else
1829 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001830 smsLog( pMac, LOGE, "Empty rsp message for meas (eWNI_SME_ACTION_FRAME_SEND_CNF), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 }
1832 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 case eWNI_SME_COEX_IND:
1834 if(pMsg->bodyptr)
1835 {
1836 status = btcHandleCoexInd((void *)pMac, pMsg->bodyptr);
1837 vos_mem_free(pMsg->bodyptr);
1838 }
1839 else
1840 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001841 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 }
1843 break;
1844
1845#ifdef FEATURE_WLAN_SCAN_PNO
1846 case eWNI_SME_PREF_NETWORK_FOUND_IND:
1847 if(pMsg->bodyptr)
1848 {
1849 status = sme_PreferredNetworkFoundInd((void *)pMac, pMsg->bodyptr);
1850 vos_mem_free(pMsg->bodyptr);
1851 }
1852 else
1853 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001854 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_PREF_NETWORK_FOUND_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 }
1856 break;
1857#endif // FEATURE_WLAN_SCAN_PNO
1858
1859 case eWNI_SME_TX_PER_HIT_IND:
1860 if (pMac->sme.pTxPerHitCallback)
1861 {
1862 pMac->sme.pTxPerHitCallback(pMac->sme.pTxPerHitCbContext);
1863 }
1864 break;
1865
1866 case eWNI_SME_CHANGE_COUNTRY_CODE:
1867 if(pMsg->bodyptr)
1868 {
1869 status = sme_HandleChangeCountryCode((void *)pMac, pMsg->bodyptr);
1870 vos_mem_free(pMsg->bodyptr);
1871 }
1872 else
1873 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001874 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_COEX_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 }
1876 break;
1877
1878#ifdef WLAN_FEATURE_PACKET_FILTERING
1879 case eWNI_PMC_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP:
1880 if(pMsg->bodyptr)
1881 {
1882 status = sme_PCFilterMatchCountResponseHandler((void *)pMac, pMsg->bodyptr);
1883 vos_mem_free(pMsg->bodyptr);
1884 }
1885 else
1886 {
1887 smsLog(pMac, LOGE, "Empty rsp message for meas "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001888 "(PACKET_COALESCING_FILTER_MATCH_COUNT_RSP), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 }
1890 break;
1891#endif // WLAN_FEATURE_PACKET_FILTERING
1892 case eWNI_SME_PRE_SWITCH_CHL_IND:
1893 {
1894 status = sme_HandlePreChannelSwitchInd(pMac);
1895 break;
1896 }
1897
1898 case eWNI_SME_POST_SWITCH_CHL_IND:
1899 {
1900 status = sme_HandlePostChannelSwitchInd(pMac);
1901 break;
1902 }
1903
1904#ifdef WLAN_WAKEUP_EVENTS
1905 case eWNI_SME_WAKE_REASON_IND:
1906 if(pMsg->bodyptr)
1907 {
1908 status = sme_WakeReasonIndCallback((void *)pMac, pMsg->bodyptr);
1909 vos_mem_free(pMsg->bodyptr);
1910 }
1911 else
1912 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001913 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_WAKE_REASON_IND), nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 }
1915 break;
1916#endif // WLAN_WAKEUP_EVENTS
1917
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001918#ifdef FEATURE_WLAN_TDLS
1919 /*
1920 * command rescived from PE, SME tdls msg processor shall be called
1921 * to process commands recieved from PE
1922 */
1923 case eWNI_SME_TDLS_SEND_MGMT_RSP:
1924 case eWNI_SME_TDLS_ADD_STA_RSP:
Hoonki Leee6bfe942013-02-05 15:01:19 -08001925 case eWNI_SME_TDLS_DEL_STA_RSP:
1926 case eWNI_SME_TDLS_DEL_STA_IND:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08001927 case eWNI_SME_TDLS_DEL_ALL_PEER_IND:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08001928 case eWNI_SME_MGMT_FRM_TX_COMPLETION_IND:
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05301929 case eWNI_SME_TDLS_LINK_ESTABLISH_RSP:
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001930#ifdef FEATURE_WLAN_TDLS_INTERNAL
1931 case eWNI_SME_TDLS_DISCOVERY_START_RSP:
1932 case eWNI_SME_TDLS_DISCOVERY_START_IND:
1933 case eWNI_SME_TDLS_LINK_START_RSP:
1934 case eWNI_SME_TDLS_LINK_START_IND:
1935 case eWNI_SME_TDLS_TEARDOWN_RSP:
1936 case eWNI_SME_TDLS_TEARDOWN_IND:
1937 case eWNI_SME_ADD_TDLS_PEER_IND:
1938 case eWNI_SME_DELETE_TDLS_PEER_IND:
1939#endif
1940 {
1941 if (pMsg->bodyptr)
1942 {
1943 status = tdlsMsgProcessor(pMac, pMsg->type, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05301944 vos_mem_free(pMsg->bodyptr);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001945 }
1946 else
1947 {
1948 smsLog( pMac, LOGE, "Empty rsp message for TDLS, \
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001949 nothing to process");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08001950 }
1951 break;
1952 }
1953#endif
1954
Chet Lanctot186b5732013-03-18 10:26:30 -07001955#ifdef WLAN_FEATURE_11W
1956 case eWNI_SME_UNPROT_MGMT_FRM_IND:
1957 if (pMsg->bodyptr)
1958 {
1959 sme_UnprotectedMgmtFrmInd(pMac, pMsg->bodyptr);
1960 vos_mem_free(pMsg->bodyptr);
1961 }
1962 else
1963 {
1964 smsLog(pMac, LOGE, "Empty rsp message for meas (eWNI_SME_UNPROT_MGMT_FRM_IND), nothing to process");
1965 }
1966 break;
1967#endif
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001968#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1969 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
1970 status = csrRoamOffloadScanRspHdlr((void *)pMac, pMsg->bodyval);
1971 break;
1972#endif // WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Chet Lanctot186b5732013-03-18 10:26:30 -07001973
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301974#ifdef WLAN_FEATURE_GTK_OFFLOAD
1975 case eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP:
1976 if (pMsg->bodyptr)
1977 {
1978 sme_ProcessGetGtkInfoRsp(pMac, pMsg->bodyptr);
1979 vos_mem_free(pMsg->bodyptr);
1980 }
1981 else
1982 {
1983 smsLog(pMac, LOGE, "Empty rsp message for (eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP), nothing to process");
1984 }
1985 break ;
1986#endif
Leo Chang9056f462013-08-01 19:21:11 -07001987
1988#ifdef FEATURE_WLAN_LPHB
1989 /* LPHB timeout indication arrived, send IND to client */
Leo Changd9df8aa2013-09-26 13:32:26 -07001990 case eWNI_SME_LPHB_IND:
1991 if (pMac->sme.pLphbIndCb)
Leo Chang9056f462013-08-01 19:21:11 -07001992 {
Leo Changd9df8aa2013-09-26 13:32:26 -07001993 pMac->sme.pLphbIndCb(pMac->pAdapter, pMsg->bodyptr);
Leo Chang9056f462013-08-01 19:21:11 -07001994 }
1995 vos_mem_free(pMsg->bodyptr);
1996
1997 break;
1998#endif /* FEATURE_WLAN_LPHB */
1999
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 default:
2001
2002 if ( ( pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN )
2003 && ( pMsg->type <= eWNI_SME_MSG_TYPES_END ) )
2004 {
2005 //CSR
2006 if (pMsg->bodyptr)
2007 {
2008 status = csrMsgProcessor(hHal, pMsg->bodyptr);
Kiet Lam64c1b492013-07-12 13:56:44 +05302009 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 }
2011 else
2012 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002013 smsLog( pMac, LOGE, "Empty rsp message for CSR, nothing to process");
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 }
2015 }
2016 else
2017 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002018 smsLog( pMac, LOGW, "Unknown message type %d, nothing to process",
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 pMsg->type);
2020 if (pMsg->bodyptr)
2021 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302022 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 }
2024 }
2025 }//switch
2026 } //SME_IS_START
2027 else
2028 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002029 smsLog( pMac, LOGW, "message type %d in stop state ignored", pMsg->type);
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 if (pMsg->bodyptr)
2031 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302032 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 }
2034 }
2035 sme_ReleaseGlobalLock( &pMac->sme );
2036 }
2037 else
2038 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002039 smsLog( pMac, LOGW, "Locking failed, bailing out");
Jeff Johnson295189b2012-06-20 16:38:30 -07002040 if (pMsg->bodyptr)
2041 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302042 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 }
2044 }
2045
2046 return status;
2047}
2048
2049
2050//No need to hold the global lock here because this function can only be called
2051//after sme_Stop.
2052v_VOID_t sme_FreeMsg( tHalHandle hHal, vos_msg_t* pMsg )
2053{
2054 if( pMsg )
2055 {
2056 if (pMsg->bodyptr)
2057 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302058 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 }
2060 }
2061
2062}
2063
2064
2065/*--------------------------------------------------------------------------
2066
2067 \brief sme_Stop() - Stop all SME modules and put them at idle state
2068
2069 The function stops each module in SME, PMC, CCM, CSR, etc. . Upon
2070 return, all modules are at idle state ready to start.
2071
Srinivas Girigowdade697412013-02-14 16:31:48 -08002072 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 \param hHal - The handle returned by macOpen
2074
2075 \return eHAL_STATUS_SUCCESS - SME is stopped.
2076
2077 Other status means SME is failed to stop but caller should still
2078 consider SME is stopped.
2079 \sa
2080
2081 --------------------------------------------------------------------------*/
2082eHalStatus sme_Stop(tHalHandle hHal, tANI_BOOLEAN pmcFlag)
2083{
2084 eHalStatus status = eHAL_STATUS_FAILURE;
2085 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
2086 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2087
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 status = WLANSAP_Stop(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
2089 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002090 smsLog( pMac, LOGE, "WLANSAP_Stop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 status );
2092 fail_status = status;
2093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002094
2095 p2pStop(hHal);
2096
2097 if(pmcFlag)
2098 {
2099 status = pmcStop(hHal);
2100 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002101 smsLog( pMac, LOGE, "pmcStop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 status );
2103 fail_status = status;
2104 }
2105 }
2106
2107 status = csrStop(pMac);
2108 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002109 smsLog( pMac, LOGE, "csrStop failed during smeStop with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 status );
2111 fail_status = status;
2112 }
2113
2114 ccmStop(hHal);
2115
2116 purgeSmeCmdList(pMac);
2117
2118 if (!HAL_STATUS_SUCCESS( fail_status )) {
2119 status = fail_status;
2120 }
2121
2122 pMac->sme.state = SME_STATE_STOP;
2123
2124 return status;
2125}
2126
2127/*--------------------------------------------------------------------------
2128
2129 \brief sme_Close() - Release all SME modules and their resources.
2130
2131 The function release each module in SME, PMC, CCM, CSR, etc. . Upon
2132 return, all modules are at closed state.
2133
2134 No SME APIs can be involved after smeClose except smeOpen.
2135 smeClose must be called before macClose.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002136 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 \param hHal - The handle returned by macOpen
2138
2139 \return eHAL_STATUS_SUCCESS - SME is successfully close.
2140
2141 Other status means SME is failed to be closed but caller still cannot
2142 call any other SME functions except smeOpen.
2143 \sa
2144
2145 --------------------------------------------------------------------------*/
2146eHalStatus sme_Close(tHalHandle hHal)
2147{
2148 eHalStatus status = eHAL_STATUS_FAILURE;
2149 eHalStatus fail_status = eHAL_STATUS_SUCCESS;
2150 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2151
2152 status = csrClose(pMac);
2153 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002154 smsLog( pMac, LOGE, "csrClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 status );
2156 fail_status = status;
2157 }
2158
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 status = WLANSAP_Close(vos_get_global_context(VOS_MODULE_ID_SAP, NULL));
2160 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002161 smsLog( pMac, LOGE, "WLANSAP_close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 status );
2163 fail_status = status;
2164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002165
2166#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2167 status = btcClose(hHal);
2168 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002169 smsLog( pMac, LOGE, "BTC close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 status );
2171 fail_status = status;
2172 }
2173
2174 status = sme_QosClose(pMac);
2175 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002176 smsLog( pMac, LOGE, "Qos close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 status );
2178 fail_status = status;
2179 }
2180#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002181#ifdef FEATURE_OEM_DATA_SUPPORT
2182 status = oemData_OemDataReqClose(hHal);
2183 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002184 smsLog( pMac, LOGE, "OEM DATA REQ close failed during sme close with status=%d",
Jeff Johnsone7245742012-09-05 17:12:55 -07002185 status );
2186 fail_status = status;
2187 }
2188#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002189
2190 status = ccmClose(hHal);
2191 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002192 smsLog( pMac, LOGE, "ccmClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 status );
2194 fail_status = status;
2195 }
2196
2197 status = pmcClose(hHal);
2198 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002199 smsLog( pMac, LOGE, "pmcClose failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 status );
2201 fail_status = status;
2202 }
2203#if defined WLAN_FEATURE_VOWIFI
2204 status = rrmClose(hHal);
2205 if ( ! HAL_STATUS_SUCCESS( status ) ) {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002206 smsLog( pMac, LOGE, "RRM close failed during sme close with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 status );
2208 fail_status = status;
2209 }
2210#endif
2211
2212#if defined WLAN_FEATURE_VOWIFI_11R
2213 sme_FTClose(hHal);
2214#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 sme_p2pClose(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
2217 freeSmeCmdList(pMac);
2218
2219 if( !VOS_IS_STATUS_SUCCESS( vos_lock_destroy( &pMac->sme.lkSmeGlobalLock ) ) )
2220 {
2221 fail_status = eHAL_STATUS_FAILURE;
2222 }
2223
2224 if (!HAL_STATUS_SUCCESS( fail_status )) {
2225 status = fail_status;
2226 }
2227
2228 pMac->sme.state = SME_STATE_STOP;
2229
2230 return status;
2231}
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002232#ifdef FEATURE_WLAN_LFR
2233tANI_BOOLEAN csrIsScanAllowed(tpAniSirGlobal pMac)
2234{
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07002235#if 0
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002236 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
2237 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2238 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
2239 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
2240 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
2241 return eANI_BOOLEAN_FALSE;
2242 default:
2243 return eANI_BOOLEAN_TRUE;
2244 }
Madan Mohan Koyyalamudifb534bb2012-10-24 14:35:45 -07002245#else
2246 /*
2247 * TODO: always return TRUE for now until
2248 * we figure out why we could be stuck in
2249 * one of the roaming states forever.
2250 */
2251 return eANI_BOOLEAN_TRUE;
2252#endif
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002253}
2254#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002255/* ---------------------------------------------------------------------------
2256 \fn sme_ScanRequest
2257 \brief a wrapper function to Request a 11d or full scan from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002258 This is an asynchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 \param pScanRequestID - pointer to an object to get back the request ID
2260 \param callback - a callback function that scan calls upon finish, will not
2261 be called if csrScanRequest returns error
2262 \param pContext - a pointer passed in for the callback
2263 \return eHalStatus
2264 ---------------------------------------------------------------------------*/
2265eHalStatus sme_ScanRequest(tHalHandle hHal, tANI_U8 sessionId, tCsrScanRequest *pscanReq,
2266 tANI_U32 *pScanRequestID,
2267 csrScanCompleteCallback callback, void *pContext)
2268{
2269 eHalStatus status = eHAL_STATUS_FAILURE;
2270 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2271
2272 smsLog(pMac, LOG2, FL("enter"));
2273 do
2274 {
2275 if(pMac->scan.fScanEnable)
2276 {
2277 status = sme_AcquireGlobalLock( &pMac->sme );
2278 if ( HAL_STATUS_SUCCESS( status ) )
2279 {
2280 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002281#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002282 if(csrIsScanAllowed(pMac))
2283 {
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002284#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002285 status = csrScanRequest( hHal, sessionId, pscanReq,
2286 pScanRequestID, callback, pContext );
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002287#ifdef FEATURE_WLAN_LFR
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002288 }
2289 else
2290 {
Madan Mohan Koyyalamudiab4ab0d2012-10-24 14:26:50 -07002291 smsLog(pMac, LOGE, FL("Scan denied in state %d (sub-state %d)"),
2292 pMac->roam.neighborRoamInfo.neighborRoamState,
2293 pMac->roam.curSubState[sessionId]);
2294 /*HandOff is in progress. So schedule this scan later*/
2295 status = eHAL_STATUS_RESOURCES;
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07002296 }
2297#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 }
2299
2300 sme_ReleaseGlobalLock( &pMac->sme );
2301 } //sme_AcquireGlobalLock success
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002302 else
2303 {
2304 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 } //if(pMac->scan.fScanEnable)
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002307 else
2308 {
2309 smsLog(pMac, LOGE, FL("fScanEnable FALSE"));
2310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 } while( 0 );
2312
2313 return (status);
2314
2315
2316}
2317
2318/* ---------------------------------------------------------------------------
2319 \fn sme_ScanGetResult
2320 \brief a wrapper function to request scan results from CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002321 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 \param pFilter - If pFilter is NULL, all cached results are returned
2323 \param phResult - an object for the result.
2324 \return eHalStatus
2325 ---------------------------------------------------------------------------*/
2326eHalStatus sme_ScanGetResult(tHalHandle hHal, tANI_U8 sessionId, tCsrScanResultFilter *pFilter,
2327 tScanResultHandle *phResult)
2328{
2329 eHalStatus status = eHAL_STATUS_FAILURE;
2330 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2331
2332 smsLog(pMac, LOG2, FL("enter"));
2333 status = sme_AcquireGlobalLock( &pMac->sme );
2334 if ( HAL_STATUS_SUCCESS( status ) )
2335 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002336 status = csrScanGetResult( hHal, pFilter, phResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 sme_ReleaseGlobalLock( &pMac->sme );
2338 }
2339 smsLog(pMac, LOG2, FL("exit status %d"), status);
2340
2341 return (status);
2342}
2343
2344
2345/* ---------------------------------------------------------------------------
2346 \fn sme_ScanFlushResult
2347 \brief a wrapper function to request CSR to clear scan results.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002348 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 \return eHalStatus
2350 ---------------------------------------------------------------------------*/
2351eHalStatus sme_ScanFlushResult(tHalHandle hHal, tANI_U8 sessionId)
2352{
2353 eHalStatus status = eHAL_STATUS_FAILURE;
2354 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2355
2356 status = sme_AcquireGlobalLock( &pMac->sme );
2357 if ( HAL_STATUS_SUCCESS( status ) )
2358 {
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -07002359 status = csrScanFlushResult( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 sme_ReleaseGlobalLock( &pMac->sme );
2361 }
2362
2363 return (status);
2364}
2365
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002366eHalStatus sme_ScanFlushP2PResult(tHalHandle hHal, tANI_U8 sessionId)
2367{
2368 eHalStatus status = eHAL_STATUS_FAILURE;
2369 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2370
2371 status = sme_AcquireGlobalLock( &pMac->sme );
2372 if ( HAL_STATUS_SUCCESS( status ) )
2373 {
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302374 status = csrScanFlushSelectiveResult( hHal, VOS_TRUE );
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002375 sme_ReleaseGlobalLock( &pMac->sme );
2376 }
2377
2378 return (status);
2379}
Jeff Johnson295189b2012-06-20 16:38:30 -07002380
2381/* ---------------------------------------------------------------------------
2382 \fn sme_ScanResultGetFirst
2383 \brief a wrapper function to request CSR to returns the first element of
2384 scan result.
Srinivas Girigowdade697412013-02-14 16:31:48 -08002385 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 \param hScanResult - returned from csrScanGetResult
2387 \return tCsrScanResultInfo * - NULL if no result
2388 ---------------------------------------------------------------------------*/
2389tCsrScanResultInfo *sme_ScanResultGetFirst(tHalHandle hHal,
2390 tScanResultHandle hScanResult)
2391{
2392 eHalStatus status = eHAL_STATUS_FAILURE;
2393 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2394 tCsrScanResultInfo *pRet = NULL;
2395
2396 status = sme_AcquireGlobalLock( &pMac->sme );
2397 if ( HAL_STATUS_SUCCESS( status ) )
2398 {
2399 pRet = csrScanResultGetFirst( pMac, hScanResult );
2400 sme_ReleaseGlobalLock( &pMac->sme );
2401 }
2402
2403 return (pRet);
2404}
2405
2406
2407/* ---------------------------------------------------------------------------
2408 \fn sme_ScanResultGetNext
2409 \brief a wrapper function to request CSR to returns the next element of
2410 scan result. It can be called without calling csrScanResultGetFirst
2411 first
Srinivas Girigowdade697412013-02-14 16:31:48 -08002412 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 \param hScanResult - returned from csrScanGetResult
2414 \return Null if no result or reach the end
2415 ---------------------------------------------------------------------------*/
2416tCsrScanResultInfo *sme_ScanResultGetNext(tHalHandle hHal,
2417 tScanResultHandle hScanResult)
2418{
2419 eHalStatus status = eHAL_STATUS_FAILURE;
2420 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2421 tCsrScanResultInfo *pRet = NULL;
2422
2423 status = sme_AcquireGlobalLock( &pMac->sme );
2424 if ( HAL_STATUS_SUCCESS( status ) )
2425 {
2426 pRet = csrScanResultGetNext( pMac, hScanResult );
2427 sme_ReleaseGlobalLock( &pMac->sme );
2428 }
2429
2430 return (pRet);
2431}
2432
2433
2434/* ---------------------------------------------------------------------------
2435 \fn sme_ScanSetBGScanparams
2436 \brief a wrapper function to request CSR to set BG scan params in PE
Srinivas Girigowdade697412013-02-14 16:31:48 -08002437 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 \param pScanReq - BG scan request structure
2439 \return eHalStatus
2440 ---------------------------------------------------------------------------*/
2441eHalStatus sme_ScanSetBGScanparams(tHalHandle hHal, tANI_U8 sessionId, tCsrBGScanRequest *pScanReq)
2442{
2443 eHalStatus status = eHAL_STATUS_FAILURE;
2444 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2445
2446 if( NULL != pScanReq )
2447 {
2448 status = sme_AcquireGlobalLock( &pMac->sme );
2449 if ( HAL_STATUS_SUCCESS( status ) )
2450 {
2451 status = csrScanSetBGScanparams( hHal, pScanReq );
2452 sme_ReleaseGlobalLock( &pMac->sme );
2453 }
2454 }
2455
2456 return (status);
2457}
2458
2459
2460/* ---------------------------------------------------------------------------
2461 \fn sme_ScanResultPurge
2462 \brief a wrapper function to request CSR to remove all items(tCsrScanResult)
2463 in the list and free memory for each item
Srinivas Girigowdade697412013-02-14 16:31:48 -08002464 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 \param hScanResult - returned from csrScanGetResult. hScanResult is
2466 considered gone by
2467 calling this function and even before this function reutrns.
2468 \return eHalStatus
2469 ---------------------------------------------------------------------------*/
2470eHalStatus sme_ScanResultPurge(tHalHandle hHal, tScanResultHandle hScanResult)
2471{
2472 eHalStatus status = eHAL_STATUS_FAILURE;
2473 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2474
2475 status = sme_AcquireGlobalLock( &pMac->sme );
2476 if ( HAL_STATUS_SUCCESS( status ) )
2477 {
2478 status = csrScanResultPurge( hHal, hScanResult );
2479 sme_ReleaseGlobalLock( &pMac->sme );
2480 }
2481
2482 return (status);
2483}
2484
2485/* ---------------------------------------------------------------------------
2486 \fn sme_ScanGetPMKIDCandidateList
2487 \brief a wrapper function to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08002488 This is a synchronous call
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 \param pPmkidList - caller allocated buffer point to an array of
2490 tPmkidCandidateInfo
2491 \param pNumItems - pointer to a variable that has the number of
2492 tPmkidCandidateInfo allocated when retruning, this is
2493 either the number needed or number of items put into
2494 pPmkidList
2495 \return eHalStatus - when fail, it usually means the buffer allocated is not
2496 big enough and pNumItems
2497 has the number of tPmkidCandidateInfo.
2498 \Note: pNumItems is a number of tPmkidCandidateInfo,
2499 not sizeof(tPmkidCandidateInfo) * something
2500 ---------------------------------------------------------------------------*/
2501eHalStatus sme_ScanGetPMKIDCandidateList(tHalHandle hHal, tANI_U8 sessionId,
2502 tPmkidCandidateInfo *pPmkidList,
2503 tANI_U32 *pNumItems )
2504{
2505 eHalStatus status = eHAL_STATUS_FAILURE;
2506 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2507
2508 status = sme_AcquireGlobalLock( &pMac->sme );
2509 if ( HAL_STATUS_SUCCESS( status ) )
2510 {
2511 status = csrScanGetPMKIDCandidateList( pMac, sessionId, pPmkidList, pNumItems );
2512 sme_ReleaseGlobalLock( &pMac->sme );
2513 }
2514
2515 return (status);
2516}
2517
2518/*----------------------------------------------------------------------------
2519 \fn sme_RoamRegisterLinkQualityIndCallback
2520
2521 \brief
2522 a wrapper function to allow HDD to register a callback handler with CSR for
2523 link quality indications.
2524
2525 Only one callback may be registered at any time.
2526 In order to deregister the callback, a NULL cback may be provided.
2527
2528 Registration happens in the task context of the caller.
2529
2530 \param callback - Call back being registered
2531 \param pContext - user data
2532
2533 DEPENDENCIES: After CSR open
2534
2535 \return eHalStatus
2536-----------------------------------------------------------------------------*/
2537eHalStatus sme_RoamRegisterLinkQualityIndCallback(tHalHandle hHal, tANI_U8 sessionId,
2538 csrRoamLinkQualityIndCallback callback,
2539 void *pContext)
2540{
2541 return(csrRoamRegisterLinkQualityIndCallback((tpAniSirGlobal)hHal, callback, pContext));
2542}
2543
2544/* ---------------------------------------------------------------------------
2545 \fn sme_RoamRegisterCallback
2546 \brief a wrapper function to allow HDD to register a callback with CSR.
2547 Unlike scan, roam has one callback for all the roam requests
2548 \param callback - a callback function that roam calls upon when state changes
2549 \param pContext - a pointer passed in for the callback
2550 \return eHalStatus
2551 ---------------------------------------------------------------------------*/
2552eHalStatus sme_RoamRegisterCallback(tHalHandle hHal,
2553 csrRoamCompleteCallback callback,
2554 void *pContext)
2555{
2556 return(csrRoamRegisterCallback((tpAniSirGlobal)hHal, callback, pContext));
2557}
2558
2559eCsrPhyMode sme_GetPhyMode(tHalHandle hHal)
2560{
2561 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2562 return pMac->roam.configParam.phyMode;
2563}
2564
2565/* ---------------------------------------------------------------------------
2566 \fn sme_RoamConnect
2567 \brief a wrapper function to request CSR to inititiate an association
Srinivas Girigowdade697412013-02-14 16:31:48 -08002568 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 \param sessionId - the sessionId returned by sme_OpenSession.
2570 \param pProfile - description of the network to which to connect
2571 \param hBssListIn - a list of BSS descriptor to roam to. It is returned
2572 from csrScanGetResult
2573 \param pRoamId - to get back the request ID
2574 \return eHalStatus
2575 ---------------------------------------------------------------------------*/
2576eHalStatus sme_RoamConnect(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2577 tANI_U32 *pRoamId)
2578{
2579 eHalStatus status = eHAL_STATUS_FAILURE;
2580 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2581
2582 smsLog(pMac, LOG2, FL("enter"));
2583 status = sme_AcquireGlobalLock( &pMac->sme );
2584 if ( HAL_STATUS_SUCCESS( status ) )
2585 {
2586 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2587 {
2588 status = csrRoamConnect( pMac, sessionId, pProfile, NULL, pRoamId );
2589 }
2590 else
2591 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002592 smsLog(pMac, LOGE, FL("invalid sessionID %d"), sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 status = eHAL_STATUS_INVALID_PARAMETER;
2594 }
2595 sme_ReleaseGlobalLock( &pMac->sme );
2596 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002597 else
2598 {
2599 smsLog(pMac, LOGE, FL("sme_AcquireGlobalLock failed"));
2600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002601
2602 return (status);
2603}
2604
2605/* ---------------------------------------------------------------------------
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05302606
2607 \fn sme_SetPhyMode
2608
2609 \brief Changes the PhyMode.
2610
2611 \param hHal - The handle returned by macOpen.
2612
2613 \param phyMode new phyMode which is to set
2614
2615 \return eHalStatus SUCCESS.
2616
2617 -------------------------------------------------------------------------------*/
2618eHalStatus sme_SetPhyMode(tHalHandle hHal, eCsrPhyMode phyMode)
2619{
2620 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2621
2622 if (NULL == pMac)
2623 {
2624 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2625 "%s: invalid context", __func__);
2626 return eHAL_STATUS_FAILURE;
2627 }
2628
2629 pMac->roam.configParam.phyMode = phyMode;
2630 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL,
2631 pMac->roam.configParam.phyMode,
2632 pMac->roam.configParam.ProprietaryRatesEnabled);
2633
2634 return eHAL_STATUS_SUCCESS;
2635}
2636
2637/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07002638 \fn sme_RoamReassoc
2639 \brief a wrapper function to request CSR to inititiate a re-association
2640 \param pProfile - can be NULL to join the currently connected AP. In that
2641 case modProfileFields should carry the modified field(s) which could trigger
2642 reassoc
2643 \param modProfileFields - fields which are part of tCsrRoamConnectedProfile
2644 that might need modification dynamically once STA is up & running and this
2645 could trigger a reassoc
2646 \param pRoamId - to get back the request ID
2647 \return eHalStatus
2648 -------------------------------------------------------------------------------*/
2649eHalStatus sme_RoamReassoc(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamProfile *pProfile,
2650 tCsrRoamModifyProfileFields modProfileFields,
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002651 tANI_U32 *pRoamId, v_BOOL_t fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07002652{
2653 eHalStatus status = eHAL_STATUS_FAILURE;
2654 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2655
2656 smsLog(pMac, LOG2, FL("enter"));
2657 status = sme_AcquireGlobalLock( &pMac->sme );
2658 if ( HAL_STATUS_SUCCESS( status ) )
2659 {
2660 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2661 {
Madan Mohan Koyyalamudi0d0e1712012-10-21 12:02:45 -07002662 if((NULL == pProfile) && (fForce == 1))
2663 {
2664 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2665 /* to force the AP initiate fresh 802.1x authentication need to clear
2666 * the PMKID cache for that set the following boolean. this is needed
2667 * by the HS 2.0 passpoint certification 5.2.a and b testcases */
2668 pSession->fIgnorePMKIDCache = TRUE;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07002669 status = csrReassoc( pMac, sessionId, &modProfileFields, pRoamId , fForce);
2670 }
2671 else
2672 {
2673 status = csrRoamReassoc( pMac, sessionId, pProfile, modProfileFields, pRoamId );
2674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 }
2676 else
2677 {
2678 status = eHAL_STATUS_INVALID_PARAMETER;
2679 }
2680 sme_ReleaseGlobalLock( &pMac->sme );
2681 }
2682
2683 return (status);
2684}
2685
2686/* ---------------------------------------------------------------------------
2687 \fn sme_RoamConnectToLastProfile
2688 \brief a wrapper function to request CSR to disconnect and reconnect with
2689 the same profile
Srinivas Girigowdade697412013-02-14 16:31:48 -08002690 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 \return eHalStatus. It returns fail if currently connected
2692 ---------------------------------------------------------------------------*/
2693eHalStatus sme_RoamConnectToLastProfile(tHalHandle hHal, tANI_U8 sessionId)
2694{
2695 eHalStatus status = eHAL_STATUS_FAILURE;
2696 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2697
2698 status = sme_AcquireGlobalLock( &pMac->sme );
2699 if ( HAL_STATUS_SUCCESS( status ) )
2700 {
2701 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2702 {
2703 status = csrRoamConnectToLastProfile( pMac, sessionId );
2704 }
2705 else
2706 {
2707 status = eHAL_STATUS_INVALID_PARAMETER;
2708 }
2709 sme_ReleaseGlobalLock( &pMac->sme );
2710 }
2711
2712 return (status);
2713}
2714
2715/* ---------------------------------------------------------------------------
2716 \fn sme_RoamDisconnect
2717 \brief a wrapper function to request CSR to disconnect from a network
Srinivas Girigowdade697412013-02-14 16:31:48 -08002718 This is an asynchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 \param reason -- To indicate the reason for disconnecting. Currently, only
2720 eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
2721 \return eHalStatus
2722 ---------------------------------------------------------------------------*/
2723eHalStatus sme_RoamDisconnect(tHalHandle hHal, tANI_U8 sessionId, eCsrRoamDisconnectReason reason)
2724{
2725 eHalStatus status = eHAL_STATUS_FAILURE;
2726 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2727
2728 smsLog(pMac, LOG2, FL("enter"));
2729 status = sme_AcquireGlobalLock( &pMac->sme );
2730 if ( HAL_STATUS_SUCCESS( status ) )
2731 {
2732 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2733 {
2734 status = csrRoamDisconnect( pMac, sessionId, reason );
2735 }
2736 else
2737 {
2738 status = eHAL_STATUS_INVALID_PARAMETER;
2739 }
2740 sme_ReleaseGlobalLock( &pMac->sme );
2741 }
2742
2743 return (status);
2744}
2745
Jeff Johnson295189b2012-06-20 16:38:30 -07002746/* ---------------------------------------------------------------------------
2747 \fn sme_RoamStopBss
2748 \brief To stop BSS for Soft AP. This is an asynchronous API.
2749 \param hHal - Global structure
2750 \param sessionId - sessionId of SoftAP
2751 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2752 -------------------------------------------------------------------------------*/
2753eHalStatus sme_RoamStopBss(tHalHandle hHal, tANI_U8 sessionId)
2754{
2755 eHalStatus status = eHAL_STATUS_FAILURE;
2756 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2757
2758 smsLog(pMac, LOG2, FL("enter"));
2759 status = sme_AcquireGlobalLock( &pMac->sme );
2760 if ( HAL_STATUS_SUCCESS( status ) )
2761 {
2762 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2763 {
Gopichand Nakkalaf44bdc52013-02-16 00:54:45 +05302764 status = csrRoamIssueStopBssCmd( pMac, sessionId, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 }
2766 else
2767 {
2768 status = eHAL_STATUS_INVALID_PARAMETER;
2769 }
2770 sme_ReleaseGlobalLock( &pMac->sme );
2771 }
2772
2773 return (status);
2774}
2775
2776/* ---------------------------------------------------------------------------
2777 \fn sme_RoamDisconnectSta
2778 \brief To disassociate a station. This is an asynchronous API.
2779 \param hHal - Global structure
2780 \param sessionId - sessionId of SoftAP
2781 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2782 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2783 -------------------------------------------------------------------------------*/
2784eHalStatus sme_RoamDisconnectSta(tHalHandle hHal, tANI_U8 sessionId,
2785 tANI_U8 *pPeerMacAddr)
2786{
2787 eHalStatus status = eHAL_STATUS_FAILURE;
2788 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2789
2790 if ( NULL == pMac )
2791 {
2792 VOS_ASSERT(0);
2793 return status;
2794 }
2795
2796 status = sme_AcquireGlobalLock( &pMac->sme );
2797 if ( HAL_STATUS_SUCCESS( status ) )
2798 {
2799 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2800 {
2801 status = csrRoamIssueDisassociateStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302802 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 }
2804 else
2805 {
2806 status = eHAL_STATUS_INVALID_PARAMETER;
2807 }
2808 sme_ReleaseGlobalLock( &pMac->sme );
2809 }
2810
2811 return (status);
2812}
2813
2814/* ---------------------------------------------------------------------------
2815 \fn sme_RoamDeauthSta
2816 \brief To disassociate a station. This is an asynchronous API.
2817 \param hHal - Global structure
2818 \param sessionId - sessionId of SoftAP
2819 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2820 \return eHalStatus SUCCESS Roam callback will be called to indicate actual results
2821 -------------------------------------------------------------------------------*/
2822eHalStatus sme_RoamDeauthSta(tHalHandle hHal, tANI_U8 sessionId,
2823 tANI_U8 *pPeerMacAddr)
2824{
2825 eHalStatus status = eHAL_STATUS_FAILURE;
2826 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2827
2828 if ( NULL == pMac )
2829 {
2830 VOS_ASSERT(0);
2831 return status;
2832 }
2833
2834 status = sme_AcquireGlobalLock( &pMac->sme );
2835 if ( HAL_STATUS_SUCCESS( status ) )
2836 {
2837 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2838 {
2839 status = csrRoamIssueDeauthStaCmd( pMac, sessionId, pPeerMacAddr,
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302840 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 }
2842 else
2843 {
2844 status = eHAL_STATUS_INVALID_PARAMETER;
2845 }
2846 sme_ReleaseGlobalLock( &pMac->sme );
2847 }
2848
2849 return (status);
2850}
2851
2852/* ---------------------------------------------------------------------------
2853 \fn sme_RoamTKIPCounterMeasures
2854 \brief To start or stop TKIP counter measures. This is an asynchronous API.
2855 \param sessionId - sessionId of SoftAP
2856 \param pPeerMacAddr - Caller allocated memory filled with peer MAC address (6 bytes)
2857 \return eHalStatus
2858 -------------------------------------------------------------------------------*/
2859eHalStatus sme_RoamTKIPCounterMeasures(tHalHandle hHal, tANI_U8 sessionId,
2860 tANI_BOOLEAN bEnable)
2861{
2862 eHalStatus status = eHAL_STATUS_FAILURE;
2863 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2864
2865 if ( NULL == pMac )
2866 {
2867 VOS_ASSERT(0);
2868 return status;
2869 }
2870
2871 status = sme_AcquireGlobalLock( &pMac->sme );
2872 if ( HAL_STATUS_SUCCESS( status ) )
2873 {
2874 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2875 {
2876 status = csrRoamIssueTkipCounterMeasures( pMac, sessionId, bEnable);
2877 }
2878 else
2879 {
2880 status = eHAL_STATUS_INVALID_PARAMETER;
2881 }
2882 sme_ReleaseGlobalLock( &pMac->sme );
2883 }
2884
2885 return (status);
2886}
2887
2888/* ---------------------------------------------------------------------------
2889 \fn sme_RoamGetAssociatedStas
2890 \brief To probe the list of associated stations from various modules of CORE stack.
2891 \This is an asynchronous API.
2892 \param sessionId - sessionId of SoftAP
2893 \param modId - Module from whom list of associtated stations is to be probed.
2894 If an invalid module is passed then by default VOS_MODULE_ID_PE will be probed
2895 \param pUsrContext - Opaque HDD context
2896 \param pfnSapEventCallback - Sap event callback in HDD
2897 \param pAssocBuf - Caller allocated memory to be filled with associatd stations info
2898 \return eHalStatus
2899 -------------------------------------------------------------------------------*/
2900eHalStatus sme_RoamGetAssociatedStas(tHalHandle hHal, tANI_U8 sessionId,
2901 VOS_MODULE_ID modId, void *pUsrContext,
2902 void *pfnSapEventCallback, tANI_U8 *pAssocStasBuf)
2903{
2904 eHalStatus status = eHAL_STATUS_FAILURE;
2905 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2906
2907 if ( NULL == pMac )
2908 {
2909 VOS_ASSERT(0);
2910 return status;
2911 }
2912
2913 status = sme_AcquireGlobalLock( &pMac->sme );
2914 if ( HAL_STATUS_SUCCESS( status ) )
2915 {
2916 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2917 {
2918 status = csrRoamGetAssociatedStas( pMac, sessionId, modId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2919 }
2920 else
2921 {
2922 status = eHAL_STATUS_INVALID_PARAMETER;
2923 }
2924 sme_ReleaseGlobalLock( &pMac->sme );
2925 }
2926
2927 return (status);
2928}
2929
2930/* ---------------------------------------------------------------------------
2931 \fn sme_RoamGetWpsSessionOverlap
2932 \brief To get the WPS PBC session overlap information.
2933 \This is an asynchronous API.
2934 \param sessionId - sessionId of SoftAP
2935 \param pUsrContext - Opaque HDD context
2936 \param pfnSapEventCallback - Sap event callback in HDD
2937 \pRemoveMac - pointer to Mac address which needs to be removed from session
2938 \return eHalStatus
2939 -------------------------------------------------------------------------------*/
2940eHalStatus sme_RoamGetWpsSessionOverlap(tHalHandle hHal, tANI_U8 sessionId,
2941 void *pUsrContext, void
2942 *pfnSapEventCallback, v_MACADDR_t pRemoveMac)
2943{
2944 eHalStatus status = eHAL_STATUS_FAILURE;
2945 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2946
2947 if ( NULL == pMac )
2948 {
2949 VOS_ASSERT(0);
2950 return status;
2951 }
2952
2953 status = sme_AcquireGlobalLock( &pMac->sme );
2954 if ( HAL_STATUS_SUCCESS( status ) )
2955 {
2956 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2957 {
2958 status = csrRoamGetWpsSessionOverlap( pMac, sessionId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2959 }
2960 else
2961 {
2962 status = eHAL_STATUS_INVALID_PARAMETER;
2963 }
2964 sme_ReleaseGlobalLock( &pMac->sme );
2965 }
2966
2967 return (status);
2968}
2969
Jeff Johnson295189b2012-06-20 16:38:30 -07002970
2971/* ---------------------------------------------------------------------------
2972 \fn sme_RoamGetConnectState
2973 \brief a wrapper function to request CSR to return the current connect state
2974 of Roaming
Srinivas Girigowdade697412013-02-14 16:31:48 -08002975 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 \return eHalStatus
2977 ---------------------------------------------------------------------------*/
2978eHalStatus sme_RoamGetConnectState(tHalHandle hHal, tANI_U8 sessionId, eCsrConnectState *pState)
2979{
2980 eHalStatus status = eHAL_STATUS_FAILURE;
2981 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2982
2983 status = sme_AcquireGlobalLock( &pMac->sme );
2984 if ( HAL_STATUS_SUCCESS( status ) )
2985 {
2986 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
2987 {
2988 status = csrRoamGetConnectState( pMac, sessionId, pState );
2989 }
2990 else
2991 {
2992 status = eHAL_STATUS_INVALID_PARAMETER;
2993 }
2994 sme_ReleaseGlobalLock( &pMac->sme );
2995 }
2996
2997 return (status);
2998}
2999
3000/* ---------------------------------------------------------------------------
3001 \fn sme_RoamGetConnectProfile
3002 \brief a wrapper function to request CSR to return the current connect
3003 profile. Caller must call csrRoamFreeConnectProfile after it is done
3004 and before reuse for another csrRoamGetConnectProfile call.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003005 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 \param pProfile - pointer to a caller allocated structure
3007 tCsrRoamConnectedProfile
3008 \return eHalStatus. Failure if not connected
3009 ---------------------------------------------------------------------------*/
3010eHalStatus sme_RoamGetConnectProfile(tHalHandle hHal, tANI_U8 sessionId,
3011 tCsrRoamConnectedProfile *pProfile)
3012{
3013 eHalStatus status = eHAL_STATUS_FAILURE;
3014 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3015
3016 status = sme_AcquireGlobalLock( &pMac->sme );
3017 if ( HAL_STATUS_SUCCESS( status ) )
3018 {
3019 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3020 {
3021 status = csrRoamGetConnectProfile( pMac, sessionId, pProfile );
3022 }
3023 else
3024 {
3025 status = eHAL_STATUS_INVALID_PARAMETER;
3026 }
3027 sme_ReleaseGlobalLock( &pMac->sme );
3028 }
3029
3030 return (status);
3031}
3032
3033/* ---------------------------------------------------------------------------
3034 \fn sme_RoamFreeConnectProfile
3035 \brief a wrapper function to request CSR to free and reinitialize the
3036 profile returned previously by csrRoamGetConnectProfile.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003037 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 \param pProfile - pointer to a caller allocated structure
3039 tCsrRoamConnectedProfile
3040 \return eHalStatus.
3041 ---------------------------------------------------------------------------*/
3042eHalStatus sme_RoamFreeConnectProfile(tHalHandle hHal,
3043 tCsrRoamConnectedProfile *pProfile)
3044{
3045 eHalStatus status = eHAL_STATUS_FAILURE;
3046 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3047
3048 status = sme_AcquireGlobalLock( &pMac->sme );
3049 if ( HAL_STATUS_SUCCESS( status ) )
3050 {
3051 status = csrRoamFreeConnectProfile( pMac, pProfile );
3052 sme_ReleaseGlobalLock( &pMac->sme );
3053 }
3054
3055 return (status);
3056}
3057
3058/* ---------------------------------------------------------------------------
3059 \fn sme_RoamSetPMKIDCache
3060 \brief a wrapper function to request CSR to return the PMKID candidate list
Srinivas Girigowdade697412013-02-14 16:31:48 -08003061 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 \param pPMKIDCache - caller allocated buffer point to an array of
3063 tPmkidCacheInfo
3064 \param numItems - a variable that has the number of tPmkidCacheInfo
3065 allocated when retruning, this is either the number needed
3066 or number of items put into pPMKIDCache
3067 \return eHalStatus - when fail, it usually means the buffer allocated is not
3068 big enough and pNumItems has the number of
3069 tPmkidCacheInfo.
3070 \Note: pNumItems is a number of tPmkidCacheInfo,
3071 not sizeof(tPmkidCacheInfo) * something
3072 ---------------------------------------------------------------------------*/
3073eHalStatus sme_RoamSetPMKIDCache( tHalHandle hHal, tANI_U8 sessionId, tPmkidCacheInfo *pPMKIDCache,
3074 tANI_U32 numItems )
3075{
3076 eHalStatus status = eHAL_STATUS_FAILURE;
3077 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3078
3079 status = sme_AcquireGlobalLock( &pMac->sme );
3080 if ( HAL_STATUS_SUCCESS( status ) )
3081 {
3082 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3083 {
3084 status = csrRoamSetPMKIDCache( pMac, sessionId, pPMKIDCache, numItems );
3085 }
3086 else
3087 {
3088 status = eHAL_STATUS_INVALID_PARAMETER;
3089 }
3090 sme_ReleaseGlobalLock( &pMac->sme );
3091 }
3092
3093 return (status);
3094}
3095
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -07003096eHalStatus sme_RoamDelPMKIDfromCache( tHalHandle hHal, tANI_U8 sessionId, tANI_U8 *pBSSId )
3097{
3098 eHalStatus status = eHAL_STATUS_FAILURE;
3099 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3100 status = sme_AcquireGlobalLock( &pMac->sme );
3101 if ( HAL_STATUS_SUCCESS( status ) )
3102 {
3103 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3104 {
3105 status = csrRoamDelPMKIDfromCache( pMac, sessionId, pBSSId );
3106 }
3107 else
3108 {
3109 status = eHAL_STATUS_INVALID_PARAMETER;
3110 }
3111 sme_ReleaseGlobalLock( &pMac->sme );
3112 }
3113 return (status);
3114}
Jeff Johnson295189b2012-06-20 16:38:30 -07003115/* ---------------------------------------------------------------------------
3116 \fn sme_RoamGetSecurityReqIE
3117 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
3118 passes to PE to JOIN request or START_BSS request
Srinivas Girigowdade697412013-02-14 16:31:48 -08003119 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 \param pLen - caller allocated memory that has the length of pBuf as input.
3121 Upon returned, *pLen has the needed or IE length in pBuf.
3122 \param pBuf - Caller allocated memory that contain the IE field, if any,
3123 upon return
3124 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
3125 \return eHalStatus - when fail, it usually means the buffer allocated is not
3126 big enough
3127 ---------------------------------------------------------------------------*/
3128eHalStatus sme_RoamGetSecurityReqIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
3129 tANI_U8 *pBuf, eCsrSecurityType secType)
3130{
3131 eHalStatus status = eHAL_STATUS_FAILURE;
3132 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3133
3134 status = sme_AcquireGlobalLock( &pMac->sme );
3135 if ( HAL_STATUS_SUCCESS( status ) )
3136 {
3137 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3138 {
3139 status = csrRoamGetWpaRsnReqIE( hHal, sessionId, pLen, pBuf );
3140 }
3141 else
3142 {
3143 status = eHAL_STATUS_INVALID_PARAMETER;
3144 }
3145 sme_ReleaseGlobalLock( &pMac->sme );
3146 }
3147
3148 return (status);
3149}
3150
3151/* ---------------------------------------------------------------------------
3152 \fn sme_RoamGetSecurityRspIE
3153 \brief a wrapper function to request CSR to return the WPA or RSN or WAPI IE from
3154 the beacon or probe rsp if connected
Srinivas Girigowdade697412013-02-14 16:31:48 -08003155 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 \param pLen - caller allocated memory that has the length of pBuf as input.
3157 Upon returned, *pLen has the needed or IE length in pBuf.
3158 \param pBuf - Caller allocated memory that contain the IE field, if any,
3159 upon return
3160 \param secType - Specifies whether looking for WPA/WPA2/WAPI IE
3161 \return eHalStatus - when fail, it usually means the buffer allocated is not
3162 big enough
3163 ---------------------------------------------------------------------------*/
3164eHalStatus sme_RoamGetSecurityRspIE(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pLen,
3165 tANI_U8 *pBuf, eCsrSecurityType secType)
3166{
3167 eHalStatus status = eHAL_STATUS_FAILURE;
3168 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3169
3170 status = sme_AcquireGlobalLock( &pMac->sme );
3171 if ( HAL_STATUS_SUCCESS( status ) )
3172 {
3173 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3174 {
3175 status = csrRoamGetWpaRsnRspIE( pMac, sessionId, pLen, pBuf );
3176 }
3177 else
3178 {
3179 status = eHAL_STATUS_INVALID_PARAMETER;
3180 }
3181 sme_ReleaseGlobalLock( &pMac->sme );
3182 }
3183
3184 return (status);
3185
3186}
3187
3188
3189/* ---------------------------------------------------------------------------
3190 \fn sme_RoamGetNumPMKIDCache
3191 \brief a wrapper function to request CSR to return number of PMKID cache
3192 entries
Srinivas Girigowdade697412013-02-14 16:31:48 -08003193 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 \return tANI_U32 - the number of PMKID cache entries
3195 ---------------------------------------------------------------------------*/
3196tANI_U32 sme_RoamGetNumPMKIDCache(tHalHandle hHal, tANI_U8 sessionId)
3197{
3198 eHalStatus status = eHAL_STATUS_FAILURE;
3199 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3200 tANI_U32 numPmkidCache = 0;
3201
3202 status = sme_AcquireGlobalLock( &pMac->sme );
3203 if ( HAL_STATUS_SUCCESS( status ) )
3204 {
3205 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3206 {
3207 numPmkidCache = csrRoamGetNumPMKIDCache( pMac, sessionId );
3208 status = eHAL_STATUS_SUCCESS;
3209 }
3210 else
3211 {
3212 status = eHAL_STATUS_INVALID_PARAMETER;
3213 }
3214 sme_ReleaseGlobalLock( &pMac->sme );
3215 }
3216
3217 return (numPmkidCache);
3218}
3219
3220/* ---------------------------------------------------------------------------
3221 \fn sme_RoamGetPMKIDCache
3222 \brief a wrapper function to request CSR to return PMKID cache from CSR
Srinivas Girigowdade697412013-02-14 16:31:48 -08003223 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 \param pNum - caller allocated memory that has the space of the number of
3225 pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3226 needed or actually number in tPmkidCacheInfo.
3227 \param pPmkidCache - Caller allocated memory that contains PMKID cache, if
3228 any, upon return
3229 \return eHalStatus - when fail, it usually means the buffer allocated is not
3230 big enough
3231 ---------------------------------------------------------------------------*/
3232eHalStatus sme_RoamGetPMKIDCache(tHalHandle hHal, tANI_U8 sessionId, tANI_U32 *pNum,
3233 tPmkidCacheInfo *pPmkidCache)
3234{
3235 eHalStatus status = eHAL_STATUS_FAILURE;
3236 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3237
3238 status = sme_AcquireGlobalLock( &pMac->sme );
3239 if ( HAL_STATUS_SUCCESS( status ) )
3240 {
3241 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3242 {
3243 status = csrRoamGetPMKIDCache( pMac, sessionId, pNum, pPmkidCache );
3244 }
3245 else
3246 {
3247 status = eHAL_STATUS_INVALID_PARAMETER;
3248 }
3249 sme_ReleaseGlobalLock( &pMac->sme );
3250 }
3251
3252 return (status);
3253}
3254
3255
3256/* ---------------------------------------------------------------------------
3257 \fn sme_GetConfigParam
3258 \brief a wrapper function that HDD calls to get the global settings
3259 currently maintained by CSR.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003260 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 \param pParam - caller allocated memory
3262 \return eHalStatus
3263 ---------------------------------------------------------------------------*/
3264eHalStatus sme_GetConfigParam(tHalHandle hHal, tSmeConfigParams *pParam)
3265{
3266 eHalStatus status = eHAL_STATUS_FAILURE;
3267 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3268
3269 status = sme_AcquireGlobalLock( &pMac->sme );
3270 if ( HAL_STATUS_SUCCESS( status ) )
3271 {
3272 status = csrGetConfigParam(pMac, &pParam->csrConfig);
3273 if (status != eHAL_STATUS_SUCCESS)
3274 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003275 smsLog( pMac, LOGE, "%s csrGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 sme_ReleaseGlobalLock( &pMac->sme );
3277 return status;
3278 }
3279#if defined WLAN_FEATURE_P2P_INTERNAL
3280 status = p2pGetConfigParam(pMac, &pParam->p2pConfig);
3281 if (status != eHAL_STATUS_SUCCESS)
3282 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08003283 smsLog( pMac, LOGE, "%s p2pGetConfigParam failed", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 sme_ReleaseGlobalLock( &pMac->sme );
3285 return status;
3286 }
3287#endif
3288 sme_ReleaseGlobalLock( &pMac->sme );
3289 }
3290
3291 return (status);
3292}
3293
3294/* ---------------------------------------------------------------------------
3295 \fn sme_CfgSetInt
3296 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003297 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 \param cfgId - Configuration Parameter ID (type) for STA.
3299 \param ccmValue - The information related to Configuration Parameter ID
3300 which needs to be saved in CFG
3301 \param callback - To be registered by CSR with CCM. Once the CFG done with
3302 saving the information in the database, it notifies CCM &
3303 then the callback will be invoked to notify.
3304 \param toBeSaved - To save the request for future reference
3305 \return eHalStatus
3306 ---------------------------------------------------------------------------*/
3307eHalStatus sme_CfgSetInt(tHalHandle hHal, tANI_U32 cfgId, tANI_U32 ccmValue,
3308 tCcmCfgSetCallback callback, eAniBoolean toBeSaved)
3309{
3310 return(ccmCfgSetInt(hHal, cfgId, ccmValue, callback, toBeSaved));
3311}
3312
3313/* ---------------------------------------------------------------------------
3314 \fn sme_CfgSetStr
3315 \brief a wrapper function that HDD calls to set parameters in CFG.
Srinivas Girigowdade697412013-02-14 16:31:48 -08003316 This is a synchronous call.
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 \param cfgId - Configuration Parameter ID (type) for STA.
3318 \param pStr - Pointer to the byte array which carries the information needs
3319 to be saved in CFG
3320 \param length - Length of the data to be saved
3321 \param callback - To be registered by CSR with CCM. Once the CFG done with
3322 saving the information in the database, it notifies CCM &
3323 then the callback will be invoked to notify.
3324 \param toBeSaved - To save the request for future reference
3325 \return eHalStatus
3326 ---------------------------------------------------------------------------*/
3327eHalStatus sme_CfgSetStr(tHalHandle hHal, tANI_U32 cfgId, tANI_U8 *pStr,
3328 tANI_U32 length, tCcmCfgSetCallback callback,
3329 eAniBoolean toBeSaved)
3330{
3331 return(ccmCfgSetStr(hHal, cfgId, pStr, length, callback, toBeSaved));
3332}
3333
3334/* ---------------------------------------------------------------------------
3335 \fn sme_GetModifyProfileFields
3336 \brief HDD or SME - QOS calls this function to get the current values of
3337 connected profile fields, changing which can cause reassoc.
3338 This function must be called after CFG is downloaded and STA is in connected
3339 state. Also, make sure to call this function to get the current profile
3340 fields before calling the reassoc. So that pModifyProfileFields will have
3341 all the latest values plus the one(s) has been updated as part of reassoc
3342 request.
3343 \param pModifyProfileFields - pointer to the connected profile fields
3344 changing which can cause reassoc
3345
3346 \return eHalStatus
3347 -------------------------------------------------------------------------------*/
3348eHalStatus sme_GetModifyProfileFields(tHalHandle hHal, tANI_U8 sessionId,
3349 tCsrRoamModifyProfileFields * pModifyProfileFields)
3350{
3351 eHalStatus status = eHAL_STATUS_FAILURE;
3352 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3353
3354 status = sme_AcquireGlobalLock( &pMac->sme );
3355 if ( HAL_STATUS_SUCCESS( status ) )
3356 {
3357 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
3358 {
3359 status = csrGetModifyProfileFields(pMac, sessionId, pModifyProfileFields);
3360 }
3361 else
3362 {
3363 status = eHAL_STATUS_INVALID_PARAMETER;
3364 }
3365 sme_ReleaseGlobalLock( &pMac->sme );
3366 }
3367
3368 return (status);
3369}
3370
3371/*--------------------------------------------------------------------------
3372 \fn sme_SetConfigPowerSave
3373 \brief Wrapper fn to change power save configuration in SME (PMC) module.
3374 For BMPS related configuration, this function also updates the CFG
3375 and sends a message to FW to pick up the new values. Note: Calling
3376 this function only updates the configuration and does not enable
3377 the specified power save mode.
3378 \param hHal - The handle returned by macOpen.
3379 \param psMode - Power Saving mode being modified
3380 \param pConfigParams - a pointer to a caller allocated object of type
3381 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3382 \return eHalStatus
3383 --------------------------------------------------------------------------*/
3384eHalStatus sme_SetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3385 void *pConfigParams)
3386{
3387 eHalStatus status = eHAL_STATUS_FAILURE;
3388 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3389
3390 if (NULL == pConfigParams ) {
3391 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3392 "nothing to update");
3393 return eHAL_STATUS_FAILURE;
3394 }
3395
3396 status = sme_AcquireGlobalLock( &pMac->sme );
3397 if ( HAL_STATUS_SUCCESS( status ) )
3398 {
3399 status = pmcSetConfigPowerSave(hHal, psMode, pConfigParams);
3400 sme_ReleaseGlobalLock( &pMac->sme );
3401 }
3402
3403 return (status);
3404}
3405
3406/*--------------------------------------------------------------------------
3407 \fn sme_GetConfigPowerSave
3408 \brief Wrapper fn to retrieve power save configuration in SME (PMC) module
3409 \param hHal - The handle returned by macOpen.
3410 \param psMode - Power Saving mode
3411 \param pConfigParams - a pointer to a caller allocated object of type
3412 tPmcSmpsConfigParams or tPmcBmpsConfigParams or tPmcImpsConfigParams
3413 \return eHalStatus
3414 --------------------------------------------------------------------------*/
3415eHalStatus sme_GetConfigPowerSave(tHalHandle hHal, tPmcPowerSavingMode psMode,
3416 void *pConfigParams)
3417{
3418 eHalStatus status = eHAL_STATUS_FAILURE;
3419 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3420
3421 if (NULL == pConfigParams ) {
3422 smsLog( pMac, LOGE, "Empty config param structure for PMC, "
3423 "nothing to update");
3424 return eHAL_STATUS_FAILURE;
3425 }
3426
3427 status = sme_AcquireGlobalLock( &pMac->sme );
3428 if ( HAL_STATUS_SUCCESS( status ) )
3429 {
3430 status = pmcGetConfigPowerSave(hHal, psMode, pConfigParams);
3431 sme_ReleaseGlobalLock( &pMac->sme );
3432 }
3433
3434 return (status);
3435}
3436
3437/* ---------------------------------------------------------------------------
3438 \fn sme_SignalPowerEvent
3439 \brief Signals to PMC that a power event has occurred. Used for putting
3440 the chip into deep sleep mode.
3441 \param hHal - The handle returned by macOpen.
3442 \param event - the event that has occurred
3443 \return eHalStatus
3444 ---------------------------------------------------------------------------*/
3445eHalStatus sme_SignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
3446{
3447 eHalStatus status = eHAL_STATUS_FAILURE;
3448 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3449
3450 status = sme_AcquireGlobalLock( &pMac->sme );
3451 if ( HAL_STATUS_SUCCESS( status ) )
3452 {
3453 status = pmcSignalPowerEvent(hHal, event);
3454 sme_ReleaseGlobalLock( &pMac->sme );
3455 }
3456
3457 return (status);
3458}
3459
3460/* ---------------------------------------------------------------------------
3461 \fn sme_EnablePowerSave
3462 \brief Enables one of the power saving modes.
3463 \param hHal - The handle returned by macOpen.
3464 \param psMode - The power saving mode to enable. If BMPS mode is enabled
3465 while the chip is operating in Full Power, PMC will start
3466 a timer that will try to put the chip in BMPS mode after
3467 expiry.
3468 \return eHalStatus
3469 ---------------------------------------------------------------------------*/
3470eHalStatus sme_EnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3471{
3472 eHalStatus status = eHAL_STATUS_FAILURE;
3473 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3474
3475 status = sme_AcquireGlobalLock( &pMac->sme );
3476 if ( HAL_STATUS_SUCCESS( status ) )
3477 {
3478 status = pmcEnablePowerSave(hHal, psMode);
3479 sme_ReleaseGlobalLock( &pMac->sme );
3480 }
3481
3482 return (status);
3483}
3484
3485/* ---------------------------------------------------------------------------
3486 \fn sme_DisablePowerSave
3487 \brief Disables one of the power saving modes.
3488 \param hHal - The handle returned by macOpen.
3489 \param psMode - The power saving mode to disable. Disabling does not imply
3490 that device will be brought out of the current PS mode. This
3491 is purely a configuration API.
3492 \return eHalStatus
3493 ---------------------------------------------------------------------------*/
3494eHalStatus sme_DisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
3495{
3496 eHalStatus status = eHAL_STATUS_FAILURE;
3497 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3498
3499 status = sme_AcquireGlobalLock( &pMac->sme );
3500 if ( HAL_STATUS_SUCCESS( status ) )
3501 {
3502 status = pmcDisablePowerSave(hHal, psMode);
3503 sme_ReleaseGlobalLock( &pMac->sme );
3504 }
3505
3506 return (status);
3507 }
3508
3509/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +05303510+ \fn sme_SetHostPowerSave
3511+ \brief Enables BMPS logic to be controlled by User level apps
3512+ \param hHal - The handle returned by macOpen.
3513+ \param psMode - The power saving mode to disable. Disabling does not imply
3514+ that device will be brought out of the current PS mode. This
3515+ is purely a configuration API.
3516+ \return eHalStatus
3517+ ---------------------------------------------------------------------------*/
3518eHalStatus sme_SetHostPowerSave (tHalHandle hHal, v_BOOL_t psMode)
3519{
3520 eHalStatus status = eHAL_STATUS_FAILURE;
3521 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3522
3523 pMac->pmc.isHostPsEn = psMode;
3524
3525 return (status);
3526}
3527
3528/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 \fn sme_StartAutoBmpsTimer
3530 \brief Starts a timer that periodically polls all the registered
3531 module for entry into Bmps mode. This timer is started only if BMPS is
3532 enabled and whenever the device is in full power.
3533 \param hHal - The handle returned by macOpen.
3534 \return eHalStatus
3535 ---------------------------------------------------------------------------*/
3536eHalStatus sme_StartAutoBmpsTimer ( tHalHandle hHal)
3537{
3538 eHalStatus status = eHAL_STATUS_FAILURE;
3539 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3540
3541 status = sme_AcquireGlobalLock( &pMac->sme );
3542 if ( HAL_STATUS_SUCCESS( status ) )
3543 {
3544 status = pmcStartAutoBmpsTimer(hHal);
3545 sme_ReleaseGlobalLock( &pMac->sme );
3546 }
3547
3548 return (status);
3549}
3550/* ---------------------------------------------------------------------------
3551 \fn sme_StopAutoBmpsTimer
3552 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
3553 Stopping the timer does not cause a device state change. Only the timer
3554 is stopped. If "Full Power" is desired, use the sme_RequestFullPower API
3555 \param hHal - The handle returned by macOpen.
3556 \return eHalStatus
3557 ---------------------------------------------------------------------------*/
3558eHalStatus sme_StopAutoBmpsTimer ( tHalHandle hHal)
3559{
3560 eHalStatus status = eHAL_STATUS_FAILURE;
3561 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3562
3563 status = sme_AcquireGlobalLock( &pMac->sme );
3564 if ( HAL_STATUS_SUCCESS( status ) )
3565 {
3566 status = pmcStopAutoBmpsTimer(hHal);
3567 sme_ReleaseGlobalLock( &pMac->sme );
3568 }
3569
3570 return (status);
3571}
3572/* ---------------------------------------------------------------------------
3573 \fn sme_QueryPowerState
3574 \brief Returns the current power state of the device.
3575 \param hHal - The handle returned by macOpen.
3576 \param pPowerState - pointer to location to return power state (LOW or HIGH)
3577 \param pSwWlanSwitchState - ptr to location to return SW WLAN Switch state
3578 \return eHalStatus
3579 ---------------------------------------------------------------------------*/
3580eHalStatus sme_QueryPowerState (
3581 tHalHandle hHal,
3582 tPmcPowerState *pPowerState,
3583 tPmcSwitchState *pSwWlanSwitchState)
3584{
3585 eHalStatus status = eHAL_STATUS_FAILURE;
3586 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3587
3588 status = sme_AcquireGlobalLock( &pMac->sme );
3589 if ( HAL_STATUS_SUCCESS( status ) )
3590 {
3591 status = pmcQueryPowerState (hHal, pPowerState, NULL, pSwWlanSwitchState);
3592 sme_ReleaseGlobalLock( &pMac->sme );
3593 }
3594
3595 return (status);
3596}
3597
3598/* ---------------------------------------------------------------------------
3599 \fn sme_IsPowerSaveEnabled
3600 \brief Checks if the device is able to enter a particular power save mode
3601 This does not imply that the device is in a particular PS mode
3602 \param hHal - The handle returned by macOpen.
3603 \param psMode - the power saving mode
3604 \return eHalStatus
3605 ---------------------------------------------------------------------------*/
3606tANI_BOOLEAN sme_IsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
3607{
3608 eHalStatus status = eHAL_STATUS_FAILURE;
3609 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3610 tANI_BOOLEAN result = false;
3611
3612 status = sme_AcquireGlobalLock( &pMac->sme );
3613 if ( HAL_STATUS_SUCCESS( status ) )
3614 {
3615 result = pmcIsPowerSaveEnabled(hHal, psMode);
3616 sme_ReleaseGlobalLock( &pMac->sme );
3617 return result;
3618 }
3619
3620 return false;
3621}
3622
3623/* ---------------------------------------------------------------------------
3624 \fn sme_RequestFullPower
3625 \brief Request that the device be brought to full power state. When the
3626 device enters Full Power PMC will start a BMPS timer if BMPS PS mode
3627 is enabled. On timer expiry PMC will attempt to put the device in
3628 BMPS mode if following holds true:
3629 - BMPS mode is enabled
3630 - Polling of all modules through the Power Save Check routine passes
3631 - STA is associated to an access point
3632 \param hHal - The handle returned by macOpen.
3633 \param - callbackRoutine Callback routine invoked in case of success/failure
3634 \return eHalStatus - status
3635 eHAL_STATUS_SUCCESS - device brought to full power state
3636 eHAL_STATUS_FAILURE - device cannot be brought to full power state
3637 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
3638 ---------------------------------------------------------------------------*/
3639eHalStatus sme_RequestFullPower (
3640 tHalHandle hHal,
3641 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3642 void *callbackContext,
3643 tRequestFullPowerReason fullPowerReason)
3644{
3645 eHalStatus status = eHAL_STATUS_FAILURE;
3646 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3647
3648 status = sme_AcquireGlobalLock( &pMac->sme );
3649 if ( HAL_STATUS_SUCCESS( status ) )
3650 {
3651 status = pmcRequestFullPower(hHal, callbackRoutine, callbackContext, fullPowerReason);
3652 sme_ReleaseGlobalLock( &pMac->sme );
3653 }
3654
3655 return (status);
3656}
3657
3658/* ---------------------------------------------------------------------------
3659 \fn sme_RequestBmps
3660 \brief Request that the device be put in BMPS state. Request will be
3661 accepted only if BMPS mode is enabled and power save check routine
3662 passes.
3663 \param hHal - The handle returned by macOpen.
3664 \param - callbackRoutine Callback routine invoked in case of success/failure
3665 \return eHalStatus
3666 eHAL_STATUS_SUCCESS - device is in BMPS state
3667 eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
3668 eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state
3669 ---------------------------------------------------------------------------*/
3670eHalStatus sme_RequestBmps (
3671 tHalHandle hHal,
3672 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3673 void *callbackContext)
3674{
3675 eHalStatus status = eHAL_STATUS_FAILURE;
3676 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3677
3678 status = sme_AcquireGlobalLock( &pMac->sme );
3679 if ( HAL_STATUS_SUCCESS( status ) )
3680 {
3681 status = pmcRequestBmps(hHal, callbackRoutine, callbackContext);
3682 sme_ReleaseGlobalLock( &pMac->sme );
3683 }
3684
3685 return (status);
3686}
3687
3688
3689/* ---------------------------------------------------------------------------
3690 \fn sme_SetDHCPTillPowerActiveFlag
3691 \brief Sets/Clears DHCP related flag in PMC to disable/enable auto BMPS
3692 entry by PMC
3693 \param hHal - The handle returned by macOpen.
3694 ---------------------------------------------------------------------------*/
3695void sme_SetDHCPTillPowerActiveFlag(tHalHandle hHal, tANI_U8 flag)
3696{
3697 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3698
3699 // Set/Clear the DHCP flag which will disable/enable auto BMPS entery by PMC
3700 pMac->pmc.remainInPowerActiveTillDHCP = flag;
3701}
3702
3703
3704/* ---------------------------------------------------------------------------
3705 \fn sme_StartUapsd
3706 \brief Request that the device be put in UAPSD state. If the device is in
3707 Full Power it will be put in BMPS mode first and then into UAPSD
3708 mode.
3709 \param hHal - The handle returned by macOpen.
3710 \param - callbackRoutine Callback routine invoked in case of success/failure
3711 eHAL_STATUS_SUCCESS - device is in UAPSD state
3712 eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
3713 eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
3714 eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
3715 \return eHalStatus
3716 ---------------------------------------------------------------------------*/
3717eHalStatus sme_StartUapsd (
3718 tHalHandle hHal,
3719 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3720 void *callbackContext)
3721{
3722 eHalStatus status = eHAL_STATUS_FAILURE;
3723 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3724
3725 status = sme_AcquireGlobalLock( &pMac->sme );
3726 if ( HAL_STATUS_SUCCESS( status ) )
3727 {
3728 status = pmcStartUapsd(hHal, callbackRoutine, callbackContext);
3729 sme_ReleaseGlobalLock( &pMac->sme );
3730 }
3731
3732 return (status);
3733 }
3734
3735/* ---------------------------------------------------------------------------
3736 \fn sme_StopUapsd
3737 \brief Request that the device be put out of UAPSD state. Device will be
3738 put in in BMPS state after stop UAPSD completes.
3739 \param hHal - The handle returned by macOpen.
3740 \return eHalStatus
3741 eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
3742 eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
3743 ---------------------------------------------------------------------------*/
3744eHalStatus sme_StopUapsd (tHalHandle hHal)
3745{
3746 eHalStatus status = eHAL_STATUS_FAILURE;
3747 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3748
3749 status = sme_AcquireGlobalLock( &pMac->sme );
3750 if ( HAL_STATUS_SUCCESS( status ) )
3751 {
3752 status = pmcStopUapsd(hHal);
3753 sme_ReleaseGlobalLock( &pMac->sme );
3754 }
3755
3756 return (status);
3757}
3758
3759/* ---------------------------------------------------------------------------
3760 \fn sme_RequestStandby
3761 \brief Request that the device be put in standby. It is HDD's responsibility
3762 to bring the chip to full power and do a disassoc before calling
3763 this API.
3764 \param hHal - The handle returned by macOpen.
3765 \param - callbackRoutine Callback routine invoked in case of success/failure
3766 \return eHalStatus
3767 eHAL_STATUS_SUCCESS - device is in Standby mode
3768 eHAL_STATUS_FAILURE - device cannot be put in standby mode
3769 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
3770 ---------------------------------------------------------------------------*/
3771eHalStatus sme_RequestStandby (
3772 tHalHandle hHal,
3773 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
3774 void *callbackContext)
3775{
3776 eHalStatus status = eHAL_STATUS_FAILURE;
3777 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3778
3779 smsLog( pMac, LOG1, FL("") );
3780 status = sme_AcquireGlobalLock( &pMac->sme );
3781 if ( HAL_STATUS_SUCCESS( status ) )
3782 {
3783 status = pmcRequestStandby(hHal, callbackRoutine, callbackContext);
3784 sme_ReleaseGlobalLock( &pMac->sme );
3785 }
3786
3787 return (status);
3788}
3789
3790/* ---------------------------------------------------------------------------
3791 \fn sme_RegisterPowerSaveCheck
3792 \brief Register a power save check routine that is called whenever
3793 the device is about to enter one of the power save modes.
3794 \param hHal - The handle returned by macOpen.
3795 \param checkRoutine - Power save check routine to be registered
3796 \return eHalStatus
3797 eHAL_STATUS_SUCCESS - successfully registered
3798 eHAL_STATUS_FAILURE - not successfully registered
3799 ---------------------------------------------------------------------------*/
3800eHalStatus sme_RegisterPowerSaveCheck (
3801 tHalHandle hHal,
3802 tANI_BOOLEAN (*checkRoutine) (void *checkContext), void *checkContext)
3803{
3804 eHalStatus status = eHAL_STATUS_FAILURE;
3805 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3806
3807 status = sme_AcquireGlobalLock( &pMac->sme );
3808 if ( HAL_STATUS_SUCCESS( status ) )
3809 {
3810 status = pmcRegisterPowerSaveCheck (hHal, checkRoutine, checkContext);
3811 sme_ReleaseGlobalLock( &pMac->sme );
3812 }
3813
3814 return (status);
3815}
3816
3817/* ---------------------------------------------------------------------------
3818 \fn sme_DeregisterPowerSaveCheck
3819 \brief Deregister a power save check routine
3820 \param hHal - The handle returned by macOpen.
3821 \param checkRoutine - Power save check routine to be deregistered
3822 \return eHalStatus
3823 eHAL_STATUS_SUCCESS - successfully deregistered
3824 eHAL_STATUS_FAILURE - not successfully deregistered
3825 ---------------------------------------------------------------------------*/
3826eHalStatus sme_DeregisterPowerSaveCheck (
3827 tHalHandle hHal,
3828 tANI_BOOLEAN (*checkRoutine) (void *checkContext))
3829{
3830 eHalStatus status = eHAL_STATUS_FAILURE;
3831 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3832
3833 status = sme_AcquireGlobalLock( &pMac->sme );
3834 if ( HAL_STATUS_SUCCESS( status ) )
3835 {
3836 status = pmcDeregisterPowerSaveCheck (hHal, checkRoutine);
3837 sme_ReleaseGlobalLock( &pMac->sme );
3838 }
3839
3840 return (status);
3841}
3842
3843/* ---------------------------------------------------------------------------
3844 \fn sme_RegisterDeviceStateUpdateInd
3845 \brief Register a callback routine that is called whenever
3846 the device enters a new device state (Full Power, BMPS, UAPSD)
3847 \param hHal - The handle returned by macOpen.
3848 \param callbackRoutine - Callback routine to be registered
3849 \param callbackContext - Cookie to be passed back during callback
3850 \return eHalStatus
3851 eHAL_STATUS_SUCCESS - successfully registered
3852 eHAL_STATUS_FAILURE - not successfully registered
3853 ---------------------------------------------------------------------------*/
3854eHalStatus sme_RegisterDeviceStateUpdateInd (
3855 tHalHandle hHal,
3856 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
3857 void *callbackContext)
3858{
3859 eHalStatus status = eHAL_STATUS_FAILURE;
3860 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3861
3862 status = sme_AcquireGlobalLock( &pMac->sme );
3863 if ( HAL_STATUS_SUCCESS( status ) )
3864 {
3865 status = pmcRegisterDeviceStateUpdateInd (hHal, callbackRoutine, callbackContext);
3866 sme_ReleaseGlobalLock( &pMac->sme );
3867 }
3868
3869 return (status);
3870}
3871
3872/* ---------------------------------------------------------------------------
3873 \fn sme_DeregisterDeviceStateUpdateInd
3874 \brief Deregister a routine that was registered for device state changes
3875 \param hHal - The handle returned by macOpen.
3876 \param callbackRoutine - Callback routine to be deregistered
3877 \return eHalStatus
3878 eHAL_STATUS_SUCCESS - successfully deregistered
3879 eHAL_STATUS_FAILURE - not successfully deregistered
3880 ---------------------------------------------------------------------------*/
3881eHalStatus sme_DeregisterDeviceStateUpdateInd (
3882 tHalHandle hHal,
3883 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
3884{
3885 eHalStatus status = eHAL_STATUS_FAILURE;
3886 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3887
3888 status = sme_AcquireGlobalLock( &pMac->sme );
3889 if ( HAL_STATUS_SUCCESS( status ) )
3890 {
3891 status = pmcDeregisterDeviceStateUpdateInd (hHal, callbackRoutine);
3892 sme_ReleaseGlobalLock( &pMac->sme );
3893 }
3894
3895 return (status);
3896}
3897
3898/* ---------------------------------------------------------------------------
3899 \fn sme_WowlAddBcastPattern
3900 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
3901 do a pattern match on these patterns when Wowl is enabled during BMPS
3902 mode. Note that Firmware performs the pattern matching only on
3903 broadcast frames and while Libra is in BMPS mode.
3904 \param hHal - The handle returned by macOpen.
3905 \param pattern - Pattern to be added
3906 \return eHalStatus
3907 eHAL_STATUS_FAILURE Cannot add pattern
3908 eHAL_STATUS_SUCCESS Request accepted.
3909 ---------------------------------------------------------------------------*/
3910eHalStatus sme_WowlAddBcastPattern (
3911 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003912 tpSirWowlAddBcastPtrn pattern,
3913 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003914{
3915 eHalStatus status = eHAL_STATUS_FAILURE;
3916 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3917 status = sme_AcquireGlobalLock( &pMac->sme );
3918 if ( HAL_STATUS_SUCCESS( status ) )
3919 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003920 status = pmcWowlAddBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 sme_ReleaseGlobalLock( &pMac->sme );
3922 }
3923
3924 return (status);
3925}
3926
3927/* ---------------------------------------------------------------------------
3928 \fn sme_WowlDelBcastPattern
3929 \brief Delete a pattern that was added for Pattern Byte Matching.
3930 \param hHal - The handle returned by macOpen.
3931 \param pattern - Pattern to be deleted
3932 \return eHalStatus
3933 eHAL_STATUS_FAILURE Cannot delete pattern
3934 eHAL_STATUS_SUCCESS Request accepted.
3935 ---------------------------------------------------------------------------*/
3936eHalStatus sme_WowlDelBcastPattern (
3937 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003938 tpSirWowlDelBcastPtrn pattern,
3939 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003940{
3941 eHalStatus status = eHAL_STATUS_FAILURE;
3942 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3943 status = sme_AcquireGlobalLock( &pMac->sme );
3944 if ( HAL_STATUS_SUCCESS( status ) )
3945 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003946 status = pmcWowlDelBcastPattern (hHal, pattern, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 sme_ReleaseGlobalLock( &pMac->sme );
3948 }
3949
3950 return (status);
3951}
3952
3953/* ---------------------------------------------------------------------------
3954 \fn sme_EnterWowl
3955 \brief This is the SME API exposed to HDD to request enabling of WOWL mode.
3956 WoWLAN works on top of BMPS mode. If the device is not in BMPS mode,
3957 SME will will cache the information that WOWL has been enabled and
3958 attempt to put the device in BMPS. On entry into BMPS, SME will
3959 enable the WOWL mode.
3960 Note 1: If we exit BMPS mode (someone requests full power), we
3961 will NOT resume WOWL when we go back to BMPS again. Request for full
3962 power (while in WOWL mode) means disable WOWL and go to full power.
3963 Note 2: Both UAPSD and WOWL work on top of BMPS. On entry into BMPS, SME
3964 will give priority to UAPSD and enable only UAPSD if both UAPSD and WOWL
3965 are required. Currently there is no requirement or use case to support
3966 UAPSD and WOWL at the same time.
3967
3968 \param hHal - The handle returned by macOpen.
3969 \param enterWowlCallbackRoutine - Callback routine provided by HDD.
3970 Used for success/failure notification by SME
3971 \param enterWowlCallbackContext - A cookie passed by HDD, that is passed back to HDD
3972 at the time of callback.
3973 \param wakeReasonIndCB - Callback routine provided by HDD.
3974 Used for Wake Reason Indication by SME
3975 \param wakeReasonIndCBContext - A cookie passed by HDD, that is passed back to HDD
3976 at the time of callback.
3977 \return eHalStatus
3978 eHAL_STATUS_SUCCESS Device is already in WoWLAN mode
3979 eHAL_STATUS_FAILURE Device cannot enter WoWLAN mode.
3980 eHAL_STATUS_PMC_PENDING Request accepted. SME will enable WOWL after
3981 BMPS mode is entered.
3982 ---------------------------------------------------------------------------*/
3983eHalStatus sme_EnterWowl (
3984 tHalHandle hHal,
3985 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
3986 void *enterWowlCallbackContext,
3987#ifdef WLAN_WAKEUP_EVENTS
3988 void (*wakeIndicationCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
3989 void *wakeIndicationCBContext,
3990#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003991 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003992{
3993 eHalStatus status = eHAL_STATUS_FAILURE;
3994 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3995 status = sme_AcquireGlobalLock( &pMac->sme );
3996 if ( HAL_STATUS_SUCCESS( status ) )
3997 {
3998 status = pmcEnterWowl (hHal, enterWowlCallbackRoutine, enterWowlCallbackContext,
3999#ifdef WLAN_WAKEUP_EVENTS
4000 wakeIndicationCB, wakeIndicationCBContext,
4001#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004002 wowlEnterParams, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 sme_ReleaseGlobalLock( &pMac->sme );
4004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 return (status);
4006}
4007/* ---------------------------------------------------------------------------
4008 \fn sme_ExitWowl
4009 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
4010 SME will initiate exit from WoWLAN mode and device will be put in BMPS
4011 mode.
4012 \param hHal - The handle returned by macOpen.
4013 \return eHalStatus
4014 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
4015 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
4016 ---------------------------------------------------------------------------*/
4017eHalStatus sme_ExitWowl (tHalHandle hHal)
4018{
4019 eHalStatus status = eHAL_STATUS_FAILURE;
4020 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4021 status = sme_AcquireGlobalLock( &pMac->sme );
4022 if ( HAL_STATUS_SUCCESS( status ) )
4023 {
4024 status = pmcExitWowl (hHal);
4025 sme_ReleaseGlobalLock( &pMac->sme );
4026 }
4027
4028 return (status);
4029}
4030
4031/* ---------------------------------------------------------------------------
4032
4033 \fn sme_RoamSetKey
4034
4035 \brief To set encryption key. This function should be called only when connected
4036 This is an asynchronous API.
4037
4038 \param pSetKeyInfo - pointer to a caller allocated object of tCsrSetContextInfo
4039
4040 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
4041
4042 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
4043
4044 FAILURE or RESOURCES The API finished and failed.
4045
4046 -------------------------------------------------------------------------------*/
4047eHalStatus sme_RoamSetKey(tHalHandle hHal, tANI_U8 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 *pRoamId)
4048{
4049 eHalStatus status = eHAL_STATUS_FAILURE;
4050 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4051 tANI_U32 roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 tANI_U32 i;
4053 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004054
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07004055 if (pSetKey->keyLength > CSR_MAX_KEY_LEN)
4056 {
4057 smsLog(pMac, LOGE, FL("Invalid key length %d"), pSetKey->keyLength);
4058 return eHAL_STATUS_FAILURE;
4059 }
4060
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 status = sme_AcquireGlobalLock( &pMac->sme );
4062 if ( HAL_STATUS_SUCCESS( status ) )
4063 {
4064 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
4065 if(pRoamId)
4066 {
4067 *pRoamId = roamId;
4068 }
4069
Jeff Johnsonf89f4b52013-03-27 10:32:44 -07004070 smsLog(pMac, LOG2, FL("keyLength %d"), pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004071
4072 for(i=0; i<pSetKey->keyLength; i++)
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004073 smsLog(pMac, LOG2, FL("%02x"), pSetKey->Key[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004074
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004075 smsLog(pMac, LOG2, "\n sessionId=%d roamId=%d", sessionId, roamId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004076
4077 pSession = CSR_GET_SESSION(pMac, sessionId);
4078
Jeff Johnson32d95a32012-09-10 13:15:23 -07004079 if(!pSession)
4080 {
4081 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08004082 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004083 return eHAL_STATUS_FAILURE;
4084 }
4085
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
4087 {
4088 if(pSetKey->keyDirection == eSIR_TX_DEFAULT)
4089 {
4090 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
4091 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ))
4092 {
4093 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4094 }
4095 if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
4096 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ))
4097 {
4098 pSession->pCurRoamProfile->negotiatedUCEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4099 }
4100 }
4101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004102
4103 status = csrRoamSetKey ( pMac, sessionId, pSetKey, roamId );
4104 sme_ReleaseGlobalLock( &pMac->sme );
4105 }
4106
4107 return (status);
4108}
4109
4110
4111/* ---------------------------------------------------------------------------
4112
4113 \fn sme_RoamRemoveKey
4114
4115 \brief To set encryption key. This is an asynchronous API.
4116
4117 \param pRemoveKey - pointer to a caller allocated object of tCsrRoamRemoveKey
4118
4119 \param pRoamId Upon success return, this is the id caller can use to identify the request in roamcallback
4120
4121 \return eHalStatus SUCCESS Roam callback will be called indicate actually results
4122
4123 FAILURE or RESOURCES The API finished and failed.
4124
4125 -------------------------------------------------------------------------------*/
4126eHalStatus sme_RoamRemoveKey(tHalHandle hHal, tANI_U8 sessionId,
4127 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 *pRoamId)
4128{
4129 eHalStatus status = eHAL_STATUS_FAILURE;
4130 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4131 tANI_U32 roamId;
4132
4133 status = sme_AcquireGlobalLock( &pMac->sme );
4134 if ( HAL_STATUS_SUCCESS( status ) )
4135 {
4136 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
4137 if(pRoamId)
4138 {
4139 *pRoamId = roamId;
4140 }
4141 status = csrRoamIssueRemoveKeyCommand( pMac, sessionId, pRemoveKey, roamId );
4142 sme_ReleaseGlobalLock( &pMac->sme );
4143 }
4144
4145 return (status);
4146}
4147
4148/* ---------------------------------------------------------------------------
4149 \fn sme_GetRssi
4150 \brief a wrapper function that client calls to register a callback to get RSSI
4151
4152 \param callback - SME sends back the requested stats using the callback
4153 \param staId - The station ID for which the stats is requested for
4154 \param pContext - user context to be passed back along with the callback
4155 \param pVosContext - vos context
4156 \return eHalStatus
4157 ---------------------------------------------------------------------------*/
4158eHalStatus sme_GetRssi(tHalHandle hHal,
4159 tCsrRssiCallback callback,
4160 tANI_U8 staId, tCsrBssid bssId,
4161 void *pContext, void* pVosContext)
4162{
4163 eHalStatus status = eHAL_STATUS_FAILURE;
4164 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4165
4166 status = sme_AcquireGlobalLock( &pMac->sme );
4167 if ( HAL_STATUS_SUCCESS( status ) )
4168 {
4169 status = csrGetRssi( pMac, callback,
4170 staId, bssId, pContext, pVosContext);
4171 sme_ReleaseGlobalLock( &pMac->sme );
4172 }
4173 return (status);
4174}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05304175
4176/* ---------------------------------------------------------------------------
4177 \fn sme_GetSnr
4178 \brief a wrapper function that client calls to register a callback to
4179 get SNR
4180
4181 \param callback - SME sends back the requested stats using the callback
4182 \param staId - The station ID for which the stats is requested for
4183 \param pContext - user context to be passed back along with the callback
4184 \param pVosContext - vos context
4185 \return eHalStatus
4186 ---------------------------------------------------------------------------*/
4187eHalStatus sme_GetSnr(tHalHandle hHal,
4188 tCsrSnrCallback callback,
4189 tANI_U8 staId, tCsrBssid bssId,
4190 void *pContext)
4191{
4192 eHalStatus status = eHAL_STATUS_FAILURE;
4193 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4194
4195 status = sme_AcquireGlobalLock( &pMac->sme );
4196 if ( HAL_STATUS_SUCCESS( status ) )
4197 {
4198 status = csrGetSnr(pMac, callback,
4199 staId, bssId, pContext);
4200 sme_ReleaseGlobalLock( &pMac->sme );
4201 }
4202 return status;
4203}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004204#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4205/* ---------------------------------------------------------------------------
4206 \fn sme_GetRoamRssi
4207 \brief a wrapper function that client calls to register a callback to get Roam RSSI
4208
4209 \param callback - SME sends back the requested stats using the callback
4210 \param staId - The station ID for which the stats is requested for
4211 \param pContext - user context to be passed back along with the callback
4212 \param pVosContext - vos context
4213 \return eHalStatus
4214 ---------------------------------------------------------------------------*/
4215eHalStatus sme_GetRoamRssi(tHalHandle hHal,
4216 tCsrRssiCallback callback,
4217 tANI_U8 staId, tCsrBssid bssId,
4218 void *pContext, void* pVosContext)
4219{
4220 eHalStatus status = eHAL_STATUS_FAILURE;
4221 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4222
4223 status = sme_AcquireGlobalLock( &pMac->sme );
4224 if ( HAL_STATUS_SUCCESS( status ) )
4225 {
4226 status = csrGetRoamRssi( pMac, callback,
4227 staId, bssId, pContext, pVosContext);
4228 sme_ReleaseGlobalLock( &pMac->sme );
4229 }
4230 return (status);
4231}
4232#endif
4233
Jeff Johnson295189b2012-06-20 16:38:30 -07004234
4235/* ---------------------------------------------------------------------------
4236 \fn sme_GetStatistics
4237 \brief a wrapper function that client calls to register a callback to get
4238 different PHY level statistics from CSR.
4239
4240 \param requesterId - different client requesting for statistics, HDD, UMA/GAN etc
4241 \param statsMask - The different category/categories of stats requester is looking for
4242 \param callback - SME sends back the requested stats using the callback
4243 \param periodicity - If requester needs periodic update in millisec, 0 means
4244 it's an one time request
4245 \param cache - If requester is happy with cached stats
4246 \param staId - The station ID for which the stats is requested for
4247 \param pContext - user context to be passed back along with the callback
4248 \return eHalStatus
4249 ---------------------------------------------------------------------------*/
4250eHalStatus sme_GetStatistics(tHalHandle hHal, eCsrStatsRequesterType requesterId,
4251 tANI_U32 statsMask,
4252 tCsrStatsCallback callback,
4253 tANI_U32 periodicity, tANI_BOOLEAN cache,
4254 tANI_U8 staId, void *pContext)
4255{
4256 eHalStatus status = eHAL_STATUS_FAILURE;
4257 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4258
4259 status = sme_AcquireGlobalLock( &pMac->sme );
4260 if ( HAL_STATUS_SUCCESS( status ) )
4261 {
4262 status = csrGetStatistics( pMac, requesterId , statsMask, callback,
4263 periodicity, cache, staId, pContext);
4264 sme_ReleaseGlobalLock( &pMac->sme );
4265 }
4266
4267 return (status);
4268
4269}
4270
4271/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +05304272 \fn smeGetTLSTAState
4273 \helper function to get the TL STA State whenever the function is called.
4274
4275 \param staId - The staID to be passed to the TL
4276 to get the relevant TL STA State
4277 \return the state as tANI_U16
4278 ---------------------------------------------------------------------------*/
4279tANI_U16 smeGetTLSTAState(tHalHandle hHal, tANI_U8 staId)
4280{
4281 tANI_U16 tlSTAState = TL_INIT_STATE;
4282 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4283 eHalStatus status = eHAL_STATUS_FAILURE;
4284
4285 status = sme_AcquireGlobalLock( &pMac->sme );
4286 if ( HAL_STATUS_SUCCESS( status ) )
4287 {
4288 tlSTAState = csrGetTLSTAState( pMac, staId);
4289 sme_ReleaseGlobalLock( &pMac->sme );
4290 }
4291
4292 return tlSTAState;
4293}
4294
4295/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07004296
4297 \fn sme_GetCountryCode
4298
4299 \brief To return the current country code. If no country code is applied, default country code is
4300 used to fill the buffer.
4301 If 11d supported is turned off, an error is return and the last applied/default country code is used.
4302 This is a synchronous API.
4303
4304 \param pBuf - pointer to a caller allocated buffer for returned country code.
4305
4306 \param pbLen For input, this parameter indicates how big is the buffer.
4307 Upon return, this parameter has the number of bytes for country. If pBuf
4308 doesn't have enough space, this function returns
4309 fail status and this parameter contains the number that is needed.
4310
4311 \return eHalStatus SUCCESS.
4312
4313 FAILURE or RESOURCES The API finished and failed.
4314
4315 -------------------------------------------------------------------------------*/
4316eHalStatus sme_GetCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U8 *pbLen)
4317{
4318 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4319
4320 return ( csrGetCountryCode( pMac, pBuf, pbLen ) );
4321}
4322
4323
4324/* ---------------------------------------------------------------------------
4325
4326 \fn sme_SetCountryCode
4327
4328 \brief To change the current/default country code.
4329 If 11d supported is turned off, an error is return.
4330 This is a synchronous API.
4331
4332 \param pCountry - pointer to a caller allocated buffer for the country code.
4333
4334 \param pfRestartNeeded A pointer to caller allocated memory, upon successful return, it indicates
4335 whether a reset is required.
4336
4337 \return eHalStatus SUCCESS.
4338
4339 FAILURE or RESOURCES The API finished and failed.
4340
4341 -------------------------------------------------------------------------------*/
4342eHalStatus sme_SetCountryCode(tHalHandle hHal, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
4343{
4344 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4345
4346 return ( csrSetCountryCode( pMac, pCountry, pfRestartNeeded ) );
4347}
4348
4349
4350/* ---------------------------------------------------------------------------
4351 \fn sme_ResetCountryCodeInformation
4352 \brief this function is to reset the country code current being used back to EEPROM default
4353 this includes channel list and power setting. This is a synchronous API.
4354 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
4355 a restart is needed to apply the change
4356 \return eHalStatus
4357 -------------------------------------------------------------------------------*/
4358eHalStatus sme_ResetCountryCodeInformation(tHalHandle hHal, tANI_BOOLEAN *pfRestartNeeded)
4359{
4360 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4361
4362 return ( csrResetCountryCodeInformation( pMac, pfRestartNeeded ) );
4363}
4364
4365
4366/* ---------------------------------------------------------------------------
4367 \fn sme_GetSupportedCountryCode
4368 \brief this function is to get a list of the country code current being supported
4369 \param pBuf - Caller allocated buffer with at least 3 bytes, upon success return,
4370 this has the country code list. 3 bytes for each country code. This may be NULL if
4371 caller wants to know the needed byte count.
4372 \param pbLen - Caller allocated, as input, it indicates the length of pBuf. Upon success return,
4373 this contains the length of the data in pBuf. If pbuf is NULL, as input, *pbLen should be 0.
4374 \return eHalStatus
4375 -------------------------------------------------------------------------------*/
4376eHalStatus sme_GetSupportedCountryCode(tHalHandle hHal, tANI_U8 *pBuf, tANI_U32 *pbLen)
4377{
4378 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4379
4380 return ( csrGetSupportedCountryCode( pMac, pBuf, pbLen ) );
4381}
4382
4383
4384/* ---------------------------------------------------------------------------
4385 \fn sme_GetCurrentRegulatoryDomain
4386 \brief this function is to get the current regulatory domain. This is a synchronous API.
4387 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4388 SME. The function fails if 11d support is turned off.
4389 \param pDomain - Caller allocated buffer to return the current domain.
4390 \return eHalStatus SUCCESS.
4391
4392 FAILURE or RESOURCES The API finished and failed.
4393 -------------------------------------------------------------------------------*/
4394eHalStatus sme_GetCurrentRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t *pDomain)
4395{
4396 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4397 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4398
4399 if( pDomain )
4400 {
4401 if( csrIs11dSupported( pMac ) )
4402 {
4403 *pDomain = csrGetCurrentRegulatoryDomain( pMac );
4404 status = eHAL_STATUS_SUCCESS;
4405 }
4406 else
4407 {
4408 status = eHAL_STATUS_FAILURE;
4409 }
4410 }
4411
4412 return ( status );
4413}
4414
4415
4416/* ---------------------------------------------------------------------------
4417 \fn sme_SetRegulatoryDomain
4418 \brief this function is to set the current regulatory domain.
4419 This function must be called after CFG is downloaded and all the band/mode setting already passed into
4420 SME. This is a synchronous API.
4421 \param domainId - indicate the domain (defined in the driver) needs to set to.
4422 See v_REGDOMAIN_t for definition
4423 \param pfRestartNeeded - pointer to a caller allocated space. Upon successful return, it indicates whether
4424 a restart is needed to apply the change
4425 \return eHalStatus
4426 -------------------------------------------------------------------------------*/
4427eHalStatus sme_SetRegulatoryDomain(tHalHandle hHal, v_REGDOMAIN_t domainId, tANI_BOOLEAN *pfRestartNeeded)
4428{
4429 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4430
4431 return ( csrSetRegulatoryDomain( pMac, domainId, pfRestartNeeded ) );
4432}
4433
4434
4435/* ---------------------------------------------------------------------------
4436
4437 \fn sme_GetRegulatoryDomainForCountry
4438
4439 \brief To return a regulatory domain base on a country code. This is a synchronous API.
4440
4441 \param pCountry - pointer to a caller allocated buffer for input country code.
4442
4443 \param pDomainId Upon successful return, it is the domain that country belongs to.
4444 If it is NULL, returning success means that the country code is known.
4445
4446 \return eHalStatus SUCCESS.
4447
4448 FAILURE or RESOURCES The API finished and failed.
4449
4450 -------------------------------------------------------------------------------*/
4451eHalStatus sme_GetRegulatoryDomainForCountry(tHalHandle hHal, tANI_U8 *pCountry, v_REGDOMAIN_t *pDomainId)
4452{
4453 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4454
4455 return ( csrGetRegulatoryDomainForCountry( pMac, pCountry, pDomainId ) );
4456}
4457
4458
4459
4460
4461/* ---------------------------------------------------------------------------
4462
4463 \fn sme_GetSupportedRegulatoryDomains
4464
4465 \brief To return a list of supported regulatory domains. This is a synchronous API.
4466
4467 \param pDomains - pointer to a caller allocated buffer for returned regulatory domains.
4468
4469 \param pNumDomains For input, this parameter indicates howm many domains pDomains can hold.
4470 Upon return, this parameter has the number for supported domains. If pDomains
4471 doesn't have enough space for all the supported domains, this function returns
4472 fail status and this parameter contains the number that is needed.
4473
4474 \return eHalStatus SUCCESS.
4475
4476 FAILURE or RESOURCES The API finished and failed.
4477
4478 -------------------------------------------------------------------------------*/
4479eHalStatus sme_GetSupportedRegulatoryDomains(tHalHandle hHal, v_REGDOMAIN_t *pDomains, tANI_U32 *pNumDomains)
4480{
4481 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
4482
4483 //We support all domains for now
4484 if( pNumDomains )
4485 {
4486 if( NUM_REG_DOMAINS <= *pNumDomains )
4487 {
4488 status = eHAL_STATUS_SUCCESS;
4489 }
4490 *pNumDomains = NUM_REG_DOMAINS;
4491 }
4492 if( HAL_STATUS_SUCCESS( status ) )
4493 {
4494 if( pDomains )
4495 {
4496 pDomains[0] = REGDOMAIN_FCC;
4497 pDomains[1] = REGDOMAIN_ETSI;
4498 pDomains[2] = REGDOMAIN_JAPAN;
4499 pDomains[3] = REGDOMAIN_WORLD;
4500 pDomains[4] = REGDOMAIN_N_AMER_EXC_FCC;
4501 pDomains[5] = REGDOMAIN_APAC;
4502 pDomains[6] = REGDOMAIN_KOREA;
4503 pDomains[7] = REGDOMAIN_HI_5GHZ;
4504 pDomains[8] = REGDOMAIN_NO_5GHZ;
4505 }
4506 else
4507 {
4508 status = eHAL_STATUS_INVALID_PARAMETER;
4509 }
4510 }
4511
4512 return ( status );
4513}
4514
4515
4516//some support functions
4517tANI_BOOLEAN sme_Is11dSupported(tHalHandle hHal)
4518{
4519 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4520
4521 return ( csrIs11dSupported( pMac ) );
4522}
4523
4524
4525tANI_BOOLEAN sme_Is11hSupported(tHalHandle hHal)
4526{
4527 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4528
4529 return ( csrIs11hSupported( pMac ) );
4530}
4531
4532
4533tANI_BOOLEAN sme_IsWmmSupported(tHalHandle hHal)
4534{
4535 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4536
4537 return ( csrIsWmmSupported( pMac ) );
4538}
4539
4540//Upper layer to get the list of the base channels to scan for passively 11d info from csr
4541eHalStatus sme_ScanGetBaseChannels( tHalHandle hHal, tCsrChannelInfo * pChannelInfo )
4542{
4543 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4544
4545 return(csrScanGetBaseChannels(pMac,pChannelInfo) );
4546}
4547
4548/* ---------------------------------------------------------------------------
4549
4550 \fn sme_ChangeCountryCode
4551
4552 \brief Change Country code from upperlayer during WLAN driver operation.
4553 This is a synchronous API.
4554
4555 \param hHal - The handle returned by macOpen.
4556
4557 \param pCountry New Country Code String
4558
4559 \return eHalStatus SUCCESS.
4560
4561 FAILURE or RESOURCES The API finished and failed.
4562
4563 -------------------------------------------------------------------------------*/
4564eHalStatus sme_ChangeCountryCode( tHalHandle hHal,
4565 tSmeChangeCountryCallback callback,
4566 tANI_U8 *pCountry,
4567 void *pContext,
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304568 void* pVosContext,
4569 tAniBool countryFromUserSpace )
Jeff Johnson295189b2012-06-20 16:38:30 -07004570{
4571 eHalStatus status = eHAL_STATUS_FAILURE;
4572 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4573 vos_msg_t msg;
4574 tAniChangeCountryCodeReq *pMsg;
4575
4576 status = sme_AcquireGlobalLock( &pMac->sme );
4577 if ( HAL_STATUS_SUCCESS( status ) )
4578 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004579 smsLog(pMac, LOG1, FL(" called"));
Kiet Lam64c1b492013-07-12 13:56:44 +05304580 pMsg = vos_mem_malloc(sizeof(tAniChangeCountryCodeReq));
4581 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004583 smsLog(pMac, LOGE, " csrChangeCountryCode: failed to allocate mem for req");
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08004584 sme_ReleaseGlobalLock( &pMac->sme );
Kiet Lam64c1b492013-07-12 13:56:44 +05304585 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 }
4587
4588 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_CHANGE_COUNTRY_CODE);
4589 pMsg->msgLen = (tANI_U16)sizeof(tAniChangeCountryCodeReq);
Kiet Lam64c1b492013-07-12 13:56:44 +05304590 vos_mem_copy(pMsg->countryCode, pCountry, 3);
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05304591 pMsg->countryFromUserSpace = countryFromUserSpace;
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 pMsg->changeCCCallback = callback;
4593 pMsg->pDevContext = pContext;
4594 pMsg->pVosContext = pVosContext;
4595
4596 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4597 msg.bodyptr = pMsg;
4598 msg.reserved = 0;
4599
4600 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
4601 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004602 smsLog(pMac, LOGE, " sme_ChangeCountryCode failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +05304603 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 status = eHAL_STATUS_FAILURE;
4605 }
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08004606 smsLog(pMac, LOG1, FL(" returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 sme_ReleaseGlobalLock( &pMac->sme );
4608 }
4609
4610 return (status);
4611}
Sundaresan Ramachandran76e48e82013-07-15 13:07:17 +05304612/* ---------------------------------------------------------------------------
4613
4614 \fn sme_DHCPStartInd
4615
4616 \brief API to signal the FW about the DHCP Start event.
4617
4618 \param hHal - HAL handle for device.
4619
4620 \param device_mode - mode(AP,SAP etc) of the device.
4621
4622 \param macAddr - MAC address of the device.
4623
4624 \return eHalStatus SUCCESS.
4625
4626 FAILURE or RESOURCES The API finished and failed.
4627 --------------------------------------------------------------------------*/
4628eHalStatus sme_DHCPStartInd( tHalHandle hHal,
4629 tANI_U8 device_mode,
4630 tANI_U8 *macAddr )
4631{
4632 eHalStatus status;
4633 VOS_STATUS vosStatus;
4634 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4635 vos_msg_t vosMessage;
4636 tAniDHCPInd *pMsg;
4637
4638 status = sme_AcquireGlobalLock(&pMac->sme);
4639 if ( eHAL_STATUS_SUCCESS == status)
4640 {
4641 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
4642 if (NULL == pMsg)
4643 {
4644 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4645 "%s: Not able to allocate memory for dhcp start", __func__);
4646 sme_ReleaseGlobalLock( &pMac->sme );
4647 return eHAL_STATUS_FAILURE;
4648 }
4649 pMsg->msgType = WDA_DHCP_START_IND;
4650 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
4651 pMsg->device_mode = device_mode;
4652 vos_mem_copy( pMsg->macAddr, macAddr, sizeof(tSirMacAddr));
4653
4654 vosMessage.type = WDA_DHCP_START_IND;
4655 vosMessage.bodyptr = pMsg;
4656 vosMessage.reserved = 0;
4657
4658 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
4659 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
4660 {
4661 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4662 "%s: Post DHCP Start MSG fail", __func__);
4663 vos_mem_free(pMsg);
4664 status = eHAL_STATUS_FAILURE;
4665 }
4666 sme_ReleaseGlobalLock( &pMac->sme );
4667 }
4668 return (status);
4669}
4670/* ---------------------------------------------------------------------------
4671 \fn sme_DHCPStopInd
4672
4673 \brief API to signal the FW about the DHCP complete event.
4674
4675 \param hHal - HAL handle for device.
4676
4677 \param device_mode - mode(AP, SAP etc) of the device.
4678
4679 \param macAddr - MAC address of the device.
4680
4681 \return eHalStatus SUCCESS.
4682 FAILURE or RESOURCES The API finished and failed.
4683 --------------------------------------------------------------------------*/
4684eHalStatus sme_DHCPStopInd( tHalHandle hHal,
4685 tANI_U8 device_mode,
4686 tANI_U8 *macAddr )
4687{
4688 eHalStatus status;
4689 VOS_STATUS vosStatus;
4690 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4691 vos_msg_t vosMessage;
4692 tAniDHCPInd *pMsg;
4693
4694 status = sme_AcquireGlobalLock(&pMac->sme);
4695 if ( eHAL_STATUS_SUCCESS == status)
4696 {
4697 pMsg = (tAniDHCPInd*)vos_mem_malloc(sizeof(tAniDHCPInd));
4698 if (NULL == pMsg)
4699 {
4700 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4701 "%s: Not able to allocate memory for dhcp stop", __func__);
4702 sme_ReleaseGlobalLock( &pMac->sme );
4703 return eHAL_STATUS_FAILURE;
4704 }
4705
4706 pMsg->msgType = WDA_DHCP_STOP_IND;
4707 pMsg->msgLen = (tANI_U16)sizeof(tAniDHCPInd);
4708 pMsg->device_mode = device_mode;
4709 vos_mem_copy( pMsg->macAddr, macAddr, sizeof(tSirMacAddr));
4710
4711 vosMessage.type = WDA_DHCP_STOP_IND;
4712 vosMessage.bodyptr = pMsg;
4713 vosMessage.reserved = 0;
4714
4715 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
4716 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
4717 {
4718 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
4719 "%s: Post DHCP Stop MSG fail", __func__);
4720 vos_mem_free(pMsg);
4721 status = eHAL_STATUS_FAILURE;
4722 }
4723
4724 sme_ReleaseGlobalLock( &pMac->sme );
4725 }
4726 return (status);
4727}
4728
Jeff Johnson295189b2012-06-20 16:38:30 -07004729
4730/* ---------------------------------------------------------------------------
4731 \fn sme_BtcSignalBtEvent
4732 \brief API to signal Bluetooth (BT) event to the WLAN driver. Based on the
4733 BT event type and the current operating mode of Libra (full power,
4734 BMPS, UAPSD etc), appropriate Bluetooth Coexistence (BTC) strategy
4735 would be employed.
4736 \param hHal - The handle returned by macOpen.
4737 \param pBtEvent - Pointer to a caller allocated object of type tSmeBtEvent
4738 Caller owns the memory and is responsible for freeing it.
4739 \return VOS_STATUS
4740 VOS_STATUS_E_FAILURE BT Event not passed to HAL. This can happen
4741 if BTC execution mode is set to BTC_WLAN_ONLY
4742 or BTC_PTA_ONLY.
4743 VOS_STATUS_SUCCESS BT Event passed to HAL
4744 ---------------------------------------------------------------------------*/
4745VOS_STATUS sme_BtcSignalBtEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent)
4746{
4747 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4748#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4749 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4750
4751 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4752 {
4753 status = btcSignalBTEvent (hHal, pBtEvent);
4754 sme_ReleaseGlobalLock( &pMac->sme );
4755 }
4756#endif
4757 return (status);
4758}
4759
4760/* ---------------------------------------------------------------------------
4761 \fn sme_BtcSetConfig
4762 \brief API to change the current Bluetooth Coexistence (BTC) configuration
4763 This function should be invoked only after CFG download has completed.
4764 Calling it after sme_HDDReadyInd is recommended.
4765 \param hHal - The handle returned by macOpen.
4766 \param pSmeBtcConfig - Pointer to a caller allocated object of type tSmeBtcConfig.
4767 Caller owns the memory and is responsible for freeing it.
4768 \return VOS_STATUS
4769 VOS_STATUS_E_FAILURE Config not passed to HAL.
4770 VOS_STATUS_SUCCESS Config passed to HAL
4771 ---------------------------------------------------------------------------*/
4772VOS_STATUS sme_BtcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4773{
4774 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4775#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4776 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4777 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4778 {
4779 status = btcSetConfig (hHal, pSmeBtcConfig);
4780 sme_ReleaseGlobalLock( &pMac->sme );
4781 }
4782#endif
4783 return (status);
4784}
4785
4786/* ---------------------------------------------------------------------------
4787 \fn sme_BtcGetConfig
4788 \brief API to retrieve the current Bluetooth Coexistence (BTC) configuration
4789 \param hHal - The handle returned by macOpen.
4790 \param pSmeBtcConfig - Pointer to a caller allocated object of type
4791 tSmeBtcConfig. Caller owns the memory and is responsible
4792 for freeing it.
4793 \return VOS_STATUS
4794 VOS_STATUS_E_FAILURE - failure
4795 VOS_STATUS_SUCCESS success
4796 ---------------------------------------------------------------------------*/
4797VOS_STATUS sme_BtcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig)
4798{
4799 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4800#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4801 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4802
4803 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4804 {
4805 status = btcGetConfig (hHal, pSmeBtcConfig);
4806 sme_ReleaseGlobalLock( &pMac->sme );
4807 }
4808#endif
4809 return (status);
4810}
4811/* ---------------------------------------------------------------------------
4812 \fn sme_SetCfgPrivacy
4813 \brief API to set configure privacy parameters
4814 \param hHal - The handle returned by macOpen.
4815 \param pProfile - Pointer CSR Roam profile.
4816 \param fPrivacy - This parameter indicates status of privacy
4817
4818 \return void
4819 ---------------------------------------------------------------------------*/
4820void sme_SetCfgPrivacy( tHalHandle hHal,
4821 tCsrRoamProfile *pProfile,
4822 tANI_BOOLEAN fPrivacy
4823 )
4824{
4825 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4826 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4827 {
4828 csrSetCfgPrivacy(pMac, pProfile, fPrivacy);
4829 sme_ReleaseGlobalLock( &pMac->sme );
4830 }
4831}
4832
4833#if defined WLAN_FEATURE_VOWIFI
4834/* ---------------------------------------------------------------------------
4835 \fn sme_NeighborReportRequest
4836 \brief API to request neighbor report.
4837 \param hHal - The handle returned by macOpen.
4838 \param pRrmNeighborReq - Pointer to a caller allocated object of type
4839 tRrmNeighborReq. Caller owns the memory and is responsible
4840 for freeing it.
4841 \return VOS_STATUS
4842 VOS_STATUS_E_FAILURE - failure
4843 VOS_STATUS_SUCCESS success
4844 ---------------------------------------------------------------------------*/
4845VOS_STATUS sme_NeighborReportRequest (tHalHandle hHal, tANI_U8 sessionId,
4846 tpRrmNeighborReq pRrmNeighborReq, tpRrmNeighborRspCallbackInfo callbackInfo)
4847{
4848 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4849 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
4850
4851 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
4852 {
4853 status = sme_RrmNeighborReportRequest (hHal, sessionId, pRrmNeighborReq, callbackInfo);
4854 sme_ReleaseGlobalLock( &pMac->sme );
4855 }
4856
4857 return (status);
4858}
4859#endif
4860
4861//The following are debug APIs to support direct read/write register/memory
4862//They are placed in SME because HW cannot be access when in LOW_POWER state
4863//AND not connected. The knowledge and synchronization is done in SME
4864
4865//sme_DbgReadRegister
4866//Caller needs to validate the input values
4867VOS_STATUS sme_DbgReadRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t *pRegValue)
4868{
4869 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4870 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 tPmcPowerState PowerState;
4872 tANI_U32 sessionId = 0;
4873
4874 /* 1) To make Quarky work in FTM mode **************************************/
4875
4876 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4877 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08004878 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 {
4880 return VOS_STATUS_SUCCESS;
4881 }
4882 return VOS_STATUS_E_FAILURE;
4883 }
4884
4885 /* 2) NON FTM mode driver *************************************************/
4886
4887 /* Acquire SME global lock */
4888 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4889 {
4890 return VOS_STATUS_E_FAILURE;
4891 }
4892
4893 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4894 {
4895 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4896 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4897 {
Hoonki Lee0af6aaf2013-02-08 12:26:44 -08004898 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgReadRegister(regAddr, pRegValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 {
4900 status = VOS_STATUS_SUCCESS;
4901 }
4902 else
4903 {
4904 status = VOS_STATUS_E_FAILURE;
4905 }
4906 }
4907 else
4908 {
4909 status = VOS_STATUS_E_FAILURE;
4910 }
4911 }
4912
4913 /* This is a hack for Qualky/pttWniSocket
4914 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
4915 if ( VOS_STATUS_SUCCESS != status )
4916 {
4917 *pRegValue = 0xDEADBEEF;
4918 status = VOS_STATUS_SUCCESS;
4919 }
4920
4921 /* Release SME global lock */
4922 sme_ReleaseGlobalLock(&pMac->sme);
4923
4924 return (status);
4925}
4926
4927
4928//sme_DbgWriteRegister
4929//Caller needs to validate the input values
4930VOS_STATUS sme_DbgWriteRegister(tHalHandle hHal, v_U32_t regAddr, v_U32_t regValue)
4931{
4932 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4933 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 tPmcPowerState PowerState;
4935 tANI_U32 sessionId = 0;
4936
4937 /* 1) To make Quarky work in FTM mode **************************************/
4938
4939 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
4940 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 {
4943 return VOS_STATUS_SUCCESS;
4944 }
4945 return VOS_STATUS_E_FAILURE;
4946 }
4947
4948 /* 2) NON FTM mode driver *************************************************/
4949
4950 /* Acquire SME global lock */
4951 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
4952 {
4953 return VOS_STATUS_E_FAILURE;
4954 }
4955
4956 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
4957 {
4958 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
4959 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
4960 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteRegister(regAddr, regValue))
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 {
4963 status = VOS_STATUS_SUCCESS;
4964 }
4965 else
4966 {
4967 status = VOS_STATUS_E_FAILURE;
4968 }
4969 }
4970 else
4971 {
4972 status = VOS_STATUS_E_FAILURE;
4973 }
4974 }
4975
4976 /* Release SME global lock */
4977 sme_ReleaseGlobalLock(&pMac->sme);
4978
4979 return (status);
4980}
4981
4982
4983
4984//sme_DbgReadMemory
4985//Caller needs to validate the input values
4986//pBuf caller allocated buffer has the length of nLen
4987VOS_STATUS sme_DbgReadMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
4988{
4989 VOS_STATUS status = VOS_STATUS_E_FAILURE;
4990 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 tPmcPowerState PowerState;
4992 tANI_U32 sessionId = 0;
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08004993 tANI_U32 cmd = READ_MEMORY_DUMP_CMD;
4994 tANI_U32 arg1 = memAddr;
4995 tANI_U32 arg2 = nLen/4;
4996 tANI_U32 arg3 = 4;
4997 tANI_U32 arg4 = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 /* 1) To make Quarky work in FTM mode **************************************/
4999
5000 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
5001 {
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08005002 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8*)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 {
5004 return VOS_STATUS_SUCCESS;
5005 }
5006 return VOS_STATUS_E_FAILURE;
5007 }
5008
5009 /* 2) NON FTM mode driver *************************************************/
5010
5011 /* Acquire SME global lock */
5012 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
5013 {
5014 return VOS_STATUS_E_FAILURE;
5015 }
5016
5017 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
5018 {
5019 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
5020 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
5021 {
Gopichand Nakkalafab3fae2013-01-07 15:01:01 -08005022 if (VOS_STATUS_SUCCESS == WDA_HALDumpCmdReq(pMac, cmd, arg1, arg2, arg3, arg4, (tANI_U8 *)pBuf))
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 {
5024 status = VOS_STATUS_SUCCESS;
5025 }
5026 else
5027 {
5028 status = VOS_STATUS_E_FAILURE;
5029 }
5030 }
5031 else
5032 {
5033 status = VOS_STATUS_E_FAILURE;
5034 }
5035 }
5036
5037 /* This is a hack for Qualky/pttWniSocket
5038 Current implementation doesn't allow pttWniSocket to inform Qualky an error */
5039 if (VOS_STATUS_SUCCESS != status)
5040 {
5041 vos_mem_set(pBuf, nLen, 0xCD);
5042 status = VOS_STATUS_SUCCESS;
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005043 smsLog(pMac, LOGE, FL(" filled with 0xCD because it cannot access the hardware"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 }
5045
5046 /* Release SME lock */
5047 sme_ReleaseGlobalLock(&pMac->sme);
5048
5049 return (status);
5050}
5051
5052
5053//sme_DbgWriteMemory
5054//Caller needs to validate the input values
5055VOS_STATUS sme_DbgWriteMemory(tHalHandle hHal, v_U32_t memAddr, v_U8_t *pBuf, v_U32_t nLen)
5056{
5057 VOS_STATUS status = VOS_STATUS_E_FAILURE;
5058 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005059 tPmcPowerState PowerState;
5060 tANI_U32 sessionId = 0;
5061
5062 /* 1) To make Quarky work in FTM mode **************************************/
5063
5064 if(eDRIVER_TYPE_MFG == pMac->gDriverType)
5065 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 {
5067 return VOS_STATUS_SUCCESS;
5068 }
5069 return VOS_STATUS_E_FAILURE;
5070 }
5071
5072 /* 2) NON FTM mode driver *************************************************/
5073
5074 /* Acquire SME global lock */
5075 if (eHAL_STATUS_SUCCESS != sme_AcquireGlobalLock(&pMac->sme))
5076 {
5077 return VOS_STATUS_E_FAILURE;
5078 }
5079
5080 if(HAL_STATUS_SUCCESS(pmcQueryPowerState(pMac, &PowerState, NULL, NULL)))
5081 {
5082 /* Are we not in IMPS mode? Or are we in connected? Then we're safe*/
5083 if(!csrIsConnStateDisconnected(pMac, sessionId) || (ePMC_LOW_POWER != PowerState))
5084 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 if (eWLAN_PAL_STATUS_SUCCESS == wpalDbgWriteMemory(memAddr, (void *)pBuf, nLen))
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 {
5087 status = VOS_STATUS_SUCCESS;
5088 }
5089 else
5090 {
5091 status = VOS_STATUS_E_FAILURE;
5092 }
5093 }
5094 else
5095 {
5096 status = VOS_STATUS_E_FAILURE;
5097 }
5098 }
5099
5100 /* Release Global lock */
5101 sme_ReleaseGlobalLock(&pMac->sme);
5102
5103 return (status);
5104}
5105
5106
Katya Nigam70d68332013-09-16 16:49:45 +05305107void pmcLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString, ...)
5108{
5109 VOS_TRACE_LEVEL vosDebugLevel;
5110 char logBuffer[LOG_SIZE];
5111 va_list marker;
5112
5113 /* getting proper Debug level */
5114 vosDebugLevel = getVosDebugLevel(loglevel);
5115
5116 /* extracting arguments from pstring */
5117 va_start( marker, pString );
5118 vsnprintf(logBuffer, LOG_SIZE, pString, marker);
5119
5120 VOS_TRACE(VOS_MODULE_ID_PMC, vosDebugLevel, "%s", logBuffer);
5121 va_end( marker );
5122}
5123
5124
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005125void smsLog(tpAniSirGlobal pMac, tANI_U32 loglevel, const char *pString,...)
Jeff Johnson295189b2012-06-20 16:38:30 -07005126{
5127#ifdef WLAN_DEBUG
5128 // Verify against current log level
5129 if ( loglevel > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE( SIR_SMS_MODULE_ID )] )
5130 return;
5131 else
5132 {
5133 va_list marker;
5134
5135 va_start( marker, pString ); /* Initialize variable arguments. */
5136
5137 logDebug(pMac, SIR_SMS_MODULE_ID, loglevel, pString, marker);
5138
5139 va_end( marker ); /* Reset variable arguments. */
5140 }
5141#endif
5142}
Jeff Johnson295189b2012-06-20 16:38:30 -07005143
Jeff Johnson295189b2012-06-20 16:38:30 -07005144/* ---------------------------------------------------------------------------
5145 \fn sme_GetWcnssWlanCompiledVersion
5146 \brief This API returns the version of the WCNSS WLAN API with
5147 which the HOST driver was built
5148 \param hHal - The handle returned by macOpen.
5149 \param pVersion - Points to the Version structure to be filled
5150 \return VOS_STATUS
5151 VOS_STATUS_E_INVAL - failure
5152 VOS_STATUS_SUCCESS success
5153 ---------------------------------------------------------------------------*/
5154VOS_STATUS sme_GetWcnssWlanCompiledVersion(tHalHandle hHal,
5155 tSirVersionType *pVersion)
5156{
5157 VOS_STATUS status = VOS_STATUS_SUCCESS;
5158 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5159 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
5160
5161 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5162 {
5163 if( pVersion != NULL )
5164 {
5165 status = WDA_GetWcnssWlanCompiledVersion(vosContext, pVersion);
5166 }
5167 else
5168 {
5169 status = VOS_STATUS_E_INVAL;
5170 }
5171 sme_ReleaseGlobalLock( &pMac->sme );
5172 }
5173
5174 return (status);
5175}
5176
5177
5178/* ---------------------------------------------------------------------------
5179 \fn sme_GetWcnssWlanReportedVersion
5180 \brief This API returns the version of the WCNSS WLAN API with
5181 which the WCNSS driver reports it was built
5182 \param hHal - The handle returned by macOpen.
5183 \param pVersion - Points to the Version structure to be filled
5184 \return VOS_STATUS
5185 VOS_STATUS_E_INVAL - failure
5186 VOS_STATUS_SUCCESS success
5187 ---------------------------------------------------------------------------*/
5188VOS_STATUS sme_GetWcnssWlanReportedVersion(tHalHandle hHal,
5189 tSirVersionType *pVersion)
5190{
5191 VOS_STATUS status = VOS_STATUS_SUCCESS;
5192 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5193 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
5194
5195 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5196 {
5197 if( pVersion != NULL )
5198 {
5199 status = WDA_GetWcnssWlanReportedVersion(vosContext, pVersion);
5200 }
5201 else
5202 {
5203 status = VOS_STATUS_E_INVAL;
5204 }
5205 sme_ReleaseGlobalLock( &pMac->sme );
5206 }
5207
5208 return (status);
5209}
5210
5211
5212/* ---------------------------------------------------------------------------
5213 \fn sme_GetWcnssSoftwareVersion
5214 \brief This API returns the version string of the WCNSS driver
5215 \param hHal - The handle returned by macOpen.
5216 \param pVersion - Points to the Version string buffer to be filled
5217 \param versionBufferSize - THe size of the Version string buffer
5218 \return VOS_STATUS
5219 VOS_STATUS_E_INVAL - failure
5220 VOS_STATUS_SUCCESS success
5221 ---------------------------------------------------------------------------*/
5222VOS_STATUS sme_GetWcnssSoftwareVersion(tHalHandle hHal,
5223 tANI_U8 *pVersion,
5224 tANI_U32 versionBufferSize)
5225{
5226 VOS_STATUS status = VOS_STATUS_SUCCESS;
5227 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5228 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
5229
5230 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5231 {
5232 if( pVersion != NULL )
5233 {
5234 status = WDA_GetWcnssSoftwareVersion(vosContext, pVersion,
5235 versionBufferSize);
5236 }
5237 else
5238 {
5239 status = VOS_STATUS_E_INVAL;
5240 }
5241 sme_ReleaseGlobalLock( &pMac->sme );
5242 }
5243
5244 return (status);
5245}
5246
5247
5248/* ---------------------------------------------------------------------------
5249 \fn sme_GetWcnssHardwareVersion
5250 \brief This API returns the version string of the WCNSS hardware
5251 \param hHal - The handle returned by macOpen.
5252 \param pVersion - Points to the Version string buffer to be filled
5253 \param versionBufferSize - THe size of the Version string buffer
5254 \return VOS_STATUS
5255 VOS_STATUS_E_INVAL - failure
5256 VOS_STATUS_SUCCESS success
5257 ---------------------------------------------------------------------------*/
5258VOS_STATUS sme_GetWcnssHardwareVersion(tHalHandle hHal,
5259 tANI_U8 *pVersion,
5260 tANI_U32 versionBufferSize)
5261{
5262 VOS_STATUS status = VOS_STATUS_SUCCESS;
5263 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5264 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
5265
5266 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
5267 {
5268 if( pVersion != NULL )
5269 {
5270 status = WDA_GetWcnssHardwareVersion(vosContext, pVersion,
5271 versionBufferSize);
5272 }
5273 else
5274 {
5275 status = VOS_STATUS_E_INVAL;
5276 }
5277 sme_ReleaseGlobalLock( &pMac->sme );
5278 }
5279
5280 return (status);
5281}
Jeff Johnson4824d4c2013-02-12 14:23:57 -08005282
Jeff Johnson295189b2012-06-20 16:38:30 -07005283
5284#ifdef FEATURE_WLAN_WAPI
5285/* ---------------------------------------------------------------------------
5286 \fn sme_RoamSetBKIDCache
5287 \brief The SME API exposed to HDD to allow HDD to provde SME the BKID
5288 candidate list.
5289 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
5290 it is opened (by calling halOpen).
5291 \param pBKIDCache - caller allocated buffer point to an array of tBkidCacheInfo
5292 \param numItems - a variable that has the number of tBkidCacheInfo allocated
5293 when retruning, this is the number of items put into pBKIDCache
5294 \return eHalStatus - when fail, it usually means the buffer allocated is not
5295 big enough and pNumItems has the number of tBkidCacheInfo.
5296 ---------------------------------------------------------------------------*/
5297eHalStatus sme_RoamSetBKIDCache( tHalHandle hHal, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
5298 tANI_U32 numItems )
5299{
5300 eHalStatus status = eHAL_STATUS_FAILURE;
5301 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5302
5303 status = sme_AcquireGlobalLock( &pMac->sme );
5304 if ( HAL_STATUS_SUCCESS( status ) )
5305 {
5306 status = csrRoamSetBKIDCache( pMac, sessionId, pBKIDCache, numItems );
5307 sme_ReleaseGlobalLock( &pMac->sme );
5308 }
5309
5310 return (status);
5311}
5312
5313/* ---------------------------------------------------------------------------
5314 \fn sme_RoamGetBKIDCache
5315 \brief The SME API exposed to HDD to allow HDD to request SME to return its
5316 BKID cache.
5317 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
5318 it is opened (by calling halOpen).
5319 \param pNum - caller allocated memory that has the space of the number of
5320 tBkidCacheInfo as input. Upon returned, *pNum has the needed number of entries
5321 in SME cache.
5322 \param pBkidCache - Caller allocated memory that contains BKID cache, if any,
5323 upon return
5324 \return eHalStatus - when fail, it usually means the buffer allocated is not
5325 big enough.
5326 ---------------------------------------------------------------------------*/
5327eHalStatus sme_RoamGetBKIDCache(tHalHandle hHal, tANI_U32 *pNum,
5328 tBkidCacheInfo *pBkidCache)
5329{
5330 eHalStatus status = eHAL_STATUS_FAILURE;
5331 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5332
5333 status = sme_AcquireGlobalLock( &pMac->sme );
5334 if ( HAL_STATUS_SUCCESS( status ) )
5335 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005336 smsLog(pMac, LOGE, FL(" !!!!!!!!!!!!!!!!!!SessionId is hardcoded"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 status = csrRoamGetBKIDCache( pMac, 0, pNum, pBkidCache );
5338 sme_ReleaseGlobalLock( &pMac->sme );
5339 }
5340
5341 return (status);
5342}
5343
5344/* ---------------------------------------------------------------------------
5345 \fn sme_RoamGetNumBKIDCache
5346 \brief The SME API exposed to HDD to allow HDD to request SME to return the
5347 number of BKID cache entries.
5348 \param hHal - Handle to the HAL. The HAL handle is returned by the HAL after
5349 it is opened (by calling halOpen).
5350 \return tANI_U32 - the number of BKID cache entries.
5351 ---------------------------------------------------------------------------*/
5352tANI_U32 sme_RoamGetNumBKIDCache(tHalHandle hHal, tANI_U32 sessionId)
5353{
5354 eHalStatus status = eHAL_STATUS_FAILURE;
5355 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5356 tANI_U32 numBkidCache = 0;
5357
5358 status = sme_AcquireGlobalLock( &pMac->sme );
5359 if ( HAL_STATUS_SUCCESS( status ) )
5360 {
5361 numBkidCache = csrRoamGetNumBKIDCache( pMac, sessionId );
5362 sme_ReleaseGlobalLock( &pMac->sme );
5363 }
5364
5365 return (numBkidCache);
5366}
5367
5368/* ---------------------------------------------------------------------------
5369 \fn sme_ScanGetBKIDCandidateList
5370 \brief a wrapper function to return the BKID candidate list
5371 \param pBkidList - caller allocated buffer point to an array of
5372 tBkidCandidateInfo
5373 \param pNumItems - pointer to a variable that has the number of
5374 tBkidCandidateInfo allocated when retruning, this is
5375 either the number needed or number of items put into
5376 pPmkidList
5377 \return eHalStatus - when fail, it usually means the buffer allocated is not
5378 big enough and pNumItems
5379 has the number of tBkidCandidateInfo.
5380 \Note: pNumItems is a number of tBkidCandidateInfo,
5381 not sizeof(tBkidCandidateInfo) * something
5382 ---------------------------------------------------------------------------*/
5383eHalStatus sme_ScanGetBKIDCandidateList(tHalHandle hHal, tANI_U32 sessionId,
5384 tBkidCandidateInfo *pBkidList,
5385 tANI_U32 *pNumItems )
5386{
5387 eHalStatus status = eHAL_STATUS_FAILURE;
5388 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5389
5390 status = sme_AcquireGlobalLock( &pMac->sme );
5391 if ( HAL_STATUS_SUCCESS( status ) )
5392 {
5393 status = csrScanGetBKIDCandidateList( pMac, sessionId, pBkidList, pNumItems );
5394 sme_ReleaseGlobalLock( &pMac->sme );
5395 }
5396
5397 return (status);
5398}
5399#endif /* FEATURE_WLAN_WAPI */
5400
Jeff Johnsone7245742012-09-05 17:12:55 -07005401#ifdef FEATURE_OEM_DATA_SUPPORT
5402
5403/*****************************************************************************
5404 OEM DATA related modifications and function additions
5405 *****************************************************************************/
5406
5407/* ---------------------------------------------------------------------------
5408 \fn sme_getOemDataRsp
5409 \brief a wrapper function to obtain the OEM DATA RSP
5410 \param pOemDataRsp - A pointer to the response object
5411 \param pContext - a pointer passed in for the callback
5412 \return eHalStatus
5413 ---------------------------------------------------------------------------*/
5414eHalStatus sme_getOemDataRsp(tHalHandle hHal,
5415 tOemDataRsp **pOemDataRsp)
5416{
5417 eHalStatus status = eHAL_STATUS_SUCCESS;
5418 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5419
5420 do
5421 {
5422 //acquire the lock for the sme object
5423 status = sme_AcquireGlobalLock(&pMac->sme);
5424
5425 if(!HAL_STATUS_SUCCESS(status))
5426 {
5427 break;
5428 }
5429
5430 if(pMac->oemData.pOemDataRsp != NULL)
5431 {
5432 *pOemDataRsp = pMac->oemData.pOemDataRsp;
5433 }
5434 else
5435 {
5436 status = eHAL_STATUS_FAILURE;
5437 }
5438
5439 //release the lock for the sme object
5440 sme_ReleaseGlobalLock( &pMac->sme );
5441
5442 } while(0);
5443
5444 return status;
5445}
5446
5447/* ---------------------------------------------------------------------------
5448 \fn sme_OemDataReq
5449 \brief a wrapper function for OEM DATA REQ
5450 \param sessionId - session id to be used.
5451 \param pOemDataReqId - pointer to an object to get back the request ID
5452 \param callback - a callback function that is called upon finish
5453 \param pContext - a pointer passed in for the callback
5454 \return eHalStatus
5455 ---------------------------------------------------------------------------*/
5456eHalStatus sme_OemDataReq(tHalHandle hHal,
5457 tANI_U8 sessionId,
5458 tOemDataReqConfig *pOemDataReqConfig,
5459 tANI_U32 *pOemDataReqID,
5460 oemData_OemDataReqCompleteCallback callback,
5461 void *pContext)
5462{
5463 eHalStatus status = eHAL_STATUS_SUCCESS;
5464 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5465
5466 do
5467 {
5468 //acquire the lock for the sme object
5469 status = sme_AcquireGlobalLock(&pMac->sme);
5470 if(HAL_STATUS_SUCCESS(status))
5471 {
5472 tANI_U32 lOemDataReqId = pMac->oemData.oemDataReqID++; //let it wrap around
5473
5474 if(pOemDataReqID)
5475 {
5476 *pOemDataReqID = lOemDataReqId;
5477 }
5478 else
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08005479 {
5480 sme_ReleaseGlobalLock( &pMac->sme );
5481 return eHAL_STATUS_FAILURE;
5482 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005483
5484 status = oemData_OemDataReq(hHal, sessionId, pOemDataReqConfig, pOemDataReqID, callback, pContext);
5485
5486 //release the lock for the sme object
5487 sme_ReleaseGlobalLock( &pMac->sme );
5488 }
5489 } while(0);
5490
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005491 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07005492
5493 return(status);
5494}
5495
5496#endif /*FEATURE_OEM_DATA_SUPPORT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07005497
5498/*--------------------------------------------------------------------------
5499
5500 \brief sme_OpenSession() - Open a session for scan/roam operation.
5501
5502 This is a synchronous API.
5503
5504
5505 \param hHal - The handle returned by macOpen.
5506 \param callback - A pointer to the function caller specifies for roam/connect status indication
5507 \param pContext - The context passed with callback
5508 \param pSelfMacAddr - Caller allocated memory filled with self MAC address (6 bytes)
5509 \param pbSessionId - pointer to a caller allocated buffer for returned session ID
5510
5511 \return eHAL_STATUS_SUCCESS - session is opened. sessionId returned.
5512
5513 Other status means SME is failed to open the session.
5514 eHAL_STATUS_RESOURCES - no more session available.
5515 \sa
5516
5517 --------------------------------------------------------------------------*/
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005518eHalStatus sme_OpenSession(tHalHandle hHal, csrRoamCompleteCallback callback,
5519 void *pContext, tANI_U8 *pSelfMacAddr,
5520 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005521{
5522 eHalStatus status;
5523 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5524
5525 if( NULL == pbSessionId )
5526 {
5527 status = eHAL_STATUS_INVALID_PARAMETER;
5528 }
5529 else
5530 {
5531 status = sme_AcquireGlobalLock( &pMac->sme );
5532 if ( HAL_STATUS_SUCCESS( status ) )
5533 {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07005534 status = csrRoamOpenSession(pMac, callback, pContext,
5535 pSelfMacAddr, pbSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005536
5537 sme_ReleaseGlobalLock( &pMac->sme );
5538 }
5539 }
5540
5541 return ( status );
5542}
5543
5544
5545/*--------------------------------------------------------------------------
5546
5547 \brief sme_CloseSession() - Open a session for scan/roam operation.
5548
5549 This is a synchronous API.
5550
5551
5552 \param hHal - The handle returned by macOpen.
5553
5554 \param sessionId - A previous opened session's ID.
5555
5556 \return eHAL_STATUS_SUCCESS - session is closed.
5557
5558 Other status means SME is failed to open the session.
5559 eHAL_STATUS_INVALID_PARAMETER - session is not opened.
5560 \sa
5561
5562 --------------------------------------------------------------------------*/
5563eHalStatus sme_CloseSession(tHalHandle hHal, tANI_U8 sessionId,
5564 csrRoamSessionCloseCallback callback, void *pContext)
5565{
5566 eHalStatus status;
5567 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5568
5569 status = sme_AcquireGlobalLock( &pMac->sme );
5570 if ( HAL_STATUS_SUCCESS( status ) )
5571 {
5572 status = csrRoamCloseSession( pMac, sessionId, FALSE,
5573 callback, pContext );
5574
5575 sme_ReleaseGlobalLock( &pMac->sme );
5576 }
5577
5578 return ( status );
5579}
5580
Jeff Johnson295189b2012-06-20 16:38:30 -07005581/* ---------------------------------------------------------------------------
5582
5583 \fn sme_RoamUpdateAPWPSIE
5584
5585 \brief To update AP's WPS IE. This function should be called after SME AP session is created
5586 This is an asynchronous API.
5587
5588 \param pAPWPSIES - pointer to a caller allocated object of tSirAPWPSIEs
5589
5590 \return eHalStatus – SUCCESS –
5591
5592 FAILURE or RESOURCES – The API finished and failed.
5593
5594 -------------------------------------------------------------------------------*/
5595eHalStatus sme_RoamUpdateAPWPSIE(tHalHandle hHal, tANI_U8 sessionId, tSirAPWPSIEs *pAPWPSIES)
5596{
5597
5598 eHalStatus status = eHAL_STATUS_FAILURE;
5599 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5600
5601 status = sme_AcquireGlobalLock( &pMac->sme );
5602 if ( HAL_STATUS_SUCCESS( status ) )
5603 {
5604
5605 status = csrRoamUpdateAPWPSIE( pMac, sessionId, pAPWPSIES );
5606
5607 sme_ReleaseGlobalLock( &pMac->sme );
5608 }
5609
5610 return (status);
5611}
5612/* ---------------------------------------------------------------------------
5613
5614 \fn sme_RoamUpdateAPWPARSNIEs
5615
5616 \brief To update AP's WPA/RSN IEs. This function should be called after SME AP session is created
5617 This is an asynchronous API.
5618
5619 \param pAPSirRSNie - pointer to a caller allocated object of tSirRSNie with WPS/RSN IEs
5620
5621 \return eHalStatus – SUCCESS –
5622
5623 FAILURE or RESOURCES – The API finished and failed.
5624
5625 -------------------------------------------------------------------------------*/
5626eHalStatus sme_RoamUpdateAPWPARSNIEs(tHalHandle hHal, tANI_U8 sessionId, tSirRSNie * pAPSirRSNie)
5627{
5628
5629 eHalStatus status = eHAL_STATUS_FAILURE;
5630 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5631
5632 status = sme_AcquireGlobalLock( &pMac->sme );
5633 if ( HAL_STATUS_SUCCESS( status ) )
5634 {
5635
5636 status = csrRoamUpdateWPARSNIEs( pMac, sessionId, pAPSirRSNie);
5637
5638 sme_ReleaseGlobalLock( &pMac->sme );
5639 }
5640
5641 return (status);
5642}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005643/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005644
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005645 \fn sme_ChangeMCCBeaconInterval
5646
5647 \brief To update P2P-GO beaconInterval. This function should be called after
5648 disassociating all the station is done
5649 This is an asynchronous API.
5650
5651 \param
5652
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005653 \return eHalStatus SUCCESS
5654 FAILURE or RESOURCES
5655 The API finished and failed.
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005656
5657 -------------------------------------------------------------------------------*/
5658eHalStatus sme_ChangeMCCBeaconInterval(tHalHandle hHal, tANI_U8 sessionId)
5659{
5660 eHalStatus status = eHAL_STATUS_FAILURE;
5661 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5662
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08005663 smsLog(pMac, LOG1, FL("Update Beacon PARAMS "));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005664 status = sme_AcquireGlobalLock( &pMac->sme );
5665 if ( HAL_STATUS_SUCCESS( status ) )
5666 {
5667 status = csrSendChngMCCBeaconInterval( pMac, sessionId);
5668 sme_ReleaseGlobalLock( &pMac->sme );
5669 }
5670 return (status);
5671}
Jeff Johnson295189b2012-06-20 16:38:30 -07005672
5673/*-------------------------------------------------------------------------------*
5674
5675 \fn sme_sendBTAmpEvent
5676
5677 \brief to receive the coex priorty request from BT-AMP PAL
5678 and send the BT_AMP link state to HAL
5679
5680 \param btAmpEvent - btAmpEvent
5681
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005682 \return eHalStatus: SUCCESS : BTAmp event successfully sent to HAL
Jeff Johnson295189b2012-06-20 16:38:30 -07005683
5684 FAILURE: API failed
5685
5686-------------------------------------------------------------------------------*/
5687
5688eHalStatus sme_sendBTAmpEvent(tHalHandle hHal, tSmeBtAmpEvent btAmpEvent)
5689{
5690 vos_msg_t msg;
5691 tpSmeBtAmpEvent ptrSmeBtAmpEvent = NULL;
5692 eHalStatus status = eHAL_STATUS_FAILURE;
5693
5694 ptrSmeBtAmpEvent = vos_mem_malloc(sizeof(tpSmeBtAmpEvent));
5695 if (NULL == ptrSmeBtAmpEvent)
5696 {
5697 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005698 "Not able to allocate memory for BTAmp event", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 return status;
5700 }
5701
5702 vos_mem_copy(ptrSmeBtAmpEvent, (void*)&btAmpEvent, sizeof(tSmeBtAmpEvent));
5703 msg.type = WDA_SIGNAL_BTAMP_EVENT;
5704 msg.reserved = 0;
5705 msg.bodyptr = ptrSmeBtAmpEvent;
5706
5707 //status = halFW_SendBTAmpEventMesg(pMac, event);
5708
5709 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
5710 {
5711 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005712 "Not able to post SIR_HAL_SIGNAL_BTAMP_EVENT message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 vos_mem_free(ptrSmeBtAmpEvent);
5714 return status;
5715 }
5716
5717 return eHAL_STATUS_SUCCESS;
5718
5719}
5720
5721/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi48101412013-09-11 23:09:37 +05305722 \fn smeIssueFastRoamNeighborAPEvent
5723 \brief API to trigger fast BSS roam independent of RSSI triggers
5724 \param hHal - The handle returned by macOpen.
5725 \param bssid - Pointer to the BSSID to roam to.
5726 \param fastRoamTrig - Trigger to Scan or roam
5727 \return eHalStatus
5728 ---------------------------------------------------------------------------*/
5729eHalStatus smeIssueFastRoamNeighborAPEvent (tHalHandle hHal,
5730 tANI_U8 *bssid,
5731 tSmeFastRoamTrigger fastRoamTrig)
5732{
5733 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5734 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
5735 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
5736 eHalStatus status = eHAL_STATUS_SUCCESS;
5737
5738 status = sme_AcquireGlobalLock( &pMac->sme );
5739 if ( HAL_STATUS_SUCCESS( status ) )
5740 {
5741 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5742 "%s: invoked", __func__);
5743
5744 if (eSME_ROAM_TRIGGER_SCAN == fastRoamTrig)
5745 {
5746 smsLog(pMac, LOG1, FL("CFG Channel list scan... "));
5747 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_SCAN;
5748 vos_mem_copy((void *)(&pNeighborRoamInfo->cfgRoambssId),
5749 (void *)bssid, sizeof(tSirMacAddr));
5750 smsLog(pMac, LOG1, "Calling Roam Look Up down Event BSSID %x %x %x %x %x %x",
5751 pNeighborRoamInfo->cfgRoambssId[0], pNeighborRoamInfo->cfgRoambssId[1],
5752 pNeighborRoamInfo->cfgRoambssId[2], pNeighborRoamInfo->cfgRoambssId[3],
5753 pNeighborRoamInfo->cfgRoambssId[4], pNeighborRoamInfo->cfgRoambssId[5]);
5754
5755 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
5756 if (VOS_STATUS_SUCCESS != vosStatus)
5757 {
5758 smsLog(pMac, LOGE,
5759 FL("CFG Channel list scan state failed with status %d "),
5760 vosStatus);
5761 }
5762 }
5763 else if (eSME_ROAM_TRIGGER_FAST_ROAM == fastRoamTrig)
5764 {
5765 vos_mem_copy((void *)(&pNeighborRoamInfo->cfgRoambssId),
5766 (void *)bssid, sizeof(tSirMacAddr));
5767 pNeighborRoamInfo->cfgRoamEn = eSME_ROAM_TRIGGER_FAST_ROAM;
5768 smsLog(pMac, LOG1, "Roam to BSSID %x-%x-%x-%x-%x-%x",
5769 pNeighborRoamInfo->cfgRoambssId[0], pNeighborRoamInfo->cfgRoambssId[1],
5770 pNeighborRoamInfo->cfgRoambssId[2], pNeighborRoamInfo->cfgRoambssId[3],
5771 pNeighborRoamInfo->cfgRoambssId[4], pNeighborRoamInfo->cfgRoambssId[5]);
5772
5773 vosStatus = csrNeighborRoamReassocIndCallback(pMac->roam.gVosContext,
5774 0,
5775 pMac,
5776 0);
5777
5778 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
5779 {
5780 smsLog(pMac,
5781 LOGE,
5782 FL(" Call to csrNeighborRoamReassocIndCallback failed, status = %d"),
5783 vosStatus);
5784 }
5785 }
5786 sme_ReleaseGlobalLock( &pMac->sme );
5787 }
5788 return vosStatus;
5789}
5790/* ---------------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 \fn sme_SetHostOffload
5792 \brief API to set the host offload feature.
5793 \param hHal - The handle returned by macOpen.
5794 \param pRequest - Pointer to the offload request.
5795 \return eHalStatus
5796 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005797eHalStatus sme_SetHostOffload (tHalHandle hHal, tANI_U8 sessionId,
5798 tpSirHostOffloadReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005799{
5800 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07005801 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005802
5803 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5804 {
5805#ifdef WLAN_NS_OFFLOAD
5806 if(SIR_IPV6_NS_OFFLOAD == pRequest->offloadType)
5807 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005808 status = pmcSetNSOffload( hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 }
5810 else
5811#endif //WLAN_NS_OFFLOAD
5812 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005813 status = pmcSetHostOffload (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 }
5815 sme_ReleaseGlobalLock( &pMac->sme );
5816 }
5817
5818 return (status);
5819}
5820
5821#ifdef WLAN_FEATURE_GTK_OFFLOAD
5822/* ---------------------------------------------------------------------------
5823 \fn sme_SetGTKOffload
5824 \brief API to set GTK offload information.
5825 \param hHal - The handle returned by macOpen.
5826 \param pRequest - Pointer to the GTK offload request.
5827 \return eHalStatus
5828 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005829eHalStatus sme_SetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pRequest,
5830 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005831{
5832 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5833 eHalStatus status;
5834
5835 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5836 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005837 status = pmcSetGTKOffload( hHal, pRequest, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 sme_ReleaseGlobalLock( &pMac->sme );
5839 }
5840
5841 return (status);
5842}
5843
5844/* ---------------------------------------------------------------------------
5845 \fn sme_GetGTKOffload
5846 \brief API to get GTK offload information.
5847 \param hHal - The handle returned by macOpen.
5848 \param pRequest - Pointer to the GTK offload response.
5849 \return eHalStatus
5850 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005851eHalStatus sme_GetGTKOffload (tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
5852 void *callbackContext, tANI_U8 sessionId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005853{
5854 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5855 eHalStatus status;
5856
5857 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5858 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005859 pmcGetGTKOffload(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 sme_ReleaseGlobalLock( &pMac->sme );
5861 }
5862
5863 return (status);
5864}
5865#endif // WLAN_FEATURE_GTK_OFFLOAD
5866
5867/* ---------------------------------------------------------------------------
5868 \fn sme_SetKeepAlive
5869 \brief API to set the Keep Alive feature.
5870 \param hHal - The handle returned by macOpen.
5871 \param pRequest - Pointer to the Keep Alive request.
5872 \return eHalStatus
5873 ---------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07005874eHalStatus sme_SetKeepAlive (tHalHandle hHal, tANI_U8 sessionId,
5875 tpSirKeepAliveReq pRequest)
Jeff Johnson295189b2012-06-20 16:38:30 -07005876{
5877 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5878 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5880 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005881 status = pmcSetKeepAlive (hHal, pRequest, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 sme_ReleaseGlobalLock( &pMac->sme );
5883 }
5884
5885 return (status);
5886}
5887
5888#ifdef FEATURE_WLAN_SCAN_PNO
5889/* ---------------------------------------------------------------------------
5890 \fn sme_SetPreferredNetworkList
5891 \brief API to set the Preferred Network List Offload feature.
5892 \param hHal - The handle returned by macOpen.
5893 \param pRequest - Pointer to the offload request.
5894 \return eHalStatus
5895 ---------------------------------------------------------------------------*/
5896eHalStatus sme_SetPreferredNetworkList (tHalHandle hHal, tpSirPNOScanReq pRequest, tANI_U8 sessionId, void (*callbackRoutine) (void *callbackContext, tSirPrefNetworkFoundInd *pPrefNetworkFoundInd), void *callbackContext )
5897{
5898 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5899 eHalStatus status;
5900
5901 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5902 {
5903 pmcSetPreferredNetworkList(hHal, pRequest, sessionId, callbackRoutine, callbackContext);
5904 sme_ReleaseGlobalLock( &pMac->sme );
5905 }
5906
5907 return (status);
5908}
5909
5910eHalStatus sme_SetRSSIFilter(tHalHandle hHal, v_U8_t rssiThreshold)
5911{
5912 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5913 eHalStatus status;
5914
5915 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5916 {
5917 pmcSetRssiFilter(hHal, rssiThreshold);
5918 sme_ReleaseGlobalLock( &pMac->sme );
5919 }
5920
5921 return (status);
5922}
5923
5924#endif // FEATURE_WLAN_SCAN_PNO
5925
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005926eHalStatus sme_SetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams, tANI_BOOLEAN forced)
Jeff Johnson295189b2012-06-20 16:38:30 -07005927{
5928 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5929 eHalStatus status;
5930
5931 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
5932 {
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08005933 pmcSetPowerParams(hHal, pwParams, forced);
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 sme_ReleaseGlobalLock( &pMac->sme );
5935 }
5936
5937 return (status);
5938}
5939
5940/* ---------------------------------------------------------------------------
5941 \fn sme_AbortMacScan
5942 \brief API to cancel MAC scan.
5943 \param hHal - The handle returned by macOpen.
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305944 \param sessionId - sessionId on which we need to abort scan.
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 \return VOS_STATUS
5946 VOS_STATUS_E_FAILURE - failure
5947 VOS_STATUS_SUCCESS success
5948 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305949eHalStatus sme_AbortMacScan(tHalHandle hHal, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005950{
5951 eHalStatus status;
5952 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5953
5954 status = sme_AcquireGlobalLock( &pMac->sme );
5955 if ( HAL_STATUS_SUCCESS( status ) )
5956 {
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305957 status = csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005958
5959 sme_ReleaseGlobalLock( &pMac->sme );
5960 }
5961
5962 return ( status );
5963}
5964
5965/* ----------------------------------------------------------------------------
5966 \fn sme_GetOperationChannel
5967 \brief API to get current channel on which STA is parked
5968 this function gives channel information only of infra station or IBSS station
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005969 \param hHal, pointer to memory location and sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 \returns eHAL_STATUS_SUCCESS
5971 eHAL_STATUS_FAILURE
5972-------------------------------------------------------------------------------*/
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005973eHalStatus sme_GetOperationChannel(tHalHandle hHal, tANI_U32 *pChannel, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07005974{
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
5976 tCsrRoamSession *pSession;
5977
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005978 if (CSR_IS_SESSION_VALID( pMac, sessionId ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005980 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005981
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005982 if(( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE ) ||
5983 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_IBSS ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005984 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_INFRA_AP ) ||
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005985 ( pSession->connectedProfile.BSSType == eCSR_BSS_TYPE_START_IBSS ))
5986 {
5987 *pChannel =pSession->connectedProfile.operationChannel;
5988 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 }
5990 }
5991 return eHAL_STATUS_FAILURE;
5992}// sme_GetOperationChannel ends here
5993
Jeff Johnson295189b2012-06-20 16:38:30 -07005994/* ---------------------------------------------------------------------------
5995
5996 \fn sme_RegisterMgtFrame
5997
5998 \brief To register managment frame of specified type and subtype.
5999 \param frameType - type of the frame that needs to be passed to HDD.
6000 \param matchData - data which needs to be matched before passing frame
6001 to HDD.
6002 \param matchDataLen - Length of matched data.
6003 \return eHalStatus
6004 -------------------------------------------------------------------------------*/
6005eHalStatus sme_RegisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
6006 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
6007{
6008 eHalStatus status = eHAL_STATUS_SUCCESS;
6009 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6010
6011 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6012 {
6013 tSirRegisterMgmtFrame *pMsg;
6014 tANI_U16 len;
6015 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006016
6017 if(!pSession)
6018 {
6019 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08006020 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006021 return eHAL_STATUS_FAILURE;
6022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006023
6024 if( !pSession->sessionActive )
6025 {
6026 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006027 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 sme_ReleaseGlobalLock( &pMac->sme );
6029 return eHAL_STATUS_FAILURE;
6030 }
6031
6032 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
6033
Kiet Lam64c1b492013-07-12 13:56:44 +05306034 pMsg = vos_mem_malloc(len);
6035 if ( NULL == pMsg )
6036 status = eHAL_STATUS_FAILURE;
6037 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306039 vos_mem_set(pMsg, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
6041 pMsg->length = len;
6042 pMsg->sessionId = sessionId;
6043 pMsg->registerFrame = VOS_TRUE;
6044 pMsg->frameType = frameType;
6045 pMsg->matchLen = matchLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05306046 vos_mem_copy(pMsg->matchData, matchData, matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 status = palSendMBMessage(pMac->hHdd, pMsg);
6048 }
6049 sme_ReleaseGlobalLock( &pMac->sme );
6050 }
6051 return status;
6052}
6053
6054/* ---------------------------------------------------------------------------
6055
6056 \fn sme_DeregisterMgtFrame
6057
6058 \brief To De-register managment frame of specified type and subtype.
6059 \param frameType - type of the frame that needs to be passed to HDD.
6060 \param matchData - data which needs to be matched before passing frame
6061 to HDD.
6062 \param matchDataLen - Length of matched data.
6063 \return eHalStatus
6064 -------------------------------------------------------------------------------*/
6065eHalStatus sme_DeregisterMgmtFrame(tHalHandle hHal, tANI_U8 sessionId,
6066 tANI_U16 frameType, tANI_U8* matchData, tANI_U16 matchLen)
6067{
6068 eHalStatus status = eHAL_STATUS_SUCCESS;
6069 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6070
6071 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6072 {
6073 tSirRegisterMgmtFrame *pMsg;
6074 tANI_U16 len;
6075 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006076
6077 if(!pSession)
6078 {
6079 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08006080 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006081 return eHAL_STATUS_FAILURE;
6082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006083
6084 if( !pSession->sessionActive )
6085 {
6086 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006087 "%s Invalid Sessionid", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 sme_ReleaseGlobalLock( &pMac->sme );
6089 return eHAL_STATUS_FAILURE;
6090 }
6091
6092 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
6093
Kiet Lam64c1b492013-07-12 13:56:44 +05306094 pMsg = vos_mem_malloc(len);
6095 if ( NULL == pMsg )
6096 status = eHAL_STATUS_FAILURE;
6097 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306099 vos_mem_set(pMsg, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
6101 pMsg->length = len;
6102 pMsg->registerFrame = VOS_FALSE;
6103 pMsg->frameType = frameType;
6104 pMsg->matchLen = matchLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05306105 vos_mem_copy(pMsg->matchData, matchData, matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 status = palSendMBMessage(pMac->hHdd, pMsg);
6107 }
6108 sme_ReleaseGlobalLock( &pMac->sme );
6109 }
6110 return status;
6111}
6112
6113/* ---------------------------------------------------------------------------
6114 \fn sme_RemainOnChannel
6115 \brief API to request remain on channel for 'x' duration. used in p2p in listen state
6116 \param hHal - The handle returned by macOpen.
6117 \param pRequest - channel
6118 \param duration - duration in ms
6119 \param callback - HDD registered callback to process reaminOnChannelRsp
6120 \param context - HDD Callback param
6121 \return eHalStatus
6122 ---------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -07006123eHalStatus sme_RemainOnChannel(tHalHandle hHal, tANI_U8 sessionId,
6124 tANI_U8 channel, tANI_U32 duration,
Gopichand Nakkala924e4552013-05-08 19:18:14 +05306125 remainOnChanCallback callback,
6126 void *pContext,
6127 tANI_U8 isP2PProbeReqAllowed)
Jeff Johnson295189b2012-06-20 16:38:30 -07006128{
6129 eHalStatus status = eHAL_STATUS_SUCCESS;
6130 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6131
6132 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6133 {
Gopichand Nakkala924e4552013-05-08 19:18:14 +05306134 status = p2pRemainOnChannel (hHal, sessionId, channel, duration, callback, pContext,
6135 isP2PProbeReqAllowed
Jeff Johnson295189b2012-06-20 16:38:30 -07006136#ifdef WLAN_FEATURE_P2P_INTERNAL
6137 , eP2PRemainOnChnReasonUnknown
6138#endif
6139 );
6140 sme_ReleaseGlobalLock( &pMac->sme );
6141 }
6142 return(status);
6143}
6144
6145/* ---------------------------------------------------------------------------
6146 \fn sme_ReportProbeReq
6147 \brief API to enable/disable forwarding of probeReq to apps in p2p.
6148 \param hHal - The handle returned by macOpen.
6149 \param falg: to set the Probe request forarding to wpa_supplicant in listen state in p2p
6150 \return eHalStatus
6151 ---------------------------------------------------------------------------*/
6152
6153#ifndef WLAN_FEATURE_CONCURRENT_P2P
6154eHalStatus sme_ReportProbeReq(tHalHandle hHal, tANI_U8 flag)
6155{
6156 eHalStatus status = eHAL_STATUS_SUCCESS;
6157 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6158
6159 do
6160 {
6161 //acquire the lock for the sme object
6162 status = sme_AcquireGlobalLock(&pMac->sme);
6163 if(HAL_STATUS_SUCCESS(status))
6164 {
6165 /* call set in context */
6166 pMac->p2pContext.probeReqForwarding = flag;
6167 //release the lock for the sme object
6168 sme_ReleaseGlobalLock( &pMac->sme );
6169 }
6170 } while(0);
6171
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006172 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006173
6174 return(status);
6175}
6176
6177/* ---------------------------------------------------------------------------
6178 \fn sme_updateP2pIe
6179 \brief API to set the P2p Ie in p2p context
6180 \param hHal - The handle returned by macOpen.
6181 \param p2pIe - Ptr to p2pIe from HDD.
6182 \param p2pIeLength: length of p2pIe
6183 \return eHalStatus
6184 ---------------------------------------------------------------------------*/
6185
6186eHalStatus sme_updateP2pIe(tHalHandle hHal, void *p2pIe, tANI_U32 p2pIeLength)
6187{
6188 eHalStatus status = eHAL_STATUS_SUCCESS;
6189 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6190
6191 //acquire the lock for the sme object
6192 status = sme_AcquireGlobalLock(&pMac->sme);
6193 if(HAL_STATUS_SUCCESS(status))
6194 {
6195 if(NULL != pMac->p2pContext.probeRspIe){
6196 vos_mem_free(pMac->p2pContext.probeRspIe);
6197 pMac->p2pContext.probeRspIeLength = 0;
6198 }
6199
6200 pMac->p2pContext.probeRspIe = vos_mem_malloc(p2pIeLength);
6201 if (NULL == pMac->p2pContext.probeRspIe)
6202 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006203 smsLog(pMac, LOGE, "%s: Unable to allocate P2P IE", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 pMac->p2pContext.probeRspIeLength = 0;
6205 status = eHAL_STATUS_FAILURE;
6206 }
6207 else
6208 {
6209 pMac->p2pContext.probeRspIeLength = p2pIeLength;
6210
6211 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG2,
6212 pMac->p2pContext.probeRspIe,
6213 pMac->p2pContext.probeRspIeLength );
6214 vos_mem_copy((tANI_U8 *)pMac->p2pContext.probeRspIe, p2pIe,
6215 p2pIeLength);
6216 }
6217
6218 //release the lock for the sme object
6219 sme_ReleaseGlobalLock( &pMac->sme );
6220 }
6221
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006222 smsLog(pMac, LOG2, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006223
6224 return(status);
6225}
6226#endif
6227
6228/* ---------------------------------------------------------------------------
6229 \fn sme_sendAction
6230 \brief API to send action frame from supplicant.
6231 \param hHal - The handle returned by macOpen.
6232 \return eHalStatus
6233 ---------------------------------------------------------------------------*/
6234
6235eHalStatus sme_sendAction(tHalHandle hHal, tANI_U8 sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -07006236 const tANI_U8 *pBuf, tANI_U32 len,
6237 tANI_U16 wait, tANI_BOOLEAN noack)
Jeff Johnson295189b2012-06-20 16:38:30 -07006238{
6239 eHalStatus status = eHAL_STATUS_SUCCESS;
6240 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6241
6242 //acquire the lock for the sme object
6243 status = sme_AcquireGlobalLock(&pMac->sme);
6244 if(HAL_STATUS_SUCCESS(status))
6245 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006246 p2pSendAction(hHal, sessionId, pBuf, len, wait, noack);
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 //release the lock for the sme object
6248 sme_ReleaseGlobalLock( &pMac->sme );
6249 }
6250
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006251 smsLog(pMac, LOGW, "exiting function %s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006252
6253 return(status);
6254}
6255
6256eHalStatus sme_CancelRemainOnChannel(tHalHandle hHal, tANI_U8 sessionId )
6257{
6258 eHalStatus status = eHAL_STATUS_SUCCESS;
6259 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6260
6261 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6262 {
6263 status = p2pCancelRemainOnChannel (hHal, sessionId);
6264 sme_ReleaseGlobalLock( &pMac->sme );
6265 }
6266 return(status);
6267}
6268
6269//Power Save Related
6270eHalStatus sme_p2pSetPs(tHalHandle hHal, tP2pPsConfig * data)
6271{
6272 eHalStatus status = eHAL_STATUS_SUCCESS;
6273 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6274
6275 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6276 {
6277 status = p2pSetPs (hHal, data);
6278 sme_ReleaseGlobalLock( &pMac->sme );
6279 }
6280 return(status);
6281}
6282
Jeff Johnson295189b2012-06-20 16:38:30 -07006283
6284/* ---------------------------------------------------------------------------
6285
6286 \fn sme_ConfigureRxpFilter
6287
6288 \brief
6289 SME will pass this request to lower mac to set/reset the filter on RXP for
6290 multicast & broadcast traffic.
6291
6292 \param
6293
6294 hHal - The handle returned by macOpen.
6295
6296 filterMask- Currently the API takes a 1 or 0 (set or reset) as filter.
6297 Basically to enable/disable the filter (to filter "all" mcbc traffic) based
6298 on this param. In future we can use this as a mask to set various types of
6299 filters as suggested below:
6300 FILTER_ALL_MULTICAST:
6301 FILTER_ALL_BROADCAST:
6302 FILTER_ALL_MULTICAST_BROADCAST:
6303
6304
6305 \return eHalStatus
6306
6307
6308--------------------------------------------------------------------------- */
6309eHalStatus sme_ConfigureRxpFilter( tHalHandle hHal,
6310 tpSirWlanSetRxpFilters wlanRxpFilterParam)
6311{
6312 eHalStatus status = eHAL_STATUS_SUCCESS;
6313 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6314 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6315 vos_msg_t vosMessage;
6316
6317 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6318 {
6319 /* serialize the req through MC thread */
6320 vosMessage.bodyptr = wlanRxpFilterParam;
6321 vosMessage.type = WDA_CFG_RXP_FILTER_REQ;
6322 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6323 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6324 {
6325 status = eHAL_STATUS_FAILURE;
6326 }
6327 sme_ReleaseGlobalLock( &pMac->sme );
6328 }
6329 return(status);
6330}
6331
Jeff Johnson295189b2012-06-20 16:38:30 -07006332/* ---------------------------------------------------------------------------
6333
6334 \fn sme_ConfigureSuspendInd
6335
6336 \brief
6337 SME will pass this request to lower mac to Indicate that the wlan needs to
6338 be suspended
6339
6340 \param
6341
6342 hHal - The handle returned by macOpen.
6343
6344 wlanSuspendParam- Depicts the wlan suspend params
6345
6346
6347 \return eHalStatus
6348
6349
6350--------------------------------------------------------------------------- */
6351eHalStatus sme_ConfigureSuspendInd( tHalHandle hHal,
6352 tpSirWlanSuspendParam wlanSuspendParam)
6353{
6354 eHalStatus status = eHAL_STATUS_SUCCESS;
6355 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6356 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6357 vos_msg_t vosMessage;
6358
6359 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6360 {
6361 /* serialize the req through MC thread */
6362 vosMessage.bodyptr = wlanSuspendParam;
6363 vosMessage.type = WDA_WLAN_SUSPEND_IND;
6364 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6365 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6366 {
6367 status = eHAL_STATUS_FAILURE;
6368 }
6369 sme_ReleaseGlobalLock( &pMac->sme );
6370 }
6371 return(status);
6372}
6373
6374/* ---------------------------------------------------------------------------
6375
6376 \fn sme_ConfigureResumeReq
6377
6378 \brief
6379 SME will pass this request to lower mac to Indicate that the wlan needs to
6380 be Resumed
6381
6382 \param
6383
6384 hHal - The handle returned by macOpen.
6385
6386 wlanResumeParam- Depicts the wlan resume params
6387
6388
6389 \return eHalStatus
6390
6391
6392--------------------------------------------------------------------------- */
6393eHalStatus sme_ConfigureResumeReq( tHalHandle hHal,
6394 tpSirWlanResumeParam wlanResumeParam)
6395{
6396 eHalStatus status = eHAL_STATUS_SUCCESS;
6397 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6398 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6399 vos_msg_t vosMessage;
6400
6401 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
6402 {
6403 /* serialize the req through MC thread */
6404 vosMessage.bodyptr = wlanResumeParam;
6405 vosMessage.type = WDA_WLAN_RESUME_REQ;
6406 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
6407 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
6408 {
6409 status = eHAL_STATUS_FAILURE;
6410 }
6411 sme_ReleaseGlobalLock( &pMac->sme );
6412 }
6413 return(status);
6414}
6415
Jeff Johnson295189b2012-06-20 16:38:30 -07006416/* ---------------------------------------------------------------------------
6417
6418 \fn sme_GetInfraSessionId
6419
6420 \brief To get the session ID for infra session, if connected
6421 This is a synchronous API.
6422
6423 \param hHal - The handle returned by macOpen.
6424
6425 \return sessionid, -1 if infra session is not connected
6426
6427 -------------------------------------------------------------------------------*/
6428tANI_S8 sme_GetInfraSessionId(tHalHandle hHal)
6429{
6430 eHalStatus status = eHAL_STATUS_FAILURE;
6431 tANI_S8 sessionid = -1;
6432 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6433
6434 status = sme_AcquireGlobalLock( &pMac->sme );
6435 if ( HAL_STATUS_SUCCESS( status ) )
6436 {
6437
6438 sessionid = csrGetInfraSessionId( pMac);
6439
6440 sme_ReleaseGlobalLock( &pMac->sme );
6441 }
6442
6443 return (sessionid);
6444}
6445
6446/* ---------------------------------------------------------------------------
6447
6448 \fn sme_GetInfraOperationChannel
6449
6450 \brief To get the operating channel for infra session, if connected
6451 This is a synchronous API.
6452
6453 \param hHal - The handle returned by macOpen.
6454 \param sessionId - the sessionId returned by sme_OpenSession.
6455
6456 \return operating channel, 0 if infra session is not connected
6457
6458 -------------------------------------------------------------------------------*/
6459tANI_U8 sme_GetInfraOperationChannel( tHalHandle hHal, tANI_U8 sessionId)
6460{
6461 eHalStatus status = eHAL_STATUS_FAILURE;
6462 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6463 tANI_U8 channel = 0;
6464 status = sme_AcquireGlobalLock( &pMac->sme );
6465 if ( HAL_STATUS_SUCCESS( status ) )
6466 {
6467
6468 channel = csrGetInfraOperationChannel( pMac, sessionId);
6469
6470 sme_ReleaseGlobalLock( &pMac->sme );
6471 }
6472
6473 return (channel);
6474}
6475
6476//This routine will return poerating channel on which other BSS is operating to be used for concurrency mode.
6477//If other BSS is not up or not connected it will return 0
6478tANI_U8 sme_GetConcurrentOperationChannel( tHalHandle hHal )
6479{
6480 eHalStatus status = eHAL_STATUS_FAILURE;
6481 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6482 tANI_U8 channel = 0;
6483 status = sme_AcquireGlobalLock( &pMac->sme );
6484 if ( HAL_STATUS_SUCCESS( status ) )
6485 {
6486
6487 channel = csrGetConcurrentOperationChannel( pMac );
6488 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006489 " Other Concurrent Channel = %d", __func__,channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 sme_ReleaseGlobalLock( &pMac->sme );
6491 }
6492
6493 return (channel);
6494}
6495
6496#ifdef FEATURE_WLAN_SCAN_PNO
6497/******************************************************************************
6498*
6499* Name: sme_PreferredNetworkFoundInd
6500*
6501* Description:
6502* Invoke Preferred Network Found Indication
6503*
6504* Parameters:
6505* hHal - HAL handle for device
6506* pMsg - found network description
6507*
6508* Returns: eHalStatus
6509*
6510******************************************************************************/
6511eHalStatus sme_PreferredNetworkFoundInd (tHalHandle hHal, void* pMsg)
6512{
6513 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6514 eHalStatus status = eHAL_STATUS_SUCCESS;
6515 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd = (tSirPrefNetworkFoundInd *)pMsg;
Srikant Kuppa066904f2013-05-07 13:56:02 -07006516 v_U8_t dumpSsId[SIR_MAC_MAX_SSID_LENGTH + 1];
6517 tANI_U8 ssIdLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006518
6519 if (NULL == pMsg)
6520 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006521 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 status = eHAL_STATUS_FAILURE;
6523 }
6524 else
6525 {
6526 if (pPrefNetworkFoundInd->ssId.length > 0)
6527 {
Srikant Kuppa066904f2013-05-07 13:56:02 -07006528 ssIdLength = CSR_MIN(SIR_MAC_MAX_SSID_LENGTH,
6529 pPrefNetworkFoundInd->ssId.length);
6530 vos_mem_copy(dumpSsId, pPrefNetworkFoundInd->ssId.ssId, ssIdLength);
6531 dumpSsId[ssIdLength] = 0;
6532 smsLog(pMac, LOG2, "%s:SSID=%s frame length %d",
6533 __func__, dumpSsId, pPrefNetworkFoundInd->frameLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006534
Srikant Kuppa066904f2013-05-07 13:56:02 -07006535 //Save the frame to scan result
6536 if (pPrefNetworkFoundInd->mesgLen > sizeof(tSirPrefNetworkFoundInd))
6537 {
6538 //we may have a frame
6539 status = csrScanSavePreferredNetworkFound(pMac,
6540 pPrefNetworkFoundInd);
6541 if (!HAL_STATUS_SUCCESS(status))
6542 {
6543 smsLog(pMac, LOGE, FL(" fail to save preferred network"));
6544 }
6545 }
6546 else
6547 {
6548 smsLog(pMac, LOGE, FL(" not enough data length %d needed %d"),
6549 pPrefNetworkFoundInd->mesgLen, sizeof(tSirPrefNetworkFoundInd));
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 }
6551
Srikant Kuppa066904f2013-05-07 13:56:02 -07006552 /* Call Preferred Netowrk Found Indication callback routine. */
6553 if (HAL_STATUS_SUCCESS(status) && (pMac->pmc.prefNetwFoundCB != NULL))
6554 {
6555 pMac->pmc.prefNetwFoundCB(
6556 pMac->pmc.preferredNetworkFoundIndCallbackContext,
6557 pPrefNetworkFoundInd);
6558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 }
6560 else
6561 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006562 smsLog(pMac, LOGE, "%s: callback failed - SSID is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 status = eHAL_STATUS_FAILURE;
6564 }
6565 }
6566
6567
6568 return(status);
6569}
6570
6571#endif // FEATURE_WLAN_SCAN_PNO
6572
6573
6574eHalStatus sme_GetCfgValidChannels(tHalHandle hHal, tANI_U8 *aValidChannels, tANI_U32 *len)
6575{
6576 eHalStatus status = eHAL_STATUS_FAILURE;
6577 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6578
6579 status = sme_AcquireGlobalLock( &pMac->sme );
6580 if ( HAL_STATUS_SUCCESS( status ) )
6581 {
6582 status = csrGetCfgValidChannels(pMac, aValidChannels, len);
6583 sme_ReleaseGlobalLock( &pMac->sme );
6584 }
6585
6586 return (status);
6587}
6588
6589
6590/* ---------------------------------------------------------------------------
6591
6592 \fn sme_SetTxPerTracking
6593
6594 \brief Set Tx PER tracking configuration parameters
6595
6596 \param hHal - The handle returned by macOpen.
6597 \param pTxPerTrackingConf - Tx PER configuration parameters
6598
6599 \return eHalStatus
6600
6601 -------------------------------------------------------------------------------*/
6602eHalStatus sme_SetTxPerTracking(tHalHandle hHal,
6603 void (*pCallbackfn) (void *pCallbackContext),
6604 void *pCallbackContext,
6605 tpSirTxPerTrackingParam pTxPerTrackingParam)
6606{
6607 vos_msg_t msg;
6608 tpSirTxPerTrackingParam pTxPerTrackingParamReq = NULL;
6609 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6610
6611 if ( eHAL_STATUS_SUCCESS == sme_AcquireGlobalLock( &pMac->sme ) )
6612 {
6613 pMac->sme.pTxPerHitCallback = pCallbackfn;
6614 pMac->sme.pTxPerHitCbContext = pCallbackContext;
6615 sme_ReleaseGlobalLock( &pMac->sme );
6616 }
6617
6618 // free this memory in failure case or WDA request callback function
6619 pTxPerTrackingParamReq = vos_mem_malloc(sizeof(tSirTxPerTrackingParam));
6620 if (NULL == pTxPerTrackingParamReq)
6621 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006622 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for tSirTxPerTrackingParam", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 return eHAL_STATUS_FAILURE;
6624 }
6625
Kiet Lam64c1b492013-07-12 13:56:44 +05306626 vos_mem_copy(pTxPerTrackingParamReq, (void*)pTxPerTrackingParam,
6627 sizeof(tSirTxPerTrackingParam));
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 msg.type = WDA_SET_TX_PER_TRACKING_REQ;
6629 msg.reserved = 0;
6630 msg.bodyptr = pTxPerTrackingParamReq;
6631
6632 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6633 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006634 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_TX_PER_TRACKING_REQ message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 vos_mem_free(pTxPerTrackingParamReq);
6636 return eHAL_STATUS_FAILURE;
6637 }
6638
6639 return eHAL_STATUS_SUCCESS;
6640}
6641
6642/* ---------------------------------------------------------------------------
6643
6644 \fn sme_HandleChangeCountryCode
6645
6646 \brief Change Country code, Reg Domain and channel list
6647
6648 \details Country Code Priority
6649 0 = 11D > Configured Country > NV
6650 1 = Configured Country > 11D > NV
6651 If Supplicant country code is priority than 11d is disabled.
6652 If 11D is enabled, we update the country code after every scan.
6653 Hence when Supplicant country code is priority, we don't need 11D info.
6654 Country code from Supplicant is set as current courtry code.
6655 User can send reset command XX (instead of country code) to reset the
6656 country code to default values which is read from NV.
6657 In case of reset, 11D is enabled and default NV code is Set as current country code
6658 If 11D is priority,
6659 Than Supplicant country code code is set to default code. But 11D code is set as current country code
6660
6661 \param pMac - The handle returned by macOpen.
6662 \param pMsgBuf - MSG Buffer
6663
6664 \return eHalStatus
6665
6666 -------------------------------------------------------------------------------*/
6667eHalStatus sme_HandleChangeCountryCode(tpAniSirGlobal pMac, void *pMsgBuf)
6668{
6669 eHalStatus status = eHAL_STATUS_SUCCESS;
6670 tAniChangeCountryCodeReq *pMsg;
6671 v_REGDOMAIN_t domainIdIoctl;
6672 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
6673 static uNvTables nvTables;
6674 pMsg = (tAniChangeCountryCodeReq *)pMsgBuf;
6675
6676
6677 /* if the reset Supplicant country code command is triggered, enable 11D, reset the NV country code and return */
6678 if( VOS_TRUE == vos_mem_compare(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2) )
6679 {
6680 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6681
6682 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
6683
6684 /* read the country code from NV and use it */
6685 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
6686 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306687 vos_mem_copy(pMsg->countryCode,
6688 nvTables.defaultCountryTable.countryCode,
6689 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 }
6691 else
6692 {
6693 status = eHAL_STATUS_FAILURE;
6694 return status;
6695 }
6696 }
6697 else
6698 {
6699 /* if Supplicant country code has priority, disable 11d */
Gopichand Nakkalaacd94112013-05-29 21:37:47 +05306700 if(pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
6701 pMsg->countryFromUserSpace)
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 {
6703 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
6704 }
6705 }
6706
6707 /* WEXT set country code means
6708 * 11D should be supported?
6709 * 11D Channel should be enforced?
6710 * 11D Country code should be matched?
6711 * 11D Reg Domian should be matched?
6712 * Country string changed */
6713 if(pMac->roam.configParam.Is11dSupportEnabled &&
6714 pMac->roam.configParam.fEnforce11dChannels &&
6715 pMac->roam.configParam.fEnforceCountryCodeMatch &&
6716 pMac->roam.configParam.fEnforceDefaultDomain &&
6717 !csrSave11dCountryString(pMac, pMsg->countryCode, eANI_BOOLEAN_TRUE))
6718 {
6719 /* All 11D related options are already enabled
6720 * Country string is not changed
6721 * Do not need do anything for country code change request */
6722 return eHAL_STATUS_SUCCESS;
6723 }
6724
6725 /* Set Current Country code and Current Regulatory domain */
6726 status = csrSetCountryCode(pMac, pMsg->countryCode, NULL);
6727 if(eHAL_STATUS_SUCCESS != status)
6728 {
6729 /* Supplicant country code failed. So give 11D priority */
6730 pMac->roam.configParam.Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabledOriginal;
6731 smsLog(pMac, LOGE, "Set Country Code Fail %d", status);
6732 return status;
6733 }
6734
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 /* overwrite the defualt country code */
Kiet Lam64c1b492013-07-12 13:56:44 +05306736 vos_mem_copy(pMac->scan.countryCodeDefault,
6737 pMac->scan.countryCodeCurrent,
6738 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07006739
6740 /* Get Domain ID from country code */
6741 status = csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent,(v_REGDOMAIN_t *) &domainIdIoctl );
6742 if ( status != eHAL_STATUS_SUCCESS )
6743 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006744 smsLog( pMac, LOGE, FL(" fail to get regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 return status;
6746 }
6747
6748 status = WDA_SetRegDomain(pMac, domainIdIoctl);
6749
6750 if ( status != eHAL_STATUS_SUCCESS )
6751 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006752 smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainIdIoctl );
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 return status;
6754 }
6755
6756 /* set to default domain ID */
6757 pMac->scan.domainIdDefault = pMac->scan.domainIdCurrent;
6758
6759 /* get the channels based on new cc */
6760 status = csrInitGetChannels( pMac );
6761
6762 if ( status != eHAL_STATUS_SUCCESS )
6763 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006764 smsLog( pMac, LOGE, FL(" fail to get Channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07006765 return status;
6766 }
6767
6768 /* reset info based on new cc, and we are done */
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08006769 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 if( pMsg->changeCCCallback )
6771 {
6772 ((tSmeChangeCountryCallback)(pMsg->changeCCCallback))((void *)pMsg->pDevContext);
6773 }
6774
6775 return eHAL_STATUS_SUCCESS;
6776}
6777
6778#ifdef WLAN_FEATURE_PACKET_FILTERING
Amar Singhalf3a6e762013-02-19 15:06:50 -08006779eHalStatus sme_8023MulticastList (tHalHandle hHal, tANI_U8 sessionId, tpSirRcvFltMcAddrList pMulticastAddrs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006780{
6781 tpSirRcvFltMcAddrList pRequestBuf;
6782 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006783 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnsone7245742012-09-05 17:12:55 -07006784 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006785
6786 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: "
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05306787 "ulMulticastAddrCnt=%d, multicastAddr[0]=%p", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 pMulticastAddrs->ulMulticastAddrCnt,
6789 pMulticastAddrs->multicastAddr[0]);
Jeff Johnsone7245742012-09-05 17:12:55 -07006790
6791 /*
6792 *Find the connected Infra / P2P_client connected session
Amar Singhalf3a6e762013-02-19 15:06:50 -08006793 */
6794 if (CSR_IS_SESSION_VALID(pMac, sessionId) &&
6795 csrIsConnStateInfra(pMac, sessionId))
6796 {
6797 pSession = CSR_GET_SESSION( pMac, sessionId );
6798 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006799
6800 if(pSession == NULL )
6801 {
6802 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Unable to find "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006803 "the right session", __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07006804 return eHAL_STATUS_FAILURE;
6805 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006806
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltMcAddrList));
6808 if (NULL == pRequestBuf)
6809 {
6810 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006811 "allocate memory for 8023 Multicast List request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006812 return eHAL_STATUS_FAILED_ALLOC;
6813 }
Amar Singhalf3a6e762013-02-19 15:06:50 -08006814
6815 if( !csrIsConnStateConnectedInfra (pMac, sessionId ))
6816 {
6817 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Ignoring the "
6818 "indication as we are not connected", __func__);
6819 vos_mem_free(pRequestBuf);
6820 return eHAL_STATUS_FAILURE;
6821 }
6822
Jeff Johnson295189b2012-06-20 16:38:30 -07006823 vos_mem_copy(pRequestBuf, pMulticastAddrs, sizeof(tSirRcvFltMcAddrList));
6824
Kiet Lam64c1b492013-07-12 13:56:44 +05306825 vos_mem_copy(pRequestBuf->selfMacAddr, pSession->selfMacAddr,
6826 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07006827 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid,
6828 sizeof(tSirMacAddr));
6829
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 msg.type = WDA_8023_MULTICAST_LIST_REQ;
6831 msg.reserved = 0;
6832 msg.bodyptr = pRequestBuf;
6833 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6834 {
6835 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006836 "post WDA_8023_MULTICAST_LIST message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006837 vos_mem_free(pRequestBuf);
6838 return eHAL_STATUS_FAILURE;
6839 }
6840
6841 return eHAL_STATUS_SUCCESS;
6842}
6843
Jeff Johnsone7245742012-09-05 17:12:55 -07006844eHalStatus sme_ReceiveFilterSetFilter(tHalHandle hHal, tpSirRcvPktFilterCfgType pRcvPktFilterCfg,
6845 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006846{
6847 tpSirRcvPktFilterCfgType pRequestBuf;
6848 v_SINT_t allocSize;
6849 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006850 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6851 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 v_U8_t idx=0;
6853
6854 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterType=%d, "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006855 "filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 pRcvPktFilterCfg->filterType, pRcvPktFilterCfg->filterId);
6857
Madan Mohan Koyyalamudid4029622012-10-18 20:30:17 -07006858 allocSize = sizeof(tSirRcvPktFilterCfgType);
6859
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 pRequestBuf = vos_mem_malloc(allocSize);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006861
6862 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 {
6864 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006865 "allocate memory for Receive Filter Set Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 return eHAL_STATUS_FAILED_ALLOC;
6867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006868
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006869 if( NULL == pSession )
6870 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006871 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Session Not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006872 vos_mem_free(pRequestBuf);
6873 return eHAL_STATUS_FAILURE;
6874 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006875
Kiet Lam64c1b492013-07-12 13:56:44 +05306876 vos_mem_copy(pRcvPktFilterCfg->selfMacAddr, pSession->selfMacAddr,
6877 sizeof(tSirMacAddr));
6878 vos_mem_copy(pRcvPktFilterCfg->bssId, pSession->connectedProfile.bssid,
6879 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006880 vos_mem_copy(pRequestBuf, pRcvPktFilterCfg, allocSize);
6881
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 msg.type = WDA_RECEIVE_FILTER_SET_FILTER_REQ;
6883 msg.reserved = 0;
6884 msg.bodyptr = pRequestBuf;
6885
6886 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6887 "FT %d FID %d ",
6888 pRequestBuf->filterType, pRequestBuf->filterId);
6889
6890 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Pkt Flt Req : "
6891 "params %d CT %d",
6892 pRequestBuf->numFieldParams, pRequestBuf->coalesceTime);
6893
6894 for (idx=0; idx<pRequestBuf->numFieldParams; idx++)
6895 {
6896
6897 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006898 "Proto %d Comp Flag %d ",
Jeff Johnson295189b2012-06-20 16:38:30 -07006899 pRequestBuf->paramsData[idx].protocolLayer,
6900 pRequestBuf->paramsData[idx].cmpFlag);
6901
6902 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006903 "Data Offset %d Data Len %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 pRequestBuf->paramsData[idx].dataOffset,
6905 pRequestBuf->paramsData[idx].dataLength);
6906
6907 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006908 "CData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 pRequestBuf->paramsData[idx].compareData[0],
6910 pRequestBuf->paramsData[idx].compareData[1],
6911 pRequestBuf->paramsData[idx].compareData[2],
6912 pRequestBuf->paramsData[idx].compareData[3],
6913 pRequestBuf->paramsData[idx].compareData[4],
6914 pRequestBuf->paramsData[idx].compareData[5]);
6915
6916 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08006917 "MData: %d:%d:%d:%d:%d:%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 pRequestBuf->paramsData[idx].dataMask[0],
6919 pRequestBuf->paramsData[idx].dataMask[1],
6920 pRequestBuf->paramsData[idx].dataMask[2],
6921 pRequestBuf->paramsData[idx].dataMask[3],
6922 pRequestBuf->paramsData[idx].dataMask[4],
6923 pRequestBuf->paramsData[idx].dataMask[5]);
6924
6925 }
6926
6927 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6928 {
6929 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006930 "WDA_RECEIVE_FILTER_SET_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 vos_mem_free(pRequestBuf);
6932 return eHAL_STATUS_FAILURE;
6933 }
6934
6935 return eHAL_STATUS_SUCCESS;
6936}
6937
6938eHalStatus sme_GetFilterMatchCount(tHalHandle hHal,
6939 FilterMatchCountCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006940 void *callbackContext,
6941 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006942{
6943 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
6944 eHalStatus status;
6945
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006946 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "+%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006947
6948 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme)))
6949 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006950 pmcGetFilterMatchCount(hHal, callbackRoutine, callbackContext, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 sme_ReleaseGlobalLock( &pMac->sme );
6952 }
6953
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006954 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006955
6956 return (status);
6957}
6958
Jeff Johnsone7245742012-09-05 17:12:55 -07006959eHalStatus sme_ReceiveFilterClearFilter(tHalHandle hHal, tpSirRcvFltPktClearParam pRcvFltPktClearParam,
6960 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006961{
6962 tpSirRcvFltPktClearParam pRequestBuf;
6963 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07006964 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6965 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006966
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006967 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006968 pRcvFltPktClearParam->filterId);
6969
6970 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktClearParam));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006971 if (NULL == pRequestBuf)
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 {
6973 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
6974 "%s: Not able to allocate memory for Receive Filter "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006975 "Clear Filter request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006976 return eHAL_STATUS_FAILED_ALLOC;
6977 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006978 if( NULL == pSession )
6979 {
6980 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006981 "%s: Session Not find ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006982 vos_mem_free(pRequestBuf);
6983 return eHAL_STATUS_FAILURE;
6984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006985
Kiet Lam64c1b492013-07-12 13:56:44 +05306986 vos_mem_copy(pRcvFltPktClearParam->selfMacAddr, pSession->selfMacAddr,
6987 sizeof(tSirMacAddr));
6988 vos_mem_copy(pRcvFltPktClearParam->bssId, pSession->connectedProfile.bssid,
6989 sizeof(tSirMacAddr));
Jeff Johnsone7245742012-09-05 17:12:55 -07006990
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006991 vos_mem_copy(pRequestBuf, pRcvFltPktClearParam, sizeof(tSirRcvFltPktClearParam));
6992
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 msg.type = WDA_RECEIVE_FILTER_CLEAR_FILTER_REQ;
6994 msg.reserved = 0;
6995 msg.bodyptr = pRequestBuf;
6996 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
6997 {
6998 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006999 "WDA_RECEIVE_FILTER_CLEAR_FILTER message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007000 vos_mem_free(pRequestBuf);
7001 return eHAL_STATUS_FAILURE;
7002 }
7003
7004 return eHAL_STATUS_SUCCESS;
7005}
7006#endif // WLAN_FEATURE_PACKET_FILTERING
7007
7008/* ---------------------------------------------------------------------------
7009 \fn sme_PreChannelSwitchIndFullPowerCB
7010 \brief call back function for the PMC full power request because of pre
7011 channel switch.
7012 \param callbackContext
7013 \param status
7014 ---------------------------------------------------------------------------*/
7015void sme_PreChannelSwitchIndFullPowerCB(void *callbackContext,
7016 eHalStatus status)
7017{
7018 tpAniSirGlobal pMac = (tpAniSirGlobal)callbackContext;
7019 tSirMbMsg *pMsg;
7020 tANI_U16 msgLen;
7021
7022 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
Kiet Lam64c1b492013-07-12 13:56:44 +05307023 pMsg = vos_mem_malloc(msgLen);
7024 if ( NULL != pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -07007025 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307026 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_PRE_CHANNEL_SWITCH_FULL_POWER);
7028 pMsg->msgLen = pal_cpu_to_be16(msgLen);
7029 status = palSendMBMessage(pMac->hHdd, pMsg);
7030 }
7031
7032 return;
7033}
7034
7035/* ---------------------------------------------------------------------------
7036 \fn sme_HandlePreChannelSwitchInd
7037 \brief Processes the indcation from PE for pre-channel switch.
7038 \param hHal
7039 \- The handle returned by macOpen. return eHalStatus
7040 ---------------------------------------------------------------------------*/
7041eHalStatus sme_HandlePreChannelSwitchInd(tHalHandle hHal)
7042{
7043 eHalStatus status = eHAL_STATUS_FAILURE;
7044 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7045 status = sme_AcquireGlobalLock( &pMac->sme );
7046 if ( HAL_STATUS_SUCCESS( status ) )
7047 {
7048 status = pmcRequestFullPower(hHal, sme_PreChannelSwitchIndFullPowerCB,
7049 pMac, eSME_FULL_PWR_NEEDED_BY_CHANNEL_SWITCH);
7050 sme_ReleaseGlobalLock( &pMac->sme );
7051 }
7052
7053 return (status);
7054}
7055
7056/* ---------------------------------------------------------------------------
7057 \fn sme_HandlePostChannelSwitchInd
7058 \brief Processes the indcation from PE for post-channel switch.
7059 \param hHal
7060 \- The handle returned by macOpen. return eHalStatus
7061 ---------------------------------------------------------------------------*/
7062eHalStatus sme_HandlePostChannelSwitchInd(tHalHandle hHal)
7063{
7064 eHalStatus status = eHAL_STATUS_FAILURE;
7065 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7066
7067 status = sme_AcquireGlobalLock( &pMac->sme );
7068 if ( HAL_STATUS_SUCCESS( status ) )
7069 {
7070 status = pmcRequestBmps(hHal, NULL, NULL);
7071 sme_ReleaseGlobalLock( &pMac->sme );
7072 }
7073
7074 return (status);
7075}
7076
7077/* ---------------------------------------------------------------------------
7078
7079 \fn sme_IsChannelValid
7080
7081 \brief To check if the channel is valid for currently established domain
7082 This is a synchronous API.
7083
7084 \param hHal - The handle returned by macOpen.
7085 \param channel - channel to verify
7086
7087 \return TRUE/FALSE, TRUE if channel is valid
7088
7089 -------------------------------------------------------------------------------*/
7090tANI_BOOLEAN sme_IsChannelValid(tHalHandle hHal, tANI_U8 channel)
7091{
7092 eHalStatus status = eHAL_STATUS_FAILURE;
7093 tANI_BOOLEAN valid = FALSE;
7094 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7095
7096 status = sme_AcquireGlobalLock( &pMac->sme );
7097 if ( HAL_STATUS_SUCCESS( status ) )
7098 {
7099
7100 valid = csrRoamIsChannelValid( pMac, channel);
7101
7102 sme_ReleaseGlobalLock( &pMac->sme );
7103 }
7104
7105 return (valid);
7106}
7107
7108/* ---------------------------------------------------------------------------
7109 \fn sme_SetFreqBand
7110 \brief Used to set frequency band.
7111 \param hHal
7112 \eBand band value to be configured
7113 \- return eHalStatus
7114 -------------------------------------------------------------------------*/
7115eHalStatus sme_SetFreqBand(tHalHandle hHal, eCsrBand eBand)
7116{
7117 eHalStatus status = eHAL_STATUS_FAILURE;
7118 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7119
7120 status = sme_AcquireGlobalLock( &pMac->sme );
7121 if ( HAL_STATUS_SUCCESS( status ) )
7122 {
7123 status = csrSetBand(hHal, eBand);
7124 sme_ReleaseGlobalLock( &pMac->sme );
7125 }
7126 return status;
7127}
7128
7129/* ---------------------------------------------------------------------------
7130 \fn sme_GetFreqBand
7131 \brief Used to get the current band settings.
7132 \param hHal
7133 \pBand pointer to hold band value
7134 \- return eHalStatus
7135 -------------------------------------------------------------------------*/
7136eHalStatus sme_GetFreqBand(tHalHandle hHal, eCsrBand *pBand)
7137{
7138 eHalStatus status = eHAL_STATUS_FAILURE;
7139 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7140
7141 status = sme_AcquireGlobalLock( &pMac->sme );
7142 if ( HAL_STATUS_SUCCESS( status ) )
7143 {
7144 *pBand = csrGetCurrentBand( hHal );
7145 sme_ReleaseGlobalLock( &pMac->sme );
7146 }
7147 return status;
7148}
7149
7150#ifdef WLAN_WAKEUP_EVENTS
7151/******************************************************************************
7152 \fn sme_WakeReasonIndCallback
7153
7154 \brief
7155 a callback function called when SME received eWNI_SME_WAKE_REASON_IND event from WDA
7156
7157 \param hHal - HAL handle for device
7158 \param pMsg - Message body passed from WDA; includes Wake Reason Indication parameter
7159
7160 \return eHalStatus
7161******************************************************************************/
7162eHalStatus sme_WakeReasonIndCallback (tHalHandle hHal, void* pMsg)
7163{
7164 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7165 eHalStatus status = eHAL_STATUS_SUCCESS;
7166 tSirWakeReasonInd *pWakeReasonInd = (tSirWakeReasonInd *)pMsg;
7167
7168 if (NULL == pMsg)
7169 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007170 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 status = eHAL_STATUS_FAILURE;
7172 }
7173 else
7174 {
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007175 smsLog(pMac, LOG2, "SME: entering sme_WakeReasonIndCallback");
Jeff Johnson295189b2012-06-20 16:38:30 -07007176
7177 /* Call Wake Reason Indication callback routine. */
7178 if (pMac->pmc.wakeReasonIndCB != NULL)
7179 pMac->pmc.wakeReasonIndCB(pMac->pmc.wakeReasonIndCBContext, pWakeReasonInd);
7180
7181 pMac->pmc.wakeReasonIndCB = NULL;
7182 pMac->pmc.wakeReasonIndCBContext = NULL;
7183
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007184 smsLog(pMac, LOG1, "Wake Reason Indication in %s(), reason=%d", __func__, pWakeReasonInd->ulReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 }
7186
7187 return(status);
7188}
7189#endif // WLAN_WAKEUP_EVENTS
7190
7191
7192/* ---------------------------------------------------------------------------
7193
7194 \fn sme_SetMaxTxPower
7195
7196 \brief Set the Maximum Transmit Power dynamically. Note: this setting will
7197 not persist over reboots.
7198
7199 \param hHal
7200 \param pBssid BSSID to set the power cap for
7201 \param pBssid pSelfMacAddress self MAC Address
7202 \param pBssid power to set in dB
7203 \- return eHalStatus
7204
7205 -------------------------------------------------------------------------------*/
7206eHalStatus sme_SetMaxTxPower(tHalHandle hHal, tSirMacAddr pBssid,
7207 tSirMacAddr pSelfMacAddress, v_S7_t dB)
7208{
7209 vos_msg_t msg;
7210 tpMaxTxPowerParams pMaxTxParams = NULL;
7211
7212 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
7213 if (NULL == pMaxTxParams)
7214 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007215 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for pMaxTxParams", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 return eHAL_STATUS_FAILURE;
7217 }
7218
7219 vos_mem_copy(pMaxTxParams->bssId, pBssid, SIR_MAC_ADDR_LENGTH);
Kiet Lam64c1b492013-07-12 13:56:44 +05307220 vos_mem_copy(pMaxTxParams->selfStaMacAddr, pSelfMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 SIR_MAC_ADDR_LENGTH);
7222 pMaxTxParams->power = dB;
7223
7224 msg.type = WDA_SET_MAX_TX_POWER_REQ;
7225 msg.reserved = 0;
7226 msg.bodyptr = pMaxTxParams;
7227
7228 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
7229 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007230 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_MAX_TX_POWER_REQ message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007231 vos_mem_free(pMaxTxParams);
7232 return eHAL_STATUS_FAILURE;
7233 }
7234
7235 return eHAL_STATUS_SUCCESS;
7236}
7237
Jeff Johnson295189b2012-06-20 16:38:30 -07007238/* ---------------------------------------------------------------------------
7239
schang86c22c42013-03-13 18:41:24 -07007240 \fn sme_SetTxPower
7241
7242 \brief Set Transmit Power dynamically. Note: this setting will
7243 not persist over reboots.
7244
7245 \param hHal
7246 \param sessionId Target Session ID
7247 \param mW power to set in mW
7248 \- return eHalStatus
7249
7250 -------------------------------------------------------------------------------*/
7251eHalStatus sme_SetTxPower(tHalHandle hHal, v_U8_t sessionId, v_U8_t mW)
7252{
7253
7254 eHalStatus status = eHAL_STATUS_FAILURE;
7255 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7256
7257 smsLog(pMac, LOG1, FL("set tx power %dmW"), mW);
7258 status = sme_AcquireGlobalLock(&pMac->sme);
7259 if (HAL_STATUS_SUCCESS(status))
7260 {
7261 status = csrSetTxPower(pMac, sessionId, mW);
7262 sme_ReleaseGlobalLock(&pMac->sme);
7263 }
7264 return status;
7265}
7266
7267/* ---------------------------------------------------------------------------
7268
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 \fn sme_HideSSID
7270
7271 \brief hide/show SSID dynamically. Note: this setting will
7272 not persist over reboots.
7273
7274 \param hHal
7275 \param sessionId
7276 \param ssidHidden 0 - Broadcast SSID, 1 - Disable broadcast SSID
7277 \- return eHalStatus
7278
7279 -------------------------------------------------------------------------------*/
7280eHalStatus sme_HideSSID(tHalHandle hHal, v_U8_t sessionId, v_U8_t ssidHidden)
7281{
7282 eHalStatus status = eHAL_STATUS_SUCCESS;
7283 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7284 tANI_U16 len;
7285
7286 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7287 {
7288 tpSirUpdateParams pMsg;
7289 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007290
7291 if(!pSession)
7292 {
7293 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08007294 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007295 return eHAL_STATUS_FAILURE;
7296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007297
7298 if( !pSession->sessionActive )
7299 VOS_ASSERT(0);
7300
7301 /* Create the message and send to lim */
7302 len = sizeof(tSirUpdateParams);
Kiet Lam64c1b492013-07-12 13:56:44 +05307303 pMsg = vos_mem_malloc(len);
7304 if ( NULL == pMsg )
7305 status = eHAL_STATUS_FAILURE;
7306 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007307 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307308 vos_mem_set(pMsg, sizeof(tSirUpdateParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007309 pMsg->messageType = eWNI_SME_HIDE_SSID_REQ;
7310 pMsg->length = len;
7311 /* Data starts from here */
7312 pMsg->sessionId = sessionId;
7313 pMsg->ssidHidden = ssidHidden;
7314 status = palSendMBMessage(pMac->hHdd, pMsg);
7315 }
7316 sme_ReleaseGlobalLock( &pMac->sme );
7317 }
7318 return status;
7319}
Jeff Johnson295189b2012-06-20 16:38:30 -07007320
7321/* ---------------------------------------------------------------------------
7322
7323 \fn sme_SetTmLevel
7324 \brief Set Thermal Mitigation Level to RIVA
7325 \param hHal - The handle returned by macOpen.
7326 \param newTMLevel - new Thermal Mitigation Level
7327 \param tmMode - Thermal Mitigation handle mode, default 0
7328 \return eHalStatus
7329 ---------------------------------------------------------------------------*/
7330eHalStatus sme_SetTmLevel(tHalHandle hHal, v_U16_t newTMLevel, v_U16_t tmMode)
7331{
7332 eHalStatus status = eHAL_STATUS_SUCCESS;
7333 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
7334 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7335 vos_msg_t vosMessage;
7336 tAniSetTmLevelReq *setTmLevelReq = NULL;
7337
7338 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme ) ) )
7339 {
7340 setTmLevelReq = (tAniSetTmLevelReq *)vos_mem_malloc(sizeof(tAniSetTmLevelReq));
Kiet Lam64c1b492013-07-12 13:56:44 +05307341 if (NULL == setTmLevelReq)
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 {
7343 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007344 "%s: Not able to allocate memory for sme_SetTmLevel", __func__);
Leela Venkata Kiran Kumar Reddy Chirala090cc1f2013-03-07 17:40:17 -08007345 sme_ReleaseGlobalLock( &pMac->sme );
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 return eHAL_STATUS_FAILURE;
7347 }
7348
7349 setTmLevelReq->tmMode = tmMode;
7350 setTmLevelReq->newTmLevel = newTMLevel;
7351
7352 /* serialize the req through MC thread */
7353 vosMessage.bodyptr = setTmLevelReq;
7354 vosMessage.type = WDA_SET_TM_LEVEL_REQ;
7355 vosStatus = vos_mq_post_message( VOS_MQ_ID_WDA, &vosMessage );
7356 if ( !VOS_IS_STATUS_SUCCESS(vosStatus) )
7357 {
7358 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007359 "%s: Post Set TM Level MSG fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 vos_mem_free(setTmLevelReq);
7361 status = eHAL_STATUS_FAILURE;
7362 }
7363 sme_ReleaseGlobalLock( &pMac->sme );
7364 }
7365 return(status);
7366}
7367
7368/*---------------------------------------------------------------------------
7369
7370 \brief sme_featureCapsExchange() - SME interface to exchange capabilities between
7371 Host and FW.
7372
7373 \param hHal - HAL handle for device
7374
7375 \return NONE
7376
7377---------------------------------------------------------------------------*/
7378void sme_featureCapsExchange( tHalHandle hHal)
7379{
7380 v_CONTEXT_t vosContext = vos_get_global_context(VOS_MODULE_ID_SME, NULL);
7381 WDA_featureCapsExchange(vosContext);
7382}
Jeff Johnsond13512a2012-07-17 11:42:19 -07007383
Yathish9f22e662012-12-10 14:21:35 -08007384/*---------------------------------------------------------------------------
7385
7386 \brief sme_disableFeatureCapablity() - SME interface to disable Active mode offload capablity
7387 in Host.
7388
7389 \param hHal - HAL handle for device
7390
7391 \return NONE
7392
7393---------------------------------------------------------------------------*/
7394void sme_disableFeatureCapablity(tANI_U8 feature_index)
7395{
7396 WDA_disableCapablityFeature(feature_index);
7397}
7398
7399
Jeff Johnsond13512a2012-07-17 11:42:19 -07007400
7401/* ---------------------------------------------------------------------------
7402
7403 \fn sme_GetDefaultCountryCode
7404
7405 \brief Get the default country code from NV
7406
7407 \param hHal
7408 \param pCountry
7409 \- return eHalStatus
7410
7411 -------------------------------------------------------------------------------*/
7412eHalStatus sme_GetDefaultCountryCodeFrmNv(tHalHandle hHal, tANI_U8 *pCountry)
7413{
7414 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7415 return csrGetDefaultCountryCodeFrmNv(pMac, pCountry);
7416}
7417
7418/* ---------------------------------------------------------------------------
7419
7420 \fn sme_GetCurrentCountryCode
7421
7422 \brief Get the current country code
7423
7424 \param hHal
7425 \param pCountry
7426 \- return eHalStatus
7427
7428 -------------------------------------------------------------------------------*/
7429eHalStatus sme_GetCurrentCountryCode(tHalHandle hHal, tANI_U8 *pCountry)
7430{
7431 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7432 return csrGetCurrentCountryCode(pMac, pCountry);
7433}
7434
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007435/* ---------------------------------------------------------------------------
7436 \fn sme_transportDebug
7437 \brief Dynamically monitoring Transport channels
7438 Private IOCTL will querry transport channel status if driver loaded
schang6295e542013-03-12 15:31:23 -07007439 \param hHal Upper MAC context
Jeff Johnsonb88db982012-12-10 13:34:59 -08007440 \param displaySnapshot Display transport channel snapshot option
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007441 \param toggleStallDetect Enable stall detect feature
7442 This feature will take effect to data performance
7443 Not integrate till fully verification
7444 \- return NONE
7445 -------------------------------------------------------------------------*/
schang6295e542013-03-12 15:31:23 -07007446void sme_transportDebug(tHalHandle hHal, v_BOOL_t displaySnapshot, v_BOOL_t toggleStallDetect)
Madan Mohan Koyyalamudi8cb53982012-09-28 14:34:47 -07007447{
schang6295e542013-03-12 15:31:23 -07007448 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7449
7450 if (NULL == pMac)
7451 {
7452 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7453 "%s: invalid context", __func__);
7454 return;
7455 }
7456 WDA_TransportChannelDebug(pMac, displaySnapshot, toggleStallDetect);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07007457}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007458
Kiran4a17ebe2013-01-31 10:43:43 -08007459/* ---------------------------------------------------------------------------
7460 \fn sme_ResetPowerValuesFor5G
7461 \brief Reset the power values for 5G band with NV power values.
7462 \param hHal - HAL handle for device
7463 \- return NONE
7464 -------------------------------------------------------------------------*/
7465void sme_ResetPowerValuesFor5G (tHalHandle hHal)
7466{
7467 tpAniSirGlobal pMac = PMAC_STRUCT (hHal);
7468 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
7469 csrApplyPower2Current(pMac); // Store the channel+power info in the global place: Cfg
7470}
7471
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007472#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
7473/* ---------------------------------------------------------------------------
7474 \fn sme_UpdateRoamPrefer5GHz
7475 \brief enable/disable Roam prefer 5G runtime option
7476 This function is called through dynamic setConfig callback function
7477 to configure the Roam prefer 5G runtime option
7478 \param hHal - HAL handle for device
7479 \param nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
7480 \- return Success or failure
7481 -------------------------------------------------------------------------*/
7482
7483eHalStatus sme_UpdateRoamPrefer5GHz(tHalHandle hHal, v_BOOL_t nRoamPrefer5GHz)
7484{
7485 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08007486 eHalStatus status = eHAL_STATUS_SUCCESS;
7487
7488 status = sme_AcquireGlobalLock( &pMac->sme );
7489 if ( HAL_STATUS_SUCCESS( status ) )
7490 {
7491 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7492 "%s: gRoamPrefer5GHz is changed from %d to %d", __func__,
7493 pMac->roam.configParam.nRoamPrefer5GHz,
7494 nRoamPrefer5GHz);
7495 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
7496 sme_ReleaseGlobalLock( &pMac->sme );
7497 }
7498
7499 return status ;
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08007500}
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08007501
7502/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007503 \fn sme_setRoamIntraBand
7504 \brief enable/disable Intra band roaming
7505 This function is called through dynamic setConfig callback function
7506 to configure the intra band roaming
7507 \param hHal - HAL handle for device
7508 \param nRoamIntraBand Enable/Disable Intra band roaming
7509 \- return Success or failure
7510 -------------------------------------------------------------------------*/
7511eHalStatus sme_setRoamIntraBand(tHalHandle hHal, const v_BOOL_t nRoamIntraBand)
7512{
7513 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7514 eHalStatus status = eHAL_STATUS_SUCCESS;
7515
7516 status = sme_AcquireGlobalLock( &pMac->sme );
7517 if ( HAL_STATUS_SUCCESS( status ) )
7518 {
7519 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7520 "%s: gRoamIntraBand is changed from %d to %d", __func__,
7521 pMac->roam.configParam.nRoamIntraBand,
7522 nRoamIntraBand);
7523 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
7524 sme_ReleaseGlobalLock( &pMac->sme );
7525 }
7526
7527 return status ;
7528}
7529
7530/* ---------------------------------------------------------------------------
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007531 \fn sme_UpdateRoamScanNProbes
7532 \brief function to update roam scan N probes
7533 This function is called through dynamic setConfig callback function
7534 to update roam scan N probes
7535 \param hHal - HAL handle for device
7536 \param nProbes number of probe requests to be sent out
7537 \- return Success or failure
7538 -------------------------------------------------------------------------*/
7539eHalStatus sme_UpdateRoamScanNProbes(tHalHandle hHal, const v_U8_t nProbes)
7540{
7541 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7542 eHalStatus status = eHAL_STATUS_SUCCESS;
7543
7544 status = sme_AcquireGlobalLock( &pMac->sme );
7545 if ( HAL_STATUS_SUCCESS( status ) )
7546 {
7547 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7548 "%s: gRoamScanNProbes is changed from %d to %d", __func__,
7549 pMac->roam.configParam.nProbes,
7550 nProbes);
7551 pMac->roam.configParam.nProbes = nProbes;
7552 sme_ReleaseGlobalLock( &pMac->sme );
7553 }
7554#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7555 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7556 {
7557 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7558 REASON_NPROBES_CHANGED);
7559 }
7560#endif
7561 return status ;
7562}
7563
7564/* ---------------------------------------------------------------------------
7565 \fn sme_UpdateRoamScanHomeAwayTime
7566 \brief function to update roam scan Home away time
7567 This function is called through dynamic setConfig callback function
7568 to update roam scan home away time
7569 \param hHal - HAL handle for device
7570 \param nRoamScanAwayTime Scan home away time
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07007571 \param bSendOffloadCmd If TRUE then send offload command to firmware
7572 If FALSE then command is not sent to firmware
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007573 \- return Success or failure
7574 -------------------------------------------------------------------------*/
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07007575eHalStatus sme_UpdateRoamScanHomeAwayTime(tHalHandle hHal, const v_U16_t nRoamScanHomeAwayTime,
7576 const eAniBoolean bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007577{
7578 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7579 eHalStatus status = eHAL_STATUS_SUCCESS;
7580
7581 status = sme_AcquireGlobalLock( &pMac->sme );
7582 if ( HAL_STATUS_SUCCESS( status ) )
7583 {
7584 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7585 "%s: gRoamScanHomeAwayTime is changed from %d to %d", __func__,
7586 pMac->roam.configParam.nRoamScanHomeAwayTime,
7587 nRoamScanHomeAwayTime);
7588 pMac->roam.configParam.nRoamScanHomeAwayTime = nRoamScanHomeAwayTime;
7589 sme_ReleaseGlobalLock( &pMac->sme );
7590 }
7591
7592#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07007593 if (pMac->roam.configParam.isRoamOffloadScanEnabled && bSendOffloadCmd)
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007594 {
7595 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7596 REASON_HOME_AWAY_TIME_CHANGED);
7597 }
7598#endif
7599 return status;
7600}
7601
7602
7603/* ---------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007604 \fn sme_getRoamIntraBand
7605 \brief get Intra band roaming
7606 \param hHal - HAL handle for device
7607 \- return Success or failure
7608 -------------------------------------------------------------------------*/
7609v_BOOL_t sme_getRoamIntraBand(tHalHandle hHal)
7610{
7611 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7612 return pMac->roam.configParam.nRoamIntraBand;
7613}
7614
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07007615/* ---------------------------------------------------------------------------
7616 \fn sme_getRoamScanNProbes
7617 \brief get N Probes
7618 \param hHal - HAL handle for device
7619 \- return Success or failure
7620 -------------------------------------------------------------------------*/
7621v_U8_t sme_getRoamScanNProbes(tHalHandle hHal)
7622{
7623 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7624 return pMac->roam.configParam.nProbes;
7625}
7626
7627/* ---------------------------------------------------------------------------
7628 \fn sme_getRoamScanHomeAwayTime
7629 \brief get Roam scan home away time
7630 \param hHal - HAL handle for device
7631 \- return Success or failure
7632 -------------------------------------------------------------------------*/
7633v_U16_t sme_getRoamScanHomeAwayTime(tHalHandle hHal)
7634{
7635 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7636 return pMac->roam.configParam.nRoamScanHomeAwayTime;
7637}
7638
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007639
7640/* ---------------------------------------------------------------------------
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08007641 \fn sme_UpdateImmediateRoamRssiDiff
7642 \brief Update nImmediateRoamRssiDiff
7643 This function is called through dynamic setConfig callback function
7644 to configure nImmediateRoamRssiDiff
7645 Usage: adb shell iwpriv wlan0 setConfig gImmediateRoamRssiDiff=[0 .. 125]
7646 \param hHal - HAL handle for device
7647 \param nImmediateRoamRssiDiff - minimum rssi difference between potential
7648 candidate and current AP.
7649 \- return Success or failure
7650 -------------------------------------------------------------------------*/
7651
7652eHalStatus sme_UpdateImmediateRoamRssiDiff(tHalHandle hHal, v_U8_t nImmediateRoamRssiDiff)
7653{
7654 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08007655 eHalStatus status = eHAL_STATUS_SUCCESS;
7656
7657 status = sme_AcquireGlobalLock( &pMac->sme );
7658 if ( HAL_STATUS_SUCCESS( status ) )
7659 {
7660 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7661 "LFR runtime successfully set immediate roam rssi diff to %d - old value is %d - roam state is %d",
7662 nImmediateRoamRssiDiff,
7663 pMac->roam.configParam.nImmediateRoamRssiDiff,
7664 pMac->roam.neighborRoamInfo.neighborRoamState);
7665 pMac->roam.configParam.nImmediateRoamRssiDiff = nImmediateRoamRssiDiff;
7666 sme_ReleaseGlobalLock( &pMac->sme );
7667 }
7668
7669 return status ;
7670}
7671
7672/* ---------------------------------------------------------------------------
7673 \fn sme_UpdateRoamRssiDiff
7674 \brief Update RoamRssiDiff
7675 This function is called through dynamic setConfig callback function
7676 to configure RoamRssiDiff
7677 Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
7678 \param hHal - HAL handle for device
7679 \param RoamRssiDiff - minimum rssi difference between potential
7680 candidate and current AP.
7681 \- return Success or failure
7682 -------------------------------------------------------------------------*/
7683
7684eHalStatus sme_UpdateRoamRssiDiff(tHalHandle hHal, v_U8_t RoamRssiDiff)
7685{
7686 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7687 eHalStatus status = eHAL_STATUS_SUCCESS;
7688
7689 status = sme_AcquireGlobalLock( &pMac->sme );
7690 if ( HAL_STATUS_SUCCESS( status ) )
7691 {
7692 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7693 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %d",
7694 RoamRssiDiff,
7695 pMac->roam.configParam.RoamRssiDiff,
7696 pMac->roam.neighborRoamInfo.neighborRoamState);
7697 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
7698 sme_ReleaseGlobalLock( &pMac->sme );
7699 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07007700#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7701 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7702 {
7703 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_RSSI_DIFF_CHANGED);
7704 }
7705#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08007706 return status ;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08007707}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007708
7709/*--------------------------------------------------------------------------
7710 \brief sme_UpdateFastTransitionEnabled() - enable/disable Fast Transition support at runtime
7711 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7712 isFastTransitionEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007713 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007714 \param hHal - The handle returned by macOpen.
7715 \return eHAL_STATUS_SUCCESS - SME update isFastTransitionEnabled config successfully.
7716 Other status means SME is failed to update isFastTransitionEnabled.
7717 \sa
7718 --------------------------------------------------------------------------*/
7719eHalStatus sme_UpdateFastTransitionEnabled(tHalHandle hHal,
7720 v_BOOL_t isFastTransitionEnabled)
7721{
7722 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdade697412013-02-14 16:31:48 -08007723 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007724
Srinivas Girigowdade697412013-02-14 16:31:48 -08007725 status = sme_AcquireGlobalLock( &pMac->sme );
7726 if ( HAL_STATUS_SUCCESS( status ) )
7727 {
7728 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7729 "%s: FastTransitionEnabled is changed from %d to %d", __func__,
7730 pMac->roam.configParam.isFastTransitionEnabled,
7731 isFastTransitionEnabled);
7732 pMac->roam.configParam.isFastTransitionEnabled = isFastTransitionEnabled;
7733 sme_ReleaseGlobalLock( &pMac->sme );
7734 }
7735
7736 return status ;
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007737}
Srinivas Girigowda100eb322013-03-15 16:48:20 -07007738
7739/* ---------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -07007740 \fn sme_SetRoamScanControl
7741 \brief Set roam scan control
7742 This function is called to set roam scan control
7743 if roam scan control is set to 0, roaming scan cache is cleared
7744 any value other than 0 is treated as invalid value
7745 \param hHal - HAL handle for device
7746 \return eHAL_STATUS_SUCCESS - SME update config successfully.
7747 Other status means SME failure to update
7748 -------------------------------------------------------------------------*/
7749eHalStatus sme_SetRoamScanControl(tHalHandle hHal, v_BOOL_t roamScanControl)
7750{
7751 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7752 eHalStatus status = eHAL_STATUS_SUCCESS;
7753
7754 status = sme_AcquireGlobalLock( &pMac->sme );
7755 if ( HAL_STATUS_SUCCESS( status ) )
7756 {
7757 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7758 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %d",
7759 roamScanControl,
7760 pMac->roam.configParam.nRoamScanControl,
7761 pMac->roam.neighborRoamInfo.neighborRoamState);
7762 pMac->roam.configParam.nRoamScanControl = roamScanControl;
7763 if ( 0 == roamScanControl)
7764 {
7765 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7766 "LFR runtime successfully cleared roam scan cache");
7767 csrFlushBgScanRoamChannelList(pMac);
7768#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7769 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7770 {
7771 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_FLUSH_CHANNEL_LIST);
7772 }
7773#endif
7774 }
7775 sme_ReleaseGlobalLock( &pMac->sme );
7776 }
7777 return status ;
7778}
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007779#endif /* (WLAN_FEATURE_VOWIFI_11R) || (FEATURE_WLAN_CCX) || (FEATURE_WLAN_LFR) */
7780
7781#ifdef FEATURE_WLAN_LFR
7782/*--------------------------------------------------------------------------
7783 \brief sme_UpdateIsFastRoamIniFeatureEnabled() - enable/disable LFR support at runtime
7784 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7785 isFastRoamIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007786 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007787 \param hHal - The handle returned by macOpen.
7788 \return eHAL_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config successfully.
7789 Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7790 \sa
7791 --------------------------------------------------------------------------*/
7792eHalStatus sme_UpdateIsFastRoamIniFeatureEnabled(tHalHandle hHal,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007793 const v_BOOL_t isFastRoamIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007794{
7795 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7796
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007797 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled == isFastRoamIniFeatureEnabled)
7798 {
7799 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7800 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
7801 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7802 isFastRoamIniFeatureEnabled);
7803 return eHAL_STATUS_SUCCESS;
7804 }
7805
Srinivas Girigowdade697412013-02-14 16:31:48 -08007806 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7807 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7808 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7809 isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007810 pMac->roam.configParam.isFastRoamIniFeatureEnabled = isFastRoamIniFeatureEnabled;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007811 csrNeighborRoamUpdateFastRoamingEnabled(pMac, isFastRoamIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007812
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007813 return eHAL_STATUS_SUCCESS;
7814}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07007815
7816#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7817/*--------------------------------------------------------------------------
7818 \brief sme_UpdateEnableFastRoamInConcurrency() - enable/disable LFR if Concurrent session exists
7819 This is a synchronuous call
7820 \param hHal - The handle returned by macOpen.
7821 \return eHAL_STATUS_SUCCESS
7822 Other status means SME is failed
7823 \sa
7824 --------------------------------------------------------------------------*/
7825
7826eHalStatus sme_UpdateEnableFastRoamInConcurrency(tHalHandle hHal,
7827 v_BOOL_t bFastRoamInConIniFeatureEnabled)
7828{
7829
7830 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7831 eHalStatus status = eHAL_STATUS_SUCCESS;
7832
7833 status = sme_AcquireGlobalLock( &pMac->sme );
7834 if ( HAL_STATUS_SUCCESS( status ) )
7835 {
7836 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = bFastRoamInConIniFeatureEnabled;
7837 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
7838 {
7839 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = 0;
7840 }
7841 sme_ReleaseGlobalLock( &pMac->sme );
7842 }
7843
7844 return status;
7845}
7846#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007847#endif /* FEATURE_WLAN_LFR */
7848
7849#ifdef FEATURE_WLAN_CCX
7850/*--------------------------------------------------------------------------
7851 \brief sme_UpdateIsCcxFeatureEnabled() - enable/disable CCX support at runtime
7852 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7853 isCcxIniFeatureEnabled.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007854 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007855 \param hHal - The handle returned by macOpen.
7856 \return eHAL_STATUS_SUCCESS - SME update isCcxIniFeatureEnabled config successfully.
7857 Other status means SME is failed to update isCcxIniFeatureEnabled.
7858 \sa
7859 --------------------------------------------------------------------------*/
7860
7861eHalStatus sme_UpdateIsCcxFeatureEnabled(tHalHandle hHal,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007862 const v_BOOL_t isCcxIniFeatureEnabled)
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007863{
7864 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7865
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007866 if (pMac->roam.configParam.isCcxIniFeatureEnabled == isCcxIniFeatureEnabled)
7867 {
7868 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7869 "%s: CCX Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)", __func__,
7870 pMac->roam.configParam.isCcxIniFeatureEnabled,
7871 isCcxIniFeatureEnabled);
7872 return eHAL_STATUS_SUCCESS;
7873 }
7874
Srinivas Girigowdade697412013-02-14 16:31:48 -08007875 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7876 "%s: CcxEnabled is changed from %d to %d", __func__,
7877 pMac->roam.configParam.isCcxIniFeatureEnabled,
7878 isCcxIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007879 pMac->roam.configParam.isCcxIniFeatureEnabled = isCcxIniFeatureEnabled;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007880 csrNeighborRoamUpdateCcxModeEnabled(pMac, isCcxIniFeatureEnabled);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007881
7882 if(TRUE == isCcxIniFeatureEnabled)
7883 {
7884 sme_UpdateFastTransitionEnabled(hHal, TRUE);
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007885 }
Srinivas Girigowdaba173692013-08-07 11:55:38 -07007886
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07007887#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
7888 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
7889 {
7890 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CCX_INI_CFG_CHANGED);
7891 }
7892#endif
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007893 return eHAL_STATUS_SUCCESS;
7894}
7895#endif /* FEATURE_WLAN_CCX */
7896
7897/*--------------------------------------------------------------------------
7898 \brief sme_UpdateConfigFwRssiMonitoring() - enable/disable firmware RSSI Monitoring at runtime
7899 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7900 fEnableFwRssiMonitoring.
Srinivas Girigowdade697412013-02-14 16:31:48 -08007901 This is a synchronous call
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007902 \param hHal - The handle returned by macOpen.
7903 \return eHAL_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring. config successfully.
7904 Other status means SME is failed to update fEnableFwRssiMonitoring.
7905 \sa
7906 --------------------------------------------------------------------------*/
7907
7908eHalStatus sme_UpdateConfigFwRssiMonitoring(tHalHandle hHal,
7909 v_BOOL_t fEnableFwRssiMonitoring)
7910{
7911 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
7912
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007913 if (ccmCfgSetInt(hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR, fEnableFwRssiMonitoring,
7914 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
7915 {
7916 halStatus = eHAL_STATUS_FAILURE;
7917 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08007918 "Failure: Could not pass on WNI_CFG_PS_RSSI_MONITOR configuration info to CCM");
Gopichand Nakkala98a98af2012-12-31 14:38:47 -08007919 }
7920
7921 return (halStatus);
7922}
7923
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07007924#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srinivas Girigowdade697412013-02-14 16:31:48 -08007925/*--------------------------------------------------------------------------
7926 \brief sme_setNeighborLookupRssiThreshold() - update neighbor lookup rssi threshold
7927 This is a synchronous call
7928 \param hHal - The handle returned by macOpen.
7929 \return eHAL_STATUS_SUCCESS - SME update config successful.
7930 Other status means SME is failed to update
7931 \sa
7932 --------------------------------------------------------------------------*/
7933eHalStatus sme_setNeighborLookupRssiThreshold(tHalHandle hHal,
7934 v_U8_t neighborLookupRssiThreshold)
7935{
7936 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7937 eHalStatus status = eHAL_STATUS_SUCCESS;
7938
7939 status = sme_AcquireGlobalLock( &pMac->sme );
7940 if ( HAL_STATUS_SUCCESS( status ) )
7941 {
7942 status = csrNeighborRoamSetLookupRssiThreshold(pMac, neighborLookupRssiThreshold);
7943 if (HAL_STATUS_SUCCESS(status))
7944 {
7945 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7946 "LFR runtime successfully set Lookup threshold to %d - old value is %d - roam state is %d",
7947 neighborLookupRssiThreshold,
7948 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold,
7949 pMac->roam.neighborRoamInfo.neighborRoamState);
7950 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
7951 neighborLookupRssiThreshold;
7952 }
7953 sme_ReleaseGlobalLock( &pMac->sme );
7954 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08007955 return status;
7956}
7957
7958/*--------------------------------------------------------------------------
7959 \brief sme_setNeighborReassocRssiThreshold() - update neighbor reassoc rssi threshold
7960 This is a synchronous call
7961 \param hHal - The handle returned by macOpen.
7962 \return eHAL_STATUS_SUCCESS - SME update config successful.
7963 Other status means SME is failed to update
7964 \sa
7965 --------------------------------------------------------------------------*/
7966eHalStatus sme_setNeighborReassocRssiThreshold(tHalHandle hHal,
7967 v_U8_t neighborReassocRssiThreshold)
7968{
7969 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
7970 eHalStatus status = eHAL_STATUS_SUCCESS;
7971
7972 status = sme_AcquireGlobalLock( &pMac->sme );
7973 if ( HAL_STATUS_SUCCESS( status ) )
7974 {
7975 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
7976 "LFR runtime successfully set Reassoc threshold to %d - old value is %d - roam state is %d",
7977 neighborReassocRssiThreshold,
7978 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold,
7979 pMac->roam.neighborRoamInfo.neighborRoamState);
7980 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold =
7981 neighborReassocRssiThreshold;
7982 pMac->roam.neighborRoamInfo.cfgParams.neighborReassocThreshold =
7983 neighborReassocRssiThreshold;
7984 sme_ReleaseGlobalLock( &pMac->sme );
7985 }
7986
7987 return status ;
7988}
7989
7990
7991/*--------------------------------------------------------------------------
7992 \brief sme_getNeighborLookupRssiThreshold() - get neighbor lookup rssi threshold
7993 This is a synchronous call
7994 \param hHal - The handle returned by macOpen.
7995 \return eHAL_STATUS_SUCCESS - SME update config successful.
7996 Other status means SME is failed to update
7997 \sa
7998 --------------------------------------------------------------------------*/
7999v_U8_t sme_getNeighborLookupRssiThreshold(tHalHandle hHal)
8000{
8001 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8002 return pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
8003}
8004
8005/*--------------------------------------------------------------------------
8006 \brief sme_setNeighborScanRefreshPeriod() - set neighbor scan results refresh period
8007 This is a synchronous call
8008 \param hHal - The handle returned by macOpen.
8009 \return eHAL_STATUS_SUCCESS - SME update config successful.
8010 Other status means SME is failed to update
8011 \sa
8012 --------------------------------------------------------------------------*/
8013eHalStatus sme_setNeighborScanRefreshPeriod(tHalHandle hHal,
8014 v_U16_t neighborScanResultsRefreshPeriod)
8015{
8016 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8017 eHalStatus status = eHAL_STATUS_SUCCESS;
8018
8019 status = sme_AcquireGlobalLock( &pMac->sme );
8020 if ( HAL_STATUS_SUCCESS( status ) )
8021 {
8022 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8023 "LFR runtime successfully set roam scan refresh period to %d - old value is %d - roam state is %d",
8024 neighborScanResultsRefreshPeriod,
8025 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod,
8026 pMac->roam.neighborRoamInfo.neighborRoamState);
8027 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod =
8028 neighborScanResultsRefreshPeriod;
8029 pMac->roam.neighborRoamInfo.cfgParams.neighborResultsRefreshPeriod =
8030 neighborScanResultsRefreshPeriod;
8031
8032 sme_ReleaseGlobalLock( &pMac->sme );
8033 }
8034
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008035#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8036 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8037 {
8038 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8039 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
8040 }
8041#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08008042 return status ;
8043}
8044
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008045#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8046/*--------------------------------------------------------------------------
8047 \brief sme_UpdateRoamScanOffloadEnabled() - enable/disable roam scan offload feaure
8048 It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8049 gRoamScanOffloadEnabled.
8050 This is a synchronous call
8051 \param hHal - The handle returned by macOpen.
8052 \return eHAL_STATUS_SUCCESS - SME update config successfully.
8053 Other status means SME is failed to update.
8054 \sa
8055 --------------------------------------------------------------------------*/
8056
8057eHalStatus sme_UpdateRoamScanOffloadEnabled(tHalHandle hHal,
8058 v_BOOL_t nRoamScanOffloadEnabled)
8059{
8060 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8061 eHalStatus status = eHAL_STATUS_SUCCESS;
8062
8063 status = sme_AcquireGlobalLock( &pMac->sme );
8064 if ( HAL_STATUS_SUCCESS( status ) )
8065 {
8066 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8067 "%s: gRoamScanOffloadEnabled is changed from %d to %d", __func__,
8068 pMac->roam.configParam.isRoamOffloadScanEnabled,
8069 nRoamScanOffloadEnabled);
8070 pMac->roam.configParam.isRoamOffloadScanEnabled = nRoamScanOffloadEnabled;
8071 sme_ReleaseGlobalLock( &pMac->sme );
8072 }
8073
8074 return status ;
8075}
8076#endif
8077
Srinivas Girigowdade697412013-02-14 16:31:48 -08008078/*--------------------------------------------------------------------------
8079 \brief sme_getNeighborScanRefreshPeriod() - get neighbor scan results refresh period
8080 This is a synchronous call
8081 \param hHal - The handle returned by macOpen.
8082 \return v_U16_t - Neighbor scan results refresh period value
8083 \sa
8084 --------------------------------------------------------------------------*/
8085v_U16_t sme_getNeighborScanRefreshPeriod(tHalHandle hHal)
8086{
8087 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8088 return pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
8089}
8090
8091/*--------------------------------------------------------------------------
8092 \brief sme_getEmptyScanRefreshPeriod() - get empty scan refresh period
8093 This is a synchronuous call
8094 \param hHal - The handle returned by macOpen.
8095 \return eHAL_STATUS_SUCCESS - SME update config successful.
8096 Other status means SME is failed to update
8097 \sa
8098 --------------------------------------------------------------------------*/
8099v_U16_t sme_getEmptyScanRefreshPeriod(tHalHandle hHal)
8100{
8101 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8102 return pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
8103}
8104
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008105/* ---------------------------------------------------------------------------
8106 \fn sme_UpdateEmptyScanRefreshPeriod
8107 \brief Update nEmptyScanRefreshPeriod
8108 This function is called through dynamic setConfig callback function
8109 to configure nEmptyScanRefreshPeriod
8110 Usage: adb shell iwpriv wlan0 setConfig nEmptyScanRefreshPeriod=[0 .. 60]
8111 \param hHal - HAL handle for device
8112 \param nEmptyScanRefreshPeriod - scan period following empty scan results.
8113 \- return Success or failure
8114 -------------------------------------------------------------------------*/
8115
8116eHalStatus sme_UpdateEmptyScanRefreshPeriod(tHalHandle hHal, v_U16_t nEmptyScanRefreshPeriod)
8117{
8118 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8119 eHalStatus status = eHAL_STATUS_SUCCESS;
8120
8121 status = sme_AcquireGlobalLock( &pMac->sme );
8122 if ( HAL_STATUS_SUCCESS( status ) )
8123 {
8124 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8125 "LFR runtime successfully set roam scan period to %d - old value is %d - roam state is %d",
8126 nEmptyScanRefreshPeriod,
8127 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod,
8128 pMac->roam.neighborRoamInfo.neighborRoamState);
8129 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
8130 pMac->roam.neighborRoamInfo.cfgParams.emptyScanRefreshPeriod = nEmptyScanRefreshPeriod;
8131 sme_ReleaseGlobalLock( &pMac->sme );
8132 }
8133
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07008134#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8135 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8136 {
8137 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8138 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
8139 }
8140#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008141 return status ;
8142}
8143
8144/* ---------------------------------------------------------------------------
8145 \fn sme_setNeighborScanMinChanTime
8146 \brief Update nNeighborScanMinChanTime
8147 This function is called through dynamic setConfig callback function
8148 to configure gNeighborScanChannelMinTime
8149 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMinTime=[0 .. 60]
8150 \param hHal - HAL handle for device
8151 \param nNeighborScanMinChanTime - Channel minimum dwell time
8152 \- return Success or failure
8153 -------------------------------------------------------------------------*/
8154eHalStatus sme_setNeighborScanMinChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMinChanTime)
8155{
8156 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8157 eHalStatus status = eHAL_STATUS_SUCCESS;
8158
8159 status = sme_AcquireGlobalLock( &pMac->sme );
8160 if ( HAL_STATUS_SUCCESS( status ) )
8161 {
8162 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8163 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %d",
8164 nNeighborScanMinChanTime,
8165 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime,
8166 pMac->roam.neighborRoamInfo.neighborRoamState);
8167 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = nNeighborScanMinChanTime;
8168 pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime = nNeighborScanMinChanTime;
8169 sme_ReleaseGlobalLock( &pMac->sme );
8170 }
8171
8172 return status ;
8173}
8174
8175/* ---------------------------------------------------------------------------
8176 \fn sme_setNeighborScanMaxChanTime
8177 \brief Update nNeighborScanMaxChanTime
8178 This function is called through dynamic setConfig callback function
8179 to configure gNeighborScanChannelMaxTime
8180 Usage: adb shell iwpriv wlan0 setConfig gNeighborScanChannelMaxTime=[0 .. 60]
8181 \param hHal - HAL handle for device
8182 \param nNeighborScanMinChanTime - Channel maximum dwell time
8183 \- return Success or failure
8184 -------------------------------------------------------------------------*/
8185eHalStatus sme_setNeighborScanMaxChanTime(tHalHandle hHal, const v_U16_t nNeighborScanMaxChanTime)
8186{
8187 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8188 eHalStatus status = eHAL_STATUS_SUCCESS;
8189
8190 status = sme_AcquireGlobalLock( &pMac->sme );
8191 if ( HAL_STATUS_SUCCESS( status ) )
8192 {
8193 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8194 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %d",
8195 nNeighborScanMaxChanTime,
8196 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime,
8197 pMac->roam.neighborRoamInfo.neighborRoamState);
8198 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = nNeighborScanMaxChanTime;
8199 pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime = nNeighborScanMaxChanTime;
8200 sme_ReleaseGlobalLock( &pMac->sme );
8201 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07008202#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8203 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8204 {
8205 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8206 REASON_SCAN_CH_TIME_CHANGED);
8207 }
8208#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008209
8210 return status ;
8211}
8212
8213/* ---------------------------------------------------------------------------
8214 \fn sme_getNeighborScanMinChanTime
8215 \brief get neighbor scan min channel time
8216 \param hHal - The handle returned by macOpen.
8217 \return v_U16_t - channel min time value
8218 -------------------------------------------------------------------------*/
8219v_U16_t sme_getNeighborScanMinChanTime(tHalHandle hHal)
8220{
8221 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8222 return pMac->roam.neighborRoamInfo.cfgParams.minChannelScanTime;
8223}
8224
8225/* ---------------------------------------------------------------------------
8226 \fn sme_getNeighborScanMaxChanTime
8227 \brief get neighbor scan max channel time
8228 \param hHal - The handle returned by macOpen.
8229 \return v_U16_t - channel max time value
8230 -------------------------------------------------------------------------*/
8231v_U16_t sme_getNeighborScanMaxChanTime(tHalHandle hHal)
8232{
8233 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8234 return pMac->roam.neighborRoamInfo.cfgParams.maxChannelScanTime;
8235}
8236
8237/* ---------------------------------------------------------------------------
8238 \fn sme_setNeighborScanPeriod
8239 \brief Update nNeighborScanPeriod
8240 This function is called through dynamic setConfig callback function
8241 to configure nNeighborScanPeriod
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07008242 Usage: adb shell iwpriv wlan0 setConfig nNeighborScanPeriod=[0 .. 1000]
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008243 \param hHal - HAL handle for device
8244 \param nNeighborScanPeriod - neighbor scan period
8245 \- return Success or failure
8246 -------------------------------------------------------------------------*/
8247eHalStatus sme_setNeighborScanPeriod(tHalHandle hHal, const v_U16_t nNeighborScanPeriod)
8248{
8249 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8250 eHalStatus status = eHAL_STATUS_SUCCESS;
8251
8252 status = sme_AcquireGlobalLock( &pMac->sme );
8253 if ( HAL_STATUS_SUCCESS( status ) )
8254 {
8255 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8256 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %d",
8257 nNeighborScanPeriod,
8258 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod,
8259 pMac->roam.neighborRoamInfo.neighborRoamState);
8260 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = nNeighborScanPeriod;
8261 pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod = nNeighborScanPeriod;
8262 sme_ReleaseGlobalLock( &pMac->sme );
8263 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -07008264#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8265 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8266 {
8267 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8268 REASON_SCAN_HOME_TIME_CHANGED);
8269 }
8270#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008271
8272 return status ;
8273}
8274
8275/* ---------------------------------------------------------------------------
8276 \fn sme_getNeighborScanPeriod
8277 \brief get neighbor scan period
8278 \param hHal - The handle returned by macOpen.
8279 \return v_U16_t - neighbor scan period
8280 -------------------------------------------------------------------------*/
8281v_U16_t sme_getNeighborScanPeriod(tHalHandle hHal)
8282{
8283 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8284 return pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
8285}
8286
8287#endif
8288
Srinivas Girigowdade697412013-02-14 16:31:48 -08008289#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008290
Srinivas Girigowdade697412013-02-14 16:31:48 -08008291/*--------------------------------------------------------------------------
8292 \brief sme_getRoamRssiDiff() - get Roam rssi diff
8293 This is a synchronous call
8294 \param hHal - The handle returned by macOpen.
8295 \return v_U16_t - Rssi diff value
8296 \sa
8297 --------------------------------------------------------------------------*/
8298v_U8_t sme_getRoamRssiDiff(tHalHandle hHal)
8299{
8300 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8301 return pMac->roam.configParam.RoamRssiDiff;
8302}
8303
8304/*--------------------------------------------------------------------------
8305 \brief sme_ChangeRoamScanChannelList() - Change roam scan channel list
8306 This is a synchronous call
8307 \param hHal - The handle returned by macOpen.
8308 \return eHAL_STATUS_SUCCESS - SME update config successful.
8309 Other status means SME is failed to update
8310 \sa
8311 --------------------------------------------------------------------------*/
8312eHalStatus sme_ChangeRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
8313 tANI_U8 numChannels)
8314{
8315 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8316 eHalStatus status = eHAL_STATUS_SUCCESS;
8317 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008318 tANI_U8 oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN*2] = {0};
Srinivas Girigowdade697412013-02-14 16:31:48 -08008319 tANI_U8 newChannelList[128] = {0};
8320 tANI_U8 i = 0, j = 0;
8321
8322 status = sme_AcquireGlobalLock( &pMac->sme );
8323 if ( HAL_STATUS_SUCCESS( status ) )
8324 {
8325 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
8326 {
8327 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
8328 {
8329 j += snprintf(oldChannelList + j, sizeof(oldChannelList) - j," %d",
8330 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
8331 }
8332 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008333 csrFlushBgScanRoamChannelList(pMac);
8334 csrCreateBgScanRoamChannelList(pMac, pChannelList, numChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08008335 status = csrUpdateBgScanConfigIniChannelList(pMac, csrGetCurrentBand(hHal));
8336
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008337 if ( HAL_STATUS_SUCCESS( status ))
Srinivas Girigowdade697412013-02-14 16:31:48 -08008338 {
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008339 sme_SetRoamScanControl(hHal, 1);
8340 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -08008341 {
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008342 j = 0;
8343 for (i = 0; i < pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
8344 {
8345 j += snprintf(newChannelList + j, sizeof(newChannelList) - j," %d",
8346 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i]);
8347 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08008348 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08008349
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008350 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8351 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
8352 newChannelList, oldChannelList,
8353 pMac->roam.neighborRoamInfo.neighborRoamState);
8354 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08008355 sme_ReleaseGlobalLock( &pMac->sme );
8356 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07008357#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8358 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8359 {
8360 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
8361 }
8362#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08008363
8364 return status ;
8365}
8366
8367/*--------------------------------------------------------------------------
Srinivas Girigowdade697412013-02-14 16:31:48 -08008368 \brief csrUpdateBgScanConfigIniChannelList() - Update bgscan roam cache
8369 This is a synchronous call
8370 \param hHal - The handle returned by macOpen.
8371 \return eHAL_STATUS_SUCCESS - SME update config successful.
8372 Other status means SME is failed to update
8373 \sa
8374 --------------------------------------------------------------------------*/
8375eHalStatus sme_UpdateBgScanConfigIniChannelList(tHalHandle hHal,
8376 eCsrBand eBand)
8377{
8378 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8379 return csrUpdateBgScanConfigIniChannelList(pMac, eBand);
8380}
8381
8382/*--------------------------------------------------------------------------
8383 \brief sme_getRoamScanChannelList() - get roam scan channel list
8384 This is a synchronous call
8385 \param hHal - The handle returned by macOpen.
8386 \return eHAL_STATUS_SUCCESS - SME update config successful.
8387 Other status means SME is failed to update
8388 \sa
8389 --------------------------------------------------------------------------*/
8390eHalStatus sme_getRoamScanChannelList(tHalHandle hHal, tANI_U8 *pChannelList,
8391 tANI_U8 *pNumChannels)
8392{
8393 int i = 0;
8394 tANI_U8 *pOutPtr = pChannelList;
8395 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8396 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8397 eHalStatus status = eHAL_STATUS_SUCCESS;
8398
8399 status = sme_AcquireGlobalLock( &pMac->sme );
8400 if ( HAL_STATUS_SUCCESS( status ) )
8401 {
8402 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
8403 {
8404 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
8405 "Roam Scan channel list is NOT yet initialized");
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008406 *pNumChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08008407 sme_ReleaseGlobalLock( &pMac->sme );
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008408 return status;
Srinivas Girigowdade697412013-02-14 16:31:48 -08008409 }
8410
8411 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
8412 for (i = 0; i < (*pNumChannels); i++)
8413 {
8414 pOutPtr[i] = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
8415 }
8416 pOutPtr[i] = '\0';
8417 sme_ReleaseGlobalLock( &pMac->sme );
8418 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08008419 return status ;
8420}
8421
8422/*--------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008423 \brief sme_getIsCcxFeatureEnabled() - get CCX feature enabled or not
8424 This is a synchronuous call
8425 \param hHal - The handle returned by macOpen.
8426 \return TRUE (1) - if the CCX feature is enabled
8427 FALSE (0) - if feature is disabled (compile or runtime)
8428 \sa
8429 --------------------------------------------------------------------------*/
8430tANI_BOOLEAN sme_getIsCcxFeatureEnabled(tHalHandle hHal)
Srinivas Girigowdade697412013-02-14 16:31:48 -08008431{
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008432#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdade697412013-02-14 16:31:48 -08008433 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008434 return pMac->roam.configParam.isCcxIniFeatureEnabled;
8435#else
8436 return eANI_BOOLEAN_FALSE;
8437#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -08008438}
8439
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008440/*--------------------------------------------------------------------------
Srinivas Girigowda100eb322013-03-15 16:48:20 -07008441 \brief sme_GetRoamScanControl() - get scan control
8442 This is a synchronous call
8443 \param hHal - The handle returned by macOpen.
8444 \return v_BOOL_t - Enabled(1)/Disabled(0)
8445 \sa
8446 --------------------------------------------------------------------------*/
8447v_BOOL_t sme_GetRoamScanControl(tHalHandle hHal)
8448{
8449 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8450 return pMac->roam.configParam.nRoamScanControl;
8451}
8452#endif
8453
8454/*--------------------------------------------------------------------------
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008455 \brief sme_getIsLfrFeatureEnabled() - get LFR feature enabled or not
8456 This is a synchronuous call
8457 \param hHal - The handle returned by macOpen.
8458 \return TRUE (1) - if the feature is enabled
8459 FALSE (0) - if feature is disabled (compile or runtime)
8460 \sa
8461 --------------------------------------------------------------------------*/
8462tANI_BOOLEAN sme_getIsLfrFeatureEnabled(tHalHandle hHal)
8463{
8464#ifdef FEATURE_WLAN_LFR
8465 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8466 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
8467#else
8468 return eANI_BOOLEAN_FALSE;
8469#endif
8470}
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08008471
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008472/*--------------------------------------------------------------------------
8473 \brief sme_getIsFtFeatureEnabled() - get FT feature enabled or not
8474 This is a synchronuous call
8475 \param hHal - The handle returned by macOpen.
8476 \return TRUE (1) - if the feature is enabled
8477 FALSE (0) - if feature is disabled (compile or runtime)
8478 \sa
8479 --------------------------------------------------------------------------*/
8480tANI_BOOLEAN sme_getIsFtFeatureEnabled(tHalHandle hHal)
8481{
8482#ifdef WLAN_FEATURE_VOWIFI_11R
8483 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8484 return pMac->roam.configParam.isFastTransitionEnabled;
8485#else
8486 return eANI_BOOLEAN_FALSE;
8487#endif
8488}
8489
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08008490
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008491/* ---------------------------------------------------------------------------
8492 \fn sme_IsFeatureSupportedByFW
8493 \brief Check if an feature is enabled by FW
8494
8495 \param feattEnumValue - Enumeration value from placeHolderInCapBitmap
8496 \- return 1/0 (TRUE/FALSE)
8497 -------------------------------------------------------------------------*/
8498tANI_U8 sme_IsFeatureSupportedByFW(tANI_U8 featEnumValue)
8499{
8500 return IS_FEATURE_SUPPORTED_BY_FW(featEnumValue);
8501}
8502#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308503
8504/* ---------------------------------------------------------------------------
8505 \fn sme_SendTdlsMgmtFrame
8506 \brief API to send TDLS management frames.
8507
8508 \param peerMac - peer's Mac Adress.
8509 \param tdlsLinkEstablishParams - TDLS Peer Link Establishment Parameters
8510 \- return VOS_STATUS_SUCCES
8511 -------------------------------------------------------------------------*/
8512VOS_STATUS sme_SendTdlsLinkEstablishParams(tHalHandle hHal,
8513 tANI_U8 sessionId,
8514 tSirMacAddr peerMac,
8515 tCsrTdlsLinkEstablishParams *tdlsLinkEstablishParams)
8516{
8517 eHalStatus status = eHAL_STATUS_SUCCESS;
8518 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8519
8520 status = sme_AcquireGlobalLock( &pMac->sme );
8521
8522 if ( HAL_STATUS_SUCCESS( status ) )
8523 {
8524 status = csrTdlsSendLinkEstablishParams(hHal, sessionId, peerMac, tdlsLinkEstablishParams) ;
8525 sme_ReleaseGlobalLock( &pMac->sme );
8526 }
8527 return status ;
8528}
8529
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008530/* ---------------------------------------------------------------------------
8531 \fn sme_SendTdlsMgmtFrame
8532 \brief API to send TDLS management frames.
8533
8534 \param peerMac - peer's Mac Adress.
8535 \param frame_type - Type of TDLS mgmt frame to be sent.
8536 \param dialog - dialog token used in the frame.
8537 \param status - status to be incuded in the frame.
8538 \param buf - additional IEs to be included
8539 \param len - lenght of additional Ies
Hoonki Leea34dd892013-02-05 22:56:02 -08008540 \param responder - Tdls request type
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008541 \- return VOS_STATUS_SUCCES
8542 -------------------------------------------------------------------------*/
8543VOS_STATUS sme_SendTdlsMgmtFrame(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
Hoonki Leea34dd892013-02-05 22:56:02 -08008544 tANI_U8 frame_type, tANI_U8 dialog, tANI_U16 statusCode, tANI_U8 *buf, tANI_U8 len, tANI_U8 responder)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008545{
8546 eHalStatus status = eHAL_STATUS_SUCCESS;
8547 tCsrTdlsSendMgmt sendTdlsReq = {{0}} ;
8548 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8549
8550 status = sme_AcquireGlobalLock( &pMac->sme );
8551 if ( HAL_STATUS_SUCCESS( status ) )
8552 {
8553 vos_mem_copy(sendTdlsReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
8554 sendTdlsReq.frameType = frame_type;
8555 sendTdlsReq.buf = buf;
8556 sendTdlsReq.len = len;
8557 sendTdlsReq.dialog = dialog;
8558 sendTdlsReq.statusCode = statusCode;
Hoonki Leea34dd892013-02-05 22:56:02 -08008559 sendTdlsReq.responder = responder;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008560
8561 status = csrTdlsSendMgmtReq(hHal, sessionId, &sendTdlsReq) ;
8562
8563 sme_ReleaseGlobalLock( &pMac->sme );
8564 }
8565
8566 return status ;
8567
8568}
8569/* ---------------------------------------------------------------------------
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008570 \fn sme_ChangeTdlsPeerSta
8571 \brief API to Update TDLS peer sta parameters.
8572
8573 \param peerMac - peer's Mac Adress.
8574 \param staParams - Peer Station Parameters
8575 \- return VOS_STATUS_SUCCES
8576 -------------------------------------------------------------------------*/
8577VOS_STATUS sme_ChangeTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac,
8578 tCsrStaParams *pstaParams)
8579{
8580 eHalStatus status = eHAL_STATUS_SUCCESS;
8581 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8582
8583 status = sme_AcquireGlobalLock( &pMac->sme );
8584 if ( HAL_STATUS_SUCCESS( status ) )
8585 {
8586 status = csrTdlsChangePeerSta(hHal, sessionId, peerMac,pstaParams);
8587
8588 sme_ReleaseGlobalLock( &pMac->sme );
8589 }
8590
8591 return status ;
8592
8593}
8594
8595/* ---------------------------------------------------------------------------
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008596 \fn sme_AddTdlsPeerSta
8597 \brief API to Add TDLS peer sta entry.
8598
8599 \param peerMac - peer's Mac Adress.
8600 \- return VOS_STATUS_SUCCES
8601 -------------------------------------------------------------------------*/
8602VOS_STATUS sme_AddTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8603{
8604 eHalStatus status = eHAL_STATUS_SUCCESS;
8605 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8606
8607 status = sme_AcquireGlobalLock( &pMac->sme );
8608 if ( HAL_STATUS_SUCCESS( status ) )
8609 {
8610 status = csrTdlsAddPeerSta(hHal, sessionId, peerMac);
8611
8612 sme_ReleaseGlobalLock( &pMac->sme );
8613 }
8614
8615 return status ;
8616
8617}
8618/* ---------------------------------------------------------------------------
8619 \fn sme_DeleteTdlsPeerSta
8620 \brief API to Delete TDLS peer sta entry.
8621
8622 \param peerMac - peer's Mac Adress.
8623 \- return VOS_STATUS_SUCCES
8624 -------------------------------------------------------------------------*/
8625VOS_STATUS sme_DeleteTdlsPeerSta(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8626{
8627 eHalStatus status = eHAL_STATUS_SUCCESS;
8628 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8629
8630 status = sme_AcquireGlobalLock( &pMac->sme );
8631 if ( HAL_STATUS_SUCCESS( status ) )
8632 {
8633 status = csrTdlsDelPeerSta(hHal, sessionId, peerMac) ;
8634
8635 sme_ReleaseGlobalLock( &pMac->sme );
8636 }
8637
8638 return status ;
8639
8640}
Gopichand Nakkala75e7b282013-03-15 18:37:13 -07008641/* ---------------------------------------------------------------------------
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008642 \fn sme_SetTdlsPowerSaveProhibited
8643 \API to set/reset the isTdlsPowerSaveProhibited.
8644
8645 \- return void
8646 -------------------------------------------------------------------------*/
8647void sme_SetTdlsPowerSaveProhibited(tHalHandle hHal, v_BOOL_t val)
8648{
8649 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8650
8651 pMac->isTdlsPowerSaveProhibited = val;
8652 return;
8653}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008654#endif
Gopichand Nakkalafe7246d2013-06-10 17:43:37 +05308655/* ---------------------------------------------------------------------------
8656 \fn sme_IsPmcBmps
8657 \API to Check if PMC state is BMPS.
8658
8659 \- return v_BOOL_t
8660 -------------------------------------------------------------------------*/
8661v_BOOL_t sme_IsPmcBmps(tHalHandle hHal)
8662{
8663 return (BMPS == pmcGetPmcState(hHal));
8664}
8665
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008666#ifdef FEATURE_WLAN_TDLS_INTERNAL
8667/*
8668 * SME API to start TDLS discovery Procedure
8669 */
8670VOS_STATUS sme_StartTdlsDiscoveryReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8671{
8672 VOS_STATUS status = VOS_STATUS_SUCCESS;
8673 tCsrTdlsDisRequest disReq = {{0}} ;
8674 vos_mem_copy(disReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
8675 status = csrTdlsDiscoveryReq(hHal, sessionId, &disReq) ;
8676
8677 return status ;
8678
8679}
8680
8681/*
8682 * Process TDLS discovery results
8683 */
8684v_U8_t sme_GetTdlsDiscoveryResult(tHalHandle hHal,
8685 tSmeTdlsDisResult *disResult, v_U8_t listType)
8686{
8687 tCsrTdlsPeerLinkinfo *peerLinkInfo = NULL ;
8688 tSirTdlsPeerInfo *peerInfo = NULL ;
8689 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8690 tCsrTdlsCtxStruct *disInfo = &pMac->tdlsCtx ;
8691 tDblLinkList *peerList = &disInfo->tdlsPotentialPeerList ;
8692 tListElem *pEntry = NULL ;
8693 v_U8_t peerCnt = 0 ;
8694
8695 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008696 ("TDLS peer count = %d"),disInfo->tdlsPeerCount ) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008697 pEntry = csrLLPeekHead( peerList, LL_ACCESS_LOCK );
8698 while(pEntry)
8699 {
8700 peerLinkInfo = GET_BASE_ADDR( pEntry, tCsrTdlsPeerLinkinfo,
8701 tdlsPeerStaLink) ;
8702 peerInfo = &peerLinkInfo->tdlsDisPeerInfo ;
8703
8704 switch(listType)
8705 {
8706 case TDLS_SETUP_LIST:
8707 {
8708 if(TDLS_LINK_SETUP_STATE == peerInfo->tdlsPeerState)
8709 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308710 vos_mem_copy(disResult[peerCnt].tdlsPeerMac,
8711 peerInfo->peerMac, sizeof(tSirMacAddr));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008712 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
8713 peerCnt++ ;
8714 }
8715 break ;
8716 }
8717 case TDLS_DIS_LIST:
8718 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308719 vos_mem_copy(disResult[peerCnt].tdlsPeerMac,
8720 peerInfo->peerMac, sizeof(tSirMacAddr));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008721 disResult[peerCnt].tdlsPeerRssi = peerInfo->tdlsPeerRssi ;
8722 peerCnt++ ;
8723 break ;
8724 }
8725 default:
8726 {
8727 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08008728 ("unknown list type ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008729 break ;
8730 }
8731 }
8732
8733 pEntry = csrLLNext( peerList, pEntry, LL_ACCESS_LOCK) ;
8734 }
8735
8736 return peerCnt ;
8737
8738}
8739
8740/*
8741 * SME API to start TDLS link setup Procedure.
8742 */
8743VOS_STATUS sme_StartTdlsLinkSetupReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8744{
8745 VOS_STATUS status = VOS_STATUS_SUCCESS;
8746 tCsrTdlsSetupRequest setupReq = {{0}} ;
8747 vos_mem_copy(setupReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
8748 status = csrTdlsSetupReq(hHal, sessionId, &setupReq) ;
8749 return status ;
8750
8751}
8752
8753/*
8754 * SME API to start TDLS link Teardown Procedure.
8755 */
8756VOS_STATUS sme_StartTdlsLinkTeardownReq(tHalHandle hHal, tANI_U8 sessionId, tSirMacAddr peerMac)
8757{
8758 VOS_STATUS status = VOS_STATUS_SUCCESS;
8759 tCsrTdlsTeardownRequest teardownReq = {{0}} ;
8760 vos_mem_copy(teardownReq.peerMac, peerMac, sizeof(tSirMacAddr)) ;
8761 status = csrTdlsTeardownReq(hHal, sessionId, &teardownReq) ;
8762 return status ;
8763
8764}
8765
8766#endif /* FEATURE_WLAN_TDLS */
8767
Tushnim Bhattacharyya9cdf6082013-04-21 16:33:30 -07008768eHalStatus sme_UpdateDfsSetting(tHalHandle hHal, tANI_U8 fUpdateEnableDFSChnlScan)
8769{
8770 eHalStatus status = eHAL_STATUS_FAILURE;
8771 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8772
8773 smsLog(pMac, LOG2, FL("enter"));
8774 status = sme_AcquireGlobalLock( &pMac->sme );
8775 if ( HAL_STATUS_SUCCESS( status ) )
8776 {
8777 pMac->scan.fEnableDFSChnlScan = fUpdateEnableDFSChnlScan;
8778 sme_ReleaseGlobalLock( &pMac->sme );
8779 }
8780 smsLog(pMac, LOG2, FL("exit status %d"), status);
8781
8782 return (status);
8783}
8784
Gopichand Nakkalae620d5a2013-04-26 05:45:57 -07008785/*
8786 * SME API to enable/disable WLAN driver initiated SSR
8787 */
8788void sme_UpdateEnableSSR(tHalHandle hHal, tANI_BOOLEAN enableSSR)
8789{
8790 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8791 eHalStatus status = eHAL_STATUS_SUCCESS;
8792
8793 status = sme_AcquireGlobalLock(&pMac->sme);
8794 if (HAL_STATUS_SUCCESS(status))
8795 {
8796 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
8797 "SSR level is changed %d", enableSSR);
8798 /* not serializing this messsage, as this is only going
8799 * to set a variable in WDA/WDI
8800 */
8801 WDA_SetEnableSSR(enableSSR);
8802 sme_ReleaseGlobalLock(&pMac->sme);
8803 }
8804 return;
8805}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07008806
8807/*
8808 * SME API to determine the channel bonding mode
8809 */
8810VOS_STATUS sme_SelectCBMode(tHalHandle hHal, eCsrPhyMode eCsrPhyMode, tANI_U8 channel)
8811{
8812 tSmeConfigParams smeConfig;
8813 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8814
8815 if (
8816#ifdef WLAN_FEATURE_11AC
8817 eCSR_DOT11_MODE_11ac != eCsrPhyMode &&
8818 eCSR_DOT11_MODE_11ac_ONLY != eCsrPhyMode &&
8819#endif
8820 eCSR_DOT11_MODE_11n != eCsrPhyMode &&
8821 eCSR_DOT11_MODE_11n_ONLY != eCsrPhyMode
8822 )
8823 {
8824 return VOS_STATUS_SUCCESS;
8825 }
8826
8827 /* If channel bonding mode is not required */
8828 if ( !pMac->roam.configParam.channelBondingMode5GHz ) {
8829 return VOS_STATUS_SUCCESS;
8830 }
8831
8832 vos_mem_zero(&smeConfig, sizeof (tSmeConfigParams));
8833 sme_GetConfigParam(pMac, &smeConfig);
8834
8835#ifdef WLAN_FEATURE_11AC
8836 if ( eCSR_DOT11_MODE_11ac == eCsrPhyMode ||
8837 eCSR_DOT11_MODE_11ac_ONLY == eCsrPhyMode )
8838 {
8839 if ( channel== 36 || channel == 52 || channel == 100 ||
8840 channel == 116 || channel == 149 )
8841 {
8842 smeConfig.csrConfig.channelBondingMode5GHz =
8843 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1;
8844 }
8845 else if ( channel == 40 || channel == 56 || channel == 104 ||
8846 channel == 120 || channel == 153 )
8847 {
8848 smeConfig.csrConfig.channelBondingMode5GHz =
8849 PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW - 1;
8850 }
8851 else if ( channel == 44 || channel == 60 || channel == 108 ||
8852 channel == 124 || channel == 157 )
8853 {
8854 smeConfig.csrConfig.channelBondingMode5GHz =
8855 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH -1;
8856 }
8857 else if ( channel == 48 || channel == 64 || channel == 112 ||
8858 channel == 128 || channel == 161 )
8859 {
8860 smeConfig.csrConfig.channelBondingMode5GHz =
8861 PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH - 1;
8862 }
8863 else if ( channel == 165 )
8864 {
8865 smeConfig.csrConfig.channelBondingMode5GHz = 0;
8866 }
8867 }
8868#endif
8869
8870 if ( eCSR_DOT11_MODE_11n == eCsrPhyMode ||
8871 eCSR_DOT11_MODE_11n_ONLY == eCsrPhyMode )
8872 {
8873 if ( channel== 40 || channel == 48 || channel == 56 ||
8874 channel == 64 || channel == 104 || channel == 112 ||
8875 channel == 120 || channel == 128 || channel == 136 ||
8876 channel == 144 || channel == 153 || channel == 161 )
8877 {
8878 smeConfig.csrConfig.channelBondingMode5GHz = 1;
8879 }
8880 else if ( channel== 36 || channel == 44 || channel == 52 ||
8881 channel == 60 || channel == 100 || channel == 108 ||
8882 channel == 116 || channel == 124 || channel == 132 ||
8883 channel == 140 || channel == 149 || channel == 157 )
8884 {
8885 smeConfig.csrConfig.channelBondingMode5GHz = 2;
8886 }
8887 else if ( channel == 165 )
8888 {
8889 smeConfig.csrConfig.channelBondingMode5GHz = 0;
8890 }
8891 }
8892 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8893 "cbmode selected=%ld\n", smeConfig.csrConfig.channelBondingMode5GHz);
8894
8895 sme_UpdateConfig (pMac, &smeConfig);
8896 return VOS_STATUS_SUCCESS;
8897}
8898
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -07008899/*--------------------------------------------------------------------------
8900
8901 \brief sme_SetCurrDeviceMode() - Sets the current operating device mode.
8902 \param hHal - The handle returned by macOpen.
8903 \param currDeviceMode - Current operating device mode.
8904 --------------------------------------------------------------------------*/
8905
8906void sme_SetCurrDeviceMode (tHalHandle hHal, tVOS_CON_MODE currDeviceMode)
8907{
8908 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8909 pMac->sme.currDeviceMode = currDeviceMode;
8910 return;
8911}
8912
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008913#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8914/*--------------------------------------------------------------------------
8915 \brief sme_HandoffRequest() - a wrapper function to Request a handoff
8916 from CSR.
8917 This is a synchronous call
8918 \param hHal - The handle returned by macOpen
8919 \param pHandoffInfo - info provided by HDD with the handoff request (namely:
8920 BSSID, channel etc.)
8921 \return eHAL_STATUS_SUCCESS - SME passed the request to CSR successfully.
8922 Other status means SME is failed to send the request.
8923 \sa
8924 --------------------------------------------------------------------------*/
8925
8926eHalStatus sme_HandoffRequest(tHalHandle hHal,
8927 tCsrHandoffRequest *pHandoffInfo)
8928{
8929 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8930 eHalStatus status = eHAL_STATUS_SUCCESS;
8931
8932 status = sme_AcquireGlobalLock( &pMac->sme );
8933 if ( HAL_STATUS_SUCCESS( status ) )
8934 {
8935 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
8936 "%s: invoked", __func__);
8937 status = csrHandoffRequest(pMac, pHandoffInfo);
8938 sme_ReleaseGlobalLock( &pMac->sme );
8939 }
8940
8941 return status ;
8942}
8943#endif
8944
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07008945/*
8946 * SME API to check if there is any infra station or
8947 * P2P client is connected
8948 */
8949VOS_STATUS sme_isSta_p2p_clientConnected(tHalHandle hHal)
8950{
8951 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
8952 if(csrIsInfraConnected(pMac))
8953 {
8954 return VOS_STATUS_SUCCESS;
8955 }
8956 return VOS_STATUS_E_FAILURE;
8957}
8958
Leo Chang9056f462013-08-01 19:21:11 -07008959
8960#ifdef FEATURE_WLAN_LPHB
8961/* ---------------------------------------------------------------------------
8962 \fn sme_LPHBConfigReq
8963 \API to make configuration LPHB within FW.
8964 \param hHal - The handle returned by macOpen
8965 \param lphdReq - LPHB request argument by client
8966 \param pCallbackfn - LPHB timeout notification callback function pointer
8967 \- return Configuration message posting status, SUCCESS or Fail
8968 -------------------------------------------------------------------------*/
8969eHalStatus sme_LPHBConfigReq
8970(
8971 tHalHandle hHal,
8972 tSirLPHBReq *lphdReq,
8973 void (*pCallbackfn)(void *pAdapter, void *indParam)
8974)
8975{
8976 eHalStatus status = eHAL_STATUS_SUCCESS;
8977 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
8978 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8979 vos_msg_t vosMessage;
8980
8981 status = sme_AcquireGlobalLock(&pMac->sme);
8982 if (eHAL_STATUS_SUCCESS == status)
8983 {
8984 if ((LPHB_SET_EN_PARAMS_INDID == lphdReq->cmd) &&
8985 (NULL == pCallbackfn) &&
Leo Changd9df8aa2013-09-26 13:32:26 -07008986 (NULL == pMac->sme.pLphbIndCb))
Leo Chang9056f462013-08-01 19:21:11 -07008987 {
8988 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
8989 "%s: Indication Call back did not registered", __func__);
8990 sme_ReleaseGlobalLock(&pMac->sme);
8991 return eHAL_STATUS_FAILURE;
8992 }
8993 else if (NULL != pCallbackfn)
8994 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008995 pMac->sme.pLphbIndCb = pCallbackfn;
Leo Chang9056f462013-08-01 19:21:11 -07008996 }
8997
8998 /* serialize the req through MC thread */
8999 vosMessage.bodyptr = lphdReq;
9000 vosMessage.type = WDA_LPHB_CONF_REQ;
9001 vosStatus = vos_mq_post_message(VOS_MQ_ID_WDA, &vosMessage);
9002 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
9003 {
9004 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9005 "%s: Post Config LPHB MSG fail", __func__);
9006 status = eHAL_STATUS_FAILURE;
9007 }
9008 sme_ReleaseGlobalLock(&pMac->sme);
9009 }
9010
9011 return(status);
9012}
9013#endif /* FEATURE_WLAN_LPHB */
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07009014/*--------------------------------------------------------------------------
9015 \brief sme_enable_disable_split_scan() - a wrapper function to set the split
9016 scan parameter.
9017 This is a synchronous call
9018 \param hHal - The handle returned by macOpen
9019 \return NONE.
9020 \sa
9021 --------------------------------------------------------------------------*/
9022void sme_enable_disable_split_scan (tHalHandle hHal, tANI_U8 nNumStaChan,
9023 tANI_U8 nNumP2PChan)
9024{
9025 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9026
9027 pMac->roam.configParam.nNumStaChanCombinedConc = nNumStaChan;
9028 pMac->roam.configParam.nNumP2PChanCombinedConc = nNumP2PChan;
9029
9030 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
9031 "%s: SCAN nNumStaChanCombinedConc : %d,"
9032 "nNumP2PChanCombinedConc : %d ",
9033 __func__, nNumStaChan, nNumP2PChan);
9034
9035 return;
9036
9037}
Leo Chang9056f462013-08-01 19:21:11 -07009038
Yue Mab9c86f42013-08-14 15:59:08 -07009039/* ---------------------------------------------------------------------------
9040 \fn sme_AddPeriodicTxPtrn
9041 \brief API to Periodic TX Pattern Offload feature
9042 \param hHal - The handle returned by macOpen
9043 \param addPeriodicTxPtrnParams - Pointer to the add pattern structure
9044 \return eHalStatus
9045 ---------------------------------------------------------------------------*/
9046eHalStatus sme_AddPeriodicTxPtrn(tHalHandle hHal, tSirAddPeriodicTxPtrn
9047 *addPeriodicTxPtrnParams)
9048{
9049 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9050 eHalStatus status;
9051 vos_msg_t msg;
9052
9053 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
9054 {
9055 msg.type = WDA_ADD_PERIODIC_TX_PTRN_IND;
9056 msg.bodyptr = addPeriodicTxPtrnParams;
9057
9058 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
9059 {
9060 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,"%s: Not able "
9061 "to post WDA_ADD_PERIODIC_TX_PTRN_IND to WDA!",
9062 __func__);
9063
9064 sme_ReleaseGlobalLock(&pMac->sme);
9065 return eHAL_STATUS_FAILURE;
9066 }
9067
9068 sme_ReleaseGlobalLock(&pMac->sme);
9069 return eHAL_STATUS_SUCCESS;
9070 }
9071
9072 return status;
9073}
9074
9075/* ---------------------------------------------------------------------------
9076 \fn sme_DelPeriodicTxPtrn
9077 \brief API to Periodic TX Pattern Offload feature
9078 \param hHal - The handle returned by macOpen
9079 \param delPeriodicTxPtrnParams - Pointer to the delete pattern structure
9080 \return eHalStatus
9081 ---------------------------------------------------------------------------*/
9082eHalStatus sme_DelPeriodicTxPtrn(tHalHandle hHal, tSirDelPeriodicTxPtrn
9083 *delPeriodicTxPtrnParams)
9084{
9085 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9086 eHalStatus status;
9087 vos_msg_t msg;
9088
9089 if (eHAL_STATUS_SUCCESS == (status = sme_AcquireGlobalLock(&pMac->sme)))
9090 {
9091 msg.type = WDA_DEL_PERIODIC_TX_PTRN_IND;
9092 msg.bodyptr = delPeriodicTxPtrnParams;
9093
9094 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
9095 {
9096 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,"%s: Not able "
9097 "to post WDA_DEL_PERIODIC_TX_PTRN_IND to WDA!",
9098 __func__);
9099
9100 sme_ReleaseGlobalLock(&pMac->sme);
9101 return eHAL_STATUS_FAILURE;
9102 }
9103
9104 sme_ReleaseGlobalLock(&pMac->sme);
9105 return eHAL_STATUS_SUCCESS;
9106 }
9107
9108 return status;
9109}
9110
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07009111void smeGetCommandQStatus( tHalHandle hHal )
9112{
9113 tSmeCmd *pTempCmd = NULL;
9114 tListElem *pEntry;
9115 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9116
9117 if (NULL == pMac)
9118 {
9119 smsLog( pMac, LOGE, "smeGetCommandQStatus: pMac is NULL" );
9120 return;
9121 }
9122
9123 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9124 if( pEntry )
9125 {
9126 pTempCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9127 }
9128 smsLog( pMac, LOGE, "Currently smeCmdActiveList has command (0x%X)",
9129 (pTempCmd) ? pTempCmd->command : eSmeNoCommand );
9130 if(pTempCmd)
9131 {
9132 if( eSmeCsrCommandMask & pTempCmd->command )
9133 {
9134 //CSR command is stuck. See what the reason code is for that command
9135 dumpCsrCommandInfo(pMac, pTempCmd);
9136 }
9137 } //if(pTempCmd)
9138
9139 smsLog( pMac, LOGE, "Currently smeCmdPendingList has %d commands",
9140 csrLLCount(&pMac->sme.smeCmdPendingList));
9141
9142 smsLog( pMac, LOGE, "Currently roamCmdPendingList has %d commands",
9143 csrLLCount(&pMac->roam.roamCmdPendingList));
9144
9145 return;
9146}
Rajeev79dbe4c2013-10-05 11:03:42 +05309147
9148#ifdef FEATURE_WLAN_BATCH_SCAN
9149/* ---------------------------------------------------------------------------
9150 \fn sme_SetBatchScanReq
9151 \brief API to set batch scan request in FW
9152 \param hHal - The handle returned by macOpen.
9153 \param pRequest - Pointer to the batch request.
9154 \param sessionId - session ID
9155 \param callbackRoutine - HDD callback which needs to be invoked after
9156 getting set batch scan response from FW
9157 \param callbackContext - pAdapter context
9158 \return eHalStatus
9159 ---------------------------------------------------------------------------*/
9160eHalStatus sme_SetBatchScanReq
9161(
9162 tHalHandle hHal, tSirSetBatchScanReq *pRequest, tANI_U8 sessionId,
9163 void (*callbackRoutine) (void *callbackCtx, tSirSetBatchScanRsp *pRsp),
9164 void *callbackContext
9165)
9166{
9167 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9168 eHalStatus status;
9169
9170 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
9171 {
9172 status = pmcSetBatchScanReq(hHal, pRequest, sessionId, callbackRoutine,
9173 callbackContext);
9174 sme_ReleaseGlobalLock( &pMac->sme );
9175 }
9176
9177 return status;
9178}
9179
9180/* ---------------------------------------------------------------------------
9181 \fn sme_TriggerBatchScanResultInd
9182 \brief API to trigger batch scan result indications from FW
9183 \param hHal - The handle returned by macOpen.
9184 \param pRequest - Pointer to get batch request.
9185 \param sessionId - session ID
9186 \param callbackRoutine - HDD callback which needs to be invoked after
9187 getting batch scan result indication from FW
9188 \param callbackContext - pAdapter context
9189 \return eHalStatus
9190 ---------------------------------------------------------------------------*/
9191eHalStatus sme_TriggerBatchScanResultInd
9192(
9193 tHalHandle hHal, tSirTriggerBatchScanResultInd *pRequest, tANI_U8 sessionId,
9194 void (*callbackRoutine) (void *callbackCtx, void *pRsp),
9195 void *callbackContext
9196)
9197{
9198 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9199 eHalStatus status;
9200
9201 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
9202 {
9203 status = pmcTriggerBatchScanResultInd(hHal, pRequest, sessionId,
9204 callbackRoutine, callbackContext);
9205 sme_ReleaseGlobalLock( &pMac->sme );
9206 }
9207
9208 return status;
9209}
9210
9211
9212/* ---------------------------------------------------------------------------
9213 \fn sme_StopBatchScanInd
9214 \brief API to stop batch scan request in FW
9215 \param hHal - The handle returned by macOpen.
9216 \param pRequest - Pointer to the batch request.
9217 \param sessionId - session ID
9218 \return eHalStatus
9219 ---------------------------------------------------------------------------*/
9220eHalStatus sme_StopBatchScanInd
9221(
9222 tHalHandle hHal, tSirStopBatchScanInd *pRequest, tANI_U8 sessionId
9223)
9224{
9225 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
9226 eHalStatus status;
9227
9228 if ( eHAL_STATUS_SUCCESS == ( status = sme_AcquireGlobalLock( &pMac->sme )))
9229 {
9230 status = pmcStopBatchScanInd(hHal, pRequest, sessionId);
9231 sme_ReleaseGlobalLock( &pMac->sme );
9232 }
9233
9234 return status;
9235}
9236
9237#endif